Depart camera exif orientation and recording orientaiton
authorKyungYoun <ky99.won@samsung.com>
Sat, 13 Apr 2013 02:41:31 +0000 (11:41 +0900)
committerKyungYoun <ky99.won@samsung.com>
Sat, 13 Apr 2013 02:41:31 +0000 (11:41 +0900)
Change-Id: I4e74c7300fc15f4f0be063a10e4c4a6f2a282ba0
Signed-off-by: KyungYoun <ky99.won@samsung.com>
src/FMedia_CameraCoordinator.cpp
src/FMedia_CameraCoordinator.h
src/FMedia_CameraImpl.cpp
src/FMedia_CameraImpl.h
src/FMedia_VideoRecorderImpl.cpp
src/FMedia_VideoRecorderImpl.h

index 9002c68..95efa09 100755 (executable)
@@ -28,8 +28,6 @@
 #include "FMedia_CameraUtil.h"
 #include "FMedia_RecorderUtil.h"
 
-//#define _VIDEO_RECORDER_ROTATION_
-
 using namespace Tizen::Base;
 using namespace Tizen::Base::Collection;
 
@@ -120,9 +118,6 @@ _CameraCoordinator::_CameraCoordinator()
        , __recorderHandle(MM_INVALID_HANDLE)
        , __mode(_CAMERA_MODE_NONE)
        , __pListenerList(null, _ListPtrUtil::remover)
-       , __orientationFlag(0)
-       , __cameraOrientation(CAMERA_EXIF_ORIENTATION_TOP_LEFT)
-       , __recordingRotation(RECORDING_ROTATION_NONE)
        , __reloadCameraPreviewFormat(::CAMERA_PIXEL_FORMAT_I420)
 {
 }
@@ -180,7 +175,6 @@ _CameraCoordinator::RemoveRecorder(_RecorderDeviceType recorderDevice)
        SysLog(NID_MEDIA, "Enter. recorder device:%d", recorderDevice);
        _RecorderManager::Release(recorderDevice);
        __recorderHandle = MM_INVALID_HANDLE;
-       __orientationFlag = __orientationFlag & (~_ORIENTATION_FOR_RECORDING);
 }
 
 _CameraCoordinator*
@@ -1195,17 +1189,6 @@ _CameraCoordinator::StartCapture(camera_capturing_cb capturingCb , camera_captur
        result r = E_SUCCESS;
        int err = MM_SUCCESS;
 
-       if (__orientationFlag & _ORIENTATION_FOR_CAMERA)
-       {
-               r = SetCameraOrientationAttr(__cameraOrientation);
-               SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
-       }
-       else if (__orientationFlag & _ORIENTATION_FOR_RECORDING)        // If recorder setting is remained.
-       {
-               r = SetCameraOrientationAttr(CAMERA_EXIF_ORIENTATION_TOP_LEFT); // To set the init value
-               SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
-       }
-
        __mode = _CAMERA_MODE_IMAGE;
        err = camera_start_capture(__cameraHandle, capturingCb, completedCb, pUserData);
        r = ConvertResult(err);
@@ -1220,17 +1203,6 @@ _CameraCoordinator::StartRecord(void)
        result r = E_SUCCESS;
        int err = MM_SUCCESS;
 
-       if (__orientationFlag & _ORIENTATION_FOR_RECORDING)
-       {
-               r = SetRecordingOrientationAttr(__recordingRotation);
-               SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
-       }
-       else if (__orientationFlag & _ORIENTATION_FOR_CAMERA)   // If recorder setting is remained.
-       {
-               r = SetRecordingOrientationAttr(RECORDING_ROTATION_NONE);       // To set the init value
-               SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
-       }
-
        __mode = _CAMERA_MODE_VIDEO;
        err = recorder_start(__recorderHandle);
        r = ConvertResult(err);
@@ -1239,67 +1211,6 @@ _CameraCoordinator::StartRecord(void)
        return r;
 }
 
