1 /* 2 * Copyright (c) 2022 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 "event.h" 23 #include "event_bus.h" 24 #include "event_sender.h" 25 #include "eventbus_handler.h" 26 27 #include "data_buffer.h" 28 #include "image_common_type.h" 29 #include "distributed_camera_errno.h" 30 #include "dcamera_pipeline_event.h" 31 #include "idata_process_pipeline.h" 32 #include "abstract_data_process.h" 33 #include "data_process_listener.h" 34 35 namespace OHOS { 36 namespace DistributedHardware { 37 class EncodeDataProcess; 38 39 class DCameraPipelineSink : public IDataProcessPipeline, public std::enable_shared_from_this<DCameraPipelineSink> { 40 public: 41 ~DCameraPipelineSink(); 42 43 int32_t CreateDataProcessPipeline(PipelineType piplineType, const VideoConfigParams& sourceConfig, 44 const VideoConfigParams& targetConfig, const std::shared_ptr<DataProcessListener>& listener) override; 45 int32_t ProcessData(std::vector<std::shared_ptr<DataBuffer>>& dataBuffers) override; 46 void DestroyDataProcessPipeline() override; 47 48 void OnError(DataProcessErrorType errorType); 49 void OnProcessedVideoBuffer(const std::shared_ptr<DataBuffer>& videoResult); 50 51 private: 52 bool IsInRange(const VideoConfigParams& curConfig); 53 int32_t InitDCameraPipNodes(const VideoConfigParams& sourceConfig, const VideoConfigParams& targetConfig); 54 55 private: 56 const static std::string PIPELINE_OWNER; 57 constexpr static int32_t MIN_FRAME_RATE = 0; 58 constexpr static int32_t MAX_FRAME_RATE = 30; 59 constexpr static int32_t MIN_VIDEO_WIDTH = 320; 60 constexpr static int32_t MIN_VIDEO_HEIGHT = 240; 61 constexpr static int32_t MAX_VIDEO_WIDTH = 1920; 62 constexpr static int32_t MAX_VIDEO_HEIGHT = 1080; 63 64 std::shared_ptr<DataProcessListener> processListener_ = nullptr; 65 std::shared_ptr<AbstractDataProcess> pipelineHead_ = nullptr; 66 67 bool isProcess_ = false; 68 PipelineType piplineType_ = PipelineType::VIDEO; 69 std::vector<std::shared_ptr<AbstractDataProcess>> pipNodeRanks_; 70 }; 71 } // namespace DistributedHardware 72 } // namespace OHOS 73 #endif // OHOS_DCAMERA_PIPELINE_SINK_H 74