1094332d3Sopenharmony_ci/*
2094332d3Sopenharmony_ci * Copyright (c) 2020 Huawei Device Co., Ltd.
3094332d3Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4094332d3Sopenharmony_ci * you may not use this file except in compliance with the License.
5094332d3Sopenharmony_ci * You may obtain a copy of the License at
6094332d3Sopenharmony_ci *
7094332d3Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8094332d3Sopenharmony_ci *
9094332d3Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10094332d3Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11094332d3Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12094332d3Sopenharmony_ci * See the License for the specific language governing permissions and
13094332d3Sopenharmony_ci * limitations under the License.
14094332d3Sopenharmony_ci */
15094332d3Sopenharmony_ci
16094332d3Sopenharmony_ci#ifndef HOS_CAMERA_STREAM_CUSTOMER_H
17094332d3Sopenharmony_ci#define HOS_CAMERA_STREAM_CUSTOMER_H
18094332d3Sopenharmony_ci
19094332d3Sopenharmony_ci#include <iostream>
20094332d3Sopenharmony_ci#include <thread>
21094332d3Sopenharmony_ci#include <vector>
22094332d3Sopenharmony_ci#include <map>
23094332d3Sopenharmony_ci#include <hdf_log.h>
24094332d3Sopenharmony_ci#include <iconsumer_surface.h>
25094332d3Sopenharmony_ci#include "display_format.h"
26094332d3Sopenharmony_ci#include "camera_metadata_info.h"
27094332d3Sopenharmony_ci#include "ibuffer.h"
28094332d3Sopenharmony_ci#include "v1_0/ioffline_stream_operator.h"
29094332d3Sopenharmony_ci#include "camera.h"
30094332d3Sopenharmony_ci#ifndef CAMERA_BUILT_ON_OHOS_LITE
31094332d3Sopenharmony_ci#include "if_system_ability_manager.h"
32094332d3Sopenharmony_ci#include "iservice_registry.h"
33094332d3Sopenharmony_ci#endif
34094332d3Sopenharmony_ci
35094332d3Sopenharmony_cinamespace OHOS::Camera {
36094332d3Sopenharmony_ciclass StreamCustomer {
37094332d3Sopenharmony_cipublic:
38094332d3Sopenharmony_ci    StreamCustomer();
39094332d3Sopenharmony_ci    ~StreamCustomer();
40094332d3Sopenharmony_ci#ifdef CAMERA_BUILT_ON_OHOS_LITE
41094332d3Sopenharmony_ci    std::shared_ptr<OHOS::Surface> CreateProducer();
42094332d3Sopenharmony_ci#else
43094332d3Sopenharmony_ci    sptr<OHOS::IBufferProducer> CreateProducer();
44094332d3Sopenharmony_ci#endif
45094332d3Sopenharmony_ci    void CamFrame(const std::function<void(void*, const uint32_t)> callback);
46094332d3Sopenharmony_ci
47094332d3Sopenharmony_ci    RetCode ReceiveFrameOn(const std::function<void(void*, const uint32_t)> callback);
48094332d3Sopenharmony_ci    void ReceiveFrameOff();
49094332d3Sopenharmony_ci
50094332d3Sopenharmony_ci#ifndef CAMERA_BUILT_ON_OHOS_LITE
51094332d3Sopenharmony_ci    class TestBuffersConsumerListener : public IBufferConsumerListener {
52094332d3Sopenharmony_ci    public:
53094332d3Sopenharmony_ci        TestBuffersConsumerListener()
54094332d3Sopenharmony_ci        {
55094332d3Sopenharmony_ci        }
56094332d3Sopenharmony_ci
57094332d3Sopenharmony_ci        ~TestBuffersConsumerListener()
58094332d3Sopenharmony_ci        {
59094332d3Sopenharmony_ci        }
60094332d3Sopenharmony_ci
61094332d3Sopenharmony_ci        void OnBufferAvailable()
62094332d3Sopenharmony_ci        {
63094332d3Sopenharmony_ci        }
64094332d3Sopenharmony_ci    };
65094332d3Sopenharmony_ci#endif
66094332d3Sopenharmony_ci
67094332d3Sopenharmony_ciprivate:
68094332d3Sopenharmony_ci    unsigned int camFrameExit_ = 1;
69094332d3Sopenharmony_ci
70094332d3Sopenharmony_ci#ifdef CAMERA_BUILT_ON_OHOS_LITE
71094332d3Sopenharmony_ci    std::shared_ptr<OHOS::Surface> consumer_ = nullptr;
72094332d3Sopenharmony_ci#else
73094332d3Sopenharmony_ci    sptr<OHOS::IConsumerSurface> consumer_ = nullptr;
74094332d3Sopenharmony_ci#endif
75094332d3Sopenharmony_ci    std::thread* previewThreadId_ = nullptr;
76094332d3Sopenharmony_ci};
77094332d3Sopenharmony_ci} // namespace OHOS::Camera
78094332d3Sopenharmony_ci#endif // HOS_CAMERA_STREAM_CUSTOMER_H
79