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 Capture(const int32_t streamId, const int32_t captureId); 34 virtual RetCode CancelCapture(const int32_t streamId); 35 virtual RetCode Flush(const int32_t streamId); 36 virtual void SetCallback(const MetaDataCb cb); 37 virtual RetCode SetDispatcherCallback(); 38 virtual RetCode Stop(const int32_t streamId); 39 virtual RetCode Destroy(const int32_t streamId); 40 virtual std::shared_ptr<INode> GetNode(const int32_t streamId, const std::string name); 41 protected: 42 void GenerateNodeSeq(std::vector<std::shared_ptr<INode>>& nodeVec, 43 const std::shared_ptr<INode>& node); 44 45 void CutUselessBranch(int32_t streamId, std::vector<std::shared_ptr<INode>>& branch); 46 protected: 47 std::unordered_map<int, std::vector<std::shared_ptr<INode>>> seqNode_; 48 MetaDataCb metaDataCb_ = nullptr; 49 }; 50 } 51 #endif 52