• 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     StreamPipelineCore(const std::shared_ptr<NodeContext>& c) : context_(c) {}
28     virtual ~StreamPipelineCore() override = default;
29     virtual RetCode Init() override;
30     virtual RetCode PreConfig(const ModeMeta& meta) override;
31     virtual RetCode CreatePipeline(const int32_t& mode) override;
32     virtual RetCode DestroyPipeline(const std::vector<int32_t>& ids) override;
33     virtual RetCode Prepare(const std::vector<int32_t>& ids) override;
34     virtual RetCode Start(const std::vector<int32_t>& ids) override;
35     virtual RetCode Flush(const std::vector<int32_t>& ids) override;
36     virtual RetCode Stop(const std::vector<int32_t>& ids) override;
37     virtual RetCode Config(const std::vector<int32_t>& ids, const CaptureMeta& meta) override;
38     virtual RetCode Capture(const std::vector<int32_t>& ids, const int32_t captureId) override;
39     virtual RetCode CancelCapture(const std::vector<int>& streamIds) override;
40     virtual std::shared_ptr<OfflinePipeline> GetOfflinePipeline(const int32_t id) override;
41     virtual OperationMode GetCurrentMode() const override;
42     virtual DynamicStreamSwitchMode CheckStreamsSupported(OperationMode mode,
43         const ModeMeta& meta, const std::vector<StreamConfiguration>& configs) override;
44 
45 protected:
46     std::mutex mutex_;
47     OperationMode mode_ = NORMAL;
48     std::shared_ptr<NodeContext> context_ = nullptr;
49     std::unique_ptr<StreamPipelineStrategy> strategy_ = nullptr;
50     std::unique_ptr<StreamPipelineBuilder> builder_ = nullptr;
51     std::unique_ptr<StreamPipelineDispatcher> dispatcher_ = nullptr;
52 };
53 } // namespace OHOS::Camera
54 #endif
55