openharmony 鸿蒙 capi-native-avscreen-capture-base-h

2025-06-12 浏览 (1)

native_avscreen_capture_base.h

Overview

The native_avscreen_capture_base.h file declares the common structs, character constants, and enums used for running screen capture.

Library: libnative_avscreen_capture.so

System capability: SystemCapability.Multimedia.Media.AVScreenCapture

Since: 10

Related module: AVScreenCapture

Summary

Structs

Nametypedef KeywordDescription
OH_AudioCaptureInfoOH_AudioCaptureInfoDescribes the audio capture information.
When both audioSampleRate and audioChannels are 0, the audio-related parameters are ignored and the audio data is not recorded.
OH_NativeBufferOH_NativeBufferDescribes the native video stream class for screen capture.
OH_AVScreenCaptureOH_AVScreenCaptureDescribes a screen capture instance used to obtain original video and audio streams.
OH_AVScreenCapture_ContentFilterOH_AVScreenCapture_ContentFilterDescribes the filter used to filter audio and video content.
OH_AVScreenCapture_CaptureStrategyOH_AVScreenCapture_CaptureStrategyDescribes the screen capture strategy configured by using OH_AVScreenCapture_CaptureStrategy.
OH_AudioEncInfoOH_AudioEncInfoDescribes the audio encoding information.
OH_AudioInfoOH_AudioInfoDescribes the audio information.
To perform both external capture (using microphones) and internal capture, audioSampleRate and audioChannels must be the same for both audio channels.
OH_VideoCaptureInfoOH_VideoCaptureInfoDescribes the video capture information. When videoFrameWidth and videoFrameHeight are both 0, video-related parameters are ignored and screen data is not recorded.
OH_VideoEncInfoOH_VideoEncInfoDescribes the video encoding information.
OH_VideoInfoOH_VideoInfoDescribes the video information.
OH_RecorderInfoOH_RecorderInfoDescribes the recording file information.
OH_AVScreenCaptureConfigOH_AVScreenCaptureConfigDescribes the screen capture configuration.
OH_AVScreenCaptureCallbackOH_AVScreenCaptureCallbackDefines 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.
OH_RectOH_RectDescribes the width, height, and image information of the rectangle used for screen capture.
OH_AudioBufferOH_AudioBufferDescribes the configuration such as the size, type, and timestamp of audio data.

Enums

Nametypedef KeywordDescription
OH_CaptureModeOH_CaptureModeEnumerates the screen capture modes.
OH_AudioCaptureSourceTypeOH_AudioCaptureSourceTypeEnumerates the audio source types during screen capture.
OH_AudioCodecFormatOH_AudioCodecFormatEnumerates the audio encoding formats.
OH_VideoCodecFormatOH_VideoCodecFormatEnumerates the video encoding formats.
OH_DataTypeOH_DataTypeEnumerates the data types of screen capture streams.
OH_VideoSourceTypeOH_VideoSourceTypeEnumerates the video source formats.
OH_ContainerFormatTypeOH_ContainerFormatTypeEnumerates the types of files generated during screen capture.
OH_AVScreenCaptureStateCodeOH_AVScreenCaptureStateCodeEnumerates the screen capture states.
OH_AVScreenCaptureBufferTypeOH_AVScreenCaptureBufferTypeEnumerates the buffer types.
OH_AVScreenCaptureFilterableAudioContentOH_AVScreenCaptureFilterableAudioContentEnumerates the types of audio that can be added to a content filter.
OH_AVScreenCaptureContentChangedEventOH_AVScreenCaptureContentChangedEventEnumerates the screen capture content change events.

Functions

