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