afb3dcdfbf6d85a799c279f7b9296f13ec5374b9
[apps/osp/Camera.git] / inc / CmCameraPresentationModel.h
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
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
7 //
8 //     http://floralicense.org/license/
9 //
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.
15 //
16
17 /**
18  * @file                CmCameraPresentationModel.h
19  * @brief               This is the header file for CameraPresentationModel class.
20  */
21
22 #ifndef _CM_CAMERA_PRESENTATION_MODEL_H_
23 #define _CM_CAMERA_PRESENTATION_MODEL_H_
24
25 #include <new>
26 #include <FApp.h>
27 #include <FBase.h>
28 #include <FContent.h>
29 #include <FIo.h>
30 #include <FLocales.h>
31 #include <FMedia.h>
32 #include <FSystem.h>
33 #include <FUi.h>
34 #include "CmICameraEventListener.h"
35 #include "CmTypes.h"
36 #include "CmUtility.h"
37
38 class CameraSettingsPresentationModel;
39
40 class CameraPresentationModel
41         : public Tizen::Media::ICameraEventListener
42         , public Tizen::Media::IVideoRecorderEventListener
43         , public Tizen::System::IDeviceEventListener
44          ,public Tizen::Content::IContentScanListener
45 {
46 public:
47         enum CameraMode
48         {
49                 CAMERA_MODE_SNAPSHOT = 0,
50                 CAMERA_MODE_RECORD,
51         };
52
53         enum CameraDirection
54         {
55                 CAMERA_DIRECTION_BACK = 0,
56                 CAMERA_DIRECTION_FRONT,
57         };
58
59         enum CamSelfPortraitMode
60         {
61                 CAM_SELF_PORTRAIT_MODE_PRIMARY,
62                 CAM_SELF_PORTRAIT_MODE_SECONDARY,
63         };
64
65         enum AppControlRequestType
66         {
67                 APP_CONTROL_REQUEST_TYPE_CANCELED = 0,
68                 APP_CONTROL_REQUEST_TYPE_SUCCEEDED,
69                 APP_CONTROL_REQUEST_TYPE_FAILED
70         };
71
72         enum StorageCardState
73         {
74                 STORAGE_CARD_STATE_UNMOUNT = 0,
75                 STORAGE_CARD_STATE_MOUNT,
76         };
77
78         enum StorageCardChageState
79         {
80                 STORAGE_CARD_CHAGE_STATE_UNKNOWN = 0,
81                 STORAGE_CARD_CHAGE_STATE_MOUNT_TO_UNMOUNT,
82                 STORAGE_CARD_CHAGE_STATE_UNMOUNT_TO_MOUNT,
83         };
84
85         enum DisplayResolution
86         {
87                 DISPLAY_RESOLUTION_WVGA = 0,
88                 DISPLAY_RESOLUTION_HD,
89         };
90
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);
101
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);
115
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);
126         void Capture(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);
140
141         Tizen::Media::CameraFlipType GetFlip(void) const;
142         void SetFlip(Tizen::Media::CameraFlipType type);
143
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);
165
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);
171
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;
176         void ZoomIn(void);
177         void ZoomOut(void);
178         result SetExifOrientation(int orientation);
179         void KeepScreenOnState(bool keepOn, bool dimming);
180
181         void AddPresentationChangedEventListener(ICameraEventListner& pObserverListener);
182         void RemovePresentationChangedEventListener(ICameraEventListner* pObserverListener);
183         void CallOnPresentationModeChanged(CameraActionEvent event);
184
185         bool GetOnVideoRecorderStopped(void);
186         void SetOnVideoRecorderStopped(bool isCompleted);
187
188         bool GetIntervalTimerRun(void) const;
189         void SetIntervalTimerRun(bool intervalTimerRun);
190
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;
198
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);
204
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);
209
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);
217
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);
220
221         void UpdateContentFile(void);
222         void SetRecordStopException(bool currentStatus);
223         Tizen::Media::RecorderErrorReason GetRecorderErrorStatus(void);
224         void GetUpdatedContentName(Tizen::Base::String& latestContentName);
225
226         void SetMemoryFullException(bool status);
227         bool GetMemoryFullExceptionStatus(void);
228         void SetCurrentSourceForm(SourceForm source);
229         SourceForm GetCurrentSourceForm(void);
230         void SetRecorderEndReached(bool currentStatus);
231
232 private:
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;
251
252 private:
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;
271         int __cameraMode;
272         int __storageCardState;
273         int __storageCardChageState;
274         int __isStopCaptured;
275         int __contentCount;
276         int __onVideoRecorderStarted;
277         int __displayResolution;
278         bool __startPreviewException;
279         bool __isCancelRecord;
280         bool __isInitCamera;
281         bool __isPreviewExit;
282         bool __isIntervalTimerRun;
283         bool __recorderStopException;
284         bool __memoryFullException;
285         bool __recorderEndReached;
286         SourceForm __pCurrentSource;
287         Tizen::Media::RecorderErrorReason __recorderError;
288 };
289
290 #endif // _CM_CAMERA_PRESENTATION_MODEL_H_