f19578ecfd46009ebc4cc1ea678c77ef97cd58ec
[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          * 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 ~_RecorderManager(void);
53
54         /**
55         * Get the instance of _RecorderManager.
56         *
57         * @return               The _RecorderManager instance
58         * @param[in]    recorderDevice                  The recorder 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 _RecorderManager* AddInstance(_RecorderDeviceType recorderDevice);
65
66         /**
67         * Release the specific _RecorderManager.
68         *
69         * @param[in]    recorderDevice                  The recorder device type.
70         */
71         static void Release(_RecorderDeviceType recorderDevice);
72
73         /**
74         * Get the instance of _RecorderManager if it exists.
75         *
76         * @return               The _RecorderManager instance
77         * @param[in]    recorderDevice                  The recorder device id.
78         * @exception    E_SUCCESS                               The method is successful.
79         * @exception    E_SYSTEM                                A system error has occurred.
80         */
81         static _RecorderManager* HasInstance(_RecorderDeviceType recorderDevice);
82
83         /**
84         * Gets the recorder's handle
85         *
86         * @return               The handle of camera
87         */
88         _RecorderHandle GetHandle(void) const;
89
90 private:
91         friend class _RecorderManagerSafeHashMapT;
92         /**
93          * This is the default constructor for this class.
94          *
95          * @remarks             After creating an instance of this class, the Construct() method must be called explicitly to
96          * initialize this instance.
97          * @see                 Construct()
98          */
99         _RecorderManager(void);
100
101         /**
102         * Initializes this instance of _RecorderManager.
103         *
104         * @return               An error code
105         * @param[in]    cameraDevice                    The camera device id.
106         * @param[in]    recorderDevice          The recorder device id.
107         * @exception    E_SUCCESS                               The method is successful.
108         * @exception    E_SYSTEM                                A system error has occurred.
109         * @exception    E_DEVICE_BUSY                   The device cannot be approached because of other operations.
110         * @exception    E_DEVICE_UNAVAILABLE    The device is unavailable.
111         */
112         result Construct(_CameraDeviceType cameraDevice, _RecorderDeviceType recorderDevice);
113
114         /**
115         * Converts the error from recorder to Result.
116         *
117         * @return          An error code
118         * @param[in]    err                      recorder error
119         */
120         result ConvertResult(int err) const;
121
122         _RecorderManager(const _RecorderManager& camera);
123         _RecorderManager& operator =(const _RecorderManager& camera);
124
125         static void InitSafeHashMapInst(void);
126
127         _RecorderHandle __handle;
128
129         static _RecorderManagerSafeHashMapT* __pMap;
130 };
131
132 /**
133 * @class        _RecorderManagerSafeHashMapT
134 * @brief        This class is for handling safe HashMap.
135 *
136 */
137 class _RecorderManagerSafeHashMapT
138         : public Tizen::Base::Collection::HashMapT<_RecorderDeviceType, _RecorderManager*>
139         , public virtual Tizen::Base::Collection::ICollectionT <Tizen::Base::Collection::MapEntryT <_RecorderDeviceType, _RecorderManager*> >
140 {
141 public:
142         _RecorderManagerSafeHashMapT(void);
143         virtual ~_RecorderManagerSafeHashMapT(void);
144         void RemoveItems(void);
145
146 private:
147         _RecorderManagerSafeHashMapT(const _RecorderManagerSafeHashMapT& rhs);
148         _RecorderManagerSafeHashMapT& operator =(const _RecorderManagerSafeHashMapT& rhs);
149 };
150
151 }}// Tizen::Media
152
153 #endif