2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.1 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://floralicense.org/license/
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 * @file CmCameraPresentationModel.h
19 * @brief This is the header file for CameraPresentationModel class.
22 #ifndef _CM_CAMERA_PRESENTATION_MODEL_H_
23 #define _CM_CAMERA_PRESENTATION_MODEL_H_
34 #include "CmICameraEventListener.h"
36 #include "CmUtility.h"
38 class CameraSettingsPresentationModel;
40 class CameraPresentationModel
41 : public Tizen::Media::ICameraEventListener
42 , public Tizen::Media::IVideoRecorderEventListener
43 , public Tizen::System::IDeviceEventListener
44 ,public Tizen::Content::IContentScanListener
49 CAMERA_MODE_SNAPSHOT = 0,
55 CAMERA_DIRECTION_BACK = 0,
56 CAMERA_DIRECTION_FRONT,
59 enum CamSelfPortraitMode
61 CAM_SELF_PORTRAIT_MODE_PRIMARY,
62 CAM_SELF_PORTRAIT_MODE_SECONDARY,
65 enum AppControlRequestType
67 APP_CONTROL_REQUEST_TYPE_CANCELED = 0,
68 APP_CONTROL_REQUEST_TYPE_SUCCEEDED,
69 APP_CONTROL_REQUEST_TYPE_FAILED
74 STORAGE_CARD_STATE_UNMOUNT = 0,
75 STORAGE_CARD_STATE_MOUNT,
78 enum StorageCardChageState
80 STORAGE_CARD_CHAGE_STATE_UNKNOWN = 0,
81 STORAGE_CARD_CHAGE_STATE_MOUNT_TO_UNMOUNT,
82 STORAGE_CARD_CHAGE_STATE_UNMOUNT_TO_MOUNT,
85 enum DisplayResolution
87 DISPLAY_RESOLUTION_WVGA = 0,
88 DISPLAY_RESOLUTION_HD,
91 static CameraPresentationModel* GetInstance(void);
92 result Construct(void);
93 void Terminate(int mode);
94 result InitializeFlashMode(void);
95 result InitializeCamcorder(void);
96 result InitializeCamera(void);
97 result ToggleCameraCamcorder(int mode);
98 result ToggleCameraDirection(int mode, int direction);
99 bool GetInitCameraStatus(void) const;
100 result SetMode(int mode);
102 int GetContentCount(void);
103 Tizen::Base::String GetContentFilePath(int currentCameraMode);
104 Tizen::Graphics::Bitmap* GetLatestThumbnail(void);
105 result GetLatestContentName(int currentCameraMode, Tizen::Base::String& latestContentName);
106 Tizen::Graphics::Dimension GetPreviewResolution(void) const;
107 result SetPreviewResolution(Tizen::Graphics::Dimension previewResolution);
108 Tizen::Graphics::Dimension GetCaptureResolution(void) const;
109 result SetCaptureResolution(Tizen::Graphics::Dimension captureResolution);
110 Tizen::Graphics::Dimension GetRecordingResolution(void) const;
111 result SetRecordingResolution(Tizen::Graphics::Dimension captureResolution);
112 Tizen::Base::Collection::IList* GetCaptureResolutionList(void);
113 Tizen::Base::Collection::IList* GetPreviewResolutionList(void);
114 Tizen::Base::Collection::IList* GetRecordingResolutionList(void);
116 bool IsPreviewState(void);
117 bool IsCameraInstance(void);
118 bool IsCameraPoweredOn(void);
119 bool IsStorageCardMounted(void) const;
120 bool IsCharging(void);
121 bool GetStartPreviewException(void);
122 bool GetPreviewState(void) const;
123 void StartPreview(const Tizen::Graphics::BufferInfo* pBufferInfo);
124 void StopPreview(void);
125 void StopCamera(void);
127 long GetMaxRecordingTime(void);
128 long GetRecordingSize(void);
129 void StartRecord(void);
130 void SetCancelRecord(bool isCancel);
131 bool GetCancelRecord(void);
132 result StopRecord(void);
133 void CloseRecord(void);
134 void CancelRecord(void);
135 void PauseRecord(void);
136 void SetFocusMode(Tizen::Media::CameraFocusMode mode);
137 void SetContinuousAutoFocus(void);
138 void SetAutoFocusPoint(const Tizen::Graphics::Point& currentPosition);
139 void SetStartPreviewException(bool status);
141 Tizen::Media::CameraFlipType GetFlip(void) const;
142 void SetFlip(Tizen::Media::CameraFlipType type);
144 int GetExposure(void) const;
145 void SetExposure(int exposureValue);
146 int GetBrightness(void) const;
147 void SetBrightness(int brightnessValue);
148 Tizen::Media::CameraWhiteBalance GetWhiteBalance(void) const;
149 result SetWhiteBalance(Tizen::Media::CameraWhiteBalance whitebalanceValue);
150 Tizen::Base::Collection::IList* GetIsoList(void);
151 Tizen::Media::CameraIsoLevel GetIsoLevel(void) const;
152 void SetIsoLevel(Tizen::Media::CameraIsoLevel isoValue);
153 int GetMaxZoomLevel(void) const;
154 int GetZoomLevel(void) const;
155 void SetZoomValue(int zoomValue);
156 Tizen::Media::CameraFlashMode GetFlashMode(void) const;
157 result SetFlashModeOnRecord(bool flashOn);
158 result SetFlashMode(Tizen::Media::CameraFlashMode mode);
159 Tizen::Ui::OrientationStatus GetOrientation(void) const;
160 void SetOrientation(Tizen::Ui::OrientationStatus dir);
161 int GetAppControlRequestType(void) const;
162 void SetAppControlRequestType(int requestType);
163 Tizen::Base::String GetErrorResult(void) const;
164 void SetErrorResult(const Tizen::Base::String& string);
166 int GetStorageCardState(void) const;
167 void SetStorageCardState(int storageCardState);
168 int GetStorageCardChageState(void) const;
169 void SetStorageCardChageState(int storageCardChageState);
170 void UpdateThumbnail(int currentCameraMode);
172 Tizen::System::BatteryLevel GetBatteryLevel(void) const;
173 Tizen::Media::CameraState GetCameraState(void) const;
174 Tizen::Media::RecorderState GetRecorderState(void) const;
175 long long GetAvailableStorageSpace(void) const;
178 result SetExifOrientation(int orientation);
179 void KeepScreenOnState(bool keepOn, bool dimming);
181 void AddPresentationChangedEventListener(ICameraEventListner& pObserverListener);
182 void RemovePresentationChangedEventListener(ICameraEventListner* pObserverListener);
183 void CallOnPresentationModeChanged(CameraActionEvent event);
185 bool GetOnVideoRecorderStopped(void);
186 void SetOnVideoRecorderStopped(bool isCompleted);
188 bool GetIntervalTimerRun(void) const;
189 void SetIntervalTimerRun(bool intervalTimerRun);
191 result ResetCameraSettingsRegistry(void);
192 result ResetCameraSettings(void);
193 result GetValue(const Tizen::Base::String& entryName, int& value) const;
194 result SetValue(const Tizen::Base::String& entryName, int value);
195 result GetMediaCapability(Tizen::Base::String key, bool& value) const;
196 result GetMediaCapability(Tizen::Base::String key, int& value) const;
197 result GetMediaCapability(Tizen::Base::String key) const;
199 void SetDisplayResolutionType(int type);
200 int GetDisplayResolutionType(void);
201 bool IsExistThumbnail(int currentCameraMode);
202 Tizen::Base::String GetfilePath(int storageType);
203 Tizen::Base::Collection::ArrayList* GetContentPathListN(int mode);
205 virtual void OnCameraAutoFocused(bool completeCondition);
206 virtual void OnCameraPreviewed(Tizen::Base::ByteBuffer& previewedData, result r);
207 virtual void OnCameraCaptured(Tizen::Base::ByteBuffer& capturedData, result r);
208 virtual void OnCameraErrorOccurred(Tizen::Media::CameraErrorReason r);
210 virtual void OnVideoRecorderCanceled(result r);
211 virtual void OnVideoRecorderClosed(result r);
212 virtual void OnVideoRecorderEndReached(Tizen::Media::RecordingEndCondition endCondition);
213 virtual void OnVideoRecorderErrorOccurred(Tizen::Media::RecorderErrorReason r);
214 virtual void OnVideoRecorderPaused(result r);
215 virtual void OnVideoRecorderStarted(result r);
216 virtual void OnVideoRecorderStopped(result r);
218 virtual void OnDeviceStateChanged(Tizen::System::DeviceType deviceType, const Tizen::Base::String& state);
219 virtual void OnContentScanCompleted (RequestId reqId, const Tizen::Base::String &scanPath, result r);
221 void UpdateContentFile(void);
222 void SetRecordStopException(bool currentStatus);
223 Tizen::Media::RecorderErrorReason GetRecorderErrorStatus(void);
224 void GetUpdatedContentName(Tizen::Base::String& latestContentName);
226 void SetMemoryFullException(bool status);
227 bool GetMemoryFullExceptionStatus(void);
228 void SetCurrentSourceForm(SourceForm source);
229 SourceForm GetCurrentSourceForm(void);
230 void SetRecorderEndReached(bool currentStatus);
233 CameraPresentationModel(void);
234 CameraPresentationModel(const CameraPresentationModel&);
235 CameraPresentationModel& operator = (const CameraPresentationModel&);
236 virtual ~CameraPresentationModel(void);
237 result CreateThumbnail(int currentCameraMode);
238 result CreateFileName(Tizen::Base::String& fullFileName);
239 Tizen::Base::String SearchContentFilePath(int mode);
240 result SetCameraPreviewResolution(void);
241 result SetCamcorderRecordingResolution(void);
242 void StorageCardStateChaged(bool isMounted);
243 result RemoveVideoFile(void);
244 void SetDeviceManagerEventListner(void);
245 void RemoveDeviceManagerEventListner(void);
246 Tizen::Media::RecordingRotation GetRecordingRotation(void);
247 static void CreateInstance(void);
248 static void DestroyInstance(void);
249 static void DestroyPresentationModelInstance(void);
250 friend class CameraApp;
253 static CameraPresentationModel* __pPresentationModel;
254 Tizen::Media::Camera* __pCamera;
255 Tizen::Base::Collection::IList* __pPreviewResolutionList;
256 Tizen::Base::Collection::IList* __pCaptureResolutionList;
257 Tizen::Base::Collection::IList* __pRecordingResolutionList;
258 Tizen::Base::Collection::IList* __pIsoList;
259 Tizen::Media::VideoRecorder* __pVideoRecorder;
260 ICameraEventListner* __pCameraListener;
261 Tizen::Content::ContentManager* __pContentManager;
262 Tizen::Content::ImageContentInfo* __pImageContentInfo;
263 Tizen::Content::VideoContentInfo* __pVideoContentInfo;
264 CameraSettingsPresentationModel* __pCameraSettingsPresentationModel;
265 Tizen::Graphics::Bitmap* __pBitmap;
266 Tizen::Base::String __latestContentName;
267 Tizen::Base::String __errorResult;
268 Tizen::Base::String __CurrentVideoFileName;
269 int __appControlRequestType;
270 Tizen::Ui::OrientationStatus __dir;
272 int __storageCardState;
273 int __storageCardChageState;
274 int __isStopCaptured;
276 int __onVideoRecorderStarted;
277 int __displayResolution;
278 bool __startPreviewException;
279 bool __isCancelRecord;
281 bool __isPreviewExit;
282 bool __isIntervalTimerRun;
283 bool __recorderStopException;
284 bool __memoryFullException;
285 bool __recorderEndReached;
286 SourceForm __pCurrentSource;
287 Tizen::Media::RecorderErrorReason __recorderError;
290 #endif // _CM_CAMERA_PRESENTATION_MODEL_H_