1fa7767c5Sopenharmony_ci/* 2fa7767c5Sopenharmony_ci * Copyright (c) 2021-2021 Huawei Device Co., Ltd. 3fa7767c5Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4fa7767c5Sopenharmony_ci * you may not use this file except in compliance with the License. 5fa7767c5Sopenharmony_ci * You may obtain a copy of the License at 6fa7767c5Sopenharmony_ci * 7fa7767c5Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8fa7767c5Sopenharmony_ci * 9fa7767c5Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10fa7767c5Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11fa7767c5Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12fa7767c5Sopenharmony_ci * See the License for the specific language governing permissions and 13fa7767c5Sopenharmony_ci * limitations under the License. 14fa7767c5Sopenharmony_ci */ 15fa7767c5Sopenharmony_ci 16fa7767c5Sopenharmony_ci#ifndef HISTREAMER_FOUNDATION_AVBUFFER_QUEUE_H 17fa7767c5Sopenharmony_ci#define HISTREAMER_FOUNDATION_AVBUFFER_QUEUE_H 18fa7767c5Sopenharmony_ci 19fa7767c5Sopenharmony_ci#include "buffer/avbuffer_queue_define.h" 20fa7767c5Sopenharmony_ci#include "buffer/avbuffer_queue_producer.h" 21fa7767c5Sopenharmony_ci#include "buffer/avbuffer_queue_consumer.h" 22fa7767c5Sopenharmony_ci#include "surface.h" 23fa7767c5Sopenharmony_ci 24fa7767c5Sopenharmony_cinamespace OHOS { 25fa7767c5Sopenharmony_cinamespace Media { 26fa7767c5Sopenharmony_ci 27fa7767c5Sopenharmony_ciclass AVBufferQueue { 28fa7767c5Sopenharmony_cipublic: 29fa7767c5Sopenharmony_ci static std::shared_ptr<AVBufferQueue> Create(uint32_t size, MemoryType type = MemoryType::UNKNOWN_MEMORY, 30fa7767c5Sopenharmony_ci const std::string& name = "", bool disableAlloc = false); 31fa7767c5Sopenharmony_ci static std::shared_ptr<AVBufferQueue> CreateAsSurfaceProducer( 32fa7767c5Sopenharmony_ci sptr<Surface>& surface, const std::string& name = ""); 33fa7767c5Sopenharmony_ci static std::shared_ptr<AVBufferQueue> CreateAsSurfaceConsumer( 34fa7767c5Sopenharmony_ci sptr<Surface>& surface, const std::string& name = ""); 35fa7767c5Sopenharmony_ci 36fa7767c5Sopenharmony_ci AVBufferQueue() = default; 37fa7767c5Sopenharmony_ci virtual ~AVBufferQueue() = default; 38fa7767c5Sopenharmony_ci AVBufferQueue(const AVBufferQueue&) = delete; 39fa7767c5Sopenharmony_ci 40fa7767c5Sopenharmony_ci virtual std::shared_ptr<AVBufferQueueProducer> GetLocalProducer() = 0; 41fa7767c5Sopenharmony_ci virtual std::shared_ptr<AVBufferQueueConsumer> GetLocalConsumer() = 0; 42fa7767c5Sopenharmony_ci 43fa7767c5Sopenharmony_ci // 跨进程对象智能指针 44fa7767c5Sopenharmony_ci virtual sptr<AVBufferQueueProducer> GetProducer() = 0; 45fa7767c5Sopenharmony_ci virtual sptr<AVBufferQueueConsumer> GetConsumer() = 0; 46fa7767c5Sopenharmony_ci 47fa7767c5Sopenharmony_ci virtual sptr<Surface> GetSurfaceAsProducer() = 0; 48fa7767c5Sopenharmony_ci virtual sptr<Surface> GetSurfaceAsConsumer() = 0; 49fa7767c5Sopenharmony_ci 50fa7767c5Sopenharmony_ci virtual uint32_t GetQueueSize() = 0; 51fa7767c5Sopenharmony_ci virtual Status SetQueueSize(uint32_t size) = 0; 52fa7767c5Sopenharmony_ci virtual bool IsBufferInQueue(const std::shared_ptr<AVBuffer>& buffer) = 0; 53fa7767c5Sopenharmony_ci virtual Status Clear() = 0; 54fa7767c5Sopenharmony_ci virtual Status SetQueueSizeAndAttachBuffer(uint32_t size, std::shared_ptr<AVBuffer>& buffer, bool isFilled); 55fa7767c5Sopenharmony_ci}; 56fa7767c5Sopenharmony_ci 57fa7767c5Sopenharmony_ci} // namespace Media 58fa7767c5Sopenharmony_ci} // namespace OHOS 59fa7767c5Sopenharmony_ci 60fa7767c5Sopenharmony_ci#endif // HISTREAMER_FOUNDATION_AVBUFFER_QUEUE_H 61