Nametypedef KeywordDescription
typedef void (*OH_AVScreenCaptureOnError)(OH_AVScreenCapture *capture, int32_t errorCode)OH_AVScreenCaptureOnErrorCalled when an error occurs during the running of an OH_AVScreenCapture instance.
typedef void (*OH_AVScreenCaptureOnAudioBufferAvailable)(OH_AVScreenCapture *capture, bool isReady,OH_AudioCaptureSourceType type)OH_AVScreenCaptureOnAudioBufferAvailableCalled when an audio buffer is available during the running of an OH_AVScreenCapture instance.
typedef void (*OH_AVScreenCaptureOnVideoBufferAvailable)(OH_AVScreenCapture *capture, bool isReady)OH_AVScreenCaptureOnVideoBufferAvailableCalled when a video buffer is available during the running of an OH_AVScreenCapture instance.
typedef void (*OH_AVScreenCapture_OnStateChange)(struct OH_AVScreenCapture *capture,OH_AVScreenCaptureStateCode stateCode, void *userData)OH_AVScreenCapture_OnStateChangeCalled 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)OH_AVScreenCapture_OnErrorCalled 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)OH_AVScreenCapture_OnBufferAvailableCalled when an audio buffer or a video buffer is available during the running of an OH_AVScreenCapture instance.
typedef void (*OH_AVScreenCapture_OnDisplaySelected)(OH_AVScreenCapture *capture, uint64_t displayId, void *userData)OH_AVScreenCapture_OnDisplaySelectedCalled when screen capture starts.
typedef void (*OH_AVScreenCapture_OnCaptureContentChanged)(OH_AVScreenCapture* capture,OH_AVScreenCaptureContentChangedEvent event, OH_Rect* area, void *userData)OH_AVScreenCapture_OnCaptureContentChangedCalled when the screen capture content changes.

Enum Description

OH_CaptureMode

enum OH_CaptureMode

Description

Enumerates the screen capture modes.

System capability: SystemCapability.Multimedia.Media.AVScreenCapture

Since: 10

Enum ItemDescription
OH_CAPTURE_HOME_SCREEN = 0Captures the home screen.
OH_CAPTURE_SPECIFIED_SCREEN = 1Captures a specified screen.
OH_CAPTURE_SPECIFIED_WINDOW = 2Captures a specified window.
OH_CAPTURE_INVAILD = -1Invalid mode.

OH_AudioCaptureSourceType

enum OH_AudioCaptureSourceType

Description

Enumerates the audio source types during screen capture.

System capability: SystemCapability.Multimedia.Media.AVScreenCapture

Since: 10

Enum ItemDescription
OH_SOURCE_INVALID = -1Invalid audio source.
OH_SOURCE_DEFAULT = 0Default audio source. The default value is OH_MIC.
OH_MIC = 1External audio streams recorded by the microphone.
OH_ALL_PLAYBACK = 2All internal audio streams played by the system.
OH_APP_PLAYBACK = 3Internal 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

Enum ItemDescription
OH_AUDIO_DEFAULT = 0Default audio encoding format. The default value is AAC_LC.
OH_AAC_LC = 3AAC_LC audio encoding.
OH_AUDIO_CODEC_FORMAT_BUTTInvalid format.

OH_VideoCodecFormat

enum OH_VideoCodecFormat

Description

Enumerates the video encoding formats.

System capability: SystemCapability.Multimedia.Media.AVScreenCapture

Since: 10

Enum ItemDescription
OH_VIDEO_DEFAULT = 0Default video encoding format. The default value is H.264.
OH_H264 = 2H.264.
OH_H265 = 4H.265/HEVC.
OH_MPEG4 = 6MPEG4.
OH_VP8 = 8VP8.
OH_VP9 = 10VP9.
OH_VIDEO_CODEC_FORMAT_BUTTInvalid format.

OH_DataType

enum OH_DataType

Description

Enumerates the data types of screen capture streams.

System capability: SystemCapability.Multimedia.Media.AVScreenCapture

Since: 10

Enum ItemDescription
OH_ORIGINAL_STREAM = 0Original stream format, such as YUV, RGBA, and PCM.
OH_ENCODED_STREAM = 1Encoded stream format, such as H.264 and AAC. This value is not supported yet.
OH_CAPTURE_FILE = 2Format of the recording file. The value can be mp4.
OH_INVAILD = -1Invalid 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

