• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *     http://www.apache.org/licenses/LICENSE-2.0
7  * Unless required by applicable law or agreed to in writing, software
8  * distributed under the License is distributed on an "AS IS" BASIS,
9  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10  * See the License for the specific language governing permissions and
11  * limitations under the License.
12  */
13 
14 #ifndef STREAM_PIPELINE_CORE_H
15 #define STREAM_PIPELINE_CORE_H
16 
17 #include "camera_metadata_info.h"
18 #include "istream_pipeline_core.h"
19 #include "stream_pipeline_builder.h"
20 #include "stream_pipeline_dispatcher.h"
21 #include "stream_pipeline_strategy.h"
22 #include <mutex>
23 
24 namespace OHOS::Camera {
25 class StreamPipelineCore : public IStreamPipelineCore {
26 public:
StreamPipelineCore(const std::shared_ptr<NodeContext> & c)27     explicit StreamPipelineCore(const std::shared_ptr<NodeContext>& c) : context_(c) {}
28     ~StreamPipelineCore() override = default;
29     RetCode Init() override;
30     RetCode PreConfig(const ModeMeta& meta) override;
31     RetCode CreatePipeline(const int32_t& mode) override;
32     RetCode DestroyPipeline(const std::vector<int32_t>& ids) override;
33     RetCode Prepare(const std::vector<int32_t>& ids) override;
34     RetCode Start(const std::vector<int32_t>& ids) override;
35     RetCode SetCallback(const MetaDataCb cb) override;
36     RetCode Flush(const std::vector<int32_t>& ids) override;
37     RetCode Stop(const std::vector<int32_t>& ids) override;
38     RetCode Config(const std::vector<int32_t>& ids, const CaptureMeta& meta) override;
39     RetCode UpdateSettingsConfig(const CaptureMeta& meta) override;
40     RetCode Capture(const std::vector<int32_t>& ids, const int32_t captureId) override;
41     RetCode CancelCapture(const std::vector<int>& streamIds) override;
42     std::shared_ptr<OfflinePipeline> GetOfflinePipeline(const int32_t id) override;
43     OperationMode GetCurrentMode() const override;
44     DynamicStreamSwitchMode CheckStreamsSupported(OperationMode mode,
45         const ModeMeta& meta, const std::vector<StreamConfiguration>& configs) override;
46 
47 protected:
48     std::recursive_mutex mutex_;
49     OperationMode mode_ = NORMAL;
50     std::shared_ptr<NodeContext> context_ = nullptr;
51     std::unique_ptr<StreamPipelineStrategy> strategy_ = nullptr;
52     std::unique_ptr<StreamPipelineBuilder> builder_ = nullptr;
53     std::unique_ptr<StreamPipelineDispatcher> dispatcher_ = nullptr;
54 };
55 } // namespace OHOS::Camera
56 #endif
57