1 /* 2 * Copyright (c) 2021-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_STREAM_DATA_PROCESS_H 17 #define OHOS_DCAMERA_STREAM_DATA_PROCESS_H 18 19 #include <mutex> 20 #include <set> 21 22 #include "data_buffer.h" 23 #include "icamera_source_data_process.h" 24 #include "idata_process_pipeline.h" 25 #include "image_common_type.h" 26 #include "v1_1/dcamera_types.h" 27 28 #include "dcamera_stream_data_process_producer.h" 29 30 namespace OHOS { 31 namespace DistributedHardware { 32 using namespace OHOS::HDI::DistributedCamera::V1_1; 33 class DCameraStreamDataProcess : public std::enable_shared_from_this<DCameraStreamDataProcess> { 34 public: 35 DCameraStreamDataProcess(std::string devId, std::string dhId, DCStreamType streamType); 36 ~DCameraStreamDataProcess(); 37 void FeedStream(std::shared_ptr<DataBuffer>& buffer); 38 void ConfigStreams(std::shared_ptr<DCameraStreamConfig>& dstConfig, std::set<int32_t>& streamIds); 39 void ReleaseStreams(std::set<int32_t>& streamIds); 40 void StartCapture(std::shared_ptr<DCameraStreamConfig>& srcConfig, std::set<int32_t>& streamIds); 41 void StopCapture(std::set<int32_t>& streamIds); 42 void GetAllStreamIds(std::set<int32_t>& streamIds); 43 int32_t GetProducerSize(); 44 45 void OnProcessedVideoBuffer(const std::shared_ptr<DataBuffer>& videoResult); 46 void OnError(const DataProcessErrorType errorType); 47 void DestroyPipeline(); 48 49 private: 50 void FeedStreamToSnapShot(const std::shared_ptr<DataBuffer>& buffer); 51 void FeedStreamToContinue(const std::shared_ptr<DataBuffer>& buffer); 52 void CreatePipeline(); 53 VideoCodecType GetPipelineCodecType(DCEncodeType encodeType); 54 Videoformat GetPipelineFormat(int32_t format); 55 56 private: 57 std::string devId_; 58 std::string dhId_; 59 DCStreamType streamType_; 60 61 std::mutex pipelineMutex_; 62 std::mutex producerMutex_; 63 64 std::set<int32_t> streamIds_; 65 std::shared_ptr<DCameraStreamConfig> srcConfig_; 66 std::shared_ptr<DCameraStreamConfig> dstConfig_; 67 std::shared_ptr<IDataProcessPipeline> pipeline_; 68 std::shared_ptr<DataProcessListener> listener_; 69 std::map<uint32_t, std::shared_ptr<DCameraStreamDataProcessProducer>> producers_; 70 }; 71 } // namespace DistributedHardware 72 } // namespace OHOS 73 #endif // OHOS_DCAMERA_STREAM_DATA_PROCESS_H 74