Enum ItemDescription
OH_VIDEO_SOURCE_SURFACE_YUV = 0YUV format. This value is not supported yet.
OH_VIDEO_SOURCE_SURFACE_ESRaw format. This value is not supported yet.
OH_VIDEO_SOURCE_SURFACE_RGBARGBA format.
OH_VIDEO_SOURCE_BUTTInvalid format.

OH_ContainerFormatType

enum OH_ContainerFormatType

Description

Enumerates the types of files generated during screen capture.

System capability: SystemCapability.Multimedia.Media.AVScreenCapture

Since: 10

Enum ItemDescription
CFT_MPEG_4A = 0Audio format M4A.
CFT_MPEG_4 = 1Video format MP4.

OH_AVScreenCaptureStateCode

enum OH_AVScreenCaptureStateCode

Description

Enumerates the screen capture states.

System capability: SystemCapability.Multimedia.Media.AVScreenCapture

Since: 12

Enum ItemDescription
OH_SCREEN_CAPTURE_STATE_STARTED = 0Screen capture is started.
OH_SCREEN_CAPTURE_STATE_CANCELED = 1Screen capture is canceled.
OH_SCREEN_CAPTURE_STATE_STOPPED_BY_USER = 2Screen capture is stopped.
OH_SCREEN_CAPTURE_STATE_INTERRUPTED_BY_OTHER = 3Screen capture is interrupted by another screen capture.
OH_SCREEN_CAPTURE_STATE_STOPPED_BY_CALL = 4Screen capture is interrupted by a call.
OH_SCREEN_CAPTURE_STATE_MIC_UNAVAILABLE = 5The microphone is unavailable.
OH_SCREEN_CAPTURE_STATE_MIC_MUTED_BY_USER = 6The microphone is muted.
OH_SCREEN_CAPTURE_STATE_MIC_UNMUTED_BY_USER = 7The microphone is unmuted.
OH_SCREEN_CAPTURE_STATE_ENTER_PRIVATE_SCENE = 8The system enters a privacy screen.
OH_SCREEN_CAPTURE_STATE_EXIT_PRIVATE_SCENE = 9The system exits a privacy screen.
OH_SCREEN_CAPTURE_STATE_STOPPED_BY_USER_SWITCHES = 10Screen capture is interrupted by system user switching.

OH_AVScreenCaptureBufferType

enum OH_AVScreenCaptureBufferType

Description

Enumerates the buffer types.

System capability: SystemCapability.Multimedia.Media.AVScreenCapture

Since: 12

Enum ItemDescription
OH_SCREEN_CAPTURE_BUFFERTYPE_VIDEO = 0Video data.
OH_SCREEN_CAPTURE_BUFFERTYPE_AUDIO_INNER = 1Internal audio capture data.
OH_SCREEN_CAPTURE_BUFFERTYPE_AUDIO_MIC = 2Microphone 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

Enum ItemDescription
OH_SCREEN_CAPTURE_NOTIFICATION_AUDIO = 0Notification tone.
OH_SCREEN_CAPTURE_CURRENT_APP_AUDIO = 1Sound of the application itself.

OH_AVScreenCaptureContentChangedEvent

enum OH_AVScreenCaptureContentChangedEvent

Description

Enumerates the screen capture content change events.

System capability: SystemCapability.Multimedia.Media.AVScreenCapture

Since: 20

Enum ItemDescription
OH_SCREEN_CAPTURE_CONTENT_HIDE = 0The screen capture content is hidden.
OH_SCREEN_CAPTURE_CONTENT_VISIBLE = 1The screen capture content is visible.
OH_SCREEN_CAPTURE_CONTENT_UNAVAILABLE = 2The screen capture content becomes unavailable. For example, the screen capture window is closed.

Function Description

OH_AVScreenCaptureOnError()

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

