Add new attribute: MMCAM_CAMERA_SWITCH_DEVICE 53/322253/1 accepted/tizen_unified accepted/tizen_unified_x tizen accepted/tizen/unified/20250610.081759 accepted/tizen/unified/x/20250610.082527
authorJeongmo Yang <jm80.yang@samsung.com>
Fri, 10 Jan 2025 07:16:57 +0000 (16:16 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Fri, 4 Apr 2025 09:25:42 +0000 (18:25 +0900)
- It's for switching device command support.

[Version] 1.4.0
[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 425736ca7ae494cf208f38a57b00a20305ef18bc..efc8702a25543f86df434f9873d9fb2d145cd6c3 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmm-camcorder
 Summary:    Camera and recorder library
-Version:    1.3.4
+Version:    1.4.0
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0
index 11442284dffcbc3ca630f9f8bc937976bb7cfd27..a2a7f382b504802690cbc125666242ae3dfa6d36 100644 (file)
@@ -1390,6 +1390,11 @@ extern "C" {
  */
 #define MMCAM_VIDEO_STREAM_CALLBACK_FLAG        "video-stream-callback-flag"
 
+/**
+ * Switch device
+ */
+#define MMCAM_CAMERA_SWITCH_DEVICE              "camera-switch-device"
+
 
 
 /*=======================================================================================
index 9a1a0d26c6e3ae146d7d6a6e964765f2c728e3ea..6c2fb3f4c11eca0faec3a208eecfbf4220796cc4 100644 (file)
@@ -200,7 +200,8 @@ typedef enum {
        MM_CAM_REQUEST_CODEC_CONFIG,
        MM_CAM_SUPPORT_MEDIA_PACKET_PREVIEW_INTERNAL_CB,
        MM_CAM_VIDEO_STREAM_CALLBACK_FLAG,
-       MM_CAM_FILTER_WB_TEMPERATURE,       /* 145 */
+       MM_CAM_CAMERA_SWITCH_DEVICE,        /* 145 */
+       MM_CAM_FILTER_WB_TEMPERATURE,
        MM_CAM_FILTER_WB_TEMPERATURE_STEP,
        MM_CAM_CAMERA_GAIN,
        MM_CAM_CAMERA_GAIN_STEP,
@@ -409,6 +410,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 89e07eab068663bd2f2ccc7a00cdae741949f8e1..fc5fe4cb1ee19e76b39f6987a93fa067453071d3 100644 (file)
@@ -134,7 +134,7 @@ extern "C" {
 #define _MMCAMCORDER_SENSOR_ENUM_NONE  -255
 
 /* camera information related */
-#define CAMINFO_CONVERT_NUM            49
+#define CAMINFO_CONVERT_NUM            50
 
 
 /*=======================================================================================
index 49866cbebc064d604a888201d1da0195390dcad9..639a833330e4dede362469518c8b8d224d792c65 100644 (file)
@@ -1744,6 +1744,17 @@ _mmcamcorder_alloc_attribute(MMHandleType handle)
                        {.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,
+               },
                {
                        MM_CAM_FILTER_WB_TEMPERATURE,
                        "filter-wb-temperature",
@@ -5021,6 +5032,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 08cbbcca4b4ec710987a8bc64e2505aa134f1cf6..d60e5a413c1eebfc8fcbe3dea4673cb04dc4abb1 100644 (file)
@@ -674,6 +674,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} },
                { "UpdateCapsByStreamRotation",   CONFIGURE_VALUE_INT,          {.value_int = 0} },
        };
 
index 97541c05dba5cdfe9dcf5d3be218db33c606ec45..3e22aa4a85d6f09ce3551694ead0f3f7f48e5fe1 100644 (file)
@@ -672,6 +672,15 @@ static _MMCamcorderInfoConverting  g_caminfo_convert[CAMINFO_CONVERT_NUM] = {
                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,
+       },
        {
                CONFIGURE_TYPE_CTRL,
                CONFIGURE_CATEGORY_CTRL_EFFECT,