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