• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# avrecorder_base.h
2<!--Kit: Media Kit-->
3<!--Subsystem: Multimedia-->
4<!--Owner: @shiwei75-->
5<!--Designer: @HmQQQ-->
6<!--Tester: @xdlinc-->
7<!--Adviser: @zengyawen-->
8
9## 概述
10
11定义了媒体AVRecorder的结构体和枚举。
12
13**引用文件:** <multimedia/player_framework/avrecorder_base.h>
14
15**库:** libavrecorder.so
16
17**系统能力:** SystemCapability.Multimedia.Media.AVRecorder
18
19**起始版本:** 18
20
21**相关模块:** [AVRecorder](capi-avrecorder.md)
22
23## 汇总
24
25### 结构体
26
27| 名称 | typedef关键字 | 描述 |
28| -- | -- | -- |
29| [OH_AVRecorder_Profile](capi-avrecorder-oh-avrecorder-profile.md) | OH_AVRecorder_Profile | 定义音视频录制的详细参数。 |
30| [OH_AVRecorder](capi-avrecorder-oh-avrecorder.md) | OH_AVRecorder | 初始化AVRecorder。 |
31| [OH_AVRecorder_Location](capi-avrecorder-oh-avrecorder-location.md) | OH_AVRecorder_Location | 提供媒体资源的地理位置信息。 |
32| [OH_AVRecorder_MetadataTemplate](capi-avrecorder-oh-avrecorder-metadatatemplate.md) | OH_AVRecorder_MetadataTemplate | 定义元数据的基本模板。 |
33| [OH_AVRecorder_Metadata](capi-avrecorder-oh-avrecorder-metadata.md) | OH_AVRecorder_Metadata | 元数据信息数据结构。 |
34| [OH_AVRecorder_Config](capi-avrecorder-oh-avrecorder-config.md) | OH_AVRecorder_Config | 提供媒体AVRecorder的配置定义。 |
35| [OH_AVRecorder_Range](capi-avrecorder-oh-avrecorder-range.md) | OH_AVRecorder_Range | 表示类型的范围。 |
36| [OH_AVRecorder_EncoderInfo](capi-avrecorder-oh-avrecorder-encoderinfo.md) | OH_AVRecorder_EncoderInfo | 提供编码器信息。 |
37
38### 枚举
39
40| 名称 | typedef关键字 | 描述 |
41| -- | -- | -- |
42| [OH_AVRecorder_AudioSourceType](#oh_avrecorder_audiosourcetype) | OH_AVRecorder_AudioSourceType | AVRecorder的音频源类型。 |
43| [OH_AVRecorder_VideoSourceType](#oh_avrecorder_videosourcetype) | OH_AVRecorder_VideoSourceType | AVRecorder的视频源类型。 |
44| [OH_AVRecorder_CodecMimeType](#oh_avrecorder_codecmimetype) | OH_AVRecorder_CodecMimeType | 编码器MIME类型。 |
45| [OH_AVRecorder_ContainerFormatType](#oh_avrecorder_containerformattype) | OH_AVRecorder_ContainerFormatType | 容器格式类型(容器格式类型的缩写是 CFT)。 |
46| [OH_AVRecorder_State](#oh_avrecorder_state) | OH_AVRecorder_State | AVRecorder状态。 |
47| [OH_AVRecorder_StateChangeReason](#oh_avrecorder_statechangereason) | OH_AVRecorder_StateChangeReason | AVRecorder状态变化的原因。 |
48| [OH_AVRecorder_FileGenerationMode](#oh_avrecorder_filegenerationmode) | OH_AVRecorder_FileGenerationMode | 创建录制文件的模式。 |
49
50### 函数
51
52| 名称 | typedef关键字 | 描述 |
53| -- | -- | -- |
54| [typedef void (\*OH_AVRecorder_OnStateChange)(OH_AVRecorder *recorder, OH_AVRecorder_State state, OH_AVRecorder_StateChangeReason reason, void *userData)](#oh_avrecorder_onstatechange) | OH_AVRecorder_OnStateChange | 当录制状态发生变化时调用。 |
55| [typedef void (\*OH_AVRecorder_OnError)(OH_AVRecorder *recorder, int32_t errorCode, const char *errorMsg, void *userData)](#oh_avrecorder_onerror) | OH_AVRecorder_OnError | 当录制过程中发生错误时调用。 |
56| [typedef void (\*OH_AVRecorder_OnUri)(OH_AVRecorder *recorder, OH_MediaAsset *asset, void *userData)](#oh_avrecorder_onuri) | OH_AVRecorder_OnUri | 当录制在[OH_AVRecorder_FileGenerationMode](#oh_avrecorder_filegenerationmode).AVRECORDER_AUTO_CREATE_CAMERA_SCENE模式时调用。 |
57
58## 枚举类型说明
59
60### OH_AVRecorder_AudioSourceType
61
62```
63enum OH_AVRecorder_AudioSourceType
64```
65
66**描述**
67
68AVRecorder的音频源类型。
69
70**系统能力:** SystemCapability.Multimedia.Media.AVRecorder
71
72**起始版本:** 18
73
74| 枚举项 | 描述 |
75| -- | -- |
76| AVRECORDER_DEFAULT = 0 | 默认音频源类型。 |
77| AVRECORDER_MIC = 1 | 麦克风音频源类型。 |
78| AVRECORDER_VOICE_RECOGNITION = 2 | 语音识别场景的音频源。 |
79| AVRECORDER_VOICE_COMMUNICATION = 7 | 语音通话场景的音频源。 |
80| AVRECORDER_VOICE_MESSAGE = 10 | 短语音消息的音频源。 |
81| AVRECORDER_CAMCORDER = 13 | 相机录像的音频源。 |
82
83### OH_AVRecorder_VideoSourceType
84
85```
86enum OH_AVRecorder_VideoSourceType
87```
88
89**描述**
90
91AVRecorder的视频源类型。
92
93**系统能力:** SystemCapability.Multimedia.Media.AVRecorder
94
95**起始版本:** 18
96
97| 枚举项 | 描述 |
98| -- | -- |
99| AVRECORDER_SURFACE_YUV = 0 | 原始数据Surface。 |
100| AVRECORDER_SURFACE_ES = 1 | ES数据Surface。 |
101
102### OH_AVRecorder_CodecMimeType
103
104```
105enum OH_AVRecorder_CodecMimeType
106```
107
108**描述**
109
110编码器MIME类型。
111
112**系统能力:** SystemCapability.Multimedia.Media.AVRecorder
113
114**起始版本:** 18
115
116| 枚举项 | 描述 |
117| -- | -- |
118| AVRECORDER_VIDEO_AVC = 2 | H.264 编码器MIME类型。 |
119| AVRECORDER_AUDIO_AAC = 3 | AAC 编码器MIME类型。 |
120| AVRECORDER_AUDIO_MP3 = 4 | mp3 编码器MIME类型。 |
121| AVRECORDER_AUDIO_G711MU = 5 | G711-mulaw 编码器MIME类型。 |
122| AVRECORDER_VIDEO_MPEG4 = 6 | MPEG4 编码器MIME类型。 |
123| AVRECORDER_VIDEO_HEVC = 8 | H.265 编码器MIME类型。 |
124| AVRECORDER_AUDIO_AMR_NB = 9 | AMR_NB 编解码器MIME类型。 |
125| AVRECORDER_AUDIO_AMR_WB = 10 | AMR_WB 编解码器MIME类型。 |
126
127### OH_AVRecorder_ContainerFormatType
128
129```
130enum OH_AVRecorder_ContainerFormatType
131```
132
133**描述**
134
135容器格式类型(容器格式类型的缩写是 CFT)。
136
137**系统能力:** SystemCapability.Multimedia.Media.AVRecorder
138
139**起始版本:** 18
140
141| 枚举项 | 描述 |
142| -- | -- |
143| AVRECORDER_CFT_MPEG_4 = 2 | 视频容器格式类型mp4。 |
144| AVRECORDER_CFT_MPEG_4A = 6 | 音频容器格式类型m4a。 |
145| AVRECORDER_CFT_AMR = 8 | 音频容器格式类型amr。 |
146| AVRECORDER_CFT_MP3 = 9 | 音频容器格式类型mp3。 |
147| AVRECORDER_CFT_WAV = 10 | 音频容器格式类型wav。 |
148| AVRECORDER_CFT_AAC = 11 | 音频容器格式类型aac(带ADTS头)。<br>**起始版本:** 20 |
149
150### OH_AVRecorder_State
151
152```
153enum OH_AVRecorder_State
154```
155
156**描述**
157
158AVRecorder状态。
159
160**系统能力:** SystemCapability.Multimedia.Media.AVRecorder
161
162**起始版本:** 18
163
164| 枚举项 | 描述 |
165| -- | -- |
166| AVRECORDER_IDLE = 0 | 空闲状态。此时可以调用[OH_AVRecorder_Prepare](capi-avrecorder-h.md#oh_avrecorder_prepare)方法设置录制参数,进入AVRECORDER_PREPARED状态。 |
167| AVRECORDER_PREPARED = 1 | 准备状态。参数设置完成,此时可以调用[OH_AVRecorder_Start](capi-avrecorder-h.md#oh_avrecorder_start)方法开始录制,进入AVRECORDER_STARTED状态。 |
168| AVRECORDER_STARTED = 2 | 启动状态。正在录制,此时可以调用[OH_AVRecorder_Pause](capi-avrecorder-h.md#oh_avrecorder_pause)方法暂停录制,进入AVRECORDER_PAUSED状态。<br>也可以调用[OH_AVRecorder_Stop](capi-avrecorder-h.md#oh_avrecorder_stop)方法结束录制,进入AVRECORDER_STOPPED状态。 |
169| AVRECORDER_PAUSED = 3 | 暂停状态。此时可以调用[OH_AVRecorder_Resume](capi-avrecorder-h.md#oh_avrecorder_resume)方法继续录制,进入AVRECORDER_STARTED状态。<br>也可以调用[OH_AVRecorder_Stop](capi-avrecorder-h.md#oh_avrecorder_stop)方法结束录制,进入AVRECORDER_STOPPED状态。 |
170| AVRECORDER_STOPPED = 4 | 停止状态。此时可以调用[OH_AVRecorder_Prepare](capi-avrecorder-h.md#oh_avrecorder_prepare)方法设置录制参数,重新进入AVRECORDER_PREPARED状态。 |
171| AVRECORDER_RELEASED = 5 | 释放状态。录制资源释放,此时不能再进行任何操作。在任何其他状态下,均可以通过调用[OH_AVRecorder_Release](capi-avrecorder-h.md#oh_avrecorder_release)方法进入AVRECORDER_RELEASED状态。 |
172| AVRECORDER_ERROR = 6 | 错误状态。当AVRecorder实例发生不可逆错误,会转换至当前状态。<br>切换至AVRECORDER_ERROR状态时会伴随[OH_AVRecorder_OnError](#oh_avrecorder_onerror)事件,该事件会上报详细错误原因。<br>在AVRECORDER_ERROR状态时,用户需要调用[OH_AVRecorder_Reset](capi-avrecorder-h.md#oh_avrecorder_reset)方法重置AVRecorder实例,或者调用[OH_AVRecorder_Release](capi-avrecorder-h.md#oh_avrecorder_release)方法释放资源。 |
173
174### OH_AVRecorder_StateChangeReason
175
176```
177enum OH_AVRecorder_StateChangeReason
178```
179
180**描述**
181
182AVRecorder状态变化的原因。
183
184**系统能力:** SystemCapability.Multimedia.Media.AVRecorder
185
186**起始版本:** 18
187
188| 枚举项 | 描述 |
189| -- | -- |
190| AVRECORDER_USER = 0 | 用户操作导致的状态变化。 |
191| AVRECORDER_BACKGROUND = 1 | 后台操作导致的状态变化。 |
192
193### OH_AVRecorder_FileGenerationMode
194
195```
196enum OH_AVRecorder_FileGenerationMode
197```
198
199**描述**
200
201创建录制文件的模式。
202
203**系统能力:** SystemCapability.Multimedia.Media.AVRecorder
204
205**起始版本:** 18
206
207| 枚举项 | 描述 |
208| -- | -- |
209| AVRECORDER_APP_CREATE = 0 | 由应用自行在沙箱中创建媒体文件。 |
210| AVRECORDER_AUTO_CREATE_CAMERA_SCENE = 1 | 由系统创建媒体文件,当前仅在相机录制场景下生效。 |
211
212
213## 函数说明
214
215### OH_AVRecorder_OnStateChange()
216
217```
218typedef void (*OH_AVRecorder_OnStateChange)(OH_AVRecorder *recorder,OH_AVRecorder_State state, OH_AVRecorder_StateChangeReason reason, void *userData)
219```
220
221**描述**
222
223当录制状态发生变化时调用。
224
225**系统能力:** SystemCapability.Multimedia.Media.AVRecorder
226
227**起始版本:** 18
228
229
230**参数:**
231
232| 参数项 | 描述 |
233| -- | -- |
234| [OH_AVRecorder](capi-avrecorder-oh-avrecorder.md) *recorder | OH_AVRecorder实例的指针。 |
235| [OH_AVRecorder_State](#oh_avrecorder_state) state | 表示录制器状态。 |
236| [OH_AVRecorder_StateChangeReason](#oh_avrecorder_statechangereason) reason | 录制器状态变化的原因。 |
237|  void *userData | 用户特定数据的指针。 |
238
239### OH_AVRecorder_OnError()
240
241```
242typedef void (*OH_AVRecorder_OnError)(OH_AVRecorder *recorder, int32_t errorCode, const char *errorMsg,void *userData)
243```
244
245**描述**
246
247当录制过程中发生错误时调用。
248
249**系统能力:** SystemCapability.Multimedia.Media.AVRecorder
250
251**起始版本:** 18
252
253
254**参数:**
255
256| 参数项 | 描述 |
257| -- | -- |
258| [OH_AVRecorder](capi-avrecorder-oh-avrecorder.md) *recorder | OH_AVRecorder实例的指针。 |
259|  int32_t errorCode | 错误码,详细说明请参见[AVErrorCode](../apis-avcodec-kit/_core.md#oh_averrcode-1)。 |
260|  const char *errorMsg | 错误信息。 |
261| void *userData | 用户特定数据的指针。 |
262
263### OH_AVRecorder_OnUri()
264
265```
266typedef void (*OH_AVRecorder_OnUri)(OH_AVRecorder *recorder, OH_MediaAsset *asset, void *userData)
267```
268
269**描述**
270
271当录制在[OH_AVRecorder_FileGenerationMode](#oh_avrecorder_filegenerationmode).AVRECORDER_AUTO_CREATE_CAMERA_SCENE模式下时调用。
272
273**系统能力:** SystemCapability.Multimedia.Media.AVRecorder
274
275**起始版本:** 18
276
277
278**参数:**
279
280| 参数项 | 描述 |
281| -- | -- |
282| [OH_AVRecorder](capi-avrecorder-oh-avrecorder.md) *recorder | OH_AVRecorder实例的指针。 |
283| [OH_MediaAsset](../apis-media-library-kit/capi-mediaassetmanager-oh-mediaasset.md) *asset | OH_MediaAsset实例的指针。 |
284|  void *userData | 用户特定数据的指针。 |
285
286
287