• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# AVDemuxer
2
3
4## Overview
5
6The AVDemuxer module provides functions for audio and video decapsulation.
7
8\@syscap SystemCapability.Multimedia.Media.Spliter
9
10**Since**
11
1210
13
14
15## Summary
16
17
18### File
19
20| Name| Description|
21| -------- | -------- |
22| [native_avdemuxer.h](native__avdemuxer_8h.md) | Declares the native APIs used for audio and video decapsulation.<br>**File to include**: <multimedia/player_framework/native_avdemuxer.h><br>**Library**: libnative_media_avdemuxer.so|
23
24
25### Functions
26
27| Name| Description|
28| -------- | -------- |
29| \*[OH_AVDemuxer_CreateWithSource](#oh_avdemuxer_createwithsource) (OH_AVSource \*source) | Creates an **OH_AVDemuxer** instance based on an **OH_AVSource** instance.|
30| [OH_AVDemuxer_Destroy](#oh_avdemuxer_destroy) (OH_AVDemuxer \*demuxer) | Destroys an **OH_AVDemuxer** instance and clears internal resources.|
31| [OH_AVDemuxer_SelectTrackByID](#oh_avdemuxer_selecttrackbyid) (OH_AVDemuxer \*demuxer, uint32_t trackIndex) | Selects a track, from which the demuxer reads data.|
32| [OH_AVDemuxer_UnselectTrackByID](#oh_avdemuxer_unselecttrackbyid) (OH_AVDemuxer \*demuxer, uint32_t trackIndex) | Deselects a track. The demuxer no longer reads data from a track after it is deselected.|
33| [OH_AVDemuxer_ReadSample](#oh_avdemuxer_readsample) (OH_AVDemuxer \*demuxer, uint32_t trackIndex, OH_AVMemory \*sample, OH_AVCodecBufferAttr \*info) | Obtains the compressed frame and related information at the current position from the selected track.|
34| [OH_AVDemuxer_SeekToTime](#oh_avdemuxer_seektotime) (OH_AVDemuxer \*demuxer, int64_t millisecond, OH_AVSeekMode mode) | Seeks to the specified time for all the selected tracks based on a seek mode.|
35
36
37## Function Description
38
39
40### OH_AVDemuxer_CreateWithSource()
41
42
43```
44OH_AVDemuxer* OH_AVDemuxer_CreateWithSource (OH_AVSource *source)
45```
46
47**Description**
48
49Creates an **OH_AVDemuxer** instance based on an **OH_AVSource** instance. You can release the instance by calling **OH_AVDemuxer_Destroy**.
50
51\@syscap SystemCapability.Multimedia.Media.Spliter
52
53**Parameters**
54
55| Name| Description|
56| -------- | -------- |
57| source | Pointer to an **OH_AVSource** instance.|
58
59**Returns**
60
61Returns the pointer to an **OH_AVDemuxer** instance.
62
63**Since**
64
6510
66
67
68### OH_AVDemuxer_Destroy()
69
70
71```
72OH_AVErrCode OH_AVDemuxer_Destroy (OH_AVDemuxer *demuxer)
73```
74
75**Description**
76
77Destroys an **OH_AVDemuxer** instance and clears internal resources. An instance can be destroyed only once.
78
79The destroyed instance cannot be used until it is re-created. You are advised to set the pointer to **NULL** after the instance is destroyed.
80
81\@syscap SystemCapability.Multimedia.Media.Spliter
82
83**Parameters**
84
85| Name| Description|
86| -------- | -------- |
87| demuxer | Pointer to an **OH_AVDemuxer** instance.|
88
89**Returns**
90
91Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise.
92
93**Since**
94
9510
96
97
98### OH_AVDemuxer_ReadSample()
99
100
101```
102OH_AVErrCode OH_AVDemuxer_ReadSample (OH_AVDemuxer *demuxer, uint32_t trackIndex, OH_AVMemory *sample, OH_AVCodecBufferAttr *info)
103```
104
105**Description**
106
107Obtains the compressed frame and related information at the current position from the selected track.
108
109You must select a track before reading data. After this API is called, the demuxer automatically proceeds to the next frame.
110
111\@syscap SystemCapability.Multimedia.Media.Spliter
112
113**Parameters**
114
115| Name| Description|
116| -------- | -------- |
117| demuxer | Pointer to an **OH_AVDemuxer** instance.|
118| trackIndex | Index of the track from which the compressed frame is to be read.|
119| sample | Pointer to the **OH_AVMemory** instance for storing the compressed frame data.|
120| info | Pointer to the **OH_AVCodecBufferAttr** instance for storing the compressed frame information.|
121
122**Returns**
123
124Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise.
125
126**Since**
127
12810
129
130
131### OH_AVDemuxer_SeekToTime()
132
133
134```
135OH_AVErrCode OH_AVDemuxer_SeekToTime (OH_AVDemuxer *demuxer, int64_t millisecond, OH_AVSeekMode mode)
136```
137
138**Description**
139
140Seeks to the specified time for all the selected tracks based on a seek mode.
141
142\@syscap SystemCapability.Multimedia.Media.Spliter
143
144**Parameters**
145
146| Name| Description|
147| -------- | -------- |
148| demuxer | Pointer to an **OH_AVDemuxer** instance.|
149| millisecond | Time to seek to, in milliseconds. The timestamp is relative to the start position of the file.|
150| mode | Seek mode. For details, see **OH_AVSeekMode**.|
151
152**Returns**
153
154Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise.
155
156**Since**
157
15810
159
160
161### OH_AVDemuxer_SelectTrackByID()
162
163
164```
165OH_AVErrCode OH_AVDemuxer_SelectTrackByID (OH_AVDemuxer *demuxer, uint32_t trackIndex)
166```
167
168**Description**
169
170Selects a track, from which the demuxer reads data.
171
172You can select multiple tracks by calling this API multiple times, with a different track index passed in each time.
173
174When **OH_AVDemuxer_ReadSample** is called, only the data in the selected track is read. If the same track is selected multiple times, **AV_ERR_OK** is returned and the API call takes effect only once.
175
176\@syscap SystemCapability.Multimedia.Media.Spliter
177
178**Parameters**
179
180| Name| Description|
181| -------- | -------- |
182| demuxer | Pointer to an **OH_AVDemuxer** instance.|
183| trackIndex | Index of the track.|
184
185**Returns**
186
187Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise.
188
189**Since**
190
19110
192
193
194### OH_AVDemuxer_UnselectTrackByID()
195
196
197```
198OH_AVErrCode OH_AVDemuxer_UnselectTrackByID (OH_AVDemuxer *demuxer, uint32_t trackIndex)
199```
200
201**Description**
202
203Deselects a track. The demuxer no longer reads data from a track after it is deselected.
204
205You can deselect multiple tracks by calling this API multiple times, with a different track index passed in each time.
206
207If the same track is deselected multiple times, **AV_ERR_OK** is returned and the API call takes effect only once.
208
209\@syscap SystemCapability.Multimedia.Media.Spliter
210
211**Parameters**
212
213| Name| Description|
214| -------- | -------- |
215| demuxer | Pointer to an **OH_AVDemuxer** instance.|
216| trackIndex | Index of the track.|
217
218**Returns**
219
220Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise.
221
222**Since**
223
22410
225