1/* 2 * Copyright (c) 2022 - 2023 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#include "stream_customer.h" 17 18#include "distributed_hardware_log.h" 19 20namespace OHOS { 21namespace DistributedHardware { 22StreamCustomer::StreamCustomer() {} 23StreamCustomer::~StreamCustomer() {} 24 25sptr<OHOS::IBufferProducer> StreamCustomer::CreateProducer(CaptureMode mode, 26 const std::function<void(void*, uint32_t)> callback) 27{ 28 consumer_ = OHOS::IConsumerSurface::Create(); 29 if (consumer_ == nullptr) { 30 return nullptr; 31 } 32 sptr<IBufferConsumerListener> listener = nullptr; 33 if (mode == CAPTURE_SNAPSHOT) { 34 listener = sptr<TestBuffersConsumerListener>(new TestBuffersConsumerListener(consumer_, callback)); 35 } else if (mode == CAPTURE_VIDEO) { 36 listener = sptr<TestBuffersConsumerListener>(new TestBuffersConsumerListener(consumer_, callback)); 37 } 38 consumer_->RegisterConsumerListener(listener); 39 40 auto producer = consumer_->GetProducer(); 41 if (producer == nullptr) { 42 return nullptr; 43 } 44 45 DHLOGI("demo test, create a buffer queue"); 46 return producer; 47} 48} 49}