harmony 鸿蒙AVScreenCapture
AVScreenCapture
Overview
The AVScreenCapture module provides APIs for screen capture.
You can refer to the corresponding development guide and samples based on your development requirements.
- Using AVScreenCapture to Capture Screens and Obtain Streams
- Using AVScreenCapture to Capture Screens and Write Them to Files
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 10
Summary
Files
Name | Description |
---|---|
native_avscreen_capture.h | Declares the APIs used to create an OH_AVScreenCapture instance. |
native_avscreen_capture_base.h | Declares the common structs, character constants, and enums used for running screen capture. |
native_avscreen_capture_errors.h | Declares the error codes generated during screen capture. |
Structs
Name | Description |
---|---|
struct OH_AudioCaptureInfo | Describes the audio capture information. |
struct OH_AudioEncInfo | Describes the audio encoding information. |
struct OH_AudioInfo | Describes the audio information. |
struct OH_VideoCaptureInfo | Describes the video capture information. |
struct OH_VideoEncInfo | Describes the video encoding information. |
struct OH_VideoInfo | Describes the video information. |
struct OH_RecorderInfo | Describes the recording file information. |
struct OH_AVScreenCaptureConfig | Describes the screen capture configuration. |
struct OH_AVScreenCaptureCallback | Describes all the asynchronous callback function pointers of an OH_AVScreenCapture instance. |
struct OH_Rect | Describes the width, height, and image information of the rectangle used for screen capture. |
struct OH_AudioBuffer | Describes the configuration such as the size, type, and timestamp of audio data. |
Types
Name | Description |
---|---|
typedef struct OH_NativeBuffer OH_NativeBuffer | Defines the native video stream class for screen capture. |
typedef struct OH_AVScreenCapture OH_AVScreenCapture | Defines a screen capture instance used to obtain original video and audio streams. |
typedef struct OH_AVScreenCapture_ContentFilter OH_AVScreenCapture_ContentFilter | Defines a struct for the filter used to filter audio and video content. |
typedef enum OH_CaptureMode OH_CaptureMode | Defines an enum for the screen capture modes. |
typedef enum OH_AudioCaptureSourceType OH_AudioCaptureSourceType | Defines an enum for the audio source types during screen capture. |
typedef enum OH_AudioCodecFormat OH_AudioCodecFormat | Defines an enum for the audio encoding formats. |
typedef enum OH_VideoCodecFormat OH_VideoCodecFormat | Defines an enum for the video encoding formats. |
typedef enum OH_DataType OH_DataType | Defines an enum for the data types of screen capture streams. |
typedef enum OH_VideoSourceType OH_VideoSourceType | Defines an enum for the video source formats. Currently, only the RGBA format is supported. |
typedef enum OH_ContainerFormatType OH_ContainerFormatType | Defines an enum for the types of files generated during screen capture. |
typedef struct OH_AudioCaptureInfo OH_AudioCaptureInfo | Defines a struct for the audio capture information. |
typedef struct OH_AudioEncInfo OH_AudioEncInfo | Defines a struct for the audio encoding information. |
typedef struct OH_AudioInfo OH_AudioInfo | Defines a struct for the audio information. |
typedef struct OH_VideoCaptureInfo OH_VideoCaptureInfo | Defines a struct for the video capture information. |
typedef struct OH_VideoEncInfo OH_VideoEncInfo | Defines a struct for the video encoding information. |
typedef struct OH_VideoInfo OH_VideoInfo | Defines a struct for the video information. |
typedef struct OH_RecorderInfo OH_RecorderInfo | Defines a struct for the recording file information. |
typedef struct OH_AVScreenCaptureConfig OH_AVScreenCaptureConfig | Defines a struct for the screen capture configuration. |
typedef void(* OH_AVScreenCaptureOnError) (OH_AVScreenCapture *capture, int32_t errorCode) | Defines a pointer to the callback function that is called when an error occurs during the running of an OH_AVScreenCapture instance. |
typedef void(* OH_AVScreenCaptureOnAudioBufferAvailable) (OH_AVScreenCapture *capture, bool isReady, OH_AudioCaptureSourceType type) | Defines a pointer to the callback function that is called when an audio buffer is available during the running of an OH_AVScreenCapture instance. |
typedef void(* OH_AVScreenCaptureOnVideoBufferAvailable) (OH_AVScreenCapture *capture, bool isReady) | Defines a pointer to the callback function that is called when a video buffer is available during the running of an OH_AVScreenCapture instance. |
typedef struct OH_AVScreenCaptureCallback OH_AVScreenCaptureCallback | Defines a struct for all the asynchronous callback function pointers of an OH_AVScreenCapture instance. |
typedef struct OH_Rect OH_Rect | Defines a struct for the width, height, and image information of the rectangle used for screen capture. |
typedef struct OH_AudioBuffer OH_AudioBuffer | Defines a struct for the configuration such as the size, type, and timestamp of audio data. |
typedef enum OH_AVScreenCaptureStateCode OH_AVScreenCaptureStateCode | Defines an enum for the screen capture states. |
typedef enum OH_AVScreenCaptureBufferType OH_AVScreenCaptureBufferType | Defines an enum for the buffer types. |
typedef enum OH_AVScreenCaptureContentChangedEvent OH_AVScreenCaptureContentChangedEvent | Defines an enum for screen capture content change events. |
typedef enum OH_AVScreenCaptureFilterableAudioContent OH_AVScreenCaptureFilterableAudioContent | Defines an enum for the types of audio that can be added to a content filter. |
typedef void(* OH_AVScreenCapture_OnStateChange) (struct OH_AVScreenCapture *capture, OH_AVScreenCaptureStateCode stateCode, void *userData) | Defines a pointer to the callback function that is called when the state changes during the running of an OH_AVScreenCapture instance. |
typedef void(* OH_AVScreenCapture_OnError) (OH_AVScreenCapture *capture, int32_t errorCode, void *userData) | Defines a pointer to the callback function that is called when an error occurs during the running of an OH_AVScreenCapture instance. |
typedef void(* OH_AVScreenCapture_OnBufferAvailable) (OH_AVScreenCapture *capture, OH_AVBuffer *buffer, OH_AVScreenCaptureBufferType bufferType, int64_t timestamp, void *userData) | Defines a pointer to the callback function that is called when an audio or a video buffer is available during the running of an OH_AVScreenCapture instance. |
typedef enum OH_AVSCREEN_CAPTURE_ErrCode OH_AVSCREEN_CAPTURE_ErrCode | Defines an enum for the error codes generated during screen recording. |
typedef void(* OH_AVScreenCapture_OnDisplaySelected) (OH_AVScreenCapture *capture, uint64_t displayId, void *userData) | Defines a pointer to the callback function that is called when screen capture starts. |
typedef struct OH_AVScreenCapture_CaptureStrategy OH_AVScreenCapture_CaptureStrategy | Defines a struct for the screen capture strategy. |
typedef void(* OH_AVScreenCapture_OnCaptureContentChanged) (OH_AVScreenCapture *capture, OH_AVScreenCaptureContentChangedEvent event, OH_Rect *area, void *userData) | Defines a pointer to the callback function that is called when the screen capture content changes. |
Enums
Name | Description |
---|---|
OH_CaptureMode { OH_CAPTURE_HOME_SCREEN = 0, OH_CAPTURE_SPECIFIED_SCREEN = 1, OH_CAPTURE_SPECIFIED_WINDOW = 2, OH_CAPTURE_INVAILD = -1 } |
Enumerates the screen capture modes. |
OH_AudioCaptureSourceType { OH_SOURCE_INVALID = -1, OH_SOURCE_DEFAULT = 0, OH_MIC = 1, OH_ALL_PLAYBACK = 2, OH_APP_PLAYBACK = 3 } |
Enumerates the audio source types during screen capture. |
OH_AudioCodecFormat { OH_AUDIO_DEFAULT = 0, OH_AAC_LC = 3, OH_AUDIO_CODEC_FORMAT_BUTT } |
Enumerates the audio encoding formats. |
OH_VideoCodecFormat { OH_VIDEO_DEFAULT = 0, OH_H264 = 2, OH_H265 = 4, OH_MPEG4 = 6, OH_VP8 = 8, OH_VP9 = 10, OH_VIDEO_CODEC_FORMAT_BUTT } |
Enumerates the video encoding formats. |
OH_DataType { OH_ORIGINAL_STREAM = 0, OH_ENCODED_STREAM = 1, OH_CAPTURE_FILE = 2, OH_INVAILD = -1 } |
Enumerates the data types of screen capture streams. |
OH_VideoSourceType { OH_VIDEO_SOURCE_SURFACE_YUV = 0, OH_VIDEO_SOURCE_SURFACE_ES, OH_VIDEO_SOURCE_SURFACE_RGBA, OH_VIDEO_SOURCE_BUTT } |
Enumerates the video source formats. Currently, only the RGBA format is supported. |
OH_ContainerFormatType { CFT_MPEG_4A = 0, CFT_MPEG_4 = 1 } |
Enumerates the types of files generated during screen capture. |
OH_AVScreenCaptureStateCode { OH_SCREEN_CAPTURE_STATE_STARTED = 0, OH_SCREEN_CAPTURE_STATE_CANCELED = 1, OH_SCREEN_CAPTURE_STATE_STOPPED_BY_USER = 2, OH_SCREEN_CAPTURE_STATE_INTERRUPTED_BY_OTHER = 3, OH_SCREEN_CAPTURE_STATE_STOPPED_BY_CALL = 4, OH_SCREEN_CAPTURE_STATE_MIC_UNAVAILABLE = 5, OH_SCREEN_CAPTURE_STATE_MIC_MUTED_BY_USER = 6, OH_SCREEN_CAPTURE_STATE_MIC_UNMUTED_BY_USER = 7, OH_SCREEN_CAPTURE_STATE_ENTER_PRIVATE_SCENE = 8, OH_SCREEN_CAPTURE_STATE_EXIT_PRIVATE_SCENE = 9, OH_SCREEN_CAPTURE_STATE_STOPPED_BY_USER_SWITCHES = 10 } |
Enumerates the screen capture states. |
OH_AVScreenCaptureBufferType { OH_SCREEN_CAPTURE_BUFFERTYPE_VIDEO = 0, OH_SCREEN_CAPTURE_BUFFERTYPE_AUDIO_INNER = 1, OH_SCREEN_CAPTURE_BUFFERTYPE_AUDIO_MIC = 2 } |
Enumerates the buffer types. |
OH_AVScreenCaptureFilterableAudioContent { OH_SCREEN_CAPTURE_NOTIFICATION_AUDIO = 0, OH_SCREEN_CAPTURE_CURRENT_APP_AUDIO = 1 } |
Enumerates the types of audio that can be added to a content filter. |
OH_AVSCREEN_CAPTURE_ErrCode { AV_SCREEN_CAPTURE_ERR_BASE = 0, AV_SCREEN_CAPTURE_ERR_OK = AV_SCREEN_CAPTURE_ERR_BASE, AV_SCREEN_CAPTURE_ERR_NO_MEMORY = AV_SCREEN_CAPTURE_ERR_BASE + 1, AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT = AV_SCREEN_CAPTURE_ERR_BASE + 2, AV_SCREEN_CAPTURE_ERR_INVALID_VAL = AV_SCREEN_CAPTURE_ERR_BASE + 3, AV_SCREEN_CAPTURE_ERR_IO = AV_SCREEN_CAPTURE_ERR_BASE + 4, AV_SCREEN_CAPTURE_ERR_TIMEOUT = AV_SCREEN_CAPTURE_ERR_BASE + 5, AV_SCREEN_CAPTURE_ERR_UNKNOWN = AV_SCREEN_CAPTURE_ERR_BASE + 6, AV_SCREEN_CAPTURE_ERR_SERVICE_DIED = AV_SCREEN_CAPTURE_ERR_BASE + 7, AV_SCREEN_CAPTURE_ERR_INVALID_STATE = AV_SCREEN_CAPTURE_ERR_BASE + 8, AV_SCREEN_CAPTURE_ERR_UNSUPPORT = AV_SCREEN_CAPTURE_ERR_BASE + 9, AV_SCREEN_CAPTURE_ERR_EXTEND_START = AV_SCREEN_CAPTURE_ERR_BASE + 100 } |
Enumerates the error codes generated during screen recording. |
OH_AVScreenCaptureContentChangedEvent { OH_SCREEN_CAPTURE_CONTENT_HIDE = 0, OH_SCREEN_CAPTURE_CONTENT_VISIBLE = 1, OH_SCREEN_CAPTURE_CONTENT_UNAVAILABLE = 2 } |
Enumerates the screen capture content change events. |
Functions
Name | Description |
---|---|
struct OH_AVScreenCapture * OH_AVScreenCapture_Create (void) | Creates an OH_AVScreenCapture instance. |
OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_Init (struct OH_AVScreenCapture *capture, OH_AVScreenCaptureConfig config) | Initializes parameters related to an OH_AVScreenCapture instance, including audio sampling parameters for external capture using microphones (optional), audio sampling parameters for internal capture, and video resolution parameters. |
OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_StartScreenCapture (struct OH_AVScreenCapture *capture) | Starts screen capture and collects original streams. |
OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_StartScreenCaptureWithSurface (struct OH_AVScreenCapture *capture, OHNativeWindow *window) | Starts screen capture in surface mode. |
OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_StopScreenCapture (struct OH_AVScreenCapture *capture) | Stops screen capture. This function is used in pair with OH_AVScreenCapture_StartScreenCapture. |
OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_StartScreenRecording (struct OH_AVScreenCapture *capture) | Starts screen recording, with recordings saved in files. |
OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_StopScreenRecording (struct OH_AVScreenCapture *capture) | Stops screen recording. This function is used in pair with OH_AVScreenCapture_StartScreenRecording. |
OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_AcquireAudioBuffer (struct OH_AVScreenCapture *capture, OH_AudioBuffer **audiobuffer, OH_AudioCaptureSourceType type) | Obtains an audio buffer. When calling this function, the application must allocate the memory of the corresponding struct size to the audio buffer. |
OH_NativeBuffer * OH_AVScreenCapture_AcquireVideoBuffer (struct OH_AVScreenCapture *capture, int32_t *fence, int64_t *timestamp, struct OH_Rect *region) | Obtains a video buffer. An application can call this function to obtain information such as the video buffer and timestamp. |
OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ReleaseAudioBuffer (struct OH_AVScreenCapture *capture, OH_AudioCaptureSourceType type) | Releases an audio buffer. |
OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ReleaseVideoBuffer (struct OH_AVScreenCapture *capture) | Releases a video buffer. After the video buffer is no longer needed, call this function to release it. |
OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetCallback (struct OH_AVScreenCapture *capture, struct OH_AVScreenCaptureCallback callback) | Sets a callback to listen for available video buffers and audio buffers and errors that occur during the function calling. |
OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_Release (struct OH_AVScreenCapture *capture) | Releases an OH_AVScreenCapture instance. This function is used in pair with OH_AVScreenCapture_Create. |
OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetMicrophoneEnabled (struct OH_AVScreenCapture *capture, bool isMicrophone) | Enables or disables the microphone. |
OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetStateCallback (struct OH_AVScreenCapture *capture, OH_AVScreenCapture_OnStateChange callback, void *userData) | Sets a state change callback. This function must be called before screen capture starts. |
OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetDataCallback (struct OH_AVScreenCapture *capture, OH_AVScreenCapture_OnBufferAvailable callback, void *userData) | Sets a data processing callback. This function must be called before screen capture starts. |
OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetErrorCallback (struct OH_AVScreenCapture *capture, OH_AVScreenCapture_OnError callback, void *userData) | Sets an error processing callback. This function must be called before screen capture starts. |
OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetCanvasRotation (struct OH_AVScreenCapture *capture, bool canvasRotation) | Sets canvas rotation for screen capture. |
struct OH_AVScreenCapture_ContentFilter * OH_AVScreenCapture_CreateContentFilter (void) | Creates a content filter. |
OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ReleaseContentFilter (struct OH_AVScreenCapture_ContentFilter *filter) | Releases a content filter. |
OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ContentFilter_AddAudioContent (struct OH_AVScreenCapture_ContentFilter *filter, OH_AVScreenCaptureFilterableAudioContent content) | Adds audio content to a content filter. |
OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ExcludeContent (struct OH_AVScreenCapture *capture, struct OH_AVScreenCapture_ContentFilter *filter) | Sets a content filter for an OH_AVScreenCapture instance. |
OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ContentFilter_AddWindowContent (struct OH_AVScreenCapture_ContentFilter *filter, int32_t *windowIDs, int32_t windowCount) | Adds a list of window IDs to a ContentFilter instance. |
OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ResizeCanvas (struct OH_AVScreenCapture *capture, int32_t width, int32_t height) | Adjusts the screen resolution. |
OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SkipPrivacyMode (struct OH_AVScreenCapture *capture, int32_t *windowIDs, int32_t windowCount) | Exempts privacy windows during screen capture. |
OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetMaxVideoFrameRate (struct OH_AVScreenCapture *capture, int32_t frameRate) | Sets the maximum frame rate for screen capture. |
OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ShowCursor (struct OH_AVScreenCapture *capture, bool showCursor) | Sets whether to show the cursor. |
OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetDisplayCallback (struct OH_AVScreenCapture *capture, OH_AVScreenCapture_OnDisplaySelected callback, void *userData) | Sets a callback function for obtaining the display ID. |
OH_AVScreenCapture_CaptureStrategy * OH_AVScreenCapture_CreateCaptureStrategy (void) | Creates a screen capture strategy. |
OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ReleaseCaptureStrategy (OH_AVScreenCapture_CaptureStrategy *strategy) | Releases a screen capture strategy. |
OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetCaptureStrategy (struct OH_AVScreenCapture *capture, OH_AVScreenCapture_CaptureStrategy *strategy) | Sets a screen capture strategy for an OH_AVScreenCapture instance. |
OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_StrategyForKeepCaptureDuringCall (OH_AVScreenCapture_CaptureStrategy *strategy, bool value) | Sets whether to keep screen capture during a cellular call. |
OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetCaptureContentChangedCallback (struct OH_AVScreenCapture *capture, OH_AVScreenCapture_OnCaptureContentChanged callback, void *userData) | Sets a callback for screen capture content changes. |
Type Description
OH_AudioBuffer
typedef struct OH_AudioBuffer OH_AudioBuffer
Description
Defines a struct for the configuration such as the size, type, and timestamp of audio data.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 10
OH_AudioCaptureInfo
typedef struct OH_AudioCaptureInfo OH_AudioCaptureInfo
Description
Defines a struct for the audio capture information.
When both audioSampleRate and audioChannels are 0, the audio-related parameters are ignored and the audio data is not recorded.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 10
OH_AudioCaptureSourceType
typedef enum OH_AudioCaptureSourceType OH_AudioCaptureSourceType
Description
Defines an enum for the audio source types during screen capture.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 10
OH_AudioCodecFormat
typedef enum OH_AudioCodecFormat OH_AudioCodecFormat
Description
Defines an enum for the audio encoding formats.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 10
OH_AudioEncInfo
typedef struct OH_AudioEncInfo OH_AudioEncInfo
Description
Defines a struct for the audio encoding information.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 10
OH_AudioInfo
typedef struct OH_AudioInfo OH_AudioInfo
Description
Defines a struct for the audio information.
To perform both external capture (using microphones) and internal capture, audioSampleRate and audioChannels must be the same for both audio channels.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 10
OH_AVSCREEN_CAPTURE_ErrCode
typedef enum OH_AVSCREEN_CAPTURE_ErrCode OH_AVSCREEN_CAPTURE_ErrCode
Description
Defines an enum for the error codes generated during screen recording.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 10
OH_AVScreenCapture
typedef struct OH_AVScreenCaptureOH_AVScreenCapture
Description
Defines a screen capture instance used to obtain original video and audio streams.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 10
OH_AVScreenCapture_ContentFilter
typedef struct OH_AVScreenCapture_ContentFilterOH_AVScreenCapture_ContentFilter
Description
Defines a struct for the filter used to filter audio and video content.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 12
OH_AVScreenCapture_OnBufferAvailable
typedef void(* OH_AVScreenCapture_OnBufferAvailable) (OH_AVScreenCapture *capture, OH_AVBuffer *buffer, OH_AVScreenCaptureBufferType bufferType, int64_t timestamp, void *userData)
Description
Defines a pointer to the callback function that is called when an audio or a video buffer is available during the running of an OH_AVScreenCapture instance.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 12
Parameters
Name | Description |
---|---|
capture | Pointer to an OH_AVScreenCapture instance. |
buffer | Pointer to the OH_AVBuffer instance. After the callback is triggered, the buffer is no longer valid. |
bufferType | Type of the buffer. |
timestamp | Timestamp, in nanoseconds. |
userData | Pointer to the user-defined data carried in the function. |
OH_AVScreenCapture_OnDisplaySelected
typedef void (*OH_AVScreenCapture_OnDisplaySelected)(OH_AVScreenCapture *capture, uint64_t displayId, void *userData)
Description
Defines a pointer to the callback function that is called when screen capture starts.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 15
Parameters
Name | Description |
---|---|
capture | Pointer to an OH_AVScreenCapture instance. |
displayId | ID of the screen to capture. |
userData | Pointer to the user-defined data carried in the function. |
OH_AVScreenCapture_OnError
typedef void(* OH_AVScreenCapture_OnError) (OH_AVScreenCapture *capture, int32_t errorCode, void *userData)
Description
Defines a pointer to the callback function that is called when an error occurs during the running of an OH_AVScreenCapture instance.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 12
Parameters
Name | Description |
---|---|
capture | Pointer to an OH_AVScreenCapture instance. |
errorCode | Error code. |
userData | Pointer to the user-defined data carried in the function. |
OH_AVScreenCapture_OnStateChange
typedef void(* OH_AVScreenCapture_OnStateChange) (struct OH_AVScreenCapture *capture, OH_AVScreenCaptureStateCode stateCode, void *userData)
Description
Defines a pointer to the callback function that is called when the state changes during the running of an OH_AVScreenCapture instance.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 12
Parameters
Name | Description |
---|---|
capture | Pointer to an OH_AVScreenCapture instance. |
stateCode | Status code. |
userData | Pointer to the user-defined data carried in the function. |
OH_AVScreenCapture_OnCaptureContentChanged
typedef void (*OH_AVScreenCapture_OnCaptureContentChanged)(OH_AVScreenCapture* capture, OH_AVScreenCaptureContentChangedEvent event, OH_Rect* area, void *userData)
Description
Defines a pointer to the callback function that is called when the screen capture content changes during the running of an OH_AVScreenCapture instance.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 20
Parameters
Name | Description |
---|---|
capture | Pointer to an OH_AVScreenCapture instance. |
event | Screen capture content change event. |
area | Pointer to the area information when the screen capture content is visible. |
userData | Pointer to the user-defined data carried in the function. |
OH_AVScreenCaptureBufferType
typedef enum OH_AVScreenCaptureBufferTypeOH_AVScreenCaptureBufferType
Description
Defines an enum for the buffer types.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 12
OH_AVScreenCaptureCallback
typedef struct OH_AVScreenCaptureCallback OH_AVScreenCaptureCallback
Description
Defines a struct for all the asynchronous callback function pointers of an OH_AVScreenCapture instance. To ensure the normal running of OH_AVScreenCapture, you must register the instance of this struct with the OH_AVScreenCapture instance and process the information reported by the callback functions.
From API version 12, you are advised to use OH_AVScreenCapture_OnError and OH_AVScreenCapture_OnBufferAvailable instead.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 10
Parameters
Name | Description |
---|---|
onError | Pointer to a callback function that is called when an error occurs during the running of an OH_AVScreenCapture instance. For details, see OH_AVScreenCaptureOnError. |
onAudioBufferAvailable | Pointer to a callback function that is called when an audio buffer is available during the running of an OH_AVScreenCapture instance. For details, see OH_AVScreenCaptureOnAudioBufferAvailable. |
onVideoBufferAvailable | Pointer to a callback function that is called when a video buffer is available during the running of an OH_AVScreenCapture instance. For details, see OH_AVScreenCaptureOnVideoBufferAvailable. |
OH_AVScreenCaptureConfig
typedef struct OH_AVScreenCaptureConfig OH_AVScreenCaptureConfig
Description
Defines a struct for the screen capture configuration.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 10
OH_AVScreenCaptureFilterableAudioContent
typedef enum OH_AVScreenCaptureFilterableAudioContent OH_AVScreenCaptureFilterableAudioContent
Description
Defines an enum for the types of audio that can be added to a content filter.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 12
OH_AVScreenCaptureOnAudioBufferAvailable
typedef void(* OH_AVScreenCaptureOnAudioBufferAvailable) (OH_AVScreenCapture *capture, bool isReady, OH_AudioCaptureSourceType type)
Description
Defines a pointer to the callback function that is called when an audio buffer is available during the running of an OH_AVScreenCapture instance.
From API version 12, you are advised to use OH_AVScreenCapture_OnBufferAvailable instead.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 10
Parameters
Name | Description |
---|---|
capture | Pointer to an OH_AVScreenCapture instance. |
isReady | Whether the audio buffer is available. |
type | Audio source type. |
OH_AVScreenCaptureOnError
typedef void(* OH_AVScreenCaptureOnError) (OH_AVScreenCapture *capture, int32_t errorCode)
Description
Defines a pointer to the callback function that is called when an error occurs during the running of an OH_AVScreenCapture instance.
From API version 12, you are advised to use OH_AVScreenCapture_OnError instead.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 10
Parameters
Name | Description |
---|---|
capture | Pointer to an OH_AVScreenCapture instance. |
errorCode | Error code. |
OH_AVScreenCaptureOnVideoBufferAvailable
typedef void(* OH_AVScreenCaptureOnVideoBufferAvailable) (OH_AVScreenCapture *capture, bool isReady)
Description
Defines a pointer to the callback function that is called when a video buffer is available during the running of an OH_AVScreenCapture instance.
From API version 12, you are advised to use OH_AVScreenCapture_OnBufferAvailable instead.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 10
Parameters
Name | Description |
---|---|
capture | Pointer to an OH_AVScreenCapture instance. |
isReady | Whether the video buffer is available. |
OH_AVScreenCaptureStateCode
typedef enum OH_AVScreenCaptureStateCode OH_AVScreenCaptureStateCode
Description
Defines an enum for the screen capture states.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 12
OH_CaptureMode
typedef enum OH_CaptureMode OH_CaptureMode
Description
Defines an enum for the screen capture modes.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 10
OH_ContainerFormatType
typedef enum OH_ContainerFormatType OH_ContainerFormatType
Description
Defines an enum for the types of files generated during screen capture.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 10
OH_DataType
typedef enum OH_DataType OH_DataType
Description
Defines an enum for the data types of screen capture streams.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 10
OH_NativeBuffer
typedef struct OH_NativeBuffer OH_NativeBuffer
Description
Defines the native video stream class for screen capture.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 10
OH_RecorderInfo
typedef struct OH_RecorderInfo OH_RecorderInfo
Description
Defines a struct for the recording file information.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 10
OH_Rect
typedef struct OH_Rect OH_Rect
Description
Defines a struct for the width, height, and image information of the rectangle used for screen capture.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 10
OH_VideoCaptureInfo
typedef struct OH_VideoCaptureInfo OH_VideoCaptureInfo
Description
Defines a struct for the video capture information.
When videoFrameWidth and videoFrameHeight are both 0, video-related parameters are ignored and screen data is not recorded.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 10
OH_VideoCodecFormat
typedef enum OH_VideoCodecFormat OH_VideoCodecFormat
Description
Defines an enum for the video encoding formats.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 10
OH_VideoEncInfo
typedef struct OH_VideoEncInfo OH_VideoEncInfo
Description
Defines a struct for the video encoding information.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 10
OH_VideoInfo
typedef struct OH_VideoInfo OH_VideoInfo
Description
Defines a struct for the video information.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 10
OH_VideoSourceType
typedef enum OH_VideoSourceType OH_VideoSourceType
Description
Defines an enum for the video source formats. Currently, only the RGBA format is supported.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 10
OH_AVScreenCapture_CaptureStrategy
typedef struct OH_AVScreenCapture_CaptureStrategy OH_AVScreenCapture_CaptureStrategy;
Description
Defines a struct for the screen capture strategy.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 20
OH_AVScreenCaptureContentChangedEvent
typedef enum OH_AVScreenCaptureContentChangedEvent OH_AVScreenCaptureContentChangedEvent
Description
Defines an enum for the screen capture content change events.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 20
Enum Description
OH_AudioCaptureSourceType
enum OH_AudioCaptureSourceType
Description
Enumerates the audio source types during screen capture.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 10
Value | Description |
---|---|
OH_SOURCE_INVALID | Invalid audio source. |
OH_SOURCE_DEFAULT | Default audio source. The default value is MIC. |
OH_MIC | External audio streams recorded by the microphone. |
OH_ALL_PLAYBACK | All internal audio streams played by the system. |
OH_APP_PLAYBACK | Internal audio streams played by a specified application. |
OH_AudioCodecFormat
enum OH_AudioCodecFormat
Description
Enumerates the audio encoding formats.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 10
Value | Description |
---|---|
OH_AUDIO_DEFAULT | Default audio encoding format. The default value is AAC_LC. |
OH_AAC_LC | AAC_LC audio encoding. |
OH_AUDIO_CODEC_FORMAT_BUTT | Invalid format. |
OH_AVSCREEN_CAPTURE_ErrCode
enum OH_AVSCREEN_CAPTURE_ErrCode
Description
Enumerates the error codes generated during screen recording.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 10
Value | Description |
---|---|
AV_SCREEN_CAPTURE_ERR_BASE | Basic value returned when an API call error occurs. |
AV_SCREEN_CAPTURE_ERR_OK | Operation successful. |
AV_SCREEN_CAPTURE_ERR_NO_MEMORY | Memory insufficient. |
AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT | Operation not allowed. |
AV_SCREEN_CAPTURE_ERR_INVALID_VAL | Invalid parameter. |
AV_SCREEN_CAPTURE_ERR_IO | Abnormal input and output streams. |
AV_SCREEN_CAPTURE_ERR_TIMEOUT | Network timeout. |
AV_SCREEN_CAPTURE_ERR_UNKNOWN | Unknown error. |
AV_SCREEN_CAPTURE_ERR_SERVICE_DIED | Media service terminated. |
AV_SCREEN_CAPTURE_ERR_INVALID_STATE | Unsupported operation in this state. |
AV_SCREEN_CAPTURE_ERR_UNSUPPORT | Unsupported interface. |
AV_SCREEN_CAPTURE_ERR_EXTEND_START | Unexpected error. |
OH_AVScreenCaptureBufferType
enum OH_AVScreenCaptureBufferType
Description
Enumerates the buffer types.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 12
Value | Description |
---|---|
OH_SCREEN_CAPTURE_BUFFERTYPE_VIDEO | Video data. |
OH_SCREEN_CAPTURE_BUFFERTYPE_AUDIO_INNER | Internal audio capture data. |
OH_SCREEN_CAPTURE_BUFFERTYPE_AUDIO_MIC | Microphone audio data. |
OH_AVScreenCaptureFilterableAudioContent
enum OH_AVScreenCaptureFilterableAudioContent
Description
Enumerates the types of audio that can be added to a content filter.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 12
Value | Description |
---|---|
OH_SCREEN_CAPTURE_NOTIFICATION_AUDIO | Notification tone. |
OH_SCREEN_CAPTURE_CURRENT_APP_AUDIO | Sound of the application itself. |
OH_AVScreenCaptureStateCode
enum OH_AVScreenCaptureStateCode
Description
Enumerates the screen capture states.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 12
Value | Description |
---|---|
OH_SCREEN_CAPTURE_STATE_STARTED | Screen capture is started. |
OH_SCREEN_CAPTURE_STATE_CANCELED | Screen capture is canceled. |
OH_SCREEN_CAPTURE_STATE_STOPPED_BY_USER | Screen capture is stopped. |
OH_SCREEN_CAPTURE_STATE_INTERRUPTED_BY_OTHER | Screen capture is interrupted by another screen capture. |
OH_SCREEN_CAPTURE_STATE_STOPPED_BY_CALL | Screen capture is interrupted by a call. |
OH_SCREEN_CAPTURE_STATE_MIC_UNAVAILABLE | The microphone is unavailable. |
OH_SCREEN_CAPTURE_STATE_MIC_MUTED_BY_USER | The microphone is muted. |
OH_SCREEN_CAPTURE_STATE_MIC_UNMUTED_BY_USER | The microphone is unmuted. |
OH_SCREEN_CAPTURE_STATE_ENTER_PRIVATE_SCENE | The system enters a privacy dialog box. |
OH_SCREEN_CAPTURE_STATE_EXIT_PRIVATE_SCENE | The system exits a privacy dialog box. |
OH_SCREEN_CAPTURE_STATE_STOPPED_BY_USER_SWITCHES | Screen capture is interrupted by system user switching. |
OH_CaptureMode
enum OH_CaptureMode
Description
Enumerates the screen capture modes.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 10
Value | Description |
---|---|
OH_CAPTURE_HOME_SCREEN | Captures the home screen. |
OH_CAPTURE_SPECIFIED_SCREEN | Captures a specified screen. |
OH_CAPTURE_SPECIFIED_WINDOW | Captures a specified window. |
OH_CAPTURE_INVAILD | Invalid mode. |
OH_ContainerFormatType
enum OH_ContainerFormatType
Description
Enumerates the types of files generated during screen capture.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 10
Value | Description |
---|---|
CFT_MPEG_4A | Audio format M4A. |
CFT_MPEG_4 | Video format MP4. |
OH_DataType
enum OH_DataType
Description
Enumerates the data types of screen capture streams.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 10
Value | Description |
---|---|
OH_ORIGINAL_STREAM | Original stream format, such as YUV, RGBA, and PCM. |
OH_ENCODED_STREAM | Encoded stream format, such as H.264 and AAC. This value is not supported yet. |
OH_CAPTURE_FILE | Format of the recording file. The value can be mp4. |
OH_INVAILD | Invalid format. |
OH_VideoCodecFormat
enum OH_VideoCodecFormat
Description
Enumerates the video encoding formats.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 10
Value | Description |
---|---|
OH_VIDEO_DEFAULT | Default video encoding format. The default value is H.264. |
OH_H264 | H.264. |
OH_H265 | H.265/HEVC. |
OH_MPEG4 | MPEG4. |
OH_VP8 | VP8. |
OH_VP9 | VP9. |
OH_VIDEO_CODEC_FORMAT_BUTT | Invalid format. |
OH_VideoSourceType
enum OH_VideoSourceType
Description
Enumerates the video source formats. Currently, only the RGBA format is supported.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 10
Value | Description |
---|---|
OH_VIDEO_SOURCE_SURFACE_YUV | YUV format. This value is not supported yet. |
OH_VIDEO_SOURCE_SURFACE_ES | Raw format. This value is not supported yet. |
OH_VIDEO_SOURCE_SURFACE_RGBA | RGBA format. |
OH_VIDEO_SOURCE_BUTT | Invalid format. |
OH_AVScreenCaptureContentChangedEvent
enum OH_AVScreenCaptureContentChangedEvent
Description
Enumerates the screen capture content change events.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 20
Value | Description |
---|---|
OH_SCREEN_CAPTURE_CONTENT_HIDE | The screen capture content is hidden. |
OH_SCREEN_CAPTURE_CONTENT_VISIBLE | The screen capture content is visible. |
OH_SCREEN_CAPTURE_CONTENT_UNAVAILABLE | The screen capture content becomes unavailable. For example, the screen capture window is closed. |
Function Description
OH_AVScreenCapture_AcquireAudioBuffer()
OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_AcquireAudioBuffer (struct OH_AVScreenCapture * capture, OH_AudioBuffer ** audiobuffer, OH_AudioCaptureSourceType type )
Description
Obtains an audio buffer. When calling this function, the application must allocate the memory of the corresponding struct size to the audio buffer.
From API version 12, you are advised to use OH_AVScreenCapture_OnBufferAvailable instead.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 10
Parameters
Name | Description |
---|---|
capture | Pointer to an OH_AVScreenCapture instance. |
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. |
type | Type of the audio buffer, which is used to distinguish external streams recorded by the microphone from internal streams played by the system. For details, see OH_AudioCaptureSourceType. |
Returns
Result code defined in OH_AVSCREEN_CAPTURE_ErrCode.
AV_SCREEN_CAPTURE_ERR_OK: The operation is successful.
AV_SCREEN_CAPTURE_ERR_INVALID_VAL: The input parameter capture or audiobuffer is a null pointer.
AV_SCREEN_CAPTURE_ERR_NO_MEMORY: The audio buffer fails to be allocated due to insufficient memory.
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.
OH_AVScreenCapture_AcquireVideoBuffer()
OH_NativeBuffer* OH_AVScreenCapture_AcquireVideoBuffer (struct OH_AVScreenCapture * capture, int32_t * fence, int64_t * timestamp, struct OH_Rect * region )
Description
Obtains a video buffer. An application can call this function to obtain information such as the video buffer and timestamp. After the buffer is no longer needed, call OH_AVScreenCapture_ReleaseVideoBuffer to release it.
From API version 12, you are advised to use OH_AVScreenCapture_OnBufferAvailable instead.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 10
Parameters
Name | Description |
---|---|
capture | Pointer to an OH_AVScreenCapture instance. |
fence | Pointer to parameters for synchronization display. |
timestamp | Pointer to the timestamp of the video frame. |
region | Pointer to the coordinates related to video display. |
Returns
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.
OH_AVScreenCapture_ContentFilter_AddAudioContent()
OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ContentFilter_AddAudioContent (struct OH_AVScreenCapture_ContentFilter * filter, OH_AVScreenCaptureFilterableAudioContent content )
Description
Adds audio content to a content filter.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 12
Parameters
Name | Description |
---|---|
filter | Pointer to an OH_AVScreenCapture_ContentFilter instance. |
content | OH_AVScreenCaptureFilterableAudioContent instance. |
Returns
Result code defined in OH_AVSCREEN_CAPTURE_ErrCode.
AV_SCREEN_CAPTURE_ERR_OK: The operation is successful.
AV_SCREEN_CAPTURE_ERR_INVALID_VAL: The input parameter filter is a null pointer or the input parameter content is invalid.
OH_AVScreenCapture_ContentFilter_AddWindowContent()
OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ContentFilter_AddWindowContent (struct OH_AVScreenCapture_ContentFilter *filter, int32_t *windowIDs, int32_t windowCount)
Description
Adds a list of window IDs to a ContentFilter instance.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 12
Parameters
Name | Description |
---|---|
filter | Pointer to an OH_AVScreenCapture_ContentFilter instance. |
windowIDs | Pointer to the window IDs. |
windowCount | Length of the window ID list. |
Returns
AV_SCREEN_CAPTURE_ERR_OK if the operation is successful; an error code defined in OH_AVSCREEN_CAPTURE_ErrCode otherwise.
OH_AVScreenCapture_Create()
struct OH_AVScreenCapture* OH_AVScreenCapture_Create (void )
Description
Creates an OH_AVScreenCapture instance. You can release the instance by calling OH_AVScreenCapture_Release.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 10
Returns
Pointer to an OH_AVScreenCapture instance.
OH_AVScreenCapture_CreateContentFilter()
struct OH_AVScreenCapture_ContentFilter* OH_AVScreenCapture_CreateContentFilter (void )
Description
Creates a content filter.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 12
Returns
OH_AVScreenCapture_ContentFilter if the operation is successful; a null pointer otherwise.
OH_AVScreenCapture_ExcludeContent()
OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ExcludeContent (struct OH_AVScreenCapture * capture, struct OH_AVScreenCapture_ContentFilter * filter )
Description
Sets a content filter for an OH_AVScreenCapture instance.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 12
Parameters
Name | Description |
---|---|
capture | Pointer to an OH_AVScreenCapture instance. |
filter | Pointer to an OH_AVScreenCapture_ContentFilter instance. |
Returns
Result code defined in OH_AVSCREEN_CAPTURE_ErrCode.
AV_SCREEN_CAPTURE_ERR_OK: The operation is successful.
AV_SCREEN_CAPTURE_ERR_INVALID_VAL: The input parameter capture or filter is a null pointer.
AV_SCREEN_CAPTURE_ERR_UNSUPPORT: The operation is not supported. For streams, the AudioCapturer API must be called for the operation to take effect during the start. For captured files, the AudioRecorder API must be called for the operation to take effect during the start.
OH_AVScreenCapture_Init()
OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_Init (struct OH_AVScreenCapture * capture, OH_AVScreenCaptureConfig config )
Description
Initializes parameters related to an OH_AVScreenCapture instance, including audio sampling parameters for external capture using microphones (optional), audio sampling parameters for internal capture, and video resolution parameters.
In 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.
In 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).
The 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.
If both audioSampleRate and audioChannels in the OH_AudioCaptureInfo struct are 0, the OH_AVScreenCapture instance ignores the audio parameters of this type and does not collect the audio data of this type.
If both videoFrameWidth and videoFrameHeight in the OH_VideoCaptureInfo struct are 0, the OH_AVScreenCapture instance ignores the corresponding video parameters and does not collect screen data.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 10
Parameters
Name | Description |
---|---|
capture | Pointer to an OH_AVScreenCapture instance. |
config | Parameters related to screen capture initialization. |
Returns
Result code defined in OH_AVSCREEN_CAPTURE_ErrCode.
AV_SCREEN_CAPTURE_ERR_OK: The operation is successful.
AV_SCREEN_CAPTURE_ERR_INVALID_VAL: The input parameter capture is a null pointer.
AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT: The operation is not allowed. The configuration fails to be initialized.
OH_AVScreenCapture_Release()
OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_Release (struct OH_AVScreenCapture * capture)
Description
Releases an OH_AVScreenCapture instance. This function is used in pair with OH_AVScreenCapture_Create.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 10
Parameters
Name | Description |
---|---|
capture | Pointer to an OH_AVScreenCapture instance. |
Returns
Result code defined in OH_AVSCREEN_CAPTURE_ErrCode.
AV_SCREEN_CAPTURE_ERR_OK: The operation is successful.
AV_SCREEN_CAPTURE_ERR_INVALID_VAL: The input parameter capture is a null pointer.
AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT: The operation is not allowed. The OH_AVScreenCapture instance fails to be released.
OH_AVScreenCapture_ReleaseAudioBuffer()
OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ReleaseAudioBuffer (struct OH_AVScreenCapture * capture, OH_AudioCaptureSourceType type )
Description
Releases an audio buffer. After the audio buffer is no longer needed, call this function to release it.
From API version 12, you are advised to use OH_AVScreenCapture_OnBufferAvailable instead.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 10
Parameters
Name | Description |
---|---|
capture | Pointer to an OH_AVScreenCapture instance. |
type | Type of the audio buffer, which is used to distinguish external streams recorded by the microphone from internal streams played by the system. |
Returns
Result code defined in OH_AVSCREEN_CAPTURE_ErrCode.
AV_SCREEN_CAPTURE_ERR_OK: The operation is successful.
AV_SCREEN_CAPTURE_ERR_INVALID_VAL: The input parameter capture is a null pointer.
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.
OH_AVScreenCapture_ReleaseContentFilter()
OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ReleaseContentFilter (struct OH_AVScreenCapture_ContentFilter * filter)
Description
Releases a content filter.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 12
Parameters
Name | Description |
---|---|
filter | Pointer to an OH_AVScreenCapture_ContentFilter instance. |
Returns
Result code defined in OH_AVSCREEN_CAPTURE_ErrCode.
AV_SCREEN_CAPTURE_ERR_OK: The operation is successful.
AV_SCREEN_CAPTURE_ERR_INVALID_VAL: The input parameter filter is a null pointer.
OH_AVScreenCapture_ReleaseVideoBuffer()
OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ReleaseVideoBuffer (struct OH_AVScreenCapture * capture)
Description
Releases a video buffer. After the video buffer is no longer needed, call this function to release it.
From API version 12, you are advised to use OH_AVScreenCapture_OnBufferAvailable instead.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 10
Parameters
Name | Description |
---|---|
capture | Pointer to an OH_AVScreenCapture instance. |
Returns
Result code defined in OH_AVSCREEN_CAPTURE_ErrCode.
AV_SCREEN_CAPTURE_ERR_OK: The operation is successful.
AV_SCREEN_CAPTURE_ERR_INVALID_VAL: The input parameter capture is a null pointer.
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.
OH_AVScreenCapture_SetCallback()
OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetCallback (struct OH_AVScreenCapture * capture, struct OH_AVScreenCaptureCallback callback )
Description
Sets a callback to listen for available video buffers and audio buffers and errors that occur during the function calling.
From API version 12, you are advised to use OH_AVScreenCapture_SetErrorCallback and OH_AVScreenCapture_SetDataCallback instead.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 10
Parameters
Name | Description |
---|---|
capture | Pointer to an OH_AVScreenCapture instance. |
callback | OH_AVScreenCaptureCallback struct, which stores related callback function pointers. |
Returns
Result code defined in OH_AVSCREEN_CAPTURE_ErrCode.
AV_SCREEN_CAPTURE_ERR_OK: The operation is successful.
AV_SCREEN_CAPTURE_ERR_INVALID_VAL: The input parameter capture or callback is a null pointer.
AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT: The operation is not allowed. The callback fails to be set.
OH_AVScreenCapture_SetCanvasRotation()
OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetCanvasRotation (struct OH_AVScreenCapture * capture, bool canvasRotation )
Description
Sets canvas rotation for screen capture.
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.
The default value is false.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 12
Parameters
Name | Description |
---|---|
capture | Pointer to an OH_AVScreenCapture instance. |
canvasRotation | Whether to enable screen data rotation. |
Returns
Result code defined in OH_AVSCREEN_CAPTURE_ErrCode.
AV_SCREEN_CAPTURE_ERR_OK: The operation is successful.
AV_SCREEN_CAPTURE_ERR_INVALID_VAL: The input parameter capture is a null pointer.
AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT: The operation is not allowed. Canvas rotation fails to be set for screen capture.
OH_AVScreenCapture_SetDataCallback()
OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetDataCallback (struct OH_AVScreenCapture * capture, OH_AVScreenCapture_OnBufferAvailable callback, void * userData )
Description
Sets a data processing callback. This function must be called before screen capture starts.
The callback is triggered when an audio buffer or a video buffer becomes available during the running of an OH_AVScreenCapture instance.
The 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.
A successful call to this function leads to the following scenarios:
- The callbacks OH_AVScreenCaptureOnAudioBufferAvailable and OH_AVScreenCaptureOnVideoBufferAvailable set by calling OH_AVScreenCapture_SetCallback will no longer be triggered, even when an audio buffer or a video buffer becomes available.
- A failure message is returned for a call to any of the following functions: OH_AVScreenCapture_AcquireAudioBuffer, OH_AVScreenCapture_ReleaseAudioBuffer, OH_AVScreenCapture_AcquireVideoBuffer, and OH_AVScreenCapture_ReleaseVideoBuffer.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 12
Parameters
Name | Description |
---|---|
capture | Pointer to an OH_AVScreenCapture instance. |
callback | Data processing callback, which is OH_AVScreenCapture_OnBufferAvailable. |
userData | Pointer to the user-defined data. The data is returned as an input parameter when the data processing callback is triggered. |
Returns
Result code defined in OH_AVSCREEN_CAPTURE_ErrCode.
AV_SCREEN_CAPTURE_ERR_OK: The operation is successful.
AV_SCREEN_CAPTURE_ERR_INVALID_VAL: The input parameter capture or callback is a null pointer.
AV_SCREEN_CAPTURE_ERR_NO_MEMORY: The memory fails to be allocated due to insufficient memory.
AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT: The operation is not allowed. The data callback fails to be set.
OH_AVScreenCapture_SetDisplayCallback()
OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetDisplayCallback(struct OH_AVScreenCapture *capture, OH_AVScreenCapture_OnDisplaySelected callback, void *userData)
Description
Sets a callback function for obtaining the display ID.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 15
Parameters
Name | Description |
---|---|
capture | Pointer to an OH_AVScreenCapture instance. |
callback | Callback function for returning the display ID. The callback function is an OH_AVScreenCapture_OnDisplaySelected object. |
userData | Pointer to the user-defined data. The data is returned as an input parameter when the state change callback is triggered. |
Returns
Result code defined in OH_AVSCREEN_CAPTURE_ErrCode.
AV_SCREEN_CAPTURE_ERR_OK: The operation is successful.
AV_SCREEN_CAPTURE_ERR_INVALID_VAL: The input parameter capture or callback is a null pointer.
AV_SCREEN_CAPTURE_ERR_NO_MEMORY: The memory fails to be allocated due to insufficient memory.
AV_SCREEN_CAPTURE_ERR_INVALID_STATE: This operation is not supported in the current state. The callback function must be called before start is called.
OH_AVScreenCapture_SetErrorCallback()
OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetErrorCallback (struct OH_AVScreenCapture * capture, OH_AVScreenCapture_OnError callback, void * userData )
Description
Sets an error processing callback. This function must be called before screen capture starts.
The callback is triggered when an error occurs during the running of an OH_AVScreenCapture instance.
After a successful call to this function, the callback OH_AVScreenCaptureOnError set by calling OH_AVScreenCapture_SetCallback will no longer be triggered, even when an error occurs in the OH_AVScreenCapture instance.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 12
Parameters
Name | Description |
---|---|
capture | Pointer to an OH_AVScreenCapture instance. |
callback | Error processing callback, which is OH_AVScreenCapture_OnError. |
userData | Pointer to the user-defined data. The data is returned as an input parameter when the error processing callback is triggered. |
Returns
Result code defined in OH_AVSCREEN_CAPTURE_ErrCode.
AV_SCREEN_CAPTURE_ERR_OK: The operation is successful.
AV_SCREEN_CAPTURE_ERR_INVALID_VAL: The input parameter capture or callback is a null pointer.
AV_SCREEN_CAPTURE_ERR_NO_MEMORY: The memory fails to be allocated due to insufficient memory.
AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT: The operation is not allowed. The error callback fails to be set.
OH_AVScreenCapture_SetMicrophoneEnabled()
OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetMicrophoneEnabled (struct OH_AVScreenCapture * capture, bool isMicrophone )
Description
Enables or disables the microphone. When isMicrophone is set to true, the microphone is enabled, and the original PCM data of the microphone can be obtained by calling OH_AVScreenCapture_StartScreenCapture and OH_AVScreenCapture_AcquireAudioBuffer. When isMicrophone is set to false, the obtained audio data is silent data.
By default, the microphone is enabled.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 10
Parameters
Name | Description |
---|---|
capture | Pointer to an OH_AVScreenCapture instance. |
isMicrophone | Whether to enable the microphone. |
Returns
Result code defined in OH_AVSCREEN_CAPTURE_ErrCode.
AV_SCREEN_CAPTURE_ERR_OK: The operation is successful.
AV_SCREEN_CAPTURE_ERR_INVALID_VAL: The input parameter capture is a null pointer.
AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT: The operation is not allowed. The microphone fails to be enabled or disabled.
OH_AVScreenCapture_SetStateCallback()
OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetStateCallback (struct OH_AVScreenCapture * capture, OH_AVScreenCapture_OnStateChange callback, void * userData )
Description
Sets a state change callback. This function must be called before screen capture starts.
The callback is triggered when the state changes during the running of an OH_AVScreenCapture instance.
A 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:
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_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_SCREEN_CAPTURE_STATE_MIC_UNAVAILABLE if the microphone is unavailable), or the error processing callback OH_AVScreenCapture_OnError is triggered to report the error information.
If the user disagrees, the screen capture startup process stops. The state change callback is triggered to report the OH_SCREEN_CAPTURE_STATE_CANCELED status to notify the application of the startup failure due to user rejection.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 12
Parameters
Name | Description |
---|---|
capture | Pointer to an OH_AVScreenCapture instance. |
callback | State change callback, which is OH_AVScreenCapture_OnStateChange. |
userData | Pointer to the user-defined data. The data is returned as an input parameter when the state change callback is triggered. |
Returns
Result code defined in OH_AVSCREEN_CAPTURE_ErrCode.
AV_SCREEN_CAPTURE_ERR_OK: The operation is successful.
AV_SCREEN_CAPTURE_ERR_INVALID_VAL: The input parameter capture or callback is a null pointer.
AV_SCREEN_CAPTURE_ERR_NO_MEMORY: The memory fails to be allocated due to insufficient memory.
AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT: The operation is not allowed. The state callback fails to be set.
OH_AVScreenCapture_StartScreenCapture()
OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_StartScreenCapture (struct OH_AVScreenCapture * capture)
Description
Starts screen capture and collects original streams. After this function is called, the callback (OH_AVScreenCapture_OnBufferAvailable) can be used to check whether streams are generated, and the callback (OH_AVScreenCapture_OnStateChange) can be used to check the startup status.
The application can obtain the original streams of screen capture by calling OH_AVScreenCapture_AcquireAudioBuffer and OH_AVScreenCapture_ReleaseVideoBuffer.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 10
Parameters
Name | Description |
---|---|
capture | Pointer to an OH_AVScreenCapture instance. |
Returns
Result code defined in OH_AVSCREEN_CAPTURE_ErrCode.
AV_SCREEN_CAPTURE_ERR_OK: The operation is successful.
AV_SCREEN_CAPTURE_ERR_INVALID_VAL: The input parameter capture is a null pointer.
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.
OH_AVScreenCapture_StartScreenCaptureWithSurface()
OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_StartScreenCaptureWithSurface (struct OH_AVScreenCapture * capture, OHNativeWindow * window )
Description
Starts screen capture in surface mode.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 12
Parameters
Name | Description |
---|---|
capture | Pointer to an OH_AVScreenCapture instance. |
window | Pointer to an OHNativeWindow instance. |
Returns
Result code defined in OH_AVSCREEN_CAPTURE_ErrCode.
AV_SCREEN_CAPTURE_ERR_OK: The operation is successful.
AV_SCREEN_CAPTURE_ERR_INVALID_VAL: The input parameter capture, input parameter window, or windowSurface pointed to by window is a null pointer.
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.
OH_AVScreenCapture_StartScreenRecording()
OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_StartScreenRecording (struct OH_AVScreenCapture * capture)
Description
Starts screen recording, with recordings saved in files.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 10
Parameters
Name | Description |
---|---|
capture | Pointer to an OH_AVScreenCapture instance. |
Returns
Result code defined in OH_AVSCREEN_CAPTURE_ErrCode.
AV_SCREEN_CAPTURE_ERR_OK: The operation is successful.
AV_SCREEN_CAPTURE_ERR_INVALID_VAL: The input parameter capture is a null pointer.
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.
OH_AVScreenCapture_StopScreenCapture()
OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_StopScreenCapture (struct OH_AVScreenCapture * capture)
Description
Stops screen capture. This function is used in pair with OH_AVScreenCapture_StartScreenCapture. After calling this function, the application stops screen capture or screen share and releases the microphone.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 10
Parameters
Name | Description |
---|---|
capture | Pointer to an OH_AVScreenCapture instance. |
Returns
Result code defined in OH_AVSCREEN_CAPTURE_ErrCode.
AV_SCREEN_CAPTURE_ERR_OK: The operation is successful.
AV_SCREEN_CAPTURE_ERR_INVALID_VAL: The input parameter capture is a null pointer.
AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT: The operation is not allowed. Screen capture fails to stop.
OH_AVScreenCapture_StopScreenRecording()
OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_StopScreenRecording (struct OH_AVScreenCapture * capture)
Description
Stops screen recording. This function is used in pair with OH_AVScreenCapture_StartScreenRecording.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 10
Parameters
Name | Description |
---|---|
capture | Pointer to an OH_AVScreenCapture instance. |
Returns
Result code defined in OH_AVSCREEN_CAPTURE_ErrCode.
AV_SCREEN_CAPTURE_ERR_OK: The operation is successful.
AV_SCREEN_CAPTURE_ERR_INVALID_VAL: The input parameter capture is a null pointer.
AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT: The operation is not allowed. Screen capture fails to stop.
OH_AVScreenCapture_ResizeCanvas()
OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ResizeCanvas (struct OH_AVScreenCapture * capture, int32_t width, int32_t height)
Description
Adjusts the screen resolution.
This function is used to set the resolution of screen capture data. width indicates the screen width and height indicates the screen height.
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.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 12
Parameters
Name | Description |
---|---|
capture | Pointer to an OH_AVScreenCapture instance. |
width | Width of the screen to capture. |
height | Height of the screen to capture. |
Returns
Result code defined in OH_AVSCREEN_CAPTURE_ErrCode.
AV_SCREEN_CAPTURE_ERR_OK: The operation is successful.
AV_SCREEN_CAPTURE_ERR_INVALID_VAL: The input parameter capture is a null pointer.
AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT: The operation is not allowed.
OH_AVScreenCapture_ShowCursor()
OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ShowCursor(struct OH_AVScreenCapture *capture, bool showCursor)
Description
Sets whether to show the cursor.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 15
Parameters
Name | Description |
---|---|
capture | Pointer to an OH_AVScreenCapture instance. |
showCursor | Whether to show the cursor. |
Returns
Result code defined in OH_AVSCREEN_CAPTURE_ErrCode.
AV_SCREEN_CAPTURE_ERR_OK: The operation is successful.
AV_SCREEN_CAPTURE_ERR_INVALID_VAL: The input parameter capture is a null pointer.
AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT: The operation is not allowed. The cursor setting fails.
OH_AVScreenCapture_SkipPrivacyMode()
OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SkipPrivacyMode (struct OH_AVScreenCapture * capture, int32_t *windowIDs, int32_t windowCount)
Description
Exempts privacy windows during screen capture.
Currently, all the IDs of the subwindows and main windows to skip must be passed in.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 12
Parameters
Name | Description |
---|---|
capture | Pointer to an OH_AVScreenCapture instance. |
windowIDs | Pointer to the IDs of the privacy windows to skip. |
windowCount | Length of the privacy window ID list. |
Returns
Result code defined in OH_AVSCREEN_CAPTURE_ErrCode.
AV_SCREEN_CAPTURE_ERR_OK: The operation is successful.
AV_SCREEN_CAPTURE_ERR_INVALID_VAL: The input parameter capture is a null pointer.
AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT: The operation is not allowed.
OH_AVScreenCapture_SetMaxVideoFrameRate()
OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetMaxVideoFrameRate (struct OH_AVScreenCapture * capture, int32_t frameRate)
Description
Sets the maximum frame rate for screen capture.
This function must be called after screen capture starts.
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.
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.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 14
Parameters
Name | Description |
---|---|
capture | Pointer to an OH_AVScreenCapture instance. |
frameRate | Maximum frame rate. |
Returns
Result code defined in OH_AVSCREEN_CAPTURE_ErrCode.
AV_SCREEN_CAPTURE_ERR_OK: The operation is successful.
AV_SCREEN_CAPTURE_ERR_INVALID_VAL: The input parameter capture is a null pointer, or the input parameter frameRate is not supported.
AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT: The operation is restricted. You are advised to try again.
OH_AVScreenCapture_CreateCaptureStrategy()
OH_AVScreenCapture_CaptureStrategy* OH_AVScreenCapture_CreateCaptureStrategy(void);
Description
Creates a screen capture strategy.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 20
Returns
OH_AVScreenCapture_CaptureStrategy instance if the operation is successful; a null pointer otherwise.
OH_AVScreenCapture_ReleaseCaptureStrategy()
OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ReleaseCaptureStrategy(OH_AVScreenCapture_CaptureStrategy* strategy);
Description
Releases a screen capture strategy.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 20
Parameters
Name | Description |
---|---|
strategy | Pointer to an OH_AVScreenCapture_CaptureStrategy instance. |
Returns
Result code defined in OH_AVSCREEN_CAPTURE_ErrCode.
AV_SCREEN_CAPTURE_ERR_OK: The operation is successful.
AV_SCREEN_CAPTURE_ERR_INVALID_VAL: The input parameter strategy is a null pointer.
OH_AVScreenCapture_SetCaptureStrategy()
OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetCaptureStrategy(struct OH_AVScreenCapture *capture, OH_AVScreenCapture_CaptureStrategy *strategy);
Description
Sets a screen capture strategy for an OH_AVScreenCapture instance.
This function must be called before screen capture starts.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 20
Parameters
Name | Description |
---|---|
capture | Pointer to an OH_AVScreenCapture instance. |
strategy | Pointer to an OH_AVScreenCapture_CaptureStrategy instance. |
Returns
Result code defined in OH_AVSCREEN_CAPTURE_ErrCode.
AV_SCREEN_CAPTURE_ERR_OK: The operation is successful.
AV_SCREEN_CAPTURE_ERR_INVALID_VAL: The input parameter capture or strategy is a null pointer.
AV_SCREEN_CAPTURE_ERR_UNSUPPORT: The operation is not supported. For example, the function is called after screen capture.
OH_AVScreenCapture_StrategyForKeepCaptureDuringCall()
OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_StrategyForKeepCaptureDuringCall(OH_AVScreenCapture_CaptureStrategy *strategy, bool value);
Description
Sets whether to keep screen capture during a cellular call.
The value true means to keep screen capture during a cellular call, and false means the opposite. The default value is false.
When this parameter 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.
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 20
Parameters
Name | Description |
---|---|
strategy | Pointer to an OH_AVScreenCapture_CaptureStrategy instance. |
value | Whether to keep screen capture. |
Returns
Result code defined in OH_AVSCREEN_CAPTURE_ErrCode.
AV_SCREEN_CAPTURE_ERR_OK: The operation is successful.
AV_SCREEN_CAPTURE_ERR_INVALID_VAL: The input parameter strategy is a null pointer.
OH_AVScreenCapture_SetCaptureContentChangedCallback()
OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetCaptureContentChangedCallback(struct OH_AVScreenCapture *capture,
OH_AVScreenCapture_OnCaptureContentChanged callback, void *userData)
Description
System capability: SystemCapability.Multimedia.Media.AVScreenCapture
Since: 20
Parameters
Name | Description |
---|---|
capture | Pointer to an OH_AVScreenCapture instance. |
callback | Pointer to the callback function instance for the screen capture content change event OH_AVScreenCapture_OnCaptureContentChanged. |
userData | Pointer to the user-defined data. The data is returned as an input parameter when the error processing callback is triggered. |
Returns
Result code defined in OH_AVSCREEN_CAPTURE_ErrCode.
AV_SCREEN_CAPTURE_ERR_OK: The operation is successful.
AV_SCREEN_CAPTURE_ERR_INVALID_VAL: The input parameter capture or callback is a null pointer.
AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT: The operation is not allowed. The screen capture callback fails to be set.
你可能感兴趣的鸿蒙文章
harmony 鸿蒙OH_AVRecorder_Config
harmony 鸿蒙OH_AVRecorder_EncoderInfo
- 所属分类: 后端技术
- 本文标签:
热门推荐
-
2、 - 优质文章
-
3、 gate.io
-
8、 golang
-
9、 openharmony
-
10、 Vue中input框自动聚焦