• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# avrecorder.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接口。应用可使用媒体AVRecorder提供的接口录制媒体数据。
12
13**引用文件:** <multimedia/player_framework/avrecorder.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| 名称 | 描述 |
28| -- | -- |
29| [OH_AVRecorder *OH_AVRecorder_Create(void)](#oh_avrecorder_create) | 创建AVRecorder实例。调用成功之后进入AVRECORDER_IDLE状态。 |
30| [OH_AVErrCode OH_AVRecorder_Prepare(OH_AVRecorder *recorder, OH_AVRecorder_Config *config)](#oh_avrecorder_prepare) | 配置AVRecorder参数,准备录制。必须在[OH_AVRecorder_Create](#oh_avrecorder_create)成功触发之后调用,调用成功之后进入AVRECORDER_PREPARED状态。<br>若只录制音频,则无需配置视频相关参数;同理,若只录制视频,则无需配置音频相关参数。 |
31| [OH_AVErrCode OH_AVRecorder_GetAVRecorderConfig(OH_AVRecorder *recorder, OH_AVRecorder_Config **config)](#oh_avrecorder_getavrecorderconfig) | 获取当前的录制参数。此接口必须在录制准备完成后调用。传入的*config必须为nullptr,由框架层统一分配和释放内存,以避免内存管理混乱,防止内存泄漏或重复释放等问题。 |
32| [OH_AVErrCode OH_AVRecorder_GetInputSurface(OH_AVRecorder *recorder, OHNativeWindow **window)](#oh_avrecorder_getinputsurface) | 获取输入Surface。必须在[OH_AVRecorder_Prepare](#oh_avrecorder_prepare)成功触发之后,[OH_AVRecorder_Start](#oh_avrecorder_start)之前调用。<br>此Surface提供给调用者,调用者从此Surface中获取Surface Buffer,填入相应的视频数据。 |
33| [OH_AVErrCode OH_AVRecorder_UpdateRotation(OH_AVRecorder *recorder, int32_t rotation)](#oh_avrecorder_updaterotation) | 更新视频旋转角度。必须在[OH_AVRecorder_Prepare](#oh_avrecorder_prepare)成功触发之后,[OH_AVRecorder_Start](#oh_avrecorder_start)之前调用。 |
34| [OH_AVErrCode OH_AVRecorder_Start(OH_AVRecorder *recorder)](#oh_avrecorder_start) | 开始录制。必须在[OH_AVRecorder_Prepare](#oh_avrecorder_prepare)成功触发之后调用,调用成功之后进入AVRECORDER_STARTED状态。 |
35| [OH_AVErrCode OH_AVRecorder_Pause(OH_AVRecorder *recorder)](#oh_avrecorder_pause) | 暂停录制。必须在[OH_AVRecorder_Start](#oh_avrecorder_start)成功触发之后,处于AVRECORDER_STARTED状态时调用,调用成功之后进入AVRECORDER_PAUSED状态。<br>之后可以通过调用[OH_AVRecorder_Resume](#oh_avrecorder_resume)恢复录制,重新进入AVRECORDER_STARTED状态。 |
36| [OH_AVErrCode OH_AVRecorder_Resume(OH_AVRecorder *recorder)](#oh_avrecorder_resume) | 恢复录制。必须在[OH_AVRecorder_Pause](#oh_avrecorder_pause)成功触发之后,处于PAUSED状态时调用,调用成功之后重新进入AVRECORDER_STARTED状态。 |
37| [OH_AVErrCode OH_AVRecorder_Stop(OH_AVRecorder *recorder)](#oh_avrecorder_stop) | 停止录制。必须在[OH_AVRecorder_Start](#oh_avrecorder_start)成功触发之后调用,调用成功之后进入AVRECORDER_STOPPED状态。<br>纯音频录制时,需要重新调用[OH_AVRecorder_Prepare](#oh_avrecorder_prepare)接口才能重新录制。<br>纯视频录制、音视频录制时,需要重新调用[OH_AVRecorder_Prepare](#oh_avrecorder_prepare)和[OH_AVRecorder_GetInputSurface](#oh_avrecorder_getinputsurface)接口才能重新录制。 |
38| [OH_AVErrCode OH_AVRecorder_Reset(OH_AVRecorder *recorder)](#oh_avrecorder_reset) | 重置录制状态。必须在非AVRECORDER_RELEASED状态下调用,调用成功之后进入AVRECORDER_IDLE状态。<br>纯音频录制时,需要重新调用[OH_AVRecorder_Prepare](#oh_avrecorder_prepare)接口才能重新录制。<br>纯视频录制、音视频录制时,需要重新调用[OH_AVRecorder_Prepare](#oh_avrecorder_prepare)和[OH_AVRecorder_GetInputSurface](#oh_avrecorder_getinputsurface)接口才能重新录制。 |
39| [OH_AVErrCode OH_AVRecorder_Release(OH_AVRecorder *recorder)](#oh_avrecorder_release) | 释放录制资源。调用成功之后进入AVRECORDER_RELEASED状态。<br>调用此接口释放录制资源后,recorder内存将释放,应用层需要显式地将recorder指针置空,避免访问野指针。释放音视频录制资源之后,该OH_AVRecorder实例不能再进行任何操作。 |
40| [OH_AVErrCode OH_AVRecorder_GetAvailableEncoder(OH_AVRecorder *recorder, OH_AVRecorder_EncoderInfo **info, int32_t *length)](#oh_avrecorder_getavailableencoder) | 获取AVRecorder可用的编码器和编码器信息。<br>参数\*info必须为nullptr,由框架层统一分配和释放内存,以避免内存管理混乱,防止内存泄漏或重复释放等问题。 |
41| [OH_AVErrCode OH_AVRecorder_SetStateCallback(OH_AVRecorder *recorder, OH_AVRecorder_OnStateChange callback, void *userData)](#oh_avrecorder_setstatecallback) | 设置状态回调函数,以便应用能够响应AVRecorder生成的状态变化事件。此接口必须在[OH_AVRecorder_Start](#oh_avrecorder_start)调用之前调用。 |
42| [OH_AVErrCode OH_AVRecorder_SetErrorCallback(OH_AVRecorder *recorder, OH_AVRecorder_OnError callback, void *userData)](#oh_avrecorder_seterrorcallback) | 设置错误回调函数,以便应用能够响应AVRecorder生成的错误事件。此接口必须在[OH_AVRecorder_Start](#oh_avrecorder_start)调用之前调用。 |
43| [OH_AVErrCode OH_AVRecorder_SetUriCallback(OH_AVRecorder *recorder, OH_AVRecorder_OnUri callback, void *userData)](#oh_avrecorder_seturicallback) | 设置URI回调函数,以便应用能够响应AVRecorder生成的URI事件。此接口必须在[OH_AVRecorder_Start](#oh_avrecorder_start)调用之前调用。 |
44| [OH_AVErrCode OH_AVRecorder_SetWillMuteWhenInterrupted(OH_AVRecorder *recorder, bool muteWhenInterrupted)](#oh_avrecorder_setwillmutewheninterrupted) | 设置是否开启静音打断模式。 |
45
46## 函数说明
47
48### OH_AVRecorder_Create()
49
50```
51OH_AVRecorder *OH_AVRecorder_Create(void)
52```
53
54**描述**
55
56创建AVRecorder实例。调用成功之后进入AVRECORDER_IDLE状态。
57
58**系统能力:** SystemCapability.Multimedia.Media.AVRecorder
59
60**起始版本:** 18
61
62**返回:**
63
64| 类型 | 说明 |
65| -- | -- |
66| [OH_AVRecorder](capi-avrecorder-oh-avrecorder.md) | 成功时返回指向OH_AVRecorder实例的指针,失败时返回nullptr。 |
67
68### OH_AVRecorder_Prepare()
69
70```
71OH_AVErrCode OH_AVRecorder_Prepare(OH_AVRecorder *recorder, OH_AVRecorder_Config *config)
72```
73
74**描述**
75
76配置AVRecorder参数,准备录制。必须在[OH_AVRecorder_Create](#oh_avrecorder_create)成功触发之后调用,调用成功之后进入AVRECORDER_PREPARED状态。<br>若只录制音频,则无需配置视频相关参数;同理,若只录制视频,则无需配置音频相关参数。
77
78**系统能力:** SystemCapability.Multimedia.Media.AVRecorder
79
80**起始版本:** 18
81
82
83**参数:**
84
85| 参数项 | 描述 |
86| -- | -- |
87| [OH_AVRecorder](capi-avrecorder-oh-avrecorder.md) *recorder | 指向OH_AVRecorder实例的指针。 |
88| [OH_AVRecorder_Config](capi-avrecorder-oh-avrecorder-config.md) *config | 指向OH_AVRecorder_Config实例的指针。 |
89
90**返回:**
91
92| 类型 | 说明 |
93| -- | -- |
94| [OH_AVErrCode](../apis-avcodec-kit/_core.md#oh_averrcode-1) | AV_ERR_OK:执行成功。<br>        AV_ERR_INVALID_VAL:输入的recorder为nullptr或者准备失败。 |
95
96### OH_AVRecorder_GetAVRecorderConfig()
97
98```
99OH_AVErrCode OH_AVRecorder_GetAVRecorderConfig(OH_AVRecorder *recorder, OH_AVRecorder_Config **config)
100```
101
102**描述**
103
104获取当前的录制参数。此接口必须在录制准备完成后调用。<br>传入的*config必须为nullptr,由框架层统一分配和释放内存,以避免内存管理混乱,防止内存泄漏或重复释放等问题。
105
106**系统能力:** SystemCapability.Multimedia.Media.AVRecorder
107
108**起始版本:** 18
109
110
111**参数:**
112
113| 参数项 | 描述 |
114| -- | -- |
115| [OH_AVRecorder](capi-avrecorder-oh-avrecorder.md) *recorder | 指向OH_AVRecorder实例的指针。 |
116| [OH_AVRecorder_Config](capi-avrecorder-oh-avrecorder-config.md) **config | 指向OH_AVRecorder_Config实例的指针。 |
117
118**返回:**
119
120| 类型 | 说明 |
121| -- | -- |
122| [OH_AVErrCode](../apis-avcodec-kit/_core.md#oh_averrcode-1) | AV_ERR_OK:执行成功。<br>        AV_ERR_INVALID_VAL:输入的recorder为nullptr或\*config不为nullptr。<br>        AV_ERR_NO_MEMORY:内存不足,\*config内存分配失败。 |
123
124### OH_AVRecorder_GetInputSurface()
125
126```
127OH_AVErrCode OH_AVRecorder_GetInputSurface(OH_AVRecorder *recorder, OHNativeWindow **window)
128```
129
130**描述**
131
132获取输入Surface。必须在[OH_AVRecorder_Prepare](#oh_avrecorder_prepare)成功触发之后,[OH_AVRecorder_Start](#oh_avrecorder_start)之前调用。<br>此Surface提供给调用者,调用者从此Surface中获取Surface Buffer,填入相应的视频数据。
133
134**系统能力:** SystemCapability.Multimedia.Media.AVRecorder
135
136**起始版本:** 18
137
138
139**参数:**
140
141| 参数项 | 描述 |
142| -- | -- |
143| [OH_AVRecorder](capi-avrecorder-oh-avrecorder.md) *recorder | 指向OH_AVRecorder实例的指针。 |
144| [OHNativeWindow](../apis-arkgraphics2d/capi-nativewindow-nativewindow.md) **window | 指向OHNativeWindow实例的指针。 |
145
146**返回:**
147
148| 类型 | 说明 |
149| -- | -- |
150| [OH_AVErrCode](../apis-avcodec-kit/_core.md#oh_averrcode-1) | AV_ERR_OK:执行成功。<br>        AV_ERR_INVALID_VAL:输入的recorder为nullptr。 |
151
152### OH_AVRecorder_UpdateRotation()
153
154```
155OH_AVErrCode OH_AVRecorder_UpdateRotation(OH_AVRecorder *recorder, int32_t rotation)
156```
157
158**描述**
159
160更新视频旋转角度。必须在[OH_AVRecorder_Prepare](#oh_avrecorder_prepare)成功触发之后,[OH_AVRecorder_Start](#oh_avrecorder_start)之前调用。
161
162**系统能力:** SystemCapability.Multimedia.Media.AVRecorder
163
164**起始版本:** 18
165
166
167**参数:**
168
169| 参数项 | 描述 |
170| -- | -- |
171| [OH_AVRecorder](capi-avrecorder-oh-avrecorder.md) *recorder | 指向OH_AVRecorder实例的指针。 |
172| int32_t rotation | 视频旋转角度,必须是整数 [0, 90, 180, 270] 中的一个。 |
173
174**返回:**
175
176| 类型 | 说明 |
177| -- | -- |
178| [OH_AVErrCode](../apis-avcodec-kit/_core.md#oh_averrcode-1) | AV_ERR_OK:执行成功。<br>        AV_ERR_INVALID_VAL:输入的recorder为nullptr或输入的rotation不符合要求或更新方向失败。 |
179
180### OH_AVRecorder_Start()
181
182```
183OH_AVErrCode OH_AVRecorder_Start(OH_AVRecorder *recorder)
184```
185
186**描述**
187
188开始录制。必须在[OH_AVRecorder_Prepare](#oh_avrecorder_prepare)成功触发之后调用,调用成功之后进入AVRECORDER_STARTED状态。
189
190**系统能力:** SystemCapability.Multimedia.Media.AVRecorder
191
192**起始版本:** 18
193
194
195**参数:**
196
197| 参数项 | 描述 |
198| -- | -- |
199| [OH_AVRecorder](capi-avrecorder-oh-avrecorder.md) *recorder | 指向OH_AVRecorder实例的指针。 |
200
201**返回:**
202
203| 类型 | 说明 |
204| -- | -- |
205| [OH_AVErrCode](../apis-avcodec-kit/_core.md#oh_averrcode-1) | AV_ERR_OK:执行成功。<br>        AV_ERR_INVALID_VAL:输入的recorder为nullptr或启动失败。 |
206
207### OH_AVRecorder_Pause()
208
209```
210OH_AVErrCode OH_AVRecorder_Pause(OH_AVRecorder *recorder)
211```
212
213**描述**
214
215暂停录制。必须在[OH_AVRecorder_Start](#oh_avrecorder_start)成功触发之后,处于AVRECORDER_STARTED状态时调用,调用成功之后进入AVRECORDER_PAUSED状态。<br>之后可以通过调用[OH_AVRecorder_Resume](#oh_avrecorder_resume)恢复录制,重新进入AVRECORDER_STARTED状态。
216
217**系统能力:** SystemCapability.Multimedia.Media.AVRecorder
218
219**起始版本:** 18
220
221
222**参数:**
223
224| 参数项 | 描述 |
225| -- | -- |
226| [OH_AVRecorder](capi-avrecorder-oh-avrecorder.md) *recorder | 指向OH_AVRecorder实例的指针。 |
227
228**返回:**
229
230| 类型 | 说明 |
231| -- | -- |
232| [OH_AVErrCode](../apis-avcodec-kit/_core.md#oh_averrcode-1) | AV_ERR_OK:执行成功。<br>        AV_ERR_INVALID_VAL:输入的recorder为nullptr或暂停失败。 |
233
234### OH_AVRecorder_Resume()
235
236```
237OH_AVErrCode OH_AVRecorder_Resume(OH_AVRecorder *recorder)
238```
239
240**描述**
241
242恢复录制。必须在[OH_AVRecorder_Pause](#oh_avrecorder_pause)成功触发之后,处于PAUSED状态时调用,调用成功之后重新进入AVRECORDER_STARTED状态。
243
244**系统能力:** SystemCapability.Multimedia.Media.AVRecorder
245
246**起始版本:** 18
247
248
249**参数:**
250
251| 参数项 | 描述 |
252| -- | -- |
253| [OH_AVRecorder](capi-avrecorder-oh-avrecorder.md) *recorder | 指向OH_AVRecorder实例的指针。 |
254
255**返回:**
256
257| 类型 | 说明 |
258| -- | -- |
259| [OH_AVErrCode](../apis-avcodec-kit/_core.md#oh_averrcode-1) | AV_ERR_OK:执行成功。<br>        AV_ERR_INVALID_VAL:输入的recorder为nullptr或恢复失败。 |
260
261### OH_AVRecorder_Stop()
262
263```
264OH_AVErrCode OH_AVRecorder_Stop(OH_AVRecorder *recorder)
265```
266
267**描述**
268
269停止录制。必须在[OH_AVRecorder_Start](#oh_avrecorder_start)成功触发之后调用,调用成功之后进入AVRECORDER_STOPPED状态。<br>纯音频录制时,需要重新调用[OH_AVRecorder_Prepare](#oh_avrecorder_prepare)接口才能重新录制。<br>纯视频录制、音视频录制时,需要重新调用[OH_AVRecorder_Prepare](#oh_avrecorder_prepare)和[OH_AVRecorder_GetInputSurface](#oh_avrecorder_getinputsurface)接口才能重新录制。
270
271**系统能力:** SystemCapability.Multimedia.Media.AVRecorder
272
273**起始版本:** 18
274
275
276**参数:**
277
278| 参数项 | 描述 |
279| -- | -- |
280| [OH_AVRecorder](capi-avrecorder-oh-avrecorder.md) *recorder | 指向OH_AVRecorder实例的指针。 |
281
282**返回:**
283
284| 类型 | 说明 |
285| -- | -- |
286| [OH_AVErrCode](../apis-avcodec-kit/_core.md#oh_averrcode-1) | AV_ERR_OK:执行成功。<br>        AV_ERR_INVALID_VAL:输入的recorder为nullptr或停止失败。 |
287
288### OH_AVRecorder_Reset()
289
290```
291OH_AVErrCode OH_AVRecorder_Reset(OH_AVRecorder *recorder)
292```
293
294**描述**
295
296重置录制状态。必须在非AVRECORDER_RELEASED状态下调用,调用成功之后进入AVRECORDER_IDLE状态。<br>纯音频录制时,需要重新调用[OH_AVRecorder_Prepare](#oh_avrecorder_prepare)接口才能重新录制。<br>纯视频录制、音视频录制时,需要重新调用[OH_AVRecorder_Prepare](#oh_avrecorder_prepare)和[OH_AVRecorder_GetInputSurface](#oh_avrecorder_getinputsurface)接口才能重新录制。
297
298**系统能力:** SystemCapability.Multimedia.Media.AVRecorder
299
300**起始版本:** 18
301
302
303**参数:**
304
305| 参数项 | 描述 |
306| -- | -- |
307| [OH_AVRecorder](capi-avrecorder-oh-avrecorder.md) *recorder | 指向OH_AVRecorder实例的指针。 |
308
309**返回:**
310
311| 类型 | 说明 |
312| -- | -- |
313| [OH_AVErrCode](../apis-avcodec-kit/_core.md#oh_averrcode-1) | AV_ERR_OK:执行成功。<br>        AV_ERR_INVALID_VAL:输入的recorder为nullptr或重置失败。 |
314
315### OH_AVRecorder_Release()
316
317```
318OH_AVErrCode OH_AVRecorder_Release(OH_AVRecorder *recorder)
319```
320
321**描述**
322
323释放录制资源。调用成功之后进入AVRECORDER_RELEASED状态。<br>调用此接口释放录制资源后,recorder内存将释放,应用层需要显式地将recorder指针置空,避免访问野指针。释放音视频录制资源之后,该OH_AVRecorder实例不能再进行任何操作。
324
325**系统能力:** SystemCapability.Multimedia.Media.AVRecorder
326
327**起始版本:** 18
328
329
330**参数:**
331
332| 参数项 | 描述 |
333| -- | -- |
334| [OH_AVRecorder](capi-avrecorder-oh-avrecorder.md) *recorder | 指向OH_AVRecorder实例的指针。 |
335
336**返回:**
337
338| 类型 | 说明 |
339| -- | -- |
340| [OH_AVErrCode](../apis-avcodec-kit/_core.md#oh_averrcode-1) | AV_ERR_OK:执行成功。<br>        AV_ERR_INVALID_VAL:输入的recorder为nullptr或释放失败。 |
341
342### OH_AVRecorder_GetAvailableEncoder()
343
344```
345OH_AVErrCode OH_AVRecorder_GetAvailableEncoder(OH_AVRecorder *recorder, OH_AVRecorder_EncoderInfo **info,int32_t *length)
346```
347
348**描述**
349
350获取AVRecorder可用的编码器和编码器信息。<br>参数*info必须为nullptr,由框架层统一分配和释放内存,以避免内存管理混乱,防止内存泄漏或重复释放等问题。
351
352**系统能力:** SystemCapability.Multimedia.Media.AVRecorder
353
354**起始版本:** 18
355
356
357**参数:**
358
359| 参数项 | 描述 |
360| -- | -- |
361| [OH_AVRecorder](capi-avrecorder-oh-avrecorder.md) *recorder | 指向OH_AVRecorder实例的指针。 |
362| [OH_AVRecorder_EncoderInfo](capi-avrecorder-oh-avrecorder-encoderinfo.md) **info | 指向OH_AVRecorder_EncoderInfo实例的指针。 |
363| int32_t *length | 可用编码器的长度。 |
364
365**返回:**
366
367| 类型 | 说明 |
368| -- | -- |
369| [OH_AVErrCode](../apis-avcodec-kit/_core.md#oh_averrcode-1) | AV_ERR_OK:执行成功。<br>        AV_ERR_INVALID_VAL:输入的 recorder 为nullptr。<br>        AV_ERR_NO_MEMORY:内存不足,\*info内存分配失败。 |
370
371### OH_AVRecorder_SetStateCallback()
372
373```
374OH_AVErrCode OH_AVRecorder_SetStateCallback(OH_AVRecorder *recorder, OH_AVRecorder_OnStateChange callback, void *userData)
375```
376
377**描述**
378
379设置状态回调函数,以便应用能够响应AVRecorder生成的状态变化事件。此接口必须在[OH_AVRecorder_Start](#oh_avrecorder_start)调用之前调用。
380
381**系统能力:** SystemCapability.Multimedia.Media.AVRecorder
382
383**起始版本:** 18
384
385
386**参数:**
387
388| 参数项 | 描述 |
389| -- | -- |
390| [OH_AVRecorder](capi-avrecorder-oh-avrecorder.md) *recorder | 指向OH_AVRecorder实例的指针。 |
391| [OH_AVRecorder_OnStateChange](capi-avrecorder-base-h.md#oh_avrecorder_onstatechange) callback | 状态回调函数。 |
392| void *userData | 指向用户特定数据的指针。 |
393
394**返回:**
395
396| 类型 | 说明 |
397| -- | -- |
398| [OH_AVErrCode](../apis-avcodec-kit/_core.md#oh_averrcode-1) | AV_ERR_OK:执行成功。<br>        AV_ERR_INVALID_VAL:输入的recorder为nullptr或回调函数为nullptr。 |
399
400### OH_AVRecorder_SetErrorCallback()
401
402```
403OH_AVErrCode OH_AVRecorder_SetErrorCallback(OH_AVRecorder *recorder, OH_AVRecorder_OnError callback, void *userData)
404```
405
406**描述**
407
408设置错误回调函数,以便应用能够响应AVRecorder生成的错误事件。此接口必须在[OH_AVRecorder_Start](#oh_avrecorder_start)调用之前调用。
409
410**系统能力:** SystemCapability.Multimedia.Media.AVRecorder
411
412**起始版本:** 18
413
414
415**参数:**
416
417| 参数项 | 描述 |
418| -- | -- |
419| [OH_AVRecorder](capi-avrecorder-oh-avrecorder.md) *recorder | 指向OH_AVRecorder实例的指针。 |
420| [OH_AVRecorder_OnError](capi-avrecorder-base-h.md#oh_avrecorder_onerror) callback | 错误回调函数。 |
421| void *userData | 指向用户特定数据的指针。 |
422
423**返回:**
424
425| 类型 | 说明 |
426| -- | -- |
427| [OH_AVErrCode](../apis-avcodec-kit/_core.md#oh_averrcode-1) | AV_ERR_OK:执行成功。<br>        AV_ERR_INVALID_VAL:输入的recorder为nullptr或回调函数为nullptr。 |
428
429### OH_AVRecorder_SetUriCallback()
430
431```
432OH_AVErrCode OH_AVRecorder_SetUriCallback(OH_AVRecorder *recorder, OH_AVRecorder_OnUri callback, void *userData)
433```
434
435**描述**
436
437设置URI回调函数,以便应用能够响应AVRecorder生成的URI事件。此接口必须在[OH_AVRecorder_Start](#oh_avrecorder_start)调用之前调用。
438
439**系统能力:** SystemCapability.Multimedia.Media.AVRecorder
440
441**起始版本:** 18
442
443
444**参数:**
445
446| 参数项 | 描述 |
447| -- | -- |
448| [OH_AVRecorder](capi-avrecorder-oh-avrecorder.md) *recorder | 指向OH_AVRecorder实例的指针。 |
449| [OH_AVRecorder_OnUri](capi-avrecorder-base-h.md#oh_avrecorder_onuri) callback | URI回调函数。 |
450| void *userData | 指向用户特定数据的指针。 |
451
452**返回:**
453
454| 类型 | 说明 |
455| -- | -- |
456| [OH_AVErrCode](../apis-avcodec-kit/_core.md#oh_averrcode-1) | AV_ERR_OK:执行成功。<br>        AV_ERR_INVALID_VAL:输入的recorder为nullptr或回调函数为nullptr。 |
457
458### OH_AVRecorder_SetWillMuteWhenInterrupted()
459
460```
461OH_AVErrCode OH_AVRecorder_SetWillMuteWhenInterrupted(OH_AVRecorder *recorder, bool muteWhenInterrupted)
462```
463
464**描述**
465
466设置是否开启静音打断模式。
467
468**系统能力:** SystemCapability.Multimedia.Media.AVRecorder
469
470**起始版本:** 20
471
472
473**参数:**
474
475| 参数项 | 描述 |
476| -- | -- |
477| [OH_AVRecorder](capi-avrecorder-oh-avrecorder.md) *recorder | 指向OH_AVRecorder实例的指针。 |
478| bool muteWhenInterrupted | 设置成true表示当应用需要录制时保持静音而不是被打断。 |
479
480**返回:**
481
482| 类型 | 说明 |
483| -- | -- |
484| [OH_AVErrCode](../apis-avcodec-kit/_core.md#oh_averrcode-1) | AV_ERR_OK:执行成功。<br>        AV_ERR_INVALID_VAL:输入的recorder为nullptr或回调函数为nullptr。<br>        AV_ERR_INVALID_STATE:函数在无效状态下调用,应先处于准备状态。 |
485
486
487