openharmony 鸿蒙 capi-preview-output-h

2026-08-25 浏览 (1)

preview_output.h

Overview

The file declares the preview output concepts.

File to include: <ohcamera/preview_output.h>

Library: libohcamera.so

System capability: SystemCapability.Multimedia.Camera.Core

Since: 11

Related module: OH_Camera

Summary

Structs

Nametypedef KeywordDescription
PreviewOutput_CallbacksPreviewOutput_CallbacksDescribes the callbacks related to preview output.
Camera_PreviewOutputCamera_PreviewOutputDescribes the preview output object.
You can use OH_CameraManager_CreatePreviewOutput to create such an object.

Functions

Nametypedef KeywordDescription
typedef void (*OH_PreviewOutput_OnFrameStart)(Camera_PreviewOutput* previewOutput)OH_PreviewOutput_OnFrameStartDefines the callback defined in the PreviewOutput_Callbacks struct and used to report preview output frame start events.
typedef void (*OH_PreviewOutput_OnFrameEnd)(Camera_PreviewOutput* previewOutput, int32_t frameCount)OH_PreviewOutput_OnFrameEndDefines the callback defined in the PreviewOutput_Callbacks struct and used to report preview output frame end events.
typedef void (*OH_PreviewOutput_OnError)(Camera_PreviewOutput* previewOutput, Camera_ErrorCode errorCode)OH_PreviewOutput_OnErrorDefines the callback defined in the PreviewOutput_Callbacks struct and used to report preview output errors.
Camera_ErrorCode OH_PreviewOutput_RegisterCallback(Camera_PreviewOutput* previewOutput, PreviewOutput_Callbacks* callback)-Registers a callback to listen for preview output events.
Camera_ErrorCode OH_PreviewOutput_UnregisterCallback(Camera_PreviewOutput* previewOutput, PreviewOutput_Callbacks* callback)-Unregisters the callback used to listen for preview output events.
Camera_ErrorCode OH_PreviewOutput_Start(Camera_PreviewOutput* previewOutput)-Starts preview output.
Camera_ErrorCode OH_PreviewOutput_Stop(Camera_PreviewOutput* previewOutput)-Stops preview output.
Camera_ErrorCode OH_PreviewOutput_Release(Camera_PreviewOutput* previewOutput)-Releases a PreviewOutput instance.
Camera_ErrorCode OH_PreviewOutput_GetActiveProfile(Camera_PreviewOutput* previewOutput, Camera_Profile** profile)-Obtains the profile of a PreviewOutput instance.
Camera_ErrorCode OH_PreviewOutput_DeleteProfile(Camera_Profile* profile)-Deletes the profile of a PreviewOutput instance.
Camera_ErrorCode OH_PreviewOutput_GetPreviewRotation(Camera_PreviewOutput* previewOutput, int displayRotation, Camera_ImageRotation* imageRotation)-Obtains the preview rotation angle.
Camera_ErrorCode OH_PreviewOutput_GetPreviewRotationWithoutDisplayRotation(Camera_PreviewOutput* previewOutput, Camera_ImageRotation* imageRotation)-Obtains the preview rotation angle.
Camera_ErrorCode OH_PreviewOutput_SetPreviewRotation(Camera_PreviewOutput* previewOutput, Camera_ImageRotation previewRotation, bool isDisplayLocked)-Sets the preview rotation angle.
Camera_ErrorCode OH_PreviewOutput_GetSupportedFrameRates(Camera_PreviewOutput* previewOutput, Camera_FrameRateRange** frameRateRange, uint32_t* size)-Obtains the list of frame rates supported by a PreviewOutput instance.
Camera_ErrorCode OH_PreviewOutput_DeleteFrameRates(Camera_PreviewOutput* previewOutput, Camera_FrameRateRange* frameRateRange)-Deletes the frame rate list.
Camera_ErrorCode OH_PreviewOutput_SetFrameRate(Camera_PreviewOutput* previewOutput, int32_t minFps, int32_t maxFps)-Sets the frame rates for a PreviewOutput instance.
Camera_ErrorCode OH_PreviewOutput_GetActiveFrameRate(Camera_PreviewOutput* previewOutput, Camera_FrameRateRange* frameRateRange)-Obtains the active frame rates of a PreviewOutput instance.
Camera_ErrorCode OH_PreviewOutput_IsBandwidthCompressionSupported(Camera_PreviewOutput* previewOutput, bool* isSupported)-Checks whether preview bandwidth compression is supported. This involves reducing data volume through encoding to minimize bandwidth usage during transmission.
Camera_ErrorCode OH_PreviewOutput_EnableBandwidthCompression(Camera_PreviewOutput* previewOutput, bool enabled)-Enables preview bandwidth compression.
This function must be called prior to OH_CaptureSession_CommitConfig(). Otherwise, the preview output stream format will be affected.
Camera_ErrorCode OH_PreviewOutput_AddDeferredSurface(const Camera_PreviewOutput* previewOutput, const char* surfaceId)-Adds a surface for delayed preview.

