harmony 鸿蒙AVScreenCapture

2023-10-30 浏览 (885)

AVScreenCapture

Overview

The AVScreenCapture module provides APIs for screen capture.

System capability: SystemCapability.Multimedia.Media.AVScreenCapture

Since

10

Summary

Files

NameDescription
native_avscreen_capture.hDeclares the native APIs used to create an OH_AVScreenCapture instance.
File to include: <multimedia/player_framework/native_avscreen_capture.h>
Library: libnative_avscreen_capture.so
native_avscreen_capture_base.hDeclares the common structs, character constants, and enums used for running screen capture.
File to include: <multimedia/player_framework/native_avscreen_capture_base.h>
Library: libnative_avscreen_capture.so
native_avscreen_capture_errors.hDeclares the error codes generated during screen capture.
File to include: <multimedia/player_framework/native_avscreen_capture_errors.h>
Library: libnative_avscreen_capture.so

Structs

NameDescription
OH_AudioCaptureInfoDefines audio capture information.
OH_AudioEncInfoDefines audio encoding information.
NOTE: This struct is reserved and will be provided in later versions.
OH_AudioInfoDefines audio capture parameters.
OH_VideoCaptureInfoDefines video capture information.
OH_VideoEncInfoDefines video encoding information.
NOTE: This struct is reserved and will be provided in later versions.
OH_VideoInfoDefines video capture parameters.
OH_RecorderInfoDefines recording file information.
NOTE: This struct is reserved and will be provided in later versions.
OH_AVScreenCaptureConfigDefines the screen capture configuration.
OH_AVScreenCaptureCallbackDefines all the asynchronous callback function pointers of an OH_AVScreenCapture instance.
OH_RectDefines the width, height, and image information of the rectangle used for screen capture.
OH_AudioBufferDefines the configuration such as the size, type, and timestamp of audio data.

Types

NameDescription
OH_NativeBufferDefines the native video stream class for screen capture.
OH_AVScreenCaptureDefines a screen capture instance used to obtain original video and audio streams.
OH_CaptureModeDefines an enum that enumerates the screen capture modes.
OH_AudioCaptureSourceTypeDefines an enum that enumerates the audio source types during screen capture.
OH_AudioCodecFormatDefines an enum that enumerates the audio encoding formats.
OH_VideoCodecFormatDefines an enum that enumerates the video encoding formats.
OH_DataTypeDefines an enum that enumerates the data types of screen capture streams.
OH_VideoSourceTypeDefines an enum that enumerates the video source formats.
OH_ContainerFormatTypeDefines an enum that enumerates the types of files generated during screen capture.
NOTE: This type is reserved and will be provided in later versions.
OH_AudioCaptureInfoDefines audio capture information.
OH_AudioEncInfoDefines audio encoding information.
NOTE: This type is reserved and will be provided in later versions.
OH_AudioInfoDefines audio capture parameters.
OH_VideoCaptureInfoDefines video capture information.
OH_VideoEncInfoDefines video encoding information.
NOTE: This type is reserved and will be provided in later versions.
OH_VideoInfoDefines video capture parameters.
OH_RecorderInfoDefines recording file information.
OH_AVScreenCaptureConfigDefines the screen capture configuration.
(*OH_AVScreenCaptureOnError) (OH_AVScreenCapture *capture, int32_t errorCode)Defines a pointer to a callback function that is called when an error occurs during the running of an OH_AVScreenCapture instance.
(*OH_AVScreenCaptureOnAudioBufferAvailable) (OH_AVScreenCapture *capture, bool isReady, OH_AudioCaptureSourceType type)Defines a pointer to a callback function that is called when an audio buffer is available during the running of an OH_AVScreenCapture instance.
(*OH_AVScreenCaptureOnVideoBufferAvailable) (OH_AVScreenCapture *capture, bool isReady)Defines a pointer to a callback function that is called when a video buffer is available during the running of an OH_AVScreenCapture instance.
OH_AVScreenCaptureCallbackDefines all the asynchronous callback function pointers of an OH_AVScreenCapture instance.
OH_RectDefines the width, height, and image information of the rectangle used for screen capture.
OH_AudioBufferDefines the configuration such as the size, type, and timestamp of audio data.
OH_AVSCREEN_CAPTURE_ErrCodeDefines an enum that enumerates the error codes generated during screen recording.

