enable dual camera
[platform/framework/native/media.git] / src / FMedia_CameraImpl.h
index 4ed5401..cb64cb4 100755 (executable)
@@ -24,6 +24,7 @@
 #ifndef _FMEDIA_INTERNAL_CAMERA_IMPL_H_
 #define _FMEDIA_INTERNAL_CAMERA_IMPL_H_
 
+#include <unique_ptr.h>
 #include <camera.h>
 #include <FBaseColIList.h>
 #include <FBaseColIListT.h>
 #include <FGrpRectangle.h>
 #include <FMediaCameraTypes.h>
 #include <FMediaTypes.h>
+#include <FMediaIVideoStreamFilter.h>
 #include "FMedia_CameraTypes.h"
 #include "FMedia_CapabilityTypes.h"
 #include "FMedia_ICameraCoordinatorListener.h"
 #include "FMedia_CameraBuffer.h"
+#include "FMedia_CamPtrUtil.h"
 
 namespace Tizen { namespace Media
 {
 class Camera;
 class ICameraEventListener;
+class _CameraRef;
 class _CameraEvent;
 class _CameraCoordinator;
 class _CameraCapability;
 class _ImageUtilImpl;
-
-typedef void (*_CameraPreprocessingCallback)( MediaPixelFormat format, byte* data[4], int size[4], void* user);
+class _VideoStreamCoordinator;
 
 /**
  * @class      _CameraImpl
@@ -966,6 +969,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
@@ -1091,6 +1105,55 @@ public:
        CameraMeteringMode GetMeteringMode(void) const;
 
        /**
+        * Sets the scene mode of the camera.
+        *
+        * @return             An error code
+        * @param[in]       sceneMode                                                  The scene mode
+        * @exception       E_SUCCESS                                                               The method is successful.
+        * @exception       E_INVALID_STATE                                         This instance is in an invalid state for this method.
+        * @exception       E_DEVICE_BUSY                                            The camera is under use by other application.
+        * @exception       E_DEVICE_UNAVAILABLE                  The camera becomes unavailable.
+        * @exception       E_DEVICE_FAILED                                         The device operation has failed.
+        * @exception       E_INVALID_ARG                                            The specified scene mode is invalid.
+        * @exception       E_UNSUPPORTED_OPERATION         The target device does not support scene mode configuration feature.
+        * @exception       E_UNSUPPORTED_TYPE                      The specified @c sceneMode is not supported.
+        * @remarks             In a specific scene mode, camera's attributes such as brightness, metering mode, iso level, white balance, flash and focus  are changed to the ones which are pre-defined by each scene mode.@n
+        *                         In a specific scene mode, if an application sets any attribute which is related to the scene, the mode can be changed to ::CAMERA_SCENE_OFF.@n
+        *                         Thus it is recommended that the application checks the current scene mode after setting the attributes.@n
+        *                         In case that the scene mode is changed to ::CAMERA_SCENE_OFF, all the attributes set by the application are re-loaded.@n
+        */
+        result SetSceneMode(CameraSceneMode sceneMode);
+
+        /**
+        * Adds the stream filter to process the video stream data while previewing or recording.
+        *
+        * @return               An error code
+        * @param[in]    filter                  An instance of IVideoStreamFilter
+        * @exception    E_SUCCESS                       The method is successful.
+        * @exception    E_OBJ_ALREADY_EXIST     The filter already exists.
+        * @exception    E_OUT_OF_MEMORY         The memory is insufficient.
+        * @remarks IVideoStreamFilter::ProcessVideoStream() will be called when the video frame is ready.
+        */
+        result AddVideoStreamFilter(IVideoStreamFilter& filter);
+
+        /**
+        * Removes the stream filter to stop receiving the video stream data.
+        *
+        * @return               An error code
+        * @param[in]    filter                  An instance of IVideoStreamFilter
+        * @exception    E_SUCCESS                       The method is successful.
+        * @exception    E_OBJ_NOT_FOUND                The filter is not found.
+        */
+        result RemoveVideoStreamFilter(IVideoStreamFilter& filter);
+
+        /**
+        * Gets the scene mode of the camera.
+        *
+        * @return                         The %Camera scene mode
+        */
+        CameraSceneMode GetSceneMode(void) const;
+
+       /**
        * Gets the camera's state.
        *
        * @return                  The state
@@ -1105,14 +1168,6 @@ public:
        void SetState(CameraState state);
 
        /**
-       * Get the event processing object.
-       *
-       * @return          The event processing object.
-       * @remarks      This event is working synchronously.
-       */
-       _CameraEvent* GetEvent(void) const;
-
-       /**
        * Get the camera selection.
        *
        * @return          The camera selection.
@@ -1120,13 +1175,6 @@ public:
        CameraSelection GetSelection(void) const;
 
        /**
-       * Gets the preview process flag
-       *
-       * @return               The preview processing flag
-       */
-       int GetPreviewProcessing(void) const;
-
-       /**
        * Enqueues the preview or captured data.
        *
        * @return          An error code
@@ -1151,14 +1199,6 @@ public:
        _CameraBuffer* DequeueDataN(_CameraBufferType bufferType);
 
        /**
-       * Gets the queue's element count.
-       *
-       * @return          A count of queue element
-       * @param[in]    bufferType              Queue type
-       */
-       int GetDataCount(_CameraBufferType bufferType);
-
-       /**
        * Gets the camera coordinator.
        *
        * @return          camera coordinator
@@ -1172,6 +1212,14 @@ public:
        */
        bool IsZeroShutterLag(void) const;
 
+
+       /**
+       * Gets the camera's recommened preview format
+       *
+       * @return          recommened preview format
+       */
+       Tizen::Graphics::PixelFormat GetDeviceRecommendPreviewFormat(void) const;
+
        /**
        * Called when the event is received from the %_ICameraCoordinatorListener object.
        *
@@ -1199,20 +1247,11 @@ public:
        result OnCameraCoordinatorModeChanged(_CameraMode mode);
 
        /**
-       * Sets the preprocessing callback fuction pointer.
+       * Called when the other module is removed
        *
-       * @param[in]    pPreProcessCbFunc                       preprocessing callback fuction pointer
-       * @param[in]    pPreProcessUserData                     preprocessing userdata pointer
-       */
-       void SetPreprocessingCb(_CameraPreprocessingCallback pPreProcessCbFunc, void* pPreProcessUserData);
-
-       /**
-       * Gets the preprocessing callback fuction pointer.
-       *
-       * @param[out]   pPreProcessCbFunc                       preprocessing callback fuction pointer
-       * @param[out]   pPreProcessUserData                     preprocessing userdata pointer
+       * @return               An error code
        */
-       void GetPreprocessingCb(_CameraPreprocessingCallback& pPreProcessCbFunc, void*& pPreProcessUserData);
+       result OnCameraCoordinatorOtherRemoved(void);
 
        /**
         *      Function definition for start capture.
@@ -1272,21 +1311,25 @@ public:
         */
        static void InterruptedCb(camera_policy_e policy, camera_state_e previous, camera_state_e current, void *pUserData);
 
+
        /**
-        *      Function definition for focus changed callback.
+        *      Function definition for error callback.
         *
-        *      @param[in]      state                   focus state
+        *      @param[in]      error                   The cause which made the error
+        *      @param[in]      current                 Current state
         *      @param[in]      pUserData               User parameter which is received from user when callback function was set
         *      @remarks        This function is called in the camera created thread.
         */
-       static void FocusStateChangedCb(camera_focus_state_e state, void *pUserData);
+       static void ErrorCb(camera_error_e error, camera_state_e current, void *pUserData);
 
        /**
-        *      Function check fo this object is alive.
+        *      Function definition for focus changed callback.
         *
-        * @return              true if the object is alive, otherwise false.
+        *      @param[in]      state                   focus state
+        *      @param[in]      pUserData               User parameter which is received from user when callback function was set
+        *      @remarks        This function is called in the camera created thread.
         */
-       static bool IsAlive(void);
+       static void FocusStateChangedCb(camera_focus_state_e state, void *pUserData);
 
        /**
         * Gets the Impl instance.
@@ -1359,7 +1402,7 @@ private:
        * @param[in]    reload                            reload configuration field
        * @exception    E_SUCCESS                               The method is successful.
        * @exception    E_SYSTEM                                A system error has occurred.
-       * @remarks      Multiple configuration field can be set using reloadConf parameter appending.
+       * @remarks      Multiple configuration field can be set using reload parameter appending.
        */
        result ReloadConfiguration(int reload);
 
@@ -1377,12 +1420,11 @@ private:
        * Change the focus state.
        *
        * @return       An error code
-       * @param[in]    currentMode             focus' current mode
-       * @param[in]    destMode             focus' destinationed mode
+       * @param[in]    focusMode             focus' destinationed mode
        * @exception    E_SUCCESS                               The method is successful.
        * @exception    E_SYSTEM                                A system error has occurred.
        */
-       result ChangeFocusModeTo(CameraFocusMode currentMode, CameraFocusMode destMode);
+       result ChangeFocusModeTo(CameraFocusMode focusMode);
 
        /**
        * Handle the auto focus operations.
@@ -1394,6 +1436,17 @@ private:
        */
        result HandleAutoFocus(CameraFocusMode currentMode);
 
+       /**
+        * Sets the scene mode off.
+        *
+        * @return             An error code
+        * @param[in]       reload                                                  The reload flag
+        * @exception       E_SUCCESS                                                               The method is successful.
+        * @exception       E_DEVICE_FAILED                                         The device operation has failed.
+        * @exception   E_SYSTEM                                A system error has occurred.
+        */
+       result SetSceneModeOff(int reload);
+
        _CameraImpl(const _CameraImpl& camera);
        _CameraImpl& operator =(const _CameraImpl& camera);
 
@@ -1404,10 +1457,12 @@ private:
        CameraState __state;
        _CameraHandle __handle;
 
-       _CameraEvent* __pCameraEvent;
+       std::unique_ptr <_CameraRef> __pCameraRef;
+       std::unique_ptr <_CameraEvent> __pCameraEvent;
+       std::unique_ptr <_VideoStreamCoordinator> __pVideoStreamCoordinator;
        ICameraEventListener* __pCameraEventListener;
-       Tizen::Base::Collection::Queue* __pCaptureBufferQueue;
-       Tizen::Base::Collection::Queue* __pPreviewBufferQueue;
+       std::unique_ptr <Tizen::Base::Collection::Queue, _ListPtrUtil::Remover> __pCaptureBufferQueue;
+       std::unique_ptr <Tizen::Base::Collection::Queue, _ListPtrUtil::Remover> __pPreviewBufferQueue;
 
        bool __isConstructed;
        bool __isPoweredOn;
@@ -1425,6 +1480,7 @@ private:
        CameraFlashMode __flashMode;
        bool __zeroShutterLag;
        CameraMeteringMode __meteringMode;
+       CameraSceneMode __sceneMode;
        bool __focusCallback;
        bool __isFocusAreaSet;
 
@@ -1448,6 +1504,7 @@ private:
        CameraRotation __previewRotation;
        int __fps;
        CameraFocusMode __focusMode;
+       CameraFocusMode __currentFocusMode;
 
        int __previewProcessing;
        Tizen::Graphics::Rectangle __previewRegionRect;
@@ -1460,10 +1517,7 @@ private:
        int __focusPoints[2][MAX_FOCUS_POINT];
        int __supportedFocusPointCount;
 
-       static bool __isUsed;
-
-       _CameraPreprocessingCallback __pPreProcessCbFunc;
-       void* __pPreProcessUserData;
+       static const int MAX_CAMERA_PLANE_COUNT = 4;
 };
 
 }}// Tizen::Media