Function Description

OH_PreviewOutput_OnFrameStart()

typedef void (*OH_PreviewOutput_OnFrameStart)(Camera_PreviewOutput* previewOutput)

Description

Defines the callback defined in the PreviewOutput_Callbacks struct and used to report preview output frame start events.

Since: 11

Parameters

NameDescription
Camera_PreviewOutput* previewOutputPointer to the PreviewOutput instance that transfers the callback.

OH_PreviewOutput_OnFrameEnd()

typedef void (*OH_PreviewOutput_OnFrameEnd)(Camera_PreviewOutput* previewOutput, int32_t frameCount)

Description

Defines the callback defined in the PreviewOutput_Callbacks struct and used to report preview output frame end events.

Since: 11

Parameters

NameDescription
Camera_PreviewOutput* previewOutputPointer to the PreviewOutput instance that transfers the callback.
int32_t frameCountNumber of frames to be included in the callback.

OH_PreviewOutput_OnError()

typedef void (*OH_PreviewOutput_OnError)(Camera_PreviewOutput* previewOutput, Camera_ErrorCode errorCode)

Description

Defines the callback defined in the PreviewOutput_Callbacks struct and used to report preview output errors.

Since: 11

Parameters

NameDescription
Camera_PreviewOutput* previewOutputPointer to the PreviewOutput instance that transfers the callback.
Camera_ErrorCode errorCodeError code reported during preview output.

See also

CAMERA_SERVICE_FATAL_ERROR

OH_PreviewOutput_RegisterCallback()

Camera_ErrorCode OH_PreviewOutput_RegisterCallback(Camera_PreviewOutput* previewOutput, PreviewOutput_Callbacks* callback)

Description

Registers a callback to listen for preview output events.

Since: 11

Parameters

NameDescription
Camera_PreviewOutput* previewOutputPointer to the target PreviewOutput instance.
PreviewOutput_Callbacks* callbackPointer to the target callback.

Returns

TypeDescription
Camera_ErrorCodeCAMERA_OK: The operation is successful.
CAMERA_INVALID_ARGUMENT: A parameter is missing or the parameter type is incorrect.

OH_PreviewOutput_UnregisterCallback()

Camera_ErrorCode OH_PreviewOutput_UnregisterCallback(Camera_PreviewOutput* previewOutput, PreviewOutput_Callbacks* callback)

Description

Unregisters the callback used to listen for preview output events.

Since: 11

Parameters

NameDescription
Camera_PreviewOutput* previewOutputPointer to the target PreviewOutput instance.
PreviewOutput_Callbacks* callbackPointer to the target callback.

Returns

TypeDescription
Camera_ErrorCodeCAMERA_OK: The operation is successful.
CAMERA_INVALID_ARGUMENT: A parameter is missing or the parameter type is incorrect.

OH_PreviewOutput_Start()

Camera_ErrorCode OH_PreviewOutput_Start(Camera_PreviewOutput* previewOutput)

Description

Starts preview output.

Since: 11

Parameters

