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