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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
// automatically generated by rust-bindgen 0.71.1
#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(deprecated)]
#[cfg(feature = "api-11")]
#[allow(unused_imports)]
use crate::avbuffer::OH_AVBuffer;
#[allow(unused_imports)]
use crate::avbuffer_info::OH_AVCodecBufferAttr;
#[allow(unused_imports)]
use crate::avcodec_base::OH_AVOutputFormat;
#[allow(unused_imports)]
use crate::averrors::OH_AVErrCode;
#[allow(unused_imports)]
use crate::avformat::OH_AVFormat;
#[allow(unused_imports)]
use crate::avmemory::OH_AVMemory;
/// Forward declaration of OH_AVMuxer.
///
///
/// Available since API-level: 10
#[repr(C)]
pub struct OH_AVMuxer {
_unused: [u8; 0],
}
extern "C" {
/// Create an OH_AVMuxer instance by output file description and format.
///
/// Required System Capabilities: SystemCapability.Multimedia.Media.Muxer
/// # Arguments
///
/// * `fd` - Must be opened with read and write permission. Caller is responsible for closing fd.
///
/// * `format` - The output format is [`OH_AVOutputFormat`] .
///
/// # Returns
///
/// * Returns a pointer to an OH_AVMuxer instance, needs to be freed by OH_AVMuxer_Destroy.
///
/// Available since API-level: 10
pub fn OH_AVMuxer_Create(fd: i32, format: OH_AVOutputFormat) -> *mut OH_AVMuxer;
/// Set the rotation for output video playback.
/// Note: This interface can only be called before OH_AVMuxer_Start.
///
/// Required System Capabilities: SystemCapability.Multimedia.Media.Muxer
/// # Arguments
///
/// * `muxer` - Pointer to an OH_AVMuxer instance.
///
/// * `rotation` - The supported angles are 0, 90, 180, and 270 degrees.
///
/// # Returns
///
/// * Returns AV_ERR_OK if the execution is successful,
/// otherwise returns a specific error code, refer to [`OH_AVErrCode`]
/// [`AV_ERR_INVALID_VAL`], the muxer or rotation invalid.
/// [`AV_ERR_OPERATE_NOT_PERMIT`], not permit to call the interface, it was called in invalid state.
///
/// Available since API-level: 10
pub fn OH_AVMuxer_SetRotation(muxer: *mut OH_AVMuxer, rotation: i32) -> OH_AVErrCode;
/// Set format to the muxer.
///
///
/// Required System Capabilities: SystemCapability.Multimedia.Media.Muxer
/// # Arguments
///
/// * `muxer` - Pointer to an OH_AVMuxer instance
///
/// * `format` - OH_AVFormat handle pointer contain format
///
/// # Returns
///
/// * Returns AV_ERR_OK if the execution is successful
/// [`AV_ERR_INVALID_VAL`], the muxer or format is invalid
/// [`AV_ERR_OPERATE_NOT_PERMIT`], not permit to call the interface, it was called in invalid state
///
/// Available since API-level: 14
#[cfg(feature = "api-14")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-14")))]
pub fn OH_AVMuxer_SetFormat(muxer: *mut OH_AVMuxer, format: *mut OH_AVFormat) -> OH_AVErrCode;
/// Add track format to the muxer.
/// Note: This interface can only be called before OH_AVMuxer_Start.
///
/// Required System Capabilities: SystemCapability.Multimedia.Media.Muxer
/// # Arguments
///
/// * `muxer` - Pointer to an OH_AVMuxer instance
///
/// * `trackIndex` - The int32_t handle pointer used to get the track index for this newly added track,
/// and it should be used in the OH_AVMuxer_WriteSample. The track index is greater than or equal to 0,
/// others is error index.
///
/// * `trackFormat` - OH_AVFormat handle pointer contain track format
///
/// # Returns
///
/// * Returns AV_ERR_OK if the execution is successful,
/// otherwise returns a specific error code, refer to [`OH_AVErrCode`]
/// [`AV_ERR_INVALID_VAL`], the muxer or trackIndex or trackFormat invalid.
/// [`AV_ERR_OPERATE_NOT_PERMIT`], not permit to call the interface, it was called in invalid state.
/// [`AV_ERR_UNSUPPORT`], the mime type is not supported.
/// [`AV_ERR_NO_MEMORY`], failed to malloc memory.
/// [`AV_ERR_UNKNOWN`], unknown error.
///
/// Available since API-level: 10
pub fn OH_AVMuxer_AddTrack(
muxer: *mut OH_AVMuxer,
trackIndex: *mut i32,
trackFormat: *mut OH_AVFormat,
) -> OH_AVErrCode;
/// Start the muxer.
/// Note: This interface is called after OH_AVMuxer_AddTrack and before OH_AVMuxer_WriteSample.
///
/// Required System Capabilities: SystemCapability.Multimedia.Media.Muxer
/// # Arguments
///
/// * `muxer` - Pointer to an OH_AVMuxer instance
///
/// # Returns
///
/// * Returns AV_ERR_OK if the execution is successful,
/// otherwise returns a specific error code, refer to [`OH_AVErrCode`]
/// [`AV_ERR_INVALID_VAL`], the muxer invalid.
/// [`AV_ERR_OPERATE_NOT_PERMIT`], not permit to call the interface, it was called in invalid state.
/// [`AV_ERR_UNKNOWN`], unknown error.
///
/// Available since API-level: 10
pub fn OH_AVMuxer_Start(muxer: *mut OH_AVMuxer) -> OH_AVErrCode;
/// Write an encoded sample to the muxer.
/// Note: This interface can only be called after OH_AVMuxer_Start and before OH_AVMuxer_Stop. The application needs to
/// make sure that the samples are written to the right tacks. Also, it needs to make sure the samples for each track are
/// written in chronological order.
///
/// Required System Capabilities: SystemCapability.Multimedia.Media.Muxer
/// # Arguments
///
/// * `muxer` - Pointer to an OH_AVMuxer instance
///
/// * `trackIndex` - The track index for this sample
///
/// * `sample` - The encoded or demuxer sample
///
/// * `info` - The buffer information related to this sample [`OH_AVCodecBufferAttr`]
///
/// # Returns
///
/// * Returns AV_ERR_OK if the execution is successful,
/// otherwise returns a specific error code, refer to [`OH_AVErrCode`]
/// [`AV_ERR_INVALID_VAL`], the muxer or trackIndex or sample or info invalid.
/// [`AV_ERR_OPERATE_NOT_PERMIT`], not permit to call the interface, it was called in invalid state.
/// [`AV_ERR_NO_MEMORY`], failed to request memory.
/// [`AV_ERR_UNKNOWN`], unknown error.
///
/// **Deprecated** since 11
/// OH_AVMuxer_WriteSampleBuffer
///
/// Available since API-level: 10
#[deprecated(since = "11")]
pub fn OH_AVMuxer_WriteSample(
muxer: *mut OH_AVMuxer,
trackIndex: u32,
sample: *mut OH_AVMemory,
info: OH_AVCodecBufferAttr,
) -> OH_AVErrCode;
/// Write an encoded sample to the muxer.
/// Note: This interface can only be called after OH_AVMuxer_Start and before OH_AVMuxer_Stop. The application needs to
/// make sure that the samples are written to the right tracks. Also, it needs to make sure the samples for each track
/// are written in chronological order.
///
/// Required System Capabilities: SystemCapability.Multimedia.Media.Muxer
/// # Arguments
///
/// * `muxer` - Pointer to an OH_AVMuxer instance
///
/// * `trackIndex` - The track index for this sample
///
/// * `sample` - The encoded or demuxer sample, which including data and buffer information
///
/// # Returns
///
/// * Returns AV_ERR_OK if the execution is successful,
/// otherwise returns a specific error code, refer to [`OH_AVErrCode`]
/// [`AV_ERR_INVALID_VAL`], the muxer or trackIndex or sample invalid.
/// [`AV_ERR_OPERATE_NOT_PERMIT`], not permit to call the interface, it was called in invalid state.
/// [`AV_ERR_NO_MEMORY`], failed to request memory.
/// [`AV_ERR_UNKNOWN`], unknown error.
///
/// Available since API-level: 11
#[cfg(feature = "api-11")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
pub fn OH_AVMuxer_WriteSampleBuffer(
muxer: *mut OH_AVMuxer,
trackIndex: u32,
sample: *const OH_AVBuffer,
) -> OH_AVErrCode;
/// Stop the muxer.
/// Note: Once the muxer stops, it can not be restarted.
///
/// Required System Capabilities: SystemCapability.Multimedia.Media.Muxer
/// # Arguments
///
/// * `muxer` - Pointer to an OH_AVMuxer instance
///
/// # Returns
///
/// * Returns AV_ERR_OK if the execution is successful,
/// otherwise returns a specific error code, refer to [`OH_AVErrCode`]
/// [`AV_ERR_INVALID_VAL`], the muxer invalid.
/// [`AV_ERR_OPERATE_NOT_PERMIT`], not permit to call the interface, it was called in invalid state.
///
/// Available since API-level: 10
pub fn OH_AVMuxer_Stop(muxer: *mut OH_AVMuxer) -> OH_AVErrCode;
/// Clear the internal resources of the muxer and destroy the muxer instance
///
/// Required System Capabilities: SystemCapability.Multimedia.Media.Muxer
/// # Arguments
///
/// * `muxer` - Pointer to an OH_AVMuxer instance
///
/// # Returns
///
/// * Returns AV_ERR_OK if the execution is successful,
/// otherwise returns a specific error code, refer to [`OH_AVErrCode`]
/// [`AV_ERR_INVALID_VAL`], the muxer invalid.
///
/// Available since API-level: 10
pub fn OH_AVMuxer_Destroy(muxer: *mut OH_AVMuxer) -> OH_AVErrCode;
}