Add new internal APIs for extra preview bitrate 25/263425/1 accepted/tizen/unified/20210906.123742 submit/tizen/20210903.031152
authorJeongmo Yang <jm80.yang@samsung.com>
Thu, 2 Sep 2021 06:23:00 +0000 (15:23 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Thu, 2 Sep 2021 06:23:00 +0000 (15:23 +0900)
[Version] 0.4.62
[Issue Type] New feature

Change-Id: I1f7490b88b6d432c28b004bc452ead1489a545d2
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
include/camera_internal.h
packaging/capi-media-camera.spec
src/camera_internal.c
test/camera_test.c

index 923000d..68efb85 100644 (file)
@@ -478,6 +478,38 @@ int camera_attr_get_focus_level(camera_h camera, int *level);
 int camera_attr_get_focus_level_range(camera_h camera, int *min, int *max);
 
 /**
+ * @brief Sets the bitrate of extra preview.
+ * @since_tizen 6.5
+ * @param[in] camera    The handle to the camera
+ * @param[in] stream_id The id of extra preview stream
+ * @param[in] bitrate   The bitrate(bps) of extra preview
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CAMERA_ERROR_NONE Successful
+ * @retval #CAMERA_ERROR_INVALID_OPERATION Internal error
+ * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CAMERA_ERROR_NOT_SUPPORTED The feature is not supported
+ * @retval #CAMERA_ERROR_SERVICE_DISCONNECTED The socket to multimedia server is disconnected
+ * @see camera_attr_get_extra_preview_bitrate()
+ */
+int camera_attr_set_extra_preview_bitrate(camera_h camera, int stream_id, int bitrate);
+
+/**
+ * @brief Gets the bitrate of extra preview.
+ * @since_tizen 6.5
+ * @param[in] camera    The handle to the camera
+ * @param[in] stream_id The id of extra preview stream
+ * @param[out] bitrate  The bitrate(bps) of extra preview stream
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CAMERA_ERROR_NONE Successful
+ * @retval #CAMERA_ERROR_INVALID_OPERATION Internal error
+ * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CAMERA_ERROR_NOT_SUPPORTED The feature is not supported
+ * @retval #CAMERA_ERROR_SERVICE_DISCONNECTED The socket to multimedia server is disconnected
+ * @see camera_attr_set_extra_preview_bitrate()
+ */
+int camera_attr_get_extra_preview_bitrate(camera_h camera, int stream_id, int *bitrate);
+
+/**
  * @}
  */
 #ifdef __cplusplus
index dd6b891..98c2018 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-camera
 Summary:    A Camera API
-Version:    0.4.61
+Version:    0.4.62
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index 71db289..dda4c16 100644 (file)
@@ -660,4 +660,61 @@ int camera_get_extra_preview_stream_format(camera_h camera, int stream_id, camer
 
        return ret;
 }
+
+
+int camera_attr_set_extra_preview_bitrate(camera_h camera, int stream_id, int bitrate)
+{
+       int ret = CAMERA_ERROR_NONE;
+       camera_cli_s *pc = (camera_cli_s *)camera;
+       muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXTRA_PREVIEW_BITRATE;
+       camera_msg_param param0;
+       camera_msg_param param1;
+
+       if (!pc || !pc->cb_info) {
+               CAM_LOG_ERROR("NULL handle");
+               return CAMERA_ERROR_INVALID_PARAMETER;
+       }
+
+       CAM_LOG_INFO("Enter - stream_id[%d], bitrate[%d]", stream_id, bitrate);
+
+       CAMERA_MSG_PARAM_SET(param0, INT, stream_id);
+       CAMERA_MSG_PARAM_SET(param1, INT, bitrate);
+
+       _camera_msg_send_param2_int(api, pc->cb_info, &ret,
+               &param0, &param1, CAMERA_CB_TIMEOUT);
+
+       CAM_LOG_INFO("ret : 0x%x", ret);
+
+       return ret;
+}
+
+
+int camera_attr_get_extra_preview_bitrate(camera_h camera, int stream_id, int *bitrate)
+{
+       int ret = CAMERA_ERROR_NONE;
+       camera_cli_s *pc = (camera_cli_s *)camera;
+       muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXTRA_PREVIEW_BITRATE;
+       camera_msg_param param;
+
+       if (!pc || !pc->cb_info || !bitrate) {
+               CAM_LOG_ERROR("NULL pointer %p %p", pc, bitrate);
+               return CAMERA_ERROR_INVALID_PARAMETER;
+       }
+
+       CAM_LOG_INFO("Enter - stream_id[%d]", stream_id);
+
+       CAMERA_MSG_PARAM_SET(param, INT, stream_id);
+
+       _camera_msg_send_param1(api, pc->cb_info, &ret, &param, CAMERA_CB_TIMEOUT);
+
+       if (ret == CAMERA_ERROR_NONE) {
+               *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXTRA_PREVIEW_BITRATE];
+               CAM_LOG_INFO("get bitrate[%d] for stream[%d]", *bitrate, stream_id);
+       } else {
+               CAM_LOG_ERROR("get bitrate failed for stream[%d] : 0x%x", stream_id, ret);
+       }
+
+       return ret;
+}
+
 //LCOV_EXCL_STOP
index a84daf1..99dd4e5 100644 (file)
@@ -926,6 +926,7 @@ static void print_menu()
                g_print("\t     'E' EXIF orientation \n");
                g_print("\t     'F' Get facing direction of camera module\n");
                g_print("\t     's' Extra preview stream format\n");
+               g_print("\t     'B' Extra preview bitrate\n");
                g_print("\t  >>>>>>>>>>>>>>>>>>>> [Display/Filter]\n");
                g_print("\t     'v' Visible \n");
                g_print("\t     'o' Output mode \n");
@@ -1096,6 +1097,7 @@ static void setting_menu(gchar buf)
        int stream_id;
        int pixel_format;
        int fps;
+       int bitrate;
 
        switch (buf) {
        /* Camera setting */
@@ -1341,6 +1343,29 @@ static void setting_menu(gchar buf)
                g_print("\tGet stream_id[%d],pixel format[%d],res[%dx%d],fps[%d]\n",
                        stream_id, pixel_format, width, height, fps);
                break;
+       case 'B': /* Setting > Set extra preview bitrate */
+               g_print("* Set extra preview bitrate\n");
+
+               g_print("\tstream_id,bitrate : ");
+               err = scanf("%d,%d", &stream_id, &bitrate);
+               flush_stdin();
+
+               err = camera_attr_set_extra_preview_bitrate(hcamcorder->camera, stream_id, bitrate);
+               if (err != CAMERA_ERROR_NONE) {
+                       g_print("* Set Error : 0x%x\n", err);
+                       break;
+               }
+
+               bitrate = -1;
+
+               err = camera_attr_get_extra_preview_bitrate(hcamcorder->camera, stream_id, &bitrate);
+               if (err != CAMERA_ERROR_NONE) {
+                       g_print("* Get Error : 0x%x\n", err);
+                       break;
+               }
+
+               g_print("\tGet stream_id[%d],bitrate[%d]\n", stream_id, bitrate);
+               break;
                /* Display / Filter setting */
        case 'v': /* Display visible */
                g_print("* Display visible setting !\n");