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_STRATEGY_H 15 #define STREAM_PIPELINE_STRATEGY_H 16 17 #include "stream_pipeline_data_structure.h" 18 #include "host_stream_mgr.h" 19 #include "object_factory.h" 20 #include "config_parser.h" 21 #include "no_copyable.h" 22 23 namespace OHOS::Camera { 24 class StreamPipelineStrategy : public NoCopyable, private ConfigParser { 25 public: 26 static std::unique_ptr<StreamPipelineStrategy> Create(const std::shared_ptr<HostStreamMgr>& streamMgr); 27 virtual std::shared_ptr<PipelineSpec> GeneratePipelineSpec(const int32_t& mode); 28 virtual RetCode Destroy(const int32_t& streamType = -1); 29 StreamPipelineStrategy(const std::shared_ptr<HostStreamMgr>& streamMgr, 30 const std::shared_ptr<PipelineSpec>& spec); 31 virtual ~StreamPipelineStrategy() = default; 32 virtual RetCode CheckPipelineSpecExist(const int32_t mode, const std::vector<int32_t>& types); 33 PortFormat SetPortFormat(G_PIPELINE_SPEC_DATA_TYPE &pipeSpecPtr, const std::optional<int32_t>& typeId, 34 int j, int k, HostStreamInfo hostStreamInfo); 35 void InitPipeSpecPtr(G_PIPELINE_SPEC_DATA_TYPE &pipeSpecPtr, const std::string& keyStr); 36 37 protected: 38 virtual std::string ConstructKeyStrIndex(const int32_t& mode); 39 virtual RetCode SetUpBasicOutPortFormat(const PipelineSpec& pipe, const PortInfo& info, PortFormat& format); 40 virtual RetCode SetUpBasicInPortFormat(const NodeSpec& nodeSpec, PortFormat& format); 41 virtual RetCode SelectPipelineSpec(const int32_t& mode, PipelineSpec& pipe); 42 void PrintConnection(const NodeSpec& n); 43 RetCode CombineSpecs(PipelineSpec& pipe); 44 45 protected: 46 std::shared_ptr<HostStreamMgr> hostStreamMgr_ = nullptr; 47 std::shared_ptr<PipelineSpec> pipelineSpec_ = nullptr; 48 }; 49 } 50 #endif 51