Enums

NameDescription
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.
OH_ContainerFormatType { CFT_MPEG_4A = 0, CFT_MPEG_4 = 1 }Enumerates the types of files generated during screen capture.
NOTE: This enum is reserved and will be provided in later versions.
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.

Functions

NameDescription
OH_AVScreenCapture_Create (void)Creates an OH_AVScreenCapture instance.
OH_AVScreenCapture_Init (struct OH_AVScreenCapture *capture, OH_AVScreenCaptureConfig config)Initializes parameters related to an OH_AVScreenCapture instance.
OH_AVScreenCapture_StartScreenCapture (struct OH_AVScreenCapture *capture)Starts screen capture and collects original streams. After calling this function, the application can use the callback listeners OH_AVScreenCaptureOnAudioBufferAvailable and OH_AVScreenCaptureOnVideoBufferAvailable to check whether streams are generated.
OH_AVScreenCapture_StopScreenCapture (struct OH_AVScreenCapture *capture)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.
OH_AVScreenCapture_StartScreenRecording (struct OH_AVScreenCapture *capture)Starts screen recording and collects encoded streams.
NOTE: This function is reserved and will be provided in later versions.
OH_AVScreenCapture_StopScreenRecording (struct OH_AVScreenCapture *capture)Stops screen recording. This function is used in pair with OH_AVScreenCapture_StartScreenRecording.
NOTE: This function is reserved and will be provided in later versions.
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_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_AVScreenCapture_ReleaseAudioBuffer (struct OH_AVScreenCapture *capture, OH_AudioCaptureSourceType type)Releases an audio buffer.
OH_AVScreenCapture_ReleaseVideoBuffer (struct OH_AVScreenCapture *capture)Releases a video buffer.
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_AVScreenCapture_Release (struct OH_AVScreenCapture *capture)Releases an OH_AVScreenCapture instance. This function is used in pair with OH_AVScreenCapture_Create.
OH_AVScreenCapture_SetMicrophoneEnabled (struct OH_AVScreenCapture *capture, bool isMicrophone)Enables or disables the microphone.

Type Description

OH_AudioBuffer

typedef struct OH_AudioBuffer OH_AudioBuffer

Description

Defines the configuration such as the size, type, and timestamp of audio data.

System capability

SystemCapability.Multimedia.Media.AVScreenCapture

OH_AudioCaptureInfo

typedef struct OH_AudioCaptureInfo OH_AudioCaptureInfo

Description

Defines audio capture information.

System capability

SystemCapability.Multimedia.Media.AVScreenCapture

OH_AudioCaptureSourceType

typedef enum OH_AudioCaptureSourceType OH_AudioCaptureSourceType

Description

Defines an enum that enumerates the audio source types during screen capture.

System capability

SystemCapability.Multimedia.Media.AVScreenCapture

OH_AudioCodecFormat

typedef enum OH_AudioCodecFormat OH_AudioCodecFormat

Description

Defines an enum that enumerates the audio encoding formats.

System capability

SystemCapability.Multimedia.Media.AVScreenCapture

OH_AudioEncInfo

typedef struct OH_AudioEncInfo OH_AudioEncInfo

Description

Defines audio encoding information.

NOTE

This type is reserved and will be provided in later versions.

System capability

SystemCapability.Multimedia.Media.AVScreenCapture

OH_AudioInfo

typedef struct OH_AudioInfo OH_AudioInfo

Description

Defines audio capture parameters.

System capability

SystemCapability.Multimedia.Media.AVScreenCapture

OH_AVSCREEN_CAPTURE_ErrCode

typedef enum OH_AVSCREEN_CAPTURE_ErrCode OH_AVSCREEN_CAPTURE_ErrCode

Description

Defines an enum that enumerates the error codes generated during screen recording.

System capability

SystemCapability.Multimedia.Media.AVScreenCapture

OH_AVScreenCapture

