Add new internal API to set device for extra preview 80/281480/1 accepted/tizen_7.0_unified_hotfix tizen_7.0_hotfix accepted/tizen/7.0/unified/hotfix/20221116.104617 accepted/tizen/unified/20220920.110654 tizen_7.0_m2_release
authorJeongmo Yang <jm80.yang@samsung.com>
Mon, 19 Sep 2022 10:50:13 +0000 (19:50 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Mon, 19 Sep 2022 10:50:13 +0000 (19:50 +0900)
[Version] 0.4.90
[Issue Type] New feature

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

index 11876ad..672a64b 100644 (file)
@@ -218,6 +218,25 @@ 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);
 
 /**
+ * @internal
+ * @brief Sets device for the extra preview stream.
+ * @since_tizen 7.0
+ * @param[in] camera       The handle to the camera
+ * @param[in] stream_id    The id of extra preview stream
+ * @param[in] device       The camera type
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CAMERA_ERROR_NONE Successful
+ * @retval #CAMERA_ERROR_NOT_SUPPORTED The feature is not supported
+ * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
+ * @retval #CAMERA_ERROR_SERVICE_DISCONNECTED The socket to multimedia server is disconnected
+ * @pre The camera state must be set to #CAMERA_STATE_CREATED.
+ * @see camera_set_extra_preview_cb()
+ * @see camera_unset_extra_preview_cb()
+ */
+int camera_set_extra_preview_device(camera_h camera, int stream_id, camera_device_e device);
+
+/**
  * @}
  */
 #ifdef __cplusplus
index 0cece0b..74e11e1 100644 (file)
@@ -87,6 +87,22 @@ extern "C" {
                        LOGD("[V] "format, ##args); \
        } while (0)
 
+#define CAMERA_CHECK_HANDLE_RETURN(pc) \
+       do {\
+               if (!pc || !pc->cb_info) {\
+                       CAM_LOG_ERROR("NULL handle[%p]", pc);\
+                       return;\
+               }\
+       } while (0)
+
+#define CAMERA_CHECK_HANDLE_RETURN_VAL(pc, val) \
+       do {\
+               if (!pc || !pc->cb_info) {\
+                       CAM_LOG_ERROR("NULL handle[%p]", pc);\
+                       return (val);\
+               }\
+       } while (0)
+
 
 enum {
        CAMERA_MESSAGE_HANDLER_TYPE_GENERAL,
@@ -259,6 +275,8 @@ void _camera_msg_send_param2_int(int api, camera_cb_info_s *cb_info,
 void _camera_msg_return_buffer(int ret_fd, camera_cb_info_s *cb_info);
 int _camera_client_wait_for_cb_return(muse_camera_api_e api, camera_cb_info_s *cb_info, int time_out);
 void _camera_update_api_waiting(camera_cb_info_s *cb_info, int api, int value);
+void _camera_send_message_get_return(camera_cb_info_s *cb_info, muse_camera_api_e api, char *msg,
+       int time_out, int *ret);
 int _camera_get_log_level(void);
 
 typedef bool (*camera_supported_cb_param1)(int param, void *user_data);
index 20221ad..a30a364 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-camera
 Summary:    A Camera API
-Version:    0.4.89
+Version:    0.4.90
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index 9cbca68..228808f 100644 (file)
                        return CAMERA_ERROR_NOT_SUPPORTED;\
                }\
        } while (0)
-#define CAMERA_CHECK_HANDLE_RETURN(pc) \
-       do {\
-               if (!pc || !pc->cb_info) {\
-                       CAM_LOG_ERROR("NULL handle[%p]", pc);\
-                       return;\
-               }\
-       } while (0)
-#define CAMERA_CHECK_HANDLE_RETURN_VAL(pc, val) \
-       do {\
-               if (!pc || !pc->cb_info) {\
-                       CAM_LOG_ERROR("NULL handle[%p]", pc);\
-                       return (val);\
-               }\
-       } while (0)
+
 
 /* for camera device manager */
 typedef struct _cdm_symbol_table {
@@ -760,7 +747,7 @@ static int __set_enable(camera_h camera, muse_camera_api_e api, int set_enable)
 }
 
 
-static void __send_message_get_return(camera_cb_info_s *cb_info, muse_camera_api_e api, char *msg, int time_out, int *ret)
+void _camera_send_message_get_return(camera_cb_info_s *cb_info, muse_camera_api_e api, char *msg, int time_out, int *ret)
 {
        int send_ret = 0;
 
@@ -869,7 +856,7 @@ void _camera_msg_send(int api, int *fds, camera_cb_info_s *cb_info,
 
        msg = muse_core_msg_new(api, NULL);
 
-       __send_message_get_return(cb_info, api, msg, timeout, ret);
+       _camera_send_message_get_return(cb_info, api, msg, timeout, ret);
 }
 
 
@@ -914,7 +901,7 @@ void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info,
                break;
        }
 
-       __send_message_get_return(cb_info, api, msg, timeout, ret);
+       _camera_send_message_get_return(cb_info, api, msg, timeout, ret);
 }
 
 
