• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 HOS_CAMERA_STREAM_CUSTOMER_H
17 #define HOS_CAMERA_STREAM_CUSTOMER_H
18 
19 #include <iostream>
20 #include <thread>
21 #include <vector>
22 #include <map>
23 #include <hdf_log.h>
24 #include <surface.h>
25 #include <v1_0/display_composer_type.h>
26 #include "camera_metadata_info.h"
27 #include "ibuffer.h"
28 #include "iconsumer_surface.h"
29 #include "v1_0/ioffline_stream_operator.h"
30 #include "camera.h"
31 #ifndef CAMERA_BUILT_ON_OHOS_LITE
32 #include "if_system_ability_manager.h"
33 #include "iservice_registry.h"
34 #endif
35 
36 
37 class StreamCustomer {
38 public:
39     StreamCustomer();
40     ~StreamCustomer();
41 #ifdef CAMERA_BUILT_ON_OHOS_LITE
42     std::shared_ptr<OHOS::Surface> CreateProducer();
43 #else
44     OHOS::sptr<OHOS::IBufferProducer> CreateProducer();
45 #endif
46     void CamFrame(const std::function<void(const unsigned char *, const uint32_t)> callback);
47 
48     OHOS::Camera::RetCode ReceiveFrameOn(const std::function<void(const unsigned char *, const uint32_t)> callback);
49     void ReceiveFrameOff();
50 
51 #ifndef CAMERA_BUILT_ON_OHOS_LITE
52     class TestBuffersConsumerListener : public OHOS::IBufferConsumerListener {
53     public:
TestBuffersConsumerListener()54         TestBuffersConsumerListener()
55         {
56         }
57 
~TestBuffersConsumerListener()58         ~TestBuffersConsumerListener()
59         {
60         }
61 
OnBufferAvailable()62         void OnBufferAvailable()
63         {
64         }
65     };
66 #endif
67 
68 private:
69     unsigned int camFrameExit_ = 1;
70 
71 #ifdef CAMERA_BUILT_ON_OHOS_LITE
72     std::shared_ptr<OHOS::Surface> consumer_ = nullptr;
73 #else
74     OHOS::sptr<OHOS::IConsumerSurface> consumer_ = nullptr;
75 #endif
76     std::thread* previewThreadId_ = nullptr;
77 };
78 #endif // HOS_CAMERA_STREAM_CUSTOMER_H
79