NameDescription
Camera_PreviewOutput* previewOutputPointer to the PreviewOutput instance to start.

Returns

TypeDescription
Camera_ErrorCodeCAMERA_OK: The operation is successful.
CAMERA_INVALID_ARGUMENT: A parameter is missing or the parameter type is incorrect.
CAMERA_SESSION_NOT_CONFIG: The capture session is not configured.
CAMERA_SERVICE_FATAL_ERROR: The camera service is abnormal.

OH_PreviewOutput_Stop()

Camera_ErrorCode OH_PreviewOutput_Stop(Camera_PreviewOutput* previewOutput)

Description

Stops preview output.

Since: 11

Parameters

NameDescription
Camera_PreviewOutput* previewOutputPointer to the PreviewOutput instance to stop.

Returns

TypeDescription
Camera_ErrorCodeCAMERA_OK: The operation is successful.
CAMERA_INVALID_ARGUMENT: A parameter is missing or the parameter type is incorrect.
CAMERA_SERVICE_FATAL_ERROR: The camera service is abnormal.

OH_PreviewOutput_Release()

Camera_ErrorCode OH_PreviewOutput_Release(Camera_PreviewOutput* previewOutput)

Description

Releases a PreviewOutput instance.

Since: 11

Parameters

NameDescription
Camera_PreviewOutput* previewOutputPointer to the PreviewOutput instance to release.

Returns

TypeDescription
Camera_ErrorCodeCAMERA_OK: The operation is successful.
CAMERA_INVALID_ARGUMENT: A parameter is missing or the parameter type is incorrect.
CAMERA_SERVICE_FATAL_ERROR: The camera service is abnormal.

OH_PreviewOutput_GetActiveProfile()

Camera_ErrorCode OH_PreviewOutput_GetActiveProfile(Camera_PreviewOutput* previewOutput, Camera_Profile** profile)

Description

Obtains the profile of a PreviewOutput instance.

Since: 12

Parameters

NameDescription
Camera_PreviewOutput* previewOutputPointer to the PreviewOutput instance for which the profile is to be obtained.
Camera_Profile** profileDouble pointer to the preview output profile obtained.

Returns

TypeDescription
Camera_ErrorCodeCAMERA_OK: The operation is successful.
CAMERA_INVALID_ARGUMENT: A parameter is missing or the parameter type is incorrect.
CAMERA_SERVICE_FATAL_ERROR: The camera service is abnormal.

OH_PreviewOutput_DeleteProfile()

Camera_ErrorCode OH_PreviewOutput_DeleteProfile(Camera_Profile* profile)

Description

Deletes the profile of a PreviewOutput instance.

Since: 12

Parameters

NameDescription
Camera_Profile* profilePointer to the profile to delete.

Returns

TypeDescription
Camera_ErrorCodeCAMERA_OK: The operation is successful.
CAMERA_INVALID_ARGUMENT: A parameter is missing or the parameter type is incorrect.

OH_PreviewOutput_GetPreviewRotation()

Camera_ErrorCode OH_PreviewOutput_GetPreviewRotation(Camera_PreviewOutput* previewOutput, int displayRotation, Camera_ImageRotation* imageRotation)

Description

Obtains the preview rotation angle.

Since: 12

Parameters

NameDescription
Camera_PreviewOutput* previewOutputPointer to the PreviewOutput instance used to obtain the rotation angle.
int displayRotationRotation angle of the display.
Camera_ImageRotation* imageRotationPointer to the preview rotation angle.

Returns

TypeDescription
Camera_ErrorCodeCAMERA_OK: The operation is successful.
CAMERA_INVALID_ARGUMENT: A parameter is missing or the parameter type is incorrect.
CAMERA_SERVICE_FATAL_ERROR: The camera service is abnormal.

OH_PreviewOutput_GetPreviewRotationWithoutDisplayRotation()

Camera_ErrorCode OH_PreviewOutput_GetPreviewRotationWithoutDisplayRotation(Camera_PreviewOutput* previewOutput, Camera_ImageRotation* imageRotation)

Description

Obtains the preview rotation angle.

