Tizen 2.1 base
[platform/framework/native/media.git] / src / FMedia_RecorderManager.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_RecorderManager.h
20  * @brief                       This header file contains the declarations of the %_RecorderManager class.
21  *
22  */
23
24 #ifndef _FMEDIA_INTERNAL_RECORDER_MANAGER_H_
25 #define _FMEDIA_INTERNAL_RECORDER_MANAGER_H_
26
27 #include <memory>
28 #include <FBaseColHashMapT.h>
29 #include "FMedia_RecorderTypes.h"
30 #include "FMedia_CameraTypes.h"
31 #include "FMedia_CameraRefHelper.h"
32
33 namespace Tizen { namespace Media
34 {
35 class _RecorderManagerSafeHashMapT;
36
37 /**
38  * @class       _RecorderManager
39  * @brief       This class implements the _RecorderManager class.
40  */
41 class _RecorderManager
42         : public _CameraRefHelper
43 {
44 public:
45         /**
46         * Get the instance of _RecorderManager.
47         *
48         * @return               The _RecorderManager instance
49         * @param[in]    recorderDevice                  The recorder device id.
50         * @exception    E_SUCCESS                               The method is successful.
51         * @exception    E_SYSTEM                                A system error has occurred.
52         * @exception    E_DEVICE_BUSY                   The device cannot be approached because of other operations.
53         * @exception    E_DEVICE_UNAVAILABLE    The device is unavailable.
54         */
55         static _RecorderManager* AddInstance(_RecorderDeviceType recorderDevice);
56
57         /**
58         * Release the specific _RecorderManager.
59         *
60         * @param[in]    recorderDevice                  The recorder device type.
61         */
62         static void Release(_RecorderDeviceType recorderDevice);
63
64         /**
65         * Gets the recorder's handle
66         *
67         * @return               The handle of camera
68         */
69         _RecorderHandle GetHandle(void) const;
70
71 private:
72         friend class _RecorderManagerSafeHashMapT;
73         /**
74          * This is the default constructor for this class.
75          *
76          * @remarks             After creating an instance of this class, the Construct() method must be called explicitly to
77          * initialize this instance.
78          * @see                 Construct()
79          */
80         _RecorderManager(void);
81
82         /**
83          * This is the destructor for this class. @n
84          * All allocated resources are deallocated by this method. This method should be called in the same thread
85          * where the Construct() method is called.
86          *
87          * @see                 Construct()
88          */
89         virtual ~_RecorderManager(void);
90
91         /**
92         * Initializes this instance of _RecorderManager.
93         *
94         * @return               An error code
95         * @param[in]    cameraDevice                    The camera device id.
96         * @param[in]    recorderDevice          The recorder device id.
97         * @exception    E_SUCCESS                               The method is successful.
98         * @exception    E_SYSTEM                                A system error has occurred.
99         * @exception    E_DEVICE_BUSY                   The device cannot be approached because of other operations.
100         * @exception    E_DEVICE_UNAVAILABLE    The device is unavailable.
101         */
102         result Construct(_CameraDeviceType cameraDevice, _RecorderDeviceType recorderDevice);
103
104         /**
105         * Converts the error from recorder to Result.
106         *
107         * @return          An error code
108         * @param[in]    err                      recorder error
109         */
110         result ConvertResult(int err) const;
111
112         _RecorderManager(const _RecorderManager& camera);
113         _RecorderManager& operator =(const _RecorderManager& camera);
114
115         static void InitSafeHashMapInst(void);
116
117         _RecorderHandle __handle;
118
119         static _RecorderManagerSafeHashMapT* __pMap;
120 };
121
122 /**
123 * @class        _RecorderManagerSafeHashMapT
124 * @brief        This class is for handling safe HashMap.
125 *
126 */
127 class _RecorderManagerSafeHashMapT
128         : public Tizen::Base::Collection::HashMapT<_RecorderDeviceType, _RecorderManager*>
129         , public virtual Tizen::Base::Collection::ICollectionT <Tizen::Base::Collection::MapEntryT <_RecorderDeviceType, _RecorderManager*> >
130 {
131 public:
132         _RecorderManagerSafeHashMapT(void);
133         virtual ~_RecorderManagerSafeHashMapT(void);
134         void RemoveItems(void);
135
136 private:
137         _RecorderManagerSafeHashMapT(const _RecorderManagerSafeHashMapT& rhs);
138         _RecorderManagerSafeHashMapT& operator =(const _RecorderManagerSafeHashMapT& rhs);
139 };
140
141 }}// Tizen::Media
142
143 #endif