1fa7767c5Sopenharmony_ci/* 2fa7767c5Sopenharmony_ci * Copyright (C) 2023 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 NATIVE_AVBUFFER_H 17fa7767c5Sopenharmony_ci#define NATIVE_AVBUFFER_H 18fa7767c5Sopenharmony_ci 19fa7767c5Sopenharmony_ci#include <stdint.h> 20fa7767c5Sopenharmony_ci#include <stdio.h> 21fa7767c5Sopenharmony_ci#include "native_avbuffer_info.h" 22fa7767c5Sopenharmony_ci#include "native_averrors.h" 23fa7767c5Sopenharmony_ci#include "native_avformat.h" 24fa7767c5Sopenharmony_ci 25fa7767c5Sopenharmony_ci#ifdef __cplusplus 26fa7767c5Sopenharmony_ciextern "C" { 27fa7767c5Sopenharmony_ci#endif 28fa7767c5Sopenharmony_citypedef struct OH_AVBuffer OH_AVBuffer; 29fa7767c5Sopenharmony_citypedef struct OH_NativeBuffer OH_NativeBuffer; 30fa7767c5Sopenharmony_ci 31fa7767c5Sopenharmony_ci/** 32fa7767c5Sopenharmony_ci * @brief Create an OH_AVBuffer instance, It should be noted that the life cycle of the OH_AVBuffer instance pointed 33fa7767c5Sopenharmony_ci * to by the return value * needs to be manually released by {@link OH_AVBuffer_Destroy}. 34fa7767c5Sopenharmony_ci * @syscap SystemCapability.Multimedia.Media.Core 35fa7767c5Sopenharmony_ci * @param capacity the buffer's capacity, bytes 36fa7767c5Sopenharmony_ci * @return Returns a pointer to an OH_AVBuffer instance if the execution is successful, otherwise returns nullptr 37fa7767c5Sopenharmony_ci * @since 11 38fa7767c5Sopenharmony_ci */ 39fa7767c5Sopenharmony_ciOH_AVBuffer *OH_AVBuffer_Create(int32_t capacity); 40fa7767c5Sopenharmony_ci 41fa7767c5Sopenharmony_ci/** 42fa7767c5Sopenharmony_ci * @brief Clear the internal resources of the buffer and destroy the buffer instance. 43fa7767c5Sopenharmony_ci * @syscap SystemCapability.Multimedia.Media.Core 44fa7767c5Sopenharmony_ci * @param buffer Encapsulate OH_AVBuffer structure instance pointer 45fa7767c5Sopenharmony_ci * @return Returns AV_ERR_OK if the execution is successful, otherwise returns a specific error code, refer to 46fa7767c5Sopenharmony_ci * {@link OH_AVErrCode} 47fa7767c5Sopenharmony_ci * @since 11 48fa7767c5Sopenharmony_ci */ 49fa7767c5Sopenharmony_ciOH_AVErrCode OH_AVBuffer_Destroy(OH_AVBuffer *buffer); 50fa7767c5Sopenharmony_ci 51fa7767c5Sopenharmony_ci/** 52fa7767c5Sopenharmony_ci * @brief Get the buffer's attribute. 53fa7767c5Sopenharmony_ci * @syscap SystemCapability.Multimedia.Media.Core 54fa7767c5Sopenharmony_ci * @param buffer Encapsulate OH_AVBuffer structure instance pointer 55fa7767c5Sopenharmony_ci * @param attr Encapsulate OH_AVCodecBufferAttr structure instance pointer, please refer to 56fa7767c5Sopenharmony_ci * {@link OH_AVCodecBufferAttr} 57fa7767c5Sopenharmony_ci * @return Returns AV_ERR_OK if the execution is successful, otherwise returns a specific error code, refer to 58fa7767c5Sopenharmony_ci * {@link OH_AVErrCode} 59fa7767c5Sopenharmony_ci * @since 11 60fa7767c5Sopenharmony_ci */ 61fa7767c5Sopenharmony_ciOH_AVErrCode OH_AVBuffer_GetBufferAttr(OH_AVBuffer *buffer, OH_AVCodecBufferAttr *attr); 62fa7767c5Sopenharmony_ci 63fa7767c5Sopenharmony_ci/** 64fa7767c5Sopenharmony_ci * @brief Set the buffer's attribute. 65fa7767c5Sopenharmony_ci * @syscap SystemCapability.Multimedia.Media.Core 66fa7767c5Sopenharmony_ci * @param buffer Encapsulate OH_AVBuffer structure instance pointer 67fa7767c5Sopenharmony_ci * @param attr Encapsulate OH_AVCodecBufferAttr structure instance pointer, please refer to 68fa7767c5Sopenharmony_ci * {@link OH_AVCodecBufferAttr} 69fa7767c5Sopenharmony_ci * @return Returns AV_ERR_OK if the execution is successful, otherwise returns a specific error code, refer to 70fa7767c5Sopenharmony_ci * {@link OH_AVErrCode} 71fa7767c5Sopenharmony_ci * @since 11 72fa7767c5Sopenharmony_ci */ 73fa7767c5Sopenharmony_ciOH_AVErrCode OH_AVBuffer_SetBufferAttr(OH_AVBuffer *buffer, const OH_AVCodecBufferAttr *attr); 74fa7767c5Sopenharmony_ci 75fa7767c5Sopenharmony_ci/** 76fa7767c5Sopenharmony_ci * @brief Get the buffer's parameter. It should be noted that the life cycle of the OH_AVFormat instance pointed to 77fa7767c5Sopenharmony_ci * by the return value * needs to be manually released by {@link OH_AVFormat_Destroy}. 78fa7767c5Sopenharmony_ci * @syscap SystemCapability.Multimedia.Media.Core 79fa7767c5Sopenharmony_ci * @param buffer Encapsulate OH_AVBuffer structure instance pointer 80fa7767c5Sopenharmony_ci * @return Returns Encapsulate OH_AVFormat structure instance pointer if the execution is successful, 81fa7767c5Sopenharmony_ci * otherwise returns nullptr 82fa7767c5Sopenharmony_ci * @since 11 83fa7767c5Sopenharmony_ci */ 84fa7767c5Sopenharmony_ciOH_AVFormat *OH_AVBuffer_GetParameter(OH_AVBuffer *buffer); 85fa7767c5Sopenharmony_ci 86fa7767c5Sopenharmony_ci/** 87fa7767c5Sopenharmony_ci * @brief Set the buffer's parameter. 88fa7767c5Sopenharmony_ci * @syscap SystemCapability.Multimedia.Media.Core 89fa7767c5Sopenharmony_ci * @param buffer Encapsulate OH_AVBuffer structure instance pointer 90fa7767c5Sopenharmony_ci * @param format Encapsulate OH_AVFormat structure instance pointer 91fa7767c5Sopenharmony_ci * @return Returns AV_ERR_OK if the execution is successful, otherwise returns a specific error code, refer to 92fa7767c5Sopenharmony_ci * {@link OH_AVErrCode} 93fa7767c5Sopenharmony_ci * @since 11 94fa7767c5Sopenharmony_ci */ 95fa7767c5Sopenharmony_ciOH_AVErrCode OH_AVBuffer_SetParameter(OH_AVBuffer *buffer, const OH_AVFormat *format); 96fa7767c5Sopenharmony_ci 97fa7767c5Sopenharmony_ci/** 98fa7767c5Sopenharmony_ci * @brief Get the buffer's virtual address. 99fa7767c5Sopenharmony_ci * @syscap SystemCapability.Multimedia.Media.Core 100fa7767c5Sopenharmony_ci * @param buffer Encapsulate OH_AVBuffer structure instance pointer 101fa7767c5Sopenharmony_ci * @return the buffer's virtual address if the buffer is valid, otherwise nullptr 102fa7767c5Sopenharmony_ci * @since 11 103fa7767c5Sopenharmony_ci */ 104fa7767c5Sopenharmony_ciuint8_t *OH_AVBuffer_GetAddr(OH_AVBuffer *buffer); 105fa7767c5Sopenharmony_ci 106fa7767c5Sopenharmony_ci/** 107fa7767c5Sopenharmony_ci * @brief Get the buffer's capacity 108fa7767c5Sopenharmony_ci * @syscap SystemCapability.Multimedia.Media.Core 109fa7767c5Sopenharmony_ci * @param buffer Encapsulate OH_AVBuffer structure instance pointer 110fa7767c5Sopenharmony_ci * @return the buffer's capacity if the buffer is valid, otherwise -1 111fa7767c5Sopenharmony_ci * @since 11 112fa7767c5Sopenharmony_ci */ 113fa7767c5Sopenharmony_ciint32_t OH_AVBuffer_GetCapacity(OH_AVBuffer *buffer); 114fa7767c5Sopenharmony_ci 115fa7767c5Sopenharmony_ci/** 116fa7767c5Sopenharmony_ci * @brief Get the OH_NativeBuffer instance pointer,It should be noted that the life cycle of the OH_AVBuffer 117fa7767c5Sopenharmony_ci * instance pointed to by the return value * needs to be manually released by {@link OH_NativeBuffer_Unreference}. 118fa7767c5Sopenharmony_ci * @syscap SystemCapability.Multimedia.Media.Core 119fa7767c5Sopenharmony_ci * @param buffer Encapsulate OH_AVBuffer structure instance pointer 120fa7767c5Sopenharmony_ci * @return Returns Encapsulate OH_NativeBuffer structure instance pointer is successful, 121fa7767c5Sopenharmony_ci * otherwise returns nullptr 122fa7767c5Sopenharmony_ci * @since 11 123fa7767c5Sopenharmony_ci */ 124fa7767c5Sopenharmony_ciOH_NativeBuffer *OH_AVBuffer_GetNativeBuffer(OH_AVBuffer *buffer); 125fa7767c5Sopenharmony_ci 126fa7767c5Sopenharmony_ci#ifdef __cplusplus 127fa7767c5Sopenharmony_ci} 128fa7767c5Sopenharmony_ci#endif 129fa7767c5Sopenharmony_ci 130fa7767c5Sopenharmony_ci#endif // NATIVE_AVBUFFER_H 131