@@ -943,7 +930,7 @@ void _camera_msg_send_param2_int(int api, camera_cb_info_s *cb_info,
                param1->type, param1->name, param1->value.value_INT,
                NULL);
 
-       __send_message_get_return(cb_info, api, msg, timeout, ret);
+       _camera_send_message_get_return(cb_info, api, msg, timeout, ret);
 }
 
 
@@ -4792,7 +4779,7 @@ int camera_attr_set_geotag(camera_h camera, double latitude, double longitude, d
                MUSE_TYPE_ARRAY, "set_geotag", length, (int *)set_geotag,
                NULL);
 
-       __send_message_get_return(pc->cb_info, api, msg, CAMERA_CB_TIMEOUT, &ret);
+       _camera_send_message_get_return(pc->cb_info, api, msg, CAMERA_CB_TIMEOUT, &ret);
 
        return ret;
 }
@@ -6201,7 +6188,7 @@ int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, i
                MUSE_TYPE_ARRAY, "set_display_roi_area", length, (int *)set_display_roi_area,
                NULL);
 
-       __send_message_get_return(pc->cb_info, api, msg, CAMERA_CB_TIMEOUT, &ret);
+       _camera_send_message_get_return(pc->cb_info, api, msg, CAMERA_CB_TIMEOUT, &ret);
 
        return ret;
 }
@@ -6763,7 +6750,7 @@ int camera_set_extra_preview_stream_format(camera_h camera, int stream_id, camer
                MUSE_TYPE_ARRAY, "stream_format", 4, stream_format,
                NULL);
 
-       __send_message_get_return(pc->cb_info, api, msg, CAMERA_CB_TIMEOUT, &ret);
+       _camera_send_message_get_return(pc->cb_info, api, msg, CAMERA_CB_TIMEOUT, &ret);
 
        return ret;
 }
index 59e9c0b..7fc9b72 100644 (file)
@@ -335,4 +335,26 @@ int camera_attr_get_focus_level_range(camera_h camera, int *min, int *max)
 
        return ret;
 }
+
+
+int camera_set_extra_preview_device(camera_h camera, int stream_id, camera_device_e device)
+{
+       int ret = CAMERA_ERROR_NONE;
+       char *msg = NULL;
+       camera_cli_s *pc = (camera_cli_s *)camera;
+       muse_camera_api_e api = MUSE_CAMERA_API_SET_EXTRA_PREVIEW_DEVICE;
+
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
+
+       CAM_LOG_INFO("Enter - stream[%d], device[%d]", stream_id, device);
+
+       msg = muse_core_msg_new(api,
+               MUSE_TYPE_INT, "stream_id", stream_id,
+               MUSE_TYPE_INT, "device", device,
+               NULL);
+
+       _camera_send_message_get_return(pc->cb_info, api, msg, CAMERA_CB_TIMEOUT, &ret);
+
+       return ret;
+}
 //LCOV_EXCL_STOP
index 8ca3544..4ec9e23 100644 (file)
@@ -1765,6 +1765,7 @@ static void __enable_extra_preview_and_callback(camera_h camera)
        int height = 0;
        int fps = 0;
        int pixel_format = 0;
+       int camera_device = 0;
 
        g_print("\n\t- Format list");
        g_print("\n\t0:NV12, 1:NV12T, 2:NV16, 3:NV21, 4:YUYV, 5:UYVY, 6:422P, 7:I420, 8:YV12, 9:RGB565, 10:RGB888");
@@ -1786,6 +1787,14 @@ static void __enable_extra_preview_and_callback(camera_h camera)
                return;
        }
 
+       g_print("\n\t## for MM_CAMCORDER_EXTRA_PREVIEW_MODE_PIPELINE_ELEMENT ##\n");
+       g_print("\n\tSet device for extra preview[0 ~ 9] : ");
+       err = scanf("%d", (int *)&camera_device);
+       flush_stdin();
+
+       err = camera_set_extra_preview_device(hcamcorder->camera, 0, camera_device);
+       g_print("\n\tcamera_set_extra_preview_device(device:%d) 0x%x\n", camera_device, err);
+
        g_print("\n\tDump extra preview data to file - NO[0], YES[Others] : ");
        err = scanf("%d", &g_camera_extra_preview_cb_dump);
        flush_stdin();