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