Handling Source adapter
authorKyungYoun <ky99.won@samsung.com>
Mon, 1 Apr 2013 12:54:37 +0000 (21:54 +0900)
committerKyungYoun <ky99.won@samsung.com>
Mon, 1 Apr 2013 12:54:37 +0000 (21:54 +0900)
Change-Id: I551db5dede5ec4b63e590a2266c9367fe8e73dbb
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_ICameraCoordinatorListener.h
src/FMedia_VideoRecorderImpl.cpp
src/FMedia_VideoRecorderImpl.h

index 8c472e1..9002c68 100755 (executable)
@@ -376,6 +376,7 @@ _CameraCoordinator::AddCameraCoordinatorListener(_ICameraCoordinatorListener& li
 {
        result r = E_SUCCESS;
        r = __pListenerList->Add(&listener);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
        return r;
 }
 
@@ -384,6 +385,10 @@ _CameraCoordinator::RemoveCameraCoordinatorListener(_ICameraCoordinatorListener&
 {
        result r = E_SUCCESS;
        r = __pListenerList->Remove(&listener);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       r = NotifyOtherRemoved();
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
        return r;
 }
 
@@ -450,6 +455,28 @@ _CameraCoordinator::NotifyModeChanged(_CameraMode mode)
 }
 
 result
+_CameraCoordinator::NotifyOtherRemoved(void)
+{
+       result r = E_SUCCESS;
+       _ICameraCoordinatorListener* pListener = null;
+       SysLog(NID_MEDIA, "Enter");
+
+       std::unique_ptr <IEnumeratorT <_ICameraCoordinatorListener*> > pEnum (__pListenerList->GetEnumeratorN());
+       SysTryReturn(NID_MEDIA, pEnum.get() != null, GetLastResult(), r, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       while (pEnum->MoveNext() == E_SUCCESS)
+       {
+               r = pEnum->GetCurrent(pListener);
+               SysTryReturn(NID_MEDIA, pListener != null && r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
+                                  "[E_SYSTEM] A system error has been occurred.  The listener is not proper");
+
+               r = pListener->OnCameraCoordinatorOtherRemoved();
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+       return r;
+}
+
+result
 _CameraCoordinator::StartMmPreview(void)
 {
        result r = E_SUCCESS;
index 44924db..f1f29c3 100755 (executable)
@@ -190,6 +190,17 @@ public:
        */
        result NotifyModeChanged(_CameraMode mode);
 
+
+       /**
+       * Notifies the other _ICameraCoordinatorListener is removed
+       *
+       * @return               An error code
+       * @param[in]    mode                    camera mode
+       * @remarks      This mtehod calls _ICameraCoordinatorListener::::OnCameraCoordinatorOtherRemoved().
+       *                       This method will call every _ICameraCoordinatorListener which are registered to _CameraCoordinator.
+       */
+       result NotifyOtherRemoved(void);
+
        /**
        * Start the preview.
        *
index 1a5e222..6a1c214 100755 (executable)
@@ -3033,6 +3033,14 @@ _CameraImpl::OnCameraCoordinatorModeChanged(_CameraMode mode)
        return r;
 }
 
+result
+_CameraImpl::OnCameraCoordinatorOtherRemoved(void)
+{
+       result r = E_SUCCESS;
+       SysLog(NID_MEDIA, "Enter.");
+       return r;
+}
+
 void
 _CameraImpl::StateChangedCb(camera_state_e previous, camera_state_e current, bool byPolicy, void *pUserData)
 {
index 5b828f3..cf90dd2 100755 (executable)
@@ -1235,6 +1235,13 @@ public:
        result OnCameraCoordinatorModeChanged(_CameraMode mode);
 
        /**
+       * Called when the other module is removed
+       *
+       * @return               An error code
+       */
+       result OnCameraCoordinatorOtherRemoved(void);
+
+       /**
         *      Function definition for start capture.
         *
         *      @return         This function returns 0 on success, else on failure.
index 543ff67..f26302c 100755 (executable)
@@ -60,6 +60,13 @@ public:
        */
        virtual result OnCameraCoordinatorModeChanged(_CameraMode mode) = 0;
 
+       /**
+       * Called when the other module is removed
+       *
+       * @return               An error code
+       */
+       virtual result OnCameraCoordinatorOtherRemoved(void) = 0;
+
 };
 
 }}// Tizen::Media
index 4621f80..02e6f4c 100755 (executable)
@@ -170,7 +170,7 @@ _VideoRecorderImpl::~_VideoRecorderImpl(void)
        }
        if (__pCoordinator != null)
        {
-               if (__pVideoSourceAdapter != null)
+               if (__pVideoSourceAdapter.get() != null)
                {
                        if (__pVideoSourceAdapter->GetUserPreviewFormat() != __pCoordinator->GetCameraSourceFormat())
                        {
@@ -421,6 +421,7 @@ _VideoRecorderImpl::Record(void)
        SysTryReturn(NID_MEDIA, state == RECORDER_STATE_OPENED || state == RECORDER_STATE_PAUSED
                           , E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] VideoRecorder is in an invalid state:%d",     state);
 
+       SysTryReturn(NID_MEDIA, __pVideoSourceAdapter.get() != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  The source is deleted.");
        if (__pVideoSourceAdapter->HasRecordingResolutionRestriction())
        {
                SysTryReturn(NID_MEDIA, __recordingResolution == __pVideoSourceAdapter->GetSourceResolution()
@@ -987,6 +988,7 @@ _VideoRecorderImpl::SetRecordingResolution(const Tizen::Graphics::Dimension& res
        SysTryReturn(NID_MEDIA, pList.get() != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  Getting the supported list was failed.\n");
        SysTryReturn(NID_MEDIA, pList->Contains(resolution), E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE]. resolution is out of range. This resolution(%d,%d) is not supported in the device.\n", resolution.width, resolution.height);
 
+       SysTryReturn(NID_MEDIA, __pVideoSourceAdapter.get() != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  The source is deleted.");
        if ( __pVideoSourceAdapter->HasRecordingResolutionRestriction())
        {
                Dimension sourceResolution = __pVideoSourceAdapter->GetSourceResolution();
@@ -1262,6 +1264,15 @@ CATCH:
        return r;
 }
 
+result
+_VideoRecorderImpl::OnCameraCoordinatorOtherRemoved(void)
+{
+       result r = E_SUCCESS;
+       SysLog(NID_MEDIA, "Enter.");
+       __pVideoSourceAdapter.reset(null);
+       return r;
+}
+
 void
 _VideoRecorderImpl::StateChangedCb(recorder_state_e previous, recorder_state_e current, bool byPolicy, void* pUserData)
 {
@@ -1675,6 +1686,7 @@ _VideoRecorderImpl::LoadDefaultConfiguration(int reload)
        // Preview resolution
        if (reload & _RELOAD_RECORD_RESOLUTION)
        {
+               SysTryReturn(NID_MEDIA, __pVideoSourceAdapter.get() != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  The source is deleted.");
                __recordingResolution = __pVideoSourceAdapter->GetSourceResolution();
        }
 
index 2c6270d..e678e0f 100755 (executable)
@@ -544,6 +544,13 @@ public:
        result OnCameraCoordinatorModeChanged(_CameraMode mode);
 
        /**
+       * Called when the other module is removed
+       *
+       * @return               An error code
+       */
+       result OnCameraCoordinatorOtherRemoved(void);
+
+       /**
        * Sets the state.
        *
        * @param[in]    state              new _VideoRecorder's state