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 #ifndef NATIVE_AVMEMORY_H 17 #define NATIVE_AVMEMORY_H 18 19 #include <stdint.h> 20 #include "native_averrors.h" 21 22 #ifdef __cplusplus 23 extern "C" { 24 #endif 25 26 typedef struct OH_AVMemory OH_AVMemory; 27 28 /** 29 * @brief Create an OH_AVMemory instance 30 * @syscap SystemCapability.Multimedia.Media.Core 31 * @param size the memory's size, bytes. 32 * @return Returns a pointer to an OH_AVMemory instance, needs to be freed by OH_AVMemory_Destroy. 33 * @since 10 34 */ 35 OH_AVMemory *OH_AVMemory_Create(int32_t size); 36 37 /** 38 * @brief Get the memory's virtual address 39 * @syscap SystemCapability.Multimedia.Media.Core 40 * @param mem Encapsulate OH_AVMemory structure instance pointer 41 * @return the memory's virtual address if the memory is valid, otherwise nullptr. 42 * @since 9 43 * @version 1.0 44 */ 45 uint8_t *OH_AVMemory_GetAddr(struct OH_AVMemory *mem); 46 47 /** 48 * @brief Get the memory's size 49 * @syscap SystemCapability.Multimedia.Media.Core 50 * @param mem Encapsulate OH_AVMemory structure instance pointer 51 * @return the memory's size if the memory is valid, otherwise -1. 52 * @since 9 53 * @version 1.0 54 */ 55 int32_t OH_AVMemory_GetSize(struct OH_AVMemory *mem); 56 57 /** 58 * @brief Clear the internal resources of the memory and destroy the memory instance 59 * @syscap SystemCapability.Multimedia.Media.Core 60 * @param mem Encapsulate OH_AVMemory structure instance pointer 61 * @return Returns AV_ERR_OK if the execution is successful, 62 * otherwise returns a specific error code, refer to {@link OH_AVErrCode} 63 * @since 10 64 */ 65 OH_AVErrCode OH_AVMemory_Destroy(struct OH_AVMemory *mem); 66 67 #ifdef __cplusplus 68 } 69 #endif 70 71 #endif // NATIVE_AVMEMORY_H 72