Since: 23

Parameters

NameDescription
Camera_PreviewOutput* previewOutputPointer to the PreviewOutput instance used to obtain the rotation angle.
Camera_ImageRotation* imageRotationPointer to the preview rotation angle.

Returns

TypeDescription
Camera_ErrorCodeCAMERA_OK: The operation is successful.
CAMERA_INVALID_ARGUMENT: A parameter is missing or the parameter type is incorrect.
CAMERA_SERVICE_FATAL_ERROR: The camera service is abnormal.

OH_PreviewOutput_SetPreviewRotation()

Camera_ErrorCode OH_PreviewOutput_SetPreviewRotation(Camera_PreviewOutput* previewOutput, Camera_ImageRotation previewRotation, bool isDisplayLocked)

Description

Sets the preview rotation angle.

Since: 12

Parameters

NameDescription
Camera_PreviewOutput* previewOutputPointer to the PreviewOutput instance used to set the rotation angle.
Camera_ImageRotation previewRotationPreview rotation angle.
bool isDisplayLockedWhether the orientation of the surface is locked when the screen rotates. If this parameter is not set, the default value false is used, indicating that the orientation is not locked. true if locked, false otherwise. For details, see SurfaceRotationOptions.

Returns

TypeDescription
Camera_ErrorCodeCAMERA_OK: The operation is successful.
CAMERA_INVALID_ARGUMENT: A parameter is missing or the parameter type is incorrect.
CAMERA_SERVICE_FATAL_ERROR: The camera service is abnormal.

OH_PreviewOutput_GetSupportedFrameRates()

Camera_ErrorCode OH_PreviewOutput_GetSupportedFrameRates(Camera_PreviewOutput* previewOutput, Camera_FrameRateRange** frameRateRange, uint32_t* size)

Description

Obtains the list of frame rates supported by a PreviewOutput instance.

Since: 12

Parameters

NameDescription
Camera_PreviewOutput* previewOutputPointer to the PreviewOutput instance used to obtain the frame rates.
Camera_FrameRateRange** frameRateRangeDouble pointer to the list of frame rates, if the function is successfully called.
uint32_t* sizePointer to the size of the list of frame rates.

Returns

TypeDescription
Camera_ErrorCodeCAMERA_OK: The operation is successful.
CAMERA_INVALID_ARGUMENT: A parameter is missing or the parameter type is incorrect.
CAMERA_SERVICE_FATAL_ERROR: The camera service is abnormal.

OH_PreviewOutput_DeleteFrameRates()

Camera_ErrorCode OH_PreviewOutput_DeleteFrameRates(Camera_PreviewOutput* previewOutput, Camera_FrameRateRange* frameRateRange)

Description

Deletes the frame rate list.

Since: 12

Parameters

NameDescription
Camera_PreviewOutput* previewOutputPointer to the target PreviewOutput instance.
Camera_FrameRateRange* frameRateRangePointer to the list of frame rates to delete.

Returns

TypeDescription
Camera_ErrorCodeCAMERA_OK: The operation is successful.
CAMERA_INVALID_ARGUMENT: A parameter is missing or the parameter type is incorrect.

OH_PreviewOutput_SetFrameRate()

Camera_ErrorCode OH_PreviewOutput_SetFrameRate(Camera_PreviewOutput* previewOutput, int32_t minFps, int32_t maxFps)

Description

Sets the frame rates for a PreviewOutput instance.

Since: 12

Parameters

NameDescription
Camera_PreviewOutput* previewOutputPointer to the PreviewOutput instance used to set the frame rates.
int32_t minFpsMinimum frame rate.
int32_t maxFpsMaximum frame rate.

Returns

TypeDescription
Camera_ErrorCodeCAMERA_OK: The operation is successful.
CAMERA_INVALID_ARGUMENT: A parameter is missing or the parameter type is incorrect.

OH_PreviewOutput_GetActiveFrameRate()

Camera_ErrorCode OH_PreviewOutput_GetActiveFrameRate(Camera_PreviewOutput* previewOutput, Camera_FrameRateRange* frameRateRange)

