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