• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_SOURCE_H
17 #define OHOS_DCAMERA_PIPELINE_SOURCE_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 DecodeDataProcess;
38 
39 class DCameraPipelineSource : public EventSender, public EventBusHandler<DCameraPipelineEvent>,
40     public IDataProcessPipeline, public std::enable_shared_from_this<DCameraPipelineSource> {
41 public:
42     ~DCameraPipelineSource();
43 
44     int32_t CreateDataProcessPipeline(PipelineType piplineType, const VideoConfigParams& sourceConfig,
45         const VideoConfigParams& targetConfig, const std::shared_ptr<DataProcessListener>& listener) override;
46     int32_t ProcessData(std::vector<std::shared_ptr<DataBuffer>>& dataBuffers) override;
47     void DestroyDataProcessPipeline() override;
48     void OnEvent(DCameraPipelineEvent& ev) override;
49 
50     void OnError(DataProcessErrorType errorType);
51     void OnProcessedVideoBuffer(const std::shared_ptr<DataBuffer>& videoResult);
52 
53 private:
54     bool IsInRange(const VideoConfigParams& curConfig);
55     void InitDCameraPipEvent();
56     int32_t InitDCameraPipNodes(const VideoConfigParams& sourceConfig, const VideoConfigParams& targetConfig);
57 
58 private:
59     const static std::string PIPELINE_OWNER;
60     constexpr static int32_t MIN_FRAME_RATE = 0;
61     constexpr static int32_t MAX_FRAME_RATE = 30;
62     constexpr static int32_t MIN_VIDEO_WIDTH = 320;
63     constexpr static int32_t MIN_VIDEO_HEIGHT = 240;
64     constexpr static int32_t MAX_VIDEO_WIDTH = 1920;
65     constexpr static int32_t MAX_VIDEO_HEIGHT = 1080;
66 
67     std::shared_ptr<DataProcessListener> processListener_ = nullptr;
68     std::shared_ptr<AbstractDataProcess> pipelineHead_ = nullptr;
69     std::shared_ptr<EventBus> eventBusSource_ = nullptr;
70 
71     bool isProcess_ = false;
72     PipelineType piplineType_ = PipelineType::VIDEO;
73     std::vector<std::shared_ptr<AbstractDataProcess>> pipNodeRanks_;
74 };
75 } // namespace DistributedHardware
76 } // namespace OHOS
77 #endif // OHOS_DCAMERA_PIPELINE_SOURCE_H
78