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_avmemory.h 29 * 30 * @brief Declared the definition of media data structure AVMemory. 31 * 32 * @kit AVCodecKit 33 * @library libnative_media_core.so 34 * @syscap SystemCapability.Multimedia.Media.Core 35 * @since 9 36 */ 37 38 #ifndef NATIVE_AVMEMORY_H 39 #define NATIVE_AVMEMORY_H 40 41 #include <stdint.h> 42 #include "native_averrors.h" 43 44 #ifdef __cplusplus 45 extern "C" { 46 #endif 47 48 /** 49 * @brief Forward declaration of OH_AVFormat. 50 * 51 * @since 9 52 */ 53 typedef struct OH_AVMemory OH_AVMemory; 54 55 /** 56 * @brief Create an OH_AVMemory instance 57 * @syscap SystemCapability.Multimedia.Media.Core 58 * @param size the memory's size, bytes. 59 * @return Returns a pointer to an OH_AVMemory instance for success, needs to be freed by OH_AVMemory_Destroy, 60 * otherwise returns nullptr. Possible failure causes: 1. size <= 0. 2. create OH_AVMemory failed. 61 * 3.failed to new OH_AVMemory. 62 * @deprecated since 11 63 * @useinstead OH_AVBuffer_Create 64 * @since 10 65 */ 66 OH_AVMemory *OH_AVMemory_Create(int32_t size); 67 68 /** 69 * @brief Get the memory's virtual address 70 * @syscap SystemCapability.Multimedia.Media.Core 71 * @param mem Encapsulate OH_AVMemory structure instance pointer 72 * @return the memory's virtual address if the memory is valid, otherwise nullptr. 73 * Possible failure causes: 1. input mem is nullptr. 2. mem's magic error. 3. mem's memory is nullptr. 74 * @deprecated since 11 75 * @useinstead OH_AVBuffer_GetAddr 76 * @since 9 77 * @version 1.0 78 */ 79 uint8_t *OH_AVMemory_GetAddr(struct OH_AVMemory *mem); 80 81 /** 82 * @brief Get the memory's size 83 * @syscap SystemCapability.Multimedia.Media.Core 84 * @param mem Encapsulate OH_AVMemory structure instance pointer 85 * @return the memory's size if the memory is valid, otherwise -1. 86 * Possible failure causes: 1. input mem is nullptr. 2. mem's magic error. 3. mem's memory is nullptr. 87 * @deprecated since 11 88 * @useinstead OH_AVBuffer_GetCapacity 89 * @since 9 90 * @version 1.0 91 */ 92 int32_t OH_AVMemory_GetSize(struct OH_AVMemory *mem); 93 94 /** 95 * @brief Clear the internal resources of the memory and destroy the memory 96 * instance 97 * @syscap SystemCapability.Multimedia.Media.Core 98 * @param mem Encapsulate OH_AVMemory structure instance pointer 99 * @return Function result code. 100 * {@link AV_ERR_OK} if the execution is successful. 101 * {@link AV_ERR_INVALID_VAL} if input mem is nullptr, mem's magic error or input mem is not user created. 102 * @deprecated since 11 103 * @useinstead OH_AVBuffer_Destroy 104 * @since 10 105 */ 106 OH_AVErrCode OH_AVMemory_Destroy(struct OH_AVMemory *mem); 107 108 #ifdef __cplusplus 109 } 110 #endif 111 112 #endif // NATIVE_AVMEMORY_H 113 /** @} */ 114