1 /* 2 * Copyright (c) 2022-2024 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 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef OHOS_DCAMERA_PIPELINE_SINK_H 17 #define OHOS_DCAMERA_PIPELINE_SINK_H 18 19 #include <memory> 20 #include <vector> 21 22 #include "data_buffer.h" 23 #include "image_common_type.h" 24 #include "distributed_camera_errno.h" 25 #include "idata_process_pipeline.h" 26 #include "abstract_data_process.h" 27 #include "data_process_listener.h" 28 29 namespace OHOS { 30 namespace DistributedHardware { 31 class EncodeDataProcess; 32 33 class DCameraPipelineSink : public IDataProcessPipeline, public std::enable_shared_from_this<DCameraPipelineSink> { 34 public: 35 ~DCameraPipelineSink() override; 36 37 int32_t CreateDataProcessPipeline(PipelineType piplineType, const VideoConfigParams& sourceConfig, 38 const VideoConfigParams& targetConfig, const std::shared_ptr<DataProcessListener>& listener) override; 39 int32_t ProcessData(std::vector<std::shared_ptr<DataBuffer>>& dataBuffers) override; 40 void DestroyDataProcessPipeline() override; 41 42 void OnError(DataProcessErrorType errorType); 43 void OnProcessedVideoBuffer(const std::shared_ptr<DataBuffer>& videoResult); 44 45 int32_t GetProperty(const std::string& propertyName, PropertyCarrier& propertyCarrier) override; 46 47 private: 48 bool IsInRange(const VideoConfigParams& curConfig); 49 int32_t InitDCameraPipNodes(const VideoConfigParams& sourceConfig, const VideoConfigParams& targetConfig); 50 51 private: 52 const static std::string PIPELINE_OWNER; 53 constexpr static int32_t MIN_FRAME_RATE = 0; 54 constexpr static int32_t MAX_FRAME_RATE = 30; 55 constexpr static int32_t MIN_VIDEO_WIDTH = 320; 56 constexpr static int32_t MIN_VIDEO_HEIGHT = 240; 57 constexpr static int32_t MAX_VIDEO_WIDTH = 1920; 58 constexpr static int32_t MAX_VIDEO_HEIGHT = 1080; 59 60 std::shared_ptr<DataProcessListener> processListener_ = nullptr; 61 std::shared_ptr<AbstractDataProcess> pipelineHead_ = nullptr; 62 63 bool isProcess_ = false; 64 PipelineType piplineType_ = PipelineType::VIDEO; 65 std::vector<std::shared_ptr<AbstractDataProcess>> pipNodeRanks_; 66 }; 67 } // namespace DistributedHardware 68 } // namespace OHOS 69 #endif // OHOS_DCAMERA_PIPELINE_SINK_H 70