23ceba6df05d61abfc605b93675783963991d77b
[platform/framework/native/media.git] / src / inc / FMedia_CapabilityImpl.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_CapabilityImpl.h
20  * @brief                       This is the header file for the _CapabilityImpl class.
21  *
22  * This header file contains the declarations of the _CapabilityImpl class.
23  */
24
25 #ifndef _FMEDIA_INTERNAL_CAPABILITY_IMPL_H_
26 #define _FMEDIA_INTERNAL_CAPABILITY_IMPL_H_
27
28 #include <unique_ptr.h>
29 #include <libxml/tree.h>
30 #include <FBaseColIList.h>
31 #include <FBaseColHashMap.h>
32
33 namespace Tizen { namespace Media
34 {
35 _OSP_EXPORT_ extern const wchar_t* const AUDIORECORDER_CODEC_TYPE;
36 _OSP_EXPORT_ extern const wchar_t* const AUDIORECORDER_MEDIA_CONTAINER_TYPE;
37 _OSP_EXPORT_ extern const wchar_t* const VIDEORECORDER_AUDIO_CODEC_TYPE;
38 _OSP_EXPORT_ extern const wchar_t* const VIDEORECORDER_VIDEO_CODEC_TYPE;
39 _OSP_EXPORT_ extern const wchar_t* const VIDEORECORDER_MEDIA_CONTAINER_TYPE;
40 _OSP_EXPORT_ extern const wchar_t* const VIDEORECORDER_CODEC;
41
42 _OSP_EXPORT_ extern const wchar_t* const CAMERA_PRIMARY_ZOOM_LEVEL;
43 _OSP_EXPORT_ extern const wchar_t* const CAMERA_PRIMARY_FOCUS_POINT;
44 _OSP_EXPORT_ extern const wchar_t* const CAMERA_SECONDARY_ZOOM_LEVEL;
45 _OSP_EXPORT_ extern const wchar_t* const CAMERA_SECONDARY_FOCUS_POINT;
46
47 enum _MediaCapValueType
48 {
49         _MEDIA_CAP_VALUE_TYPE_BOOL,
50         _MEDIA_CAP_VALUE_TYPE_INT,
51         _MEDIA_CAP_VALUE_TYPE_LONG_LONG,
52         _MEDIA_CAP_VALUE_TYPE_DOUBLE,
53         _MEDIA_CAP_VALUE_TYPE_STRING,
54         _MEDIA_CAP_VALUE_TYPE_LIST,
55 };
56
57 enum _MediaCapCategoryType
58 {
59         _MEDIA_CAP_CATEGORY_NONE,
60         _MEDIA_CAP_CATEGORY_AUDIO,
61         _MEDIA_CAP_CATEGORY_IMAGE,
62         _MEDIA_CAP_CATEGORY_PLAYER,
63         _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA,
64         _MEDIA_CAP_CATEGORY_SECONDARY_CAMERA,
65         _MEDIA_CAP_CATEGORY_VIDEO_RECORDER,
66         _MEDIA_CAP_CATEGORY_AUDIO_RECORDER,
67         _MEDIA_CAP_CATEGORY_CODEC,
68 };
69
70 /**
71  * @class       _CapabilityImpl
72  * @brief       This class provides parsing class for MediaCapability class.
73  */
74 class _CapabilityImpl
75         : public Tizen::Base::Object
76 {
77 public:
78         static _CapabilityImpl* GetInstance(void);
79
80         /**
81         *       Initializes this instance of _CapabilityImpl.
82         *
83         *       @return         E_SUCCESS in success, an error code in failure
84         *
85         *       @exception      E_SUCCESS                                               The method was successful.
86         *       @exception      E_INVALID_STATE                                 This instance is in an invalid state for this method.
87         *       @exception      E_SYSTEM                                                A system error occurred.
88         */
89         result Construct(void);
90
91         /**
92         *       Get capability value in Media.
93         *
94         *       @return         E_SUCCESS in success, an error code in failure
95         *
96         *       @exception      E_SUCCESS                                               The method was successful.
97         *       @exception      E_OBJ_NOT_FOUND                 The specified key was not found.
98         *       @exception      E_INVALID_STATE                                 This instance is in an invalid state for this method.
99         *       @exception      E_SYSTEM                                                A system error occurred.
100         */
101         result GetValue(const Tizen::Base::String& key, bool& value);
102
103         /**
104         *       Get capability value in Media.
105         *
106         *       @return         E_SUCCESS in success, an error code in failure
107         *
108         *       @exception      E_SUCCESS                                               The method was successful.
109         *       @exception      E_OBJ_NOT_FOUND                 The specified key was not found.
110         *       @exception      E_INVALID_STATE                                 This instance is in an invalid state for this method.
111         *       @exception      E_SYSTEM                                                A system error occurred.
112         */
113         result GetValue(const Tizen::Base::String& key, int& value);
114
115
116         /**
117         *       Get capability value in Media.
118         *
119         *       @return         E_SUCCESS in success, an error code in failure
120         *
121         *       @exception      E_SUCCESS                                               The method was successful.
122         *       @exception      E_OBJ_NOT_FOUND                 The specified key was not found.
123         *       @exception      E_INVALID_STATE                                 This instance is in an invalid state for this method.
124         *       @exception      E_SYSTEM                                                A system error occurred.
125         */
126         result GetValue(const Tizen::Base::String& key, long long& value);
127
128         /**
129         *       Get capability value in Media.
130         *
131         *       @return         E_SUCCESS in success, an error code in failure
132         *
133         *       @exception      E_SUCCESS                                               The method was successful.
134         *       @exception      E_OBJ_NOT_FOUND                 The specified key was not found.
135         *       @exception      E_INVALID_STATE                                 This instance is in an invalid state for this method.
136         *       @exception      E_SYSTEM                                                A system error occurred.
137         */
138         result GetValue(const Tizen::Base::String& key, double& value);
139
140         /**
141         *       Get capability value in Media.
142         *
143         *       @return         E_SUCCESS in success, an error code in failure
144         *
145         *       @exception      E_SUCCESS                                               The method was successful.
146         *       @exception      E_OBJ_NOT_FOUND                 The specified key was not found.
147         *       @exception      E_INVALID_STATE                                 This instance is in an invalid state for this method.
148         *       @exception      E_SYSTEM                                                A system error occurred.
149         */
150         result GetValue(const Tizen::Base::String& key, Tizen::Base::String& value);
151
152         /**
153         *       Get capability value in Media.
154         *
155         *       @return         E_SUCCESS in success, an error code in failure
156         *
157         *       @exception      E_SUCCESS                                               The method was successful.
158         *       @exception      E_OBJ_NOT_FOUND                 The specified key was not found.
159         *       @exception      E_INVALID_STATE                                 This instance is in an invalid state for this method.
160         *       @exception      E_SYSTEM                                                A system error occurred.
161         */
162         result GetValueN(const Tizen::Base::String& key, Tizen::Base::Collection::IList& value);
163
164
165         /**
166         *       Convert char to integer
167         *
168         *       @return         Tizen::Base::Object*
169         *
170         *       @exception      E_SUCCESS                                               The method was successful.
171         *       @exception      E_OBJ_NOT_FOUND                 The specified key was not found.
172         *       @exception      E_OUT_OF_MEMORY                                 The memory is insufficient.
173         *       @exception      E_SYSTEM                                                A system error occurred.
174         */
175         static Tizen::Base::Object* ConvertCharToInteger(const char* input, Object* pObj, const void* param);
176
177         /**
178         *       Convert char to string
179         *
180         *       @return         Tizen::Base::Object*
181         *
182         *       @exception      E_SUCCESS                                               The method was successful.
183         *       @exception      E_OBJ_NOT_FOUND                 The specified key was not found.
184         *       @exception      E_OUT_OF_MEMORY                                 The memory is insufficient.
185         *       @exception      E_SYSTEM                                                A system error occurred.
186         */
187         static Tizen::Base::Object* ConvertCharToString(const char* input, Object* pObj, const void* param);
188
189         /**
190         *       Convert char to enum
191         *
192         *       @return         Tizen::Base::Object*
193         *
194         *       @exception      E_SUCCESS                                               The method was successful.
195         *       @exception      E_OBJ_NOT_FOUND                 The specified key was not found.
196         *       @exception      E_OUT_OF_MEMORY                                 The memory is insufficient.
197         *       @exception      E_SYSTEM                                                A system error occurred.
198         */
199         static Tizen::Base::Object* ConvertCharToEnum(const char* input, Object* pObj, const void* param);
200
201         /**
202         *       Convert char to dimesion
203         *
204         *       @return         Tizen::Base::Object*
205         *
206         *       @exception      E_SUCCESS                                               The method was successful.
207         *       @exception      E_OBJ_NOT_FOUND                 The specified key was not found.
208         *       @exception      E_OUT_OF_MEMORY                                 The memory is insufficient.
209         *       @exception      E_SYSTEM                                                A system error occurred.
210         */
211         static Tizen::Base::Object* ConvertCharToDimension(const char* input, Object* pObj, const void* param);
212
213         /**
214         *       Copy object to list integer type
215         *
216         *       @return         E_SUCCESS in success, an error code in failure
217         *
218         *       @exception      E_SUCCESS                                               The method was successful.
219         *       @exception      E_OBJ_NOT_FOUND                 The specified key was not found.
220         *       @exception      E_INVALID_STATE                                 This instance is in an invalid state for this method.
221         *       @exception      E_OUT_OF_MEMORY                                 The memory is insufficient.
222         *       @exception      E_SYSTEM                                                A system error occurred.
223         */
224         static result CopyListInteger(int type, Object* pObj, void* value);
225
226         /**
227         *       Copy object to list string type
228         *
229         *       @return         E_SUCCESS in success, an error code in failure
230         *
231         *       @exception      E_SUCCESS                                               The method was successful.
232         *       @exception      E_OBJ_NOT_FOUND                 The specified key was not found.
233         *       @exception      E_INVALID_STATE                                 This instance is in an invalid state for this method.
234         *       @exception      E_OUT_OF_MEMORY                                 The memory is insufficient.
235         *       @exception      E_SYSTEM                                                A system error occurred.
236         */
237         static result CopyListString(int type, Object* pObj, void* value);
238
239         /**
240         *       Copy object to demension type
241         *
242         *       @return         E_SUCCESS in success, an error code in failure
243         *
244         *       @exception      E_SUCCESS                                               The method was successful.
245         *       @exception      E_OBJ_NOT_FOUND                 The specified key was not found.
246         *       @exception      E_INVALID_STATE                                 This instance is in an invalid state for this method.
247         *       @exception      E_OUT_OF_MEMORY                                 The memory is insufficient.
248         *       @exception      E_SYSTEM                                                A system error occurred.
249         */
250         static result CopyListDimension(int type, Object* pObj, void* value);
251
252         /**
253         *       Copy object to integer type
254         *
255         *       @return         E_SUCCESS in success, an error code in failure
256         *
257         *       @exception      E_SUCCESS                                               The method was successful.
258         *       @exception      E_OBJ_NOT_FOUND                 The specified key was not found.
259         *       @exception      E_INVALID_STATE                                 This instance is in an invalid state for this method.
260         *       @exception      E_OUT_OF_MEMORY                                 The memory is insufficient.
261         *       @exception      E_SYSTEM                                                A system error occurred.
262         */
263         static result CopyInteger(int type, Object* pObj, void* value);
264
265         /**
266         *       Copy object to bool type
267         *
268         *       @return         E_SUCCESS in success, an error code in failure
269         *
270         *       @exception      E_SUCCESS                                               The method was successful.
271         *       @exception      E_OBJ_NOT_FOUND                 The specified key was not found.
272         *       @exception      E_INVALID_STATE                                 This instance is in an invalid state for this method.
273         *       @exception      E_OUT_OF_MEMORY                                 The memory is insufficient.
274         *       @exception      E_SYSTEM                                                A system error occurred.
275         */
276         static result CopyBool(int type, Object* pObj, void* value);
277
278 protected:
279         /**
280         *       Get capability value in Media.
281         *
282         *       @return         E_SUCCESS in success, an error code in failure
283         *
284         *       @param[in]      key                     The key string for capability lookup
285         *       @param[in]      type            value type
286         *       @param[out]     value           returned capability value
287         *
288         *       @exception      E_SUCCESS                                               The method was successful.
289         *       @exception      E_OBJ_NOT_FOUND                 The specified key was not found.
290         *       @exception      E_INVALID_STATE                                 This instance is in an invalid state for this method.
291         *       @exception      E_SYSTEM                                                A system error occurred.
292         */
293         result GetValue(const Tizen::Base::String& key, int type, void* value);
294
295         /**
296         *       parse the xml file data
297         *       @return         E_SUCCESS in success, an error code in failure
298         *       @param[in]      pXmlBuffer                                              xml file content
299         *       @param[in]      length                                  size of xml buffer
300         *       @exception      E_SUCCESS                                               The method was successful.
301         *       @exception      E_OBJ_NOT_FOUND                 The specified key was not found.
302         *       @exception      E_INVALID_STATE                                 This instance is in an invalid state for this method.
303         *       @exception      E_SYSTEM                                                A system error occurred.
304         */
305         result ParseCapability(const char* pXmlBuffer, int length);
306
307         /**
308         *       parse the xml node data
309         *       @param[in]      pRoot                                            xml start tag node
310         *       @param[in]      section                              section name
311         */
312         void ParseSection(xmlNode* pRoot, const Tizen::Base::String& section);
313
314 private:
315         /**
316         *       This is the default constructor for this class.
317         *
318         *       @remarks        After creating an instance of this class, you must explicitly call one of
319         *                               the Construct() methods to initialize the instance.
320         *       @see            Construct()
321         */
322         _CapabilityImpl(void);
323
324         /**
325         *       This is the destructor for this class. @n
326         *       Resources are deallocated by this method.
327         *       This method should be called in the same thread as Construct() method
328         *
329         *       @see            Construct()
330         */
331         virtual ~_CapabilityImpl(void);
332
333         /**
334         *       copy constructor
335         *       @param[in]      src                                     _CapabilityImpl type object
336         */
337         _CapabilityImpl(const _CapabilityImpl& src);
338
339         /**
340         *       assignment operator overloading
341         *       @param[in]      src                                     _CapabilityImpl type object
342         */
343         _CapabilityImpl& operator =(const _CapabilityImpl& src);
344
345         /**
346         *       parse the capability by the category
347         *       @return         E_SUCCESS in success, an error code in failure
348         *       @param[in]      category                                        the category
349         *       @exception      E_SUCCESS                                               The method was successful.
350         *       @exception      E_INVALID_ARG                 The specified category is not valid.
351         *       @exception      E_INVALID_STATE                                 This instance is in an invalid state for this method.
352         *       @exception      E_SYSTEM                                                A system error occurred.
353         */
354         result ParseCapability(_MediaCapCategoryType category);
355
356         static void InitCapabilityImpl(void);
357
358         std::unique_ptr <Tizen::Base::Collection::HashMap> __pMap;
359         int __cameraCount;
360         bool __primaryCameraDone;
361         bool __secondaryCameraDone;
362         bool __videoRecorderDone;
363         bool __audioRecorderDone;
364
365         static _CapabilityImpl* __pCapabilityImplInst;
366 };
367
368
369 };
370 };  // Tizen::Media
371
372 #endif