-void
-_CameraCoordinator::SetRecordingOrientation(RecordingRotation rotation)
-{
-       __orientationFlag = __orientationFlag | _ORIENTATION_FOR_RECORDING;
-       __recordingRotation = rotation;
-}
-
-void
-_CameraCoordinator::SetCameraOrientation(CameraExifOrientation orientation)
-{
-       __orientationFlag = __orientationFlag | _ORIENTATION_FOR_CAMERA;
-       __cameraOrientation = orientation;
-}
-
-result
-_CameraCoordinator::SetRecordingOrientationAttr(RecordingRotation rotation)
-{
-       result r = E_SUCCESS;
-       int err = MM_SUCCESS;
-#if _VIDEO_RECORDER_ROTATION_
-       recorder_rotation_e mmAttr = ::RECORDER_ROTATION_NONE;
-       r = _RecorderUtil::GetMmRotation(rotation, mmAttr);
-       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating. rotation:%d", GetErrorMessage(r), rotation);
-
-       err = recorder_attr_set_recording_orientation(__recorderHandle, mmAttr);
-       r = ConvertResult(err);
-       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Camcorder set attribute failed. rotation:%d", GetErrorMessage(r), rotation);
-#else
-       CameraRotation cameraRotation = CAMERA_ROTATION_NONE;
-       r = _RecorderUtil::GetCameraRotation(rotation, cameraRotation);
-       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating. rotation:%d", GetErrorMessage(r), rotation);
-
-       camera_attr_tag_orientation_e mmOrientationAttr = CAMERA_ATTR_TAG_ORIENTATION_TOP_LEFT;
-       r = _CameraUtil::GetMmExifOrientation(cameraRotation, mmOrientationAttr);
-       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating. rotation:%d", GetErrorMessage(r), rotation);
-
-       err = camera_attr_set_tag_orientation(__cameraHandle, mmOrientationAttr);
-       r = ConvertResult(err);
-       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Camcorder set attribute failed. Mm orientation:%d", GetErrorMessage(r), mmOrientationAttr);
-#endif
-
-       return r;
-}
-
-result
-_CameraCoordinator::SetCameraOrientationAttr(CameraExifOrientation orientation)
-{
-       result r = E_SUCCESS;
-       int err = MM_SUCCESS;
-       camera_attr_tag_orientation_e attr = ::CAMERA_ATTR_TAG_ORIENTATION_TOP_LEFT;
-
-       r = _CameraUtil::GetMmExifOrientation(orientation, attr);
-       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating. orientation:%d", GetErrorMessage(r), orientation);
-
-       err = camera_attr_set_tag_orientation(__cameraHandle, attr);
-       r = ConvertResult(err);
-       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating. orientation:%d", GetErrorMessage(r), orientation);
-
-       return r;
-}
-
 camera_pixel_format_e
 _CameraCoordinator::GetReloadPreviewFormat(void) const
 {
index f1f29c3..6dd39ff 100755 (executable)
@@ -312,20 +312,6 @@ public:
        result StartRecord(void);
 
        /**
-       * Sets the orientation of the recorder.
-       *
-       * @return               An error code
-       */
-       void SetRecordingOrientation(RecordingRotation rotation);
-
-       /**
-       * Sets the orientation of the camera.
-       *
-       * @return               An error code
-       */
-       void SetCameraOrientation(CameraExifOrientation orientation);
-
-       /**
        * Gets the reloaded preview format of the camera.
        *
        * @return               An error code
@@ -416,28 +402,6 @@ private:
        */
        result ChangeRecorderStateTo(recorder_state_e destState);
 
-       /**
-       * Sets the orientation of the recorder.
-       *
-       * @return               An error code
-       * @param[in]    rotation                        The rotation of the recorder
-       * @exception    E_SUCCESS                       The method is successful.
-       * @exception    E_INVALID_STATE         This method is invalid for the current state of this instance.
-       * @exception    E_INVALID_ARG           The specified @c rotation is not supported.
-       */
-       result SetRecordingOrientationAttr(RecordingRotation rotation);
-
-       /**
-       * Sets the orientation of the camera.
-       *
-       * @return               An error code
-       * @param[in]    orientation                     The orientation of the camera
-       * @exception    E_SUCCESS                       The method is successful.
-       * @exception    E_INVALID_STATE         This method is invalid for the current state of this instance.
-       * @exception    E_INVALID_ARG           The specified @c rotation is not supported.
-       */
-       result SetCameraOrientationAttr(CameraExifOrientation orientation);
-
        _CameraCoordinator(const _CameraCoordinator& rhs);
        _CameraCoordinator& operator =(const _CameraCoordinator& rhs);
 
@@ -446,9 +410,6 @@ private:
        _RecorderHandle __recorderHandle;
        _CameraMode __mode;
        std::unique_ptr<Tizen::Base::Collection::LinkedListT <_ICameraCoordinatorListener*>, _ListPtrUtil::Remover> __pListenerList;
-       int __orientationFlag;
-       CameraExifOrientation __cameraOrientation;
-       RecordingRotation __recordingRotation;
        camera_pixel_format_e __reloadCameraPreviewFormat;
 
        static _CameraCoordinatorSafeHashMapT* __pMap;
index 13af2af..a4c66ba 100755 (executable)
@@ -1792,7 +1792,8 @@ _CameraImpl::SetExifOrientation(CameraExifOrientation orientation)
 
        if ( __isPoweredOn )
        {
-               __pCoordinator->SetCameraOrientation(orientation);
+               r = SetExifOrientationAttr(orientation);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
        }
        __exifOrientation = orientation;
        return r;
@@ -1802,6 +1803,23 @@ CATCH:
 }
 
 result