typedef struct OH_AVScreenCapture OH_AVScreenCapture

Description

Defines a screen capture instance used to obtain original video and audio streams.

System capability

SystemCapability.Multimedia.Media.AVScreenCapture

OH_AVScreenCaptureCallback

typedef struct OH_AVScreenCaptureCallback OH_AVScreenCaptureCallback

Description

Defines 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.

Parameters

NameDescription
onErrorPointer to a callback function that is called when an error occurs during the running of an OH_AVScreenCapture instance. For details, see OH_AVScreenCaptureOnError.
onAudioBufferAvailablePointer 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.
onVideoBufferAvailablePointer 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.

System capability

SystemCapability.Multimedia.Media.AVScreenCapture

OH_AVScreenCaptureConfig

typedef struct OH_AVScreenCaptureConfig OH_AVScreenCaptureConfig

Description

Defines the screen capture configuration.

System capability

SystemCapability.Multimedia.Media.AVScreenCapture

OH_AVScreenCaptureOnAudioBufferAvailable

typedef void(* OH_AVScreenCaptureOnAudioBufferAvailable) (OH_AVScreenCapture *capture, bool isReady, OH_AudioCaptureSourceType type)

Description

Defines a pointer to a callback function that is called when an audio buffer is available during the running of an OH_AVScreenCapture instance.

Parameters

NameDescription
capturePointer to an OH_AVScreenCapture instance.
isReadyWhether the audio buffer is available.
typeAudio source type.

System capability

SystemCapability.Multimedia.Media.AVScreenCapture

OH_AVScreenCaptureOnError

typedef void(* OH_AVScreenCaptureOnError) (OH_AVScreenCapture *capture, int32_t errorCode)

Description

Defines a pointer to a callback function that is called when an error occurs during the running of an OH_AVScreenCapture instance.

Parameters

NameDescription
capturePointer to an OH_AVScreenCapture instance.
errorCodeError code.

System capability

SystemCapability.Multimedia.Media.AVScreenCapture

OH_AVScreenCaptureOnVideoBufferAvailable

typedef void(* OH_AVScreenCaptureOnVideoBufferAvailable) (OH_AVScreenCapture *capture, bool isReady)

Description

Defines a pointer to a callback function that is called when a video buffer is available during the running of an OH_AVScreenCapture instance.

Parameters

NameDescription
capturePointer to an OH_AVScreenCapture instance.
isReadyWhether the video buffer is available.

System capability

SystemCapability.Multimedia.Media.AVScreenCapture

OH_CaptureMode

typedef enum OH_CaptureModeOH_CaptureMode

Description

Defines an enum that enumerates the screen capture modes.

System capability

SystemCapability.Multimedia.Media.AVScreenCapture

OH_ContainerFormatType

typedef enum OH_ContainerFormatType OH_ContainerFormatType

Description

Defines an enum that enumerates the types of files generated during screen capture.

NOTE

This type is reserved and will be provided in later versions.

System capability

SystemCapability.Multimedia.Media.AVScreenCapture

OH_DataType

typedef enum OH_DataType OH_DataType

Description

Defines an enum that enumerates the data types of screen capture streams.

System capability

SystemCapability.Multimedia.Media.AVScreenCapture

OH_NativeBuffer

typedef struct OH_NativeBuffer OH_NativeBuffer

Description

Defines the native video stream class for screen capture.

System capability

SystemCapability.Multimedia.Media.AVScreenCapture

OH_RecorderInfo

typedef struct OH_RecorderInfo OH_RecorderInfo

Description

Defines recording file information.

System capability

SystemCapability.Multimedia.Media.AVScreenCapture

OH_Rect

typedef struct OH_Rect OH_Rect

Description

Defines the width, height, and image information of the rectangle used for screen capture.

System capability

SystemCapability.Multimedia.Media.AVScreenCapture

OH_VideoCaptureInfo

typedef struct OH_VideoCaptureInfo OH_VideoCaptureInfo

Description

Defines video capture information.

System capability

SystemCapability.Multimedia.Media.AVScreenCapture

OH_VideoCodecFormat

