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.cpp
19 * @brief This is the implementation file for CameraPresentationModel class.
23 #include "CmCameraPresentationModel.h"
24 #include "CmCameraSettingsPresentationModel.h"
26 using namespace Tizen::App;
27 using namespace Tizen::Base;
28 using namespace Tizen::Base::Collection;
29 using namespace Tizen::Content;
30 using namespace Tizen::Graphics;
31 using namespace Tizen::Io;
32 using namespace Tizen::Locales;
33 using namespace Tizen::Media;
34 using namespace Tizen::System;
35 using namespace Tizen::Ui;
36 using namespace Tizen::Ui::Controls;
38 static const long RECORD_DEFAULT_SEC = 60000;
39 static const long SECONDS_PER_MINUTE = 60;
40 static const int MAX_FULL_FILE_PATH = 100;
41 static const bool CAPTURE_NORMAL_MODE = 0;
42 static const bool CAPTURE_BURST_MODE = 1;
43 static const int MAX_CAMERA_EXPOSURE_VALUE = 8;
44 static const int PREVIEW_RESOLOTION_WIDTH = 640;
45 static const int PREVIEW_RESOLOTION_HEIGHT = 480;
46 static const int PREVIEW_RESOLOTION_WVGA_WIDTH = 320;
47 static const int PREVIEW_RESOLOTION_WVGA_HEIGHT = 240;
48 static const int SEARCH_PAGE_NO = 1;
49 static const long INIT = -1;
51 static const wchar_t* STRING_SDCARD_MOUNTED_STATE = L"Mounted";
52 static const wchar_t* STRING_KEY_STORAGE_PHONE = L"http://tizen.org/runtime/storage.available.internal.media";
53 static const wchar_t* STRING_KEY_STORAGE_SDCARD = L"http://tizen.org/runtime/storage.available.external";
54 static const wchar_t* STRING_CAMCORDER_TEMPORARY_FILE = L"data/temp.mp4";
55 static const wchar_t* STRING_CAMCORDER_TEMPORARY_FILE_EXT = L"Camera/temp.mp4";
56 static const wchar_t* STRING_CAMERA_CAPTURED_ERROR = L"Captured Error";
57 static const wchar_t* STRING_VIDEO_RECORDER_CLOSED_ERROR = L"Video Recorder Closed Error";
58 static const wchar_t* STRING_VIDEO_RECORDER_END_REACHED_ERROR = L"Video Recorder End Reached Error";
59 static const String STRING_CONTENT_CAMERA_PATH = Environment::GetMediaPath() + L"Camera";
60 static const String STRING_CONTENT_CAMERA_PATH_EXT = Environment::GetExternalStoragePath() + L"Camera";
61 static const String CONTENT_INFO_ORDER = L"ContentName";
62 static const wchar_t* EMPTY_SPACE = L"";
64 CameraPresentationModel* CameraPresentationModel::__pPresentationModel = null;
68 Tizen::Ui::OrientationStatus orientation;
69 CameraSelection camType;
70 RecordingRotation rotate;
71 }_RecordingRotationTable;
73 static const _RecordingRotationTable _RecordRotate[] =
75 {ORIENTATION_STATUS_PORTRAIT, CAMERA_PRIMARY, RECORDING_ROTATION_90},
76 {ORIENTATION_STATUS_LANDSCAPE, CAMERA_PRIMARY, RECORDING_ROTATION_NONE},
77 {ORIENTATION_STATUS_PORTRAIT_REVERSE, CAMERA_PRIMARY, RECORDING_ROTATION_180},
78 {ORIENTATION_STATUS_LANDSCAPE_REVERSE, CAMERA_PRIMARY, RECORDING_ROTATION_270},
80 {ORIENTATION_STATUS_PORTRAIT, CAMERA_SECONDARY, RECORDING_ROTATION_90},
81 {ORIENTATION_STATUS_LANDSCAPE, CAMERA_SECONDARY, RECORDING_ROTATION_NONE},
82 {ORIENTATION_STATUS_PORTRAIT_REVERSE, CAMERA_SECONDARY, RECORDING_ROTATION_180},
83 {ORIENTATION_STATUS_LANDSCAPE_REVERSE, CAMERA_SECONDARY, RECORDING_ROTATION_270},
86 enum CamSetExifOrientationMode
88 CAM_SET_EXIF_ORIENTATION_MODE_NONE = 0,
89 CAM_SET_EXIF_ORIENTATION_MODE_PORTRAIT,
90 CAM_SET_EXIF_ORIENTATION_MODE_LANDSCAPE,
91 CAM_SET_EXIF_ORIENTATION_MODE_PORTRAIT_REVERSE,
92 CAM_SET_EXIF_ORIENTATION_MODE_LANDSCAPE_REVERSE,
95 CameraPresentationModel::CameraPresentationModel(void)
97 , __pPreviewResolutionList(null)
98 , __pCaptureResolutionList(null)
99 , __pRecordingResolutionList(null)
101 , __pVideoRecorder(null)
102 , __pCameraListener(null)
104 , __pContentManager(null)
105 , __pImageContentInfo(null)
106 , __pVideoContentInfo(null)
108 , __pCameraSettingsPresentationModel(null)
110 , __latestContentName(L"")
112 , __appControlRequestType(APP_CONTROL_REQUEST_TYPE_CANCELED)
113 , __dir(ORIENTATION_STATUS_NONE)
114 , __cameraMode(CAMERA_MODE_SNAPSHOT)
115 , __storageCardState(STORAGE_CARD_STATE_UNMOUNT)
116 , __storageCardChageState(STORAGE_CARD_CHAGE_STATE_UNKNOWN)
117 , __isStopCaptured(false)
119 , __onVideoRecorderStarted(false)
120 , __displayResolution(DISPLAY_RESOLUTION_HD)
121 , __startPreviewException(false)
122 , __isCancelRecord(false)
123 , __isInitCamera(false)
124 , __isPreviewExit(false)
125 , __isIntervalTimerRun(false)
126 ,__recorderStopException(false)
127 ,__memoryFullException(false)
128 ,__pCurrentSource(SOURCE_FORM_CAMERA)
129 ,__recorderError(RECORDER_ERROR_OUT_OF_STORAGE)
131 AppLogDebug("ENTER");
135 CameraPresentationModel::~CameraPresentationModel(void)
137 AppLogDebug("ENTER");
138 result r = E_SUCCESS;
140 if (__isInitCamera == true)
142 if (__pVideoRecorder != null)
144 AppLogDebug("VideoRecorder State[%d]", __pVideoRecorder->GetState());
146 if (__pVideoRecorder->GetState()== RECORDER_STATE_RECORDING
147 || __pVideoRecorder->GetState() == RECORDER_STATE_STARTING
148 || __pVideoRecorder->GetState() == RECORDER_STATE_PAUSING
149 || __pVideoRecorder->GetState() == RECORDER_STATE_PAUSED
152 r = __pVideoRecorder->Stop();
153 TryReturnVoid(r == E_SUCCESS, "__pVideoRecorder::Stop() [%s]", GetErrorMessage(r));
156 if (__pVideoRecorder->GetState()== RECORDER_STATE_STOPPING
157 || __pVideoRecorder->GetState() == RECORDER_STATE_STOPPED
160 r = __pVideoRecorder->Close();
161 TryReturnVoid(r == E_SUCCESS, "__pVideoRecorder::Close() [%s]", GetErrorMessage(r));
164 delete __pVideoRecorder;
165 __pVideoRecorder = null;
168 if (__pCamera != null)
170 AppLogDebug("Camera State[%d]", __pCamera->GetState());
172 if (__pCamera->GetState() == CAMERA_STATE_PREVIEW)
174 r = __pCamera->StopPreview();
175 TryReturnVoid(r == E_SUCCESS, "Camera::StopPreview() [%s]", GetErrorMessage(r));
178 if (__pCamera->IsPoweredOn() == true)
180 r = __pCamera->PowerOff();
181 TryReturnVoid(r == E_SUCCESS, "Camera::PowerOff() [%s]", GetErrorMessage(r));
190 if (__pCamera != null)
197 if (__pPreviewResolutionList)
199 __pPreviewResolutionList->RemoveAll(true);
200 delete __pPreviewResolutionList;
201 __pPreviewResolutionList = null;
204 if (__pCaptureResolutionList)
206 __pCaptureResolutionList->RemoveAll(true);
207 delete __pCaptureResolutionList;
208 __pCaptureResolutionList = null;
211 if (__pRecordingResolutionList)
213 __pRecordingResolutionList->RemoveAll(true);
214 delete __pRecordingResolutionList;
215 __pRecordingResolutionList = null;
220 __pIsoList->RemoveAll(true);
226 if (__pContentManager)
228 delete __pContentManager;
230 if (__pImageContentInfo)
232 delete __pImageContentInfo;
234 if (__pVideoContentInfo)
236 delete __pVideoContentInfo;
245 __isInitCamera = false;
247 __isStopCaptured = false;
251 __onVideoRecorderStarted = false;
253 __isPreviewExit = false;
255 __isIntervalTimerRun = false;
257 __displayResolution = DISPLAY_RESOLUTION_HD;
259 RemoveDeviceManagerEventListner();
261 __pCameraSettingsPresentationModel = null;
266 CameraPresentationModel::CreateThumbnail(int currentCameraMode)
268 AppLogDebug("ENTER");
269 String latestContentName = L"";
270 result r = E_SUCCESS;
277 r = GetLatestContentName(currentCameraMode, latestContentName);
278 AppLogDebug("latestContentName : %ls",latestContentName.GetPointer());
279 TryCatch(r == E_SUCCESS, , "GetLatestContentName() fail[%s]", GetErrorMessage(r));
281 if (currentCameraMode == CAMERA_MODE_SNAPSHOT)
283 __pBitmap = CmUtility::CreateThumbnailN(latestContentName, CONTENT_TYPE_IMAGE);
285 if (latestContentName == L"")
292 r = GetValue(STORAGE_TYPE, storageType);
294 if (storageType == STORAGE_TYPE_PHONE)
296 filePath = Environment::GetMediaPath();
300 filePath = Environment::GetExternalStoragePath();
303 filePath.Append(STRING_CAMERA_FOLDER_NAME);
304 filePath.Append("/");
305 filePath.Append(__CurrentVideoFileName);
306 if (!File::IsFileExist(filePath) || __CurrentVideoFileName.IsEmpty())
308 AppLogDebug("Latest content name is %ls",latestContentName.GetPointer());
309 __pBitmap = CmUtility::CreateThumbnailN(latestContentName,CONTENT_TYPE_VIDEO);
314 AppLogDebug("Current content name is %ls",__CurrentVideoFileName.GetPointer());
315 __pBitmap = CmUtility::CreateThumbnailN(__CurrentVideoFileName,CONTENT_TYPE_VIDEO);
318 if (latestContentName == L"")
324 if (__pBitmap == null)
326 AppLogDebug("__pBitmap : null");
333 AppLogDebug("EXIT - CATCH");
338 CameraPresentationModel::IsExistThumbnail(int currentCameraMode)
340 AppLogDebug("ENTER");
341 String latestContentName = L"";
342 result r = E_SUCCESS;
343 Bitmap* pThumbnailBitmap = null;
345 r = GetLatestContentName(currentCameraMode, latestContentName);
348 AppLogDebug("GetLatestContentName() fail[%s]", GetErrorMessage(r));
352 if (currentCameraMode == CAMERA_MODE_SNAPSHOT)
354 pThumbnailBitmap = CmUtility::CreateThumbnailN(latestContentName, CONTENT_TYPE_IMAGE);
356 if (pThumbnailBitmap != null)
358 delete pThumbnailBitmap;
359 pThumbnailBitmap = null;
362 if (latestContentName == L"")
364 AppLogDebug("EXIT - FILE NOT FOUND");
375 pThumbnailBitmap = CmUtility::CreateThumbnailN(latestContentName, CONTENT_TYPE_VIDEO);
377 if (pThumbnailBitmap != null)
379 delete pThumbnailBitmap;
380 pThumbnailBitmap = null;
383 if (latestContentName == L"")
385 AppLogDebug("EXIT - FILE NOT FOUND");
397 CameraPresentationModel::GetfilePath(int storageType)
399 AppLogDebug("ENTER");
400 result r = E_SUCCESS;
401 String filePath = L"";
403 if (storageType == STORAGE_TYPE_MEMORYCARD)
405 r = filePath.Format(MAX_DIRECTORY_PATH_LENGTH, L"%ls%ls", Environment::GetExternalStoragePath().GetPointer(), STRING_CAMERA_FOLDER);
406 TryCatch(r == E_SUCCESS, , "String::Format() fail[%s]", GetErrorMessage(r));
408 else if (storageType == STORAGE_TYPE_PHONE)
410 r = filePath.Format(MAX_DIRECTORY_PATH_LENGTH, L"%ls%ls", Environment::GetMediaPath().GetPointer(), STRING_CAMERA_FOLDER);
411 TryCatch(r == E_SUCCESS, , "String::Format() fail[%s]", GetErrorMessage(r));
415 r = filePath.Format(MAX_DIRECTORY_PATH_LENGTH, L"%ls%ls", Environment::GetMediaPath().GetPointer(), STRING_CAMERA_FOLDER);
416 TryCatch(r == E_SUCCESS, , "String::Format() fail[%s]", GetErrorMessage(r));
419 AppLogDebug("EXIT - filePath : %ls", filePath.GetPointer());
423 AppLogDebug("EXIT - CATCH");
428 CameraPresentationModel::CreateFileName(Tizen::Base::String& fullFileName)
430 AppLogDebug("ENTER");
431 String* pFilePath = null;
432 String* pFileName = null;
434 int currentCameraMode = 0;
435 result r = E_SUCCESS;
436 bool checkFileAvailability = false;
437 String updatedFileName;
438 int currentNameCount = 0;
439 String currentFileName;
440 String fileExtension;
441 int fileExtensionLength = 0;
442 int generatedFileLength = 0;
444 r = GetValue(STORAGE_TYPE, storageType);
445 TryCatch(r == E_SUCCESS, , "GetValue() fail[%s]", GetErrorMessage(r));
447 r = GetValue(CURRENT_MODE, currentCameraMode);
448 TryCatch(r == E_SUCCESS, , "GetValue() fail[%s]", GetErrorMessage(r));
450 pFilePath = new (std::nothrow) String();
451 pFileName = new (std::nothrow) String();
453 r = CmUtility::GetDirectoryPath(storageType, *pFilePath);
454 TryCatch(r == E_SUCCESS, , "GetDirectoryPath() fail[%s]", GetErrorMessage(r));
456 r = CmUtility::GetFileName(currentCameraMode, *pFileName);
457 TryCatch(r == E_SUCCESS, , "GetFileName() fail[%s]", GetErrorMessage(r));
459 updatedFileName.Clear();
460 updatedFileName.Format(MAX_FULL_FILE_PATH, L"%ls%ls", pFilePath->GetPointer(), pFileName->GetPointer());
461 currentFileName = *pFileName;
462 checkFileAvailability = File::IsFileExist(updatedFileName);
464 generatedFileLength = pFileName->GetLength();
465 if (checkFileAvailability)
467 if (currentCameraMode == CameraPresentationModel::CAMERA_MODE_SNAPSHOT)
469 r = fileExtension.Append(STRING_EXTENSION_JPG);
470 TryCatch(r == E_SUCCESS, , "fileName::Append() fail[%s]", GetErrorMessage(r));
474 r = fileExtension.Append(STRING_EXTENSION_MP4);
475 TryCatch(r == E_SUCCESS, , "fileName::Append() fail[%s]", GetErrorMessage(r));
477 fileExtensionLength = fileExtension.GetLength();
480 while (checkFileAvailability)
483 currentFileName.Clear();
484 currentFileName = *pFileName;
485 currentFileName.Remove(generatedFileLength -fileExtensionLength,fileExtensionLength);
486 AppLogDebug("filename after remove is %ls",currentFileName.GetPointer());
487 currentFileName.Append("_");
488 currentFileName.Append(currentNameCount);
489 if (currentCameraMode == CameraPresentationModel::CAMERA_MODE_SNAPSHOT)
491 currentFileName.Append(STRING_EXTENSION_JPG);
495 currentFileName.Append(STRING_EXTENSION_MP4);
497 updatedFileName.Clear();
498 updatedFileName.Format(MAX_FULL_FILE_PATH, L"%ls%ls", pFilePath->GetPointer(), currentFileName.GetPointer());
499 checkFileAvailability = File::IsFileExist(updatedFileName);
502 if (currentNameCount != 0)
505 pFileName->Append(currentFileName);
506 AppLogDebug("updated file name is %ls",pFileName->GetPointer());
509 fullFileName.Clear();
510 r = fullFileName.Format(MAX_FULL_FILE_PATH, L"%ls%ls", pFilePath->GetPointer(), pFileName->GetPointer());
511 TryCatch(r == E_SUCCESS, , "String::Format() fail[%s]", GetErrorMessage(r));
519 AppLogDebug("EXIT - pFullFileName %ls", fullFileName.GetPointer());
523 AppLogDebug("EXIT - CATCH");
534 CameraPresentationModel::CreateInstance(void)
536 AppLogDebug("ENTER");
537 __pPresentationModel = new (std::nothrow) CameraPresentationModel();
539 result r = __pPresentationModel->Construct();
543 delete __pPresentationModel;
544 __pPresentationModel = null;
548 // std::atexit(DestroyInstance);
553 CameraPresentationModel::DestroyInstance(void)
555 AppLogDebug("ENTER");
556 delete __pPresentationModel;
557 __pPresentationModel = null;
561 CameraPresentationModel*
562 CameraPresentationModel::GetInstance(void)
564 AppLogDebug("ENTER");
565 if (__pPresentationModel == null)
571 return __pPresentationModel;
575 CameraPresentationModel::Construct(void)
577 AppLogDebug("ENTER");
578 result r = E_SUCCESS;
580 __pCameraSettingsPresentationModel = CameraSettingsPresentationModel::GetInstance();
581 TryCatch(__pCameraSettingsPresentationModel != null, r = E_SYSTEM, "__pCameraSettingsPresentationModel is null");
583 SetDeviceManagerEventListner();
589 AppLogDebug("EXIT - CATCH");
594 CameraPresentationModel::Terminate(int mode)
596 AppLogDebug("ENTER Terminate :: mode = %d", mode);
597 result r = E_SUCCESS;
599 if (mode == CAMERA_MODE_SNAPSHOT)
601 if (__pVideoRecorder != null)
603 AppLogDebug("VideoRecorder State[%d]", __pVideoRecorder->GetState());
605 if (__pVideoRecorder->GetState()== RECORDER_STATE_RECORDING
606 || __pVideoRecorder->GetState() == RECORDER_STATE_STARTING
607 || __pVideoRecorder->GetState() == RECORDER_STATE_PAUSING
608 || __pVideoRecorder->GetState() == RECORDER_STATE_PAUSED
611 r = __pVideoRecorder->Stop();
612 TryReturnVoid(r == E_SUCCESS, "__pVideoRecorder::Stop() [%s]", GetErrorMessage(r));
615 if (__pVideoRecorder->GetState()== RECORDER_STATE_STOPPING
616 || __pVideoRecorder->GetState() == RECORDER_STATE_STOPPED
619 r = __pVideoRecorder->Close();
620 TryReturnVoid(r == E_SUCCESS, "__pVideoRecorder::Close() [%s]", GetErrorMessage(r));
623 delete __pVideoRecorder;
624 __pVideoRecorder = null;
627 if (__pCamera != null)
629 AppLogDebug("Camera State[%d]", __pCamera->GetState());
631 if (__pCamera->GetState() == CAMERA_STATE_PREVIEW)
633 r = __pCamera->StopPreview();
634 TryReturnVoid(r == E_SUCCESS, "Camera::StopPreview() [%s]", GetErrorMessage(r));
637 if (__pCamera->IsPoweredOn() == true)
639 r = __pCamera->PowerOff();
641 AppLogDebug("Camera::PowerOff() [%s]", GetErrorMessage(r));
643 if (r == E_DEVICE_BUSY)
645 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_PREVIEW_START_FAILED);
653 else if (mode == CAMERA_MODE_RECORD)
655 if (__pCamera != null)
657 AppLogDebug("Camera State[%d]", __pCamera->GetState());
659 if (__pCamera->GetState() == CAMERA_STATE_PREVIEW)
661 r = __pCamera->StopPreview();
662 TryReturnVoid(r == E_SUCCESS, "Camera::StopPreview() [%s]", GetErrorMessage(r));
665 if (__pCamera->IsPoweredOn() == true)
667 r = __pCamera->PowerOff();
669 AppLogDebug("Camera::PowerOff() [%s]", GetErrorMessage(r));
671 if (r == E_DEVICE_BUSY)
673 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_PREVIEW_START_FAILED);
681 if (__pVideoRecorder != null)
683 AppLogDebug("VideoRecorder State[%d]", __pVideoRecorder->GetState());
685 if (__pVideoRecorder->GetState()== RECORDER_STATE_RECORDING
686 || __pVideoRecorder->GetState() == RECORDER_STATE_STARTING
687 || __pVideoRecorder->GetState() == RECORDER_STATE_PAUSING
688 || __pVideoRecorder->GetState() == RECORDER_STATE_PAUSED
691 r = __pVideoRecorder->Stop();
692 TryReturnVoid(r == E_SUCCESS, "__pVideoRecorder::Stop() [%s]", GetErrorMessage(r));
695 if (__pVideoRecorder->GetState()== RECORDER_STATE_STOPPING
696 || __pVideoRecorder->GetState() == RECORDER_STATE_STOPPED
699 r = __pVideoRecorder->Close();
700 TryReturnVoid(r == E_SUCCESS, "__pVideoRecorder::Close() [%s]", GetErrorMessage(r));
703 delete __pVideoRecorder;
704 __pVideoRecorder = null;
711 CameraPresentationModel::InitializeFlashMode(void)
713 AppLogDebug("ENTER");
714 result r = E_SUCCESS;
716 int selfPortraitEnable = 0;
718 r = GetValue(SELF_PORTRAIT_ENABLE, selfPortraitEnable);
719 if (selfPortraitEnable == CAM_SELF_PORTRAIT_MODE_PRIMARY)
721 r = GetMediaCapability(CAMERA_PRIMARY_FLASH_MODE);
725 r = GetMediaCapability(CAMERA_SECONDARY_FLASH_MODE);
730 if (selfPortraitEnable == CAM_SELF_PORTRAIT_MODE_PRIMARY)
732 r = GetValue(FLASH_MODE_PRIMARY, flashMode);
736 r = GetValue(FLASH_MODE_SECONDARY, flashMode);
738 TryCatch(r == E_SUCCESS, , "GetValue() fail[%s]", GetErrorMessage(r));
740 AppLogDebug("flashMode = %d", flashMode);
741 SetFlashMode(CameraFlashMode(flashMode));
748 AppLogDebug("EXIT - CATCH");
753 CameraPresentationModel::InitializeCamera(void)
755 AppLogDebug("ENTER");
756 Dimension* pCaptureResolution = null;
757 int selfPortraitEnable = 0;
758 int captureResolutionCount = 0;
759 result r = E_SUCCESS;
760 int resolutionIndex = 0;
762 r = GetValue(SELF_PORTRAIT_ENABLE, selfPortraitEnable);
763 TryCatch(r == E_SUCCESS, , "GetValue() fail[%s]", GetErrorMessage(r));
765 if (selfPortraitEnable == CameraPresentationModel::CAM_SELF_PORTRAIT_MODE_PRIMARY)
767 r = GetValue(PRIMARY_RESOLUTION_INDEX, resolutionIndex);
768 TryCatch(r == E_SUCCESS, , "GetValue() fail[%s]", GetErrorMessage(r));
772 r = GetValue(SECONDARY_RESOLUTION_INDEX, resolutionIndex);
773 TryCatch(r == E_SUCCESS, , "GetValue() fail[%s]", GetErrorMessage(r));
776 if (__pCamera == null)
778 __pCamera = new (std::nothrow) Camera();
779 TryCatch(__pCamera != null, , "[FAILURE] new (std::nothrow) Camera()");
781 if (selfPortraitEnable == CAM_SELF_PORTRAIT_MODE_PRIMARY)
783 AppLogDebug("CAMERA_PRIMARY_MODE !!!");
784 r = __pCamera->Construct(*this, CAMERA_PRIMARY);
788 AppLogDebug("CAMERA_SECONDARY_MODE !!!");
789 r = __pCamera->Construct(*this, CAMERA_SECONDARY);
791 TryCatch(r == E_SUCCESS, , "__pCamera->Construct() [%s]", GetErrorMessage(r));
794 r = __pCamera->PowerOn();
795 TryCatch(r == E_SUCCESS, , "Camera::PowerOn fail[%s]", GetErrorMessage(r));
797 r = SetCameraPreviewResolution();
798 TryCatch(r == E_SUCCESS, , "Camera::SetCameraPreviewResolution fail[%s]", GetErrorMessage(r));
800 __pCaptureResolutionList = __pCamera->GetSupportedCaptureResolutionListN();
801 TryCatch(__pCaptureResolutionList != null, , "pCaptureResolutionList is null");
803 captureResolutionCount = __pCaptureResolutionList->GetCount();
804 AppLogDebug("__pCaptureResolutionList Count : %d", captureResolutionCount);
807 pCaptureResolution = static_cast< Dimension*>(__pCaptureResolutionList->GetAt(captureResolutionCount -1 - resolutionIndex));
808 TryCatch(pCaptureResolution != null, , "pCaptureResolution is null");
810 r = __pCamera->SetCaptureResolution(*pCaptureResolution);
811 TryCatch(r == E_SUCCESS, , "Camera::SetCaptureResolution fail[%s]", GetErrorMessage(r));
817 AppLogDebug("EXIT - CATCH");
819 if ( __pCamera != null ) //Deleting Camera if something goes wrong.
824 if (__pPreviewResolutionList)
826 __pPreviewResolutionList->RemoveAll(true);
829 delete __pPreviewResolutionList;
830 __pPreviewResolutionList = null;
832 if (__pCaptureResolutionList)
834 __pCaptureResolutionList->RemoveAll(true);
837 delete __pCaptureResolutionList;
838 __pCaptureResolutionList = null;
840 __isInitCamera = false;
841 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_INITIALIZE_FAILED);
847 CameraPresentationModel::SetCameraPreviewResolution(void)
849 AppLogDebug("ENTER");
850 Dimension* pPreviewResolution = null;
851 Dimension PreviewResolutionDim;
852 Dimension tempDimention(PREVIEW_RESOLOTION_WIDTH, PREVIEW_RESOLOTION_HEIGHT);
853 Dimension tempDimentionWvga(PREVIEW_RESOLOTION_WVGA_WIDTH, PREVIEW_RESOLOTION_WVGA_HEIGHT);
854 int previewResolutionCount = 0;
855 int previewResolutionIdx = 0;
857 result r = E_SUCCESS;
859 if (__pPreviewResolutionList == null)
861 __pPreviewResolutionList = __pCamera->GetSupportedPreviewResolutionListN();
862 TryCatch(__pPreviewResolutionList != null, , "__pPreviewResolutionList is null");
864 previewResolutionCount = __pPreviewResolutionList->GetCount();
865 AppLogDebug("pPreviewResolutionList Count : %d", previewResolutionCount);
867 if (previewResolutionCount > 0)
869 for (idx = 0; idx < previewResolutionCount; idx++)
871 pPreviewResolution = static_cast<Dimension*>(__pPreviewResolutionList->GetAt(idx));
873 AppLogDebug("InitializeCamcorder pPreviewResolution w:%d,h:%d", pPreviewResolution->width, pPreviewResolution->height);
875 if (GetDisplayResolutionType() == DISPLAY_RESOLUTION_WVGA)
877 AppLogDebug("DISPLAY_RESOLUTION_WVGA");
878 if (*pPreviewResolution == tempDimentionWvga)
880 previewResolutionIdx = idx;
886 if (*pPreviewResolution == tempDimention)
888 previewResolutionIdx = idx;
895 pPreviewResolution = static_cast<Dimension*>(__pPreviewResolutionList->GetAt(previewResolutionIdx));
896 TryCatch(pPreviewResolution != null, , "pPreviewResolution is null");
898 AppLogDebug("InitializeCamcorder::pPreviewResolution w:%d,h:%d", pPreviewResolution->width, pPreviewResolution->height);
900 r = __pCamera->SetPreviewResolution(*pPreviewResolution);
901 TryCatch(r == E_SUCCESS, , "Camera::SetPreviewResolution fail[%s]", GetErrorMessage(r));
905 PreviewResolutionDim = __pCamera->GetPreviewResolution();
907 AppLogDebug("InitializeCamcorder::pPreviewResolution w:%d,h:%d", PreviewResolutionDim.width, PreviewResolutionDim.height);
909 r = __pCamera->SetPreviewResolution(PreviewResolutionDim);
910 TryCatch(r == E_SUCCESS, , "Camera::SetPreviewResolution fail[%s]", GetErrorMessage(r));
917 AppLogDebug("EXIT - CATCH");
918 if (__pPreviewResolutionList)
920 __pPreviewResolutionList->RemoveAll(true);
921 delete __pPreviewResolutionList;
922 __pPreviewResolutionList = null;
928 CameraPresentationModel::SetCamcorderRecordingResolution(void)
930 AppLogDebug("ENTER");
931 Dimension* pRecordingResolution = null;
932 Dimension RecordingResolutionDim;
933 Dimension tempDimention(PREVIEW_RESOLOTION_WIDTH, PREVIEW_RESOLOTION_HEIGHT);
934 Dimension tempDimentionWvga(PREVIEW_RESOLOTION_WVGA_WIDTH, PREVIEW_RESOLOTION_WVGA_HEIGHT);
935 int recordingResolutionCount = 0;
936 int recordingResolutionIdx = 0;
938 result r = E_SUCCESS;
940 if (__pRecordingResolutionList == null)
942 __pRecordingResolutionList = __pVideoRecorder->GetSupportedRecordingResolutionListN();
943 TryCatch(__pRecordingResolutionList != null, , "__pRecordingResolutionList is null");
945 recordingResolutionCount = __pRecordingResolutionList->GetCount();
946 AppLogDebug("__pRecordingResolutionList Count : %d", recordingResolutionCount);
948 if (recordingResolutionCount > 0)
950 for (idx = 0; idx < recordingResolutionCount; idx++)
952 pRecordingResolution = static_cast<Dimension*>(__pRecordingResolutionList->GetAt(idx));
954 AppLogDebug("pRecordingResolution w:%d,h:%d", pRecordingResolution->width, pRecordingResolution->height);
956 if (GetDisplayResolutionType() == DISPLAY_RESOLUTION_WVGA)
958 AppLogDebug("DISPLAY_RESOLUTION_WVGA");
959 if (*pRecordingResolution == tempDimentionWvga)
961 recordingResolutionIdx = idx;
962 __pCamera->SetPreviewResolution(tempDimentionWvga);
968 if (*pRecordingResolution == tempDimention)
970 __pCamera->SetPreviewResolution(tempDimention);
971 recordingResolutionIdx = idx;
978 pRecordingResolution = static_cast<Dimension*>(__pRecordingResolutionList->GetAt(recordingResolutionIdx));
979 TryCatch(pRecordingResolution != null, , "pRecordingResolution is null");
981 AppLogDebug("pRecordingResolution w:%d,h:%d", pRecordingResolution->width, pRecordingResolution->height);
983 r = __pVideoRecorder->SetRecordingResolution(*pRecordingResolution);
984 TryCatch(r == E_SUCCESS, , "VideoRecorder::SetRecordingResolution() fail[%s]", GetErrorMessage(r));
988 RecordingResolutionDim = __pVideoRecorder->GetRecordingResolution();
990 AppLogDebug("pPreviewResolution w:%d,h:%d", RecordingResolutionDim.width, RecordingResolutionDim.height);
992 if (__pVideoRecorder->GetState() != RECORDER_STATE_STOPPING)
994 __pVideoRecorder->SetRecordingResolution(RecordingResolutionDim);
995 TryCatch(r == E_SUCCESS, , "VideoRecorder::SetRecordingResolution() fail[%s]", GetErrorMessage(r));
1003 AppLogDebug("EXIT - CATCH");
1004 if (__pRecordingResolutionList)
1006 __pRecordingResolutionList->RemoveAll(true);
1009 delete __pRecordingResolutionList;
1010 __pRecordingResolutionList = null;
1015 CameraPresentationModel::InitializeCamcorder(void)
1017 AppLogDebug("ENTER");
1018 int selfPortraitEnable = 0;
1019 result r = E_SUCCESS;
1021 r = GetValue(SELF_PORTRAIT_ENABLE, selfPortraitEnable);
1022 TryCatch(r == E_SUCCESS, , "GetValue() fail[%s]", GetErrorMessage(r));
1024 if (__pCamera == null)
1026 __pCamera = new (std::nothrow) Camera();
1027 TryCatch(__pCamera != null, , "[FAILURE] new (std::nothrow) Camera()");
1029 if (selfPortraitEnable == CAM_SELF_PORTRAIT_MODE_PRIMARY)
1031 AppLogDebug("CAMERA_PRIMARY_MODE !!!");
1032 r = __pCamera->Construct(*this, CAMERA_PRIMARY);
1036 AppLogDebug("CAMERA_SECONDARY_MODE !!!");
1037 r = __pCamera->Construct(*this, CAMERA_SECONDARY);
1039 TryCatch(r == E_SUCCESS, , "__pCamera->Construct() [%s]", GetErrorMessage(r));
1042 if( __pCamera->IsPoweredOn() == false)
1044 r = __pCamera->PowerOn();
1045 TryCatch(r == E_SUCCESS, , "Camera::PowerOn fail[%s]", GetErrorMessage(r));
1049 AppLogDebug("Camera was already powered on");
1052 if (__pVideoRecorder == null)
1054 __pVideoRecorder = new (std::nothrow) VideoRecorder();
1055 __pVideoRecorder->Construct(*this, *__pCamera);
1058 r = SetCameraPreviewResolution();
1059 TryCatch(r == E_SUCCESS, , "SetCameraPreviewResolution fail[%s]", GetErrorMessage(r));
1061 r = SetCamcorderRecordingResolution();
1062 TryCatch(r == E_SUCCESS, , "SetCamcorderRecordingResolution fail[%s]", GetErrorMessage(r));
1064 AppLogDebug("EXIT");
1068 AppLogDebug("EXIT - CATCH");
1069 if (__pPreviewResolutionList)
1071 __pPreviewResolutionList->RemoveAll(true);
1072 delete __pPreviewResolutionList;
1073 __pPreviewResolutionList = null;
1076 __isInitCamera = false;
1077 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_INITIALIZE_FAILED);
1083 CameraPresentationModel::ToggleCameraCamcorder(int mode)
1085 AppLogDebug("ENTER");
1086 Dimension PreviewResolutionDim;
1087 result r = E_SUCCESS;
1089 if (mode == CAMERA_MODE_SNAPSHOT)
1091 r = __pCamera->PowerOn();
1092 TryCatch(r == E_SUCCESS, , "Camera::PowerOn fail[%s]", GetErrorMessage(r));
1094 else if (mode == CAMERA_MODE_RECORD)
1096 r = __pCamera->PowerOn();
1097 TryCatch(r == E_SUCCESS, , "Camera::PowerOn fail[%s]", GetErrorMessage(r));
1099 r = SetCameraPreviewResolution();
1100 TryCatch(r == E_SUCCESS, , "ToggleCameraCamcorder::SetCameraPreviewResolution fail[%s]", GetErrorMessage(r));
1102 r = SetCamcorderRecordingResolution();
1103 TryCatch(r == E_SUCCESS, , "ToggleCameraCamcorder::SetCamcorderRecordingResolution fail[%s]", GetErrorMessage(r));
1106 AppLogDebug("EXIT");
1110 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_INITIALIZE_FAILED);
1111 AppLogDebug("EXIT - CATCH");
1116 CameraPresentationModel::ToggleCameraDirection(int mode, int direction)
1118 AppLogDebug("ENTER");
1119 result r = E_SUCCESS;
1120 int captureResolutionCount = 0;
1121 Dimension* pCaptureResolution = null;
1125 __pCamera = new (std::nothrow) Camera();
1126 TryCatch(__pCamera != null, , "[FAILURE] new (std::nothrow) Camera()");
1128 if (direction == CAMERA_DIRECTION_BACK)
1130 AppLogDebug("BACK");
1132 r = __pCamera->Construct(*this, CAMERA_PRIMARY);
1133 TryCatch(r == E_SUCCESS, , "__pCamera->Construct() [%s]", GetErrorMessage(r));
1135 else if (direction == CAMERA_DIRECTION_FRONT)
1137 AppLogDebug("FRONT");
1139 r = __pCamera->Construct(*this, CAMERA_SECONDARY);
1140 TryCatch(r == E_SUCCESS, , "__pCamera->Construct() [%s]", GetErrorMessage(r));
1143 r = __pCamera->PowerOn();
1144 TryCatch(r == E_SUCCESS, , "__pCamera->PowerOn() [%s]", GetErrorMessage(r));
1146 if (mode == CAMERA_MODE_RECORD)
1148 if (__pVideoRecorder == null)
1150 __pVideoRecorder = new (std::nothrow) VideoRecorder();
1151 __pVideoRecorder->Construct(*this, *__pCamera);
1155 if (mode == CAMERA_MODE_SNAPSHOT && direction == CAMERA_DIRECTION_FRONT)
1157 __pCaptureResolutionList = __pCamera->GetSupportedCaptureResolutionListN();
1158 TryCatch(__pCaptureResolutionList != null, , "pCaptureResolutionList is null");
1160 captureResolutionCount = __pCaptureResolutionList->GetCount();
1162 pCaptureResolution = static_cast< Dimension*>(__pCaptureResolutionList->GetAt(captureResolutionCount - 1));
1163 TryCatch(pCaptureResolution != null, , " pCaptureResolution->GetAt()");
1165 r = __pCamera->SetCaptureResolution(*pCaptureResolution);
1166 TryCatch(r == E_SUCCESS, , "Camera::SetCaptureResolution fail[%s]", GetErrorMessage(r));
1169 if (direction == CAMERA_DIRECTION_FRONT)
1171 SetFlip(CAMERA_FLIP_HORIZONTAL);
1174 AppLogDebug("EXIT");
1178 AppLogDebug("EXIT - CATCH");
1179 if (__pCaptureResolutionList)
1181 __pCaptureResolutionList->RemoveAll(true);
1184 delete __pCaptureResolutionList;
1185 __pCaptureResolutionList = null;
1187 __isInitCamera = false;
1188 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_INITIALIZE_FAILED);
1194 CameraPresentationModel::GetInitCameraStatus(void) const
1196 AppLogDebug("ENTER");
1197 AppLogDebug("EXIT - __isInitCamera = %d", __isInitCamera);
1198 return __isInitCamera;
1202 CameraPresentationModel::SetMode(int mode)
1204 AppLogDebug("ENTER");
1205 result r = E_SUCCESS;
1206 String contentSubDirectory = STRING_CAMERA_FOLDER_NAME;
1207 Directory contentDirectory;
1208 int cameraSelfPortraitEnable = CAM_SELF_PORTRAIT_MODE_PRIMARY;
1209 int camcorderSelfPortraitEnable = CAM_SELF_PORTRAIT_MODE_PRIMARY;
1210 int direction = CAMERA_DIRECTION_BACK;
1211 int selfPortraitEnable = 0;
1213 AppLogDebug("SetMode __SetMode = %d && mode = %d", __cameraMode, mode);
1215 if (__pCamera != null)
1217 if (__pCamera->IsPoweredOn() == true)
1219 AppLogDebug("StopCamera or Terminate");
1221 __pCameraSettingsPresentationModel->GetValue(SECTION_CAMERA, SELF_PORTRAIT_ENABLE, cameraSelfPortraitEnable);
1223 __pCameraSettingsPresentationModel->GetValue(SECTION_CAMCORDER, SELF_PORTRAIT_ENABLE, camcorderSelfPortraitEnable);
1225 AppLogDebug("SECTION_CAMERA mode = %d && SECTION_CAMCORDER mode = %d", cameraSelfPortraitEnable, camcorderSelfPortraitEnable);
1227 GetMediaCapability(CAMERA_SECONDARY_DIRECTION, direction);
1229 if ((cameraSelfPortraitEnable == CAM_SELF_PORTRAIT_MODE_SECONDARY && camcorderSelfPortraitEnable == CAM_SELF_PORTRAIT_MODE_PRIMARY)
1230 || (cameraSelfPortraitEnable == CAM_SELF_PORTRAIT_MODE_PRIMARY && camcorderSelfPortraitEnable == CAM_SELF_PORTRAIT_MODE_SECONDARY)
1233 if (__cameraMode == mode && direction == CAMERA_DIRECTION_FRONT)
1235 AppLogDebug("StopCamera");
1240 AppLogDebug("Terminate");
1246 AppLogDebug("StopCamera");
1252 if (mode == CAMERA_MODE_SNAPSHOT)
1254 if (__pCamera == null)
1256 AppLogDebug("CAMERA_MODE_SNAPSHOT::NOT_INITIALIZED");
1259 if (__pContentManager == null)
1261 __pContentManager = new (std::nothrow) ContentManager();
1263 r = __pContentManager->Construct();
1264 TryCatch(r == E_SUCCESS, , "__pContentManager->Construct [%s]", GetErrorMessage(r));
1266 if (__pImageContentInfo == null)
1268 __pImageContentInfo = new (std::nothrow) ImageContentInfo();
1269 r = __pImageContentInfo->Construct(null);
1270 TryCatch(r == E_SUCCESS, , "__pImageContentInfo->Construct [%s]", GetErrorMessage(r));
1274 r = CreateThumbnail(CAMERA_MODE_SNAPSHOT);
1275 AppLogDebug("CreateThumbnail [%s]", GetErrorMessage(r));
1277 r = InitializeCamera();
1278 TryCatch(r == E_SUCCESS, , "InitializeCamera [%s]", GetErrorMessage(r));
1280 r = InitializeFlashMode();
1281 AppLogDebug("InitFlashMode fail [%s]", GetErrorMessage(r));
1283 r = GetValue(SELF_PORTRAIT_ENABLE, selfPortraitEnable);
1286 selfPortraitEnable = CAM_SELF_PORTRAIT_MODE_PRIMARY;
1289 if (selfPortraitEnable == CAM_SELF_PORTRAIT_MODE_SECONDARY)
1291 SetFlip(CAMERA_FLIP_HORIZONTAL);
1294 else if (__pCamera != null)
1296 AppLogDebug("CAMERA_MODE_SNAPSHOT::INITIALIZED");
1298 r = CreateThumbnail(CAMERA_MODE_SNAPSHOT);
1299 AppLogDebug("CreateThumbnail [%s]", GetErrorMessage(r));
1301 r = ToggleCameraCamcorder(CAMERA_MODE_SNAPSHOT);
1302 TryCatch(r == E_SUCCESS, , "ToggleCameraCamcorder [%s]", GetErrorMessage(r));
1305 else if (mode == CAMERA_MODE_RECORD)
1307 if (__pCamera == null)
1309 AppLogDebug("CAMERA_MODE_RECORD::NOT_INITIALIZED");
1310 #if 0 //varialbe not in use
1311 if (__pContentManager == null)
1313 __pContentManager = new (std::nothrow) ContentManager();
1315 r = __pContentManager->Construct();
1316 TryCatch(r == E_SUCCESS, , "__pContentManager->Construct [%s]", GetErrorMessage(r));
1318 if (__pVideoContentInfo == null)
1320 __pVideoContentInfo = new (std::nothrow) VideoContentInfo();
1322 r = __pVideoContentInfo->Construct(null);
1323 TryCatch(r == E_SUCCESS, , "__pVideoContentInfo->Construct [%s]", GetErrorMessage(r));
1327 r = CreateThumbnail(CAMERA_MODE_RECORD);
1328 AppLogDebug("CreateThumbnail [%s]", GetErrorMessage(r));
1330 r = InitializeCamcorder();
1331 TryCatch(r == E_SUCCESS, , "InitializeCamcorder [%s]", GetErrorMessage(r));
1333 r = InitializeFlashMode();
1334 AppLogDebug("InitFlashMode fail [%s]", GetErrorMessage(r));
1336 r = GetValue(SELF_PORTRAIT_ENABLE, selfPortraitEnable);
1339 selfPortraitEnable = CAM_SELF_PORTRAIT_MODE_PRIMARY;
1342 if (selfPortraitEnable == CAM_SELF_PORTRAIT_MODE_SECONDARY)
1344 SetFlip(CAMERA_FLIP_HORIZONTAL);
1347 else if (__pCamera != null)
1349 AppLogDebug("CAMERA_MODE_RECORD::INITIALIZED");
1351 if (__pVideoRecorder == null)
1353 __pVideoRecorder = new (std::nothrow) VideoRecorder();
1354 __pVideoRecorder->Construct(*this, *__pCamera);
1357 r = CreateThumbnail(CAMERA_MODE_RECORD);
1358 AppLogDebug("CreateThumbnail [%s]", GetErrorMessage(r));
1360 r = ToggleCameraCamcorder(CAMERA_MODE_RECORD);
1361 TryCatch(r == E_SUCCESS, , "ToggleCameraCamcorder [%s]", GetErrorMessage(r));
1362 InitializeFlashMode();
1365 __cameraMode = mode;
1367 __isInitCamera = true;
1369 AppLogDebug("EXIT");
1373 AppLogDebug("EXIT - CATCH");
1374 __isInitCamera = false;
1378 Tizen::Graphics::Bitmap*
1379 CameraPresentationModel::GetLatestThumbnail(void)
1381 AppLogDebug("ENTER");
1384 AppLogDebug("__pBitmap NOT null");
1385 AppLogDebug("EXIT");
1390 AppLogDebug("__pBitmap null");
1391 AppLogDebug("EXIT");
1397 CameraPresentationModel::GetContentCount(void)
1399 AppLogDebug("ENTER");
1400 AppLogDebug("EXIT");
1401 return __contentCount;
1404 Tizen::Base::Collection::ArrayList*
1405 CameraPresentationModel::GetContentPathListN(int mode)
1407 AppLogDebug("ENTER");
1408 result r = E_SUCCESS;
1409 ContentDirectory contentDirectory;
1410 IList* pContentList = null;
1411 String contentFullPath = L"";
1412 String filePath = L"";
1413 String combineText = L"";
1414 int storageType = 0;
1415 int countPerPage = 0;
1416 ArrayList* pContentPath = null;
1418 r = GetValue(STORAGE_TYPE, storageType);
1421 storageType = STORAGE_TYPE_PHONE;
1424 if (storageType == STORAGE_TYPE_MEMORYCARD)
1426 filePath = STRING_CONTENT_CAMERA_PATH_EXT;
1428 else if (storageType == STORAGE_TYPE_PHONE)
1430 filePath = STRING_CONTENT_CAMERA_PATH;
1432 AppLogDebug("SearchContentFilePath :: pFilePath = %ls", filePath.GetPointer());
1434 if (mode == CAMERA_MODE_SNAPSHOT)
1436 r = contentDirectory.Construct(CONTENT_TYPE_IMAGE);
1440 r = contentDirectory.Construct(CONTENT_TYPE_VIDEO);
1442 TryCatch(r == E_SUCCESS, , "contentDirectory.Construct[%s]", GetErrorMessage(r));
1444 countPerPage = contentDirectory.GetContentDirectoryItemCount(filePath);
1445 AppLogDebug("SearchContentFilePath :: countPerPage = %d", countPerPage);
1447 pContentList = contentDirectory.GetContentDirectoryItemListN(filePath,
1451 SORT_ORDER_ASCENDING);
1452 TryCatch(pContentList != null, , "pContentList is null");
1454 __contentCount = pContentList->GetCount();
1455 AppLogDebug("SearchContentFilePath :: __contentCount = %d", __contentCount);
1457 pContentPath = new (std::nothrow) ArrayList();
1458 pContentPath->Construct();
1460 if ((pContentList != null) && (pContentList->GetCount() > 0))
1462 IEnumerator* pEnum = pContentList->GetEnumeratorN();
1463 while (pEnum->MoveNext() == E_SUCCESS)
1465 ContentInfo* pContentInfo = static_cast<ContentInfo*>(pEnum->GetCurrent());
1466 contentFullPath = pContentInfo->GetContentPath();
1468 AppLogDebug("SearchContentFilePath :: contentFullPath = %ls", contentFullPath.GetPointer());
1470 pContentPath->Add(*(new (std::nothrow) String(contentFullPath)));
1477 if (pContentList != null)
1479 pContentList->RemoveAll(true);
1480 delete pContentList;
1483 AppLogDebug("EXIT");
1484 return pContentPath;
1487 AppLogDebug("EXIT - CATCH");
1488 return pContentPath;
1492 CameraPresentationModel::SearchContentFilePath(int mode)
1494 AppLogDebug("ENTER");
1495 result r = E_SUCCESS;
1496 ContentDirectory contentDirectory;
1497 IList* pContentList = null;
1498 String contentFullPath = L"";
1499 String filePath = L"";
1500 String combineText = L"";
1501 int storageType = 0;
1502 int countPerPage = 0;
1504 r = GetValue(STORAGE_TYPE, storageType);
1507 storageType = STORAGE_TYPE_PHONE;
1510 if (storageType == STORAGE_TYPE_MEMORYCARD)
1512 filePath = STRING_CONTENT_CAMERA_PATH_EXT;
1514 else if (storageType == STORAGE_TYPE_PHONE)
1516 filePath = STRING_CONTENT_CAMERA_PATH;
1518 AppLogDebug("SearchContentFilePath :: pFilePath = %ls", filePath.GetPointer());
1520 if (mode == CAMERA_MODE_SNAPSHOT)
1522 r = contentDirectory.Construct(CONTENT_TYPE_IMAGE);
1526 r = contentDirectory.Construct(CONTENT_TYPE_VIDEO);
1528 TryCatch(r == E_SUCCESS, , "contentDirectory.Construct[%s]", GetErrorMessage(r));
1530 countPerPage = contentDirectory.GetContentDirectoryItemCount(filePath);
1531 AppLogDebug("SearchContentFilePath :: countPerPage = %d", countPerPage);
1533 pContentList = contentDirectory.GetContentDirectoryItemListN(filePath,
1537 SORT_ORDER_ASCENDING);
1538 TryCatch(pContentList != null, , "pContentList is null");
1540 __contentCount = pContentList->GetCount();
1541 AppLogDebug("SearchContentFilePath :: __contentCount = %d", __contentCount);
1543 if ((pContentList != null) && (pContentList->GetCount() > 0))
1545 IEnumerator* pEnum = pContentList->GetEnumeratorN();
1546 while (pEnum->MoveNext() == E_SUCCESS)
1548 ContentInfo* pContentInfo = static_cast<ContentInfo*>(pEnum->GetCurrent());
1549 contentFullPath = pContentInfo->GetContentPath();
1551 if (combineText.CompareTo(EMPTY_SPACE) != 0)
1553 combineText.Append(L";");
1556 combineText.Append(contentFullPath);
1563 AppLogDebug("SearchContentFilePath :: combineText = %ls", combineText.GetPointer());
1565 if (pContentList != null)
1567 pContentList->RemoveAll(true);
1568 delete pContentList;
1571 AppLogDebug("EXIT");
1575 AppLogDebug("EXIT - CATCH");
1580 CameraPresentationModel::GetContentFilePath(int currentCameraMode)
1582 AppLogDebug("ENTER");
1583 String contentFullName = L"";
1585 contentFullName = SearchContentFilePath(currentCameraMode);
1587 AppLogDebug("EXIT");
1588 return contentFullName;
1592 CameraPresentationModel::GetLatestContentName(int currentCameraMode, Tizen::Base::String& latestContentName)
1594 AppLogDebug("ENTER");
1595 String contentSubDirectory = STRING_CAMERA_FOLDER_NAME;
1596 String fileExtension = L"";
1597 String directoryEntryName = L"";
1598 String temporaryEntryName = L"";
1599 Directory contentDirectory;
1600 result r = E_SUCCESS;
1601 DirEnumerator* pDirEnum = null;
1602 DateTime directoryEntryDateTime;
1603 DateTime temporaryEntryDateTime = DateTime::GetMinValue();
1604 int storageType = STORAGE_TYPE_PHONE;
1606 AppLogDebug("__lastestContentName content name is %ls",__latestContentName.GetPointer());
1608 r = GetValue(STORAGE_TYPE, storageType);
1609 TryCatch(r == E_SUCCESS, , "Err catch [%s]", GetErrorMessage(r));
1611 if (storageType == STORAGE_TYPE_PHONE)
1613 r = contentDirectory.Construct(Environment::GetMediaPath().GetPointer() + contentSubDirectory);
1615 AppLogDebug("GetLatestContentName::contentDirectory.Construct r = %s", GetErrorMessage(r));
1616 if (r == E_FILE_NOT_FOUND)
1618 r = contentDirectory.Create((Environment::GetMediaPath().GetPointer() + contentSubDirectory), true);
1619 TryCatch(r == E_SUCCESS, , "contentDirectory Create Fail");
1621 contentDirectory.Construct(Environment::GetMediaPath().GetPointer() + contentSubDirectory);
1624 else if (storageType == STORAGE_TYPE_MEMORYCARD)
1626 r = contentDirectory.Construct(Environment::GetExternalStoragePath().GetPointer() + contentSubDirectory);
1628 if (r == E_FILE_NOT_FOUND)
1630 r = contentDirectory.Create((Environment::GetExternalStoragePath().GetPointer() + contentSubDirectory), true);
1631 TryCatch(r == E_SUCCESS, , "contentDirectory Create Fail");
1633 contentDirectory.Construct(Environment::GetExternalStoragePath().GetPointer() + contentSubDirectory);
1637 pDirEnum = contentDirectory.ReadN();
1638 AppLogDebug("contentDirectory.ReadN()r = %s", GetErrorMessage(GetLastResult()));
1639 TryCatch(pDirEnum != null, r = E_SYSTEM, "pDirEnum is null");
1641 if (currentCameraMode == CAMERA_MODE_SNAPSHOT)
1643 r = fileExtension.Append(STRING_EXTENSION_JPG);
1644 TryCatch(r == E_SUCCESS, , "String::Append() fail[%s]", GetErrorMessage(r));
1648 r = fileExtension.Append(STRING_EXTENSION_MP4);
1649 TryCatch(r == E_SUCCESS, , "String::Append() fail[%s]", GetErrorMessage(r));
1652 while (pDirEnum->MoveNext() == E_SUCCESS)
1654 DirEntry directoryEntry = pDirEnum->GetCurrentDirEntry();
1655 directoryEntryName = directoryEntry.GetName();
1656 if (directoryEntryName.Contains(fileExtension))
1658 directoryEntryDateTime = directoryEntry.GetDateTime();
1659 AppLogDebug("DirEntry::GetDateTime() name %ls Time %ls", directoryEntryName.GetPointer(), directoryEntryDateTime.ToString().GetPointer());
1661 if (directoryEntryDateTime > temporaryEntryDateTime)
1663 temporaryEntryDateTime = directoryEntryDateTime;
1664 temporaryEntryName = directoryEntryName;
1665 AppLogDebug("dt_temp change Str %ls Time %ls", temporaryEntryName.GetPointer(), temporaryEntryDateTime.ToString().GetPointer());
1670 AppLogDebug("Dont Contains(fileExtension)");
1674 if (!(temporaryEntryName.IsEmpty()))
1676 latestContentName.Clear();
1677 r = latestContentName.Append(temporaryEntryName);
1678 TryCatch(r == E_SUCCESS, , "String::Append() fail[%s]", GetErrorMessage(r));
1680 AppLogDebug("latestContentName = %ls", latestContentName.GetPointer());
1686 AppLogDebug("EXIT");
1690 AppLogDebug("EXIT - CATCH");
1697 Tizen::Graphics::Dimension
1698 CameraPresentationModel::GetPreviewResolution(void) const
1700 AppLogDebug("ENTER");
1701 Dimension dimension(INIT, INIT);
1703 if (__pCamera != null)
1705 dimension = __pCamera->GetPreviewResolution();
1708 AppLogDebug("CameraPresentationModel::GetPreviewResolution(%d, %d)", dimension.width, dimension.height);
1710 AppLogDebug("EXIT");
1715 CameraPresentationModel::SetPreviewResolution(Tizen::Graphics::Dimension previewResolution)
1717 AppLogDebug("ENTER");
1718 result r = E_SUCCESS;
1720 r = __pCamera->SetPreviewResolution(previewResolution);
1721 TryCatch(r == E_SUCCESS, , "Camera::SetPreviewResolution fail[%s]", GetErrorMessage(r));
1723 AppLogDebug("EXIT");
1727 AppLogDebug("EXIT - CATCH");
1731 Tizen::Graphics::Dimension
1732 CameraPresentationModel::GetCaptureResolution(void) const
1734 AppLogDebug("ENTER");
1735 Dimension dimension(INIT, INIT);
1737 if (__pCamera != null)
1739 dimension = __pCamera->GetCaptureResolution();
1742 AppLogDebug("CameraPresentationModel::GetCaptureResolution(%d, %d)", dimension.width, dimension.height);
1744 AppLogDebug("EXIT");
1749 CameraPresentationModel::SetCaptureResolution(Tizen::Graphics::Dimension captureResolution)
1751 AppLogDebug("ENTER");
1752 result r = E_SUCCESS;
1754 if (__pCamera != null)
1756 r = __pCamera->SetCaptureResolution(captureResolution);
1757 TryCatch(r == E_SUCCESS, , "Camera::SetCaptureResolution fail[%s]", GetErrorMessage(r));
1759 AppLogDebug("EXIT");
1763 AppLogDebug("EXIT - CATCH");
1767 Tizen::Graphics::Dimension
1768 CameraPresentationModel::GetRecordingResolution(void) const
1770 AppLogDebug("ENTER");
1771 Dimension dimension(INIT, INIT);
1773 if (__pVideoRecorder != null)
1775 dimension = __pVideoRecorder->GetRecordingResolution();
1777 AppLogDebug("CameraPresentationModel::GetRecordingResolution(%d, %d)", dimension.width, dimension.height);
1779 AppLogDebug("EXIT");
1784 CameraPresentationModel::SetRecordingResolution(Tizen::Graphics::Dimension previewResolution)
1786 AppLogDebug("ENTER");
1787 result r = E_SUCCESS;
1789 r = __pVideoRecorder->SetRecordingResolution(previewResolution);
1790 TryCatch(r == E_SUCCESS, , "Camera::SetRecordingResolution fail[%s]", GetErrorMessage(r));
1792 AppLogDebug("EXIT");
1796 AppLogDebug("EXIT - CATCH");
1800 Tizen::Base::Collection::IList*
1801 CameraPresentationModel::GetCaptureResolutionList(void)
1803 AppLogDebug("ENTER");
1804 result r = E_SUCCESS;
1805 int selfPortraitEnable = 0;
1807 r = GetValue(SELF_PORTRAIT_ENABLE, selfPortraitEnable);
1809 if (selfPortraitEnable == CAM_SELF_PORTRAIT_MODE_PRIMARY)
1811 AppLogDebug("CAM_SELF_PORTRAIT_MODE_PRIMARY");
1812 __pCaptureResolutionList = MediaCapability::GetValueN(CAMERA_PRIMARY_CAPTURE_RESOLUTION);
1813 TryCatch(__pCaptureResolutionList != null, , "MediaCapability::GetValueN() fail[%s]", GetErrorMessage(GetLastResult()));
1817 AppLogDebug("CAM_SELF_PORTRAIT_MODE_SECONDARY");
1818 __pCaptureResolutionList = MediaCapability::GetValueN(CAMERA_SECONDARY_CAPTURE_RESOLUTION);
1819 TryCatch(__pCaptureResolutionList != null, , "MediaCapability::GetValueN() fail[%s]", GetErrorMessage(GetLastResult()));
1822 AppLogDebug("EXIT");
1823 return __pCaptureResolutionList;
1826 AppLogDebug("EXIT - CATCH");
1827 if (__pCaptureResolutionList)
1829 __pCaptureResolutionList->RemoveAll(true);
1832 delete __pCaptureResolutionList;
1834 __pCaptureResolutionList = null;
1836 return __pCaptureResolutionList;
1839 Tizen::Base::Collection::IList*
1840 CameraPresentationModel::GetPreviewResolutionList(void)
1842 AppLogDebug("ENTER");
1843 result r = E_SUCCESS;
1844 int selfPortraitEnable = 0;
1846 r = GetValue(SELF_PORTRAIT_ENABLE, selfPortraitEnable);
1848 if (selfPortraitEnable == CAM_SELF_PORTRAIT_MODE_PRIMARY)
1850 if (__pPreviewResolutionList != null)
1852 __pPreviewResolutionList->RemoveAll(true);
1853 delete __pPreviewResolutionList;
1854 __pPreviewResolutionList = null;
1856 __pPreviewResolutionList = MediaCapability::GetValueN(CAMERA_PRIMARY_PREVIEW_RESOLUTION);
1857 TryCatch(__pPreviewResolutionList != null, , "MediaCapability::GetValueN() fail[%s]", GetErrorMessage(GetLastResult()));
1861 __pPreviewResolutionList = MediaCapability::GetValueN(CAMERA_SECONDARY_PREVIEW_RESOLUTION);
1862 TryCatch(__pPreviewResolutionList != null, , "MediaCapability::GetValueN() fail[%s]", GetErrorMessage(GetLastResult()));
1865 AppLogDebug("EXIT");
1866 return __pPreviewResolutionList;
1869 AppLogDebug("EXIT - CATCH");
1870 if (__pPreviewResolutionList)
1872 __pPreviewResolutionList->RemoveAll(true);
1875 delete __pPreviewResolutionList;
1877 __pPreviewResolutionList = null;
1879 return __pPreviewResolutionList;
1882 Tizen::Base::Collection::IList*
1883 CameraPresentationModel::GetRecordingResolutionList(void)
1885 AppLogDebug("ENTER");
1886 result r = E_SUCCESS;
1887 int selfPortraitEnable = 0;
1889 r = GetValue(SELF_PORTRAIT_ENABLE, selfPortraitEnable);
1891 if (selfPortraitEnable == CAM_SELF_PORTRAIT_MODE_PRIMARY)
1893 __pRecordingResolutionList = MediaCapability::GetValueN(CAMERA_PRIMARY_RECORDING_RESOLUTION);
1894 TryCatch(__pRecordingResolutionList != null, , "MediaCapability::GetValueN() fail[%s]", GetErrorMessage(GetLastResult()));
1898 __pRecordingResolutionList = MediaCapability::GetValueN(CAMERA_PRIMARY_RECORDING_RESOLUTION);
1899 TryCatch(__pRecordingResolutionList != null, , "MediaCapability::GetValueN() fail[%s]", GetErrorMessage(GetLastResult()));
1902 AppLogDebug("EXIT");
1903 return __pRecordingResolutionList;
1906 AppLogDebug("EXIT - CATCH");
1907 if (__pRecordingResolutionList)
1909 __pRecordingResolutionList->RemoveAll(true);
1912 delete __pRecordingResolutionList;
1914 __pRecordingResolutionList = null;
1916 return __pRecordingResolutionList;
1920 CameraPresentationModel::IsPreviewState(void)
1922 AppLogDebug("ENTER");
1923 if (GetCameraState() == CAMERA_STATE_PREVIEW)
1925 AppLogDebug("IsPreviewState YES");
1926 AppLogDebug("EXIT");
1931 AppLogDebug("IsPreviewState NOT");
1932 AppLogDebug("EXIT");
1936 AppLogDebug("EXIT");
1941 CameraPresentationModel::IsCameraInstance(void)
1943 AppLogDebug("ENTER");
1944 if (__pCamera == null)
1946 AppLogDebug("EXIT - __pCamera is null");
1950 AppLogDebug("EXIT");
1955 CameraPresentationModel::IsCameraPoweredOn(void)
1957 AppLogDebug("ENTER");
1958 AppLogDebug("IsPoweredOn State[%d]", __pCamera->IsPoweredOn());
1959 AppLogDebug("EXIT");
1960 return __pCamera->IsPoweredOn();
1964 CameraPresentationModel::IsStorageCardMounted(void) const
1966 AppLogDebug("ENTER");
1967 String strState = L"";
1969 DeviceManager::GetState(StorageCard, strState);
1971 if (strState == STRING_SDCARD_MOUNTED_STATE)
1973 AppLogDebug("EXIT");
1978 AppLogDebug("EXIT");
1984 CameraPresentationModel::IsCharging(void)
1986 AppLogDebug("ENTER");
1987 bool isCharging = false;
1988 isCharging = PowerManager::IsCharging();
1989 AppLogDebug("charging status is %d",isCharging);
1990 AppLogDebug("EXIT");
1995 CameraPresentationModel::GetStartPreviewException(void)
1997 AppLogDebug("ENTER");
1998 AppLogDebug("EXIT - Error %d", __startPreviewException);
1999 return __startPreviewException;
2003 CameraPresentationModel::GetIntervalTimerRun(void) const
2005 AppLogDebug("ENTER");
2006 AppLogDebug("EXIT - __isIntervalTimerRun = %d", __isIntervalTimerRun);
2007 return __isIntervalTimerRun;
2011 CameraPresentationModel::SetIntervalTimerRun(bool intervalTimerRun)
2013 AppLogDebug("ENTER");
2014 __isIntervalTimerRun = intervalTimerRun;
2015 AppLogDebug("EXIT");
2019 CameraPresentationModel::GetPreviewState(void) const
2021 AppLogDebug("ENTER");
2022 AppLogDebug("EXIT - __isPreviewExit = %d", __isPreviewExit);
2023 return __isPreviewExit;
2027 CameraPresentationModel::StartPreview(const Tizen::Graphics::BufferInfo* pBufferInfo)
2029 AppLogDebug("ENTER");
2030 result r = E_SUCCESS;
2032 AppLogDebug("GetCameraState = %d", __pCamera->GetState());
2033 if (GetCameraState() == CAMERA_STATE_INITIALIZED || GetCameraState() == CAMERA_STATE_CAPTURED)
2035 r = __pCamera->StartPreview(pBufferInfo, false);
2036 if (r == E_DEVICE_BUSY || r == E_DEVICE_UNAVAILABLE || r == E_SYSTEM)
2038 __startPreviewException = true;
2042 __startPreviewException = false;
2044 __isPreviewExit = true;
2045 TryReturnVoid(r == E_SUCCESS, "Camera::StartPreview() fail[%s]", GetErrorMessage(r));
2049 AppLogDebug("Before the StartPreview() method is called, camera state should be CAMERA_STATE_INITIALIZED or CAMERA_STATE_CAPTURED");
2052 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_BACK_BUTTON_ACTIVATED);
2053 AppLogDebug("EXIT");
2057 CameraPresentationModel::StopPreview(void)
2059 AppLogDebug("ENTER");
2060 result r = E_SUCCESS;
2062 if (__pCamera != null)
2064 if (__pCamera->GetState() == CAMERA_STATE_PREVIEW)
2066 r = __pCamera->StopPreview();
2067 TryReturnVoid(r == E_SUCCESS, "Camera::StopPreview() [%s]", GetErrorMessage(r));
2070 AppLogDebug("EXIT");
2074 CameraPresentationModel::StopCamera(void)
2076 AppLogDebug("ENTER");
2077 result r = E_SUCCESS;
2079 if (__isInitCamera == false)
2081 AppLogDebug("Camera Construct fail or Memory allocation Fail");
2085 if (__pVideoRecorder != null)
2087 AppLogDebug("VideoRecorder State[%d]", __pVideoRecorder->GetState());
2089 if (__pVideoRecorder->GetState()== RECORDER_STATE_RECORDING
2090 || __pVideoRecorder->GetState() == RECORDER_STATE_PAUSED
2093 r = __pVideoRecorder->Stop();
2094 TryReturnVoid(r == E_SUCCESS, "__pVideoRecorder::Stop() [%s]", GetErrorMessage(r));
2098 if (__pCamera != null)
2100 AppLogDebug("Camera State[%d]", __pCamera->GetState());
2102 if (__pCamera->GetState() == CAMERA_STATE_PREVIEW)
2104 r = __pCamera->StopPreview();
2105 TryReturnVoid(r == E_SUCCESS, "Camera::StopPreview() [%s]", GetErrorMessage(r));
2108 if (__pCamera->IsPoweredOn() == true)
2110 r = __pCamera->PowerOff();
2111 TryReturnVoid(r == E_SUCCESS, "Camera::PowerOff() [%s]", GetErrorMessage(r));
2114 AppLogDebug("EXIT");
2118 CameraPresentationModel::Capture(void)
2120 AppLogDebug("ENTER");
2121 result r = E_SUCCESS;
2123 if (GetCameraState() == CAMERA_STATE_PREVIEW)
2125 r = __pCamera->Capture();
2126 TryReturnVoid( r == E_SUCCESS, "Camera::Capture() fail[%s]", GetErrorMessage(r));
2130 AppLogDebug("Before the Capture() method is called, camera state should be CAMERA_STATE_PREVIEW");
2132 AppLogDebug("EXIT");
2136 CameraPresentationModel::GetMaxRecordingTime(void)
2138 AppLogDebug("ENTER");
2139 long getMaxRecordingTime = 0;
2141 getMaxRecordingTime = __pVideoRecorder->GetMaxRecordingTime();
2143 AppLogDebug("GetMaxRecordingTime = %d EXIT", getMaxRecordingTime);
2144 return getMaxRecordingTime;
2148 CameraPresentationModel::GetRecordingSize(void)
2150 AppLogDebug("ENTER");
2151 long getRecordingSize = 0;
2153 getRecordingSize = __pVideoRecorder->GetRecordingSize();
2155 AppLogDebug("EXIT - GetRecordingSize = %d", getRecordingSize);
2156 return getRecordingSize;
2160 CameraPresentationModel::StartRecord(void)
2162 AppLogDebug("ENTER");
2163 String* pFullFileName = null;
2164 result r = E_SUCCESS;
2165 long maxRecordDefaultTime = 0;
2166 String camcorderTemporaryFilePath;
2167 RecordingRotation rotate = RECORDING_ROTATION_NONE;
2168 int storageType = STORAGE_TYPE_PHONE;
2170 __onVideoRecorderStarted = true;
2172 AppLogDebug("Record GetRecorderState = %d", GetRecorderState());
2173 if (GetRecorderState() == RECORDER_STATE_PAUSED || GetRecorderState() == RECORDER_STATE_PAUSING)
2175 AppLogDebug("RECORDER_STATE_PAUSED or RECORDER_STATE_PAUSING ==> RECORDER_STATE_RECORDING");
2177 r = __pVideoRecorder->Record();
2178 TryCatch(r == E_SUCCESS, , "VideoRecorder::Record() fail[%s]", GetErrorMessage(r));
2180 r = SetFlashModeOnRecord(true);
2181 AppLogDebug("SetFlashModeOnRecord fail[%s]", GetErrorMessage(r));
2183 AppLogDebug("EXIT");
2187 r = GetValue(STORAGE_TYPE, storageType);
2190 storageType = STORAGE_TYPE_PHONE;
2193 if (storageType == STORAGE_TYPE_PHONE)
2195 camcorderTemporaryFilePath.Format(MAX_DIRECTORY_PATH_LENGTH, L"%ls%ls", App::GetInstance()->GetAppRootPath().GetPointer(), STRING_CAMCORDER_TEMPORARY_FILE);
2199 camcorderTemporaryFilePath.Format(MAX_DIRECTORY_PATH_LENGTH, L"%ls%ls", Environment::GetExternalStoragePath().GetPointer(), STRING_CAMCORDER_TEMPORARY_FILE_EXT);
2202 pFullFileName = new (std::nothrow) String();
2203 r = CreateFileName(*pFullFileName);
2204 TryCatch(r == E_SUCCESS, , "pFullFileName is null");
2206 __latestContentName.Clear();
2207 r = __latestContentName.Append(pFullFileName->GetPointer());
2208 TryCatch(r == E_SUCCESS, , "String::Append() fail[%s]", GetErrorMessage(r));
2210 AppLogDebug("Record pFullFileName = %ls", pFullFileName->GetPointer());
2211 if (__pVideoRecorder == null)
2213 __pVideoRecorder = new (std::nothrow) VideoRecorder();
2214 __pVideoRecorder->Construct(*this, *__pCamera);
2217 r = __pVideoRecorder->SetQuality(RECORDING_QUALITY_HIGH);
2218 TryCatch(r == E_SUCCESS, , "VideoRecorder::SetQuality() fail[%s]", GetErrorMessage(r));
2220 maxRecordDefaultTime = RECORD_DEFAULT_SEC * SECONDS_PER_MINUTE;
2222 r = __pVideoRecorder->SetMaxRecordingTime(maxRecordDefaultTime);
2223 TryCatch(r == E_SUCCESS, , "VideoRecorder::SetMaxRecordingTime() fail[%s]", GetErrorMessage(r));
2225 r = __pVideoRecorder->SetFormat(CODEC_AAC, CODEC_MPEG4, MEDIA_CONTAINER_MP4);
2226 TryCatch(r == E_SUCCESS, , "VideoRecorder::SetFormat() fail[%s]", GetErrorMessage(r));
2228 rotate = GetRecordingRotation();
2229 AppLogDebug("StartRecord rotate = %d",rotate);
2231 r = __pVideoRecorder->SetRecordingRotation(rotate);
2232 TryCatch(r == E_SUCCESS, , "VideoRecorder::SetRecordingRotation() fail[%s]", GetErrorMessage(r));
2234 AppLogDebug("latest file name is %ls",__latestContentName.GetPointer());
2235 r = __pVideoRecorder->CreateVideoFile(__latestContentName, true);
2236 AppLogDebug("create video file result is %s",GetErrorMessage(r));
2237 TryCatch(r == E_SUCCESS, , "VideoRecorder::CreateVideoFile() fail[%s]", GetErrorMessage(r));
2239 r = __pVideoRecorder->Record();
2240 TryCatch(r == E_SUCCESS, , "VideoRecorder::Record() fail[%s]", GetErrorMessage(r));
2242 delete pFullFileName;
2243 pFullFileName = null;
2245 r = SetFlashModeOnRecord(true);
2246 AppLogDebug("SetFlashModeOnRecord fail[%s]", GetErrorMessage(r));
2248 AppLogDebug("EXIT");
2252 AppLogDebug("EXIT - CATCH");
2253 __onVideoRecorderStarted = false;
2254 delete pFullFileName;
2255 pFullFileName = null;
2259 CameraPresentationModel::SetCancelRecord(bool isCancel)
2261 AppLogDebug("ENTER");
2262 __isCancelRecord = isCancel;
2263 AppLogDebug("EXIT");
2267 CameraPresentationModel::StopRecord(void)
2269 AppLogDebug("ENTER");
2270 result r = E_SUCCESS;
2272 if (__pVideoRecorder != null)
2274 r = __pVideoRecorder->Stop();
2275 AppLogDebug("stop record result is %s",GetErrorMessage(r));
2276 //TryReturnVoid(r == E_SUCCESS, "VideoRecorder::Stop() fail[%s]", GetErrorMessage(r));
2278 AppLogDebug("EXIT");
2283 CameraPresentationModel::CloseRecord(void)
2285 AppLogDebug("ENTER");
2286 result r = E_SUCCESS;
2288 if (__pVideoRecorder != null)
2290 r = __pVideoRecorder->Close();
2291 TryReturnVoid(r == E_SUCCESS, "VideoRecorder::Close() fail[%s]", GetErrorMessage(r));
2293 AppLogDebug("EXIT");
2297 CameraPresentationModel::CancelRecord(void)
2299 AppLogDebug("ENTER");
2300 result r = E_SUCCESS;
2302 if (__pVideoRecorder != null)
2304 r = __pVideoRecorder->Cancel();
2305 TryReturnVoid(r == E_SUCCESS, "VideoRecorder::Cancel() fail[%s]", GetErrorMessage(r));
2307 AppLogDebug("EXIT");
2311 CameraPresentationModel::PauseRecord(void)
2313 AppLogDebug("ENTER");
2314 result r = E_SUCCESS;
2316 if (__pVideoRecorder != null)
2318 r = __pVideoRecorder->Pause();
2319 TryReturnVoid(r == E_SUCCESS, "VideoRecorder::Pause() fail[%s]", GetErrorMessage(r));
2321 AppLogDebug("EXIT");
2325 CameraPresentationModel::SetFlip(CameraFlipType type)
2327 AppLogDebug("ENTER");
2328 result r = E_SUCCESS;
2329 int selfPortraitEnable = 0;
2331 r = GetValue(SELF_PORTRAIT_ENABLE, selfPortraitEnable);
2333 if (selfPortraitEnable == CAM_SELF_PORTRAIT_MODE_PRIMARY)
2335 r = GetMediaCapability(CAMERA_PRIMARY_FLIP);
2339 r = GetMediaCapability(CAMERA_SECONDARY_FLIP);
2344 r = __pCamera->SetFlip(type);
2345 TryReturnVoid(r == E_SUCCESS, "Camera::SetFlip() [%s]", GetErrorMessage(r));
2349 AppLogDebug("SetFlip is not support");
2351 AppLogDebug("EXIT");
2355 CameraPresentationModel::GetFlip(void) const
2357 AppLogDebug("ENTER");
2358 AppLogDebug("EXIT");
2359 return __pCamera->GetFlip();
2363 CameraPresentationModel::SetFocusMode(CameraFocusMode mode)
2365 AppLogDebug("ENTER");
2366 result r = E_SUCCESS;
2368 r = __pCamera->SetFocusMode(mode);
2369 TryReturnVoid(r == E_SUCCESS, "Camera::SetFocusMode() [%s]", GetErrorMessage(r));
2370 AppLogDebug("EXIT");
2374 CameraPresentationModel::SetContinuousAutoFocus(void)
2376 AppLogDebug("ENTER");
2377 result r = E_SUCCESS;
2379 if (__pCamera != null)
2381 r = __pCamera->SetFocusMode(CAMERA_FOCUS_MODE_CONTINUOUS_AUTO);
2382 TryReturnVoid(r == E_SUCCESS, "Camera::SetFocusMode() [%s]", GetErrorMessage(r));
2384 r = __pCamera->SetAutoFocus(true);
2385 TryReturnVoid(r == E_SUCCESS, "Camera::SetAutoFocus() [%s]", GetErrorMessage(r));
2387 AppLogDebug("EXIT");
2391 CameraPresentationModel::SetAutoFocusPoint(const Tizen::Graphics::Point& currentPosition)
2393 AppLogDebug("ENTER");
2394 result r = E_SUCCESS;
2395 ArrayList currentPositionList;
2396 currentPositionList.Construct();
2397 currentPositionList.Add(currentPosition);
2399 r = __pCamera->SetFocusMode(CAMERA_FOCUS_MODE_NORMAL);
2400 TryReturnVoid(r == E_SUCCESS, "Camera::SetFocusMode() [%s]", GetErrorMessage(r));
2402 r = __pCamera->SetAutoFocusPoint(currentPositionList);
2403 TryReturnVoid(r == E_SUCCESS, "Camera::SetAutoFocusPoint() [%s]", GetErrorMessage(r));
2405 r = __pCamera->SetAutoFocus(true);
2406 TryReturnVoid(r == E_SUCCESS, "Camera::SetAutoFocus() [%s]", GetErrorMessage(r));
2407 AppLogDebug("EXIT");
2411 CameraPresentationModel::GetExposure(void) const
2413 AppLogDebug("ENTER");
2414 int exposureValue = 0;
2416 exposureValue = __pCamera->GetExposure();
2418 AppLogDebug("EXIT");
2419 return exposureValue;
2423 CameraPresentationModel::SetExposure(int exposureValue)
2425 AppLogDebug("ENTER");
2426 result r = E_SUCCESS;
2428 exposureValue = MAX_CAMERA_EXPOSURE_VALUE - exposureValue;
2430 r = __pCamera->SetExposure(exposureValue);
2431 TryReturnVoid(r == E_SUCCESS, "SetExposure() fail[%s]", GetErrorMessage(r));
2432 AppLogDebug("EXIT");
2436 CameraPresentationModel::GetBrightness(void) const
2438 AppLogDebug("ENTER");
2439 int brightnessValue = 0;
2441 brightnessValue = __pCamera->GetBrightness();
2443 AppLogDebug("EXIT");
2444 return brightnessValue;
2448 CameraPresentationModel::SetBrightness(int brightnessValue)
2450 AppLogDebug("ENTER");
2451 result r = E_SUCCESS;
2453 brightnessValue = MAX_CAMERA_EXPOSURE_VALUE - brightnessValue;
2455 r = __pCamera->SetBrightness(brightnessValue);
2456 TryReturnVoid(r == E_SUCCESS, "Camera::SetBrightness() fail[%s]", GetErrorMessage(r));
2457 AppLogDebug("EXIT");
2461 CameraPresentationModel::GetWhiteBalance(void) const
2463 AppLogDebug("ENTER");
2464 CameraWhiteBalance whiteBalanceValue = CAMERA_WHITE_BALANCE_AUTO;
2466 whiteBalanceValue = __pCamera->GetWhiteBalance();
2468 AppLogDebug("EXIT");
2469 return whiteBalanceValue;
2473 CameraPresentationModel::SetWhiteBalance(CameraWhiteBalance whitebalanceValue)
2475 AppLogDebug("ENTER");
2476 result r = E_SUCCESS;
2478 r = __pCamera->SetWhiteBalance(whitebalanceValue);
2480 AppLogDebug("EXIT");
2484 Tizen::Base::Collection::IList*
2485 CameraPresentationModel::GetIsoList(void)
2487 AppLogDebug("ENTER");
2488 result r = E_SUCCESS;
2489 int selfPortraitEnable = 0;
2491 r = GetValue(SELF_PORTRAIT_ENABLE, selfPortraitEnable);
2493 if (selfPortraitEnable == CAM_SELF_PORTRAIT_MODE_PRIMARY)
2495 __pIsoList = MediaCapability::GetValueN(CAMERA_PRIMARY_ISO_LEVEL);
2496 TryCatch(__pIsoList != null, , "MediaCapability::GetValueN() fail[%s]", GetErrorMessage(GetLastResult()));
2500 __pIsoList = MediaCapability::GetValueN(CAMERA_SECONDARY_ISO_LEVEL);
2501 TryCatch(__pIsoList != null, , "MediaCapability::GetValueN() fail[%s]", GetErrorMessage(GetLastResult()));
2504 AppLogDebug("EXIT");
2508 AppLogDebug("EXIT - CATCH");
2511 __pIsoList->RemoveAll(true);
2522 CameraPresentationModel::GetIsoLevel(void) const
2524 AppLogDebug("ENTER");
2525 CameraIsoLevel isoValue = CAMERA_ISO_DEFAULT;
2527 isoValue = __pCamera->GetIsoLevel();
2529 AppLogDebug("EXIT");
2534 CameraPresentationModel::SetIsoLevel(CameraIsoLevel isoValue)
2536 AppLogDebug("ENTER");
2537 result r = E_SUCCESS;
2539 r = __pCamera->SetIsoLevel(isoValue);
2540 TryReturnVoid(r == E_SUCCESS, "SetIsoLevel() fail[%s]", GetErrorMessage(r));
2541 AppLogDebug("EXIT");
2545 CameraPresentationModel::GetMaxZoomLevel(void) const
2547 AppLogDebug("ENTER");
2550 zoomLevel = __pCamera->GetMaxZoomLevel();
2552 AppLogDebug("EXIT");
2557 CameraPresentationModel::GetZoomLevel(void) const
2559 AppLogDebug("ENTER");
2562 zoomLevel = __pCamera->GetZoomLevel();
2564 AppLogDebug("EXIT");
2569 CameraPresentationModel::SetZoomValue(int zoomValue)
2571 AppLogDebug("ENTER");
2572 result r = E_SUCCESS;
2574 int currentZoomValue = __pCamera->GetZoomLevel();
2576 if (currentZoomValue < zoomValue)
2578 for (int i = currentZoomValue; i < zoomValue; i++)
2580 r = __pCamera->ZoomIn();
2581 TryReturnVoid(r == E_SUCCESS, "ZoomIn() fail[%s]", GetErrorMessage(r));
2586 for (int i = currentZoomValue; i > zoomValue; i--)
2588 r = __pCamera->ZoomOut();
2589 TryReturnVoid(r == E_SUCCESS, "ZoomOut() fail[%s]", GetErrorMessage(r));
2592 AppLogDebug("EXIT");
2596 CameraPresentationModel::GetFlashMode(void) const
2598 AppLogDebug("ENTER");
2599 CameraFlashMode cameraFlashMode = CAMERA_FLASH_MODE_OFF;
2601 cameraFlashMode = __pCamera->GetFlashMode();
2603 AppLogDebug("Get flashMode = %d", cameraFlashMode);
2605 AppLogDebug("EXIT");
2606 return cameraFlashMode;
2610 CameraPresentationModel::SetFlashModeOnRecord(bool flashOn)
2612 AppLogDebug("ENTER");
2613 result ret = E_SUCCESS;
2614 int selfPortraitEnable = 0;
2617 ret = GetValue(SELF_PORTRAIT_ENABLE, selfPortraitEnable);
2618 if (ret != E_SUCCESS)
2620 selfPortraitEnable = CAM_SELF_PORTRAIT_MODE_PRIMARY;
2623 if (selfPortraitEnable == CAM_SELF_PORTRAIT_MODE_PRIMARY)
2625 ret = GetMediaCapability(CAMERA_PRIMARY_FLASH_MODE);
2629 ret = GetMediaCapability(CAMERA_SECONDARY_FLASH_MODE);
2632 if (ret == E_SUCCESS)
2634 if (selfPortraitEnable == CAM_SELF_PORTRAIT_MODE_PRIMARY)
2636 ret = __pCameraSettingsPresentationModel->GetValue(SECTION_CAMCORDER, FLASH_MODE_PRIMARY, flashMode);
2640 ret = __pCameraSettingsPresentationModel->GetValue(SECTION_CAMCORDER, FLASH_MODE_SECONDARY, flashMode);
2642 TryCatch(ret == E_SUCCESS, , "GetValue() fail[%s]", GetErrorMessage(ret));
2644 AppLogDebug("flashMode = %d", flashMode);
2646 if (__pCamera->IsPoweredOn() == true && flashMode == FLASH_TYPE_ON)
2648 AppLogDebug("SetFlashModeOnRecord flashOn = %d", flashOn);
2652 ret = __pCamera->SetFlashMode(CAMERA_FLASH_MODE_CONTINUOUS);
2653 TryCatch(ret == E_SUCCESS, , "SetFlashMode() fail[%s]", GetErrorMessage(ret));
2657 ret = __pCamera->SetFlashMode(CAMERA_FLASH_MODE_ON); //CAMERA_FLASH_MODE_OFF >>is TAF don't flash on
2658 TryCatch(ret == E_SUCCESS, , "SetFlashMode() fail[%s]", GetErrorMessage(ret));
2663 AppLogDebug("Camera PoweredOff status");
2667 AppLogDebug("EXIT");
2671 AppLogDebug("EXIT - CATCH");
2676 CameraPresentationModel::SetFlashMode(CameraFlashMode mode)
2678 AppLogDebug("ENTER");
2679 result r = E_SUCCESS;
2681 AppLogDebug("Set flashMode = %d", mode);
2683 if (__pCamera != null)
2685 if (mode == CAMERA_FLASH_MODE_OFF)
2687 if (__pCamera->IsFlashOn())
2689 r = __pCamera->SetFlashMode(CAMERA_FLASH_MODE_OFF);
2690 AppLogDebug("Set SetFlashMode = %s", GetErrorMessage(r));
2695 r = __pCamera->SetFlashMode(mode);
2696 AppLogDebug("Set SetFlashMode = %s", GetErrorMessage(r));
2701 AppLogDebug("__pCamera is null");
2704 AppLogDebug("EXIT");
2708 Tizen::Ui::OrientationStatus
2709 CameraPresentationModel::GetOrientation(void) const
2711 AppLogDebug("ENTER");
2712 AppLogDebug("EXIT");
2717 CameraPresentationModel::SetOrientation(Tizen::Ui::OrientationStatus dir)
2719 AppLogDebug("ENTER");
2720 AppLogDebug("EXIT");
2725 CameraPresentationModel::GetAppControlRequestType(void) const
2727 AppLogDebug("ENTER");
2728 AppLogDebug("EXIT");
2729 return __appControlRequestType;
2733 CameraPresentationModel::SetAppControlRequestType(int requestType)
2735 AppLogDebug("ENTER");
2736 __appControlRequestType = requestType;
2737 AppLogDebug("EXIT");
2741 CameraPresentationModel::GetErrorResult(void) const
2743 AppLogDebug("ENTER");
2744 AppLogDebug("EXIT");
2745 return __errorResult;
2749 CameraPresentationModel::SetErrorResult(const Tizen::Base::String& string)
2751 AppLogDebug("ENTER");
2752 __errorResult = string;
2753 AppLogDebug("EXIT");
2756 Tizen::System::BatteryLevel
2757 CameraPresentationModel::GetBatteryLevel(void) const
2759 AppLogDebug("ENTER");
2760 BatteryLevel batteryLevel;
2762 batteryLevel = PowerManager::GetCurrentBatteryLevel();
2764 AppLogDebug("EXIT");
2765 return batteryLevel;
2768 Tizen::Media::CameraState
2769 CameraPresentationModel::GetCameraState(void) const
2771 AppLogDebug("ENTER");
2772 TryCatch(__pCamera != null, , "__pCamera is null");
2774 AppLogDebug("EXIT");
2775 return __pCamera->GetState();
2778 AppLogDebug("EXIT - CATCH");
2779 return CAMERA_STATE_ERROR;
2782 Tizen::Media::RecorderState
2783 CameraPresentationModel::GetRecorderState(void) const
2785 AppLogDebug("ENTER");
2786 TryCatch(__pVideoRecorder != null, , "__pVideoRecorder is null");
2788 AppLogDebug("EXIT");
2789 return __pVideoRecorder->GetState();
2792 AppLogDebug("EXIT - CATCH");
2793 return RECORDER_STATE_ERROR;
2797 CameraPresentationModel::GetAvailableStorageSpace(void) const
2799 AppLogDebug("ENTER");
2800 result r = E_SUCCESS;
2801 int storageType = STORAGE_TYPE_PHONE;
2802 long long availableStorageSpace = 0;
2804 r = GetValue(STORAGE_TYPE, storageType);
2807 storageType = STORAGE_TYPE_PHONE;
2810 if (storageType == STORAGE_TYPE_PHONE)
2812 String key(STRING_KEY_STORAGE_PHONE);
2813 r = RuntimeInfo::GetValue(key, availableStorageSpace);
2814 TryCatch(r == E_SUCCESS, , "To get a value is fail");
2816 else if (storageType == STORAGE_TYPE_MEMORYCARD)
2818 if (IsStorageCardMounted() == true)
2820 String key(STRING_KEY_STORAGE_SDCARD);
2822 r = RuntimeInfo::GetValue(key, availableStorageSpace);
2823 TryCatch(r == E_SUCCESS, , "To get a value is fail");
2827 availableStorageSpace = 0;
2831 AppLogDebug("EXIT - availableStorageSpace = %ld", availableStorageSpace);
2832 return availableStorageSpace;
2835 AppLogDebug("EXIT - CATCH");
2836 availableStorageSpace = 0;
2837 return availableStorageSpace;
2841 CameraPresentationModel::ZoomIn(void)
2843 AppLogDebug("ENTER");
2844 result r = E_SUCCESS;
2846 r = __pCamera->ZoomIn();
2847 TryReturnVoid(r == E_SUCCESS, "ZoomIn() fail[%s]", GetErrorMessage(r));
2848 AppLogDebug("EXIT");
2852 CameraPresentationModel::ZoomOut(void)
2854 AppLogDebug("ENTER");
2855 result r = E_SUCCESS;
2857 r = __pCamera->ZoomOut();
2858 TryReturnVoid(r == E_SUCCESS, "ZoomOut() fail[%s]", GetErrorMessage(r));
2859 AppLogDebug("EXIT");
2863 CameraPresentationModel::SetExifOrientation(int orientation)
2865 AppLogDebug("ENTER");
2866 result r = E_SUCCESS;
2868 switch (orientation)
2870 case CAM_SET_EXIF_ORIENTATION_MODE_PORTRAIT:
2872 r = __pCamera->SetExifOrientation(CAMERA_EXIF_ORIENTATION_RIGHT_TOP);
2876 case CAM_SET_EXIF_ORIENTATION_MODE_PORTRAIT_REVERSE:
2878 r = __pCamera->SetExifOrientation(CAMERA_EXIF_ORIENTATION_LEFT_BOTTOM);
2882 case CAM_SET_EXIF_ORIENTATION_MODE_LANDSCAPE:
2884 r = __pCamera->SetExifOrientation(CAMERA_EXIF_ORIENTATION_TOP_LEFT);
2888 case CAM_SET_EXIF_ORIENTATION_MODE_LANDSCAPE_REVERSE:
2890 r = __pCamera->SetExifOrientation(CAMERA_EXIF_ORIENTATION_BOTTOM_RIGHT);
2897 AppLogDebug("__pCamera->SetExifOrientation() fail[%s]", GetErrorMessage(r));
2899 AppLogDebug("EXIT");
2904 CameraPresentationModel::KeepScreenOnState(bool keepOn, bool dimming)
2906 result r = E_FAILURE;
2907 AppLogDebug("ENTER");
2909 AppLogDebug("PowerManager keepOn : %d dimming : %d", keepOn, dimming);
2911 r = PowerManager::KeepScreenOnState(keepOn, dimming);
2912 TryReturnVoid(r == E_SUCCESS, "PowerManager::KeepScreenOnState() failed:%s", GetErrorMessage(r));
2913 AppLogDebug("EXIT");
2917 CameraPresentationModel::AddPresentationChangedEventListener(ICameraEventListner& pObserverListener)
2919 AppLogDebug("ENTER");
2920 __pCameraListener = &pObserverListener;
2921 AppLogDebug("EXIT");
2925 CameraPresentationModel::RemovePresentationChangedEventListener(ICameraEventListner* pObserverListener)
2927 AppLogDebug("ENTER");
2928 __pCameraListener = pObserverListener;
2929 AppLogDebug("EXIT");
2933 CameraPresentationModel::CallOnPresentationModeChanged(CameraActionEvent event)
2935 AppLogDebug("ENTER");
2936 AppLogDebug("CallOnPresentationModeChanged - event = %d", event);
2937 if (__pCameraListener != null)
2939 __pCameraListener->OnCameraActionPerformed(event);
2941 AppLogDebug("EXIT");
2945 CameraPresentationModel::ResetCameraSettingsRegistry(void)
2947 AppLogDebug("ENTER");
2948 result r = E_SUCCESS;
2950 r = __pCameraSettingsPresentationModel->ResetCameraSettingsRegistry();
2951 TryCatch(r == E_SUCCESS, , "Registry::SetValue() failed[%s]", GetErrorMessage(r));
2953 AppLogDebug("EXIT");
2957 AppLogDebug("EXIT - CATCH");
2962 CameraPresentationModel::ResetCameraSettings(void)
2964 AppLogDebug("ENTER");
2965 result r = E_SUCCESS;
2967 TryCatch(__pCameraSettingsPresentationModel!=null, r = E_FAILURE,"Camera Settings Presentation Model is NULL");
2969 r = __pCameraSettingsPresentationModel->SetValue(SECTION_CAMERA, EXPOSURE_VALUE, EXPOSURE_DEFAULT_VALUE);
2970 TryCatch(r == E_SUCCESS, , "Registry::GetValue() failed[%s]", GetErrorMessage(r));
2972 r = __pCameraSettingsPresentationModel->SetValue(SECTION_CAMCORDER, EXPOSURE_VALUE, EXPOSURE_DEFAULT_VALUE);
2973 TryCatch(r == E_SUCCESS, , "Registry::GetValue() failed[%s]", GetErrorMessage(r));
2975 r = __pCameraSettingsPresentationModel->SetValue(SECTION_CAMERA, BRIGHTNESS_VALUE, BRIGHTNESS_DEFAULT_VALUE);
2976 TryCatch(r == E_SUCCESS, , "Registry::GetValue() failed[%s]", GetErrorMessage(r));
2978 r = __pCameraSettingsPresentationModel->SetValue(SECTION_CAMCORDER, BRIGHTNESS_VALUE, BRIGHTNESS_DEFAULT_VALUE);
2979 TryCatch(r == E_SUCCESS, , "Registry::GetValue() failed[%s]", GetErrorMessage(r));
2981 AppLogDebug("EXIT");
2985 AppLogDebug("EXIT - CATCH %s", GetErrorMessage(r));
2990 CameraPresentationModel::GetValue(const Tizen::Base::String& entryName, int& value) const
2992 AppLogDebug("ENTER");
2993 AppLogDebug("entry name is %ls",entryName.GetPointer());
2994 AppLogDebug("entry value is %d",value);
2995 result r = E_SUCCESS;
2997 String strSectionName = SECTION_CAMERA;
2999 if (entryName.Equals(String(CURRENT_MODE)))
3001 strSectionName = SECTION_CAMERA;
3005 r = __pCameraSettingsPresentationModel->GetValue(SECTION_CAMERA, CURRENT_MODE, mode);
3006 TryCatch(r == E_SUCCESS, , "Registry::GetValue() failed[%s]", GetErrorMessage(r));
3008 if (mode == CAMERA_MODE_SNAPSHOT)
3010 strSectionName = SECTION_CAMERA;
3014 strSectionName = SECTION_CAMCORDER;
3018 r = __pCameraSettingsPresentationModel->GetValue(strSectionName, entryName, value);
3019 TryCatch(r == E_SUCCESS, , "Registry::GetValue() failed[%s]", GetErrorMessage(r));
3021 AppLogDebug("EXIT");
3025 AppLogDebug("EXIT - CATCH");
3030 CameraPresentationModel::SetValue(const Tizen::Base::String& entryName, const int value)
3032 AppLogDebug("ENTER");
3033 result r = E_SUCCESS;
3035 String strSectionName = SECTION_CAMERA;
3037 AppLogDebug("entry name is %ls",entryName.GetPointer());
3038 AppLogDebug("entry value is %d",value);
3040 if (entryName.Equals(String(CURRENT_MODE)))
3042 strSectionName = SECTION_CAMERA;
3046 r = __pCameraSettingsPresentationModel->GetValue(SECTION_CAMERA, CURRENT_MODE, mode);
3047 TryCatch(r == E_SUCCESS, , "Registry::GetValue() failed[%s]", GetErrorMessage(r));
3049 if (mode == CAMERA_MODE_SNAPSHOT)
3051 strSectionName = SECTION_CAMERA;
3055 strSectionName = SECTION_CAMCORDER;
3059 r = __pCameraSettingsPresentationModel->SetValue(strSectionName, entryName, value);
3061 /*if ( entryName.CompareTo(L"PRIMARY_FLASH_MODE") == 0)
3063 AppLogDebug("flash mode is set to value %d",value);
3064 SetFlashMode(CameraFlashMode(value));
3066 TryCatch(r == E_SUCCESS, , "Registry::SetValue() failed[%s]", GetErrorMessage(r));
3068 AppLogDebug("EXIT");
3072 AppLogDebug("EXIT - CATCH");
3077 CameraPresentationModel::GetMediaCapability(Tizen::Base::String key, bool& value) const
3079 AppLogDebug("ENTER");
3080 result r = E_SUCCESS;
3081 r = MediaCapability::GetValue(key, value);
3083 AppLogDebug("GetMediaCapability for %ls value = %d return = %s", key.GetPointer(), value, GetErrorMessage(r));
3084 TryCatch(r == E_SUCCESS, , "MediaCapability::GetValue() fail[%s]", GetErrorMessage(r));
3086 AppLogDebug("EXIT");
3090 AppLogDebug("EXIT - CATCH");
3095 CameraPresentationModel::GetMediaCapability(Tizen::Base::String key, int& value) const
3097 AppLogDebug("ENTER");
3098 result r = E_SUCCESS;
3099 r = MediaCapability::GetValue(key, value);
3101 AppLogDebug("GetMediaCapability for %ls value = %d return = %s", key.GetPointer(), value, GetErrorMessage(r));
3102 TryCatch(r == E_SUCCESS, , "MediaCapability::GetValue() fail[%s]", GetErrorMessage(r));
3104 AppLogDebug("EXIT");
3108 AppLogDebug("EXIT - CATCH");
3113 CameraPresentationModel::GetMediaCapability(Tizen::Base::String key) const
3115 AppLogDebug("ENTER");
3116 result r = E_SUCCESS;
3117 IList* pList = null;
3118 pList = MediaCapability::GetValueN(key);
3119 r = GetLastResult();
3120 AppLogDebug("GetMediaCapability for %ls return = %s", key.GetPointer(), GetErrorMessage(r));
3121 TryCatch(pList != null, , "MediaCapability::GetValueN() fail[%s]", GetErrorMessage(r));
3123 pList->RemoveAll(true);
3127 AppLogDebug("EXIT");
3131 AppLogDebug("EXIT - CATCH");
3136 CameraPresentationModel::OnCameraAutoFocused(bool completeCondition)
3138 AppLogDebug("ENTER");
3139 CameraFocusMode focusMode = CAMERA_FOCUS_MODE_NONE;
3141 if (__isIntervalTimerRun == true)
3143 AppLogDebug("__isIntervalTimerRun: true");
3147 if (completeCondition == true)
3149 focusMode = __pCamera->GetFocusMode();
3151 if (focusMode == CAMERA_FOCUS_MODE_CONTINUOUS_AUTO)
3153 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_AUTO_FOCUSED);
3155 else if (focusMode == CAMERA_FOCUS_MODE_NORMAL)
3157 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_TOUCH_AUTO_FOCUSED);
3162 AppLogDebug("completeCondition:false");
3163 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_AUTO_FOCUS_FAILED);
3165 AppLogDebug("EXIT");
3169 CameraPresentationModel::OnCameraPreviewed(Tizen::Base::ByteBuffer& previewedData, result r)
3171 AppLogDebug("ENTER");
3172 AppLogDebug("EXIT");
3176 CameraPresentationModel::OnCameraCaptured(Tizen::Base::ByteBuffer& capturedData, result r)
3178 AppLogDebug("ENTER");
3179 int shootingMode = 0;
3180 String* pFullFileName = null;
3181 ContentManager* pContentManager = null;
3182 ImageContentInfo* pImageContentInfo = null;
3183 result ret = E_SUCCESS;
3184 int storageType = 0;
3185 String FilePath= null;
3186 bool bDoScanDir= false;
3188 AppLogDebug("OnCameraCaptured :: StopCaptured = %d", __isStopCaptured);
3190 if (__isStopCaptured == true)
3192 AppLogDebug("OnCameraCaptured :: StopCaptured");
3193 __isStopCaptured = false;
3195 SetErrorResult(STRING_CAMERA_CAPTURED_ERROR);
3197 SetAppControlRequestType(APP_CONTROL_REQUEST_TYPE_FAILED);
3199 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_ERROR_OCCURRED);
3203 ret = GetValue(SHOOTING_MODE, shootingMode);
3204 TryCatch(ret == E_SUCCESS, , "GetValue() fail[%s]", GetErrorMessage(ret));
3206 if (shootingMode == CAPTURE_NORMAL_MODE)
3210 ContentId contentId;
3212 pFullFileName = new (std::nothrow) String();
3213 ret = CreateFileName(*pFullFileName);
3214 TryCatch(ret == E_SUCCESS, , "pFullFileName is null");
3216 __latestContentName.Clear();
3217 ret = __latestContentName.Append(pFullFileName->GetPointer());
3218 TryCatch(ret == E_SUCCESS, , "String::Append() fail[%s]", GetErrorMessage(ret));
3220 AppLogDebug("OnCameraCaptured pFullFileName = %ls", pFullFileName->GetPointer());
3221 pContentManager = new (std::nothrow) ContentManager();
3223 ret = pContentManager->Construct();
3224 TryCatch(ret == E_SUCCESS, , "ContentManager->Construct() failed(%s)", GetErrorMessage(r));
3227 //Code for doing ScanDirectory!!!
3228 r = GetValue(STORAGE_TYPE, storageType);
3229 TryCatch(r == E_SUCCESS, , "GetValue() fail[%s]", GetErrorMessage(r));
3231 r = CmUtility::GetDirectoryPath(storageType, FilePath);
3232 TryCatch(r == E_SUCCESS, , "GetDirectoryPath() fail[%s]", GetErrorMessage(r));
3234 if( File::IsFileExist(FilePath) != true)
3240 contentId = pContentManager->CreateContent(capturedData, pFullFileName->GetPointer());
3241 TryCatch(Tizen::Base::UuId::GetInvalidUuId() != contentId, GetLastResult(), "CreateContent failed.");
3243 pImageContentInfo = static_cast<ImageContentInfo*>(pContentManager->GetContentInfoN(contentId));
3244 TryCatch(pImageContentInfo != null, , "pImageContentInfo is null");
3249 pContentManager->ScanDirectory(FilePath, true, null , reqId);
3255 __pBitmap = pImageContentInfo->GetThumbnailN();
3256 TryCatch(__pBitmap != null, , "__pBitmap is null");
3258 delete pContentManager;
3259 pContentManager = null;
3261 delete pImageContentInfo;
3262 pImageContentInfo = null;
3264 delete pFullFileName;
3265 pFullFileName = null;
3267 AppLogDebug("ENTER:E_SUCCESS");
3269 SetAppControlRequestType(APP_CONTROL_REQUEST_TYPE_SUCCEEDED);
3271 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_CAPTURED);
3275 AppLogDebug("ENTER:E_FAILED");
3276 SetErrorResult(STRING_CAMERA_CAPTURED_ERROR);
3278 SetAppControlRequestType(APP_CONTROL_REQUEST_TYPE_FAILED);
3280 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_ERROR_OCCURRED);
3283 else if (shootingMode == CAPTURE_BURST_MODE)
3289 AppLogDebug("EXIT");
3293 AppLogDebug("EXIT - CATCH");
3294 if (__pBitmap != null)
3300 if (pContentManager != null)
3302 delete pContentManager;
3303 pContentManager = null;
3306 if (pImageContentInfo)
3308 delete pImageContentInfo;
3309 pImageContentInfo = null;
3314 delete pFullFileName;
3315 pFullFileName = null;
3318 SetErrorResult(STRING_CAMERA_CAPTURED_ERROR);
3320 SetAppControlRequestType(APP_CONTROL_REQUEST_TYPE_FAILED);
3322 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_ERROR_OCCURRED);
3326 CameraPresentationModel::OnCameraErrorOccurred(Tizen::Media::CameraErrorReason r)
3328 AppLogDebug("ENTER");
3329 result res = E_FAILURE;
3330 int currentCameraMode = 0;
3334 case CAMERA_ERROR_OUT_OF_MEMORY:
3336 AppLogDebug("camera error occurred - CAMERA_ERROR_OUT_OF_MEMORY");
3337 res = E_OUT_OF_MEMORY;
3341 case CAMERA_ERROR_DEVICE_FAILED:
3343 AppLogDebug("camera error occurred - CAMERA_ERROR_DEVICE_FAILED");
3344 res = E_DEVICE_FAILED;
3348 case CAMERA_ERROR_DEVICE_INTERRUPTED:
3350 AppLogDebug("camera error occurred - CAMERA_ERROR_DEVICE_INTERRUPTED");
3351 res = E_DEVICE_BUSY;
3362 result ret = GetValue(CURRENT_MODE, currentCameraMode);
3363 TryReturnVoid(ret == E_SUCCESS, "Faled to set value to registry[%s]", GetErrorMessage(ret));
3365 if (currentCameraMode == CAMERA_MODE_RECORD)
3367 AppLogDebug("RECORD error occurred");
3368 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_VIDEO_RECORDER_ERROR_OCCURRED);
3372 AppLogDebug("SNAPSHOT error occurred");
3373 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_ERROR_OCCURRED);
3375 AppLogDebug("EXIT");
3379 CameraPresentationModel::OnVideoRecorderCanceled(result r)
3381 AppLogDebug("ENTER");
3382 if (__pVideoRecorder != null)
3384 __pVideoRecorder->Close();
3387 if (__recorderStopException)
3389 r = __pCamera->StopPreview();
3390 TryReturnVoid(r == E_SUCCESS, "Camera::StopPreview() [%s]", GetErrorMessage(r));
3392 if (__pCamera->IsPoweredOn() == true)
3394 r = __pCamera->PowerOff();
3395 TryReturnVoid(r == E_SUCCESS, "Camera::PowerOff() [%s]", GetErrorMessage(r));
3398 AppLogDebug("EXIT");
3402 CameraPresentationModel::OnVideoRecorderClosed(result r)
3404 AppLogDebug("ENTER");
3405 # if 0 //Unused code
3406 ContentManager* pContentManager = null;
3408 ContentId contentId;
3409 String replaceFilePath;
3410 String camcorderTemporaryFilePath;
3411 int storageType = STORAGE_TYPE_PHONE;
3412 result ret = E_SUCCESS;
3414 ret = SetFlashModeOnRecord(false);
3415 AppLogDebug("SetFlashModeOnRecord fail[%s]", GetErrorMessage(ret));
3417 AppLogDebug("isCancelRecord", __isCancelRecord);
3419 if (__isCancelRecord)
3421 __onVideoRecorderStarted = false;
3422 AppLogDebug("isCancelRecord %d", __isCancelRecord);
3424 ret = RemoveVideoFile();
3425 AppLogDebug("RemoveVideoFile fail[%s]", GetErrorMessage(ret));
3427 SetAppControlRequestType(APP_CONTROL_REQUEST_TYPE_CANCELED);
3428 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_VIDEO_RECORDER_CANCELED);
3430 AppLogDebug("CANCELRECORD - EXIT");
3436 AppLogDebug("ENTER: E_SUCCESS");
3438 ret = GetValue(STORAGE_TYPE, storageType);
3439 if (ret != E_SUCCESS)
3441 storageType = STORAGE_TYPE_PHONE;
3444 if (storageType == STORAGE_TYPE_PHONE)
3446 camcorderTemporaryFilePath.Format(MAX_DIRECTORY_PATH_LENGTH, L"%ls%ls", App::GetInstance()->GetAppRootPath().GetPointer(), STRING_CAMCORDER_TEMPORARY_FILE);
3450 camcorderTemporaryFilePath.Format(MAX_DIRECTORY_PATH_LENGTH, L"%ls%ls", Environment::GetExternalStoragePath().GetPointer(), STRING_CAMCORDER_TEMPORARY_FILE_EXT);
3453 # if 0 //Contnet Manager is nto used
3454 pContentManager = new (std::nothrow) ContentManager();
3455 ret = pContentManager->Construct();
3456 TryCatch(ret == E_SUCCESS, , "ContentManager->Construct() failed(%s)", GetErrorMessage(r));
3459 AppLogDebug("latest content name is %ls",__latestContentName.GetPointer());
3460 r = ContentManager::ScanFile(__latestContentName);
3461 __CurrentVideoFileName = __latestContentName;
3463 if (storageType == STORAGE_TYPE_PHONE)
3465 replaceFilePath = Environment::GetMediaPath();
3469 replaceFilePath = Environment::GetExternalStoragePath();
3472 replaceFilePath.Append(STRING_CAMERA_FOLDER_NAME);
3473 replaceFilePath.Append("/");
3474 AppLogDebug("Replace filepath is %ls",replaceFilePath.GetPointer());
3475 __CurrentVideoFileName.Replace(replaceFilePath,"");
3476 AppLogDebug("__CurrentVideoFileName path is %ls",__CurrentVideoFileName.GetPointer());
3478 __pBitmap = CmUtility::CreateThumbnailN(__CurrentVideoFileName,CONTENT_TYPE_VIDEO);
3480 SetAppControlRequestType(APP_CONTROL_REQUEST_TYPE_SUCCEEDED);
3482 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_VIDEO_RECORDER_CLOSED);
3486 AppLogDebug("ENTER: E_FAILED");
3488 SetErrorResult(STRING_VIDEO_RECORDER_CLOSED_ERROR);
3490 SetAppControlRequestType(APP_CONTROL_REQUEST_TYPE_FAILED);
3491 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_VIDEO_RECORDER_ERROR_OCCURRED);
3494 __onVideoRecorderStarted = false;
3496 AppLogDebug("EXIT");
3501 CameraPresentationModel::OnVideoRecorderEndReached(RecordingEndCondition endCondition)
3503 AppLogDebug("ENTER");
3504 ContentManager* pContentManager = null;
3505 VideoContentInfo* videoContentInfo = null;
3506 ContentId contentId;
3507 String camcorderTemporaryFilePath;
3508 int storageType = STORAGE_TYPE_PHONE;
3509 result ret = E_SUCCESS;
3511 ret = SetFlashModeOnRecord(false);
3512 AppLogDebug("SetFlashModeOnRecord fail[%s]", GetErrorMessage(ret));
3516 ret = GetValue(STORAGE_TYPE, storageType);
3517 if (ret != E_SUCCESS)
3519 storageType = STORAGE_TYPE_PHONE;
3522 if (storageType == STORAGE_TYPE_PHONE)
3524 camcorderTemporaryFilePath.Format(MAX_DIRECTORY_PATH_LENGTH, L"%ls%ls", App::GetInstance()->GetAppRootPath().GetPointer(), STRING_CAMCORDER_TEMPORARY_FILE);
3528 camcorderTemporaryFilePath.Format(MAX_DIRECTORY_PATH_LENGTH, L"%ls%ls", Environment::GetExternalStoragePath().GetPointer(), STRING_CAMCORDER_TEMPORARY_FILE_EXT);
3531 pContentManager = new (std::nothrow) ContentManager();
3533 ret = pContentManager->Construct();
3534 TryCatch(ret == E_SUCCESS, , "ContentManager->Construct() failed(%s)", GetErrorMessage(ret));
3536 contentId = pContentManager->CreateContent(camcorderTemporaryFilePath, __latestContentName, true);
3537 TryCatch(Tizen::Base::UuId::GetInvalidUuId() != contentId, GetLastResult(), "CreateContent failed.");
3539 videoContentInfo = static_cast<VideoContentInfo*>(pContentManager->GetContentInfoN(contentId));
3540 TryCatch(videoContentInfo != null, , "videoContentInfo is null");
3545 __pBitmap = videoContentInfo->GetThumbnailN();
3546 TryCatch(__pBitmap != null, , "__pBitmap is null");
3548 delete videoContentInfo;
3549 videoContentInfo = null;
3551 delete pContentManager;
3552 pContentManager = null;
3554 SetAppControlRequestType(APP_CONTROL_REQUEST_TYPE_SUCCEEDED);
3556 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_VIDEO_RECORDER_END_REACHED);
3558 __onVideoRecorderStarted = false;
3559 AppLogDebug("EXIT");
3563 AppLogDebug("EXIT - CATCH");
3564 delete pContentManager;
3565 pContentManager = null;
3567 delete videoContentInfo;
3568 videoContentInfo = null;
3573 SetErrorResult(STRING_VIDEO_RECORDER_END_REACHED_ERROR);
3574 SetAppControlRequestType(APP_CONTROL_REQUEST_TYPE_FAILED);
3575 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_VIDEO_RECORDER_ERROR_OCCURRED);
3579 CameraPresentationModel::OnVideoRecorderErrorOccurred(RecorderErrorReason r)
3581 AppLogDebug("ENTER OnVideoRecorderErrorOccurred (%ld)", r);
3583 __recorderError = r;
3584 __pVideoRecorder->Close();
3586 SetAppControlRequestType(APP_CONTROL_REQUEST_TYPE_FAILED);
3588 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_VIDEO_RECORDER_ERROR_OCCURRED);
3590 __onVideoRecorderStarted = false;
3591 AppLogDebug("EXIT");
3595 CameraPresentationModel::OnVideoRecorderPaused(result r)
3597 AppLogDebug("ENTER");
3598 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_VIDEO_RECORDER_PAUSED);
3599 AppLogDebug("EXIT");
3603 CameraPresentationModel::OnVideoRecorderStarted(result r)
3605 AppLogDebug("ENTER");
3606 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_VIDEO_RECORDER_STARTED);
3607 AppLogDebug("EXIT");
3611 CameraPresentationModel::GetOnVideoRecorderStopped(void)
3613 AppLogDebug("ENTER");
3614 AppLogDebug("EXIT");
3615 return __onVideoRecorderStarted;
3619 CameraPresentationModel::SetOnVideoRecorderStopped(bool isCompleted)
3621 AppLogDebug("ENTER");
3622 __onVideoRecorderStarted = isCompleted;
3623 AppLogDebug("EXIT");
3627 CameraPresentationModel::OnVideoRecorderStopped(result r)
3629 AppLogDebug("ENTER");
3630 result localResult = E_SUCCESS;
3632 if (__pVideoRecorder != null)
3634 localResult = __pVideoRecorder->Close();
3635 TryCatch(localResult == E_SUCCESS, , "__pVideoRecorder::Close() fail[%s]", GetErrorMessage(localResult));
3637 __onVideoRecorderStarted = true;
3639 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_VIDEO_RECORDER_STOPPED);
3641 AppLogDebug("EXIT");
3645 AppLogDebug("EXIT - CATCH");
3646 SetAppControlRequestType(APP_CONTROL_REQUEST_TYPE_FAILED);
3647 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_VIDEO_RECORDER_ERROR_OCCURRED);
3651 CameraPresentationModel::DestroyPresentationModelInstance(void)
3653 AppLogDebug("ENTER");
3654 CameraPresentationModel* pCameraPresentationModel = CameraPresentationModel::GetInstance();
3656 delete pCameraPresentationModel;
3657 AppLogDebug("EXIT");
3661 CameraPresentationModel::UpdateThumbnail(int currentCameraMode)
3663 AppLogDebug("ENTER");
3664 result r = E_SUCCESS;
3666 r = CreateThumbnail(currentCameraMode);
3667 TryReturnVoid(r == E_SUCCESS, "CreateThumbnail() fail[%s]", GetErrorMessage(r));
3668 AppLogDebug("EXIT");
3672 CameraPresentationModel::GetStorageCardState(void) const
3674 AppLogDebug("ENTER");
3675 AppLogDebug("EXIT");
3676 return __storageCardState;
3680 CameraPresentationModel::SetStorageCardState(int storageCardState)
3682 AppLogDebug("ENTER");
3683 __storageCardState = storageCardState;
3684 AppLogDebug("EXIT");
3688 CameraPresentationModel::GetStorageCardChageState(void) const
3690 AppLogDebug("ENTER");
3691 AppLogDebug("EXIT");
3692 return __storageCardChageState;
3696 CameraPresentationModel::SetStorageCardChageState(int storageCardChageState)
3698 AppLogDebug("ENTER");
3699 __storageCardChageState = storageCardChageState;
3700 AppLogDebug("EXIT");
3704 CameraPresentationModel::StorageCardStateChaged(bool isMounted)
3706 AppLogDebug("ENTER");
3709 __storageCardState = STORAGE_CARD_STATE_MOUNT;
3713 __storageCardState = STORAGE_CARD_STATE_UNMOUNT;
3715 __pCameraSettingsPresentationModel->SetValue(SECTION_CAMERA, STORAGE_TYPE, STORAGE_TYPE_PHONE);
3717 __pCameraSettingsPresentationModel->SetValue(SECTION_CAMCORDER, STORAGE_TYPE, STORAGE_TYPE_PHONE);
3719 AppLogDebug("EXIT");
3723 CameraPresentationModel::SetDeviceManagerEventListner(void)
3725 AppLogDebug("ENTER");
3726 result r = E_SUCCESS;
3728 r = DeviceManager::AddDeviceEventListener(DEVICE_TYPE_STORAGE_CARD, *this);
3729 AppLogDebug("AddDeviceEventListener [%s] fail", GetErrorMessage(r));
3730 AppLogDebug("EXIT");
3734 CameraPresentationModel::RemoveDeviceManagerEventListner(void)
3736 AppLogDebug("ENTER");
3737 result r = E_SUCCESS;
3739 r = DeviceManager::RemoveDeviceEventListener(DEVICE_TYPE_STORAGE_CARD, *this);
3740 AppLogDebug("RemoveDeviceManagerEventListner [%s] fail", GetErrorMessage(r));
3741 AppLogDebug("EXIT");
3745 CameraPresentationModel::OnDeviceStateChanged(Tizen::System::DeviceType deviceType, const Tizen::Base::String& state)
3747 AppLogDebug("ENTER");
3748 int currentCameraMode = 0;
3749 int storageType = STORAGE_TYPE_PHONE;
3751 result r = E_SUCCESS;
3752 r = GetValue(CURRENT_MODE, currentCameraMode);
3753 TryReturnVoid(r == E_SUCCESS, "GetValue returns not E_SUCCESS", GetErrorMessage(r));
3755 if (deviceType == DEVICE_TYPE_STORAGE_CARD)
3757 switch (currentCameraMode)
3759 case CAMERA_MODE_RECORD:
3761 __pCameraSettingsPresentationModel->GetValue(SECTION_CAMCORDER, STORAGE_TYPE, storageType);
3763 if (storageType == STORAGE_TYPE_MEMORYCARD)
3765 if (IsStorageCardMounted()== false)
3767 AppLogDebug("RemoveVideoFile::GetRecorderState() = %d", __pVideoRecorder->GetState());
3769 if (__pVideoRecorder->GetState() == RECORDER_STATE_RECORDING
3770 || __pVideoRecorder->GetState() == RECORDER_STATE_PAUSED
3771 || __pVideoRecorder->GetState() == RECORDER_STATE_STARTING
3772 || __pVideoRecorder->GetState() == RECORDER_STATE_PAUSING
3775 r = RemoveVideoFile();
3776 AppLogDebug("RemoveVideoFile fail[%s]", GetErrorMessage(r));
3779 StorageCardStateChaged(false);
3781 SetAppControlRequestType(APP_CONTROL_REQUEST_TYPE_FAILED);
3783 SetStorageCardChageState(STORAGE_CARD_CHAGE_STATE_MOUNT_TO_UNMOUNT);
3784 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_STORAGE_CARD_UNMOUNT);
3788 StorageCardStateChaged(true);
3789 SetStorageCardChageState(STORAGE_CARD_CHAGE_STATE_UNKNOWN);
3794 if ( IsStorageCardMounted()== false)
3796 StorageCardStateChaged(false);
3797 SetStorageCardChageState(STORAGE_CARD_CHAGE_STATE_UNKNOWN);
3801 StorageCardStateChaged(true);
3802 SetStorageCardChageState(STORAGE_CARD_CHAGE_STATE_UNKNOWN);
3808 case CAMERA_MODE_SNAPSHOT:
3810 __pCameraSettingsPresentationModel->GetValue(SECTION_CAMERA, STORAGE_TYPE, storageType);
3812 if (storageType == STORAGE_TYPE_MEMORYCARD)
3814 if ( IsStorageCardMounted()== false)
3816 AppLogDebug("OnDeviceStateChanged state=%d", __pCamera->GetState());
3818 if (GetCameraState() == CAMERA_STATE_CAPTURED || GetCameraState() == CAMERA_STATE_CAPTURING)
3820 __isStopCaptured = true;
3824 __isStopCaptured = false;
3827 StorageCardStateChaged(false);
3829 SetAppControlRequestType(APP_CONTROL_REQUEST_TYPE_FAILED);
3830 SetStorageCardChageState(STORAGE_CARD_CHAGE_STATE_MOUNT_TO_UNMOUNT);
3831 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_STORAGE_CARD_UNMOUNT);
3835 StorageCardStateChaged(true);
3836 SetStorageCardChageState(STORAGE_CARD_CHAGE_STATE_UNKNOWN);
3841 __isStopCaptured = false;
3843 if ( IsStorageCardMounted()== false)
3845 StorageCardStateChaged(false);
3846 SetStorageCardChageState(STORAGE_CARD_CHAGE_STATE_UNKNOWN);
3850 StorageCardStateChaged(true);
3851 SetStorageCardChageState(STORAGE_CARD_CHAGE_STATE_UNKNOWN);
3861 AppLogDebug("EXIT");
3865 CameraPresentationModel::RemoveVideoFile(void)
3867 AppLogDebug("ENTER");
3868 String removeFileName;
3870 result r = E_SUCCESS;
3871 int storageType = STORAGE_TYPE_PHONE;
3873 r = GetValue(STORAGE_TYPE, storageType);
3876 storageType = STORAGE_TYPE_PHONE;
3879 removeFileName = __latestContentName;
3881 AppLogDebug("removeFileName is %ls",removeFileName.GetPointer());
3882 AppLogDebug("RemoveVideoFile::GetRecorderState() = %d", __pVideoRecorder->GetState());
3883 if (__pVideoRecorder->GetState()== RECORDER_STATE_RECORDING
3884 || __pVideoRecorder->GetState() == RECORDER_STATE_PAUSED
3885 || __pVideoRecorder->GetState() == RECORDER_STATE_STARTING
3886 || __pVideoRecorder->GetState() == RECORDER_STATE_PAUSING
3892 r = file.Construct(removeFileName, "w+");
3893 TryCatch(r == E_SUCCESS, , "file::Construct() fail[%s]", GetErrorMessage(r));
3895 r = file.Remove(removeFileName);
3896 TryCatch(r == E_SUCCESS, , "file::Remove() fail[%s]", GetErrorMessage(r));
3898 AppLogDebug("EXIT");
3902 AppLogDebug("EXIT - CATCH");
3907 CameraPresentationModel::SetDisplayResolutionType(int type)
3909 AppLogDebug("ENTER");
3910 __displayResolution = type;
3911 AppLogDebug("EXIT");
3915 CameraPresentationModel::GetDisplayResolutionType(void)
3917 AppLogDebug("ENTER");
3918 AppLogDebug("EXIT");
3919 return __displayResolution;
3922 Tizen::Media::RecordingRotation
3923 CameraPresentationModel::GetRecordingRotation(void)
3925 AppLogDebug("ENTER");
3926 RecordingRotation rotate = RECORDING_ROTATION_NONE;
3927 int selfPortraitEnable = 0;
3928 result r = E_SUCCESS;
3929 int count = sizeof(_RecordRotate) / sizeof(_RecordRotate[0]);
3931 r = GetValue(SELF_PORTRAIT_ENABLE, selfPortraitEnable);
3933 for (int i=0; i < count; i++)
3935 if ((_RecordRotate[i].camType == selfPortraitEnable) && _RecordRotate[i].orientation == GetOrientation())
3937 return _RecordRotate[i].rotate;
3940 AppLogDebug("EXIT");
3945 CameraPresentationModel::OnContentScanCompleted (RequestId reqId, const Tizen::Base::String &scanPath, result r)
3947 AppLogDebug("Enter");
3948 AppLogDebug("Exit");
3952 CameraPresentationModel::SetStartPreviewException(bool status)
3954 __startPreviewException = status;
3958 CameraPresentationModel::UpdateContentFile(void)
3960 AppLogDebug("latest content name is %ls",__latestContentName.GetPointer());
3961 ContentManager::ScanFile(__latestContentName);
3962 SetAppControlRequestType(APP_CONTROL_REQUEST_TYPE_SUCCEEDED);
3966 CameraPresentationModel::SetRecordStopException(bool currentStatus)
3968 __recorderStopException = currentStatus;
3972 CameraPresentationModel::GetRecorderErrorStatus(void)
3974 return __recorderError;
3978 CameraPresentationModel::GetUpdatedContentName(Tizen::Base::String& latestContentName)
3980 latestContentName = __latestContentName;
3984 CameraPresentationModel::SetMemoryFullException(bool status)
3986 __memoryFullException = status;
3990 CameraPresentationModel::GetMemoryFullExceptionStatus(void)
3992 long long allocatedMemory = 0;
3993 bool memoryStatus = false;
3995 allocatedMemory = CmUtility::GetAvailableMemory();
3997 if (__memoryFullException && allocatedMemory < MIN_MEMORY_NEEDED)
3999 memoryStatus = true;
4002 return memoryStatus;
4006 CameraPresentationModel::SetCurrentSourceForm(SourceForm source)
4008 __pCurrentSource = source;
4012 CameraPresentationModel::GetCurrentSourceForm(void)
4014 return __pCurrentSource;
4018 CameraPresentationModel::GetCancelRecord(void)
4020 return __isCancelRecord;