1 /* 2 * Copyright (C) 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 /** 17 * @addtogroup Core 18 * @{ 19 * 20 * @brief The Core module provides basic backbone capabilities for media frameworks, 21 * including functions such as memory, error codes, and media data structures. 22 * 23 * @syscap SystemCapability.Multimedia.Media.Core 24 * @since 9 25 */ 26 27 /** 28 * @file native_avbuffer.h 29 * 30 * @brief Declared the function interface of media data structure AVBuffer. 31 * 32 * @library libnative_media_core.so 33 * @syscap SystemCapability.Multimedia.Media.Core 34 * @since 11 35 */ 36 37 #ifndef NATIVE_AVBUFFER_H 38 #define NATIVE_AVBUFFER_H 39 40 #include <stdint.h> 41 #include <stdio.h> 42 #include "native_avbuffer_info.h" 43 #include "native_averrors.h" 44 #include "native_avformat.h" 45 46 #ifdef __cplusplus 47 extern "C" { 48 #endif 49 typedef struct OH_AVBuffer OH_AVBuffer; 50 typedef struct OH_NativeBuffer OH_NativeBuffer; 51 52 /** 53 * @brief Create an OH_AVBuffer instance, It should be noted that the life cycle of the OH_AVBuffer instance pointed 54 * to by the return value * needs to be manually released by {@link OH_AVBuffer_Destroy}. 55 * @syscap SystemCapability.Multimedia.Media.Core 56 * @param capacity the buffer's capacity, bytes 57 * @return Returns a pointer to an OH_AVBuffer instance if the execution is successful, otherwise returns nullptr 58 * @since 11 59 */ 60 OH_AVBuffer *OH_AVBuffer_Create(int32_t capacity); 61 62 /** 63 * @brief Clear the internal resources of the buffer and destroy the buffer instance. 64 * @syscap SystemCapability.Multimedia.Media.Core 65 * @param buffer Encapsulate OH_AVBuffer structure instance pointer 66 * @return Returns AV_ERR_OK if the execution is successful, otherwise returns a specific error code, refer to 67 * {@link OH_AVErrCode} 68 * @since 11 69 */ 70 OH_AVErrCode OH_AVBuffer_Destroy(OH_AVBuffer *buffer); 71 72 /** 73 * @brief Get the buffer's attribute. 74 * @syscap SystemCapability.Multimedia.Media.Core 75 * @param buffer Encapsulate OH_AVBuffer structure instance pointer 76 * @param attr Encapsulate OH_AVCodecBufferAttr structure instance pointer, please refer to 77 * {@link OH_AVCodecBufferAttr} 78 * @return Returns AV_ERR_OK if the execution is successful, otherwise returns a specific error code, refer to 79 * {@link OH_AVErrCode} 80 * @since 11 81 */ 82 OH_AVErrCode OH_AVBuffer_GetBufferAttr(OH_AVBuffer *buffer, OH_AVCodecBufferAttr *attr); 83 84 /** 85 * @brief Set the buffer's attribute. 86 * @syscap SystemCapability.Multimedia.Media.Core 87 * @param buffer Encapsulate OH_AVBuffer structure instance pointer 88 * @param attr Encapsulate OH_AVCodecBufferAttr structure instance pointer, please refer to 89 * {@link OH_AVCodecBufferAttr} 90 * @return Returns AV_ERR_OK if the execution is successful, otherwise returns a specific error code, refer to 91 * {@link OH_AVErrCode} 92 * @since 11 93 */ 94 OH_AVErrCode OH_AVBuffer_SetBufferAttr(OH_AVBuffer *buffer, const OH_AVCodecBufferAttr *attr); 95 96 /** 97 * @brief Get the buffer's parameter. It should be noted that the life cycle of the OH_AVFormat instance pointed to 98 * by the return value * needs to be manually released by {@link OH_AVFormat_Destroy}. 99 * @syscap SystemCapability.Multimedia.Media.Core 100 * @param buffer Encapsulate OH_AVBuffer structure instance pointer 101 * @return Returns Encapsulate OH_AVFormat structure instance pointer if the execution is successful, 102 * otherwise returns nullptr 103 * @since 11 104 */ 105 OH_AVFormat *OH_AVBuffer_GetParameter(OH_AVBuffer *buffer); 106 107 /** 108 * @brief Set the buffer's parameter. 109 * @syscap SystemCapability.Multimedia.Media.Core 110 * @param buffer Encapsulate OH_AVBuffer structure instance pointer 111 * @param format Encapsulate OH_AVFormat structure instance pointer 112 * @return Returns AV_ERR_OK if the execution is successful, otherwise returns a specific error code, refer to 113 * {@link OH_AVErrCode} 114 * @since 11 115 */ 116 OH_AVErrCode OH_AVBuffer_SetParameter(OH_AVBuffer *buffer, const OH_AVFormat *format); 117 118 /** 119 * @brief Get the buffer's virtual address. 120 * @syscap SystemCapability.Multimedia.Media.Core 121 * @param buffer Encapsulate OH_AVBuffer structure instance pointer 122 * @return the buffer's virtual address if the buffer is valid, otherwise nullptr 123 * @since 11 124 */ 125 uint8_t *OH_AVBuffer_GetAddr(OH_AVBuffer *buffer); 126 127 /** 128 * @brief Get the buffer's capacity 129 * @syscap SystemCapability.Multimedia.Media.Core 130 * @param buffer Encapsulate OH_AVBuffer structure instance pointer 131 * @return the buffer's capacity if the buffer is valid, otherwise -1 132 * @since 11 133 */ 134 int32_t OH_AVBuffer_GetCapacity(OH_AVBuffer *buffer); 135 136 /** 137 * @brief Get the OH_NativeBuffer instance pointer,It should be noted that the life cycle of the OH_AVBuffer 138 * instance pointed to by the return value * needs to be manually released by {@link OH_NativeBuffer_Unreference}. 139 * @syscap SystemCapability.Multimedia.Media.Core 140 * @param buffer Encapsulate OH_AVBuffer structure instance pointer 141 * @return Returns Encapsulate OH_NativeBuffer structure instance pointer is successful, 142 * otherwise returns nullptr 143 * @since 11 144 */ 145 OH_NativeBuffer *OH_AVBuffer_GetNativeBuffer(OH_AVBuffer *buffer); 146 147 #ifdef __cplusplus 148 } 149 #endif 150 151 #endif // NATIVE_AVBUFFER_H 152 /** @} */