Support switching device command using camera_change_device() API 54/322254/2 accepted/tizen_unified accepted/tizen_unified_x tizen accepted/tizen/unified/20250610.081801 accepted/tizen/unified/x/20250610.082528
authorJeongmo Yang <jm80.yang@samsung.com>
Fri, 10 Jan 2025 07:18:39 +0000 (16:18 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Thu, 10 Apr 2025 09:58:18 +0000 (18:58 +0900)
[Version] 1.2.0
[Issue Type] New feature

Change-Id: I37e3c6f12fd02003b6fbf2dce1174fba46078e75
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
legacy/src/legacy_camera.c
packaging/mmsvc-camera.spec

index 9924bd7404a390eacd4480d1665312040c19d305..a3e54286d7684927d84c970c6d061378de72af04 100644 (file)
@@ -644,6 +644,33 @@ int legacy_camera_create(camera_device_e device, camera_h *camera)
 }
 
 
+static int _camera_switch_device(camera_s *handle, camera_device_e device)
+{
+       int ret = MM_ERROR_NONE;
+       MMCamAttrsInfo info;
+
+       camera_return_val_if_fail(handle, CAMERA_ERROR_INVALID_PARAMETER);
+
+       ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_SWITCH_DEVICE, &info);
+       if (ret != MM_ERROR_NONE)
+               return __convert_camera_error_code(__func__, ret);
+
+       if (info.int_array.count == 0) {
+               /* NOTE: Return INVALID_STATE here.
+                - The camera_change_device() API should return INVALID_STATE if it's not CREATED state.
+                - The current state is PREVIEW now. */
+               CAM_LOG_ERROR("not support switch device");
+               return CAMERA_ERROR_INVALID_STATE;
+       }
+
+       ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
+               MMCAM_CAMERA_SWITCH_DEVICE, device,
+               NULL);
+
+       return __convert_camera_error_code(__func__, ret);
+}
+
+
 int legacy_camera_change_device(camera_h *camera, camera_device_e device)
 {
        int ret = MM_ERROR_NONE;
@@ -661,14 +688,17 @@ int legacy_camera_change_device(camera_h *camera, camera_device_e device)
 
        old_handle = (camera_s *)*camera;
 
-       camera_return_val_if_fail(old_handle->is_used_in_recorder == false, CAMERA_ERROR_INVALID_OPERATION);
-       camera_return_val_if_fail(old_handle->device_type != device, CAMERA_ERROR_NONE);
-
        /* check current state */
        legacy_camera_get_state(*camera, &capi_state);
 
+       if (capi_state == CAMERA_STATE_PREVIEW)
+               return _camera_switch_device(old_handle, device);
+
+       camera_return_val_if_fail(old_handle->device_type != device, CAMERA_ERROR_NONE);
        camera_return_val_if_fail(capi_state == CAMERA_STATE_CREATED, CAMERA_ERROR_INVALID_STATE);
 
+       camera_return_val_if_fail(!old_handle->is_used_in_recorder, CAMERA_ERROR_INVALID_OPERATION);
+
        /* get reuse element */
        ret = mm_camcorder_get_attributes(old_handle->mm_handle, NULL,
                MMCAM_DISPLAY_REUSE_ELEMENT, &reuse_element, &element_size,
index 2fe660e6b4b7fae02201e9f2c3d991557e95c734..79ba7a79b7e7a3926579c4e0388553387bb093f1 100644 (file)
@@ -1,6 +1,6 @@
 Name:       mmsvc-camera
 Summary:    A Camera module for muse server
-Version:    1.1.3
+Version:    1.2.0
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0