From c8b1f55cec857f4c3737c49b9270f51bbfe37b5c Mon Sep 17 00:00:00 2001 From: Jeongmo Yang Date: Tue, 31 Aug 2021 18:11:47 +0900 Subject: [PATCH] Add new interface for extra preview bitrate [Version] 0.0.12 [Issue Type] New feature Change-Id: Ic435ebea2fe7f0972f8d0278669f14e7d0030428 Signed-off-by: Jeongmo Yang --- include/hal-camera-interface.h | 3 +++ include/hal-camera.h | 31 +++++++++++++++++++++++++++++++ packaging/hal-api-camera.spec | 2 +- src/hal-api-camera.c | 24 ++++++++++++++++++++++++ 4 files changed, 59 insertions(+), 1 deletion(-) diff --git a/include/hal-camera-interface.h b/include/hal-camera-interface.h index 9203736..b247814 100644 --- a/include/hal-camera-interface.h +++ b/include/hal-camera-interface.h @@ -239,6 +239,7 @@ typedef struct camera_format { camera_pixel_format_e capture_format; camera_resolution_s capture_resolution; uint32_t capture_quality; + uint32_t stream_bitrate; } camera_format_s; /** @@ -624,6 +625,8 @@ typedef struct _hal_backend_media_camera_funcs { int (*release_extra_preview_buffer)(void *camera_handle, int stream_id, int buffer_index); int (*set_extra_preview_stream_format)(void *camera_handle, int stream_id, camera_format_s *format); int (*get_extra_preview_stream_format)(void *camera_handle, int stream_id, camera_format_s *format); + int (*set_extra_preview_bitrate)(void *camera_handle, int stream_id, int bitrate); + int (*get_extra_preview_bitrate)(void *camera_handle, int stream_id, int *bitrate); } hal_backend_camera_funcs; /** diff --git a/include/hal-camera.h b/include/hal-camera.h index 77a5071..608c33d 100644 --- a/include/hal-camera.h +++ b/include/hal-camera.h @@ -287,6 +287,37 @@ int hal_camera_set_extra_preview_stream_format(void *camera_handle, int stream_i */ int hal_camera_get_extra_preview_stream_format(void *camera_handle, int stream_id, camera_format_s *format); +/** + * @brief Sets the bitrate of the extra preview. + * @since_tizen 6.5 + * @param[in] camera_handle The handle to the camera HAL + * @param[in] stream_id The id of extra preview stream + * @param[in] bitrate The bitrate(bps) of the extra preview + * @return @c 0 on success, otherwise a negative error value + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CAMERA_ERROR_INVALID_STATE Invalid state + * @retval #CAMERA_ERROR_DEVICE_NOT_SUPPORTED The feature is not supported + * @pre The camera state must be set to #CAMERA_STATE_OPENED. + * @see hal_camera_get_extra_preview_bitrate() + */ +int hal_camera_set_extra_preview_bitrate(void *camera_handle, int stream_id, int bitrate); + +/** + * @brief Gets the bitrate of the extra preview. + * @since_tizen 6.5 + * @param[in] camera_handle The handle to the camera HAL + * @param[in] stream_id The id of extra preview stream + * @param[out] bitrate The bitrate(bps) of the extra preview + * @return @c 0 on success, otherwise a negative error value + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CAMERA_ERROR_INVALID_STATE Invalid state + * @retval #CAMERA_ERROR_DEVICE_NOT_SUPPORTED The feature is not supported + * @see hal_camera_set_extra_preview_bitrate() + */ +int hal_camera_get_extra_preview_bitrate(void *camera_handle, int stream_id, int *bitrate); + /** * @brief Sets a callback function to be called for extra preview frames. * @since_tizen 6.5 diff --git a/packaging/hal-api-camera.spec b/packaging/hal-api-camera.spec index 5a09d01..168df1b 100644 --- a/packaging/hal-api-camera.spec +++ b/packaging/hal-api-camera.spec @@ -4,7 +4,7 @@ ### main package ######### Name: %{name} Summary: %{name} interface -Version: 0.0.11 +Version: 0.0.12 Release: 0 Group: Development/Libraries License: Apache-2.0 diff --git a/src/hal-api-camera.c b/src/hal-api-camera.c index 2d69734..f878060 100644 --- a/src/hal-api-camera.c +++ b/src/hal-api-camera.c @@ -432,6 +432,30 @@ int hal_camera_get_extra_preview_stream_format(void *camera_handle, int stream_i } +int hal_camera_set_extra_preview_bitrate(void *camera_handle, int stream_id, int bitrate) +{ + hal_camera_s *handle = (hal_camera_s *)camera_handle; + + HAL_CAMERA_RETURN_IF_FAILED(handle, CAMERA_ERROR_INVALID_PARAMETER); + HAL_CAMERA_RETURN_IF_FAILED(handle->funcs, CAMERA_ERROR_INVALID_PARAMETER); + HAL_CAMERA_RETURN_IF_FAILED(handle->funcs->set_extra_preview_bitrate, CAMERA_ERROR_NOT_IMPLEMENTED); + + return handle->funcs->set_extra_preview_bitrate(handle->backend, stream_id, bitrate); +} + + +int hal_camera_get_extra_preview_bitrate(void *camera_handle, int stream_id, int *bitrate) +{ + hal_camera_s *handle = (hal_camera_s *)camera_handle; + + HAL_CAMERA_RETURN_IF_FAILED(handle, CAMERA_ERROR_INVALID_PARAMETER); + HAL_CAMERA_RETURN_IF_FAILED(handle->funcs, CAMERA_ERROR_INVALID_PARAMETER); + HAL_CAMERA_RETURN_IF_FAILED(handle->funcs->get_extra_preview_bitrate, CAMERA_ERROR_NOT_IMPLEMENTED); + + return handle->funcs->get_extra_preview_bitrate(handle->backend, stream_id, bitrate); +} + + int hal_camera_set_command(void *camera_handle, int64_t command, void *value) { hal_camera_s *handle = (hal_camera_s *)camera_handle; -- 2.34.1