1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
// automatically generated by rust-bindgen 0.71.1
#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(deprecated)]
use crate::avbuffer_info::OH_AVCodecBufferAttr;
#[allow(unused_imports)]
use crate::averrors::OH_AVErrCode;
use crate::avformat::OH_AVFormat;
use ohos_sys_opaque_types::OH_NativeBuffer;
/// Forward declaration of OH_AVBuffer.
///
///
/// Available since API-level: 11
#[cfg(feature = "api-11")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
#[repr(C)]
pub struct OH_AVBuffer {
_unused: [u8; 0],
}
extern "C" {
/// Create an OH_AVBuffer instance, It should be noted that the life cycle of the OH_AVBuffer instance pointed
/// to by the return value * needs to be manually released by [`OH_AVBuffer_Destroy`].
///
/// Required System Capabilities: SystemCapability.Multimedia.Media.Core
/// # Arguments
///
/// * `capacity` - the buffer's capacity, bytes
///
/// # Returns
///
/// * Returns a pointer to an OH_AVBuffer instance if the execution is successful, otherwise returns nullptr.
/// Possible failure causes: 1. capacity <= 0. 2. create allocator failed. 3. create OH_AVBuffer failed.
/// 4. created buffer memory is nullptr. 5. created buffer memory's addr is nullptr. 6. failed to new OH_AVBuffer.
///
/// Available since API-level: 11
#[cfg(feature = "api-11")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
pub fn OH_AVBuffer_Create(capacity: i32) -> *mut OH_AVBuffer;
/// Clear the internal resources of the buffer and destroy the buffer instance.
///
/// Required System Capabilities: SystemCapability.Multimedia.Media.Core
/// # Arguments
///
/// * `buffer` - Encapsulate OH_AVBuffer structure instance pointer
///
/// # Returns
///
/// * Function result code.
/// [`AV_ERR_OK`] if the execution is successful.
/// [`AV_ERR_INVALID_VAL`] if input buffer is nullptr or buffer's magic error.
/// [`AV_ERR_OPERATE_NOT_PERMIT`] if input buffer is not user created.
///
/// Available since API-level: 11
#[cfg(feature = "api-11")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
pub fn OH_AVBuffer_Destroy(buffer: *mut OH_AVBuffer) -> OH_AVErrCode;
/// Get the buffer's attribute.
///
/// Required System Capabilities: SystemCapability.Multimedia.Media.Core
/// # Arguments
///
/// * `buffer` - Encapsulate OH_AVBuffer structure instance pointer
///
/// * `attr` - Encapsulate OH_AVCodecBufferAttr structure instance pointer, please refer to
/// [`OH_AVCodecBufferAttr`]
///
/// # Returns
///
/// * Function result code.
/// [`AV_ERR_OK`] if the execution is successful.
/// [`AV_ERR_INVALID_VAL`] if input buffer is nullptr, buffer's magic error,
/// input buffer's buffer is nulllptr or attr is nullptr.
///
/// Available since API-level: 11
#[cfg(feature = "api-11")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
pub fn OH_AVBuffer_GetBufferAttr(
buffer: *mut OH_AVBuffer,
attr: *mut OH_AVCodecBufferAttr,
) -> OH_AVErrCode;
/// Set the buffer's attribute.
///
/// Required System Capabilities: SystemCapability.Multimedia.Media.Core
/// # Arguments
///
/// * `buffer` - Encapsulate OH_AVBuffer structure instance pointer
///
/// * `attr` - Encapsulate OH_AVCodecBufferAttr structure instance pointer, please refer to
/// [`OH_AVCodecBufferAttr`]
///
/// # Returns
///
/// * Function result code.
/// [`AV_ERR_OK`] if the execution is successful.
/// [`AV_ERR_INVALID_VAL`] if input buffer is nullptr, buffer's magic error,
/// input buffer's buffer is nulllptr, attr is nullptr, the size or offset of input buffer's memory is invalid.
///
/// Available since API-level: 11
#[cfg(feature = "api-11")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
pub fn OH_AVBuffer_SetBufferAttr(
buffer: *mut OH_AVBuffer,
attr: *const OH_AVCodecBufferAttr,
) -> OH_AVErrCode;
/// Get the buffer's parameter. It should be noted that the life cycle of the OH_AVFormat instance pointed to
/// by the return value * needs to be manually released by [`OH_AVFormat_Destroy`].
///
/// Required System Capabilities: SystemCapability.Multimedia.Media.Core
/// # Arguments
///
/// * `buffer` - Encapsulate OH_AVBuffer structure instance pointer
///
/// # Returns
///
/// * Returns Encapsulate OH_AVFormat structure instance pointer if the execution is successful,
/// otherwise returns nullptr. Possible failure causes: 1. input buffer is nullptr. 2. buffer's magic error.
/// 3. input buffer's buffer is nulllptr. 4. buffer's meta is nullptr.
///
/// Available since API-level: 11
#[cfg(feature = "api-11")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
pub fn OH_AVBuffer_GetParameter(buffer: *mut OH_AVBuffer) -> *mut OH_AVFormat;
/// Set the buffer's parameter.
///
/// Required System Capabilities: SystemCapability.Multimedia.Media.Core
/// # Arguments
///
/// * `buffer` - Encapsulate OH_AVBuffer structure instance pointer
///
/// * `format` - Encapsulate OH_AVFormat structure instance pointer
///
/// # Returns
///
/// * Function result code.
/// [`AV_ERR_OK`] if the execution is successful.
/// [`AV_ERR_INVALID_VAL`] if input buffer is nullptr, buffer's magic error,
/// input buffer's buffer is nulllptr, input format is nullptr or input meta is nullptr.
///
/// Available since API-level: 11
#[cfg(feature = "api-11")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
pub fn OH_AVBuffer_SetParameter(
buffer: *mut OH_AVBuffer,
format: *const OH_AVFormat,
) -> OH_AVErrCode;
/// Get the buffer's virtual address.
///
/// Required System Capabilities: SystemCapability.Multimedia.Media.Core
/// # Arguments
///
/// * `buffer` - Encapsulate OH_AVBuffer structure instance pointer
///
/// # Returns
///
/// * the buffer's virtual address if the buffer is valid, otherwise nullptr
/// Possible failure causes: 1. input buffer is nullptr. 2. buffer's magic error.
/// 3. input buffer's buffer is nulllptr. 4. buffer's memory is nullptr.
///
/// Available since API-level: 11
#[cfg(feature = "api-11")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
pub fn OH_AVBuffer_GetAddr(buffer: *mut OH_AVBuffer) -> *mut u8;
/// Get the buffer's capacity
///
/// Required System Capabilities: SystemCapability.Multimedia.Media.Core
/// # Arguments
///
/// * `buffer` - Encapsulate OH_AVBuffer structure instance pointer
///
/// # Returns
///
/// * the buffer's capacity if the buffer is valid, otherwise -1
/// Possible failure causes: 1. input buffer is nullptr. 2. buffer's magic error.
/// 3. input buffer's buffer is nulllptr. 4. buffer's memory is nullptr.
///
/// Available since API-level: 11
#[cfg(feature = "api-11")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
pub fn OH_AVBuffer_GetCapacity(buffer: *mut OH_AVBuffer) -> i32;
/// Get the OH_NativeBuffer instance pointer,It should be noted that the life cycle of the OH_AVBuffer
/// instance pointed to by the return value * needs to be manually released by [`OH_NativeBuffer_Unreference`].
///
/// Required System Capabilities: SystemCapability.Multimedia.Media.Core
/// # Arguments
///
/// * `buffer` - Encapsulate OH_AVBuffer structure instance pointer
///
/// # Returns
///
/// * Returns Encapsulate OH_NativeBuffer structure instance pointer is successful, otherwise returns nullptr
/// Possible failure causes: 1. input buffer is nullptr. 2. buffer's magic error.
/// 3. input buffer's buffer is nulllptr. 4. buffer's memory is nullptr. 5. surfaceBuffer is nullptr.
///
/// Available since API-level: 11
#[cfg(feature = "api-11")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
pub fn OH_AVBuffer_GetNativeBuffer(buffer: *mut OH_AVBuffer) -> *mut OH_NativeBuffer;
}