typedef enum OH_VideoCodecFormat OH_VideoCodecFormat

Description

Defines an enum that enumerates the video encoding formats.

System capability

SystemCapability.Multimedia.Media.AVScreenCapture

OH_VideoEncInfo

typedef struct OH_VideoEncInfo OH_VideoEncInfo

Description

Defines video encoding parameters.

NOTE

This type is reserved and will be provided in later versions.

System capability

SystemCapability.Multimedia.Media.AVScreenCapture

OH_VideoInfo

typedef struct OH_VideoInfo OH_VideoInfo

Description

Defines video capture parameters.

System capability

SystemCapability.Multimedia.Media.AVScreenCapture

OH_VideoSourceType

typedef enum OH_VideoSourceType OH_VideoSourceType

Description

Defines an enum that enumerates the video source formats.

System capability

SystemCapability.Multimedia.Media.AVScreenCapture

Enum Description

OH_AudioCaptureSourceType

enum OH_AudioCaptureSourceType

Description

Enumerates the audio source types during screen capture.

System capability

SystemCapability.Multimedia.Media.AVScreenCapture

ValueDescription
OH_SOURCE_INVALIDInvalid audio source.
OH_SOURCE_DEFAULTDefault audio source. The default value is MIC.
OH_MICExternal audio streams recorded by the microphone.
OH_ALL_PLAYBACKAll internal audio streams played by the system.
OH_APP_PLAYBACKInternal audio streams played by a specified application.

OH_AudioCodecFormat

enum OH_AudioCodecFormat

Description

Enumerates the audio encoding formats.

System capability

SystemCapability.Multimedia.Media.AVScreenCapture

ValueDescription
OH_AUDIO_DEFAULTDefault audio encoding format. The default value is AAC_LC.
OH_AAC_LCAAC_LC audio encoding.
OH_AUDIO_CODEC_FORMAT_BUTTInvalid 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

ValueDescription
AV_SCREEN_CAPTURE_ERR_BASEBasic value returned when an API call error occurs.
AV_SCREEN_CAPTURE_ERR_OKOperation successful.
AV_SCREEN_CAPTURE_ERR_NO_MEMORYMemory insufficient.
AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMITOperation not allowed.
AV_SCREEN_CAPTURE_ERR_INVALID_VALInvalid parameter.
AV_SCREEN_CAPTURE_ERR_IOAbnormal input and output streams.
AV_SCREEN_CAPTURE_ERR_TIMEOUTNetwork timeout.
AV_SCREEN_CAPTURE_ERR_UNKNOWNUnknown error.
AV_SCREEN_CAPTURE_ERR_SERVICE_DIEDMedia service terminated.
AV_SCREEN_CAPTURE_ERR_INVALID_STATEUnsupported operation in this state.
AV_SCREEN_CAPTURE_ERR_UNSUPPORTUnsupported interface.
AV_SCREEN_CAPTURE_ERR_EXTEND_STARTUnexpected error.

OH_CaptureMode

enum OH_CaptureMode

Description

Enumerates the screen capture modes.

System capability

SystemCapability.Multimedia.Media.AVScreenCapture

ValueDescription
OH_CAPTURE_HOME_SCREENTo capture the home screen.
OH_CAPTURE_SPECIFIED_SCREENTo capture a specified screen.
NOTE: This value is reserved and will be provided in later versions.
OH_CAPTURE_SPECIFIED_WINDOWTo capture a specified window.
NOTE: This value is reserved and will be provided in later versions.
OH_CAPTURE_INVAILDInvalid mode.

OH_ContainerFormatType

enum OH_ContainerFormatType

Description

Enumerates the types of files generated during screen capture.

NOTE

This enum is reserved and will be provided in later versions.

System capability

SystemCapability.Multimedia.Media.AVScreenCapture

ValueDescription
CFT_MPEG_4AAudio format M4A.
CFT_MPEG_4Video format MP4.

OH_DataType

enum OH_DataType

Description

Enumerates the data types of screen capture streams.

System capability

SystemCapability.Multimedia.Media.AVScreenCapture