Description

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

ParameterDescription
OH_AVScreenCapture *capturePointer to the OH_AVScreenCapture instance.
int32_t errorCodeError code.

OH_AVScreenCaptureOnAudioBufferAvailable()

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

Description

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

ParameterDescription
OH_AVScreenCapture *capturePointer to the OH_AVScreenCapture instance.
bool isReadyWhether the audio buffer is available.
OH_AudioCaptureSourceType typeAudio source type.

OH_AVScreenCaptureOnVideoBufferAvailable()

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

Description

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

ParameterDescription
OH_AVScreenCapture *capturePointer to the OH_AVScreenCapture instance.
bool isReadyWhether the video buffer is available.

OH_AVScreenCapture_OnStateChange()

typedef void (*OH_AVScreenCapture_OnStateChange)(struct OH_AVScreenCapture *capture,OH_AVScreenCaptureStateCode stateCode, void *userData)

Description

Called when the state changes during the running of an OH_AVScreenCapture instance.

System capability: SystemCapability.Multimedia.Media.AVScreenCapture

Since: 12

Parameters

ParameterDescription
struct OH_AVScreenCapture *capturePointer to the OH_AVScreenCapture instance.
OH_AVScreenCaptureStateCode stateCodeStatus code.
void *userDataPointer 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

Called when an error occurs during the running of an OH_AVScreenCapture instance.

System capability: SystemCapability.Multimedia.Media.AVScreenCapture

Since: 12

Parameters

ParameterDescription
OH_AVScreenCapture *capturePointer to the OH_AVScreenCapture instance.
int32_t errorCodeError code.
void *userDataPointer to the user-defined data carried in the function.

OH_AVScreenCapture_OnBufferAvailable()

typedef void (*OH_AVScreenCapture_OnBufferAvailable)(OH_AVScreenCapture *capture, OH_AVBuffer *buffer,OH_AVScreenCaptureBufferType bufferType, int64_t timestamp, void *userData)

Description

Called when an audio buffer or a video buffer is available during the running of an OH_AVScreenCapture instance.

System capability: SystemCapability.Multimedia.Media.AVScreenCapture

Since: 12

Parameters

ParameterDescription
OH_AVScreenCapture *capturePointer to the OH_AVScreenCapture instance.
OH_AVBuffer *bufferPointer to the OH_AVBuffer instance. After the callback is triggered, the buffer is no longer valid.
OH_AVScreenCaptureBufferType bufferTypeType of the buffer.
int64_t timestampTimestamp, in nanoseconds.
void *userDataPointer 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

Called when screen capture starts.

System capability: SystemCapability.Multimedia.Media.AVScreenCapture

Since: 15

Parameters

ParameterDescription
OH_AVScreenCapture *capturePointer to the OH_AVScreenCapture instance.
uint64_t displayIdID of the screen to capture.
void *userDataPointer 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

Called when the screen capture content changes during the running of an OH_AVScreenCapture instance.

System capability: SystemCapability.Multimedia.Media.AVScreenCapture

Since: 20

Parameters

ParameterDescription
OH_AVScreenCapture* capturePointer to the OH_AVScreenCapture instance.
OH_AVScreenCaptureContentChangedEvent eventScreen capture content change event.
OH_Rect* areaPointer to the area information when the screen capture content is visible.
void *userDataPointer to the user-defined data carried in the function.

你可能感兴趣的鸿蒙文章

harmony 鸿蒙Media Kit

harmony 鸿蒙AVImageGenerator

harmony 鸿蒙AVMetadataExtractor

harmony 鸿蒙AVPlayer

harmony 鸿蒙AVPlayerCallback

harmony 鸿蒙AVRecorder

harmony 鸿蒙AVScreenCapture

harmony 鸿蒙OH_AVRecorder_Config

harmony 鸿蒙OH_AVRecorder_EncoderInfo

harmony 鸿蒙OH_AVRecorder_Location

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