Add new attribute: MMCAM_CAMERA_SWITCH_DEVICE 69/317969/1 accepted/tizen_7.0_unified tizen_7.0 accepted/tizen/7.0/unified/20250123.020348
authorJeongmo Yang <jm80.yang@samsung.com>
Fri, 10 Jan 2025 07:16:57 +0000 (16:16 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Fri, 10 Jan 2025 07:16:57 +0000 (16:16 +0900)
- It's for switching device command support.

[Version] 0.10.299
[Issue Type] New feature

Change-Id: Ifaa3ffd1981e121d696e9ae7b6145eeadd5ee1ae
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
packaging/libmm-camcorder.spec
src/include/mm_camcorder.h
src/include/mm_camcorder_attribute.h
src/include/mm_camcorder_platform.h
src/mm_camcorder_attribute.c
src/mm_camcorder_configure.c
src/mm_camcorder_platform.c

index 33061766d3e11ffea9cb3b04e49b6c0518f26bd7..f1fd1bebad57d83c297a8ddf8691f85f6d31074d 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       libmm-camcorder
 Summary:    Camera and recorder library
-Version:    0.10.298
+Version:    0.10.299
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0
index 751938d533d9ab3163a192df2b734906769f2aaa..41bdc2f149256d3ecf8924eae96da522ff9cc69a 100644 (file)
@@ -1370,6 +1370,11 @@ extern "C" {
  */
 #define MMCAM_VIDEO_STREAM_CALLBACK_FLAG        "video-stream-callback-flag"
 
+/**
+ * Switch device
+ */
+#define MMCAM_CAMERA_SWITCH_DEVICE              "camera-switch-device"
+
 
 
 /*=======================================================================================
index 3de628f97ae6c4fd7a861722bb7ee85672300231..b129dda11ffb18233aa4299fd78ee126135c54c6 100644 (file)
@@ -200,6 +200,7 @@ typedef enum {
        MM_CAM_REQUEST_CODEC_CONFIG,
        MM_CAM_SUPPORT_MEDIA_PACKET_PREVIEW_INTERNAL_CB,
        MM_CAM_VIDEO_STREAM_CALLBACK_FLAG,
+       MM_CAM_CAMERA_SWITCH_DEVICE,
        MM_CAM_ATTRIBUTE_NUM
 } MMCamcorderAttrsID;
 
@@ -405,6 +406,7 @@ bool _mmcamcorder_commit_tag(MMHandleType handle, int attr_idx, const MMAttrsVal
 bool _mmcamcorder_commit_audio_replay_gain(MMHandleType handle, int attr_idx, const MMAttrsValue *value);
 bool _mmcamcorder_commit_extra_preview(MMHandleType handle, int attr_idx, const MMAttrsValue *value);
 bool _mmcamcorder_commit_request_codec_config(MMHandleType handle, int attr_idx, const MMAttrsValue *value);
+bool _mmcamcorder_commit_camera_switch_device(MMHandleType handle, int attr_idx, const MMAttrsValue *value);
 
 
 /**
index ad4f7ead7f33a00b79b2da2a0fc4fd2fe9551a83..4ff21cc616c4b43dae5a58a067ae6733aa7df059 100644 (file)
@@ -134,7 +134,7 @@ extern "C" {
 #define _MMCAMCORDER_SENSOR_ENUM_NONE  -255
 
 /* camera information related */
-#define CAMINFO_CONVERT_NUM            47
+#define CAMINFO_CONVERT_NUM            48
 
 
 /*=======================================================================================
index 760c1f9af65dd2f85f478614543d5d3eea40dc98..f94b103d1091e8ead7208438e8addd1e02235e63 100644 (file)
@@ -1743,6 +1743,17 @@ _mmcamcorder_alloc_attribute(MMHandleType handle)
                        {.int_min = 0},
                        {.int_max = _MMCAMCORDER_MAX_INT},
                        NULL,
+               },
+               {
+                       MM_CAM_CAMERA_SWITCH_DEVICE,
+                       "camera-switch-device",
+                       MM_ATTRS_TYPE_INT,
+                       MM_ATTRS_FLAG_RW,
+                       {(void*)0},
+                       MM_ATTRS_VALID_TYPE_INT_ARRAY,
+                       {0},
+                       {0},
+                       _mmcamcorder_commit_camera_switch_device,
                }
        };
 
@@ -4915,6 +4926,43 @@ bool _mmcamcorder_commit_request_codec_config(MMHandleType handle, int attr_idx,
 }
 
 
+bool _mmcamcorder_commit_camera_switch_device(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
+{
+       int device = 0;
+       int current_state = MM_CAMCORDER_STATE_NONE;
+       mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
+       _MMCamcorderSubContext *sc = NULL;
+       GstCameraControl *control = NULL;
+
+       mmf_return_val_if_fail(hcamcorder && value, FALSE);
+
+       sc = MMF_CAMCORDER_SUBCONTEXT(handle);
+       mmf_return_val_if_fail(sc, TRUE);
+
+       current_state = _mmcamcorder_get_state(handle);
+
+       if (hcamcorder->type != MM_CAMCORDER_MODE_VIDEO_CAPTURE ||
+               current_state != MM_CAMCORDER_STATE_PREPARE ||
+               !GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
+               MMCAM_LOG_ERROR("invalid condition[type:%d,state:%d]",
+                       hcamcorder->type, current_state);
+               return FALSE;
+       }
+
+       device = value->value.i_val;
+
+       MMCAM_LOG_INFO("switch device[%d]", device);
+
+       control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
+       if (!gst_camera_control_switch_device(control, device)) {
+               MMCAM_LOG_ERROR("switch device[%d] failed", device);
+               return FALSE;
+       }
+
+       return TRUE;
+}
+
+
 bool _mmcamcorder_set_attribute_to_camsensor(MMHandleType handle)
 {
        mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
index 99bff357b4f05ab714a21f10f6109f71638e654a..777ebe30b2ff09312ab9b56108fd8264c45979f7 100644 (file)
@@ -671,6 +671,7 @@ int _mmcamcorder_conf_init(MMHandleType handle, int type, camera_conf *configure
                { "SupportUserBuffer",            CONFIGURE_VALUE_INT,          {.value_int = 0} },
                { "MeasurePreviewFPS",            CONFIGURE_VALUE_INT,          {.value_int = 0} },
                { "DefaultEncodedPreviewBitrate", CONFIGURE_VALUE_INT,          {.value_int = DEFAULT_ENCODED_PREVIEW_BITRATE} },
+               { "SwitchDevice",                 CONFIGURE_VALUE_INT_ARRAY,    {NULL} },
        };
 
        /* [AudioInput] matching table */
index a480548390acc290c496eca8f519793b4f989e36..4fdc59b8c580a1e82679cfaa8ab54e02a196488e 100644 (file)
@@ -670,6 +670,15 @@ static _MMCamcorderInfoConverting  g_caminfo_convert[CAMINFO_CONVERT_NUM] = {
                "FocusLevel",
                MM_CAMCONVERT_TYPE_INT_RANGE,
                NULL,
+       },
+       {
+               CONFIGURE_TYPE_MAIN,
+               CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT,
+               MM_CAM_CAMERA_SWITCH_DEVICE,
+               MM_CAMCORDER_ATTR_NONE,
+               "SwitchDevice",
+               MM_CAMCONVERT_TYPE_INT_ARRAY,
+               NULL,
        }
 };