1 /* 2 * Copyright (C) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 /** 17 * @addtogroup AVScreenCapture 18 * @{ 19 * 20 * @brief Provides APIs of request capability for Screen Capture. 21 * @since 10 22 */ 23 24 /** 25 * @file native_avscreen_capture.h 26 * 27 * @brief Declare screen capture related interfaces. 28 * 29 * @library libnative_avscreen_capture.so 30 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 31 * @kit MediaKit 32 * @since 10 33 */ 34 35 #ifndef NATIVE_AVSCREEN_CAPTURE_H 36 #define NATIVE_AVSCREEN_CAPTURE_H 37 38 #include <stdbool.h> 39 #include <stdint.h> 40 #include <stdio.h> 41 #include "native_avscreen_capture_errors.h" 42 #include "native_avscreen_capture_base.h" 43 #include "native_window/external_window.h" 44 45 #ifdef __cplusplus 46 extern "C" { 47 #endif 48 49 /** 50 * @brief Create a screen capture 51 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 52 * @return Returns a pointer to an OH_AVScreenCapture instance 53 * @since 10 54 * @version 1.0 55 */ 56 struct OH_AVScreenCapture *OH_AVScreenCapture_Create(void); 57 58 /** 59 * @brief To init the screen capture, typically, you need to configure the description information of the audio 60 * and video, which can be extracted from the container. This interface must be called before StartAVScreenCapture 61 * called. 62 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 63 * @param capture Pointer to an OH_AVScreenCapture instance 64 * @param config Information describing the audio and video config 65 * @return Function result code. 66 * {@link AV_SCREEN_CAPTURE_ERR_OK} if the execution is successful. 67 * {@link AV_SCREEN_CAPTURE_ERR_INVALID_VAL} input capture is nullptr. 68 * {@link AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT} opertation not be permitted, init config failed. 69 * @since 10 70 * @version 1.0 71 */ 72 OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_Init(struct OH_AVScreenCapture *capture, 73 OH_AVScreenCaptureConfig config); 74 75 /** 76 * @brief Start the av screen capture 77 * @param {struct OH_AVScreenCapture*} capture Pointer to an OH_AVScreenCapture instance 78 * @return Function result code. 79 * {@link AV_SCREEN_CAPTURE_ERR_OK} if the execution is successful. 80 * {@link AV_SCREEN_CAPTURE_ERR_INVALID_VAL} input capture is nullptr. 81 * {@link AV_SCREEN_CAPTURE_ERR_UNSUPPORT} device doesn't support certain configurations. add since api20. 82 * {@link AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT} opertation not be permitted, set privacy authority enabled 83 * failed or start ScreenCapture failed. 84 * @since 10 85 */ 86 OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_StartScreenCapture(struct OH_AVScreenCapture *capture); 87 88 /** 89 * @brief Stop the av screen capture 90 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 91 * @param capture Pointer to an OH_AVScreenCapture instance 92 * @return Function result code. 93 * {@link AV_SCREEN_CAPTURE_ERR_OK} if the execution is successful. 94 * {@link AV_SCREEN_CAPTURE_ERR_INVALID_VAL} input capture is nullptr. 95 * {@link AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT} opertation not be permitted, stop ScreenCapture failed. 96 * @since 10 97 * @version 1.0 98 */ 99 OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_StopScreenCapture(struct OH_AVScreenCapture *capture); 100 101 /** 102 * @brief Start av screen record use to start save screen record file. 103 * @param {struct OH_AVScreenCapture*} capture Pointer to an OH_AVScreenCapture instance 104 * @return Function result code. 105 * {@link AV_SCREEN_CAPTURE_ERR_OK} if the execution is successful. 106 * {@link AV_SCREEN_CAPTURE_ERR_INVALID_VAL} input capture is nullptr. 107 * {@link AV_SCREEN_CAPTURE_ERR_UNSUPPORT} device doesn't support certain configurations. add since api20. 108 * {@link AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT} opertation not be permitted, set privacy authority enabled 109 * failed or start ScreenRecording failed. 110 * @since 10 111 */ 112 OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_StartScreenRecording(struct OH_AVScreenCapture *capture); 113 114 /** 115 * @brief Start av screen record use to stop save screen record file. 116 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 117 * @param capture Pointer to an OH_AVScreenCapture instance 118 * @return Function result code. 119 * {@link AV_SCREEN_CAPTURE_ERR_OK} if the execution is successful. 120 * {@link AV_SCREEN_CAPTURE_ERR_INVALID_VAL} input capture is nullptr. 121 * {@link AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT} opertation not be permitted, stop ScreenRecording failed. 122 * @since 10 123 * @version 1.0 124 */ 125 OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_StopScreenRecording(struct OH_AVScreenCapture *capture); 126 127 /** 128 * @brief Acquire the audio buffer for the av screen capture 129 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 130 * @param capture Pointer to an OH_AVScreenCapture instance 131 * @param audiobuffer Information describing the audio buffer of the capture 132 * @param type Information describing the audio source type 133 * @return Function result code. 134 * {@link AV_SCREEN_CAPTURE_ERR_OK} if the execution is successful. 135 * {@link AV_SCREEN_CAPTURE_ERR_INVALID_VAL} input capture is nullptr or input **audiobuffer is nullptr. 136 * {@link AV_SCREEN_CAPTURE_ERR_NO_MEMORY} no memory, audiobuffer allocate failed. 137 * {@link AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT} opertation not be permitted, not permit for has set 138 * DataCallback or acquire AudioBuffer failed. 139 * @since 10 140 * @version 1.0 141 */ 142 OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_AcquireAudioBuffer(struct OH_AVScreenCapture *capture, 143 OH_AudioBuffer **audiobuffer, OH_AudioCaptureSourceType type); 144 145 /** 146 * @brief Acquire the video buffer for the av screen capture 147 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 148 * @param capture Pointer to an OH_AVScreenCapture instance 149 * @param fence A processing state of display buffer 150 * @param timestamp Information about the video buffer 151 * @param region Information about the video buffer 152 * @return Returns a pointer to an OH_NativeBuffer instance 153 * @since 10 154 * @version 1.0 155 */ 156 OH_NativeBuffer* OH_AVScreenCapture_AcquireVideoBuffer(struct OH_AVScreenCapture *capture, 157 int32_t *fence, int64_t *timestamp, struct OH_Rect *region); 158 159 /** 160 * @brief Release the audio buffer for the av screen capture 161 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 162 * @param capture Pointer to an OH_AVScreenCapture instance 163 * @param type Information describing the audio source type 164 * @return Function result code. 165 * {@link AV_SCREEN_CAPTURE_ERR_OK} if the execution is successful. 166 * {@link AV_SCREEN_CAPTURE_ERR_INVALID_VAL} input capture is nullptr. 167 * {@link AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT} opertation not be permitted, not permit for has set 168 * DataCallback or Release AudioBuffer failed. 169 * @since 10 170 * @version 1.0 171 */ 172 OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ReleaseAudioBuffer(struct OH_AVScreenCapture *capture, 173 OH_AudioCaptureSourceType type); 174 175 /** 176 * @brief Release the video buffer for the av screen capture 177 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 178 * @param capture Pointer to an OH_AVScreenCapture instance 179 * @return Function result code. 180 * {@link AV_SCREEN_CAPTURE_ERR_OK} if the execution is successful. 181 * {@link AV_SCREEN_CAPTURE_ERR_INVALID_VAL} input capture is nullptr. 182 * {@link AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT} opertation not be permitted, not permit for has set 183 * DataCallback or Release VideoBuffer failed. 184 * @since 10 185 * @version 1.0 186 */ 187 OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ReleaseVideoBuffer(struct OH_AVScreenCapture *capture); 188 189 /** 190 * @brief Set the callback function so that your application 191 * can respond to the events generated by the av screen capture. This interface must be called before Init is called. 192 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 193 * @param capture Pointer to an OH_AVScreenCapture instance 194 * @param callback A collection of all callback functions, see {@link OH_AVScreenCaptureCallback} 195 * @return Function result code. 196 * {@link AV_SCREEN_CAPTURE_ERR_OK} if the execution is successful. 197 * {@link AV_SCREEN_CAPTURE_ERR_INVALID_VAL} input capture is nullptr or input callback is nullptr. 198 * {@link AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT} opertation not be permitted, set callback failed. 199 * @since 10 200 * @version 1.0 201 */ 202 OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetCallback(struct OH_AVScreenCapture *capture, 203 struct OH_AVScreenCaptureCallback callback); 204 205 /** 206 * @brief Release the av screen capture 207 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 208 * @param capture Pointer to an OH_AVScreenCapture instance 209 * @return Function result code. 210 * {@link AV_SCREEN_CAPTURE_ERR_OK} if the execution is successful. 211 * {@link AV_SCREEN_CAPTURE_ERR_INVALID_VAL} input capture is nullptr. 212 * {@link AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT} opertation not be permitted, screen capture release failed. 213 * @since 10 214 * @version 1.0 215 */ 216 OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_Release(struct OH_AVScreenCapture *capture); 217 218 /** 219 * @brief Controls the switch of the microphone, which is turned on by default 220 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 221 * @param capture Pointer to an OH_AVScreenCapture instance 222 * @param isMicrophone The switch of the microphone 223 * @return Function result code. 224 * {@link AV_SCREEN_CAPTURE_ERR_OK} if the execution is successful. 225 * {@link AV_SCREEN_CAPTURE_ERR_INVALID_VAL} input capture is nullptr. 226 * {@link AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT} opertation not be permitted, set microphone enable failed. 227 * @since 10 228 * @version 1.0 229 */ 230 OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetMicrophoneEnabled(struct OH_AVScreenCapture *capture, 231 bool isMicrophone); 232 233 /** 234 * @brief Set the state callback function so that your application can respond to the 235 * state change events generated by the av screen capture. This interface must be called before Start is called. 236 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 237 * @param capture Pointer to an OH_AVScreenCapture instance 238 * @param callback State callback function, see {@link OH_AVScreenCapture_OnStateChange} 239 * @param userData Pointer to user specific data 240 * @return Function result code. 241 * {@link AV_SCREEN_CAPTURE_ERR_OK} if the execution is successful. 242 * {@link AV_SCREEN_CAPTURE_ERR_INVALID_VAL} input capture is nullptr or input callback is nullptr. 243 * {@link AV_SCREEN_CAPTURE_ERR_NO_MEMORY} no memory, mem allocate failed. 244 * {@link AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT} opertation not be permitted, set StateCallback failed. 245 * @since 12 246 * @version 1.0 247 */ 248 OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetStateCallback(struct OH_AVScreenCapture *capture, 249 OH_AVScreenCapture_OnStateChange callback, void *userData); 250 251 /** 252 * @brief Set the data callback function so that your application can respond to the 253 * data available events generated by the av screen capture. This interface must be called before Start is called. 254 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 255 * @param capture Pointer to an OH_AVScreenCapture instance 256 * @param callback Data callback function, see {@link OH_AVScreenCapture_OnBufferAvailable} 257 * @param userData Pointer to user specific data 258 * @return Function result code. 259 * {@link AV_SCREEN_CAPTURE_ERR_OK} if the execution is successful. 260 * {@link AV_SCREEN_CAPTURE_ERR_INVALID_VAL} input capture is nullptr or input callback is nullptr. 261 * {@link AV_SCREEN_CAPTURE_ERR_NO_MEMORY} no memory, mem allocate failed. 262 * {@link AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT} opertation not be permitted, set DataCallback failed. 263 * @since 12 264 * @version 1.0 265 */ 266 OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetDataCallback(struct OH_AVScreenCapture *capture, 267 OH_AVScreenCapture_OnBufferAvailable callback, void *userData); 268 269 /** 270 * @brief Set the error callback function so that your application can respond to the 271 * error events generated by the av screen capture. This interface must be called before Start is called. 272 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 273 * @param capture Pointer to an OH_AVScreenCapture instance 274 * @param callback Error callback function, see {@link OH_AVScreenCapture_OnError} 275 * @param userData Pointer to user specific data 276 * @return Function result code. 277 * {@link AV_SCREEN_CAPTURE_ERR_OK} if the execution is successful. 278 * {@link AV_SCREEN_CAPTURE_ERR_INVALID_VAL} input capture is nullptr or input callback is nullptr. 279 * {@link AV_SCREEN_CAPTURE_ERR_NO_MEMORY} no memory, mem allocate failed. 280 * {@link AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT} opertation not be permitted, set ErrorCallback failed. 281 * @since 12 282 * @version 1.0 283 */ 284 OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetErrorCallback(struct OH_AVScreenCapture *capture, 285 OH_AVScreenCapture_OnError callback, void *userData); 286 287 /** 288 * @brief Start the av screen capture, video data provided by OHNativeWindow. 289 * @param {struct OH_AVScreenCapture*} capture Pointer to an OH_AVScreenCapture instance. 290 * @param {OHNativeWindow*} window Pointer to an OHNativeWindow instance. 291 * @return Function result code. 292 * {@link AV_SCREEN_CAPTURE_ERR_OK} if the execution is successful. 293 * {@link AV_SCREEN_CAPTURE_ERR_INVALID_VAL} input capture is nullptr or input window is nullptr or 294 * input windowSurface is nullptr. 295 * {@link AV_SCREEN_CAPTURE_ERR_UNSUPPORT} device doesn't support certain configurations. add since api20. 296 * {@link AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT} opertation not be permitted, set privacy authority enabled 297 * failed or start ScreenCaptureWithSurface failed. 298 * @since 12 299 */ 300 OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_StartScreenCaptureWithSurface(struct OH_AVScreenCapture *capture, 301 OHNativeWindow *window); 302 303 /** 304 * @brief Set canvas rotation when capturing screen 305 * @param {struct OH_AVScreenCapture*} capture Pointer to an OH_AVScreenCapture instance 306 * @param {bool} canvasRotation whether to rotate the canvas 307 * @return Function result code. 308 * {@link AV_SCREEN_CAPTURE_ERR_OK} if the execution is successful. 309 * {@link AV_SCREEN_CAPTURE_ERR_INVALID_VAL} input capture is nullptr. 310 * {@link AV_SCREEN_CAPTURE_ERR_UNSUPPORT} device doesn't support current interface. add since api20. 311 * {@link AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT} opertation not be permitted, set CanvasRotation failed. 312 * @since 12 313 */ 314 OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetCanvasRotation(struct OH_AVScreenCapture *capture, 315 bool canvasRotation); 316 317 /** 318 * @brief Create a screen capture content filter 319 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 320 * @return Returns a pointer to an OH_AVScreenCapture_ContentFilter instance 321 * @since 12 322 * @version 1.0 323 */ 324 struct OH_AVScreenCapture_ContentFilter *OH_AVScreenCapture_CreateContentFilter(void); 325 326 /** 327 * @brief Release the screen capture content filter 328 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 329 * @param filter Pointer to an OH_AVScreenCapture_ContentFilter instance 330 * @return Function result code. 331 * {@link AV_SCREEN_CAPTURE_ERR_OK} if the execution is successful. 332 * {@link AV_SCREEN_CAPTURE_ERR_INVALID_VAL} input filter is nullptr. 333 * @since 12 334 * @version 1.0 335 */ 336 OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ReleaseContentFilter(struct OH_AVScreenCapture_ContentFilter *filter); 337 338 /** 339 * @brief Add content to the screen capture content filter 340 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 341 * @param filter Pointer to an OH_AVScreenCapture_ContentFilter instance 342 * @param content content to be added 343 * @return Function result code. 344 * {@link AV_SCREEN_CAPTURE_ERR_OK} if the execution is successful. 345 * {@link AV_SCREEN_CAPTURE_ERR_INVALID_VAL} input filter is nullptr or input content invalid. 346 * @since 12 347 * @version 1.0 348 */ 349 OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ContentFilter_AddAudioContent( 350 struct OH_AVScreenCapture_ContentFilter *filter, OH_AVScreenCaptureFilterableAudioContent content); 351 352 /** 353 * @brief Set content filter to screen capture 354 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 355 * @param capture Pointer to an OH_AVScreenCapture instance 356 * @param filter Pointer to an OH_AVScreenCapture_ContentFilter instance 357 * @return Function result code. 358 * {@link AV_SCREEN_CAPTURE_ERR_OK} if the execution is successful. 359 * {@link AV_SCREEN_CAPTURE_ERR_INVALID_VAL} input capture is nullptr or input filter is nullptr. 360 * {@link AV_SCREEN_CAPTURE_ERR_UNSUPPORT} not support, for STREAM, should call AudioCapturer interface to make 361 * effect when start, for CAPTURE FILE, should call Recorder interface to make effect when start. 362 * @since 12 363 * @version 1.0 364 */ 365 OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ExcludeContent(struct OH_AVScreenCapture *capture, 366 struct OH_AVScreenCapture_ContentFilter *filter); 367 368 /** 369 * @brief Add Window content to the screen capture content filter 370 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 371 * @param filter Pointer to an OH_AVScreenCapture_ContentFilter instance 372 * @param windowIDs Pointer to windowIDs to be added 373 * @param windowCount length of windowID list 374 * @return Returns AV_SCREEN_CAPTURE_ERR_OK if the execution is successful, 375 * otherwise returns a specific error code, refer to {@link OH_AVSCREEN_CAPTURE_ErrCode} 376 * @since 12 377 * @version 1.0 378 */ 379 OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ContentFilter_AddWindowContent( 380 struct OH_AVScreenCapture_ContentFilter *filter, int32_t *windowIDs, int32_t windowCount); 381 382 /** 383 * @brief Resize the Resolution of the Screen 384 * @param {struct OH_AVScreenCapture*} capture Pointer to an OH_AVScreenCapture instance 385 * @param {int32_t} width Video frame width of avscreeencapture 386 * @param {int32_t} height Video frame height of avscreeencapture 387 * @return Function result code. 388 * {@link AV_SCREEN_CAPTURE_ERR_OK} if the execution is successful. 389 * {@link AV_SCREEN_CAPTURE_ERR_INVALID_VAL} input capture is nullptr. 390 * {@link AV_SCREEN_CAPTURE_ERR_UNSUPPORT} device doesn't support current interface. add since api20. 391 * {@link AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT} opertation not be permitted. 392 * @since 12 393 */ 394 OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ResizeCanvas(struct OH_AVScreenCapture *capture, 395 int32_t width, int32_t height); 396 397 /** 398 * @brief skip some windows' privacy mode of current app during the screen recording 399 * @param {struct OH_AVScreenCapture*} capture Pointer to an OH_AVScreenCapture instance 400 * @param {int32_t*} windowIDs Pointer of windowID list 401 * @param {int32_t} windowCount length of windowID list 402 * @return Function result code. 403 * {@link AV_SCREEN_CAPTURE_ERR_OK} if the execution is successful. 404 * {@link AV_SCREEN_CAPTURE_ERR_INVALID_VAL} input capture is nullptr or input windowIDs are not belong current 405 * app. 406 * {@link AV_SCREEN_CAPTURE_ERR_UNSUPPORT} device doesn't support current interface. add since api20. 407 * {@link AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT} opertation not be permitted. 408 * @since 12 409 */ 410 OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SkipPrivacyMode(struct OH_AVScreenCapture *capture, 411 int32_t *windowIDs, int32_t windowCount); 412 413 /** 414 * @brief set up the max number of video frame per second 415 * @param {struct OH_AVScreenCapture*} capture Pointer to an OH_AVScreenCapture instance 416 * @param {int32_t} frameRate max frame rate of video 417 * @return Function result code. 418 * {@link AV_SCREEN_CAPTURE_ERR_OK} if the execution is successful. 419 * {@link AV_SCREEN_CAPTURE_ERR_INVALID_VAL} input capture is nullptr or frameRate is not support. 420 * {@link AV_SCREEN_CAPTURE_ERR_UNSUPPORT} device doesn't support current interface. add since api20. 421 * {@link AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT} opertation not be permitted. 422 * @since 14 423 */ 424 OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetMaxVideoFrameRate(struct OH_AVScreenCapture *capture, 425 int32_t frameRate); 426 427 /** 428 * @brief determines whether the cursor is visible in the session 429 * @param {struct OH_AVScreenCapture* } capture Pointer to an OH_AVScreenCapture instance 430 * @param {bool} showCursor The switch of the cursor 431 * @return Function result code. 432 * {@link AV_SCREEN_CAPTURE_ERR_OK} if the execution is successful. 433 * {@link AV_SCREEN_CAPTURE_ERR_INVALID_VAL} input capture is nullptr. 434 * {@link AV_SCREEN_CAPTURE_ERR_UNSUPPORT} device doesn't support current interface. add since api20. 435 * {@link AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT} opertation not be permitted, show cursor failed. 436 * @since 15 437 */ 438 OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ShowCursor(struct OH_AVScreenCapture *capture, 439 bool showCursor); 440 441 /** 442 * @brief Set the display device selection callback function so that your application can respond to the 443 * display device selected event generated by the av screen capture. 444 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 445 * @param capture Pointer to an OH_AVScreenCapture instance 446 * @param callback display device selection callback function, see {@link OH_AVScreenCapture_OnDisplaySelected} 447 * @param userData Pointer to user specific data 448 * @return Function result code. 449 * {@link AV_SCREEN_CAPTURE_ERR_OK} if the execution is successful. 450 * {@link AV_SCREEN_CAPTURE_ERR_INVALID_VAL} input capture is nullptr or input callback is nullptr. 451 * {@link AV_SCREEN_CAPTURE_ERR_NO_MEMORY} no memory, mem allocate failed. 452 * {@link AV_SCREEN_CAPTURE_ERR_INVALID_STATE} This interface should be called before Start is called. 453 * @since 15 454 */ 455 OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetDisplayCallback(struct OH_AVScreenCapture *capture, 456 OH_AVScreenCapture_OnDisplaySelected callback, void *userData); 457 458 /** 459 * @brief Create a screen capture Strategy object 460 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 461 * @return Returns a pointer to the screen capture strategy object, or null if failure 462 * @since 20 463 */ 464 OH_AVScreenCapture_CaptureStrategy* OH_AVScreenCapture_CreateCaptureStrategy(void); 465 466 /** 467 * @brief Release the screen capture Strategy object 468 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 469 * @param {OH_AVScreenCapture_CaptureStrategy*} strategy Pointer to an OH_AVScreenCapture_CaptureStrategy instance 470 * @return Function result code. 471 * {@link AV_SCREEN_CAPTURE_ERR_OK} if the execution is successful. 472 * {@link AV_SCREEN_CAPTURE_ERR_INVALID_VAL} input strategy is nullptr. 473 * @since 20 474 */ 475 OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ReleaseCaptureStrategy(OH_AVScreenCapture_CaptureStrategy* strategy); 476 477 /** 478 * @brief set the screen capture strategy for the specified screen capture 479 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 480 * @param {OH_AVScreenCapture*} capture Pointer to an OH_AVScreenCapture which need to be setted. 481 * @param {OH_AVScreenCapture_CaptureStrategy*} strategy Pointer to an OH_AVScreenCapture_CaptureStrategy which want to 482 * set. 483 * @return Function result code. 484 * {@link AV_SCREEN_CAPTURE_ERR_OK} if the execution is successful. 485 * {@link AV_SCREEN_CAPTURE_ERR_INVALID_VAL} capture or strategyvalue is nullptr. 486 * {@link AV_SCREEN_CAPTURE_ERR_INVALID_STATE} This interface should be called before Start is called. 487 * @since 20 488 */ 489 OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetCaptureStrategy( 490 struct OH_AVScreenCapture *capture, OH_AVScreenCapture_CaptureStrategy *strategy); 491 492 /** 493 * @brief Call Settings Policy value for whether to allow screen capture during cellular calls 494 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 495 * @param {OH_AVScreenCapture_CaptureStrategy*} strategy Pointer to an OH_AVScreenCapture_CaptureStrategy instance 496 * @param {bool} value The default value is false, which means that screen recording is not allowed during cellular 497 * calls. 498 * @return Function result code. 499 * {@link AV_SCREEN_CAPTURE_ERR_OK} if the execution is successful. 500 * {@link AV_SCREEN_CAPTURE_ERR_INVALID_VAL} strategy value is nullptr. 501 * @since 20 502 */ 503 OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_StrategyForKeepCaptureDuringCall( 504 OH_AVScreenCapture_CaptureStrategy *strategy, bool value); 505 506 /** 507 * @brief Set the Capture Content Changed callback function so that your application can 508 * customize event handler generated by the screen capture. This interface must be called before Start is called. 509 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 510 * @param capture Pointer to an OH_AVScreenCapture instance 511 * @param callback contentchanged callback function, see {@link OH_AVScreenCapture_OnCaptureContentChanged} 512 * @param userData Pointer to user specific data 513 * @return Function result code. 514 * {@link AV_SCREEN_CAPTURE_ERR_OK} if the execution is successful. 515 * {@link AV_SCREEN_CAPTURE_ERR_INVALID_VAL} input capture is nullptr or input callback is nullptr. 516 * {@link AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT} opertation not be permitted, set ErrorCallback failed. 517 * @since 20 518 */ 519 OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetCaptureContentChangedCallback(struct OH_AVScreenCapture *capture, 520 OH_AVScreenCapture_OnCaptureContentChanged callback, void *userData); 521 522 /** 523 * @brief Set or update the captureArea 524 * @param {struct OH_AVScreenCapture*} capture capture Pointer to an OH_AVScreenCapture instance 525 * @param {uint64_t} displayId Indicates the screen index for setting area recording 526 * @param {OH_Rect*} area Pointer to an object describing the location and size of the region 527 * @return Function result code. 528 * {@link AV_SCREEN_CAPTURE_ERR_OK} if the execution is successful. 529 * {@link AV_SCREEN_CAPTURE_ERR_INVALID_VAL} input capture is nullptr or displayid not exist or area is 530 * invalid. 531 * @since 20 532 */ 533 OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetCaptureArea(struct OH_AVScreenCapture *capture, 534 uint64_t displayId, OH_Rect* area); 535 536 /** 537 * @brief Set the fill mode for screen capture when a privacy window exists 538 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 539 * @param {OH_AVScreenCapture_CaptureStrategy*} strategy Pointer to an OH_AVScreenCapture_CaptureStrategy instance 540 * @param {int32_t} value 541 * If set to 0, it means that when there is a privacy window interface, the output screen image is completely black. 542 * If set to 1, it means that when there is a privacy window interface, only the privacy window area of the output 543 * screen becomes black, and other values returns an error. 544 * @return Function result code. 545 * {@link AV_SCREEN_CAPTURE_ERR_OK} if the execution is successful. 546 * {@link AV_SCREEN_CAPTURE_ERR_INVALID_VAL} strategy is nullptr or value is invalid. 547 * @since 20 548 */ 549 OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_StrategyForPrivacyMaskMode( 550 OH_AVScreenCapture_CaptureStrategy *strategy, int32_t value); 551 552 /** 553 * @brief Set the canvas to rotate with the screen when capturing the screen 554 * @param {OH_AVScreenCapture_CaptureStrategy*} strategy Pointer to an OH_AVScreenCapture_CaptureStrategy instance 555 * @param {bool} value The default value is False, which means that the width and height of the VirtualDisplay 556 * remain the initial settings. If set to True, it means that the width and height of the VirtualDisplay rotates 557 * with the rotation of the screen.. 558 * @return Function result code. 559 * {@link AV_SCREEN_CAPTURE_ERR_OK} if the execution is successful. 560 * {@link AV_SCREEN_CAPTURE_ERR_INVALID_VAL} strategy value is nullptr. 561 * @since 20 562 */ 563 OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_StrategyForCanvasFollowRotation( 564 OH_AVScreenCapture_CaptureStrategy *strategy, bool value); 565 566 /** 567 * @brief Register user selection notification callback function 568 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 569 * @param {OH_AVScreenCapture*} capture Pointer to OH_AVScreenCapture which want to handle user selection info 570 * @param {OH_AVScreenCapture_OnUserSelected} callback user selection callback function, see 571 * {@link OH_AVScreenCapture_OnUserSelected} 572 * @param {void*} userData The control block pointer passed by the application is carried to the application when it 573 * is returned 574 * @return Function result code. 575 * {@link AV_SCREEN_CAPTURE_ERR_OK} if the execution is successful. 576 * {@link AV_SCREEN_CAPTURE_ERR_INVALID_VAL} input capture is nullptr. 577 * @since 20 578 */ 579 OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetSelectionCallback(struct OH_AVScreenCapture *capture, 580 OH_AVScreenCapture_OnUserSelected callback, void *userData); 581 582 /** 583 * @brief Get the recording content type selected by the user in the confirmation interface 584 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 585 * @param {OH_AVScreenCapture_UserSelectionInfo*} selection Pointer to an OH_AVScreenCapture_UserSelectionInfo instance 586 * @param {int32_t*} type The capture object type selected by the user, 0: represents the screen, 1: represents the 587 * window. 588 * @return Function result code. 589 * {@link AV_SCREEN_CAPTURE_ERR_OK} if the execution is successful. 590 * {@link AV_SCREEN_CAPTURE_ERR_INVALID_VAL} if selections is nullptr. 591 * @since 20 592 */ 593 OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_GetCaptureTypeSelected(OH_AVScreenCapture_UserSelectionInfo *selection, 594 int32_t* type); 595 596 /** 597 * @brief Get the Display ID of user selections in the confirmation interface 598 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 599 * @param {OH_AVScreenCapture_UserSelectionInfo*} selection Pointer to an OH_AVScreenCapture_UserSelectionInfo instance 600 * @param {uint64_t*} displayId Returns the screen ID value selected by the user 601 * @return Function result code. 602 * {@link AV_SCREEN_CAPTURE_ERR_OK} if the execution is successful. 603 * {@link AV_SCREEN_CAPTURE_ERR_INVALID_VAL} if selections is nullptr. 604 * @since 20 605 */ 606 OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_GetDisplayIdSelected(OH_AVScreenCapture_UserSelectionInfo *selection, 607 uint64_t* displayId); 608 609 /** 610 * @brief Indicates whether to enable B-frame encoding, which is used to reduce the size of the recorded file. 611 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 612 * @param {OH_AVScreenCapture_CaptureStrategy*} strategy Pointer to an OH_AVScreenCapture_CaptureStrategy instance 613 * @param {bool} value The default value is false, which means B frames encoding are disabled. 614 * @return Function result code. 615 * {@link AV_SCREEN_CAPTURE_ERR_OK} if the execution is successful. 616 * {@link AV_SCREEN_CAPTURE_ERR_INVALID_VAL} strategy is nullptr. 617 * @since 20 618 */ 619 OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_StrategyForBFramesEncoding( 620 OH_AVScreenCapture_CaptureStrategy *strategy, bool value); 621 622 /** 623 * @brief set whether to pop up the screen capture Picker 624 * @param {OH_AVScreenCapture_CaptureStrategy*} strategy Pointer to an OH_AVScreenCapture_CaptureStrategy instance 625 * @param {bool} value 626 * If set to false, it means that the APP don’t need to pop up the Picker after screen capture starts; 627 * if set to True, the Picker will pop up uniformly after screen capture starts; 628 * If not set, it means using the system recommended behavior. 629 * @return Function result code. 630 * {@link AV_SCREEN_CAPTURE_ERR_OK} if the execution is successful. 631 * {@link AV_SCREEN_CAPTURE_ERR_INVALID_VAL} strategy value is nullptr. 632 * @since 20 633 */ 634 OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_StrategyForPickerPopUp( 635 OH_AVScreenCapture_CaptureStrategy *strategy, bool value); 636 637 /** 638 * @brief Set the fill mode of the captured image in the target area 639 * @param {OH_AVScreenCapture_CaptureStrategy*} strategy Pointer to an OH_AVScreenCapture_CaptureStrategy instance 640 * @param {OH_AVScreenCapture_FillMode} mode Value of the captured image fill mode 641 * @return Function result code. 642 * {@link AV_SCREEN_CAPTURE_ERR_OK} if the execution is successful. 643 * {@link AV_SCREEN_CAPTURE_ERR_INVALID_VAL} strategy value is nullptr. 644 * @since 20 645 */ 646 OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_StrategyForFillMode( 647 OH_AVScreenCapture_CaptureStrategy *strategy, OH_AVScreenCapture_FillMode mode); 648 #ifdef __cplusplus 649 } 650 #endif 651 652 #endif // NATIVE_AVSCREEN_CAPTURE_H 653 /** @} */