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 <surface.h> 25094332d3Sopenharmony_ci#include "display_format.h" 26094332d3Sopenharmony_ci#include "camera_metadata_info.h" 27094332d3Sopenharmony_ci#include "ibuffer.h" 28094332d3Sopenharmony_ci#include "iconsumer_surface.h" 29094332d3Sopenharmony_ci#include "v1_0/ioffline_stream_operator.h" 30094332d3Sopenharmony_ci#include "camera.h" 31094332d3Sopenharmony_ci#ifndef CAMERA_BUILT_ON_OHOS_LITE 32094332d3Sopenharmony_ci#include "if_system_ability_manager.h" 33094332d3Sopenharmony_ci#include "iservice_registry.h" 34094332d3Sopenharmony_ci#endif 35094332d3Sopenharmony_ci 36094332d3Sopenharmony_ci 37094332d3Sopenharmony_ciclass StreamCustomer { 38094332d3Sopenharmony_cipublic: 39094332d3Sopenharmony_ci StreamCustomer(); 40094332d3Sopenharmony_ci ~StreamCustomer(); 41094332d3Sopenharmony_ci#ifdef CAMERA_BUILT_ON_OHOS_LITE 42094332d3Sopenharmony_ci std::shared_ptr<OHOS::Surface> CreateProducer(); 43094332d3Sopenharmony_ci#else 44094332d3Sopenharmony_ci OHOS::sptr<OHOS::IBufferProducer> CreateProducer(); 45094332d3Sopenharmony_ci#endif 46094332d3Sopenharmony_ci void CamFrame(const std::function<void(const unsigned char *, const uint32_t)> callback); 47094332d3Sopenharmony_ci 48094332d3Sopenharmony_ci OHOS::Camera::RetCode ReceiveFrameOn(const std::function<void(const unsigned char *, const uint32_t)> callback); 49094332d3Sopenharmony_ci void ReceiveFrameOff(); 50094332d3Sopenharmony_ci 51094332d3Sopenharmony_ci#ifndef CAMERA_BUILT_ON_OHOS_LITE 52094332d3Sopenharmony_ci class TestBuffersConsumerListener : public OHOS::IBufferConsumerListener { 53094332d3Sopenharmony_ci public: 54094332d3Sopenharmony_ci TestBuffersConsumerListener() 55094332d3Sopenharmony_ci { 56094332d3Sopenharmony_ci } 57094332d3Sopenharmony_ci 58094332d3Sopenharmony_ci ~TestBuffersConsumerListener() 59094332d3Sopenharmony_ci { 60094332d3Sopenharmony_ci } 61094332d3Sopenharmony_ci 62094332d3Sopenharmony_ci void OnBufferAvailable() 63094332d3Sopenharmony_ci { 64094332d3Sopenharmony_ci } 65094332d3Sopenharmony_ci }; 66094332d3Sopenharmony_ci#endif 67094332d3Sopenharmony_ci 68094332d3Sopenharmony_ciprivate: 69094332d3Sopenharmony_ci unsigned int camFrameExit_ = 1; 70094332d3Sopenharmony_ci 71094332d3Sopenharmony_ci#ifdef CAMERA_BUILT_ON_OHOS_LITE 72094332d3Sopenharmony_ci std::shared_ptr<OHOS::Surface> consumer_ = nullptr; 73094332d3Sopenharmony_ci#else 74094332d3Sopenharmony_ci OHOS::sptr<OHOS::IConsumerSurface> consumer_ = nullptr; 75094332d3Sopenharmony_ci#endif 76094332d3Sopenharmony_ci std::thread* previewThreadId_ = nullptr; 77094332d3Sopenharmony_ci}; 78094332d3Sopenharmony_ci#endif // HOS_CAMERA_STREAM_CUSTOMER_H 79