ValueDescription
OH_ORIGINAL_STREAMOriginal stream format, such as YUV, RGBA, and PCM.
OH_ENCODED_STREAMEncoded stream format, such as H.264 and AAC.
NOTE: This value is reserved and will be provided in later versions.
OH_CAPTURE_FILEFormat of the recording file. The value can be mp4.
NOTE: This value is reserved and will be provided in later versions.
OH_INVAILDInvalid format.

OH_VideoCodecFormat

enum OH_VideoCodecFormat

Description

Enumerates the video encoding formats.

System capability

SystemCapability.Multimedia.Media.AVScreenCapture

ValueDescription
OH_VIDEO_DEFAULTDefault video encoding format. The default value is H.264.
OH_H264H.264.
OH_H265H.265/HEVC.
OH_MPEG4MPEG4.
OH_VP8VP8.
OH_VP9VP9.
OH_VIDEO_CODEC_FORMAT_BUTTInvalid format.

OH_VideoSourceType

enum OH_VideoSourceType

Description

Enumerates the video source formats.

System capability

SystemCapability.Multimedia.Media.AVScreenCapture

ValueDescription
OH_VIDEO_SOURCE_SURFACE_YUVYUV format.
OH_VIDEO_SOURCE_SURFACE_ESRaw format.
OH_VIDEO_SOURCE_SURFACE_RGBARGBA format.
OH_VIDEO_SOURCE_BUTTInvalid format.

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.

Parameters

NameDescription
capturePointer to an OH_AVScreenCapture instance.
audiobufferPointer 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.
typeType 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.

System capability

SystemCapability.Multimedia.Media.AVScreenCapture

Returns

Returns AV_SCREEN_CAPTURE_ERR_OK if the operation is successful; returns an error code defined in OH_AVSCREEN_CAPTURE_ErrCode otherwise.

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.

Parameters

NameDescription
capturePointer to an OH_AVScreenCapture instance.
fencePointer to parameters for synchronization display.
timestampPointer to the timestamp of the video frame.
regionPointer to the coordinates related to video display.

System capability

SystemCapability.Multimedia.Media.AVScreenCapture

Returns

Returns an OH_NativeBuffer object if the operation is successful. The application can call the APIs provided by the OH_NativeBuffer object to obtain information such as the video buffer and resolution.

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

Returns

Returns the pointer to an OH_AVScreenCapture instance.

OH_AVScreenCapture_Init()

OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_Init (struct OH_AVScreenCapture * capture, OH_AVScreenCaptureConfig config )

Description

Initializes OH_AVScreenCapture parameters, including audio microphone sampling parameters, audio capture parameters (optional), and video resolution parameters.

To call this function, you must configure the ohos.permission.MICROPHONE and ohos.permission.CAPTURE_SCREEN permissions. Otherwise, the initialization fails and screen capture cannot be performed properly.

Parameters

NameDescription
capturePointer to an OH_AVScreenCapture instance.
configParameters related to screen capture initialization.

System capability

SystemCapability.Multimedia.Media.AVScreenCapture

Returns

Returns AV_SCREEN_CAPTURE_ERR_OK if the operation is successful; returns an error code defined in OH_AVSCREEN_CAPTURE_ErrCode otherwise.

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.

Parameters

NameDescription
capturePointer to an OH_AVScreenCapture instance.

System capability

SystemCapability.Multimedia.Media.AVScreenCapture

Returns

Returns AV_SCREEN_CAPTURE_ERR_OK if the operation is successful; returns an error code defined in OH_AVSCREEN_CAPTURE_ErrCode otherwise.

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.

Parameters

NameDescription
capturePointer to an OH_AVScreenCapture instance.
typeType of the audio buffer, which is used to distinguish external streams recorded by the microphone from internal streams played by the system.

System capability

SystemCapability.Multimedia.Media.AVScreenCapture

Returns

Returns AV_SCREEN_CAPTURE_ERR_OK if the operation is successful; returns an error code defined in OH_AVSCREEN_CAPTURE_ErrCode otherwise.

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.

Parameters

NameDescription
capturePointer to an OH_AVScreenCapture instance.

System capability

