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
| Name | typedef Keyword | Description |
|---|---|---|
| PreviewOutput_Callbacks | PreviewOutput_Callbacks | Describes the callbacks related to preview output. |
| Camera_PreviewOutput | Camera_PreviewOutput | Describes the preview output object. You can use OH_CameraManager_CreatePreviewOutput to create such an object. |
Functions
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
| Name | Description |
|---|---|
| Camera_PreviewOutput* previewOutput | Pointer 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
| Name | Description |
|---|---|
| Camera_PreviewOutput* previewOutput | Pointer to the PreviewOutput instance that transfers the callback. |
| int32_t frameCount | Number 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
| Name | Description |
|---|---|
| Camera_PreviewOutput* previewOutput | Pointer to the PreviewOutput instance that transfers the callback. |
| Camera_ErrorCode errorCode | Error code reported during preview output. |
See also
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
| Name | Description |
|---|---|
| Camera_PreviewOutput* previewOutput | Pointer to the target PreviewOutput instance. |
| PreviewOutput_Callbacks* callback | Pointer to the target callback. |
Returns
| Type | Description |
|---|---|
| Camera_ErrorCode | CAMERA_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
| Name | Description |
|---|---|
| Camera_PreviewOutput* previewOutput | Pointer to the target PreviewOutput instance. |
| PreviewOutput_Callbacks* callback | Pointer to the target callback. |
Returns
| Type | Description |
|---|---|
| Camera_ErrorCode | CAMERA_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
| Name | Description |
|---|---|
| Camera_PreviewOutput* previewOutput | Pointer to the PreviewOutput instance to start. |
Returns
| Type | Description |
|---|---|
| Camera_ErrorCode | CAMERA_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
| Name | Description |
|---|---|
| Camera_PreviewOutput* previewOutput | Pointer to the PreviewOutput instance to stop. |
Returns
| Type | Description |
|---|---|
| Camera_ErrorCode | CAMERA_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
| Name | Description |
|---|---|
| Camera_PreviewOutput* previewOutput | Pointer to the PreviewOutput instance to release. |
Returns
| Type | Description |
|---|---|
| Camera_ErrorCode | CAMERA_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
| Name | Description |
|---|---|
| Camera_PreviewOutput* previewOutput | Pointer to the PreviewOutput instance for which the profile is to be obtained. |
| Camera_Profile** profile | Double pointer to the preview output profile obtained. |
Returns
| Type | Description |
|---|---|
| Camera_ErrorCode | CAMERA_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
| Name | Description |
|---|---|
| Camera_Profile* profile | Pointer to the profile to delete. |
Returns
| Type | Description |
|---|---|
| Camera_ErrorCode | CAMERA_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
| Name | Description |
|---|---|
| Camera_PreviewOutput* previewOutput | Pointer to the PreviewOutput instance used to obtain the rotation angle. |
| int displayRotation | Rotation angle of the display. |
| Camera_ImageRotation* imageRotation | Pointer to the preview rotation angle. |
Returns
| Type | Description |
|---|---|
| Camera_ErrorCode | CAMERA_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
| Name | Description |
|---|---|
| Camera_PreviewOutput* previewOutput | Pointer to the PreviewOutput instance used to obtain the rotation angle. |
| Camera_ImageRotation* imageRotation | Pointer to the preview rotation angle. |
Returns
| Type | Description |
|---|---|
| Camera_ErrorCode | CAMERA_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
| Name | Description |
|---|---|
| Camera_PreviewOutput* previewOutput | Pointer to the PreviewOutput instance used to set the rotation angle. |
| Camera_ImageRotation previewRotation | Preview rotation angle. |
| bool isDisplayLocked | Whether 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
| Type | Description |
|---|---|
| Camera_ErrorCode | CAMERA_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
| Name | Description |
|---|---|
| Camera_PreviewOutput* previewOutput | Pointer to the PreviewOutput instance used to obtain the frame rates. |
| Camera_FrameRateRange** frameRateRange | Double pointer to the list of frame rates, if the function is successfully called. |
| uint32_t* size | Pointer to the size of the list of frame rates. |
Returns
| Type | Description |
|---|---|
| Camera_ErrorCode | CAMERA_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
| Name | Description |
|---|---|
| Camera_PreviewOutput* previewOutput | Pointer to the target PreviewOutput instance. |
| Camera_FrameRateRange* frameRateRange | Pointer to the list of frame rates to delete. |
Returns
| Type | Description |
|---|---|
| Camera_ErrorCode | CAMERA_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
| Name | Description |
|---|---|
| Camera_PreviewOutput* previewOutput | Pointer to the PreviewOutput instance used to set the frame rates. |
| int32_t minFps | Minimum frame rate. |
| int32_t maxFps | Maximum frame rate. |
Returns
| Type | Description |
|---|---|
| Camera_ErrorCode | CAMERA_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
| Name | Description |
|---|---|
| Camera_PreviewOutput* previewOutput | Pointer to the PreviewOutput instance used to obtain the active frame rates. |
| Camera_FrameRateRange* frameRateRange | Pointer to the frame rate range, which is defined in the Camera_FrameRateRange struct, if the function is successfully called. |
Returns
| Type | Description |
|---|---|
| Camera_ErrorCode | CAMERA_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
| Name | Description |
|---|---|
| Camera_PreviewOutput* previewOutput | Pointer to the target PreviewOutput instance. |
| bool* isSupported | Pointer to the check result for the support of bandwidth compression. true if supported, false otherwise. |
Returns
| Type | Description |
|---|---|
| Camera_ErrorCode | CAMERA_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
| Name | Description |
|---|---|
| Camera_PreviewOutput* previewOutput | Pointer to the target PreviewOutput instance. |
| bool enabled | Whether to enable preview bandwidth compression. true to enable, false otherwise. |
Returns
| Type | Description |
|---|---|
| Camera_ErrorCode | CAMERA_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
| Name | Description |
|---|---|
| const Camera_PreviewOutput* previewOutput | Pointer to the PreviewOutput instance of the surface ID to add. |
| const char* surfaceId | Pointer to the surface ID used for creating the Camera_PreviewOutput instance. |
Returns
| Type | Description |
|---|---|
| Camera_ErrorCode | CAMERA_OK: The operation is successful. CAMERA_INVALID_ARGUMENT: A parameter is missing or the parameter type is incorrect. |