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 typedef struct OH_AVMemory OH_AVMemory; 49 50 /** 51 * @brief Create an OH_AVMemory instance 52 * @syscap SystemCapability.Multimedia.Media.Core 53 * @param size the memory's size, bytes. 54 * @return Returns a pointer to an OH_AVMemory instance for success, needs to be freed by OH_AVMemory_Destroy, 55 * otherwise returns NULL. 56 * @deprecated since 11 57 * @useinstead OH_AVBuffer_Create 58 * @since 10 59 */ 60 OH_AVMemory *OH_AVMemory_Create(int32_t size); 61 62 /** 63 * @brief Get the memory's virtual address 64 * @syscap SystemCapability.Multimedia.Media.Core 65 * @param mem Encapsulate OH_AVMemory structure instance pointer 66 * @return the memory's virtual address if the memory is valid, otherwise NULL. 67 * Possible failure causes: 68 * 1. input mem is NULL; 69 * 2. structure verification failed of the mem; 70 * 3. mem's memory is NULL. 71 * @deprecated since 11 72 * @useinstead OH_AVBuffer_GetAddr 73 * @since 9 74 * @version 1.0 75 */ 76 uint8_t *OH_AVMemory_GetAddr(struct OH_AVMemory *mem); 77 78 /** 79 * @brief Get the memory's size 80 * @syscap SystemCapability.Multimedia.Media.Core 81 * @param mem Encapsulate OH_AVMemory structure instance pointer 82 * @return the memory's size if the memory is valid, otherwise -1. 83 * Possible failure causes: 84 * 1. input mem is NULL; 85 * 2. structure verification failed of the mem; 86 * 3. mem's memory is NULL. 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} 102 * 1. input mem is NULL; 103 * 2. structure verification failed of the mem; 104 * 3. mem's memory is NULL. 105 * @deprecated since 11 106 * @useinstead OH_AVBuffer_Destroy 107 * @since 10 108 */ 109 OH_AVErrCode OH_AVMemory_Destroy(struct OH_AVMemory *mem); 110 111 #ifdef __cplusplus 112 } 113 #endif 114 115 #endif // NATIVE_AVMEMORY_H 116 /** @} */