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_DISPATCHER_H 15 #define STREAM_PIPELINE_DISPATCHER_H 16 #include <unordered_map> 17 #include "stream_pipeline_data_structure.h" 18 #include "inode.h" 19 #include "config_parser.h" 20 #include "no_copyable.h" 21 22 namespace OHOS::Camera { 23 24 class StreamPipelineDispatcher : public NoCopyable, private ConfigParser { 25 public: 26 StreamPipelineDispatcher() = default; 27 virtual ~StreamPipelineDispatcher() = default; 28 static std::unique_ptr<StreamPipelineDispatcher> Create(); 29 virtual RetCode Update(const std::shared_ptr<Pipeline>& p); 30 virtual RetCode Prepare(const int32_t streamId); 31 virtual RetCode Start(const int32_t streamId); 32 virtual RetCode Config(const int32_t streamId, const CaptureMeta& meta); 33 virtual RetCode UpdateSettingsConfig(const CaptureMeta& meta); 34 virtual RetCode Capture(const int32_t streamId, const int32_t captureId); 35 virtual RetCode CancelCapture(const int32_t streamId); 36 virtual RetCode Flush(const int32_t streamId); 37 virtual void SetCallback(const MetaDataCb cb); 38 virtual RetCode SetDispatcherCallback(); 39 virtual RetCode Stop(const int32_t streamId); 40 virtual RetCode Destroy(const int32_t streamId); 41 virtual std::shared_ptr<INode> GetNode(const int32_t streamId, const std::string name); 42 protected: 43 void GenerateNodeSeq(std::vector<std::shared_ptr<INode>>& nodeVec, 44 const std::shared_ptr<INode>& node); 45 46 void CutUselessBranch(int32_t streamId, std::vector<std::shared_ptr<INode>>& branch); 47 protected: 48 std::unordered_map<int, std::vector<std::shared_ptr<INode>>> seqNode_; 49 MetaDataCb metaDataCb_ = nullptr; 50 }; 51 } 52 #endif 53