Description

Obtains the active frame rates of a PreviewOutput instance.

Since: 12

Parameters

NameDescription
Camera_PreviewOutput* previewOutputPointer to the PreviewOutput instance used to obtain the active frame rates.
Camera_FrameRateRange* frameRateRangePointer to the frame rate range, which is defined in the Camera_FrameRateRange struct, if the function is successfully called.

Returns

TypeDescription
Camera_ErrorCodeCAMERA_OK: The operation is successful.
CAMERA_INVALID_ARGUMENT: A parameter is missing or the parameter type is incorrect.
CAMERA_SERVICE_FATAL_ERROR: The camera service is abnormal.

OH_PreviewOutput_IsBandwidthCompressionSupported()

Camera_ErrorCode OH_PreviewOutput_IsBandwidthCompressionSupported(Camera_PreviewOutput* previewOutput, bool* isSupported)

Description

Checks whether preview bandwidth compression is supported. This involves reducing data volume through encoding to minimize bandwidth usage during transmission.

Since: 23

Parameters

NameDescription
Camera_PreviewOutput* previewOutputPointer to the target PreviewOutput instance.
bool* isSupportedPointer to the check result for the support of bandwidth compression. true if supported, false otherwise.

Returns

TypeDescription
Camera_ErrorCodeCAMERA_OK: The operation is successful.
CAMERA_INVALID_ARGUMENT: A parameter is missing or the parameter type is incorrect.
CAMERA_SERVICE_FATAL_ERROR: The camera service is abnormal.

OH_PreviewOutput_EnableBandwidthCompression()

Camera_ErrorCode OH_PreviewOutput_EnableBandwidthCompression(Camera_PreviewOutput* previewOutput, bool enabled)

Description

Enables preview bandwidth compression.
This function must be called prior to OH_CaptureSession_CommitConfig(). Otherwise, the preview output stream format will be affected.

Since: 23

Parameters

NameDescription
Camera_PreviewOutput* previewOutputPointer to the target PreviewOutput instance.
bool enabledWhether to enable preview bandwidth compression. true to enable, false otherwise.

Returns

TypeDescription
Camera_ErrorCodeCAMERA_OK: The operation is successful.
CAMERA_OPERATION_NOT_ALLOWED: The operation is not allowed.
CAMERA_INVALID_ARGUMENT: A parameter is missing or the parameter type is incorrect.
CAMERA_SESSION_NOT_CONFIG: The camera session is not configured.
CAMERA_SERVICE_FATAL_ERROR: The camera service is abnormal.

OH_PreviewOutput_AddDeferredSurface()

Camera_ErrorCode OH_PreviewOutput_AddDeferredSurface(const Camera_PreviewOutput* previewOutput, const char* surfaceId)

Description

Adds a surface for delayed preview.

Since: 24

Parameters

NameDescription
const Camera_PreviewOutput* previewOutputPointer to the PreviewOutput instance of the surface ID to add.
const char* surfaceIdPointer to the surface ID used for creating the Camera_PreviewOutput instance.

Returns

TypeDescription
Camera_ErrorCodeCAMERA_OK: The operation is successful.
CAMERA_INVALID_ARGUMENT: A parameter is missing or the parameter type is incorrect.

你可能感兴趣的鸿蒙文章

openharmony 鸿蒙 capi-oh-camera-capturesession-callbacks

openharmony 鸿蒙 arkts-apis-camera-OIS

openharmony 鸿蒙 capi-oh-camera-camera-devicequeryinfo

openharmony 鸿蒙 capi-oh-camera-camera-frameraterange

openharmony 鸿蒙 capi-oh-camera-camera-outputcapability

openharmony 鸿蒙 arkts-apis-camera-Photo

openharmony 鸿蒙 capi-oh-camera-camera-profile

openharmony 鸿蒙 capi-oh-camera-camera-manager

openharmony 鸿蒙 capi-oh-camera-previewoutput-callbacks

openharmony 鸿蒙 arkts-apis-camera-ManualExposureQuery

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