Tizen 2.1 base
[platform/framework/native/media.git] / src / FMediaCapability.cpp
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         FMediaCapability.cpp
20 * @brief        This file contains the implementation of subsystem's Camera.
21 */
22
23 #include <FMediaCapability.h>
24 #include <FMediaCameraTypes.h>
25 #include <FBaseSysLog.h>
26 #include "FMedia_CapabilityImpl.h"
27
28 using namespace Tizen::Base;
29
30 namespace Tizen { namespace Media
31 {
32
33 const wchar_t* const AUDIOIN_SAMPLE_RATE = L"AudioIn.SampleRate";
34 const wchar_t* const AUDIOIN_SAMPLE_TYPE = L"AudioIn.SampleType";
35
36 const wchar_t* const AUDIOOUT_COUNT_MAX = L"AudioOut.CountMax";
37 const wchar_t* const AUDIOOUT_SAMPLE_RATE = L"AudioOut.SampleRate";
38 const wchar_t* const AUDIOOUT_SAMPLE_TYPE = L"AudioOut.SampleType";
39
40 const wchar_t* const AUDIORECORDER_FORMAT = L"AudioRecorder.Format";
41
42 const wchar_t* const CAMERA_COUNT = L"Camera.Count";
43 const wchar_t* const CAMERA_PRIMARY_CAPTURE_FORMAT = L"Camera.Primary.CaptureFormat";
44 const wchar_t* const CAMERA_PRIMARY_CAPTURE_RESOLUTION = L"Camera.Primary.CaptureResolution";
45 const wchar_t* const CAMERA_PRIMARY_DIRECTION = L"Camera.Primary.Direction";
46 const wchar_t* const CAMERA_PRIMARY_EFFECT = L"Camera.Primary.Effect";
47 const wchar_t* const CAMERA_PRIMARY_ISO_LEVEL = L"Camera.Primary.IsoLevel";
48 const wchar_t* const CAMERA_PRIMARY_PREVIEW_FORMAT = L"Camera.Primary.PreviewFormat";
49 const wchar_t* const CAMERA_PRIMARY_PREVIEW_FRAMERATE = L"Camera.Primary.PreviewFrameRate";
50 const wchar_t* const CAMERA_PRIMARY_PREVIEW_RESOLUTION = L"Camera.Primary.PreviewResolution";
51 const wchar_t* const CAMERA_PRIMARY_RECORDING_RESOLUTION = L"Camera.Primary.RecordingResolution";
52 const wchar_t* const CAMERA_PRIMARY_ROTATION = L"Camera.Primary.Rotation";
53 const wchar_t* const CAMERA_PRIMARY_SUPPORT_BRIGHTNESS = L"Camera.Primary.SupportBrightness";
54 const wchar_t* const CAMERA_PRIMARY_SUPPORT_CAPTURE = L"Camera.Primary.SupportCapture";
55 const wchar_t* const CAMERA_PRIMARY_SUPPORT_CONTRAST = L"Camera.Primary.SupportContrast";
56 const wchar_t* const CAMERA_PRIMARY_SUPPORT_EXPOSURE = L"Camera.Primary.SupportExposure";
57 const wchar_t* const CAMERA_PRIMARY_SUPPORT_FLASH = L"Camera.Primary.SupportFlash";
58 const wchar_t* const CAMERA_PRIMARY_SUPPORT_FOCUS = L"Camera.Primary.SupportFocus";
59 const wchar_t* const CAMERA_PRIMARY_SUPPORT_PREVIEW = L"Camera.Primary.SupportPreview";
60 const wchar_t* const CAMERA_PRIMARY_SUPPORT_RECORDING = L"Camera.Primary.SupportRecording";
61 const wchar_t* const CAMERA_PRIMARY_SUPPORT_ZOOM = L"Camera.Primary.SupportZoom";
62 const wchar_t* const CAMERA_PRIMARY_SUPPORT_ZERO_SHUTTER_LAG = L"Camera.Primary.SupportZeroShutterLag";
63 const wchar_t* const CAMERA_PRIMARY_WHITE_BALANCE = L"Camera.Primary.WhiteBalance";
64 const wchar_t* const CAMERA_PRIMARY_ZOOM_TYPE = L"Camera.Primary.ZoomType";
65 const wchar_t* const CAMERA_PRIMARY_FLIP = L"Camera.Primary.Flip";
66 const wchar_t* const CAMERA_PRIMARY_PREVIEW_ROTATION = L"Camera.Primary.PreviewRotation";
67 const wchar_t* const CAMERA_PRIMARY_FOCUS_MODE = L"Camera.Primary.FocusMode";
68 const wchar_t* const CAMERA_PRIMARY_FOCUS_POINT = L"Camera.Primary.FocusPoint";
69 const wchar_t* const CAMERA_PRIMARY_FLASH_MODE = L"Camera.Primary.FlashMode";
70 const wchar_t* const CAMERA_PRIMARY_DEFAULT_PREVIEW_FORMAT = L"Camera.Primary.DefaultPreviewFormat";
71 const wchar_t* const CAMERA_PRIMARY_METERING_MODE = L"Camera.Primary.MeteringMode";
72
73 const wchar_t* const CAMERA_SECONDARY_CAPTURE_FORMAT = L"Camera.Secondary.CaptureFormat";
74 const wchar_t* const CAMERA_SECONDARY_CAPTURE_RESOLUTION = L"Camera.Secondary.CaptureResolution";
75 const wchar_t* const CAMERA_SECONDARY_DIRECTION = L"Camera.Secondary.Direction";
76 const wchar_t* const CAMERA_SECONDARY_EFFECT = L"Camera.Secondary.Effect";
77 const wchar_t* const CAMERA_SECONDARY_ISO_LEVEL = L"Camera.Secondary.IsoLevel";
78 const wchar_t* const CAMERA_SECONDARY_PREVIEW_FORMAT = L"Camera.Secondary.PreviewFormat";
79 const wchar_t* const CAMERA_SECONDARY_PREVIEW_FRAMERATE = L"Camera.Secondary.PreviewFrameRate";
80 const wchar_t* const CAMERA_SECONDARY_PREVIEW_RESOLUTION = L"Camera.Secondary.PreviewResolution";
81 const wchar_t* const CAMERA_SECONDARY_RECORDING_RESOLUTION = L"Camera.Secondary.RecordingResolution";
82 const wchar_t* const CAMERA_SECONDARY_ROTATION = L"Camera.Secondary.Rotation";
83 const wchar_t* const CAMERA_SECONDARY_SUPPORT_BRIGHTNESS = L"Camera.Secondary.SupportBrightness";
84 const wchar_t* const CAMERA_SECONDARY_SUPPORT_CAPTURE = L"Camera.Secondary.SupportCapture";
85 const wchar_t* const CAMERA_SECONDARY_SUPPORT_CONTRAST = L"Camera.Secondary.SupportContrast";
86 const wchar_t* const CAMERA_SECONDARY_SUPPORT_EXPOSURE = L"Camera.Secondary.SupportExposure";
87 const wchar_t* const CAMERA_SECONDARY_SUPPORT_FLASH = L"Camera.Secondary.SupportFlash";
88 const wchar_t* const CAMERA_SECONDARY_SUPPORT_FOCUS = L"Camera.Secondary.SupportFocus";
89 const wchar_t* const CAMERA_SECONDARY_SUPPORT_PREVIEW = L"Camera.Secondary.SupportPreview";
90 const wchar_t* const CAMERA_SECONDARY_SUPPORT_RECORDING = L"Camera.Secondary.SupportRecording";
91 const wchar_t* const CAMERA_SECONDARY_SUPPORT_ZOOM = L"Camera.Secondary.SupportZoom";
92 const wchar_t* const CAMERA_SECONDARY_SUPPORT_ZERO_SHUTTER_LAG = L"Camera.Secondary.SupportZeroShutterLag";
93 const wchar_t* const CAMERA_SECONDARY_WHITE_BALANCE = L"Camera.Secondary.WhiteBalance";
94 const wchar_t* const CAMERA_SECONDARY_ZOOM_TYPE = L"Camera.Secondary.ZoomType";
95 const wchar_t* const CAMERA_SECONDARY_FLIP = L"Camera.Secondary.Flip";
96 const wchar_t* const CAMERA_SECONDARY_PREVIEW_ROTATION = L"Camera.Secondary.PreviewRotation";
97 const wchar_t* const CAMERA_SECONDARY_FOCUS_MODE = L"Camera.Secondary.FocusMode";
98 const wchar_t* const CAMERA_SECONDARY_FOCUS_POINT = L"Camera.Secondary.FocusPoint";
99 const wchar_t* const CAMERA_SECONDARY_FLASH_MODE = L"Camera.Secondary.FlashMode";
100 const wchar_t* const CAMERA_SECONDARY_DEFAULT_PREVIEW_FORMAT = L"Camera.Secondary.DefaultPreviewFormat";
101 const wchar_t* const CAMERA_SECONDARY_METERING_MODE = L"Camera.Secondary.MeteringMode";
102
103 const wchar_t* const PLAYER_AUDIO_CODEC = L"Player.AudioCodec";
104 const wchar_t* const PLAYER_COUNT_MAX = L"Player.CountMax";
105 const wchar_t* const PLAYER_PROTOCOL = L"Player.Protocol";
106 const wchar_t* const PLAYER_VIDEO_CODEC = L"Player.VideoCodec";
107 const wchar_t* const PLAYER_VIDEO_HEIGHT = L"Player.VideoHeight";
108 const wchar_t* const PLAYER_VIDEO_WIDTH = L"Player.VideoWidth";
109
110 const wchar_t* const VIDEORECORDER_AUDIO_CODEC = L"VideoRecorder.AudioCodec";
111 const wchar_t* const VIDEORECORDER_FORMAT = L"VideoRecorder.Format";
112 const wchar_t* const VIDEORECORDER_VIDEO_CODEC = L"VideoRecorder.VideoCodec";
113
114 MediaCapability::MediaCapability()
115 :__pImpl(null)
116 {
117 }
118
119 MediaCapability::~MediaCapability()
120 {
121 }
122
123 result
124 MediaCapability::GetValue(const Tizen::Base::String& key, bool& value)
125 {
126         result r = E_SUCCESS;
127         ClearLastResult();
128         _CapabilityImpl* pImpl = _CapabilityImpl::GetInstance();
129
130         SysTryCatch(NID_MEDIA, pImpl != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  Internal object is not found.");
131
132         return pImpl->GetValue(key, value);
133
134 CATCH:
135         return r;
136 }
137
138 result
139 MediaCapability::GetValue(const Tizen::Base::String& key, int& value)
140 {
141         result r = E_SUCCESS;
142         ClearLastResult();
143         _CapabilityImpl* pImpl = _CapabilityImpl::GetInstance();
144         SysTryCatch(NID_MEDIA, pImpl != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  Internal object is not found.");
145
146         return pImpl->GetValue(key, value);
147 CATCH:
148         return r;
149 }
150
151 result
152 MediaCapability::GetValue(const Tizen::Base::String& key, long long& value)
153 {
154         result r = E_SUCCESS;
155         ClearLastResult();
156         _CapabilityImpl* pImpl = _CapabilityImpl::GetInstance();
157         SysTryCatch(NID_MEDIA, pImpl != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  Internal object is not found.");
158
159         return pImpl->GetValue(key, value);
160 CATCH:
161         return r;
162 }
163
164 result
165 MediaCapability::GetValue(const Tizen::Base::String& key, double& value)
166 {
167         result r = E_SUCCESS;
168         ClearLastResult();
169         _CapabilityImpl* pImpl = _CapabilityImpl::GetInstance();
170         SysTryCatch(NID_MEDIA, pImpl != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  Internal object is not found.");
171
172         return pImpl->GetValue(key, value);
173 CATCH:
174         return r;
175 }
176
177 result
178 MediaCapability::GetValue(const Tizen::Base::String& key, Tizen::Base::String& value)
179 {
180         result r = E_SUCCESS;
181         ClearLastResult();
182         _CapabilityImpl* pImpl = _CapabilityImpl::GetInstance();
183         SysTryCatch(NID_MEDIA, pImpl != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  Internal object is not found.");
184
185         return pImpl->GetValue(key, value);
186 CATCH:
187         return r;
188 }
189
190 Tizen::Base::Collection::IList*
191 MediaCapability::GetValueN(const Tizen::Base::String& key)
192 {
193         result r = E_SUCCESS;
194         Tizen::Base::Collection::ArrayList* pList = null;
195         ClearLastResult();
196
197         _CapabilityImpl* pImpl = _CapabilityImpl::GetInstance();
198         SysTryCatch(NID_MEDIA, pImpl != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  Internal object is not found.");
199
200         pList = new (std::nothrow) Tizen::Base::Collection::ArrayList();
201         SysTryCatch(NID_MEDIA, pList !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The object is not created.");
202
203         r = pList->Construct();
204         SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
205
206         r = pImpl->GetValueN(key, *pList);
207         SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
208
209         return pList;
210
211 CATCH:
212         if (pList != null)
213         {
214                 delete pList;
215         }
216
217         return null;
218 }
219
220
221 }}// Tizen::Media