• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# AVScreenCapture
2
3
4## Overview
5
6The AVScreenCapture module provides APIs for screen capture.
7
8**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
9
10**Since**: 10
11
12
13## Summary
14
15
16### Files
17
18| Name| Description|
19| -------- | -------- |
20| [native_avscreen_capture.h](native__avscreen__capture_8h.md) | Declares the APIs used to create an **OH_AVScreenCapture** instance.|
21| [native_avscreen_capture_base.h](native__avscreen__capture__base_8h.md) | Declares the common structs, character constants, and enums used for running screen capture.|
22| [native_avscreen_capture_errors.h](native__avscreen__capture__errors_8h.md) | Declares the error codes generated during screen capture.|
23
24
25### Structs
26
27| Name| Description|
28| -------- | -------- |
29| struct  [OH_AudioCaptureInfo](_o_h___audio_capture_info.md) | Describes the audio capture information.|
30| struct  [OH_AudioEncInfo](_o_h___audio_enc_info.md) | Describes the audio encoding information.|
31| struct  [OH_AudioInfo](_o_h___audio_info.md) | Describes the audio information.|
32| struct  [OH_VideoCaptureInfo](_o_h___video_capture_info.md) | Describes the video capture information.|
33| struct  [OH_VideoEncInfo](_o_h___video_enc_info.md) | Describes the video encoding information.|
34| struct  [OH_VideoInfo](_o_h___video_info.md) |Describes the video information.|
35| struct  [OH_RecorderInfo](_o_h___recorder_info.md) | Describes the recording file information.|
36| struct  [OH_AVScreenCaptureConfig](_o_h___a_v_screen_capture_config.md) | Describes the screen capture configuration.|
37| struct  [OH_AVScreenCaptureCallback](_o_h___a_v_screen_capture_callback.md) | Describes all the asynchronous callback function pointers of an **OH_AVScreenCapture** instance.|
38| struct  [OH_Rect](_o_h___rect.md) | Describes the width, height, and image information of the rectangle used for screen capture.|
39| struct  [OH_AudioBuffer](_o_h___audio_buffer.md) | Describes the configuration such as the size, type, and timestamp of audio data.|
40
41
42### Types
43
44| Name| Description|
45| -------- | -------- |
46| typedef struct [OH_NativeBuffer](#oh_nativebuffer) [OH_NativeBuffer](#oh_nativebuffer) | Defines the native video stream class for screen capture.|
47| typedef struct [OH_AVScreenCapture](#oh_avscreencapture) [OH_AVScreenCapture](#oh_avscreencapture) | Defines a screen capture instance used to obtain original video and audio streams.|
48| typedef struct [OH_AVScreenCapture_ContentFilter](#oh_avscreencapture_contentfilter) [OH_AVScreenCapture_ContentFilter](#oh_avscreencapture_contentfilter) | Defines a struct for the filter used to filter audio and video content.|
49| typedef enum [OH_CaptureMode](#oh_capturemode-1) [OH_CaptureMode](#oh_capturemode) | Defines an enum for the screen capture modes.|
50| typedef enum [OH_AudioCaptureSourceType](#oh_audiocapturesourcetype-1) [OH_AudioCaptureSourceType](#oh_audiocapturesourcetype) | Defines an enum for the audio source types during screen capture.|
51| typedef enum [OH_AudioCodecFormat](#oh_audiocodecformat-1) [OH_AudioCodecFormat](#oh_audiocodecformat) | Defines an enum for the audio encoding formats.|
52| typedef enum [OH_VideoCodecFormat](#oh_videocodecformat-1) [OH_VideoCodecFormat](#oh_videocodecformat) | Defines an enum for the video encoding formats.|
53| typedef enum [OH_DataType](#oh_datatype-1) [OH_DataType](#oh_datatype) | Defines an enum for the data types of screen capture streams.|
54| typedef enum [OH_VideoSourceType](#oh_videosourcetype-1) [OH_VideoSourceType](#oh_videosourcetype) | Defines an enum for the video source formats.|
55| typedef enum [OH_ContainerFormatType](#oh_containerformattype-1) [OH_ContainerFormatType](#oh_containerformattype) | Defines an enum for the types of files generated during screen capture.|
56| typedef struct [OH_AudioCaptureInfo](_o_h___audio_capture_info.md) [OH_AudioCaptureInfo](#oh_audiocaptureinfo) | Defines a struct for the audio capture information.|
57| typedef struct [OH_AudioEncInfo](_o_h___audio_enc_info.md) [OH_AudioEncInfo](#oh_audioencinfo) | Defines a struct for the audio encoding information.|
58| typedef struct [OH_AudioInfo](_o_h___audio_info.md) [OH_AudioInfo](#oh_audioinfo) | Defines a struct for the audio information.|
59| typedef struct [OH_VideoCaptureInfo](_o_h___video_capture_info.md) [OH_VideoCaptureInfo](#oh_videocaptureinfo) | Defines a struct for the video capture information.|
60| typedef struct [OH_VideoEncInfo](_o_h___video_enc_info.md) [OH_VideoEncInfo](#oh_videoencinfo) | Defines a struct for the video encoding information.|
61| typedef struct [OH_VideoInfo](_o_h___video_info.md) [OH_VideoInfo](#oh_videoinfo) | Defines a struct for the video information.|
62| typedef struct [OH_RecorderInfo](_o_h___recorder_info.md) [OH_RecorderInfo](#oh_recorderinfo) | Defines a struct for the recording file information.|
63| typedef struct [OH_AVScreenCaptureConfig](_o_h___a_v_screen_capture_config.md) [OH_AVScreenCaptureConfig](#oh_avscreencaptureconfig) | Defines a struct for the screen capture configuration.|
64| typedef void(\* [OH_AVScreenCaptureOnError](#oh_avscreencaptureonerror)) ([OH_AVScreenCapture](#oh_avscreencapture) \*capture, int32_t errorCode) | Defines a pointer to a callback function that is called when an error occurs during the running of an **OH_AVScreenCapture** instance.|
65| typedef void(\* [OH_AVScreenCaptureOnAudioBufferAvailable](#oh_avscreencaptureonaudiobufferavailable)) ([OH_AVScreenCapture](#oh_avscreencapture) \*capture, bool isReady, [OH_AudioCaptureSourceType](#oh_audiocapturesourcetype) type) | Defines a pointer to a callback function that is called when an audio buffer is available during the running of an **OH_AVScreenCapture** instance.|
66| typedef void(\* [OH_AVScreenCaptureOnVideoBufferAvailable](#oh_avscreencaptureonvideobufferavailable)) ([OH_AVScreenCapture](#oh_avscreencapture) \*capture, bool isReady) | Defines a pointer to a callback function that is called when a video buffer is available during the running of an **OH_AVScreenCapture** instance.|
67| typedef struct [OH_AVScreenCaptureCallback](_o_h___a_v_screen_capture_callback.md) [OH_AVScreenCaptureCallback](#oh_avscreencapturecallback) | Defines a struct for all the asynchronous callback function pointers of an **OH_AVScreenCapture** instance.|
68| typedef struct [OH_Rect](_o_h___rect.md) [OH_Rect](#oh_rect) | Defines a struct for the width, height, and image information of the rectangle used for screen capture.|
69| typedef struct [OH_AudioBuffer](_o_h___audio_buffer.md) [OH_AudioBuffer](#oh_audiobuffer) | Defines a struct for the configuration such as the size, type, and timestamp of audio data.|
70| typedef enum [OH_AVScreenCaptureStateCode](#oh_avscreencapturestatecode-1) [OH_AVScreenCaptureStateCode](#oh_avscreencapturestatecode) | Defines an enum for the screen capture states.|
71| typedef enum [OH_AVScreenCaptureBufferType](#oh_avscreencapturebuffertype-1) [OH_AVScreenCaptureBufferType](#oh_avscreencapturebuffertype) | Defines an enum for the buffer types.|
72| typedef enum [OH_AVScreenCaptureFilterableAudioContent](#oh_avscreencapturefilterableaudiocontent-1) [OH_AVScreenCaptureFilterableAudioContent](#oh_avscreencapturefilterableaudiocontent) | Defines an enum for the types of audio that can be added to a content filter.|
73| typedef void(\* [OH_AVScreenCapture_OnStateChange](#oh_avscreencapture_onstatechange)) (struct [OH_AVScreenCapture](#oh_avscreencapture) \*capture, [OH_AVScreenCaptureStateCode](#oh_avscreencapturestatecode) stateCode, void \*userData) | Defines a pointer to a callback function that is called when the state changes during the running of an **OH_AVScreenCapture** instance.|
74| typedef void(\* [OH_AVScreenCapture_OnError](#oh_avscreencapture_onerror)) ([OH_AVScreenCapture](#oh_avscreencapture) \*capture, int32_t errorCode, void \*userData) | Defines a pointer to a callback function that is called when an error occurs during the running of an **OH_AVScreenCapture** instance.|
75| typedef void(\* [OH_AVScreenCapture_OnBufferAvailable](#oh_avscreencapture_onbufferavailable)) ([OH_AVScreenCapture](#oh_avscreencapture) \*capture, OH_AVBuffer \*buffer, [OH_AVScreenCaptureBufferType](#oh_avscreencapturebuffertype) bufferType, int64_t timestamp, void \*userData) | Defines a pointer to a callback function that is called when an audio or a video buffer is available during the running of an **OH_AVScreenCapture** instance.|
76| typedef enum [OH_AVSCREEN_CAPTURE_ErrCode](#oh_avscreen_capture_errcode-1) [OH_AVSCREEN_CAPTURE_ErrCode](#oh_avscreen_capture_errcode) | Defines an enum for the error codes generated during screen recording.|
77
78
79### Enums
80
81| Name| Description|
82| -------- | -------- |
83| [OH_CaptureMode](#oh_capturemode-1) {<br>OH_CAPTURE_HOME_SCREEN = 0,<br>OH_CAPTURE_SPECIFIED_SCREEN = 1,<br>OH_CAPTURE_SPECIFIED_WINDOW = 2,<br>OH_CAPTURE_INVAILD = -1<br>} | Enumerates the screen capture modes.|
84| [OH_AudioCaptureSourceType](#oh_audiocapturesourcetype-1) {<br>OH_SOURCE_INVALID = -1,<br>OH_SOURCE_DEFAULT = 0,<br>OH_MIC = 1,<br>OH_ALL_PLAYBACK = 2,<br>OH_APP_PLAYBACK = 3<br>} | Enumerates the audio source types during screen capture.|
85| [OH_AudioCodecFormat](#oh_audiocodecformat-1) {<br>OH_AUDIO_DEFAULT = 0,<br>OH_AAC_LC = 3,<br>OH_AUDIO_CODEC_FORMAT_BUTT<br>} | Enumerates the audio encoding formats.|
86| [OH_VideoCodecFormat](#oh_videocodecformat-1) {<br>OH_VIDEO_DEFAULT = 0,<br>OH_H264 = 2,<br>OH_H265 = 4,<br>OH_MPEG4 = 6,<br>OH_VP8 = 8,<br>OH_VP9 = 10,<br>OH_VIDEO_CODEC_FORMAT_BUTT<br>} | Enumerates the video encoding formats.|
87| [OH_DataType](#oh_datatype-1) {<br>OH_ORIGINAL_STREAM = 0,<br>OH_ENCODED_STREAM = 1,<br>OH_CAPTURE_FILE = 2,<br>OH_INVAILD = -1<br>} | Enumerates the data types of screen capture streams.|
88| [OH_VideoSourceType](#oh_videosourcetype-1) {<br>OH_VIDEO_SOURCE_SURFACE_YUV = 0,<br>OH_VIDEO_SOURCE_SURFACE_ES,<br>OH_VIDEO_SOURCE_SURFACE_RGBA,<br>OH_VIDEO_SOURCE_BUTT<br>} | Enumerates the video source formats.|
89| [OH_ContainerFormatType](#oh_containerformattype) {<br>CFT_MPEG_4A = 0,<br>CFT_MPEG_4 = 1<br>} | Enumerates the types of files generated during screen capture.|
90| [OH_AVScreenCaptureStateCode](#oh_avscreencapturestatecode-1) {<br>OH_SCREEN_CAPTURE_STATE_STARTED = 0,<br>OH_SCREEN_CAPTURE_STATE_CANCELED = 1,<br>OH_SCREEN_CAPTURE_STATE_STOPPED_BY_USER = 2,<br>OH_SCREEN_CAPTURE_STATE_INTERRUPTED_BY_OTHER = 3,<br>OH_SCREEN_CAPTURE_STATE_STOPPED_BY_CALL = 4,<br>OH_SCREEN_CAPTURE_STATE_MIC_UNAVAILABLE = 5,<br>OH_SCREEN_CAPTURE_STATE_MIC_MUTED_BY_USER = 6,<br>OH_SCREEN_CAPTURE_STATE_MIC_UNMUTED_BY_USER = 7,<br>OH_SCREEN_CAPTURE_STATE_ENTER_PRIVATE_SCENE = 8,<br>OH_SCREEN_CAPTURE_STATE_EXIT_PRIVATE_SCENE = 9<br>OH_SCREEN_CAPTURE_STATE_STOPPED_BY_USER_SWITCHES = 10<br>} | Enumerates the screen capture states.|
91| [OH_AVScreenCaptureBufferType](#oh_avscreencapturebuffertype-1) {<br>OH_SCREEN_CAPTURE_BUFFERTYPE_VIDEO = 0,<br>OH_SCREEN_CAPTURE_BUFFERTYPE_AUDIO_INNER = 1,<br>OH_SCREEN_CAPTURE_BUFFERTYPE_AUDIO_MIC = 2<br>} | Enumerates the buffer types.|
92| [OH_AVScreenCaptureFilterableAudioContent](#oh_avscreencapturefilterableaudiocontent-1) {<br>OH_SCREEN_CAPTURE_NOTIFICATION_AUDIO = 0, <br>OH_SCREEN_CAPTURE_CURRENT_APP_AUDIO = 1 <br>} | Enumerates the types of audio that can be added to a content filter. |
93| [OH_AVSCREEN_CAPTURE_ErrCode](#oh_avscreen_capture_errcode-1) {<br>AV_SCREEN_CAPTURE_ERR_BASE = 0,<br>AV_SCREEN_CAPTURE_ERR_OK = AV_SCREEN_CAPTURE_ERR_BASE,<br>AV_SCREEN_CAPTURE_ERR_NO_MEMORY = AV_SCREEN_CAPTURE_ERR_BASE + 1,<br>AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT = AV_SCREEN_CAPTURE_ERR_BASE + 2,<br>AV_SCREEN_CAPTURE_ERR_INVALID_VAL = AV_SCREEN_CAPTURE_ERR_BASE + 3,<br>AV_SCREEN_CAPTURE_ERR_IO = AV_SCREEN_CAPTURE_ERR_BASE + 4,<br>AV_SCREEN_CAPTURE_ERR_TIMEOUT = AV_SCREEN_CAPTURE_ERR_BASE + 5,<br>AV_SCREEN_CAPTURE_ERR_UNKNOWN = AV_SCREEN_CAPTURE_ERR_BASE + 6,<br>AV_SCREEN_CAPTURE_ERR_SERVICE_DIED = AV_SCREEN_CAPTURE_ERR_BASE + 7,<br>AV_SCREEN_CAPTURE_ERR_INVALID_STATE = AV_SCREEN_CAPTURE_ERR_BASE + 8,<br>AV_SCREEN_CAPTURE_ERR_UNSUPPORT = AV_SCREEN_CAPTURE_ERR_BASE + 9,<br>AV_SCREEN_CAPTURE_ERR_EXTEND_START = AV_SCREEN_CAPTURE_ERR_BASE + 100<br>} | Enumerates the error codes generated during screen recording.|
94
95
96### Functions
97
98| Name| Description|
99| -------- | -------- |
100| struct [OH_AVScreenCapture](#oh_avscreencapture) \* [OH_AVScreenCapture_Create](#oh_avscreencapture_create) (void) | Creates an **OH_AVScreenCapture** instance. |
101| [OH_AVSCREEN_CAPTURE_ErrCode](#oh_avscreen_capture_errcode) [OH_AVScreenCapture_Init](#oh_avscreencapture_init) (struct [OH_AVScreenCapture](#oh_avscreencapture) \*capture, [OH_AVScreenCaptureConfig](_o_h___a_v_screen_capture_config.md) config) | Initializes parameters related to an **OH_AVScreenCapture** instance, including audio sampling parameters for external capture using microphones (optional), audio sampling parameters for internal capture, and video resolution parameters. |
102| [OH_AVSCREEN_CAPTURE_ErrCode](#oh_avscreen_capture_errcode) [OH_AVScreenCapture_StartScreenCapture](#oh_avscreencapture_startscreencapture) (struct [OH_AVScreenCapture](#oh_avscreencapture) \*capture) | Starts screen capture and collects original streams. |
103| [OH_AVSCREEN_CAPTURE_ErrCode](#oh_avscreen_capture_errcode) [OH_AVScreenCapture_StartScreenCaptureWithSurface](#oh_avscreencapture_startscreencapturewithsurface) (struct [OH_AVScreenCapture](#oh_avscreencapture) \*capture, OHNativeWindow \*window) | Starts screen capture in surface mode. |
104| [OH_AVSCREEN_CAPTURE_ErrCode](#oh_avscreen_capture_errcode) [OH_AVScreenCapture_StopScreenCapture](#oh_avscreencapture_stopscreencapture) (struct [OH_AVScreenCapture](#oh_avscreencapture) \*capture) | Stops screen capture. This function is used in pair with **OH_AVScreenCapture_StartScreenCapture**. |
105| [OH_AVSCREEN_CAPTURE_ErrCode](#oh_avscreen_capture_errcode) [OH_AVScreenCapture_StartScreenRecording](#oh_avscreencapture_startscreenrecording) (struct [OH_AVScreenCapture](#oh_avscreencapture) \*capture) | Starts screen recording, with recordings saved in files. |
106| [OH_AVSCREEN_CAPTURE_ErrCode](#oh_avscreen_capture_errcode) [OH_AVScreenCapture_StopScreenRecording](#oh_avscreencapture_stopscreenrecording) (struct [OH_AVScreenCapture](#oh_avscreencapture) \*capture) | Stops screen recording. This function is used in pair with **OH_AVScreenCapture_StartScreenRecording**.|
107| [OH_AVSCREEN_CAPTURE_ErrCode](#oh_avscreen_capture_errcode) [OH_AVScreenCapture_AcquireAudioBuffer](#oh_avscreencapture_acquireaudiobuffer) (struct [OH_AVScreenCapture](#oh_avscreencapture) \*capture, [OH_AudioBuffer](_o_h___audio_buffer.md) \*\*audiobuffer, [OH_AudioCaptureSourceType](#oh_audiocapturesourcetype) type) | Obtains an audio buffer. When calling this function, the application must allocate the memory of the corresponding struct size to the audio buffer. |
108| [OH_NativeBuffer](#oh_nativebuffer) \* [OH_AVScreenCapture_AcquireVideoBuffer](#oh_avscreencapture_acquirevideobuffer) (struct [OH_AVScreenCapture](#oh_avscreencapture) \*capture, int32_t \*fence, int64_t \*timestamp, struct [OH_Rect](_o_h___rect.md) \*region) | Obtains a video buffer. An application can call this function to obtain information such as the video buffer and timestamp. |
109| [OH_AVSCREEN_CAPTURE_ErrCode](#oh_avscreen_capture_errcode) [OH_AVScreenCapture_ReleaseAudioBuffer](#oh_avscreencapture_releaseaudiobuffer) (struct [OH_AVScreenCapture](#oh_avscreencapture) \*capture, [OH_AudioCaptureSourceType](#oh_audiocapturesourcetype) type) | Releases an audio buffer. |
110| [OH_AVSCREEN_CAPTURE_ErrCode](#oh_avscreen_capture_errcode) [OH_AVScreenCapture_ReleaseVideoBuffer](#oh_avscreencapture_releasevideobuffer) (struct [OH_AVScreenCapture](#oh_avscreencapture) \*capture) | Releases a video buffer. After the video buffer is no longer needed, call this function to release it. |
111| [OH_AVSCREEN_CAPTURE_ErrCode](#oh_avscreen_capture_errcode) [OH_AVScreenCapture_SetCallback](#oh_avscreencapture_setcallback) (struct [OH_AVScreenCapture](#oh_avscreencapture) \*capture, struct [OH_AVScreenCaptureCallback](_o_h___a_v_screen_capture_callback.md) callback) | Sets a callback to listen for available video buffers and audio buffers and errors that occur during the function calling. |
112| [OH_AVSCREEN_CAPTURE_ErrCode](#oh_avscreen_capture_errcode) [OH_AVScreenCapture_Release](#oh_avscreencapture_release) (struct [OH_AVScreenCapture](#oh_avscreencapture) \*capture) | Releases an **OH_AVScreenCapture** instance. This function is used in pair with **OH_AVScreenCapture_Create**. |
113| [OH_AVSCREEN_CAPTURE_ErrCode](#oh_avscreen_capture_errcode) [OH_AVScreenCapture_SetMicrophoneEnabled](#oh_avscreencapture_setmicrophoneenabled) (struct [OH_AVScreenCapture](#oh_avscreencapture) \*capture, bool isMicrophone) | Enables or disables the microphone. |
114| [OH_AVSCREEN_CAPTURE_ErrCode](#oh_avscreen_capture_errcode) [OH_AVScreenCapture_SetStateCallback](#oh_avscreencapture_setstatecallback) (struct [OH_AVScreenCapture](#oh_avscreencapture) \*capture, [OH_AVScreenCapture_OnStateChange](#oh_avscreencapture_onstatechange) callback, void \*userData) | Sets a state change callback. This function must be called before screen capture starts. |
115| [OH_AVSCREEN_CAPTURE_ErrCode](#oh_avscreen_capture_errcode) [OH_AVScreenCapture_SetDataCallback](#oh_avscreencapture_setdatacallback) (struct [OH_AVScreenCapture](#oh_avscreencapture) \*capture, [OH_AVScreenCapture_OnBufferAvailable](#oh_avscreencapture_onbufferavailable) callback, void \*userData) | Sets a data processing callback. This function must be called before screen capture starts. |
116| [OH_AVSCREEN_CAPTURE_ErrCode](#oh_avscreen_capture_errcode) [OH_AVScreenCapture_SetErrorCallback](#oh_avscreencapture_seterrorcallback) (struct [OH_AVScreenCapture](#oh_avscreencapture) \*capture, [OH_AVScreenCapture_OnError](#oh_avscreencapture_onerror) callback, void \*userData) | Sets an error processing callback. This function must be called before screen capture starts. |
117| [OH_AVSCREEN_CAPTURE_ErrCode](#oh_avscreen_capture_errcode) [OH_AVScreenCapture_SetCanvasRotation](#oh_avscreencapture_setcanvasrotation) (struct [OH_AVScreenCapture](#oh_avscreencapture) \*capture, bool canvasRotation) | Sets canvas rotation for screen capture. |
118| struct [OH_AVScreenCapture_ContentFilter](#oh_avscreencapture_contentfilter) \* [OH_AVScreenCapture_CreateContentFilter](#oh_avscreencapture_createcontentfilter) (void) | Creates a content filter. |
119| [OH_AVSCREEN_CAPTURE_ErrCode](#oh_avscreen_capture_errcode) [OH_AVScreenCapture_ReleaseContentFilter](#oh_avscreencapture_releasecontentfilter) (struct [OH_AVScreenCapture_ContentFilter](#oh_avscreencapture_contentfilter) \*filter) | Releases a content filter. |
120| [OH_AVSCREEN_CAPTURE_ErrCode](#oh_avscreen_capture_errcode) [OH_AVScreenCapture_ContentFilter_AddAudioContent](#oh_avscreencapture_contentfilter_addaudiocontent) (struct [OH_AVScreenCapture_ContentFilter](#oh_avscreencapture_contentfilter) \*filter, [OH_AVScreenCaptureFilterableAudioContent](#oh_avscreencapturefilterableaudiocontent) content) | Adds audio content to a content filter. |
121| [OH_AVSCREEN_CAPTURE_ErrCode](#oh_avscreen_capture_errcode) [OH_AVScreenCapture_ExcludeContent](#oh_avscreencapture_excludecontent) (struct [OH_AVScreenCapture](#oh_avscreencapture) \*capture, struct [OH_AVScreenCapture_ContentFilter](#oh_avscreencapture_contentfilter) \*filter) | Sets a content filter for an **OH_AVScreenCapture** instance. |
122| [OH_AVSCREEN_CAPTURE_ErrCode](#oh_avscreen_capture_errcode) [OH_AVScreenCapture_ContentFilter_AddWindowContent](#oh_avscreencapture_contentfilter_addwindowcontent) (struct [OH_AVScreenCapture_ContentFilter](#oh_avscreencapture_contentfilter) \*filter, int32_t \*windowIDs, int32_t windowCount) | Adds a list of window IDs to a **ContentFilter** instance. |
123| [OH_AVSCREEN_CAPTURE_ErrCode](#oh_avscreen_capture_errcode) [OH_AVScreenCapture_ResizeCanvas](#oh_avscreencapture_resizecanvas) (struct [OH_AVScreenCapture](#oh_avscreencapture) \*capture, int32_t width, int32_t height) | Adjusts the screen resolution. |
124| [OH_AVSCREEN_CAPTURE_ErrCode](#oh_avscreen_capture_errcode) [OH_AVScreenCapture_SkipPrivacyMode](#oh_avscreencapture_skipprivacymode) (struct [OH_AVScreenCapture](#oh_avscreencapture) \*capture, int32_t \*windowIDs, int32_t windowCount) | Exempts privacy windows during screen capture. |
125
126
127## Type Description
128
129
130### OH_AudioBuffer
131
132```
133typedef struct OH_AudioBuffer OH_AudioBuffer
134```
135
136**Description**
137
138Defines a struct for the configuration such as the size, type, and timestamp of audio data.
139
140**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
141
142**Since**: 10
143
144
145### OH_AudioCaptureInfo
146
147```
148typedef struct OH_AudioCaptureInfo OH_AudioCaptureInfo
149```
150
151**Description**
152
153Defines a struct for the audio capture information.
154
155When both **audioSampleRate** and **audioChannels** are **0**, the audio-related parameters are ignored and the audio data is not recorded.
156
157**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
158
159**Since**: 10
160
161
162### OH_AudioCaptureSourceType
163
164```
165typedef enum OH_AudioCaptureSourceType OH_AudioCaptureSourceType
166```
167
168**Description**
169
170Defines an enum for the audio source types during screen capture.
171
172**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
173
174**Since**: 10
175
176
177### OH_AudioCodecFormat
178
179```
180typedef enum OH_AudioCodecFormat OH_AudioCodecFormat
181```
182
183**Description**
184
185Defines an enum for the audio encoding formats.
186
187**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
188
189**Since**: 10
190
191
192### OH_AudioEncInfo
193
194```
195typedef struct OH_AudioEncInfo OH_AudioEncInfo
196```
197
198**Description**
199
200Defines a struct for the audio encoding information.
201
202**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
203
204**Since**: 10
205
206
207### OH_AudioInfo
208
209```
210typedef struct OH_AudioInfo OH_AudioInfo
211```
212
213**Description**
214
215Defines a struct for the audio information.
216
217To perform both external capture (using microphones) and internal capture, **audioSampleRate** and **audioChannels** must be the same for both audio channels.
218
219**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
220
221**Since**: 10
222
223
224### OH_AVSCREEN_CAPTURE_ErrCode
225
226```
227typedef enum OH_AVSCREEN_CAPTURE_ErrCode OH_AVSCREEN_CAPTURE_ErrCode
228```
229
230**Description**
231
232Defines an enum for the error codes generated during screen recording.
233
234**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
235
236**Since**: 10
237
238
239### OH_AVScreenCapture
240
241```
242typedef struct OH_AVScreenCaptureOH_AVScreenCapture
243```
244
245**Description**
246
247Defines a screen capture instance used to obtain original video and audio streams.
248
249**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
250
251**Since**: 10
252
253
254### OH_AVScreenCapture_ContentFilter
255
256```
257typedef struct OH_AVScreenCapture_ContentFilterOH_AVScreenCapture_ContentFilter
258```
259
260**Description**
261
262Defines a struct for the filter used to filter audio and video content.
263
264**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
265
266**Since**: 12
267
268
269### OH_AVScreenCapture_OnBufferAvailable
270
271```
272typedef void(* OH_AVScreenCapture_OnBufferAvailable) (OH_AVScreenCapture *capture, OH_AVBuffer *buffer, OH_AVScreenCaptureBufferType bufferType, int64_t timestamp, void *userData)
273```
274
275**Description**
276
277Defines a pointer to a callback function that is called when an audio or a video buffer is available during the running of an **OH_AVScreenCapture** instance.
278
279**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
280
281**Since**: 12
282
283**Parameters**
284
285| Name| Description|
286| -------- | -------- |
287| capture | Pointer to an **OH_AVScreenCapture** instance. |
288| buffer | Pointer to the **OH_AVBuffer** instance. After the callback is triggered, the buffer is no longer valid. |
289| bufferType | Type of the buffer. |
290| timestamp | Timestamp, in nanoseconds. |
291| userData | Pointer to the user-defined data carried in the function.|
292
293
294### OH_AVScreenCapture_OnError
295
296```
297typedef void(* OH_AVScreenCapture_OnError) (OH_AVScreenCapture *capture, int32_t errorCode, void *userData)
298```
299
300**Description**
301
302Defines a pointer to a callback function that is called when an error occurs during the running of an **OH_AVScreenCapture** instance.
303
304**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
305
306**Since**: 12
307
308**Parameters**
309
310| Name| Description|
311| -------- | -------- |
312| capture | Pointer to an **OH_AVScreenCapture** instance. |
313| errorCode | Error code. |
314| userData | Pointer to the user-defined data carried in the function.|
315
316
317### OH_AVScreenCapture_OnStateChange
318
319```
320typedef void(* OH_AVScreenCapture_OnStateChange) (struct OH_AVScreenCapture *capture, OH_AVScreenCaptureStateCode stateCode, void *userData)
321```
322
323**Description**
324
325Defines a pointer to a callback function that is called when the state changes during the running of an **OH_AVScreenCapture** instance.
326
327**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
328
329**Since**: 12
330
331**Parameters**
332
333| Name| Description|
334| -------- | -------- |
335| capture | Pointer to an **OH_AVScreenCapture** instance. |
336| stateCode | Status code. |
337| userData | Pointer to the user-defined data carried in the function.|
338
339
340### OH_AVScreenCaptureBufferType
341
342```
343typedef enum OH_AVScreenCaptureBufferTypeOH_AVScreenCaptureBufferType
344```
345
346**Description**
347
348Defines an enum for the buffer types.
349
350**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
351
352**Since**: 12
353
354
355### OH_AVScreenCaptureCallback
356
357```
358typedef struct OH_AVScreenCaptureCallback OH_AVScreenCaptureCallback
359```
360
361**Description**
362
363Defines a struct for all the asynchronous callback function pointers of an **OH_AVScreenCapture** instance. To ensure the normal running of **OH_AVScreenCapture**, you must register the instance of this struct with the **OH_AVScreenCapture** instance and process the information reported by the callback functions.
364
365**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
366
367**Since**: 10
368
369**Deprecated from**: 12
370
371**Substitute APIs**
372
373[OH_AVScreenCapture_OnError](#oh_avscreencapture_onerror) and [OH_AVScreenCapture_OnBufferAvailable](#oh_avscreencapture_onbufferavailable)
374
375**Parameters**
376
377| Name| Description|
378| -------- | -------- |
379| onError | Pointer to a callback function that is called when an error occurs during the running of an **OH_AVScreenCapture** instance. For details, see [OH_AVScreenCaptureOnError](#oh_avscreencaptureonerror).|
380| onAudioBufferAvailable | Pointer to a callback function that is called when an audio buffer is available during the running of an **OH_AVScreenCapture** instance. For details, see [OH_AVScreenCaptureOnAudioBufferAvailable](#oh_avscreencaptureonaudiobufferavailable).|
381| onVideoBufferAvailable | Pointer to a callback function that is called when a video buffer is available during the running of an **OH_AVScreenCapture** instance. For details, see [OH_AVScreenCaptureOnVideoBufferAvailable](#oh_avscreencaptureonvideobufferavailable).|
382
383
384### OH_AVScreenCaptureConfig
385
386```
387typedef struct OH_AVScreenCaptureConfig OH_AVScreenCaptureConfig
388```
389
390**Description**
391
392Defines a struct for the screen capture configuration.
393
394**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
395
396**Since**: 10
397
398
399### OH_AVScreenCaptureFilterableAudioContent
400
401```
402typedef enum OH_AVScreenCaptureFilterableAudioContent OH_AVScreenCaptureFilterableAudioContent
403```
404
405**Description**
406
407Defines an enum for the types of audio that can be added to a content filter.
408
409**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
410
411**Since**: 12
412
413
414### OH_AVScreenCaptureOnAudioBufferAvailable
415
416```
417typedef void(* OH_AVScreenCaptureOnAudioBufferAvailable) (OH_AVScreenCapture *capture, bool isReady, OH_AudioCaptureSourceType type)
418```
419
420**Description**
421
422Defines a pointer to a callback function that is called when an audio buffer is available during the running of an **OH_AVScreenCapture** instance.
423
424**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
425
426**Since**: 10
427
428**Deprecated from**: 12
429
430**Substitute API**: [OH_AVScreenCapture_OnBufferAvailable](#oh_avscreencapture_onbufferavailable)
431
432**Parameters**
433
434| Name| Description|
435| -------- | -------- |
436| capture | Pointer to an **OH_AVScreenCapture** instance. |
437| isReady | Whether the audio buffer is available. |
438| type | Audio source type.|
439
440
441### OH_AVScreenCaptureOnError
442
443```
444typedef void(* OH_AVScreenCaptureOnError) (OH_AVScreenCapture *capture, int32_t errorCode)
445```
446
447**Description**
448
449Defines a pointer to a callback function that is called when an error occurs during the running of an **OH_AVScreenCapture** instance.
450
451**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
452
453**Since**: 10
454
455**Deprecated from**: 12
456
457**Substitute API**: [OH_AVScreenCapture_OnError](#oh_avscreencapture_onerror)
458
459**Parameters**
460
461| Name| Description|
462| -------- | -------- |
463| capture | Pointer to an **OH_AVScreenCapture** instance. |
464| errorCode | Error code.|
465
466
467### OH_AVScreenCaptureOnVideoBufferAvailable
468
469```
470typedef void(* OH_AVScreenCaptureOnVideoBufferAvailable) (OH_AVScreenCapture *capture, bool isReady)
471```
472
473**Description**
474
475Defines a pointer to a callback function that is called when a video buffer is available during the running of an **OH_AVScreenCapture** instance.
476
477**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
478
479**Since**: 10
480
481**Deprecated from**: 12
482
483**Substitute API**: [OH_AVScreenCapture_OnBufferAvailable](#oh_avscreencapture_onbufferavailable)
484
485**Parameters**
486
487| Name| Description|
488| -------- | -------- |
489| capture | Pointer to an **OH_AVScreenCapture** instance. |
490| isReady | Whether the video buffer is available.|
491
492
493### OH_AVScreenCaptureStateCode
494
495```
496typedef enum OH_AVScreenCaptureStateCode OH_AVScreenCaptureStateCode
497```
498
499**Description**
500
501Defines an enum for the screen capture states.
502
503**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
504
505**Since**: 12
506
507
508### OH_CaptureMode
509
510```
511typedef enum OH_CaptureMode OH_CaptureMode
512```
513
514**Description**
515
516Defines an enum for the screen capture modes.
517
518**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
519
520**Since**: 10
521
522
523### OH_ContainerFormatType
524
525```
526typedef enum OH_ContainerFormatType OH_ContainerFormatType
527```
528
529**Description**
530
531Defines an enum for the types of files generated during screen capture.
532
533**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
534
535**Since**: 10
536
537
538### OH_DataType
539
540```
541typedef enum OH_DataType OH_DataType
542```
543
544**Description**
545
546Defines an enum for the data types of screen capture streams.
547
548**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
549
550**Since**: 10
551
552
553### OH_NativeBuffer
554
555```
556typedef struct OH_NativeBuffer OH_NativeBuffer
557```
558
559**Description**
560
561Defines the native video stream class for screen capture.
562
563**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
564
565**Since**: 10
566
567
568### OH_RecorderInfo
569
570```
571typedef struct OH_RecorderInfo OH_RecorderInfo
572```
573
574**Description**
575
576Defines a struct for the recording file information.
577
578**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
579
580**Since**: 10
581
582
583### OH_Rect
584
585```
586typedef struct OH_Rect OH_Rect
587```
588
589**Description**
590
591Defines a struct for the width, height, and image information of the rectangle used for screen capture.
592
593**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
594
595**Since**: 10
596
597
598### OH_VideoCaptureInfo
599
600```
601typedef struct OH_VideoCaptureInfo OH_VideoCaptureInfo
602```
603
604**Description**
605
606Defines a struct for the video capture information.
607
608When **videoFrameWidth** and **videoFrameHeight** are both **0**, video-related parameters are ignored and screen data is not recorded.
609
610**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
611
612**Since**: 10
613
614
615### OH_VideoCodecFormat
616
617```
618typedef enum OH_VideoCodecFormat OH_VideoCodecFormat
619```
620
621**Description**
622
623Defines an enum for the video encoding formats.
624
625**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
626
627**Since**: 10
628
629
630### OH_VideoEncInfo
631
632```
633typedef struct OH_VideoEncInfo OH_VideoEncInfo
634```
635
636**Description**
637
638Defines a struct for the video encoding information.
639
640**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
641
642**Since**: 10
643
644
645### OH_VideoInfo
646
647```
648typedef struct OH_VideoInfo OH_VideoInfo
649```
650
651**Description**
652
653Defines a struct for the video information.
654
655**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
656
657**Since**: 10
658
659
660### OH_VideoSourceType
661
662```
663typedef enum OH_VideoSourceType OH_VideoSourceType
664```
665
666**Description**
667
668Defines an enum for the video source formats.
669
670**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
671
672**Since**: 10
673
674
675## Enum Description
676
677
678### OH_AudioCaptureSourceType
679
680```
681enum OH_AudioCaptureSourceType
682```
683
684**Description**
685
686Enumerates the audio source types during screen capture.
687
688**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
689
690**Since**: 10
691
692| Value| Description|
693| -------- | -------- |
694| OH_SOURCE_INVALID  | Invalid audio source.  |
695| OH_SOURCE_DEFAULT  | Default audio source. The default value is **MIC**.  |
696| OH_MIC  | External audio streams recorded by the microphone.  |
697| OH_ALL_PLAYBACK  | All internal audio streams played by the system.  |
698| OH_APP_PLAYBACK  | Internal audio streams played by a specified application.  |
699
700
701### OH_AudioCodecFormat
702
703```
704enum OH_AudioCodecFormat
705```
706
707**Description**
708
709Enumerates the audio encoding formats.
710
711**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
712
713**Since**: 10
714
715| Value| Description|
716| -------- | -------- |
717| OH_AUDIO_DEFAULT  | Default audio encoding format. The default value is **AAC_LC**.  |
718| OH_AAC_LC  | AAC_LC audio encoding.  |
719| OH_AUDIO_CODEC_FORMAT_BUTT  | Invalid format.  |
720
721
722### OH_AVSCREEN_CAPTURE_ErrCode
723
724```
725enum OH_AVSCREEN_CAPTURE_ErrCode
726```
727
728**Description**
729
730Enumerates the error codes generated during screen recording.
731
732**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
733
734**Since**: 10
735
736| Value| Description|
737| -------- | -------- |
738| AV_SCREEN_CAPTURE_ERR_BASE | Basic value returned when an API call error occurs.|
739| AV_SCREEN_CAPTURE_ERR_OK | Operation successful.|
740| AV_SCREEN_CAPTURE_ERR_NO_MEMORY | Memory insufficient.|
741| AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT | Operation not allowed.|
742| AV_SCREEN_CAPTURE_ERR_INVALID_VAL | Invalid parameter.|
743| AV_SCREEN_CAPTURE_ERR_IO | Abnormal input and output streams.|
744| AV_SCREEN_CAPTURE_ERR_TIMEOUT | Network timeout.|
745| AV_SCREEN_CAPTURE_ERR_UNKNOWN | Unknown error.|
746| AV_SCREEN_CAPTURE_ERR_SERVICE_DIED | Media service terminated.|
747| AV_SCREEN_CAPTURE_ERR_INVALID_STATE | Unsupported operation in this state.|
748| AV_SCREEN_CAPTURE_ERR_UNSUPPORT | Unsupported interface.|
749| AV_SCREEN_CAPTURE_ERR_EXTEND_START | Unexpected error.|
750
751
752### OH_AVScreenCaptureBufferType
753
754```
755enum OH_AVScreenCaptureBufferType
756```
757
758**Description**
759
760Enumerates the buffer types.
761
762**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
763
764**Since**: 12
765
766| Value| Description|
767| -------- | -------- |
768| OH_SCREEN_CAPTURE_BUFFERTYPE_VIDEO  | Video data.  |
769| OH_SCREEN_CAPTURE_BUFFERTYPE_AUDIO_INNER  | Internal audio capture data.  |
770| OH_SCREEN_CAPTURE_BUFFERTYPE_AUDIO_MIC  | Microphone audio data.  |
771
772
773### OH_AVScreenCaptureFilterableAudioContent
774
775```
776enum OH_AVScreenCaptureFilterableAudioContent
777```
778
779**Description**
780
781Enumerates the types of audio that can be added to a content filter.
782
783**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
784
785**Since**: 12
786
787| Value| Description|
788| -------- | -------- |
789| OH_SCREEN_CAPTURE_NOTIFICATION_AUDIO  | Notification tone.  |
790| OH_SCREEN_CAPTURE_CURRENT_APP_AUDIO  | Sound of the application itself.  |
791
792
793### OH_AVScreenCaptureStateCode
794
795```
796enum OH_AVScreenCaptureStateCode
797```
798
799**Description**
800
801Enumerates the screen capture states.
802
803**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
804
805**Since**: 12
806
807| Value| Description|
808| -------- | -------- |
809| OH_SCREEN_CAPTURE_STATE_STARTED  | Screen capture is started.  |
810| OH_SCREEN_CAPTURE_STATE_CANCELED  | Screen capture is canceled.  |
811| OH_SCREEN_CAPTURE_STATE_STOPPED_BY_USER  | Screen capture is stopped.  |
812| OH_SCREEN_CAPTURE_STATE_INTERRUPTED_BY_OTHER  | Screen capture is interrupted by another screen capture.  |
813| OH_SCREEN_CAPTURE_STATE_STOPPED_BY_CALL  | Screen capture is interrupted by a call.  |
814| OH_SCREEN_CAPTURE_STATE_MIC_UNAVAILABLE  | The microphone is unavailable.  |
815| OH_SCREEN_CAPTURE_STATE_MIC_MUTED_BY_USER  | The microphone is muted.  |
816| OH_SCREEN_CAPTURE_STATE_MIC_UNMUTED_BY_USER  | The microphone is unmuted.   |
817| OH_SCREEN_CAPTURE_STATE_ENTER_PRIVATE_SCENE  | The system enters a privacy dialog box.   |
818| OH_SCREEN_CAPTURE_STATE_EXIT_PRIVATE_SCENE  | The system exits a privacy dialog box.   |
819| OH_SCREEN_CAPTURE_STATE_STOPPED_BY_USER_SWITCHES   | Screen capture is interrupted by system user switching.|
820
821
822### OH_CaptureMode
823
824```
825enum OH_CaptureMode
826```
827
828**Description**
829
830Enumerates the screen capture modes.
831
832**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
833
834**Since**: 10
835
836| Value| Description|
837| -------- | -------- |
838| OH_CAPTURE_HOME_SCREEN  | Captures the home screen.  |
839| OH_CAPTURE_SPECIFIED_SCREEN  | Captures a specified screen.  |
840| OH_CAPTURE_SPECIFIED_WINDOW  | Captures a specified window.  |
841| OH_CAPTURE_INVAILD  | Invalid mode.  |
842
843
844### OH_ContainerFormatType
845
846```
847enum OH_ContainerFormatType
848```
849
850**Description**
851
852Enumerates the types of files generated during screen capture.
853
854**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
855
856**Since**: 10
857
858| Value| Description|
859| -------- | -------- |
860| CFT_MPEG_4A  | Audio format M4A.  |
861| CFT_MPEG_4  | Video format MP4.  |
862
863
864### OH_DataType
865
866```
867enum OH_DataType
868```
869
870**Description**
871
872Enumerates the data types of screen capture streams.
873
874**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
875
876**Since**: 10
877
878| Value| Description|
879| -------- | -------- |
880| OH_ORIGINAL_STREAM  | Original stream format, such as YUV, RGBA, and PCM.  |
881| OH_ENCODED_STREAM  | Encoded stream format, such as H.264 and AAC. This value is not supported yet.  |
882| OH_CAPTURE_FILE  | Format of the recording file. The value can be **mp4**.  |
883| OH_INVAILD  | Invalid format.  |
884
885
886### OH_VideoCodecFormat
887
888```
889enum OH_VideoCodecFormat
890```
891
892**Description**
893
894Enumerates the video encoding formats.
895
896**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
897
898**Since**: 10
899
900| Value| Description|
901| -------- | -------- |
902| OH_VIDEO_DEFAULT | Default video encoding format. The default value is **H.264**.|
903| OH_H264 | H.264.|
904| OH_H265 | H.265/HEVC.|
905| OH_MPEG4 | MPEG4.|
906| OH_VP8 | VP8.|
907| OH_VP9 | VP9.|
908| OH_VIDEO_CODEC_FORMAT_BUTT | Invalid format.|
909
910
911### OH_VideoSourceType
912
913```
914enum OH_VideoSourceType
915```
916
917**Description**
918
919Enumerates the video source formats.
920
921**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
922
923**Since**: 10
924
925| Value| Description|
926| -------- | -------- |
927| OH_VIDEO_SOURCE_SURFACE_YUV  | YUV format.  |
928| OH_VIDEO_SOURCE_SURFACE_ES  | Raw format.  |
929| OH_VIDEO_SOURCE_SURFACE_RGBA  | RGBA format.  |
930| OH_VIDEO_SOURCE_BUTT  | Invalid format.  |
931
932
933## Function Description
934
935
936### OH_AVScreenCapture_AcquireAudioBuffer()
937
938```
939OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_AcquireAudioBuffer (struct OH_AVScreenCapture * capture, OH_AudioBuffer ** audiobuffer, OH_AudioCaptureSourceType type )
940```
941
942**Description**
943
944Obtains an audio buffer. When calling this function, the application must allocate the memory of the corresponding struct size to the audio buffer.
945
946**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
947
948**Since**: 10
949
950**Deprecated from**: 12
951
952**Substitute API**: [OH_AVScreenCapture_OnBufferAvailable](#oh_avscreencapture_onbufferavailable)
953
954**Parameters**
955
956| Name| Description|
957| -------- | -------- |
958| capture | Pointer to an [OH_AVScreenCapture](#oh_avscreencapture) instance.|
959| audiobuffer | Pointer to the struct for storing the audio buffer. This struct is used to obtain the information about the audio buffer and the timestamp of the buffer.|
960| type | Type of the audio buffer, which is used to distinguish external streams recorded by the microphone from internal streams played by the system. For details, see [OH_AudioCaptureSourceType](#oh_audiocapturesourcetype).|
961
962**Returns**
963
964Returns a result code defined in [OH_AVErrCode](../apis-avcodec-kit/_core.md#oh_averrcode-1). The following result codes are possible:
965
966**AV_SCREEN_CAPTURE_ERR_OK**: The operation is successful.
967
968**AV_SCREEN_CAPTURE_ERR_INVALID_VAL**: The input parameter **capture** or **audiobuffer** is a null pointer.
969
970**AV_SCREEN_CAPTURE_ERR_NO_MEMORY**: The audio buffer fails to be allocated due to insufficient memory.
971
972**AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT**: The operation is not allowed. The privacy permission fails to be enabled or the audio buffer fails to be obtained.
973
974
975
976### OH_AVScreenCapture_AcquireVideoBuffer()
977
978```
979OH_NativeBuffer* OH_AVScreenCapture_AcquireVideoBuffer (struct OH_AVScreenCapture * capture, int32_t * fence, int64_t * timestamp, struct OH_Rect * region )
980```
981
982**Description**
983
984Obtains a video buffer. An application can call this function to obtain information such as the video buffer and timestamp. After the buffer is no longer needed, call [OH_AVScreenCapture_ReleaseVideoBuffer](#oh_avscreencapture_releasevideobuffer) to release it.
985
986**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
987
988**Since**: 10
989
990**Deprecated from**: 12
991
992**Substitute API**: [OH_AVScreenCapture_OnBufferAvailable](#oh_avscreencapture_onbufferavailable)
993
994**Parameters**
995
996| Name| Description|
997| -------- | -------- |
998| capture | Pointer to an [OH_AVScreenCapture](#oh_avscreencapture) instance. |
999| fence | Pointer to parameters for synchronization display. |
1000| timestamp | Pointer to the timestamp of the video frame. |
1001| region | Pointer to the coordinates related to video display. |
1002
1003**Returns**
1004
1005Returns an **OH_NativeBuffer** object if the operation is successful. The application can call the APIs provided by the **OH_NativeBuffer** object to obtain information such as the video buffer and resolution.
1006
1007
1008### OH_AVScreenCapture_ContentFilter_AddAudioContent()
1009
1010```
1011OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ContentFilter_AddAudioContent (struct OH_AVScreenCapture_ContentFilter * filter, OH_AVScreenCaptureFilterableAudioContent content )
1012```
1013
1014**Description**
1015
1016Adds audio content to a content filter.
1017
1018**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
1019
1020**Since**: 12
1021
1022**Parameters**
1023
1024| Name| Description|
1025| -------- | -------- |
1026| filter | Pointer to an [OH_AVScreenCapture_ContentFilter](#oh_avscreencapture_contentfilter) instance.|
1027| content | [OH_AVScreenCaptureFilterableAudioContent](#oh_avscreencapturefilterableaudiocontent) instance.|
1028
1029**Returns**
1030
1031Returns a result code defined in [OH_AVErrCode](../apis-avcodec-kit/_core.md#oh_averrcode-1). The following result codes are possible:
1032
1033**AV_SCREEN_CAPTURE_ERR_OK**: The operation is successful.
1034
1035**AV_SCREEN_CAPTURE_ERR_INVALID_VAL**: The input parameter **filter** is a null pointer or the input parameter **content** is invalid.
1036
1037
1038### OH_AVScreenCapture_ContentFilter_AddWindowContent()
1039
1040```
1041OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ContentFilter_AddWindowContent (struct OH_AVScreenCapture_ContentFilter *filter, int32_t *windowIDs, int32_t windowCount)
1042```
1043
1044**Description**
1045
1046Adds a list of window IDs to a **ContentFilter** instance.
1047
1048**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
1049
1050**Since**: 12
1051
1052**Parameters**
1053
1054| Name| Description|
1055| -------- | -------- |
1056| filter | Pointer to an **OH_AVScreenCapture_ContentFilter** instance. |
1057| windowIDs | Pointer to the window IDs. |
1058| windowCount | Length of the window ID list. |
1059
1060**Returns**
1061
1062Returns **AV_SCREEN_CAPTURE_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVSCREEN_CAPTURE_ErrCode](#oh_avscreen_capture_errcode-1) otherwise.
1063
1064
1065### OH_AVScreenCapture_Create()
1066
1067```
1068struct OH_AVScreenCapture* OH_AVScreenCapture_Create (void )
1069```
1070
1071**Description**
1072
1073Creates an **OH_AVScreenCapture** instance. You can release the instance by calling [OH_AVScreenCapture_Release](#oh_avscreencapture_release).
1074
1075**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
1076
1077**Since**: 10
1078
1079**Returns**
1080
1081Returns the pointer to an [OH_AVScreenCapture](#oh_avscreencapture) instance.
1082
1083
1084### OH_AVScreenCapture_CreateContentFilter()
1085
1086```
1087struct OH_AVScreenCapture_ContentFilter* OH_AVScreenCapture_CreateContentFilter (void )
1088```
1089
1090**Description**
1091
1092Creates a content filter.
1093
1094**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
1095
1096**Since**: 12
1097
1098**Returns**
1099
1100Returns [OH_AVScreenCapture_ContentFilter](#oh_avscreencapture_contentfilter) if the operation is successful; returns a null pointer otherwise.
1101
1102
1103### OH_AVScreenCapture_ExcludeContent()
1104
1105```
1106OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ExcludeContent (struct OH_AVScreenCapture * capture, struct OH_AVScreenCapture_ContentFilter * filter )
1107```
1108
1109**Description**
1110
1111Sets a content filter for an **OH_AVScreenCapture** instance.
1112
1113**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
1114
1115**Since**: 12
1116
1117**Parameters**
1118
1119| Name| Description|
1120| -------- | -------- |
1121| capture | Pointer to an [OH_AVScreenCapture](#oh_avscreencapture) instance.|
1122| filter | Pointer to an [OH_AVScreenCapture_ContentFilter](#oh_avscreencapture_contentfilter) instance.|
1123
1124**Returns**
1125
1126Returns a result code defined in [OH_AVErrCode](../apis-avcodec-kit/_core.md#oh_averrcode-1). The following result codes are possible:
1127
1128**AV_SCREEN_CAPTURE_ERR_OK**: The operation is successful.
1129
1130**AV_SCREEN_CAPTURE_ERR_INVALID_VAL**: The input parameter **capture** or **filter** is a null pointer.
1131
1132**AV_SCREEN_CAPTURE_ERR_UNSUPPORT**: The operation is not supported. For streams, the **AudioCapturer** API must be called for the operation to take effect during the start. For captured files, the **AudioRecorder** API must be called for the operation to take effect during the start.
1133
1134
1135### OH_AVScreenCapture_Init()
1136
1137```
1138OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_Init (struct OH_AVScreenCapture * capture, OH_AVScreenCaptureConfig config )
1139```
1140
1141**Description**
1142
1143Initializes parameters related to an [OH_AVScreenCapture](#oh_avscreencapture) instance, including audio sampling parameters for external capture using microphones (optional), audio sampling parameters for internal capture, and video resolution parameters.
1144
1145In the scenario where screen recording files are stored, the application must ensure that the video encoding parameters, video sampling parameters, audio encoding parameters, audio sampling parameters for internal capture, and audio sampling parameters for external capture using microphones (optional) are valid.
1146
1147In the scenario where screen capture streams are generated, the application must ensure that either audio sampling parameters for internal capture or video sampling parameters are valid, or both are valid, and audio sampling parameters for external capture using microphones are valid (optional).
1148
1149The members of the struct variables are not initialized during initialization. Therefore, the application must correctly set the parameters based on the use scenario. You are advised to
1150set all memory bytes of the OH_AVScreenCaptureConfig struct variables to **0**, and then set valid parameters based on the screen capture scenario.
1151
1152If both **audioSampleRate** and **audioChannels** in the [OH_AudioCaptureInfo](#oh_audiocaptureinfo) struct are **0**,
1153the **OH_AVScreenCapture** instance ignores the audio parameters of this type and does not collect the audio data of this type.
1154
1155If both **videoFrameWidth** and **videoFrameHeight** in the [OH_AudioCaptureInfo](#oh_audiocaptureinfo) struct are **0**,
1156the **OH_AVScreenCapture** instance ignores the corresponding video parameters and does not collect screen data.
1157
1158**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
1159
1160**Since**: 10
1161
1162**Parameters**
1163
1164| Name| Description|
1165| -------- | -------- |
1166| capture | Pointer to an [OH_AVScreenCapture](#oh_avscreencapture) instance.|
1167| config | Parameters related to screen capture initialization.|
1168
1169**Returns**
1170
1171Returns a result code defined in [OH_AVErrCode](../apis-avcodec-kit/_core.md#oh_averrcode-1). The following result codes are possible:
1172
1173**AV_SCREEN_CAPTURE_ERR_OK**: The operation is successful.
1174
1175**AV_SCREEN_CAPTURE_ERR_INVALID_VAL**: The input parameter **capture** is a null pointer.
1176
1177**AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT**: The operation is not allowed. The configuration fails to be initialized.
1178
1179
1180### OH_AVScreenCapture_Release()
1181
1182```
1183OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_Release (struct OH_AVScreenCapture * capture)
1184```
1185
1186**Description**
1187
1188Releases an **OH_AVScreenCapture** instance. This function is used in pair with [OH_AVScreenCapture_Create](#oh_avscreencapture_create).
1189
1190**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
1191
1192**Since**: 10
1193
1194**Parameters**
1195
1196| Name| Description|
1197| -------- | -------- |
1198| capture | Pointer to an [OH_AVScreenCapture](#oh_avscreencapture) instance.|
1199
1200**Returns**
1201
1202Returns a result code defined in [OH_AVErrCode](../apis-avcodec-kit/_core.md#oh_averrcode-1). The following result codes are possible:
1203
1204**AV_SCREEN_CAPTURE_ERR_OK**: The operation is successful.
1205
1206**AV_SCREEN_CAPTURE_ERR_INVALID_VAL**: The input parameter **capture** is a null pointer.
1207
1208**AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT**: The operation is not allowed. The **OH_AVScreenCapture** instance fails to be released.
1209
1210### OH_AVScreenCapture_ReleaseAudioBuffer()
1211
1212```
1213OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ReleaseAudioBuffer (struct OH_AVScreenCapture * capture, OH_AudioCaptureSourceType type )
1214```
1215
1216**Description**
1217
1218Releases an audio buffer. After the audio buffer is no longer needed, call this function to release it.
1219
1220**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
1221
1222**Since**: 10
1223
1224**Deprecated from**: 12
1225
1226**Substitute API**: [OH_AVScreenCapture_OnBufferAvailable](#oh_avscreencapture_onbufferavailable)
1227
1228**Parameters**
1229
1230| Name| Description|
1231| -------- | -------- |
1232| capture | Pointer to an [OH_AVScreenCapture](#oh_avscreencapture) instance.|
1233| type | Type of the audio buffer, which is used to distinguish external streams recorded by the microphone from internal streams played by the system.|
1234
1235**Returns**
1236
1237Returns a result code defined in [OH_AVErrCode](../apis-avcodec-kit/_core.md#oh_averrcode-1). The following result codes are possible:
1238
1239**AV_SCREEN_CAPTURE_ERR_OK**: The operation is successful.
1240
1241**AV_SCREEN_CAPTURE_ERR_INVALID_VAL**: The input parameter **capture** is a null pointer.
1242
1243**AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT**: The operation is not allowed. The data callback has been set or the audio buffer fails to be released.
1244
1245
1246### OH_AVScreenCapture_ReleaseContentFilter()
1247
1248```
1249OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ReleaseContentFilter (struct OH_AVScreenCapture_ContentFilter * filter)
1250```
1251
1252**Description**
1253
1254Releases a content filter.
1255
1256**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
1257
1258**Since**: 12
1259
1260**Parameters**
1261
1262| Name| Description|
1263| -------- | -------- |
1264| filter | Pointer to an [OH_AVScreenCapture_ContentFilter](#oh_avscreencapture_contentfilter) instance.|
1265
1266**Returns**
1267
1268Returns a result code defined in [OH_AVErrCode](../apis-avcodec-kit/_core.md#oh_averrcode-1). The following result codes are possible:
1269
1270**AV_SCREEN_CAPTURE_ERR_OK**: The operation is successful.
1271
1272**AV_SCREEN_CAPTURE_ERR_INVALID_VAL**: The input parameter **filter** is a null pointer.
1273
1274
1275### OH_AVScreenCapture_ReleaseVideoBuffer()
1276
1277```
1278OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ReleaseVideoBuffer (struct OH_AVScreenCapture * capture)
1279```
1280
1281**Description**
1282
1283Releases a video buffer. After the video buffer is no longer needed, call this function to release it.
1284
1285**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
1286
1287**Since**: 10
1288
1289**Deprecated from**: 12
1290
1291**Substitute API**: [OH_AVScreenCapture_OnBufferAvailable](#oh_avscreencapture_onbufferavailable)
1292
1293**Parameters**
1294
1295| Name| Description|
1296| -------- | -------- |
1297| capture | Pointer to an [OH_AVScreenCapture](#oh_avscreencapture) instance.|
1298
1299**Returns**
1300
1301Returns a result code defined in [OH_AVErrCode](../apis-avcodec-kit/_core.md#oh_averrcode-1). The following result codes are possible:
1302
1303**AV_SCREEN_CAPTURE_ERR_OK**: The operation is successful.
1304
1305**AV_SCREEN_CAPTURE_ERR_INVALID_VAL**: The input parameter **capture** is a null pointer.
1306
1307**AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT**: The operation is not allowed. The data callback has been set or the video buffer fails to be released.
1308
1309
1310### OH_AVScreenCapture_SetCallback()
1311
1312```
1313OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetCallback (struct OH_AVScreenCapture * capture, struct OH_AVScreenCaptureCallback callback )
1314```
1315
1316**Description**
1317
1318Sets a callback to listen for available video buffers and audio buffers and errors that occur during the function calling.
1319
1320**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
1321
1322**Since**: 10
1323
1324**Deprecated from**: 12
1325
1326**Substitute API**: [OH_AVScreenCapture_SetErrorCallback](#oh_avscreencapture_seterrorcallback) and [OH_AVScreenCapture_SetDataCallback](#oh_avscreencapture_setdatacallback)
1327
1328**Parameters**
1329
1330| Name| Description|
1331| -------- | -------- |
1332| capture | Pointer to an [OH_AVScreenCapture](#oh_avscreencapture) instance.|
1333| callback | [OH_AVScreenCaptureCallback](_o_h___a_v_screen_capture_callback.md) struct, which stores related callback function pointers.|
1334
1335**Returns**
1336
1337Returns a result code defined in [OH_AVErrCode](../apis-avcodec-kit/_core.md#oh_averrcode-1). The following result codes are possible:
1338
1339**AV_SCREEN_CAPTURE_ERR_OK**: The operation is successful.
1340
1341**AV_SCREEN_CAPTURE_ERR_INVALID_VAL**: The input parameter **capture** or **callback** is a null pointer.
1342
1343**AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT**: The operation is not allowed. The callback fails to be set.
1344
1345
1346### OH_AVScreenCapture_SetCanvasRotation()
1347
1348```
1349OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetCanvasRotation (struct OH_AVScreenCapture * capture, bool canvasRotation )
1350```
1351
1352**Description**
1353
1354Sets canvas rotation for screen capture.
1355
1356You can call this function to set whether to rotate the recorded screen data. When **canvasRotation** is set to **true**, screen capture rotation is enabled and the recorded screen data remains positive.
1357
1358The default value is **false**.
1359
1360**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
1361
1362**Since**: 12
1363
1364**Parameters**
1365
1366| Name| Description|
1367| -------- | -------- |
1368| capture | Pointer to an [OH_AVScreenCapture](#oh_avscreencapture) instance.|
1369| canvasRotation | Whether to enable screen data rotation.|
1370
1371**Returns**
1372
1373Returns a result code defined in [OH_AVErrCode](../apis-avcodec-kit/_core.md#oh_averrcode-1). The following result codes are possible:
1374
1375**AV_SCREEN_CAPTURE_ERR_OK**: The operation is successful.
1376
1377**AV_SCREEN_CAPTURE_ERR_INVALID_VAL**: The input parameter **capture** is a null pointer.
1378
1379**AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT**: The operation is not allowed. Canvas rotation fails to be set for screen capture.
1380
1381
1382### OH_AVScreenCapture_SetDataCallback()
1383
1384```
1385OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetDataCallback (struct OH_AVScreenCapture * capture, OH_AVScreenCapture_OnBufferAvailable callback, void * userData )
1386```
1387
1388**Description**
1389
1390Sets a data processing callback. This function must be called before screen capture starts.
1391
1392The callback is triggered when an audio buffer or a video buffer becomes available during the running of an **OH_AVScreenCapture** instance.
1393
1394The application needs to process microphone audio, internal audio, and video data based on the data type in the callback. After the callback is triggered, the buffer is no longer valid.
1395
1396A successful call to this function leads to the following scenarios:
1397
1398- The callbacks [OH_AVScreenCaptureOnAudioBufferAvailable](#oh_avscreencaptureonaudiobufferavailable) and [OH_AVScreenCaptureOnVideoBufferAvailable](#oh_avscreencaptureonvideobufferavailable) set by calling [OH_AVScreenCapture_SetCallback](#oh_avscreencapture_setcallback) will no longer be triggered, even when an audio buffer or a video buffer becomes available.
1399- A failure message is returned for a call to any of the following functions: [OH_AVScreenCapture_AcquireAudioBuffer](#oh_avscreencapture_acquireaudiobuffer), [OH_AVScreenCapture_ReleaseAudioBuffer](#oh_avscreencapture_releaseaudiobuffer), [OH_AVScreenCapture_AcquireVideoBuffer](#oh_avscreencapture_acquirevideobuffer), and [OH_AVScreenCapture_ReleaseVideoBuffer](#oh_avscreencapture_releasevideobuffer).
1400
1401**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
1402
1403**Since**: 12
1404
1405**Parameters**
1406
1407| Name| Description|
1408| -------- | -------- |
1409| capture | Pointer to an [OH_AVScreenCapture](#oh_avscreencapture) instance.|
1410| callback | Data processing callback, which is [OH_AVScreenCapture_OnBufferAvailable](#oh_avscreencapture_onbufferavailable).|
1411| userData | Pointer to the user-defined data. The data is returned as an input parameter when the data processing callback is triggered.|
1412
1413**Returns**
1414
1415Returns a result code defined in [OH_AVErrCode](../apis-avcodec-kit/_core.md#oh_averrcode-1). The following result codes are possible:
1416
1417**AV_SCREEN_CAPTURE_ERR_OK**: The operation is successful.
1418
1419**AV_SCREEN_CAPTURE_ERR_INVALID_VAL**: The input parameter **capture** or **callback** is a null pointer.
1420
1421**AV_SCREEN_CAPTURE_ERR_NO_MEMORY**: The memory fails to be allocated due to insufficient memory.
1422
1423**AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT**: The operation is not allowed. The data callback fails to be set.
1424
1425
1426### OH_AVScreenCapture_SetErrorCallback()
1427
1428```
1429OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetErrorCallback (struct OH_AVScreenCapture * capture, OH_AVScreenCapture_OnError callback, void * userData )
1430```
1431
1432**Description**
1433
1434Sets an error processing callback. This function must be called before screen capture starts.
1435
1436The callback is triggered when an error occurs during the running of an **OH_AVScreenCapture** instance.
1437
1438After a successful call to this function, the callback [OH_AVScreenCaptureOnError](#oh_avscreencaptureonerror) set by calling [OH_AVScreenCapture_SetCallback](#oh_avscreencapture_setcallback) will no longer be triggered, even when an error occurs in the **OH_AVScreenCapture** instance.
1439
1440**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
1441
1442**Since**: 12
1443
1444**Parameters**
1445
1446| Name| Description|
1447| -------- | -------- |
1448| capture | Pointer to an [OH_AVScreenCapture](#oh_avscreencapture) instance.|
1449| callback | Error processing callback, which is [OH_AVScreenCapture_OnError](#oh_avscreencapture_onerror).|
1450| userData | Pointer to the user-defined data. The data is returned as an input parameter when the error processing callback is triggered.|
1451
1452**Returns**
1453
1454Returns a result code defined in [OH_AVErrCode](../apis-avcodec-kit/_core.md#oh_averrcode-1). The following result codes are possible:
1455
1456**AV_SCREEN_CAPTURE_ERR_OK**: The operation is successful.
1457
1458**AV_SCREEN_CAPTURE_ERR_INVALID_VAL**: The input parameter **capture** or **callback** is a null pointer.
1459
1460**AV_SCREEN_CAPTURE_ERR_NO_MEMORY**: The memory fails to be allocated due to insufficient memory.
1461
1462**AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT**: The operation is not allowed. The error callback fails to be set.
1463
1464
1465### OH_AVScreenCapture_SetMicrophoneEnabled()
1466
1467```
1468OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetMicrophoneEnabled (struct OH_AVScreenCapture * capture, bool isMicrophone )
1469```
1470
1471**Description**
1472
1473Enables or disables the microphone. When **isMicrophone** is set to **true**, the microphone is enabled, and the original PCM data of the microphone can be obtained by calling [OH_AVScreenCapture_StartScreenCapture](#oh_avscreencapture_startscreencapture) and [OH_AVScreenCapture_AcquireAudioBuffer](#oh_avscreencapture_acquireaudiobuffer). When **isMicrophone** is set to **false**, the obtained audio data is silent data.
1474
1475By default, the microphone is enabled.
1476
1477**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
1478
1479**Since**: 10
1480
1481**Parameters**
1482
1483| Name| Description|
1484| -------- | -------- |
1485| capture | Pointer to an [OH_AVScreenCapture](#oh_avscreencapture) instance.|
1486| isMicrophone | Whether to enable the microphone.|
1487
1488**Returns**
1489
1490Returns a result code defined in [OH_AVErrCode](../apis-avcodec-kit/_core.md#oh_averrcode-1). The following result codes are possible:
1491
1492**AV_SCREEN_CAPTURE_ERR_OK**: The operation is successful.
1493
1494**AV_SCREEN_CAPTURE_ERR_INVALID_VAL**: The input parameter **capture** is a null pointer.
1495
1496**AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT**: The operation is not allowed. The microphone fails to be enabled or disabled.
1497
1498
1499### OH_AVScreenCapture_SetStateCallback()
1500
1501```
1502OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetStateCallback (struct OH_AVScreenCapture * capture, OH_AVScreenCapture_OnStateChange callback, void * userData )
1503```
1504
1505**Description**
1506
1507Sets a state change callback. This function must be called before screen capture starts.
1508
1509The callback is triggered when the state changes during the running of an **OH_AVScreenCapture** instance.
1510
1511A privacy dialog box is displayed to ask for user consent before screen capture starts. After a successful call to this function, the following scenarios are possible:
1512
1513- If the user agrees, the screen capture startup process starts.
1514
1515  - If screen capture starts successfully, the state change callback is triggered to report the [OH_SCREEN_CAPTURE_STATE_STARTED](#oh_avscreencapturestatecode-1) status to notify the application of the startup success, with a screen capture notification displayed.
1516
1517  - If screen capture fails to start, the state change callback is triggered to report the failure information (for example, [OH_SCREEN_CAPTURE_STATE_MIC_UNAVAILABLE](#oh_avscreencapturestatecode-1) if the microphone is unavailable), or the error processing callback [OH_AVScreenCapture_OnError](#oh_avscreencapture_onerror) is triggered to report the error information.
1518
1519- If the user disagrees, the screen capture startup process stops. The state change callback is triggered to report the [OH_SCREEN_CAPTURE_STATE_CANCELED](#oh_avscreencapturestatecode-1) status to notify the application of the startup failure due to user rejection.
1520
1521**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
1522
1523**Since**: 12
1524
1525**Parameters**
1526
1527| Name| Description|
1528| -------- | -------- |
1529| capture | Pointer to an [OH_AVScreenCapture](#oh_avscreencapture) instance.|
1530| callback | State change callback, which is [OH_AVScreenCapture_OnStateChange](#oh_avscreencapture_onstatechange).|
1531| userData | Pointer to the user-defined data. The data is returned as an input parameter when the state change callback is triggered.|
1532
1533**Returns**
1534
1535Returns a result code defined in [OH_AVErrCode](../apis-avcodec-kit/_core.md#oh_averrcode-1). The following result codes are possible:
1536
1537**AV_SCREEN_CAPTURE_ERR_OK**: The operation is successful.
1538
1539**AV_SCREEN_CAPTURE_ERR_INVALID_VAL**: The input parameter **capture** or **callback** is a null pointer.
1540
1541**AV_SCREEN_CAPTURE_ERR_NO_MEMORY**: The memory fails to be allocated due to insufficient memory.
1542
1543**AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT**: The operation is not allowed. The state callback fails to be set.
1544
1545
1546### OH_AVScreenCapture_StartScreenCapture()
1547
1548```
1549OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_StartScreenCapture (struct OH_AVScreenCapture * capture)
1550```
1551
1552**Description**
1553
1554Starts screen capture and collects original streams. After this function is called, the callback ([OH_AVScreenCapture_OnBufferAvailable](#oh_avscreencapture_onbufferavailable)) can be used to check whether streams are generated, and the callback ([OH_AVScreenCapture_OnStateChange](#oh_avscreencapture_onstatechange)) can be used to check the startup status.
1555
1556The application can obtain the original streams of screen capture by calling [OH_AVScreenCapture_AcquireAudioBuffer](#oh_avscreencapture_acquireaudiobuffer) and [OH_AVScreenCapture_ReleaseVideoBuffer](#oh_avscreencapture_releasevideobuffer).
1557
1558**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
1559
1560**Since**: 10
1561
1562**Parameters**
1563
1564| Name| Description|
1565| -------- | -------- |
1566| capture | Pointer to an [OH_AVScreenCapture](#oh_avscreencapture) instance.|
1567
1568**Returns**
1569
1570Returns a result code defined in [OH_AVErrCode](../apis-avcodec-kit/_core.md#oh_averrcode-1). The following result codes are possible:
1571
1572**AV_SCREEN_CAPTURE_ERR_OK**: The operation is successful.
1573
1574**AV_SCREEN_CAPTURE_ERR_INVALID_VAL**: The input parameter **capture** is a null pointer.
1575
1576**AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT**: The operation is not allowed. The privacy permission fails to be enabled or screen capture fails to start.
1577
1578
1579### OH_AVScreenCapture_StartScreenCaptureWithSurface()
1580
1581```
1582OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_StartScreenCaptureWithSurface (struct OH_AVScreenCapture * capture, OHNativeWindow * window )
1583```
1584
1585**Description**
1586
1587Starts screen capture in surface mode.
1588
1589**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
1590
1591**Since**: 12
1592
1593**Parameters**
1594
1595| Name| Description|
1596| -------- | -------- |
1597| capture | Pointer to an [OH_AVScreenCapture](#oh_avscreencapture) instance.|
1598| window | Pointer to an [OHNativeWindow](../apis-arkgraphics2d/_native_window.md#ohnativewindow) instance.|
1599
1600**Returns**
1601
1602Returns a result code defined in [OH_AVErrCode](../apis-avcodec-kit/_core.md#oh_averrcode-1). The following result codes are possible:
1603
1604**AV_SCREEN_CAPTURE_ERR_OK**: The operation is successful.
1605
1606**AV_SCREEN_CAPTURE_ERR_INVALID_VAL**: The input parameter **capture**, input parameter **window**, or **windowSurface** pointed to by **window** is a null pointer.
1607
1608**AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT**: The operation is not allowed. The privacy permission fails to be enabled or screen capture with a surface fails to start.
1609
1610
1611### OH_AVScreenCapture_StartScreenRecording()
1612
1613```
1614OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_StartScreenRecording (struct OH_AVScreenCapture * capture)
1615```
1616
1617**Description**
1618
1619Starts screen recording, with recordings saved in files.
1620
1621**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
1622
1623**Since**: 10
1624
1625**Parameters**
1626
1627| Name| Description|
1628| -------- | -------- |
1629| capture | Pointer to an [OH_AVScreenCapture](#oh_avscreencapture) instance.|
1630
1631**Returns**
1632
1633Returns a result code defined in [OH_AVErrCode](../apis-avcodec-kit/_core.md#oh_averrcode-1). The following result codes are possible:
1634
1635**AV_SCREEN_CAPTURE_ERR_OK**: The operation is successful.
1636
1637**AV_SCREEN_CAPTURE_ERR_INVALID_VAL**: The input parameter **capture** is a null pointer.
1638
1639**AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT**: The operation is not allowed. The privacy permission fails to be enabled or screen recording fails to start.
1640
1641
1642### OH_AVScreenCapture_StopScreenCapture()
1643
1644```
1645OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_StopScreenCapture (struct OH_AVScreenCapture * capture)
1646```
1647
1648**Description**
1649
1650Stops screen capture. This function is used in pair with [OH_AVScreenCapture_StartScreenCapture](#oh_avscreencapture_startscreencapture). After calling this function, the application stops screen capture or screen share and releases the microphone.
1651
1652**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
1653
1654**Since**: 10
1655
1656**Parameters**
1657
1658| Name| Description|
1659| -------- | -------- |
1660| capture | Pointer to an [OH_AVScreenCapture](#oh_avscreencapture) instance.|
1661
1662**Returns**
1663
1664Returns a result code defined in [OH_AVErrCode](../apis-avcodec-kit/_core.md#oh_averrcode-1). The following result codes are possible:
1665
1666**AV_SCREEN_CAPTURE_ERR_OK**: The operation is successful.
1667
1668**AV_SCREEN_CAPTURE_ERR_INVALID_VAL**: The input parameter **capture** is a null pointer.
1669
1670**AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT**: The operation is not allowed. Screen capture fails to stop.
1671
1672
1673### OH_AVScreenCapture_StopScreenRecording()
1674
1675```
1676OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_StopScreenRecording (struct OH_AVScreenCapture * capture)
1677```
1678
1679**Description**
1680
1681Stops screen recording. This function is used in pair with [OH_AVScreenCapture_StartScreenRecording](#oh_avscreencapture_startscreenrecording).
1682
1683**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
1684
1685**Since**: 10
1686
1687**Parameters**
1688
1689| Name| Description|
1690| -------- | -------- |
1691| capture | Pointer to an [OH_AVScreenCapture](#oh_avscreencapture) instance.|
1692
1693**Returns**
1694
1695Returns a result code defined in [OH_AVErrCode](../apis-avcodec-kit/_core.md#oh_averrcode-1). The following result codes are possible:
1696
1697**AV_SCREEN_CAPTURE_ERR_OK**: The operation is successful.
1698
1699**AV_SCREEN_CAPTURE_ERR_INVALID_VAL**: The input parameter **capture** is a null pointer.
1700
1701**AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT**: The operation is not allowed. Screen recording fails to stop.
1702
1703### OH_AVScreenCapture_ResizeCanvas()
1704
1705```
1706OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ResizeCanvas (struct OH_AVScreenCapture * capture, int32_t width, int32_t height)
1707```
1708
1709**Description**
1710
1711Adjusts the screen resolution.
1712
1713This function is used to set the resolution of screen capture data. **width** indicates the screen width and **height** indicates the screen height.
1714
1715Currently, this function supports only the scenario of capturing streams, but not the scenario of storing captured files. In addition, the caller of this function and the video data consumer must ensure that they support resolution changes of the received video data.
1716
1717**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
1718
1719**Since**: 12
1720
1721**Parameters**
1722
1723| Name| Description|
1724| -------- | -------- |
1725| capture | Pointer to an [OH_AVScreenCapture](#oh_avscreencapture) instance.|
1726| width | Width of the screen to capture.|
1727| height | Height of the screen to capture.|
1728
1729**Returns**
1730
1731Returns a result code defined in [OH_AVErrCode](../apis-avcodec-kit/_core.md#oh_averrcode-1). The following result codes are possible:
1732
1733**AV_SCREEN_CAPTURE_ERR_OK**: The operation is successful.
1734
1735**AV_SCREEN_CAPTURE_ERR_INVALID_VAL**: The input parameter **capture** is a null pointer.
1736
1737**AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT**: The operation is not allowed.
1738
1739### OH_AVScreenCapture_SkipPrivacyMode()
1740
1741```
1742OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SkipPrivacyMode (struct OH_AVScreenCapture * capture, int32_t *windowIDs, int32_t windowCount)
1743```
1744
1745**Description**
1746
1747Exempts privacy windows during screen capture.
1748
1749Currently, all the IDs of the subwindows and main windows to skip must be passed in.
1750
1751**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
1752
1753**Since**: 12
1754
1755**Parameters**
1756
1757| Name| Description|
1758| -------- | -------- |
1759| capture | Pointer to an [OH_AVScreenCapture](#oh_avscreencapture) instance.|
1760| windowIDs | Pointer to the IDs of the privacy windows to skip.|
1761| windowCount | Length of the privacy window ID list.|
1762
1763**Returns**
1764
1765Returns a result code defined in [OH_AVErrCode](../apis-avcodec-kit/_core.md#oh_averrcode-1). The following result codes are possible:
1766
1767**AV_SCREEN_CAPTURE_ERR_OK**: The operation is successful.
1768
1769**AV_SCREEN_CAPTURE_ERR_INVALID_VAL**: The input parameter **capture** is a null pointer.
1770
1771**AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT**: The operation is not allowed.
1772