• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# native_avscreen_capture.h
2<!--Kit: Media Kit-->
3<!--Subsystem: Multimedia-->
4<!--Owner: @zzs_911-->
5<!--Designer: @stupig001-->
6<!--Tester: @xdlinc-->
7<!--Adviser: @zengyawen-->
8
9## Overview
10
11The file declares the APIs used to create an OH_AVScreenCapture instance.
12
13**File to include**: <multimedia/player_framework/native_avscreen_capture.h>
14
15**Library**: libnative_avscreen_capture.so
16
17**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
18
19**Since**: 10
20
21**Related module**: [AVScreenCapture](capi-avscreencapture.md)
22
23
24
25## Summary
26
27### Functions
28
29| Name| Description|
30| -- | -- |
31| [struct OH_AVScreenCapture *OH_AVScreenCapture_Create(void)](#oh_avscreencapture_create) | Creates an OH_AVScreenCapture instance.<br>You can release the instance by calling [OH_AVScreenCapture_Release](#oh_avscreencapture_release).|
32| [OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_Init(struct OH_AVScreenCapture *capture, OH_AVScreenCaptureConfig config)](#oh_avscreencapture_init) | Initializes parameters related to an [OH_AVScreenCapture](capi-avscreencapture-oh-avscreencapture.md) instance, including audio sampling parameters for external capture using microphones (optional), audio sampling parameters for internal capture, and video resolution parameters.|
33| [OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_StartScreenCapture(struct OH_AVScreenCapture *capture)](#oh_avscreencapture_startscreencapture) | Starts screen capture and collects original streams.|
34| [OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_StopScreenCapture(struct OH_AVScreenCapture *capture)](#oh_avscreencapture_stopscreencapture) | Stops 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.|
35| [OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_StartScreenRecording(struct OH_AVScreenCapture *capture)](#oh_avscreencapture_startscreenrecording) | Starts screen recording, with recordings saved in files.|
36| [OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_StopScreenRecording(struct OH_AVScreenCapture *capture)](#oh_avscreencapture_stopscreenrecording) | Stops screen recording. This function is used in pair with [OH_AVScreenCapture_StartScreenRecording](#oh_avscreencapture_startscreenrecording).|
37| [OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_AcquireAudioBuffer(struct OH_AVScreenCapture *capture, OH_AudioBuffer **audiobuffer, OH_AudioCaptureSourceType type)](#oh_avscreencapture_acquireaudiobuffer) | Obtains an audio buffer. When calling this function, the application must allocate the memory of the corresponding struct size to the audio buffer.<br>From API version 12, you are advised to use [OH_AVScreenCapture_OnBufferAvailable](capi-native-avscreen-capture-base-h.md#oh_avscreencapture_onbufferavailable) instead.|
38| [OH_NativeBuffer* OH_AVScreenCapture_AcquireVideoBuffer(struct OH_AVScreenCapture *capture, int32_t *fence, int64_t *timestamp, struct OH_Rect *region)](#oh_avscreencapture_acquirevideobuffer) | Obtains a video buffer. The application can call this function to obtain information such as the video buffer and timestamp.<br>When a video buffer is no longer needed, call **OH_AVScreenCapture_ReleaseVideoBuffer** to release it.<br>From API version 12, you are advised to use [OH_AVScreenCapture_OnBufferAvailable](capi-native-avscreen-capture-base-h.md#oh_avscreencapture_onbufferavailable) instead.|
39| [OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ReleaseAudioBuffer(struct OH_AVScreenCapture *capture, OH_AudioCaptureSourceType type)](#oh_avscreencapture_releaseaudiobuffer) | Releases an audio buffer. When an audio buffer is no longer needed, call this function to release it.<br>From API version 12, you are advised to use [OH_AVScreenCapture_OnBufferAvailable](capi-native-avscreen-capture-base-h.md#oh_avscreencapture_onbufferavailable) instead.|
40| [OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ReleaseVideoBuffer(struct OH_AVScreenCapture *capture)](#oh_avscreencapture_releasevideobuffer) | Releases a video buffer. When a video buffer is no longer needed, call this function to release it.<br>From API version 12, you are advised to use [OH_AVScreenCapture_OnBufferAvailable](capi-native-avscreen-capture-base-h.md#oh_avscreencapture_onbufferavailable) instead.|
41| [OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetCallback(struct OH_AVScreenCapture *capture, struct OH_AVScreenCaptureCallback callback)](#oh_avscreencapture_setcallback) | Sets a callback to listen for available video buffers and audio buffers and errors that occur during the function calling.<br>From API version 12, you are advised to use [OH_AVScreenCapture_SetErrorCallback](#oh_avscreencapture_seterrorcallback) and [OH_AVScreenCapture_SetDataCallback](#oh_avscreencapture_setdatacallback) instead.|
42| [OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_Release(struct OH_AVScreenCapture *capture)](#oh_avscreencapture_release) | Releases an OH_AVScreenCapture instance. This function is used in pair with [OH_AVScreenCapture_Create](#oh_avscreencapture_create).|
43| [OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetMicrophoneEnabled(struct OH_AVScreenCapture *capture, bool isMicrophone)](#oh_avscreencapture_setmicrophoneenabled) | Enables or disables the microphone.<br>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.<br>By default, the microphone is enabled.|
44| [OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetStateCallback(struct OH_AVScreenCapture *capture, OH_AVScreenCapture_OnStateChange callback, void *userData)](#oh_avscreencapture_setstatecallback) | Sets a state change callback. This function must be called before screen capture starts.|
45| [OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetDataCallback(struct OH_AVScreenCapture *capture, OH_AVScreenCapture_OnBufferAvailable callback, void *userData)](#oh_avscreencapture_setdatacallback) | Sets a data processing callback. This function must be called before screen capture starts.|
46| [OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetErrorCallback(struct OH_AVScreenCapture *capture, OH_AVScreenCapture_OnError callback, void *userData)](#oh_avscreencapture_seterrorcallback) | Sets an error processing callback. This function must be called before screen capture starts.|
47| [OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_StartScreenCaptureWithSurface(struct OH_AVScreenCapture *capture, OHNativeWindow *window)](#oh_avscreencapture_startscreencapturewithsurface) | Starts screen capture in surface mode.|
48| [OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetCanvasRotation(struct OH_AVScreenCapture *capture, bool canvasRotation)](#oh_avscreencapture_setcanvasrotation) | Sets canvas rotation for screen capture.<br>You 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.<br>The default value is **false**.|
49| [struct OH_AVScreenCapture_ContentFilter *OH_AVScreenCapture_CreateContentFilter(void)](#oh_avscreencapture_createcontentfilter) | Creates a content filter.|
50| [OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ReleaseContentFilter(struct OH_AVScreenCapture_ContentFilter *filter)](#oh_avscreencapture_releasecontentfilter) | Releases a content filter.|
51| [OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ContentFilter_AddAudioContent(struct OH_AVScreenCapture_ContentFilter *filter, OH_AVScreenCaptureFilterableAudioContent content)](#oh_avscreencapture_contentfilter_addaudiocontent) | Adds audio content to a content filter.|
52| [OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ExcludeContent(struct OH_AVScreenCapture *capture,struct OH_AVScreenCapture_ContentFilter *filter)](#oh_avscreencapture_excludecontent) | Sets a content filter for an OH_AVScreenCapture instance.|
53| [OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ContentFilter_AddWindowContent(struct OH_AVScreenCapture_ContentFilter *filter, int32_t *windowIDs, int32_t windowCount)](#oh_avscreencapture_contentfilter_addwindowcontent) | Adds a list of window IDs to a ContentFilter instance.|
54| [OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ResizeCanvas(struct OH_AVScreenCapture *capture, int32_t width, int32_t height)](#oh_avscreencapture_resizecanvas) | Adjusts the screen resolution.<br>This function is used to set the resolution of screen capture data. **width** indicates the screen width and **height** indicates the screen height.<br>Currently, 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.|
55| [OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SkipPrivacyMode(struct OH_AVScreenCapture *capture, int32_t *windowIDs, int32_t windowCount)](#oh_avscreencapture_skipprivacymode) | Exempts privacy windows during screen capture.<br>Currently, all the IDs of the subwindows and main windows to skip must be passed in.|
56| [OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetMaxVideoFrameRate(struct OH_AVScreenCapture *capture, int32_t frameRate)](#oh_avscreencapture_setmaxvideoframerate) | Sets the maximum frame rate for screen capture.<br>This function must be called after screen capture starts.<br> <br>The 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.<br> Although 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.|
57| [OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ShowCursor(struct OH_AVScreenCapture *capture, bool showCursor)](#oh_avscreencapture_showcursor) | Sets whether to show the cursor.|
58| [OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetDisplayCallback(struct OH_AVScreenCapture *capture, OH_AVScreenCapture_OnDisplaySelected callback, void *userData)](#oh_avscreencapture_setdisplaycallback) | Sets a callback function for obtaining the display ID.|
59| [OH_AVScreenCapture_CaptureStrategy* OH_AVScreenCapture_CreateCaptureStrategy(void)](#oh_avscreencapture_createcapturestrategy) | Creates a screen capture strategy.|
60| [OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ReleaseCaptureStrategy(OH_AVScreenCapture_CaptureStrategy* strategy)](#oh_avscreencapture_releasecapturestrategy) | Releases a screen capture strategy.|
61| [OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetCaptureStrategy(struct OH_AVScreenCapture *capture, OH_AVScreenCapture_CaptureStrategy *strategy)](#oh_avscreencapture_setcapturestrategy) | Sets a screen capture strategy for an OH_AVScreenCapture instance.<br>This function must be called before screen capture starts.|
62| [OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_StrategyForCanvasFollowRotation(OH_AVScreenCapture_CaptureStrategy *strategy, bool value)](#oh_avscreencapture_strategyforcanvasfollowrotation) | Sets the automatic rotation following configuration for screen capture. If the value is set to **true**, the screen capture follows the rotation, and the virtual screen size is automatically adjusted after a rotation to ensure the output image matches the new orientation.<br>After this setting, there is no need to manually call [OH_AVScreenCapture_ResizeCanvas](#oh_avscreencapture_resizecanvas) after rotation notifications.|
63| [OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_StrategyForKeepCaptureDuringCall(OH_AVScreenCapture_CaptureStrategy *strategy, bool value)](#oh_avscreencapture_strategyforkeepcaptureduringcall) | Sets whether to keep screen capture during a cellular call.<br>When **value** is set to **true** and screen capture is active during a cellular call, for privacy reasons, the voices of both parties (local microphone and remote speaker) are not recorded. Other system sounds are recorded normally. After the call ends, the screen capture framework resumes microphone recording. If the screen capture application is running in the background when the call ends, microphone recording fails to start because the audio module does not allow background applications to activate microphone recording.|
64| [OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetCaptureContentChangedCallback(struct OH_AVScreenCapture *capture, OH_AVScreenCapture_OnCaptureContentChanged callback, void *userData)](#oh_avscreencapture_setcapturecontentchangedcallback) | Sets the callback for screen capture content changes. This function must be called before screen capture starts.|
65| [OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetCaptureArea(struct OH_AVScreenCapture *capture, uint64_t displayId, OH_Rect* area)](#oh_avscreencapture_setcapturearea) | Sets or updates the capture area.<br>This function can be called before or after screen capture starts. The coordinates and dimensions provided must be non-negative, and the capture area must not span multiple screens. If setting the area fails, the previously set area is used for capturing.|
66| [OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_StrategyForPrivacyMaskMode(OH_AVScreenCapture_CaptureStrategy *strategy, int32_t value)](#oh_avscreencapture_strategyforprivacymaskmode) | Sets the privacy window masking mode.|
67| [OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetSelectionCallback(struct OH_AVScreenCapture *capture, OH_AVScreenCapture_OnUserSelected callback, void *userData)](#oh_avscreencapture_setselectioncallback) | Registers a callback to handle user selection results on the manual confirmation UI. This callback must be invoked before screen capture starts.|
68| [OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_GetCaptureTypeSelected(OH_AVScreenCapture_UserSelectionInfo \*selection, int32_t\* type)](#oh_avscreencapture_getcapturetypeselected) | Obtains the screen capture object type selected by the user on the confirmation UI. This function is used in the [OH_AVScreenCapture_OnUserSelected](capi-native-avscreen-capture-base-h.md#oh_avscreencapture_onuserselected) callback. The **selection** pointer is destroyed after the callback is complete.|
69| [OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_GetDisplayIdSelected(OH_AVScreenCapture_UserSelectionInfo \*selection, uint64_t\* displayId)](#oh_avscreencapture_getdisplayidselected) | Obtains the display ID of the screen selected by the user for capture. This function is used in the [OH_AVScreenCapture_OnUserSelected](capi-native-avscreen-capture-base-h.md#oh_avscreencapture_onuserselected) callback. The **selection** pointer is destroyed after the callback is complete.|
70| [OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_StrategyForBFramesEncoding(OH_AVScreenCapture_CaptureStrategy *strategy, bool value)](#oh_avscreencapture_strategyforbframesencoding) | Sets whether to enable B-frame encoding for a CaptureStrategy instance to reduce the size of the recorded file.<br>For details about the restrictions on B-frame video encoding, see [Constraints in B-Frame Video Encoding](../../media/avcodec/video-encoding-b-frame.md#constraints). If the current environment does not meet the restrictions, B-frames will be skipped during screen capture, and no error will be returned.|
71| [OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_StrategyForPickerPopUp(OH_AVScreenCapture_CaptureStrategy *strategy, bool value)](#oh_avscreencapture_strategyforpickerpopup) | Sets whether to display the screen capture picker.|
72| [OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_StrategyForFillMode(OH_AVScreenCapture_CaptureStrategy *strategy, OH_AVScreenCapture_FillMode mode)](#oh_avscreencapture_strategyforfillmode) | Sets the fill mode of the captured image in the target region.|
73
74## Function Description
75
76### OH_AVScreenCapture_Create()
77
78```
79struct OH_AVScreenCapture *OH_AVScreenCapture_Create(void)
80```
81
82**Description**
83
84Creates an OH_AVScreenCapture instance.
85
86You can release the instance by calling [OH_AVScreenCapture_Release](#oh_avscreencapture_release).
87
88**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
89
90**Since**: 10
91
92**Returns**
93
94| Type| Description|
95| -- | -- |
96| [struct OH_AVScreenCapture](capi-avscreencapture-oh-avscreencapture.md) * | Pointer to the OH_AVScreenCapture instance.|
97
98### OH_AVScreenCapture_Init()
99
100```
101OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_Init(struct OH_AVScreenCapture *capture,OH_AVScreenCaptureConfig config)
102```
103
104**Description**
105
106Initializes parameters related to an [OH_AVScreenCapture](capi-avscreencapture-oh-avscreencapture.md) instance, including audio sampling parameters for external capture using microphones (optional), audio sampling parameters for internal capture, and video resolution parameters.
107
108In 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.
109
110In 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).
111
112The 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 set all memory bytes of the OH_AVScreenCaptureConfig struct variables to **0**, and then set valid parameters based on the screen capture scenario.
113
114If both **audioSampleRate** and **audioChannels** in the [OH_AudioCaptureInfo](capi-avscreencapture-oh-audiocaptureinfo.md) struct are **0**, the OH_AVScreenCapture instance ignores the corresponding audio parameters and does not collect the audio data.
115
116If both **videoFrameWidth** and **videoFrameHeight** in the [OH_VideoCaptureInfo](capi-avscreencapture-oh-videocaptureinfo.md) struct are **0**, the OH_AVScreenCapture instance ignores the corresponding video parameters and does not collect the screen data.
117
118**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
119
120**Since**: 10
121
122
123**Parameters**
124
125| Parameter| Description|
126| -- | -- |
127| [struct OH_AVScreenCapture](capi-avscreencapture-oh-avscreencapture.md) *capture | Pointer to the OH_AVScreenCapture instance.|
128| [OH_AVScreenCaptureConfig](capi-avscreencapture-oh-avscreencaptureconfig.md) config | Parameters related to screen capture initialization.|
129
130**Returns**
131
132| Type| Description|
133| -- | -- |
134| [OH_AVSCREEN_CAPTURE_ErrCode](capi-native-avscreen-capture-errors-h.md#oh_avscreen_capture_errcode) | **AV_SCREEN_CAPTURE_ERR_OK**: The operation is successful.<br>**AV_SCREEN_CAPTURE_ERR_INVALID_VAL**: The input parameter **capture** is nullptr.<br>**AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT**: The operation is not allowed. The configuration fails to be initialized.|
135
136### OH_AVScreenCapture_StartScreenCapture()
137
138```
139OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_StartScreenCapture(struct OH_AVScreenCapture *capture)
140```
141
142**Description**
143
144Starts screen capture and collects original streams.
145
146After this function is called, the callback [OH_AVScreenCapture_OnBufferAvailable](capi-native-avscreen-capture-base-h.md#oh_avscreencapture_onbufferavailable) can be used to check whether streams are generated, and the callback [OH_AVScreenCapture_OnStateChange](capi-native-avscreen-capture-base-h.md#oh_avscreencapture_onstatechange) can be used to check the startup status.
147
148The application can obtain the original streams of screen capture by calling [OH_AVScreenCapture_AcquireAudioBuffer](#oh_avscreencapture_acquireaudiobuffer) and [OH_AVScreenCapture_AcquireVideoBuffer](#oh_avscreencapture_acquirevideobuffer).
149
150**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
151
152**Since**: 10
153
154
155**Parameters**
156
157| Parameter| Description|
158| -- | -- |
159| [struct OH_AVScreenCapture](capi-avscreencapture-oh-avscreencapture.md) *capture | Pointer to the OH_AVScreenCapture instance.|
160
161**Returns**
162
163| Type| Description|
164| -- | -- |
165| [OH_AVSCREEN_CAPTURE_ErrCode](capi-native-avscreen-capture-errors-h.md#oh_avscreen_capture_errcode) | **AV_SCREEN_CAPTURE_ERR_OK**: The operation is successful.<br>**AV_SCREEN_CAPTURE_ERR_INVALID_VAL**: The input parameter **capture** is nullptr.<br>**AV_SCREEN_CAPTURE_ERR_UNSUPPORT** (available since API version 20): The device does not support the operation.<br>**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.|
166
167### OH_AVScreenCapture_StopScreenCapture()
168
169```
170OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_StopScreenCapture(struct OH_AVScreenCapture *capture)
171```
172
173**Description**
174
175Stops 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.
176
177**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
178
179**Since**: 10
180
181
182**Parameters**
183
184| Parameter| Description|
185| -- | -- |
186| [struct OH_AVScreenCapture](capi-avscreencapture-oh-avscreencapture.md) *capture | Pointer to the OH_AVScreenCapture instance.|
187
188**Returns**
189
190| Type| Description|
191| -- | -- |
192| [OH_AVSCREEN_CAPTURE_ErrCode](capi-native-avscreen-capture-errors-h.md#oh_avscreen_capture_errcode) | **AV_SCREEN_CAPTURE_ERR_OK**: The operation is successful.<br>**AV_SCREEN_CAPTURE_ERR_INVALID_VAL**: The input parameter **capture** is nullptr.<br>**AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT**: The operation is not allowed. Screen capture fails to stop.|
193
194### OH_AVScreenCapture_StartScreenRecording()
195
196```
197OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_StartScreenRecording(struct OH_AVScreenCapture *capture)
198```
199
200**Description**
201
202Starts screen recording, with recordings saved in files.
203
204**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
205
206**Since**: 10
207
208
209**Parameters**
210
211| Parameter| Description|
212| -- | -- |
213| [struct OH_AVScreenCapture](capi-avscreencapture-oh-avscreencapture.md) *capture | Pointer to the OH_AVScreenCapture instance.|
214
215**Returns**
216
217| Type| Description|
218| -- | -- |
219| [OH_AVSCREEN_CAPTURE_ErrCode](capi-native-avscreen-capture-errors-h.md#oh_avscreen_capture_errcode) | **AV_SCREEN_CAPTURE_ERR_OK**: The operation is successful.<br>**AV_SCREEN_CAPTURE_ERR_INVALID_VAL**: The input parameter **capture** is nullptr.<br>**AV_SCREEN_CAPTURE_ERR_UNSUPPORT** (available since API version 20): The device does not support the operation.<br>**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.|
220
221### OH_AVScreenCapture_StopScreenRecording()
222
223```
224OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_StopScreenRecording(struct OH_AVScreenCapture *capture)
225```
226
227**Description**
228
229Stops screen recording. This function is used in pair with [OH_AVScreenCapture_StartScreenRecording](#oh_avscreencapture_startscreenrecording).
230
231**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
232
233**Since**: 10
234
235
236**Parameters**
237
238| Parameter| Description|
239| -- | -- |
240| [struct OH_AVScreenCapture](capi-avscreencapture-oh-avscreencapture.md) *capture | Pointer to the OH_AVScreenCapture instance.|
241
242**Returns**
243
244| Type| Description|
245| -- | -- |
246| [OH_AVSCREEN_CAPTURE_ErrCode](capi-native-avscreen-capture-errors-h.md#oh_avscreen_capture_errcode) | **AV_SCREEN_CAPTURE_ERR_OK**: The operation is successful.<br>**AV_SCREEN_CAPTURE_ERR_INVALID_VAL**: The input parameter **capture** is nullptr.<br>**AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT**: The operation is not allowed. Screen capture fails to stop.|
247
248### OH_AVScreenCapture_AcquireAudioBuffer()
249
250```
251OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_AcquireAudioBuffer(struct OH_AVScreenCapture *capture,OH_AudioBuffer **audiobuffer, OH_AudioCaptureSourceType type)
252```
253
254**Description**
255
256Obtains an audio buffer. When calling this function, the application must allocate the memory of the corresponding struct size to the audio buffer.
257
258From API version 12, you are advised to use [OH_AVScreenCapture_OnBufferAvailable](capi-native-avscreen-capture-base-h.md#oh_avscreencapture_onbufferavailable) instead.
259
260**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
261
262**Since**: 10
263
264
265**Parameters**
266
267| Parameter| Description|
268| -- | -- |
269| [struct OH_AVScreenCapture](capi-avscreencapture-oh-avscreencapture.md) *capture | Pointer to the OH_AVScreenCapture instance.|
270| [OH_AudioBuffer](capi-avscreencapture-oh-audiobuffer.md) **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.|
271| [OH_AudioCaptureSourceType](capi-native-avscreen-capture-base-h.md#oh_audiocapturesourcetype) type | Type of the audio buffer, which is used to distinguish external streams recorded by the microphone from internal streams played by the system.|
272
273**Returns**
274
275| Type| Description|
276| -- | -- |
277| [OH_AVSCREEN_CAPTURE_ErrCode](capi-native-avscreen-capture-errors-h.md#oh_avscreen_capture_errcode) | **AV_SCREEN_CAPTURE_ERR_OK**: The operation is successful.<br>**AV_SCREEN_CAPTURE_ERR_INVALID_VAL**: The input parameter **capture** or **audiobuffer** is nullptr.<br>**AV_SCREEN_CAPTURE_ERR_NO_MEMORY**: The audio buffer fails to be allocated due to insufficient memory.<br>**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.|
278
279### OH_AVScreenCapture_AcquireVideoBuffer()
280
281```
282OH_NativeBuffer* OH_AVScreenCapture_AcquireVideoBuffer(struct OH_AVScreenCapture *capture,int32_t *fence, int64_t *timestamp, struct OH_Rect *region)
283```
284
285**Description**
286
287Obtains a video buffer. The application can call this function to obtain information such as the video buffer and timestamp.
288
289When a video buffer is no longer needed, call **OH_AVScreenCapture_ReleaseVideoBuffer** to release it.
290
291From API version 12, you are advised to use [OH_AVScreenCapture_OnBufferAvailable](capi-native-avscreen-capture-base-h.md#oh_avscreencapture_onbufferavailable) instead.
292
293**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
294
295**Since**: 10
296
297
298**Parameters**
299
300| Parameter| Description|
301| -- | -- |
302| [struct OH_AVScreenCapture](capi-avscreencapture-oh-avscreencapture.md) *capture | Pointer to the OH_AVScreenCapture instance.|
303| int32_t *fence | Pointer to parameters for synchronization display.|
304| int64_t *timestamp | Pointer to the timestamp of the video frame.|
305| [struct OH_Rect](capi-avscreencapture-oh-rect.md) *region | Pointer to the coordinates related to video display.|
306
307**Returns**
308
309| Type| Description|
310| -- | -- |
311| [OH_NativeBuffer](capi-avscreencapture-avscreencapture-oh-nativebuffer.md)* | 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.|
312
313### OH_AVScreenCapture_ReleaseAudioBuffer()
314
315```
316OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ReleaseAudioBuffer(struct OH_AVScreenCapture *capture,OH_AudioCaptureSourceType type)
317```
318
319**Description**
320
321Releases an audio buffer. When an audio buffer is no longer needed, call this function to release it.
322
323From API version 12, you are advised to use [OH_AVScreenCapture_OnBufferAvailable](capi-native-avscreen-capture-base-h.md#oh_avscreencapture_onbufferavailable) instead.
324
325**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
326
327**Since**: 10
328
329
330**Parameters**
331
332| Parameter| Description|
333| -- | -- |
334| [struct OH_AVScreenCapture](capi-avscreencapture-oh-avscreencapture.md) *capture | Pointer to the OH_AVScreenCapture instance.|
335| [OH_AudioCaptureSourceType](capi-native-avscreen-capture-base-h.md#oh_audiocapturesourcetype) type | Type of the audio buffer, which is used to distinguish external streams recorded by the microphone from internal streams played by the system.|
336
337**Returns**
338
339| Type| Description|
340| -- | -- |
341| [OH_AVSCREEN_CAPTURE_ErrCode](capi-native-avscreen-capture-errors-h.md#oh_avscreen_capture_errcode) | **AV_SCREEN_CAPTURE_ERR_OK**: The operation is successful.<br>**AV_SCREEN_CAPTURE_ERR_INVALID_VAL**: The input parameter **capture** is nullptr.<br>**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.|
342
343### OH_AVScreenCapture_ReleaseVideoBuffer()
344
345```
346OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ReleaseVideoBuffer(struct OH_AVScreenCapture *capture)
347```
348
349**Description**
350
351Releases a video buffer. When a video buffer is no longer needed, call this function to release it.
352
353From API version 12, you are advised to use [OH_AVScreenCapture_OnBufferAvailable](capi-native-avscreen-capture-base-h.md#oh_avscreencapture_onbufferavailable) instead.
354
355**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
356
357**Since**: 10
358
359
360**Parameters**
361
362| Parameter| Description|
363| -- | -- |
364| [struct OH_AVScreenCapture](capi-avscreencapture-oh-avscreencapture.md) *capture | Pointer to the OH_AVScreenCapture instance.|
365
366**Returns**
367
368| Type| Description|
369| -- | -- |
370| [OH_AVSCREEN_CAPTURE_ErrCode](capi-native-avscreen-capture-errors-h.md#oh_avscreen_capture_errcode) | **AV_SCREEN_CAPTURE_ERR_OK**: The operation is successful.<br>**AV_SCREEN_CAPTURE_ERR_INVALID_VAL**: The input parameter **capture** is nullptr.<br>**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.|
371
372### OH_AVScreenCapture_SetCallback()
373
374```
375OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetCallback(struct OH_AVScreenCapture *capture,struct OH_AVScreenCaptureCallback callback)
376```
377
378**Description**
379
380Sets a callback to listen for available video buffers and audio buffers and errors that occur during the function calling.
381
382From API version 12, you are advised to use [OH_AVScreenCapture_SetErrorCallback](#oh_avscreencapture_seterrorcallback) and [OH_AVScreenCapture_SetDataCallback](#oh_avscreencapture_setdatacallback) instead.
383
384**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
385
386**Since**: 10
387
388
389**Parameters**
390
391| Parameter| Description|
392| -- | -- |
393| [struct OH_AVScreenCapture](capi-avscreencapture-oh-avscreencapture.md) *capture | Pointer to the OH_AVScreenCapture instance.|
394| [struct OH_AVScreenCaptureCallback](capi-avscreencapture-oh-avscreencapturecallback.md) callback | OH_AVScreenCaptureCallback struct, which stores related callback function pointers.|
395
396**Returns**
397
398| Type| Description|
399| -- | -- |
400| [OH_AVSCREEN_CAPTURE_ErrCode](capi-native-avscreen-capture-errors-h.md#oh_avscreen_capture_errcode) | **AV_SCREEN_CAPTURE_ERR_OK**: The operation is successful.<br>**AV_SCREEN_CAPTURE_ERR_INVALID_VAL**: The input parameter **capture** or **callback** is nullptr.<br>**AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT**: The operation is not allowed. The callback fails to be set.|
401
402### OH_AVScreenCapture_Release()
403
404```
405OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_Release(struct OH_AVScreenCapture *capture)
406```
407
408**Description**
409
410Releases an OH_AVScreenCapture instance. This function is used in pair with [OH_AVScreenCapture_Create](#oh_avscreencapture_create).
411
412**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
413
414**Since**: 10
415
416
417**Parameters**
418
419| Parameter| Description|
420| -- | -- |
421| [struct OH_AVScreenCapture](capi-avscreencapture-oh-avscreencapture.md) *capture | Pointer to the OH_AVScreenCapture instance.|
422
423**Returns**
424
425| Type| Description|
426| -- | -- |
427| [OH_AVSCREEN_CAPTURE_ErrCode](capi-native-avscreen-capture-errors-h.md#oh_avscreen_capture_errcode) | **AV_SCREEN_CAPTURE_ERR_OK**: The operation is successful.<br>**AV_SCREEN_CAPTURE_ERR_INVALID_VAL**: The input parameter **capture** is nullptr.<br>**AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT**: The operation is not allowed. The OH_AVScreenCapture instance fails to be released.|
428
429### OH_AVScreenCapture_SetMicrophoneEnabled()
430
431```
432OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetMicrophoneEnabled(struct OH_AVScreenCapture *capture,bool isMicrophone)
433```
434
435**Description**
436
437Enables or disables the microphone.
438
439When **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.
440
441By default, the microphone is enabled.
442
443**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
444
445**Since**: 10
446
447
448**Parameters**
449
450| Parameter| Description|
451| -- | -- |
452| [struct OH_AVScreenCapture](capi-avscreencapture-oh-avscreencapture.md) *capture | Pointer to the OH_AVScreenCapture instance.|
453| bool isMicrophone | Whether to enable the microphone.|
454
455**Returns**
456
457| Type| Description|
458| -- | -- |
459| [OH_AVSCREEN_CAPTURE_ErrCode](capi-native-avscreen-capture-errors-h.md#oh_avscreen_capture_errcode) | **AV_SCREEN_CAPTURE_ERR_OK**: The operation is successful.<br>**AV_SCREEN_CAPTURE_ERR_INVALID_VAL**: The input parameter **capture** is nullptr.<br>**AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT**: The operation is not allowed. The microphone fails to be enabled or disabled.|
460
461### OH_AVScreenCapture_SetStateCallback()
462
463```
464OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetStateCallback(struct OH_AVScreenCapture *capture,OH_AVScreenCapture_OnStateChange callback, void *userData)
465```
466
467**Description**
468
469Sets a state change callback. This function must be called before screen capture starts.
470
471The callback is triggered when the state changes during the running of an OH_AVScreenCapture instance.
472
473A 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:
474
4751. If the user agrees, the screen capture startup process starts. If screen capture starts successfully, the state change callback is triggered to report the [OH_AVScreenCaptureStateCode](capi-native-avscreen-capture-base-h.md#oh_avscreencapturestatecode).OH_SCREEN_CAPTURE_STATE_STARTED status to notify the application of the startup success, with a screen capture notification displayed. If screen capture fails to start, the state change callback is triggered to report the failure information (for example, [OH_AVScreenCaptureStateCode](capi-native-avscreen-capture-base-h.md#oh_avscreencapturestatecode).OH_SCREEN_CAPTURE_STATE_MIC_UNAVAILABLE if the microphone is unavailable), or the error processing callback [OH_AVScreenCapture_OnError](capi-native-avscreen-capture-base-h.md#oh_avscreencapture_onerror) is triggered to report the error information.
4762. If the user disagrees, the screen capture startup process stops. The state change callback is triggered to report the [OH_AVScreenCaptureStateCode](capi-native-avscreen-capture-base-h.md#oh_avscreencapturestatecode).OH_SCREEN_CAPTURE_STATE_CANCELED status to notify the application of the startup failure due to user rejection.
477
478**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
479
480**Since**: 12
481
482
483**Parameters**
484
485| Parameter| Description|
486| -- | -- |
487| [struct OH_AVScreenCapture](capi-avscreencapture-oh-avscreencapture.md) *capture | Pointer to the OH_AVScreenCapture instance.|
488| [OH_AVScreenCapture_OnStateChange](capi-native-avscreen-capture-base-h.md#oh_avscreencapture_onstatechange) callback | State change callback.|
489| void *userData | Pointer to the user-defined data. The data is returned as an input parameter when the state change callback is triggered.|
490
491**Returns**
492
493| Type| Description|
494| -- | -- |
495| [OH_AVSCREEN_CAPTURE_ErrCode](capi-native-avscreen-capture-errors-h.md#oh_avscreen_capture_errcode) | **AV_SCREEN_CAPTURE_ERR_OK**: The operation is successful.<br>**AV_SCREEN_CAPTURE_ERR_INVALID_VAL**: The input parameter **capture** or **callback** is nullptr.<br>**AV_SCREEN_CAPTURE_ERR_NO_MEMORY**: The memory fails to be allocated due to insufficient memory.<br>**AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT**: The operation is not allowed. The state callback fails to be set.|
496
497### OH_AVScreenCapture_SetDataCallback()
498
499```
500OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetDataCallback(struct OH_AVScreenCapture *capture,OH_AVScreenCapture_OnBufferAvailable callback, void *userData)
501```
502
503**Description**
504
505Sets a data processing callback. This function must be called before screen capture starts.
506
507The callback is triggered when an audio buffer or a video buffer becomes available during the running of an OH_AVScreenCapture instance.
508
509The 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.
510
511A successful call to this function leads to the following scenarios:
512
5131. The callbacks [OH_AVScreenCaptureOnAudioBufferAvailable](capi-native-avscreen-capture-base-h.md#oh_avscreencaptureonaudiobufferavailable) and [OH_AVScreenCaptureOnVideoBufferAvailable](capi-native-avscreen-capture-base-h.md#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.
5142. 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).
515
516**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
517
518**Since**: 12
519
520
521**Parameters**
522
523| Parameter| Description|
524| -- | -- |
525| [struct OH_AVScreenCapture](capi-avscreencapture-oh-avscreencapture.md) *capture | Pointer to the OH_AVScreenCapture instance.|
526| [OH_AVScreenCapture_OnBufferAvailable](capi-native-avscreen-capture-base-h.md#oh_avscreencapture_onbufferavailable) callback | Data processing callback.|
527| void *userData | Pointer to the user-defined data. The data is returned as an input parameter when the data processing callback is triggered.|
528
529**Returns**
530
531| Type| Description|
532| -- | -- |
533| [OH_AVSCREEN_CAPTURE_ErrCode](capi-native-avscreen-capture-errors-h.md#oh_avscreen_capture_errcode) | **AV_SCREEN_CAPTURE_ERR_OK**: The operation is successful.<br>**AV_SCREEN_CAPTURE_ERR_INVALID_VAL**: The input parameter **capture** or **callback** is nullptr.<br>**AV_SCREEN_CAPTURE_ERR_NO_MEMORY**: The memory fails to be allocated due to insufficient memory.<br>**AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT**: The operation is not allowed. The data callback fails to be set.|
534
535### OH_AVScreenCapture_SetErrorCallback()
536
537```
538OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetErrorCallback(struct OH_AVScreenCapture *capture,OH_AVScreenCapture_OnError callback, void *userData)
539```
540
541**Description**
542
543Sets an error processing callback. This function must be called before screen capture starts.
544
545The callback is triggered when an error occurs during the running of an OH_AVScreenCapture instance.
546
547After a successful call to this function, the callback [OH_AVScreenCaptureOnError](capi-native-avscreen-capture-base-h.md#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.
548
549**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
550
551**Since**: 12
552
553
554**Parameters**
555
556| Parameter| Description|
557| -- | -- |
558| [struct OH_AVScreenCapture](capi-avscreencapture-oh-avscreencapture.md) *capture | Pointer to the OH_AVScreenCapture instance.|
559| [OH_AVScreenCapture_OnError](capi-native-avscreen-capture-base-h.md#oh_avscreencapture_onerror) callback | Error processing callback.|
560| void *userData | Pointer to the user-defined data. The data is returned as an input parameter when the error processing callback is triggered.|
561
562**Returns**
563
564| Type| Description|
565| -- | -- |
566| [OH_AVSCREEN_CAPTURE_ErrCode](capi-native-avscreen-capture-errors-h.md#oh_avscreen_capture_errcode) | **AV_SCREEN_CAPTURE_ERR_OK**: The operation is successful.<br>**AV_SCREEN_CAPTURE_ERR_INVALID_VAL**: The input parameter **capture** or **callback** is nullptr.<br>**AV_SCREEN_CAPTURE_ERR_NO_MEMORY**: The memory fails to be allocated due to insufficient memory.<br>**AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT**: The operation is not allowed. The error callback fails to be set.|
567
568### OH_AVScreenCapture_StartScreenCaptureWithSurface()
569
570```
571OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_StartScreenCaptureWithSurface(struct OH_AVScreenCapture *capture,OHNativeWindow *window)
572```
573
574**Description**
575
576Starts screen capture in surface mode.
577
578**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
579
580**Since**: 12
581
582
583**Parameters**
584
585| Parameter| Description|
586| -- | -- |
587| [struct OH_AVScreenCapture](capi-avscreencapture-oh-avscreencapture.md) *capture | Pointer to the OH_AVScreenCapture instance.|
588| [OHNativeWindow](../apis-arkgraphics2d/capi-nativewindow-nativewindow.md) *window | Pointer to the OHNativeWindow instance.|
589
590**Returns**
591
592| Type| Description|
593| -- | -- |
594| [OH_AVSCREEN_CAPTURE_ErrCode](capi-native-avscreen-capture-errors-h.md#oh_avscreen_capture_errcode) | **AV_SCREEN_CAPTURE_ERR_OK**: The operation is successful.<br>**AV_SCREEN_CAPTURE_ERR_INVALID_VAL**: The input parameter **capture**, input parameter **window**, or **windowSurface** pointed to by **window** is nullptr.<br>**AV_SCREEN_CAPTURE_ERR_UNSUPPORT** (available since API version 20): The device does not support the operation.<br>**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.|
595
596### OH_AVScreenCapture_SetCanvasRotation()
597
598```
599OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetCanvasRotation(struct OH_AVScreenCapture *capture,bool canvasRotation)
600```
601
602**Description**
603
604Sets canvas rotation for screen capture.
605
606You 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.<br>The default value is **false**.
607
608**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
609
610**Since**: 12
611
612
613**Parameters**
614
615| Parameter| Description|
616| -- | -- |
617| [struct OH_AVScreenCapture](capi-avscreencapture-oh-avscreencapture.md) *capture | Pointer to the OH_AVScreenCapture instance.|
618| bool canvasRotation | Whether to enable screen data rotation.|
619
620**Returns**
621
622| Type| Description|
623| -- | -- |
624| [OH_AVSCREEN_CAPTURE_ErrCode](capi-native-avscreen-capture-errors-h.md#oh_avscreen_capture_errcode) | **AV_SCREEN_CAPTURE_ERR_OK**: The operation is successful.<br>**AV_SCREEN_CAPTURE_ERR_INVALID_VAL**: The input parameter **capture** is nullptr.<br>**AV_SCREEN_CAPTURE_ERR_UNSUPPORT** (available since API version 20): The device does not support the operation.<br>**AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT**: The operation is not allowed. Canvas rotation fails to be set for screen capture.|
625
626### OH_AVScreenCapture_CreateContentFilter()
627
628```
629struct OH_AVScreenCapture_ContentFilter *OH_AVScreenCapture_CreateContentFilter(void)
630```
631
632**Description**
633
634Creates a content filter.
635
636**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
637
638**Since**: 12
639
640**Returns**
641
642| Type| Description|
643| -- | -- |
644| struct [OH_AVScreenCapture_ContentFilter](capi-avscreencapture-oh-avscreencapture-contentfilter.md) * | OH_AVScreenCapture_ContentFilter instance if the operation is successful; nullptr otherwise.|
645
646### OH_AVScreenCapture_ReleaseContentFilter()
647
648```
649OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ReleaseContentFilter(struct OH_AVScreenCapture_ContentFilter *filter)
650```
651
652**Description**
653
654Releases a content filter.
655
656**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
657
658**Since**: 12
659
660
661**Parameters**
662
663| Parameter| Description|
664| -- | -- |
665| [struct OH_AVScreenCapture_ContentFilter](capi-avscreencapture-oh-avscreencapture-contentfilter.md) *filter | Pointer to the OH_AVScreenCapture_ContentFilter instance.|
666
667**Returns**
668
669| Type| Description|
670| -- | -- |
671| [OH_AVSCREEN_CAPTURE_ErrCode](capi-native-avscreen-capture-errors-h.md#oh_avscreen_capture_errcode) | **AV_SCREEN_CAPTURE_ERR_OK**: The operation is successful.<br>**AV_SCREEN_CAPTURE_ERR_INVALID_VAL**: The input parameter **filter** is nullptr.|
672
673### OH_AVScreenCapture_ContentFilter_AddAudioContent()
674
675```
676OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ContentFilter_AddAudioContent(struct OH_AVScreenCapture_ContentFilter *filter, OH_AVScreenCaptureFilterableAudioContent content)
677```
678
679**Description**
680
681Adds audio content to a content filter.
682
683**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
684
685**Since**: 12
686
687
688**Parameters**
689
690| Parameter| Description|
691| -- | -- |
692| [struct OH_AVScreenCapture_ContentFilter](capi-avscreencapture-oh-avscreencapture-contentfilter.md) *filter | Pointer to the OH_AVScreenCapture_ContentFilter instance.|
693| [OH_AVScreenCaptureFilterableAudioContent](capi-native-avscreen-capture-base-h.md#oh_avscreencapturefilterableaudiocontent) content | Pointer to the OH_AVScreenCaptureFilterableAudioContent instance.|
694
695**Returns**
696
697| Type| Description|
698| -- | -- |
699| [OH_AVSCREEN_CAPTURE_ErrCode](capi-native-avscreen-capture-errors-h.md#oh_avscreen_capture_errcode) | **AV_SCREEN_CAPTURE_ERR_OK**: The operation is successful.<br>**AV_SCREEN_CAPTURE_ERR_INVALID_VAL**: The input parameter **filter** is nullptr or the input parameter **content** is invalid.|
700
701### OH_AVScreenCapture_ExcludeContent()
702
703```
704OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ExcludeContent(struct OH_AVScreenCapture *capture,struct OH_AVScreenCapture_ContentFilter *filter)
705```
706
707**Description**
708
709Sets a content filter for an OH_AVScreenCapture instance.
710
711**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
712
713**Since**: 12
714
715
716**Parameters**
717
718| Parameter| Description|
719| -- | -- |
720| [struct OH_AVScreenCapture](capi-avscreencapture-oh-avscreencapture.md) *capture | Pointer to the OH_AVScreenCapture instance.|
721| [struct OH_AVScreenCapture_ContentFilter](capi-avscreencapture-oh-avscreencapture-contentfilter.md) *filter | Pointer to the OH_AVScreenCapture_ContentFilter instance.|
722
723**Returns**
724
725| Type| Description|
726| -- | -- |
727| [OH_AVSCREEN_CAPTURE_ErrCode](capi-native-avscreen-capture-errors-h.md#oh_avscreen_capture_errcode) | **AV_SCREEN_CAPTURE_ERR_OK**: The operation is successful.<br>**AV_SCREEN_CAPTURE_ERR_INVALID_VAL**: The input parameter **capture** or **filter** is nullptr.<br>**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.<br>For captured files, the Recorder API must be called for the operation to take effect during the start.|
728
729### OH_AVScreenCapture_ContentFilter_AddWindowContent()
730
731```
732OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ContentFilter_AddWindowContent(struct OH_AVScreenCapture_ContentFilter *filter, int32_t *windowIDs, int32_t windowCount)
733```
734
735**Description**
736
737Adds a list of window IDs to a ContentFilter instance.
738
739**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
740
741**Since**: 12
742
743
744**Parameters**
745
746| Parameter| Description|
747| -- | -- |
748| [struct OH_AVScreenCapture_ContentFilter](capi-avscreencapture-oh-avscreencapture-contentfilter.md) *filter | Pointer to the OH_AVScreenCapture_ContentFilter instance.|
749| int32_t *windowIDs | Pointer to the window IDs.|
750| int32_t windowCount | Length of the window ID list.|
751
752**Returns**
753
754| Type| Description|
755| -- | -- |
756| [OH_AVSCREEN_CAPTURE_ErrCode](capi-native-avscreen-capture-errors-h.md#oh_avscreen_capture_errcode) | **AV_SCREEN_CAPTURE_ERR_OK** if the operation is successful; a specific error code if the operation fails.|
757
758### OH_AVScreenCapture_ResizeCanvas()
759
760```
761OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ResizeCanvas(struct OH_AVScreenCapture *capture,int32_t width, int32_t height)
762```
763
764**Description**
765
766Adjusts the screen resolution.
767
768This function is used to set the resolution of screen capture data. **width** indicates the screen width and **height** indicates the screen height.
769
770Currently, 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.
771
772**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
773
774**Since**: 12
775
776
777**Parameters**
778
779| Parameter| Description|
780| -- | -- |
781| [struct OH_AVScreenCapture](capi-avscreencapture-oh-avscreencapture.md) *capture | Pointer to the OH_AVScreenCapture instance.|
782| int32_t width | Width of the screen to capture.|
783| int32_t height | Height of the screen to capture.|
784
785**Returns**
786
787| Type| Description|
788| -- | -- |
789| [OH_AVSCREEN_CAPTURE_ErrCode](capi-native-avscreen-capture-errors-h.md#oh_avscreen_capture_errcode) | **AV_SCREEN_CAPTURE_ERR_OK**: The operation is successful.<br>**AV_SCREEN_CAPTURE_ERR_INVALID_VAL**: The input parameter **capture** is nullptr.<br>**AV_SCREEN_CAPTURE_ERR_UNSUPPORT** (available since API version 20): The device does not support the operation.<br>**AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT**: The operation is not allowed.|
790
791### OH_AVScreenCapture_SkipPrivacyMode()
792
793```
794OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SkipPrivacyMode(struct OH_AVScreenCapture *capture,int32_t *windowIDs, int32_t windowCount)
795```
796
797**Description**
798
799Exempts privacy windows during screen capture.
800
801Currently, all the IDs of the subwindows and main windows to skip must be passed in.
802
803**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
804
805**Since**: 12
806
807
808**Parameters**
809
810| Parameter| Description|
811| -- | -- |
812| [struct OH_AVScreenCapture](capi-avscreencapture-oh-avscreencapture.md) *capture | Pointer to the OH_AVScreenCapture instance.|
813| int32_t *windowIDs | Pointer to the IDs of the privacy windows to skip.|
814| int32_t windowCount | Length of the privacy window ID list.|
815
816**Returns**
817
818| Type| Description|
819| -- | -- |
820| [OH_AVSCREEN_CAPTURE_ErrCode](capi-native-avscreen-capture-errors-h.md#oh_avscreen_capture_errcode) | **AV_SCREEN_CAPTURE_ERR_OK**: The operation is successful.<br>**AV_SCREEN_CAPTURE_ERR_INVALID_VAL**: The input parameter **capture** is nullptr.<br>**AV_SCREEN_CAPTURE_ERR_UNSUPPORT** (available since API version 20): The device does not support the operation.<br>**AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT**: The operation is not allowed.|
821
822### OH_AVScreenCapture_SetMaxVideoFrameRate()
823
824```
825OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetMaxVideoFrameRate(struct OH_AVScreenCapture *capture,int32_t frameRate)
826```
827
828**Description**
829
830Sets the maximum frame rate for screen capture.
831
832This function must be called after screen capture starts.
833
834The 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.
835
836Although 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.
837
838**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
839
840**Since**: 14
841
842
843**Parameters**
844
845| Parameter| Description|
846| -- | -- |
847| [struct OH_AVScreenCapture](capi-avscreencapture-oh-avscreencapture.md) *capture | Pointer to the OH_AVScreenCapture instance.|
848| int32_t frameRate | Maximum frame rate for screen capture.|
849
850**Returns**
851
852| Type| Description|
853| -- | -- |
854| [OH_AVSCREEN_CAPTURE_ErrCode](capi-native-avscreen-capture-errors-h.md#oh_avscreen_capture_errcode) | **AV_SCREEN_CAPTURE_ERR_OK**: The operation is successful.<br>**AV_SCREEN_CAPTURE_ERR_INVALID_VAL**: The input parameter **capture** is nullptr, or the input parameter **frameRate** is not supported.<br>**AV_SCREEN_CAPTURE_ERR_UNSUPPORT** (available since API version 20): The device does not support the operation.<br>**AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT**: The operation is not allowed.|
855
856### OH_AVScreenCapture_ShowCursor()
857
858```
859OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ShowCursor(struct OH_AVScreenCapture *capture,bool showCursor)
860```
861
862**Description**
863
864Sets whether to show the cursor.
865
866**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
867
868**Since**: 15
869
870
871**Parameters**
872
873| Parameter| Description|
874| -- | -- |
875| [struct OH_AVScreenCapture](capi-avscreencapture-oh-avscreencapture.md) *capture | Pointer to the OH_AVScreenCapture instance.|
876| bool showCursor | Whether to show the cursor.|
877
878**Returns**
879
880| Type| Description|
881| -- | -- |
882| [OH_AVSCREEN_CAPTURE_ErrCode](capi-native-avscreen-capture-errors-h.md#oh_avscreen_capture_errcode) | **AV_SCREEN_CAPTURE_ERR_OK**: The operation is successful.<br>**AV_SCREEN_CAPTURE_ERR_INVALID_VAL**: The input parameter **capture** is nullptr.<br>**AV_SCREEN_CAPTURE_ERR_UNSUPPORT** (available since API version 20): The device does not support the operation.<br>**AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT**: The operation is not allowed. The cursor setting fails.|
883
884### OH_AVScreenCapture_SetDisplayCallback()
885
886```
887OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetDisplayCallback(struct OH_AVScreenCapture *capture,OH_AVScreenCapture_OnDisplaySelected callback, void *userData)
888```
889
890**Description**
891
892Sets a callback function for obtaining the display ID.
893
894**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
895
896**Since**: 15
897
898
899**Parameters**
900
901| Parameter| Description|
902| -- | -- |
903| [struct OH_AVScreenCapture](capi-avscreencapture-oh-avscreencapture.md) *capture | Pointer to the OH_AVScreenCapture instance.|
904| [OH_AVScreenCapture_OnDisplaySelected](capi-native-avscreen-capture-base-h.md#oh_avscreencapture_ondisplayselected) callback | Callback function for returning the display ID.|
905| void *userData | Pointer to the user-defined data. The data is returned as an input parameter when the state change callback is triggered.|
906
907**Returns**
908
909| Type| Description|
910| -- | -- |
911| [OH_AVSCREEN_CAPTURE_ErrCode](capi-native-avscreen-capture-errors-h.md#oh_avscreen_capture_errcode) | **AV_SCREEN_CAPTURE_ERR_OK**: The operation is successful.<br>**AV_SCREEN_CAPTURE_ERR_INVALID_VAL**: The input parameter **capture** or **callback** is nullptr.<br>**AV_SCREEN_CAPTURE_ERR_NO_MEMORY**: The memory fails to be allocated due to insufficient memory.<br>**AV_SCREEN_CAPTURE_ERR_INVALID_STATE**: The callback must be called before the **start** function.|
912
913### OH_AVScreenCapture_CreateCaptureStrategy()
914
915```
916OH_AVScreenCapture_CaptureStrategy* OH_AVScreenCapture_CreateCaptureStrategy(void)
917```
918
919**Description**
920
921Creates a screen capture strategy.
922
923**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
924
925**Since**: 20
926
927**Returns**
928
929| Type| Description|
930| -- | -- |
931| [OH_AVScreenCapture_CaptureStrategy](capi-avscreencapture-oh-avscreencapture-capturestrategy.md)* | OH_AVScreenCapture_CaptureStrategy instance if the operation is successful; nullptr otherwise.|
932
933### OH_AVScreenCapture_ReleaseCaptureStrategy()
934
935```
936OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ReleaseCaptureStrategy(OH_AVScreenCapture_CaptureStrategy* strategy)
937```
938
939**Description**
940
941Releases a screen capture strategy.
942
943**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
944
945**Since**: 20
946
947
948**Parameters**
949
950| Parameter| Description|
951| -- | -- |
952| [OH_AVScreenCapture_CaptureStrategy](capi-avscreencapture-oh-avscreencapture-capturestrategy.md)* strategy | Pointer to the OH_AVScreenCapture_CaptureStrategy instance.|
953
954**Returns**
955
956| Type| Description|
957| -- | -- |
958| [OH_AVSCREEN_CAPTURE_ErrCode](capi-native-avscreen-capture-errors-h.md#oh_avscreen_capture_errcode) | **AV_SCREEN_CAPTURE_ERR_OK**: The operation is successful.<br>**AV_SCREEN_CAPTURE_ERR_INVALID_VAL**: The input parameter **strategy** is nullptr.|
959
960### OH_AVScreenCapture_SetCaptureStrategy()
961
962```
963OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetCaptureStrategy(struct OH_AVScreenCapture *capture, OH_AVScreenCapture_CaptureStrategy *strategy)
964```
965
966**Description**
967
968Sets a screen capture strategy for an OH_AVScreenCapture instance.
969
970This function must be called before screen capture starts.
971
972**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
973
974**Since**: 20
975
976
977**Parameters**
978
979| Parameter| Description|
980| -- | -- |
981| [struct OH_AVScreenCapture](capi-avscreencapture-oh-avscreencapture.md) *capture | Pointer to the OH_AVScreenCapture instance.|
982| [OH_AVScreenCapture_CaptureStrategy](capi-avscreencapture-oh-avscreencapture-capturestrategy.md) *strategy | Pointer to the OH_AVScreenCapture_CaptureStrategy instance.|
983
984**Returns**
985
986| Type| Description|
987| -- | -- |
988| [OH_AVSCREEN_CAPTURE_ErrCode](capi-native-avscreen-capture-errors-h.md#oh_avscreen_capture_errcode) | **AV_SCREEN_CAPTURE_ERR_OK**: The operation is successful.<br>**AV_SCREEN_CAPTURE_ERR_INVALID_VAL**: The input parameter **capture** or **strategy** is nullptr.<br>**AV_SCREEN_CAPTURE_ERR_INVALID_STATE**: This function is called after screen capture starts.|
989
990### OH_AVScreenCapture_StrategyForCanvasFollowRotation()
991
992```
993OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_StrategyForCanvasFollowRotation(OH_AVScreenCapture_CaptureStrategy *strategy, bool value)
994```
995
996**Description**
997
998Sets the automatic rotation following configuration for screen capture. If the value is set to **true**, the screen capture follows the rotation, and the virtual screen size is automatically adjusted after a rotation to ensure the output image matches the new orientation.<br>After this setting, there is no need to manually call [OH_AVScreenCapture_ResizeCanvas](#oh_avscreencapture_resizecanvas) after rotation notifications.
999
1000**Since**: 20
1001
1002
1003**Parameters**
1004
1005| Parameter| Description|
1006| -- | -- |
1007| [OH_AVScreenCapture_CaptureStrategy](capi-avscreencapture-oh-avscreencapture-capturestrategy.md) *strategy | Pointer to the OH_AVScreenCapture_CaptureStrategy instance.|
1008| bool value | Whether the width and height of the virtual screen rotate with the screen.<br>**true** to rotate with the screen, **false** to keep the initial settings.<br>The default value is **false**.|
1009
1010**Returns**
1011
1012| Type| Description|
1013| -- | -- |
1014| [OH_AVSCREEN_CAPTURE_ErrCode](capi-native-avscreen-capture-errors-h.md#oh_avscreen_capture_errcode) | **AV_SCREEN_CAPTURE_ERR_OK**: The operation is successful.<br>**AV_SCREEN_CAPTURE_ERR_INVALID_VAL**: The input parameter **strategy** is nullptr.|
1015
1016### OH_AVScreenCapture_StrategyForKeepCaptureDuringCall()
1017
1018```
1019OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_StrategyForKeepCaptureDuringCall(OH_AVScreenCapture_CaptureStrategy *strategy, bool value)
1020```
1021
1022**Description**
1023
1024Sets whether to keep screen capture during a cellular call.
1025
1026When **value** is set to **true** and screen capture is active during a cellular call, for privacy reasons, the voices of both parties (local microphone and remote speaker) are not recorded. Other system sounds are recorded normally. After the call ends, the screen capture framework resumes microphone recording. If the screen capture application is running in the background when the call ends, microphone recording fails to start because the audio module does not allow background applications to activate microphone recording.
1027
1028**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
1029
1030**Since**: 20
1031
1032
1033**Parameters**
1034
1035| Parameter| Description|
1036| -- | -- |
1037| [OH_AVScreenCapture_CaptureStrategy](capi-avscreencapture-oh-avscreencapture-capturestrategy.md) *strategy | Pointer to the OH_AVScreenCapture_CaptureStrategy instance.|
1038| bool value | Whether to keep screen capture during a cellular call.<br>**true** to keep, **false** otherwise.<br>The default value is **false**.|
1039
1040**Returns**
1041
1042| Type| Description|
1043| -- | -- |
1044| [OH_AVSCREEN_CAPTURE_ErrCode](capi-native-avscreen-capture-errors-h.md#oh_avscreen_capture_errcode) | **AV_SCREEN_CAPTURE_ERR_OK**: The operation is successful.<br>**AV_SCREEN_CAPTURE_ERR_INVALID_VAL**: The input parameter **strategy** is nullptr.|
1045
1046### OH_AVScreenCapture_SetCaptureContentChangedCallback()
1047
1048```
1049OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetCaptureContentChangedCallback(struct OH_AVScreenCapture *capture,OH_AVScreenCapture_OnCaptureContentChanged callback, void *userData)
1050```
1051
1052**Description**
1053
1054Sets the callback for screen capture content changes. This function must be called before screen capture starts.
1055
1056**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
1057
1058**Since**: 20
1059
1060
1061**Parameters**
1062
1063| Parameter| Description|
1064| -- | -- |
1065| [struct OH_AVScreenCapture](capi-avscreencapture-oh-avscreencapture.md) *capture | Pointer to the OH_AVScreenCapture instance.|
1066| [OH_AVScreenCapture_OnCaptureContentChanged](capi-native-avscreen-capture-base-h.md#oh_avscreencapture_oncapturecontentchanged) callback | Pointer to the callback method instance for the screen capture content change event.|
1067| void *userData | Pointer to the user-defined data. The data is returned as an input parameter when the error processing callback is triggered.|
1068
1069**Returns**
1070
1071| Type| Description|
1072| -- | -- |
1073| [OH_AVSCREEN_CAPTURE_ErrCode](capi-native-avscreen-capture-errors-h.md#oh_avscreen_capture_errcode) | **AV_SCREEN_CAPTURE_ERR_OK**: The operation is successful.<br>**AV_SCREEN_CAPTURE_ERR_INVALID_VAL**: The input parameter **capture** or **callback** is nullptr.<br>**AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT**: The operation is not allowed. The screen capture callback fails to be set.|
1074
1075### OH_AVScreenCapture_SetCaptureArea()
1076
1077```
1078OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetCaptureArea(struct OH_AVScreenCapture *capture,uint64_t displayId, OH_Rect* area)
1079```
1080
1081**Description**
1082
1083Sets or updates the capture area.
1084
1085This function can be called before or after screen capture starts. The coordinates and dimensions provided must be non-negative, and the capture area must not span multiple screens. If setting the area fails, the previously set area is used for capturing.
1086
1087**Since**: 20
1088
1089
1090**Parameters**
1091
1092| Parameter| Description|
1093| -- | -- |
1094| [struct OH_AVScreenCapture](capi-avscreencapture-oh-avscreencapture.md) *capture | Pointer to the OH_AVScreenCapture instance.|
1095| uint64_t displayId | ID of the screen to capture.|
1096| [OH_Rect](capi-avscreencapture-oh-rect.md)* area | Area in the screen to capture.|
1097
1098**Returns**
1099
1100| Type| Description|
1101| -- | -- |
1102| [OH_AVSCREEN_CAPTURE_ErrCode](capi-native-avscreen-capture-errors-h.md#oh_avscreen_capture_errcode) | **AV_SCREEN_CAPTURE_ERR_OK**: The operation is successful.<br>**AV_SCREEN_CAPTURE_ERR_INVALID_VAL**: The input parameter **capture** is a nullptr, the input **displayId** does not exist, or the input **area** is abnormal.|
1103
1104### OH_AVScreenCapture_StrategyForPrivacyMaskMode()
1105
1106```
1107OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_StrategyForPrivacyMaskMode(OH_AVScreenCapture_CaptureStrategy *strategy, int32_t value)
1108```
1109
1110**Description**
1111
1112Sets the privacy window masking mode.
1113
1114**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
1115
1116**Since**: 20
1117
1118
1119**Parameters**
1120
1121| Parameter| Description|
1122| -- | -- |
1123| [OH_AVScreenCapture_CaptureStrategy](capi-avscreencapture-oh-avscreencapture-capturestrategy.md) *strategy | Pointer to the OH_AVScreenCapture_CaptureStrategy instance.|
1124| int32_t value | If this parameter is set to **0**, the full-screen masking mode is used when there is a privacy window.<br>If this parameter is set to **1**, the privacy window masking mode is used when there is a privacy window. Any other value will result in an error.|
1125
1126**Returns**
1127
1128| Type| Description|
1129| -- | -- |
1130| [OH_AVSCREEN_CAPTURE_ErrCode](capi-native-avscreen-capture-errors-h.md#oh_avscreen_capture_errcode) | **AV_SCREEN_CAPTURE_ERR_OK**: The operation is successful.<br>**AV_SCREEN_CAPTURE_ERR_INVALID_VAL**: The input parameter **strategy** is nullptr or **value** is invalid.|
1131
1132### OH_AVScreenCapture_SetSelectionCallback()
1133
1134```
1135OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetSelectionCallback(struct OH_AVScreenCapture *capture,OH_AVScreenCapture_OnUserSelected callback, void *userData)
1136```
1137
1138**Description**
1139
1140Registers a callback to handle user selection results on the manual confirmation UI. This callback must be invoked before screen capture starts.
1141
1142**Since**: 20
1143
1144
1145**Parameters**
1146
1147| Parameter| Description|
1148| -- | -- |
1149| [struct OH_AVScreenCapture](capi-avscreencapture-oh-avscreencapture.md) *capture | Pointer to the OH_AVScreenCapture_CaptureStrategy instance.|
1150| [OH_AVScreenCapture_OnUserSelected](capi-native-avscreen-capture-base-h.md#oh_avscreencapture_onuserselected) callback | Callback used to instruct the application to carry out the relevant logic processing once the user has confirmed on the UI.|
1151| void *userData | Pointer to application-specific data, returned to the application.|
1152
1153**Returns**
1154
1155| Type| Description|
1156| -- | -- |
1157| [OH_AVSCREEN_CAPTURE_ErrCode](capi-native-avscreen-capture-errors-h.md#oh_avscreen_capture_errcode) | **AV_SCREEN_CAPTURE_ERR_OK**: The operation is successful.<br>**AV_SCREEN_CAPTURE_ERR_INVALID_VAL**: The input parameter **capture** is nullptr.|
1158
1159### OH_AVScreenCapture_GetCaptureTypeSelected()
1160
1161```
1162OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_GetCaptureTypeSelected(OH_AVScreenCapture_UserSelectionInfo *selection,int32_t* type)
1163```
1164
1165**Description**
1166
1167Obtains the screen capture object type selected by the user on the confirmation UI. This function is used in the [OH_AVScreenCapture_OnUserSelected](capi-native-avscreen-capture-base-h.md#oh_avscreencapture_onuserselected) callback. The **selection** pointer is destroyed after the callback is complete.
1168
1169**Since**: 20
1170
1171
1172**Parameters**
1173
1174| Parameter| Description|
1175| -- | -- |
1176| [OH_AVScreenCapture_UserSelectionInfo](capi-avscreencapture-oh-avscreencapture-userselectioninfo.md) *selection | Pointer to the OH_AVScreenCapture_UserSelectionInfo instance.|
1177| int32_t* type | Pointer to the type of the capture object selected by the user. The value **0** means a screen, and **1** means a window.|
1178
1179**Returns**
1180
1181| Type| Description|
1182| -- | -- |
1183| [OH_AVSCREEN_CAPTURE_ErrCode](capi-native-avscreen-capture-errors-h.md#oh_avscreen_capture_errcode) | **AV_SCREEN_CAPTURE_ERR_OK**: The operation is successful.<br>**AV_SCREEN_CAPTURE_ERR_INVALID_VAL**: The input parameter **selection** is nullptr.|
1184
1185### OH_AVScreenCapture_GetDisplayIdSelected()
1186
1187```
1188OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_GetDisplayIdSelected(OH_AVScreenCapture_UserSelectionInfo *selection,uint64_t* displayId)
1189```
1190
1191**Description**
1192
1193Obtains the display ID of the screen selected by the user for capture. This function is used in the [OH_AVScreenCapture_OnUserSelected](capi-native-avscreen-capture-base-h.md#oh_avscreencapture_onuserselected) callback. The **selection** pointer is destroyed after the callback is complete.
1194
1195**Since**: 20
1196
1197
1198**Parameters**
1199
1200| Parameter| Description|
1201| -- | -- |
1202| [OH_AVScreenCapture_UserSelectionInfo](capi-avscreencapture-oh-avscreencapture-userselectioninfo.md) *selection | Pointer to the OH_AVScreenCapture_UserSelectionInfo instance.|
1203| uint64_t* displayId | Pointer to the ID of the screen selected by the user.|
1204
1205**Returns**
1206
1207| Type| Description|
1208| -- | -- |
1209| [OH_AVSCREEN_CAPTURE_ErrCode](capi-native-avscreen-capture-errors-h.md#oh_avscreen_capture_errcode) | **AV_SCREEN_CAPTURE_ERR_OK**: The operation is successful.<br>**AV_SCREEN_CAPTURE_ERR_INVALID_VAL**: The input parameter **selection** is nullptr.|
1210
1211### OH_AVScreenCapture_StrategyForBFramesEncoding()
1212
1213```
1214OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_StrategyForBFramesEncoding(OH_AVScreenCapture_CaptureStrategy *strategy, bool value)
1215```
1216
1217**Description**
1218
1219Sets whether to enable B-frame encoding for a CaptureStrategy instance to reduce the size of the recorded file.
1220
1221For details about the restrictions on B-frame video encoding, see [Constraints in B-Frame Video Encoding](../../media/avcodec/video-encoding-b-frame.md#constraints). If the current environment does not meet the restrictions, B-frames will be skipped during screen capture, and no error will be returned.
1222
1223**System capability**: SystemCapability.Multimedia.Media.AVScreenCapture
1224
1225**Since**: 20
1226
1227
1228**Parameters**
1229
1230| Parameter| Description|
1231| -- | -- |
1232| [OH_AVScreenCapture_CaptureStrategy](capi-avscreencapture-oh-avscreencapture-capturestrategy.md) *strategy | Pointer to the OH_AVScreenCapture_CaptureStrategy instance.|
1233| bool value | Whether to enable B-frame encoding for the recorded file.<br>**true** to enable, **false** otherwise.<br>The default value is **false**.|
1234
1235**Returns**
1236
1237| Type| Description|
1238| -- | -- |
1239| [OH_AVSCREEN_CAPTURE_ErrCode](capi-native-avscreen-capture-errors-h.md#oh_avscreen_capture_errcode) | **AV_SCREEN_CAPTURE_ERR_OK**: The operation is successful.<br>**AV_SCREEN_CAPTURE_ERR_INVALID_VAL**: The input parameter **strategy** is nullptr.|
1240
1241### OH_AVScreenCapture_StrategyForPickerPopUp()
1242
1243```
1244OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_StrategyForPickerPopUp(OH_AVScreenCapture_CaptureStrategy *strategy, bool value)
1245```
1246
1247**Description**
1248
1249Sets whether to display the screen capture picker.
1250
1251**Since**: 20
1252
1253
1254**Parameters**
1255
1256| Parameter| Description|
1257| -- | -- |
1258| [OH_AVScreenCapture_CaptureStrategy](capi-avscreencapture-oh-avscreencapture-capturestrategy.md) *strategy | Pointer to the OH_AVScreenCapture_CaptureStrategy instance.|
1259| bool value | If this parameter is set to **false**, the application has specified the content to capture, and the picker is not displayed after screen capture starts. If this parameter is set to **true**, the picker is displayed after screen capture starts. If this parameter is not set, the system's recommended behavior is used.|
1260
1261**Returns**
1262
1263| Type| Description|
1264| -- | -- |
1265| [OH_AVSCREEN_CAPTURE_ErrCode](capi-native-avscreen-capture-errors-h.md#oh_avscreen_capture_errcode) | **AV_SCREEN_CAPTURE_ERR_OK**: The operation is successful.<br>**AV_SCREEN_CAPTURE_ERR_INVALID_VAL**: The input parameter **strategy** is nullptr or **value** is invalid.|
1266
1267### OH_AVScreenCapture_StrategyForFillMode()
1268
1269```
1270OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_StrategyForFillMode(OH_AVScreenCapture_CaptureStrategy *strategy, OH_AVScreenCapture_FillMode mode)
1271```
1272
1273**Description**
1274
1275Sets the fill mode of the captured image in the target region.
1276
1277**Since**: 20
1278
1279
1280**Parameters**
1281
1282| Parameter| Description|
1283| -- | -- |
1284| [OH_AVScreenCapture_CaptureStrategy](capi-avscreencapture-oh-avscreencapture-capturestrategy.md) *strategy | Pointer to the OH_AVScreenCapture_CaptureStrategy instance.|
1285| [OH_AVScreenCapture_FillMode](capi-native-avscreen-capture-base-h.md#oh_avscreencapture_fillmode) mode | Fill mode of the captured image.|
1286
1287**Returns**
1288
1289| Type| Description|
1290| -- | -- |
1291| [OH_AVSCREEN_CAPTURE_ErrCode](capi-native-avscreen-capture-errors-h.md#oh_avscreen_capture_errcode) | **AV_SCREEN_CAPTURE_ERR_OK**: The operation is successful.<br>**AV_SCREEN_CAPTURE_ERR_INVALID_VAL**: The input parameter **strategy** is nullptr.|
1292
1293<!--no_check-->