• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# AVSource
2
3
4## Overview
5
6The AVSource module provides functions for constructing audio and video resource objects.
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_avsource.h](native__avsource_8h.md) | Declares the native APIs used to construct audio and video resource objects.<br>**File to include**: <multimedia/player_framework/native_avsource.h><br>**Library**: libnative_media_avsource.so|
23
24
25### Functions
26
27| Name| Description|
28| -------- | -------- |
29| \*[OH_AVSource_CreateWithURI](#oh_avsource_createwithuri) (char \*uri) | Creates an **OH_AVSource** instance based on a URI.|
30| \*[OH_AVSource_CreateWithFD](#oh_avsource_createwithfd) (int32_t fd, int64_t offset, int64_t size) | Creates an **OH_AVSource** instance based on a file descriptor (FD).|
31| [OH_AVSource_Destroy](#oh_avsource_destroy) (OH_AVSource \*source) | Destroys an **OH_AVSource** instance and clears internal resources. An instance can be destroyed only once.|
32| \*[OH_AVSource_GetSourceFormat](#oh_avsource_getsourceformat) (OH_AVSource \*source) | Obtains the basic information about a media resource.|
33| \*[OH_AVSource_GetTrackFormat](#oh_avsource_gettrackformat) (OH_AVSource \*source, uint32_t trackIndex) | Obtains the basic information about a track.|
34
35
36## Function Description
37
38
39### OH_AVSource_CreateWithFD()
40
41
42```
43OH_AVSource* OH_AVSource_CreateWithFD (int32_t fd, int64_t offset, int64_t size)
44```
45
46**Description**
47
48Creates an **OH_AVSource** instance based on an FD.
49
50You can release the instance by calling **OH_AVSource_Destroy**.
51
52If **offset** is not the start position of the file or **size** is not the file size, undefined errors such as creation failure and decapsulation failure may occur due to incomplete data obtained.
53
54\@syscap SystemCapability.Multimedia.Media.Spliter
55
56**Parameters**
57
58| Name| Description|
59| -------- | -------- |
60| fd | FD of a media resource file.|
61| offset | Position from which data is to read.|
62| size | File size, in bytes.|
63
64**Returns**
65
66Returns the pointer to an **OH_AVSource** instance.
67
68**Since**
69
7010
71
72
73### OH_AVSource_CreateWithURI()
74
75
76```
77OH_AVSource* OH_AVSource_CreateWithURI (char *uri)
78```
79
80**Description**
81
82Create an **OH_AVSource** instance object based on a URI. You can release the instance by calling **OH_AVSource_Destroy**.
83
84\@syscap SystemCapability.Multimedia.Media.Spliter
85
86**Parameters**
87
88| Name| Description|
89| -------- | -------- |
90| uri | URI of the media resource.|
91
92**Returns**
93
94Returns the pointer to an **OH_AVSource** instance.
95
96**Since**
97
9810
99
100
101### OH_AVSource_Destroy()
102
103
104```
105OH_AVErrCode OH_AVSource_Destroy (OH_AVSource *source)
106```
107
108**Description**
109
110Destroys an **OH_AVSource** instance and clears internal resources.
111
112An instance can be destroyed only once.
113
114The destroyed instance cannot be used until it is re-created. You are advised to set the pointer to **NULL** after the instance is destroyed.
115
116\@syscap SystemCapability.Multimedia.Media.Spliter
117
118**Parameters**
119
120| Name| Description|
121| -------- | -------- |
122| source | Pointer to an **OH_AVSource** instance.|
123
124**Returns**
125
126Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise.
127
128**Since**
129
13010
131
132
133### OH_AVSource_GetSourceFormat()
134
135
136```
137OH_AVFormat* OH_AVSource_GetSourceFormat (OH_AVSource *source)
138```
139
140**Description**
141
142Obtains the basic information about a media resource.
143
144\@syscap SystemCapability.Multimedia.Media.Spliter
145
146**Parameters**
147
148| Name| Description|
149| -------- | -------- |
150| source | Pointer to an **OH_AVSource** instance.|
151
152**Returns**
153
154Returns the basic information obtained.
155
156**Since**
157
15810
159
160
161### OH_AVSource_GetTrackFormat()
162
163
164```
165OH_AVFormat* OH_AVSource_GetTrackFormat (OH_AVSource *source, uint32_t trackIndex)
166```
167
168**Description**
169
170Obtains the basic information about a track.
171
172\@syscap SystemCapability.Multimedia.Media.Spliter
173
174**Parameters**
175
176| Name| Description|
177| -------- | -------- |
178| source | Pointer to an **OH_AVSource** instance.|
179| trackIndex | Index of the track whose information is to be obtained.|
180
181**Returns**
182
183Returns the basic information obtained.
184
185**Since**
186
18710
188