enable dual camera
[platform/framework/native/media.git] / src / FMedia_CameraManager.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /**
19  * @file                        FMedia_CameraManager.h
20  * @brief                       This header file contains the declarations of the %_CameraManager class.
21  *
22  */
23
24 #ifndef _FMEDIA_INTERNAL_CAMERA_MANAGER_H_
25 #define _FMEDIA_INTERNAL_CAMERA_MANAGER_H_
26
27 #include <FBaseColHashMapT.h>
28 #include "FMedia_CameraTypes.h"
29 #include "FMedia_CameraRefHelper.h"
30
31 namespace Tizen { namespace Media
32 {
33
34 class _CameraManagerSafeHashMapT;
35
36 /**
37  * @class       _CameraManager
38  * @brief       This class implements the _CameraManager class.
39  *
40  */
41 class _CameraManager
42         : public _CameraRefHelper
43 {
44 public:
45         /**
46          * This is the destructor for this class. @n
47          * All allocated resources are deallocated by this method. This method should be called in the same thread
48          * where the Construct() method is called.
49          *
50          * @see                 Construct()
51          */
52         virtual ~_CameraManager(void);
53
54         /**
55         * Get the instance of _CameraManager.
56         *
57         * @return               The _CameraManager instance
58         * @param[in]    cameraDevice                    The camera device id.
59         * @exception    E_SUCCESS                               The method is successful.
60         * @exception    E_SYSTEM                                A system error has occurred.
61         * @exception    E_DEVICE_BUSY                   The device cannot be approached because of other operations.
62         * @exception    E_DEVICE_UNAVAILABLE    The device is unavailable.
63         */
64         static _CameraManager* AddInstance(_CameraDeviceType cameraDevice);
65
66         /**
67         * Release the specific _CameraManager.
68         *
69         * @param[in]    cameraDevice                    The camera device type
70         */
71         static void Release(_CameraDeviceType cameraDevice);
72
73         /**
74         * Gets the camera's handle
75         *
76         * @return               The handle of camera
77         */
78         _CameraHandle GetHandle(void) const;
79
80 private:
81         friend class _CameraManagerSafeHashMapT;
82         /**
83          * This is the default constructor for this class.
84          *
85          * @remarks             After creating an instance of this class, the Construct() method must be called explicitly to
86          * initialize this instance.
87          * @see                 Construct()
88          */
89         _CameraManager(void);
90
91         /**
92         * Initializes this instance of _CameraManager.
93         *
94         * @return               An error code
95         * @param[in]    cameraDevice                            The camera device id.
96         * @exception    E_SUCCESS                               The method is successful.
97         * @exception    E_SYSTEM                                A system error has occurred.
98         * @exception    E_DEVICE_BUSY                   The device cannot be approached because of other operations.
99         * @exception    E_DEVICE_UNAVAILABLE    The device is unavailable.
100         */
101         result Construct(_CameraDeviceType cameraDevice);
102
103         /**
104         * Converts the error from camera to Result.
105         *
106         * @return          An error code
107         * @param[in]    err                      camera error
108         */
109         result ConvertResult(int err) const;
110
111         _CameraManager(const _CameraManager& rhs);
112         _CameraManager& operator =(const _CameraManager& rhs);
113
114         static void InitSingleton(void);
115         static void DestroySingleton(void);
116
117         _CameraHandle __handle;
118
119         static _CameraManagerSafeHashMapT* __pMap;
120 };
121
122 /**
123 * @class        _CameraManagerSafeHashMapT
124 * @brief        This class is for handling safe HashMap.
125 *
126 */
127 class _CameraManagerSafeHashMapT
128         : public Tizen::Base::Collection::HashMapT<_CameraDeviceType, _CameraManager*>
129         , public virtual Tizen::Base::Collection::ICollectionT <Tizen::Base::Collection::MapEntryT <_CameraDeviceType, _CameraManager*> >
130 {
131 public:
132         _CameraManagerSafeHashMapT(void);
133         virtual ~_CameraManagerSafeHashMapT(void);
134         void RemoveItems(void);
135
136 private:
137         _CameraManagerSafeHashMapT(const _CameraManagerSafeHashMapT& rhs);
138         _CameraManagerSafeHashMapT& operator =(const _CameraManagerSafeHashMapT& rhs);
139 };
140
141 }}// Tizen::Media
142
143 #endif