SystemCapability.Multimedia.Media.AVScreenCapture

Returns

Returns AV_SCREEN_CAPTURE_ERR_OK if the operation is successful; returns an error code defined in OH_AVSCREEN_CAPTURE_ErrCode otherwise.

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.

Parameters

NameDescription
capturePointer to an OH_AVScreenCapture instance.
callbackOH_AVScreenCaptureCallback struct, which stores related callback function pointers.

System capability

SystemCapability.Multimedia.Media.AVScreenCapture

Returns

Returns AV_SCREEN_CAPTURE_ERR_OK if the operation is successful; returns an error code defined in OH_AVSCREEN_CAPTURE_ErrCode otherwise.

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_StartScreenRecording and OH_AVScreenCapture_AcquireAudioBuffer. When isMicrophone is set to false, the obtained audio data is silent data.

Parameters

NameDescription
capturePointer to an OH_AVScreenCapture instance.
isMicrophoneWhether to enable the microphone.

System capability

SystemCapability.Multimedia.Media.AVScreenCapture

Returns

Returns AV_SCREEN_CAPTURE_ERR_OK if the operation is successful; returns an error code defined in OH_AVSCREEN_CAPTURE_ErrCode otherwise.

OH_AVScreenCapture_StartScreenCapture()

OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_StartScreenCapture (struct OH_AVScreenCapture * capture)

Description

Starts screen capture and collects original streams. After calling this function, the application can use the callback listeners OH_AVScreenCaptureOnAudioBufferAvailable and OH_AVScreenCaptureOnVideoBufferAvailable to check whether streams are generated.

The application can obtain the original streams of screen capture by calling OH_AVScreenCapture_AcquireAudioBuffer and OH_AVScreenCapture_ReleaseVideoBuffer.

Parameters

NameDescription
capturePointer to an OH_AVScreenCapture instance.

System capability

SystemCapability.Multimedia.Media.AVScreenCapture

Returns

Returns AV_SCREEN_CAPTURE_ERR_OK if the operation is successful; returns an error code defined in OH_AVSCREEN_CAPTURE_ErrCode otherwise.

OH_AVScreenCapture_StartScreenRecording()

OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_StartScreenRecording (struct OH_AVScreenCapture * capture)

Description

Starts screen recording and collects encoded streams.

NOTE

This function is reserved and will be provided in later versions.

Parameters

NameDescription
capturePointer to an OH_AVScreenCapture instance.

System capability

SystemCapability.Multimedia.Media.AVScreenCapture

Returns

Returns AV_SCREEN_CAPTURE_ERR_OK if the operation is successful; returns an error code defined in OH_AVSCREEN_CAPTURE_ErrCode otherwise.

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.

Parameters

NameDescription
capturePointer to an OH_AVScreenCapture instance.

System capability

SystemCapability.Multimedia.Media.AVScreenCapture

Returns

Returns AV_SCREEN_CAPTURE_ERR_OK if the operation is successful; returns an error code defined in OH_AVSCREEN_CAPTURE_ErrCode otherwise.

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.

NOTE

This function is reserved and will be provided in later versions.

Parameters

NameDescription
capturePointer to an OH_AVScreenCapture instance.

System capability

SystemCapability.Multimedia.Media.AVScreenCapture

Returns

Returns AV_SCREEN_CAPTURE_ERR_OK if the operation is successful; returns an error code defined in OH_AVSCREEN_CAPTURE_ErrCode otherwise.

你可能感兴趣的鸿蒙文章

harmony 鸿蒙Native APIs

harmony 鸿蒙AVCapability

harmony 鸿蒙AVDemuxer

harmony 鸿蒙AVMuxer

harmony 鸿蒙AVSource

harmony 鸿蒙AudioDecoder

harmony 鸿蒙AudioEncoder

harmony 鸿蒙CodecBase

harmony 鸿蒙Core

harmony 鸿蒙Drawing

  • 所属分类: 后端技术
  • 本文标签: 软件 鸿蒙
  • 版权声明: 本文链接 https://seaxiang.com/blog/50f14a2dc0dd48edb7e7a5d5cbe5bb6d