+_CameraImpl::SetExifOrientationAttr(CameraExifOrientation orientation)
+{
+       result r = E_SUCCESS;
+       int err = MM_SUCCESS;
+       camera_attr_tag_orientation_e attr = ::CAMERA_ATTR_TAG_ORIENTATION_TOP_LEFT;
+
+       r = _CameraUtil::GetMmExifOrientation(orientation, attr);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating. orientation:%d", GetErrorMessage(r), orientation);
+
+       err = camera_attr_set_tag_orientation(__handle, attr);
+       r = ConvertResult(err);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating. orientation:%d", GetErrorMessage(r), orientation);
+
+       return r;
+}
+
+result
 _CameraImpl::SetExifGpsCoordinates(double latitude, double longitude, float altitude)
 {
        result r = E_SUCCESS;
@@ -2590,7 +2608,8 @@ _CameraImpl::ReloadConfiguration(int reload)
        }
        if ((reload & _RELOAD_EXIF_ORIENTATION) && (__exifOrientation != CAMERA_EXIF_ORIENTATION_NONE))         //TODO check whether the exif data is lasting or one-time.
        {
-               __pCoordinator->SetCameraOrientation(__exifOrientation);
+               r = SetExifOrientationAttr(__exifOrientation);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
        }
        if (reload & _RELOAD_EXIF_GPS_COORDINATES)
        {
index d72a991..0bfed08 100755 (executable)
@@ -968,6 +968,17 @@ public:
        result SetExifOrientation(CameraExifOrientation orientation);
 
        /**
+       * Sets the orientation of the camera.
+       *
+       * @return               An error code
+       * @param[in]    orientation                     The orientation of the camera
+       * @exception    E_SUCCESS                       The method is successful.
+       * @exception    E_INVALID_STATE         This method is invalid for the current state of this instance.
+       * @exception    E_INVALID_ARG           The specified @c rotation is not supported.
+       */
+       result SetExifOrientationAttr(CameraExifOrientation orientation);
+
+       /**
        * Sets the GPS coordinates in the Exchangeable Image File Format (EXIF) field for the captured data.
        *
        * @return               An error code
index 02e6f4c..2273e0a 100755 (executable)
@@ -39,6 +39,8 @@
 #include "FMedia_CamPtrUtil.h"
 #include "FMedia_AudioStreamCoordinator.h"
 
+//#define _VIDEO_RECORDER_ROTATION_
+
 using namespace Tizen::Base;
 using namespace Tizen::Base::Collection;
 using namespace Tizen::Graphics;
@@ -1081,9 +1083,10 @@ _VideoRecorderImpl::SetRecordingRotation(RecordingRotation rotation)
        SysTryReturn(NID_MEDIA, (rotation >= RECORDING_ROTATION_NONE&& rotation <= RECORDING_ROTATION_270)
                           , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(rotation) is used. The rotation=%d.", rotation);
 
-       __pCoordinator->SetRecordingOrientation(rotation);
-       __rotation = rotation;
+       r = SetRecordingOrientationAttr(rotation);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s]  propogated", GetErrorMessage(r));
 
+       __rotation = rotation;
        return r;
 }
 
@@ -1199,6 +1202,28 @@ CATCH:
 }
 
 result
+_VideoRecorderImpl::SetRecordingOrientationAttr(RecordingRotation rotation)
+{
+       result r = E_SUCCESS;
+       int err = MM_SUCCESS;
+       recorder_rotation_e mmAttr = ::RECORDER_ROTATION_NONE;
+       r = _RecorderUtil::GetMmRotation(rotation, mmAttr);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating. rotation:%d", GetErrorMessage(r), rotation);
+
+#if _VIDEO_RECORDER_ROTATION_
+       err = recorder_attr_set_recording_orientation(__handle, mmAttr);
+       r = ConvertResult(err);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Camcorder set attribute failed. rotation:%d", GetErrorMessage(r), rotation);
+#else
+       err = recorder_attr_set_orientation_tag(__handle, mmAttr);
+       r = ConvertResult(err);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Camcorder set attribute failed. rotation:%d", GetErrorMessage(r), rotation);
+#endif
+
+       return r;
+}
+
+result
 _VideoRecorderImpl::SetCallback(void)
 {
        result r = E_SUCCESS;
@@ -1659,7 +1684,8 @@ _VideoRecorderImpl::ReloadConfiguration(int reload)
        }
        if (reload & _RELOAD_ROTATION)
        {
-               __pCoordinator->SetRecordingOrientation(__rotation);
+               r = SetRecordingOrientationAttr(__rotation);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] video recorder set orientation failed", GetErrorMessage(r));
        }
 
        return r;
index e678e0f..aa8a29c 100755 (executable)
@@ -835,6 +835,17 @@ private:
        result SetMaxRecordingTimeAttr(long msTime);
 
        /**
+       * Sets the orientation of the recorder.
+       *
+       * @return               An error code
+       * @param[in]    rotation                        The rotation of the recorder
+       * @exception    E_SUCCESS                       The method is successful.
+       * @exception    E_INVALID_STATE         This method is invalid for the current state of this instance.
+       * @exception    E_INVALID_ARG           The specified @c rotation is not supported.
+       */
+       result SetRecordingOrientationAttr(RecordingRotation rotation);
+
+       /**
        * Sets the callback of the recorder.
        *
        * @return               An error code