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 AppLogDebug("EXIT - CATCH");
1115 CameraPresentationModel::ToggleCameraDirection(int mode, int direction)
1117 AppLogDebug("ENTER");
1118 result r = E_SUCCESS;
1119 int captureResolutionCount = 0;
1120 Dimension* pCaptureResolution = null;
1124 __pCamera = new (std::nothrow) Camera();
1125 TryCatch(__pCamera != null, , "[FAILURE] new (std::nothrow) Camera()");
1127 if (direction == CAMERA_DIRECTION_BACK)
1129 AppLogDebug("BACK");
1131 r = __pCamera->Construct(*this, CAMERA_PRIMARY);
1132 TryCatch(r == E_SUCCESS, , "__pCamera->Construct() [%s]", GetErrorMessage(r));
1134 else if (direction == CAMERA_DIRECTION_FRONT)
1136 AppLogDebug("FRONT");
1138 r = __pCamera->Construct(*this, CAMERA_SECONDARY);
1139 TryCatch(r == E_SUCCESS, , "__pCamera->Construct() [%s]", GetErrorMessage(r));
1142 r = __pCamera->PowerOn();
1143 TryCatch(r == E_SUCCESS, , "__pCamera->PowerOn() [%s]", GetErrorMessage(r));
1145 if (mode == CAMERA_MODE_RECORD)
1147 if (__pVideoRecorder == null)
1149 __pVideoRecorder = new (std::nothrow) VideoRecorder();
1150 __pVideoRecorder->Construct(*this, *__pCamera);
1154 if (mode == CAMERA_MODE_SNAPSHOT && direction == CAMERA_DIRECTION_FRONT)
1156 __pCaptureResolutionList = __pCamera->GetSupportedCaptureResolutionListN();
1157 TryCatch(__pCaptureResolutionList != null, , "pCaptureResolutionList is null");
1159 captureResolutionCount = __pCaptureResolutionList->GetCount();
1161 pCaptureResolution = static_cast< Dimension*>(__pCaptureResolutionList->GetAt(captureResolutionCount - 1));
1162 TryCatch(pCaptureResolution != null, , " pCaptureResolution->GetAt()");
1164 r = __pCamera->SetCaptureResolution(*pCaptureResolution);
1165 TryCatch(r == E_SUCCESS, , "Camera::SetCaptureResolution fail[%s]", GetErrorMessage(r));
1168 if (direction == CAMERA_DIRECTION_FRONT)
1170 SetFlip(CAMERA_FLIP_HORIZONTAL);
1173 AppLogDebug("EXIT");
1177 AppLogDebug("EXIT - CATCH");
1178 if (__pCaptureResolutionList)
1180 __pCaptureResolutionList->RemoveAll(true);
1183 delete __pCaptureResolutionList;
1184 __pCaptureResolutionList = null;
1186 __isInitCamera = false;
1187 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_INITIALIZE_FAILED);
1193 CameraPresentationModel::GetInitCameraStatus(void) const
1195 AppLogDebug("ENTER");
1196 AppLogDebug("EXIT - __isInitCamera = %d", __isInitCamera);
1197 return __isInitCamera;
1201 CameraPresentationModel::SetMode(int mode)
1203 AppLogDebug("ENTER");
1204 result r = E_SUCCESS;
1205 String contentSubDirectory = STRING_CAMERA_FOLDER_NAME;
1206 Directory contentDirectory;
1207 int cameraSelfPortraitEnable = CAM_SELF_PORTRAIT_MODE_PRIMARY;
1208 int camcorderSelfPortraitEnable = CAM_SELF_PORTRAIT_MODE_PRIMARY;
1209 int direction = CAMERA_DIRECTION_BACK;
1210 int selfPortraitEnable = 0;
1212 AppLogDebug("SetMode __SetMode = %d && mode = %d", __cameraMode, mode);
1214 if (__pCamera != null)
1216 if (__pCamera->IsPoweredOn() == true)
1218 AppLogDebug("StopCamera or Terminate");
1220 __pCameraSettingsPresentationModel->GetValue(SECTION_CAMERA, SELF_PORTRAIT_ENABLE, cameraSelfPortraitEnable);
1222 __pCameraSettingsPresentationModel->GetValue(SECTION_CAMCORDER, SELF_PORTRAIT_ENABLE, camcorderSelfPortraitEnable);
1224 AppLogDebug("SECTION_CAMERA mode = %d && SECTION_CAMCORDER mode = %d", cameraSelfPortraitEnable, camcorderSelfPortraitEnable);
1226 GetMediaCapability(CAMERA_SECONDARY_DIRECTION, direction);
1228 if ((cameraSelfPortraitEnable == CAM_SELF_PORTRAIT_MODE_SECONDARY && camcorderSelfPortraitEnable == CAM_SELF_PORTRAIT_MODE_PRIMARY)
1229 || (cameraSelfPortraitEnable == CAM_SELF_PORTRAIT_MODE_PRIMARY && camcorderSelfPortraitEnable == CAM_SELF_PORTRAIT_MODE_SECONDARY)
1232 if (__cameraMode == mode && direction == CAMERA_DIRECTION_FRONT)
1234 AppLogDebug("StopCamera");
1239 AppLogDebug("Terminate");
1245 AppLogDebug("StopCamera");
1251 if (mode == CAMERA_MODE_SNAPSHOT)
1253 if (__pCamera == null)
1255 AppLogDebug("CAMERA_MODE_SNAPSHOT::NOT_INITIALIZED");
1258 if (__pContentManager == null)
1260 __pContentManager = new (std::nothrow) ContentManager();
1262 r = __pContentManager->Construct();
1263 TryCatch(r == E_SUCCESS, , "__pContentManager->Construct [%s]", GetErrorMessage(r));
1265 if (__pImageContentInfo == null)
1267 __pImageContentInfo = new (std::nothrow) ImageContentInfo();
1268 r = __pImageContentInfo->Construct(null);
1269 TryCatch(r == E_SUCCESS, , "__pImageContentInfo->Construct [%s]", GetErrorMessage(r));
1273 r = CreateThumbnail(CAMERA_MODE_SNAPSHOT);
1274 AppLogDebug("CreateThumbnail [%s]", GetErrorMessage(r));
1276 r = InitializeCamera();
1277 TryCatch(r == E_SUCCESS, , "InitializeCamera [%s]", GetErrorMessage(r));
1279 r = InitializeFlashMode();
1280 AppLogDebug("InitFlashMode fail [%s]", GetErrorMessage(r));
1282 r = GetValue(SELF_PORTRAIT_ENABLE, selfPortraitEnable);
1285 selfPortraitEnable = CAM_SELF_PORTRAIT_MODE_PRIMARY;
1288 if (selfPortraitEnable == CAM_SELF_PORTRAIT_MODE_SECONDARY)
1290 SetFlip(CAMERA_FLIP_HORIZONTAL);
1293 else if (__pCamera != null)
1295 AppLogDebug("CAMERA_MODE_SNAPSHOT::INITIALIZED");
1297 r = CreateThumbnail(CAMERA_MODE_SNAPSHOT);
1298 AppLogDebug("CreateThumbnail [%s]", GetErrorMessage(r));
1300 r = ToggleCameraCamcorder(CAMERA_MODE_SNAPSHOT);
1301 TryCatch(r == E_SUCCESS, , "ToggleCameraCamcorder [%s]", GetErrorMessage(r));
1304 else if (mode == CAMERA_MODE_RECORD)
1306 if (__pCamera == null)
1308 AppLogDebug("CAMERA_MODE_RECORD::NOT_INITIALIZED");
1309 #if 0 //varialbe not in use
1310 if (__pContentManager == null)
1312 __pContentManager = new (std::nothrow) ContentManager();
1314 r = __pContentManager->Construct();
1315 TryCatch(r == E_SUCCESS, , "__pContentManager->Construct [%s]", GetErrorMessage(r));
1317 if (__pVideoContentInfo == null)
1319 __pVideoContentInfo = new (std::nothrow) VideoContentInfo();
1321 r = __pVideoContentInfo->Construct(null);
1322 TryCatch(r == E_SUCCESS, , "__pVideoContentInfo->Construct [%s]", GetErrorMessage(r));
1326 r = CreateThumbnail(CAMERA_MODE_RECORD);
1327 AppLogDebug("CreateThumbnail [%s]", GetErrorMessage(r));
1329 r = InitializeCamcorder();
1330 TryCatch(r == E_SUCCESS, , "InitializeCamcorder [%s]", GetErrorMessage(r));
1332 r = InitializeFlashMode();
1333 AppLogDebug("InitFlashMode fail [%s]", GetErrorMessage(r));
1335 r = GetValue(SELF_PORTRAIT_ENABLE, selfPortraitEnable);
1338 selfPortraitEnable = CAM_SELF_PORTRAIT_MODE_PRIMARY;
1341 if (selfPortraitEnable == CAM_SELF_PORTRAIT_MODE_SECONDARY)
1343 SetFlip(CAMERA_FLIP_HORIZONTAL);
1346 else if (__pCamera != null)
1348 AppLogDebug("CAMERA_MODE_RECORD::INITIALIZED");
1350 if (__pVideoRecorder == null)
1352 __pVideoRecorder = new (std::nothrow) VideoRecorder();
1353 __pVideoRecorder->Construct(*this, *__pCamera);
1356 r = CreateThumbnail(CAMERA_MODE_RECORD);
1357 AppLogDebug("CreateThumbnail [%s]", GetErrorMessage(r));
1359 r = ToggleCameraCamcorder(CAMERA_MODE_RECORD);
1360 TryCatch(r == E_SUCCESS, , "ToggleCameraCamcorder [%s]", GetErrorMessage(r));
1361 InitializeFlashMode();
1364 __cameraMode = mode;
1366 __isInitCamera = true;
1368 AppLogDebug("EXIT");
1372 AppLogDebug("EXIT - CATCH");
1373 __isInitCamera = false;
1377 Tizen::Graphics::Bitmap*
1378 CameraPresentationModel::GetLatestThumbnail(void)
1380 AppLogDebug("ENTER");
1383 AppLogDebug("__pBitmap NOT null");
1384 AppLogDebug("EXIT");
1389 AppLogDebug("__pBitmap null");
1390 AppLogDebug("EXIT");
1396 CameraPresentationModel::GetContentCount(void)
1398 AppLogDebug("ENTER");
1399 AppLogDebug("EXIT");
1400 return __contentCount;
1403 Tizen::Base::Collection::ArrayList*
1404 CameraPresentationModel::GetContentPathListN(int mode)
1406 AppLogDebug("ENTER");
1407 result r = E_SUCCESS;
1408 ContentDirectory contentDirectory;
1409 IList* pContentList = null;
1410 String contentFullPath = L"";
1411 String filePath = L"";
1412 String combineText = L"";
1413 int storageType = 0;
1414 int countPerPage = 0;
1415 ArrayList* pContentPath = null;
1417 r = GetValue(STORAGE_TYPE, storageType);
1420 storageType = STORAGE_TYPE_PHONE;
1423 if (storageType == STORAGE_TYPE_MEMORYCARD)
1425 filePath = STRING_CONTENT_CAMERA_PATH_EXT;
1427 else if (storageType == STORAGE_TYPE_PHONE)
1429 filePath = STRING_CONTENT_CAMERA_PATH;
1431 AppLogDebug("SearchContentFilePath :: pFilePath = %ls", filePath.GetPointer());
1433 if (mode == CAMERA_MODE_SNAPSHOT)
1435 r = contentDirectory.Construct(CONTENT_TYPE_IMAGE);
1439 r = contentDirectory.Construct(CONTENT_TYPE_VIDEO);
1441 TryCatch(r == E_SUCCESS, , "contentDirectory.Construct[%s]", GetErrorMessage(r));
1443 countPerPage = contentDirectory.GetContentDirectoryItemCount(filePath);
1444 AppLogDebug("SearchContentFilePath :: countPerPage = %d", countPerPage);
1446 pContentList = contentDirectory.GetContentDirectoryItemListN(filePath,
1450 SORT_ORDER_ASCENDING);
1451 TryCatch(pContentList != null, , "pContentList is null");
1453 __contentCount = pContentList->GetCount();
1454 AppLogDebug("SearchContentFilePath :: __contentCount = %d", __contentCount);
1456 pContentPath = new (std::nothrow) ArrayList();
1457 pContentPath->Construct();
1459 if ((pContentList != null) && (pContentList->GetCount() > 0))
1461 IEnumerator* pEnum = pContentList->GetEnumeratorN();
1462 while (pEnum->MoveNext() == E_SUCCESS)
1464 ContentInfo* pContentInfo = static_cast<ContentInfo*>(pEnum->GetCurrent());
1465 contentFullPath = pContentInfo->GetContentPath();
1467 AppLogDebug("SearchContentFilePath :: contentFullPath = %ls", contentFullPath.GetPointer());
1469 pContentPath->Add(*(new (std::nothrow) String(contentFullPath)));
1476 if (pContentList != null)
1478 pContentList->RemoveAll(true);
1479 delete pContentList;
1482 AppLogDebug("EXIT");
1483 return pContentPath;
1486 AppLogDebug("EXIT - CATCH");
1487 return pContentPath;
1491 CameraPresentationModel::SearchContentFilePath(int mode)
1493 AppLogDebug("ENTER");
1494 result r = E_SUCCESS;
1495 ContentDirectory contentDirectory;
1496 IList* pContentList = null;
1497 String contentFullPath = L"";
1498 String filePath = L"";
1499 String combineText = L"";
1500 int storageType = 0;
1501 int countPerPage = 0;
1503 r = GetValue(STORAGE_TYPE, storageType);
1506 storageType = STORAGE_TYPE_PHONE;
1509 if (storageType == STORAGE_TYPE_MEMORYCARD)
1511 filePath = STRING_CONTENT_CAMERA_PATH_EXT;
1513 else if (storageType == STORAGE_TYPE_PHONE)
1515 filePath = STRING_CONTENT_CAMERA_PATH;
1517 AppLogDebug("SearchContentFilePath :: pFilePath = %ls", filePath.GetPointer());
1519 if (mode == CAMERA_MODE_SNAPSHOT)
1521 r = contentDirectory.Construct(CONTENT_TYPE_IMAGE);
1525 r = contentDirectory.Construct(CONTENT_TYPE_VIDEO);
1527 TryCatch(r == E_SUCCESS, , "contentDirectory.Construct[%s]", GetErrorMessage(r));
1529 countPerPage = contentDirectory.GetContentDirectoryItemCount(filePath);
1530 AppLogDebug("SearchContentFilePath :: countPerPage = %d", countPerPage);
1532 pContentList = contentDirectory.GetContentDirectoryItemListN(filePath,
1536 SORT_ORDER_ASCENDING);
1537 TryCatch(pContentList != null, , "pContentList is null");
1539 __contentCount = pContentList->GetCount();
1540 AppLogDebug("SearchContentFilePath :: __contentCount = %d", __contentCount);
1542 if ((pContentList != null) && (pContentList->GetCount() > 0))
1544 IEnumerator* pEnum = pContentList->GetEnumeratorN();
1545 while (pEnum->MoveNext() == E_SUCCESS)
1547 ContentInfo* pContentInfo = static_cast<ContentInfo*>(pEnum->GetCurrent());
1548 contentFullPath = pContentInfo->GetContentPath();
1550 if (combineText.CompareTo(EMPTY_SPACE) != 0)
1552 combineText.Append(L";");
1555 combineText.Append(contentFullPath);
1562 AppLogDebug("SearchContentFilePath :: combineText = %ls", combineText.GetPointer());
1564 if (pContentList != null)
1566 pContentList->RemoveAll(true);
1567 delete pContentList;
1570 AppLogDebug("EXIT");
1574 AppLogDebug("EXIT - CATCH");
1579 CameraPresentationModel::GetContentFilePath(int currentCameraMode)
1581 AppLogDebug("ENTER");
1582 String contentFullName = L"";
1584 contentFullName = SearchContentFilePath(currentCameraMode);
1586 AppLogDebug("EXIT");
1587 return contentFullName;
1591 CameraPresentationModel::GetLatestContentName(int currentCameraMode, Tizen::Base::String& latestContentName)
1593 AppLogDebug("ENTER");
1594 String contentSubDirectory = STRING_CAMERA_FOLDER_NAME;
1595 String fileExtension = L"";
1596 String directoryEntryName = L"";
1597 String temporaryEntryName = L"";
1598 Directory contentDirectory;
1599 result r = E_SUCCESS;
1600 DirEnumerator* pDirEnum = null;
1601 DateTime directoryEntryDateTime;
1602 DateTime temporaryEntryDateTime = DateTime::GetMinValue();
1603 int storageType = STORAGE_TYPE_PHONE;
1605 AppLogDebug("__lastestContentName content name is %ls",__latestContentName.GetPointer());
1607 r = GetValue(STORAGE_TYPE, storageType);
1608 TryCatch(r == E_SUCCESS, , "Err catch [%s]", GetErrorMessage(r));
1610 if (storageType == STORAGE_TYPE_PHONE)
1612 r = contentDirectory.Construct(Environment::GetMediaPath().GetPointer() + contentSubDirectory);
1614 AppLogDebug("GetLatestContentName::contentDirectory.Construct r = %s", GetErrorMessage(r));
1615 if (r == E_FILE_NOT_FOUND)
1617 r = contentDirectory.Create((Environment::GetMediaPath().GetPointer() + contentSubDirectory), true);
1618 TryCatch(r == E_SUCCESS, , "contentDirectory Create Fail");
1620 contentDirectory.Construct(Environment::GetMediaPath().GetPointer() + contentSubDirectory);
1623 else if (storageType == STORAGE_TYPE_MEMORYCARD)
1625 r = contentDirectory.Construct(Environment::GetExternalStoragePath().GetPointer() + contentSubDirectory);
1627 if (r == E_FILE_NOT_FOUND)
1629 r = contentDirectory.Create((Environment::GetExternalStoragePath().GetPointer() + contentSubDirectory), true);
1630 TryCatch(r == E_SUCCESS, , "contentDirectory Create Fail");
1632 contentDirectory.Construct(Environment::GetExternalStoragePath().GetPointer() + contentSubDirectory);
1636 pDirEnum = contentDirectory.ReadN();
1637 AppLogDebug("contentDirectory.ReadN()r = %s", GetErrorMessage(GetLastResult()));
1638 TryCatch(pDirEnum != null, r = E_SYSTEM, "pDirEnum is null");
1640 if (currentCameraMode == CAMERA_MODE_SNAPSHOT)
1642 r = fileExtension.Append(STRING_EXTENSION_JPG);
1643 TryCatch(r == E_SUCCESS, , "String::Append() fail[%s]", GetErrorMessage(r));
1647 r = fileExtension.Append(STRING_EXTENSION_MP4);
1648 TryCatch(r == E_SUCCESS, , "String::Append() fail[%s]", GetErrorMessage(r));
1651 while (pDirEnum->MoveNext() == E_SUCCESS)
1653 DirEntry directoryEntry = pDirEnum->GetCurrentDirEntry();
1654 directoryEntryName = directoryEntry.GetName();
1655 if (directoryEntryName.Contains(fileExtension))
1657 directoryEntryDateTime = directoryEntry.GetDateTime();
1658 AppLogDebug("DirEntry::GetDateTime() name %ls Time %ls", directoryEntryName.GetPointer(), directoryEntryDateTime.ToString().GetPointer());
1660 if (directoryEntryDateTime > temporaryEntryDateTime)
1662 temporaryEntryDateTime = directoryEntryDateTime;
1663 temporaryEntryName = directoryEntryName;
1664 AppLogDebug("dt_temp change Str %ls Time %ls", temporaryEntryName.GetPointer(), temporaryEntryDateTime.ToString().GetPointer());
1669 AppLogDebug("Dont Contains(fileExtension)");
1673 if (!(temporaryEntryName.IsEmpty()))
1675 latestContentName.Clear();
1676 r = latestContentName.Append(temporaryEntryName);
1677 TryCatch(r == E_SUCCESS, , "String::Append() fail[%s]", GetErrorMessage(r));
1679 AppLogDebug("latestContentName = %ls", latestContentName.GetPointer());
1685 AppLogDebug("EXIT");
1689 AppLogDebug("EXIT - CATCH");
1696 Tizen::Graphics::Dimension
1697 CameraPresentationModel::GetPreviewResolution(void) const
1699 AppLogDebug("ENTER");
1700 Dimension dimension(INIT, INIT);
1702 if (__pCamera != null)
1704 dimension = __pCamera->GetPreviewResolution();
1707 AppLogDebug("CameraPresentationModel::GetPreviewResolution(%d, %d)", dimension.width, dimension.height);
1709 AppLogDebug("EXIT");
1714 CameraPresentationModel::SetPreviewResolution(Tizen::Graphics::Dimension previewResolution)
1716 AppLogDebug("ENTER");
1717 result r = E_SUCCESS;
1719 r = __pCamera->SetPreviewResolution(previewResolution);
1720 TryCatch(r == E_SUCCESS, , "Camera::SetPreviewResolution fail[%s]", GetErrorMessage(r));
1722 AppLogDebug("EXIT");
1726 AppLogDebug("EXIT - CATCH");
1730 Tizen::Graphics::Dimension
1731 CameraPresentationModel::GetCaptureResolution(void) const
1733 AppLogDebug("ENTER");
1734 Dimension dimension(INIT, INIT);
1736 if (__pCamera != null)
1738 dimension = __pCamera->GetCaptureResolution();
1741 AppLogDebug("CameraPresentationModel::GetCaptureResolution(%d, %d)", dimension.width, dimension.height);
1743 AppLogDebug("EXIT");
1748 CameraPresentationModel::SetCaptureResolution(Tizen::Graphics::Dimension captureResolution)
1750 AppLogDebug("ENTER");
1751 result r = E_SUCCESS;
1753 if (__pCamera != null)
1755 r = __pCamera->SetCaptureResolution(captureResolution);
1756 TryCatch(r == E_SUCCESS, , "Camera::SetCaptureResolution fail[%s]", GetErrorMessage(r));
1758 AppLogDebug("EXIT");
1762 AppLogDebug("EXIT - CATCH");
1766 Tizen::Graphics::Dimension
1767 CameraPresentationModel::GetRecordingResolution(void) const
1769 AppLogDebug("ENTER");
1770 Dimension dimension(INIT, INIT);
1772 if (__pVideoRecorder != null)
1774 dimension = __pVideoRecorder->GetRecordingResolution();
1776 AppLogDebug("CameraPresentationModel::GetRecordingResolution(%d, %d)", dimension.width, dimension.height);
1778 AppLogDebug("EXIT");
1783 CameraPresentationModel::SetRecordingResolution(Tizen::Graphics::Dimension previewResolution)
1785 AppLogDebug("ENTER");
1786 result r = E_SUCCESS;
1788 r = __pVideoRecorder->SetRecordingResolution(previewResolution);
1789 TryCatch(r == E_SUCCESS, , "Camera::SetRecordingResolution fail[%s]", GetErrorMessage(r));
1791 AppLogDebug("EXIT");
1795 AppLogDebug("EXIT - CATCH");
1799 Tizen::Base::Collection::IList*
1800 CameraPresentationModel::GetCaptureResolutionList(void)
1802 AppLogDebug("ENTER");
1803 result r = E_SUCCESS;
1804 int selfPortraitEnable = 0;
1806 r = GetValue(SELF_PORTRAIT_ENABLE, selfPortraitEnable);
1808 if (selfPortraitEnable == CAM_SELF_PORTRAIT_MODE_PRIMARY)
1810 AppLogDebug("CAM_SELF_PORTRAIT_MODE_PRIMARY");
1811 __pCaptureResolutionList = MediaCapability::GetValueN(CAMERA_PRIMARY_CAPTURE_RESOLUTION);
1812 TryCatch(__pCaptureResolutionList != null, , "MediaCapability::GetValueN() fail[%s]", GetErrorMessage(GetLastResult()));
1816 AppLogDebug("CAM_SELF_PORTRAIT_MODE_SECONDARY");
1817 __pCaptureResolutionList = MediaCapability::GetValueN(CAMERA_SECONDARY_CAPTURE_RESOLUTION);
1818 TryCatch(__pCaptureResolutionList != null, , "MediaCapability::GetValueN() fail[%s]", GetErrorMessage(GetLastResult()));
1821 AppLogDebug("EXIT");
1822 return __pCaptureResolutionList;
1825 AppLogDebug("EXIT - CATCH");
1826 if (__pCaptureResolutionList)
1828 __pCaptureResolutionList->RemoveAll(true);
1831 delete __pCaptureResolutionList;
1833 __pCaptureResolutionList = null;
1835 return __pCaptureResolutionList;
1838 Tizen::Base::Collection::IList*
1839 CameraPresentationModel::GetPreviewResolutionList(void)
1841 AppLogDebug("ENTER");
1842 result r = E_SUCCESS;
1843 int selfPortraitEnable = 0;
1845 r = GetValue(SELF_PORTRAIT_ENABLE, selfPortraitEnable);
1847 if (selfPortraitEnable == CAM_SELF_PORTRAIT_MODE_PRIMARY)
1849 if (__pPreviewResolutionList != null)
1851 __pPreviewResolutionList->RemoveAll(true);
1852 delete __pPreviewResolutionList;
1853 __pPreviewResolutionList = null;
1855 __pPreviewResolutionList = MediaCapability::GetValueN(CAMERA_PRIMARY_PREVIEW_RESOLUTION);
1856 TryCatch(__pPreviewResolutionList != null, , "MediaCapability::GetValueN() fail[%s]", GetErrorMessage(GetLastResult()));
1860 __pPreviewResolutionList = MediaCapability::GetValueN(CAMERA_SECONDARY_PREVIEW_RESOLUTION);
1861 TryCatch(__pPreviewResolutionList != null, , "MediaCapability::GetValueN() fail[%s]", GetErrorMessage(GetLastResult()));
1864 AppLogDebug("EXIT");
1865 return __pPreviewResolutionList;
1868 AppLogDebug("EXIT - CATCH");
1869 if (__pPreviewResolutionList)
1871 __pPreviewResolutionList->RemoveAll(true);
1874 delete __pPreviewResolutionList;
1876 __pPreviewResolutionList = null;
1878 return __pPreviewResolutionList;
1881 Tizen::Base::Collection::IList*
1882 CameraPresentationModel::GetRecordingResolutionList(void)
1884 AppLogDebug("ENTER");
1885 result r = E_SUCCESS;
1886 int selfPortraitEnable = 0;
1888 r = GetValue(SELF_PORTRAIT_ENABLE, selfPortraitEnable);
1890 if (selfPortraitEnable == CAM_SELF_PORTRAIT_MODE_PRIMARY)
1892 __pRecordingResolutionList = MediaCapability::GetValueN(CAMERA_PRIMARY_RECORDING_RESOLUTION);
1893 TryCatch(__pRecordingResolutionList != null, , "MediaCapability::GetValueN() fail[%s]", GetErrorMessage(GetLastResult()));
1897 __pRecordingResolutionList = MediaCapability::GetValueN(CAMERA_PRIMARY_RECORDING_RESOLUTION);
1898 TryCatch(__pRecordingResolutionList != null, , "MediaCapability::GetValueN() fail[%s]", GetErrorMessage(GetLastResult()));
1901 AppLogDebug("EXIT");
1902 return __pRecordingResolutionList;
1905 AppLogDebug("EXIT - CATCH");
1906 if (__pRecordingResolutionList)
1908 __pRecordingResolutionList->RemoveAll(true);
1911 delete __pRecordingResolutionList;
1913 __pRecordingResolutionList = null;
1915 return __pRecordingResolutionList;
1919 CameraPresentationModel::IsPreviewState(void)
1921 AppLogDebug("ENTER");
1922 if (GetCameraState() == CAMERA_STATE_PREVIEW)
1924 AppLogDebug("IsPreviewState YES");
1925 AppLogDebug("EXIT");
1930 AppLogDebug("IsPreviewState NOT");
1931 AppLogDebug("EXIT");
1935 AppLogDebug("EXIT");
1940 CameraPresentationModel::IsCameraInstance(void)
1942 AppLogDebug("ENTER");
1943 if (__pCamera == null)
1945 AppLogDebug("EXIT - __pCamera is null");
1949 AppLogDebug("EXIT");
1954 CameraPresentationModel::IsCameraPoweredOn(void)
1956 AppLogDebug("ENTER");
1957 AppLogDebug("IsPoweredOn State[%d]", __pCamera->IsPoweredOn());
1958 AppLogDebug("EXIT");
1959 return __pCamera->IsPoweredOn();
1963 CameraPresentationModel::IsStorageCardMounted(void) const
1965 AppLogDebug("ENTER");
1966 String strState = L"";
1968 DeviceManager::GetState(StorageCard, strState);
1970 if (strState == STRING_SDCARD_MOUNTED_STATE)
1972 AppLogDebug("EXIT");
1977 AppLogDebug("EXIT");
1983 CameraPresentationModel::IsCharging(void)
1985 AppLogDebug("ENTER");
1986 bool isCharging = false;
1987 isCharging = PowerManager::IsCharging();
1988 AppLogDebug("charging status is %d",isCharging);
1989 AppLogDebug("EXIT");
1994 CameraPresentationModel::GetStartPreviewException(void)
1996 AppLogDebug("ENTER");
1997 AppLogDebug("EXIT - Error %d", __startPreviewException);
1998 return __startPreviewException;
2002 CameraPresentationModel::GetIntervalTimerRun(void) const
2004 AppLogDebug("ENTER");
2005 AppLogDebug("EXIT - __isIntervalTimerRun = %d", __isIntervalTimerRun);
2006 return __isIntervalTimerRun;
2010 CameraPresentationModel::SetIntervalTimerRun(bool intervalTimerRun)
2012 AppLogDebug("ENTER");
2013 __isIntervalTimerRun = intervalTimerRun;
2014 AppLogDebug("EXIT");
2018 CameraPresentationModel::GetPreviewState(void) const
2020 AppLogDebug("ENTER");
2021 AppLogDebug("EXIT - __isPreviewExit = %d", __isPreviewExit);
2022 return __isPreviewExit;
2026 CameraPresentationModel::StartPreview(const Tizen::Graphics::BufferInfo* pBufferInfo)
2028 AppLogDebug("ENTER");
2029 result r = E_SUCCESS;
2031 AppLogDebug("GetCameraState = %d", __pCamera->GetState());
2032 if (GetCameraState() == CAMERA_STATE_INITIALIZED || GetCameraState() == CAMERA_STATE_CAPTURED)
2034 r = __pCamera->StartPreview(pBufferInfo, false);
2035 if (r == E_DEVICE_BUSY || r == E_DEVICE_UNAVAILABLE || r == E_SYSTEM)
2037 __startPreviewException = true;
2041 __startPreviewException = false;
2043 __isPreviewExit = true;
2044 TryReturnVoid(r == E_SUCCESS, "Camera::StartPreview() fail[%s]", GetErrorMessage(r));
2048 AppLogDebug("Before the StartPreview() method is called, camera state should be CAMERA_STATE_INITIALIZED or CAMERA_STATE_CAPTURED");
2051 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_BACK_BUTTON_ACTIVATED);
2052 AppLogDebug("EXIT");
2056 CameraPresentationModel::StopPreview(void)
2058 AppLogDebug("ENTER");
2059 result r = E_SUCCESS;
2061 if (__pCamera != null)
2063 if (__pCamera->GetState() == CAMERA_STATE_PREVIEW)
2065 r = __pCamera->StopPreview();
2066 TryReturnVoid(r == E_SUCCESS, "Camera::StopPreview() [%s]", GetErrorMessage(r));
2069 AppLogDebug("EXIT");
2073 CameraPresentationModel::StopCamera(void)
2075 AppLogDebug("ENTER");
2076 result r = E_SUCCESS;
2078 if (__isInitCamera == false)
2080 AppLogDebug("Camera Construct fail or Memory allocation Fail");
2084 if (__pVideoRecorder != null)
2086 AppLogDebug("VideoRecorder State[%d]", __pVideoRecorder->GetState());
2088 if (__pVideoRecorder->GetState()== RECORDER_STATE_RECORDING
2089 || __pVideoRecorder->GetState() == RECORDER_STATE_PAUSED
2092 r = __pVideoRecorder->Stop();
2093 TryReturnVoid(r == E_SUCCESS, "__pVideoRecorder::Stop() [%s]", GetErrorMessage(r));
2097 if (__pCamera != null)
2099 AppLogDebug("Camera State[%d]", __pCamera->GetState());
2101 if (__pCamera->GetState() == CAMERA_STATE_PREVIEW)
2103 r = __pCamera->StopPreview();
2104 TryReturnVoid(r == E_SUCCESS, "Camera::StopPreview() [%s]", GetErrorMessage(r));
2107 if (__pCamera->IsPoweredOn() == true)
2109 r = __pCamera->PowerOff();
2110 TryReturnVoid(r == E_SUCCESS, "Camera::PowerOff() [%s]", GetErrorMessage(r));
2113 AppLogDebug("EXIT");
2117 CameraPresentationModel::Capture(void)
2119 AppLogDebug("ENTER");
2120 result r = E_SUCCESS;
2122 if (GetCameraState() == CAMERA_STATE_PREVIEW)
2124 r = __pCamera->Capture();
2125 TryReturnVoid( r == E_SUCCESS, "Camera::Capture() fail[%s]", GetErrorMessage(r));
2129 AppLogDebug("Before the Capture() method is called, camera state should be CAMERA_STATE_PREVIEW");
2131 AppLogDebug("EXIT");
2135 CameraPresentationModel::GetMaxRecordingTime(void)
2137 AppLogDebug("ENTER");
2138 long getMaxRecordingTime = 0;
2140 getMaxRecordingTime = __pVideoRecorder->GetMaxRecordingTime();
2142 AppLogDebug("GetMaxRecordingTime = %d EXIT", getMaxRecordingTime);
2143 return getMaxRecordingTime;
2147 CameraPresentationModel::GetRecordingSize(void)
2149 AppLogDebug("ENTER");
2150 long getRecordingSize = 0;
2152 getRecordingSize = __pVideoRecorder->GetRecordingSize();
2154 AppLogDebug("EXIT - GetRecordingSize = %d", getRecordingSize);
2155 return getRecordingSize;
2159 CameraPresentationModel::StartRecord(void)
2161 AppLogDebug("ENTER");
2162 String* pFullFileName = null;
2163 result r = E_SUCCESS;
2164 long maxRecordDefaultTime = 0;
2165 String camcorderTemporaryFilePath;
2166 RecordingRotation rotate = RECORDING_ROTATION_NONE;
2167 int storageType = STORAGE_TYPE_PHONE;
2169 __onVideoRecorderStarted = true;
2171 AppLogDebug("Record GetRecorderState = %d", GetRecorderState());
2172 if (GetRecorderState() == RECORDER_STATE_PAUSED || GetRecorderState() == RECORDER_STATE_PAUSING)
2174 AppLogDebug("RECORDER_STATE_PAUSED or RECORDER_STATE_PAUSING ==> RECORDER_STATE_RECORDING");
2176 r = __pVideoRecorder->Record();
2177 TryCatch(r == E_SUCCESS, , "VideoRecorder::Record() fail[%s]", GetErrorMessage(r));
2179 r = SetFlashModeOnRecord(true);
2180 AppLogDebug("SetFlashModeOnRecord fail[%s]", GetErrorMessage(r));
2182 AppLogDebug("EXIT");
2186 r = GetValue(STORAGE_TYPE, storageType);
2189 storageType = STORAGE_TYPE_PHONE;
2192 if (storageType == STORAGE_TYPE_PHONE)
2194 camcorderTemporaryFilePath.Format(MAX_DIRECTORY_PATH_LENGTH, L"%ls%ls", App::GetInstance()->GetAppRootPath().GetPointer(), STRING_CAMCORDER_TEMPORARY_FILE);
2198 camcorderTemporaryFilePath.Format(MAX_DIRECTORY_PATH_LENGTH, L"%ls%ls", Environment::GetExternalStoragePath().GetPointer(), STRING_CAMCORDER_TEMPORARY_FILE_EXT);
2201 pFullFileName = new (std::nothrow) String();
2202 r = CreateFileName(*pFullFileName);
2203 TryCatch(r == E_SUCCESS, , "pFullFileName is null");
2205 __latestContentName.Clear();
2206 r = __latestContentName.Append(pFullFileName->GetPointer());
2207 TryCatch(r == E_SUCCESS, , "String::Append() fail[%s]", GetErrorMessage(r));
2209 AppLogDebug("Record pFullFileName = %ls", pFullFileName->GetPointer());
2210 if (__pVideoRecorder == null)
2212 __pVideoRecorder = new (std::nothrow) VideoRecorder();
2213 __pVideoRecorder->Construct(*this, *__pCamera);
2216 r = __pVideoRecorder->SetQuality(RECORDING_QUALITY_HIGH);
2217 TryCatch(r == E_SUCCESS, , "VideoRecorder::SetQuality() fail[%s]", GetErrorMessage(r));
2219 maxRecordDefaultTime = RECORD_DEFAULT_SEC * SECONDS_PER_MINUTE;
2221 r = __pVideoRecorder->SetMaxRecordingTime(maxRecordDefaultTime);
2222 TryCatch(r == E_SUCCESS, , "VideoRecorder::SetMaxRecordingTime() fail[%s]", GetErrorMessage(r));
2224 r = __pVideoRecorder->SetFormat(CODEC_AAC, CODEC_MPEG4, MEDIA_CONTAINER_MP4);
2225 TryCatch(r == E_SUCCESS, , "VideoRecorder::SetFormat() fail[%s]", GetErrorMessage(r));
2227 rotate = GetRecordingRotation();
2228 AppLogDebug("StartRecord rotate = %d",rotate);
2230 r = __pVideoRecorder->SetRecordingRotation(rotate);
2231 TryCatch(r == E_SUCCESS, , "VideoRecorder::SetRecordingRotation() fail[%s]", GetErrorMessage(r));
2233 AppLogDebug("latest file name is %ls",__latestContentName.GetPointer());
2234 r = __pVideoRecorder->CreateVideoFile(__latestContentName, true);
2235 AppLogDebug("create video file result is %s",GetErrorMessage(r));
2236 TryCatch(r == E_SUCCESS, , "VideoRecorder::CreateVideoFile() fail[%s]", GetErrorMessage(r));
2238 r = __pVideoRecorder->Record();
2239 TryCatch(r == E_SUCCESS, , "VideoRecorder::Record() fail[%s]", GetErrorMessage(r));
2241 delete pFullFileName;
2242 pFullFileName = null;
2244 r = SetFlashModeOnRecord(true);
2245 AppLogDebug("SetFlashModeOnRecord fail[%s]", GetErrorMessage(r));
2247 AppLogDebug("EXIT");
2251 AppLogDebug("EXIT - CATCH");
2252 __onVideoRecorderStarted = false;
2253 delete pFullFileName;
2254 pFullFileName = null;
2258 CameraPresentationModel::SetCancelRecord(bool isCancel)
2260 AppLogDebug("ENTER");
2261 __isCancelRecord = isCancel;
2262 AppLogDebug("EXIT");
2266 CameraPresentationModel::StopRecord(void)
2268 AppLogDebug("ENTER");
2269 result r = E_SUCCESS;
2271 if (__pVideoRecorder != null)
2273 r = __pVideoRecorder->Stop();
2274 AppLogDebug("stop record result is %s",GetErrorMessage(r));
2275 //TryReturnVoid(r == E_SUCCESS, "VideoRecorder::Stop() fail[%s]", GetErrorMessage(r));
2277 AppLogDebug("EXIT");
2282 CameraPresentationModel::CloseRecord(void)
2284 AppLogDebug("ENTER");
2285 result r = E_SUCCESS;
2287 if (__pVideoRecorder != null)
2289 r = __pVideoRecorder->Close();
2290 TryReturnVoid(r == E_SUCCESS, "VideoRecorder::Close() fail[%s]", GetErrorMessage(r));
2292 AppLogDebug("EXIT");
2296 CameraPresentationModel::CancelRecord(void)
2298 AppLogDebug("ENTER");
2299 result r = E_SUCCESS;
2301 if (__pVideoRecorder != null)
2303 r = __pVideoRecorder->Cancel();
2304 TryReturnVoid(r == E_SUCCESS, "VideoRecorder::Cancel() fail[%s]", GetErrorMessage(r));
2306 AppLogDebug("EXIT");
2310 CameraPresentationModel::PauseRecord(void)
2312 AppLogDebug("ENTER");
2313 result r = E_SUCCESS;
2315 if (__pVideoRecorder != null)
2317 r = __pVideoRecorder->Pause();
2318 TryReturnVoid(r == E_SUCCESS, "VideoRecorder::Pause() fail[%s]", GetErrorMessage(r));
2320 AppLogDebug("EXIT");
2324 CameraPresentationModel::SetFlip(CameraFlipType type)
2326 AppLogDebug("ENTER");
2327 result r = E_SUCCESS;
2328 int selfPortraitEnable = 0;
2330 r = GetValue(SELF_PORTRAIT_ENABLE, selfPortraitEnable);
2332 if (selfPortraitEnable == CAM_SELF_PORTRAIT_MODE_PRIMARY)
2334 r = GetMediaCapability(CAMERA_PRIMARY_FLIP);
2338 r = GetMediaCapability(CAMERA_SECONDARY_FLIP);
2343 r = __pCamera->SetFlip(type);
2344 TryReturnVoid(r == E_SUCCESS, "Camera::SetFlip() [%s]", GetErrorMessage(r));
2348 AppLogDebug("SetFlip is not support");
2350 AppLogDebug("EXIT");
2354 CameraPresentationModel::GetFlip(void) const
2356 AppLogDebug("ENTER");
2357 AppLogDebug("EXIT");
2358 return __pCamera->GetFlip();
2362 CameraPresentationModel::SetFocusMode(CameraFocusMode mode)
2364 AppLogDebug("ENTER");
2365 result r = E_SUCCESS;
2367 r = __pCamera->SetFocusMode(mode);
2368 TryReturnVoid(r == E_SUCCESS, "Camera::SetFocusMode() [%s]", GetErrorMessage(r));
2369 AppLogDebug("EXIT");
2373 CameraPresentationModel::SetContinuousAutoFocus(void)
2375 AppLogDebug("ENTER");
2376 result r = E_SUCCESS;
2378 if (__pCamera != null)
2380 r = __pCamera->SetFocusMode(CAMERA_FOCUS_MODE_CONTINUOUS_AUTO);
2381 TryReturnVoid(r == E_SUCCESS, "Camera::SetFocusMode() [%s]", GetErrorMessage(r));
2383 r = __pCamera->SetAutoFocus(true);
2384 TryReturnVoid(r == E_SUCCESS, "Camera::SetAutoFocus() [%s]", GetErrorMessage(r));
2386 AppLogDebug("EXIT");
2390 CameraPresentationModel::SetAutoFocusPoint(const Tizen::Graphics::Point& currentPosition)
2392 AppLogDebug("ENTER");
2393 result r = E_SUCCESS;
2394 ArrayList currentPositionList;
2395 currentPositionList.Construct();
2396 currentPositionList.Add(currentPosition);
2398 r = __pCamera->SetFocusMode(CAMERA_FOCUS_MODE_NORMAL);
2399 TryReturnVoid(r == E_SUCCESS, "Camera::SetFocusMode() [%s]", GetErrorMessage(r));
2401 r = __pCamera->SetAutoFocusPoint(currentPositionList);
2402 TryReturnVoid(r == E_SUCCESS, "Camera::SetAutoFocusPoint() [%s]", GetErrorMessage(r));
2404 r = __pCamera->SetAutoFocus(true);
2405 TryReturnVoid(r == E_SUCCESS, "Camera::SetAutoFocus() [%s]", GetErrorMessage(r));
2406 AppLogDebug("EXIT");
2410 CameraPresentationModel::GetExposure(void) const
2412 AppLogDebug("ENTER");
2413 int exposureValue = 0;
2415 exposureValue = __pCamera->GetExposure();
2417 AppLogDebug("EXIT");
2418 return exposureValue;
2422 CameraPresentationModel::SetExposure(int exposureValue)
2424 AppLogDebug("ENTER");
2425 result r = E_SUCCESS;
2427 exposureValue = MAX_CAMERA_EXPOSURE_VALUE - exposureValue;
2429 r = __pCamera->SetExposure(exposureValue);
2430 TryReturnVoid(r == E_SUCCESS, "SetExposure() fail[%s]", GetErrorMessage(r));
2431 AppLogDebug("EXIT");
2435 CameraPresentationModel::GetBrightness(void) const
2437 AppLogDebug("ENTER");
2438 int brightnessValue = 0;
2440 brightnessValue = __pCamera->GetBrightness();
2442 AppLogDebug("EXIT");
2443 return brightnessValue;
2447 CameraPresentationModel::SetBrightness(int brightnessValue)
2449 AppLogDebug("ENTER");
2450 result r = E_SUCCESS;
2452 brightnessValue = MAX_CAMERA_EXPOSURE_VALUE - brightnessValue;
2454 r = __pCamera->SetBrightness(brightnessValue);
2455 TryReturnVoid(r == E_SUCCESS, "Camera::SetBrightness() fail[%s]", GetErrorMessage(r));
2456 AppLogDebug("EXIT");
2460 CameraPresentationModel::GetWhiteBalance(void) const
2462 AppLogDebug("ENTER");
2463 CameraWhiteBalance whiteBalanceValue = CAMERA_WHITE_BALANCE_AUTO;
2465 whiteBalanceValue = __pCamera->GetWhiteBalance();
2467 AppLogDebug("EXIT");
2468 return whiteBalanceValue;
2472 CameraPresentationModel::SetWhiteBalance(CameraWhiteBalance whitebalanceValue)
2474 AppLogDebug("ENTER");
2475 result r = E_SUCCESS;
2477 r = __pCamera->SetWhiteBalance(whitebalanceValue);
2479 AppLogDebug("EXIT");
2483 Tizen::Base::Collection::IList*
2484 CameraPresentationModel::GetIsoList(void)
2486 AppLogDebug("ENTER");
2487 result r = E_SUCCESS;
2488 int selfPortraitEnable = 0;
2490 r = GetValue(SELF_PORTRAIT_ENABLE, selfPortraitEnable);
2492 if (selfPortraitEnable == CAM_SELF_PORTRAIT_MODE_PRIMARY)
2494 __pIsoList = MediaCapability::GetValueN(CAMERA_PRIMARY_ISO_LEVEL);
2495 TryCatch(__pIsoList != null, , "MediaCapability::GetValueN() fail[%s]", GetErrorMessage(GetLastResult()));
2499 __pIsoList = MediaCapability::GetValueN(CAMERA_SECONDARY_ISO_LEVEL);
2500 TryCatch(__pIsoList != null, , "MediaCapability::GetValueN() fail[%s]", GetErrorMessage(GetLastResult()));
2503 AppLogDebug("EXIT");
2507 AppLogDebug("EXIT - CATCH");
2510 __pIsoList->RemoveAll(true);
2521 CameraPresentationModel::GetIsoLevel(void) const
2523 AppLogDebug("ENTER");
2524 CameraIsoLevel isoValue = CAMERA_ISO_DEFAULT;
2526 isoValue = __pCamera->GetIsoLevel();
2528 AppLogDebug("EXIT");
2533 CameraPresentationModel::SetIsoLevel(CameraIsoLevel isoValue)
2535 AppLogDebug("ENTER");
2536 result r = E_SUCCESS;
2538 r = __pCamera->SetIsoLevel(isoValue);
2539 TryReturnVoid(r == E_SUCCESS, "SetIsoLevel() fail[%s]", GetErrorMessage(r));
2540 AppLogDebug("EXIT");
2544 CameraPresentationModel::GetMaxZoomLevel(void) const
2546 AppLogDebug("ENTER");
2549 zoomLevel = __pCamera->GetMaxZoomLevel();
2551 AppLogDebug("EXIT");
2556 CameraPresentationModel::GetZoomLevel(void) const
2558 AppLogDebug("ENTER");
2561 zoomLevel = __pCamera->GetZoomLevel();
2563 AppLogDebug("EXIT");
2568 CameraPresentationModel::SetZoomValue(int zoomValue)
2570 AppLogDebug("ENTER");
2571 result r = E_SUCCESS;
2573 int currentZoomValue = __pCamera->GetZoomLevel();
2575 if (currentZoomValue < zoomValue)
2577 for (int i = currentZoomValue; i < zoomValue; i++)
2579 r = __pCamera->ZoomIn();
2580 TryReturnVoid(r == E_SUCCESS, "ZoomIn() fail[%s]", GetErrorMessage(r));
2585 for (int i = currentZoomValue; i > zoomValue; i--)
2587 r = __pCamera->ZoomOut();
2588 TryReturnVoid(r == E_SUCCESS, "ZoomOut() fail[%s]", GetErrorMessage(r));
2591 AppLogDebug("EXIT");
2595 CameraPresentationModel::GetFlashMode(void) const
2597 AppLogDebug("ENTER");
2598 CameraFlashMode cameraFlashMode = CAMERA_FLASH_MODE_OFF;
2600 cameraFlashMode = __pCamera->GetFlashMode();
2602 AppLogDebug("Get flashMode = %d", cameraFlashMode);
2604 AppLogDebug("EXIT");
2605 return cameraFlashMode;
2609 CameraPresentationModel::SetFlashModeOnRecord(bool flashOn)
2611 AppLogDebug("ENTER");
2612 result ret = E_SUCCESS;
2613 int selfPortraitEnable = 0;
2616 ret = GetValue(SELF_PORTRAIT_ENABLE, selfPortraitEnable);
2617 if (ret != E_SUCCESS)
2619 selfPortraitEnable = CAM_SELF_PORTRAIT_MODE_PRIMARY;
2622 if (selfPortraitEnable == CAM_SELF_PORTRAIT_MODE_PRIMARY)
2624 ret = GetMediaCapability(CAMERA_PRIMARY_FLASH_MODE);
2628 ret = GetMediaCapability(CAMERA_SECONDARY_FLASH_MODE);
2631 if (ret == E_SUCCESS)
2633 if (selfPortraitEnable == CAM_SELF_PORTRAIT_MODE_PRIMARY)
2635 ret = __pCameraSettingsPresentationModel->GetValue(SECTION_CAMCORDER, FLASH_MODE_PRIMARY, flashMode);
2639 ret = __pCameraSettingsPresentationModel->GetValue(SECTION_CAMCORDER, FLASH_MODE_SECONDARY, flashMode);
2641 TryCatch(ret == E_SUCCESS, , "GetValue() fail[%s]", GetErrorMessage(ret));
2643 AppLogDebug("flashMode = %d", flashMode);
2645 if (__pCamera->IsPoweredOn() == true && flashMode == FLASH_TYPE_ON)
2647 AppLogDebug("SetFlashModeOnRecord flashOn = %d", flashOn);
2651 ret = __pCamera->SetFlashMode(CAMERA_FLASH_MODE_CONTINUOUS);
2652 TryCatch(ret == E_SUCCESS, , "SetFlashMode() fail[%s]", GetErrorMessage(ret));
2656 ret = __pCamera->SetFlashMode(CAMERA_FLASH_MODE_ON); //CAMERA_FLASH_MODE_OFF >>is TAF don't flash on
2657 TryCatch(ret == E_SUCCESS, , "SetFlashMode() fail[%s]", GetErrorMessage(ret));
2662 AppLogDebug("Camera PoweredOff status");
2666 AppLogDebug("EXIT");
2670 AppLogDebug("EXIT - CATCH");
2675 CameraPresentationModel::SetFlashMode(CameraFlashMode mode)
2677 AppLogDebug("ENTER");
2678 result r = E_SUCCESS;
2680 AppLogDebug("Set flashMode = %d", mode);
2682 if (__pCamera != null)
2684 if (mode == CAMERA_FLASH_MODE_OFF)
2686 if (__pCamera->IsFlashOn())
2688 r = __pCamera->SetFlashMode(CAMERA_FLASH_MODE_OFF);
2689 AppLogDebug("Set SetFlashMode = %s", GetErrorMessage(r));
2694 r = __pCamera->SetFlashMode(mode);
2695 AppLogDebug("Set SetFlashMode = %s", GetErrorMessage(r));
2700 AppLogDebug("__pCamera is null");
2703 AppLogDebug("EXIT");
2707 Tizen::Ui::OrientationStatus
2708 CameraPresentationModel::GetOrientation(void) const
2710 AppLogDebug("ENTER");
2711 AppLogDebug("EXIT");
2716 CameraPresentationModel::SetOrientation(Tizen::Ui::OrientationStatus dir)
2718 AppLogDebug("ENTER");
2719 AppLogDebug("EXIT");
2724 CameraPresentationModel::GetAppControlRequestType(void) const
2726 AppLogDebug("ENTER");
2727 AppLogDebug("EXIT");
2728 return __appControlRequestType;
2732 CameraPresentationModel::SetAppControlRequestType(int requestType)
2734 AppLogDebug("ENTER");
2735 __appControlRequestType = requestType;
2736 AppLogDebug("EXIT");
2740 CameraPresentationModel::GetErrorResult(void) const
2742 AppLogDebug("ENTER");
2743 AppLogDebug("EXIT");
2744 return __errorResult;
2748 CameraPresentationModel::SetErrorResult(const Tizen::Base::String& string)
2750 AppLogDebug("ENTER");
2751 __errorResult = string;
2752 AppLogDebug("EXIT");
2755 Tizen::System::BatteryLevel
2756 CameraPresentationModel::GetBatteryLevel(void) const
2758 AppLogDebug("ENTER");
2759 BatteryLevel batteryLevel;
2761 batteryLevel = PowerManager::GetCurrentBatteryLevel();
2763 AppLogDebug("EXIT");
2764 return batteryLevel;
2767 Tizen::Media::CameraState
2768 CameraPresentationModel::GetCameraState(void) const
2770 AppLogDebug("ENTER");
2771 TryCatch(__pCamera != null, , "__pCamera is null");
2773 AppLogDebug("EXIT");
2774 return __pCamera->GetState();
2777 AppLogDebug("EXIT - CATCH");
2778 return CAMERA_STATE_ERROR;
2781 Tizen::Media::RecorderState
2782 CameraPresentationModel::GetRecorderState(void) const
2784 AppLogDebug("ENTER");
2785 TryCatch(__pVideoRecorder != null, , "__pVideoRecorder is null");
2787 AppLogDebug("EXIT");
2788 return __pVideoRecorder->GetState();
2791 AppLogDebug("EXIT - CATCH");
2792 return RECORDER_STATE_ERROR;
2796 CameraPresentationModel::GetAvailableStorageSpace(void) const
2798 AppLogDebug("ENTER");
2799 result r = E_SUCCESS;
2800 int storageType = STORAGE_TYPE_PHONE;
2801 long long availableStorageSpace = 0;
2803 r = GetValue(STORAGE_TYPE, storageType);
2806 storageType = STORAGE_TYPE_PHONE;
2809 if (storageType == STORAGE_TYPE_PHONE)
2811 String key(STRING_KEY_STORAGE_PHONE);
2812 r = RuntimeInfo::GetValue(key, availableStorageSpace);
2813 TryCatch(r == E_SUCCESS, , "To get a value is fail");
2815 else if (storageType == STORAGE_TYPE_MEMORYCARD)
2817 if (IsStorageCardMounted() == true)
2819 String key(STRING_KEY_STORAGE_SDCARD);
2821 r = RuntimeInfo::GetValue(key, availableStorageSpace);
2822 TryCatch(r == E_SUCCESS, , "To get a value is fail");
2826 availableStorageSpace = 0;
2830 AppLogDebug("EXIT - availableStorageSpace = %ld", availableStorageSpace);
2831 return availableStorageSpace;
2834 AppLogDebug("EXIT - CATCH");
2835 availableStorageSpace = 0;
2836 return availableStorageSpace;
2840 CameraPresentationModel::ZoomIn(void)
2842 AppLogDebug("ENTER");
2843 result r = E_SUCCESS;
2845 r = __pCamera->ZoomIn();
2846 TryReturnVoid(r == E_SUCCESS, "ZoomIn() fail[%s]", GetErrorMessage(r));
2847 AppLogDebug("EXIT");
2851 CameraPresentationModel::ZoomOut(void)
2853 AppLogDebug("ENTER");
2854 result r = E_SUCCESS;
2856 r = __pCamera->ZoomOut();
2857 TryReturnVoid(r == E_SUCCESS, "ZoomOut() fail[%s]", GetErrorMessage(r));
2858 AppLogDebug("EXIT");
2862 CameraPresentationModel::SetExifOrientation(int orientation)
2864 AppLogDebug("ENTER");
2865 result r = E_SUCCESS;
2867 switch (orientation)
2869 case CAM_SET_EXIF_ORIENTATION_MODE_PORTRAIT:
2871 r = __pCamera->SetExifOrientation(CAMERA_EXIF_ORIENTATION_RIGHT_TOP);
2875 case CAM_SET_EXIF_ORIENTATION_MODE_PORTRAIT_REVERSE:
2877 r = __pCamera->SetExifOrientation(CAMERA_EXIF_ORIENTATION_LEFT_BOTTOM);
2881 case CAM_SET_EXIF_ORIENTATION_MODE_LANDSCAPE:
2883 r = __pCamera->SetExifOrientation(CAMERA_EXIF_ORIENTATION_TOP_LEFT);
2887 case CAM_SET_EXIF_ORIENTATION_MODE_LANDSCAPE_REVERSE:
2889 r = __pCamera->SetExifOrientation(CAMERA_EXIF_ORIENTATION_BOTTOM_RIGHT);
2896 AppLogDebug("__pCamera->SetExifOrientation() fail[%s]", GetErrorMessage(r));
2898 AppLogDebug("EXIT");
2903 CameraPresentationModel::KeepScreenOnState(bool keepOn, bool dimming)
2905 result r = E_FAILURE;
2906 AppLogDebug("ENTER");
2908 AppLogDebug("PowerManager keepOn : %d dimming : %d", keepOn, dimming);
2910 r = PowerManager::KeepScreenOnState(keepOn, dimming);
2911 TryReturnVoid(r == E_SUCCESS, "PowerManager::KeepScreenOnState() failed:%s", GetErrorMessage(r));
2912 AppLogDebug("EXIT");
2916 CameraPresentationModel::AddPresentationChangedEventListener(ICameraEventListner& pObserverListener)
2918 AppLogDebug("ENTER");
2919 __pCameraListener = &pObserverListener;
2920 AppLogDebug("EXIT");
2924 CameraPresentationModel::RemovePresentationChangedEventListener(ICameraEventListner* pObserverListener)
2926 AppLogDebug("ENTER");
2927 __pCameraListener = pObserverListener;
2928 AppLogDebug("EXIT");
2932 CameraPresentationModel::CallOnPresentationModeChanged(CameraActionEvent event)
2934 AppLogDebug("ENTER");
2935 AppLogDebug("CallOnPresentationModeChanged - event = %d", event);
2936 if (__pCameraListener != null)
2938 __pCameraListener->OnCameraActionPerformed(event);
2940 AppLogDebug("EXIT");
2944 CameraPresentationModel::ResetCameraSettingsRegistry(void)
2946 AppLogDebug("ENTER");
2947 result r = E_SUCCESS;
2949 r = __pCameraSettingsPresentationModel->ResetCameraSettingsRegistry();
2950 TryCatch(r == E_SUCCESS, , "Registry::SetValue() failed[%s]", GetErrorMessage(r));
2952 AppLogDebug("EXIT");
2956 AppLogDebug("EXIT - CATCH");
2961 CameraPresentationModel::ResetCameraSettings(void)
2963 AppLogDebug("ENTER");
2964 result r = E_SUCCESS;
2966 TryCatch(__pCameraSettingsPresentationModel!=null, r = E_FAILURE,"Camera Settings Presentation Model is NULL");
2968 r = __pCameraSettingsPresentationModel->SetValue(SECTION_CAMERA, EXPOSURE_VALUE, EXPOSURE_DEFAULT_VALUE);
2969 TryCatch(r == E_SUCCESS, , "Registry::GetValue() failed[%s]", GetErrorMessage(r));
2971 r = __pCameraSettingsPresentationModel->SetValue(SECTION_CAMCORDER, EXPOSURE_VALUE, EXPOSURE_DEFAULT_VALUE);
2972 TryCatch(r == E_SUCCESS, , "Registry::GetValue() failed[%s]", GetErrorMessage(r));
2974 r = __pCameraSettingsPresentationModel->SetValue(SECTION_CAMERA, BRIGHTNESS_VALUE, BRIGHTNESS_DEFAULT_VALUE);
2975 TryCatch(r == E_SUCCESS, , "Registry::GetValue() failed[%s]", GetErrorMessage(r));
2977 r = __pCameraSettingsPresentationModel->SetValue(SECTION_CAMCORDER, BRIGHTNESS_VALUE, BRIGHTNESS_DEFAULT_VALUE);
2978 TryCatch(r == E_SUCCESS, , "Registry::GetValue() failed[%s]", GetErrorMessage(r));
2980 AppLogDebug("EXIT");
2984 AppLogDebug("EXIT - CATCH %s", GetErrorMessage(r));
2989 CameraPresentationModel::GetValue(const Tizen::Base::String& entryName, int& value) const
2991 AppLogDebug("ENTER");
2992 AppLogDebug("entry name is %ls",entryName.GetPointer());
2993 AppLogDebug("entry value is %d",value);
2994 result r = E_SUCCESS;
2996 String strSectionName = SECTION_CAMERA;
2998 if (entryName.Equals(String(CURRENT_MODE)))
3000 strSectionName = SECTION_CAMERA;
3004 r = __pCameraSettingsPresentationModel->GetValue(SECTION_CAMERA, CURRENT_MODE, mode);
3005 TryCatch(r == E_SUCCESS, , "Registry::GetValue() failed[%s]", GetErrorMessage(r));
3007 if (mode == CAMERA_MODE_SNAPSHOT)
3009 strSectionName = SECTION_CAMERA;
3013 strSectionName = SECTION_CAMCORDER;
3017 r = __pCameraSettingsPresentationModel->GetValue(strSectionName, entryName, value);
3018 TryCatch(r == E_SUCCESS, , "Registry::GetValue() failed[%s]", GetErrorMessage(r));
3020 AppLogDebug("EXIT");
3024 AppLogDebug("EXIT - CATCH");
3029 CameraPresentationModel::SetValue(const Tizen::Base::String& entryName, const int value)
3031 AppLogDebug("ENTER");
3032 result r = E_SUCCESS;
3034 String strSectionName = SECTION_CAMERA;
3036 AppLogDebug("entry name is %ls",entryName.GetPointer());
3037 AppLogDebug("entry value is %d",value);
3039 if (entryName.Equals(String(CURRENT_MODE)))
3041 strSectionName = SECTION_CAMERA;
3045 r = __pCameraSettingsPresentationModel->GetValue(SECTION_CAMERA, CURRENT_MODE, mode);
3046 TryCatch(r == E_SUCCESS, , "Registry::GetValue() failed[%s]", GetErrorMessage(r));
3048 if (mode == CAMERA_MODE_SNAPSHOT)
3050 strSectionName = SECTION_CAMERA;
3054 strSectionName = SECTION_CAMCORDER;
3058 r = __pCameraSettingsPresentationModel->SetValue(strSectionName, entryName, value);
3060 /*if ( entryName.CompareTo(L"PRIMARY_FLASH_MODE") == 0)
3062 AppLogDebug("flash mode is set to value %d",value);
3063 SetFlashMode(CameraFlashMode(value));
3065 TryCatch(r == E_SUCCESS, , "Registry::SetValue() failed[%s]", GetErrorMessage(r));
3067 AppLogDebug("EXIT");
3071 AppLogDebug("EXIT - CATCH");
3076 CameraPresentationModel::GetMediaCapability(Tizen::Base::String key, bool& value) const
3078 AppLogDebug("ENTER");
3079 result r = E_SUCCESS;
3080 r = MediaCapability::GetValue(key, value);
3082 AppLogDebug("GetMediaCapability for %ls value = %d return = %s", key.GetPointer(), value, GetErrorMessage(r));
3083 TryCatch(r == E_SUCCESS, , "MediaCapability::GetValue() fail[%s]", GetErrorMessage(r));
3085 AppLogDebug("EXIT");
3089 AppLogDebug("EXIT - CATCH");
3094 CameraPresentationModel::GetMediaCapability(Tizen::Base::String key, int& value) const
3096 AppLogDebug("ENTER");
3097 result r = E_SUCCESS;
3098 r = MediaCapability::GetValue(key, value);
3100 AppLogDebug("GetMediaCapability for %ls value = %d return = %s", key.GetPointer(), value, GetErrorMessage(r));
3101 TryCatch(r == E_SUCCESS, , "MediaCapability::GetValue() fail[%s]", GetErrorMessage(r));
3103 AppLogDebug("EXIT");
3107 AppLogDebug("EXIT - CATCH");
3112 CameraPresentationModel::GetMediaCapability(Tizen::Base::String key) const
3114 AppLogDebug("ENTER");
3115 result r = E_SUCCESS;
3116 IList* pList = null;
3117 pList = MediaCapability::GetValueN(key);
3118 r = GetLastResult();
3119 AppLogDebug("GetMediaCapability for %ls return = %s", key.GetPointer(), GetErrorMessage(r));
3120 TryCatch(pList != null, , "MediaCapability::GetValueN() fail[%s]", GetErrorMessage(r));
3122 pList->RemoveAll(true);
3126 AppLogDebug("EXIT");
3130 AppLogDebug("EXIT - CATCH");
3135 CameraPresentationModel::OnCameraAutoFocused(bool completeCondition)
3137 AppLogDebug("ENTER");
3138 CameraFocusMode focusMode = CAMERA_FOCUS_MODE_NONE;
3140 if (__isIntervalTimerRun == true)
3142 AppLogDebug("__isIntervalTimerRun: true");
3146 if (completeCondition == true)
3148 focusMode = __pCamera->GetFocusMode();
3150 if (focusMode == CAMERA_FOCUS_MODE_CONTINUOUS_AUTO)
3152 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_AUTO_FOCUSED);
3154 else if (focusMode == CAMERA_FOCUS_MODE_NORMAL)
3156 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_TOUCH_AUTO_FOCUSED);
3161 AppLogDebug("completeCondition:false");
3162 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_AUTO_FOCUS_FAILED);
3164 AppLogDebug("EXIT");
3168 CameraPresentationModel::OnCameraPreviewed(Tizen::Base::ByteBuffer& previewedData, result r)
3170 AppLogDebug("ENTER");
3171 AppLogDebug("EXIT");
3175 CameraPresentationModel::OnCameraCaptured(Tizen::Base::ByteBuffer& capturedData, result r)
3177 AppLogDebug("ENTER");
3178 int shootingMode = 0;
3179 String* pFullFileName = null;
3180 ContentManager* pContentManager = null;
3181 ImageContentInfo* pImageContentInfo = null;
3182 result ret = E_SUCCESS;
3183 int storageType = 0;
3184 String FilePath= null;
3185 bool bDoScanDir= false;
3187 AppLogDebug("OnCameraCaptured :: StopCaptured = %d", __isStopCaptured);
3189 if (__isStopCaptured == true)
3191 AppLogDebug("OnCameraCaptured :: StopCaptured");
3192 __isStopCaptured = false;
3194 SetErrorResult(STRING_CAMERA_CAPTURED_ERROR);
3196 SetAppControlRequestType(APP_CONTROL_REQUEST_TYPE_FAILED);
3198 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_ERROR_OCCURRED);
3202 ret = GetValue(SHOOTING_MODE, shootingMode);
3203 TryCatch(ret == E_SUCCESS, , "GetValue() fail[%s]", GetErrorMessage(ret));
3205 if (shootingMode == CAPTURE_NORMAL_MODE)
3209 ContentId contentId;
3211 pFullFileName = new (std::nothrow) String();
3212 ret = CreateFileName(*pFullFileName);
3213 TryCatch(ret == E_SUCCESS, , "pFullFileName is null");
3215 __latestContentName.Clear();
3216 ret = __latestContentName.Append(pFullFileName->GetPointer());
3217 TryCatch(ret == E_SUCCESS, , "String::Append() fail[%s]", GetErrorMessage(ret));
3219 AppLogDebug("OnCameraCaptured pFullFileName = %ls", pFullFileName->GetPointer());
3220 pContentManager = new (std::nothrow) ContentManager();
3222 ret = pContentManager->Construct();
3223 TryCatch(ret == E_SUCCESS, , "ContentManager->Construct() failed(%s)", GetErrorMessage(r));
3226 //Code for doing ScanDirectory!!!
3227 r = GetValue(STORAGE_TYPE, storageType);
3228 TryCatch(r == E_SUCCESS, , "GetValue() fail[%s]", GetErrorMessage(r));
3230 r = CmUtility::GetDirectoryPath(storageType, FilePath);
3231 TryCatch(r == E_SUCCESS, , "GetDirectoryPath() fail[%s]", GetErrorMessage(r));
3233 if( File::IsFileExist(FilePath) != true)
3239 contentId = pContentManager->CreateContent(capturedData, pFullFileName->GetPointer());
3240 TryCatch(Tizen::Base::UuId::GetInvalidUuId() != contentId, GetLastResult(), "CreateContent failed.");
3242 pImageContentInfo = static_cast<ImageContentInfo*>(pContentManager->GetContentInfoN(contentId));
3243 TryCatch(pImageContentInfo != null, , "pImageContentInfo is null");
3248 pContentManager->ScanDirectory(FilePath, true, null , reqId);
3254 __pBitmap = pImageContentInfo->GetThumbnailN();
3255 TryCatch(__pBitmap != null, , "__pBitmap is null");
3257 delete pContentManager;
3258 pContentManager = null;
3260 delete pImageContentInfo;
3261 pImageContentInfo = null;
3263 delete pFullFileName;
3264 pFullFileName = null;
3266 AppLogDebug("ENTER:E_SUCCESS");
3268 SetAppControlRequestType(APP_CONTROL_REQUEST_TYPE_SUCCEEDED);
3270 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_CAPTURED);
3274 AppLogDebug("ENTER:E_FAILED");
3275 SetErrorResult(STRING_CAMERA_CAPTURED_ERROR);
3277 SetAppControlRequestType(APP_CONTROL_REQUEST_TYPE_FAILED);
3279 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_ERROR_OCCURRED);
3282 else if (shootingMode == CAPTURE_BURST_MODE)
3288 AppLogDebug("EXIT");
3292 AppLogDebug("EXIT - CATCH");
3293 if (__pBitmap != null)
3299 if (pContentManager != null)
3301 delete pContentManager;
3302 pContentManager = null;
3305 if (pImageContentInfo)
3307 delete pImageContentInfo;
3308 pImageContentInfo = null;
3313 delete pFullFileName;
3314 pFullFileName = null;
3317 SetErrorResult(STRING_CAMERA_CAPTURED_ERROR);
3319 SetAppControlRequestType(APP_CONTROL_REQUEST_TYPE_FAILED);
3321 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_ERROR_OCCURRED);
3325 CameraPresentationModel::OnCameraErrorOccurred(Tizen::Media::CameraErrorReason r)
3327 AppLogDebug("ENTER");
3328 result res = E_FAILURE;
3329 int currentCameraMode = 0;
3333 case CAMERA_ERROR_OUT_OF_MEMORY:
3335 AppLogDebug("camera error occurred - CAMERA_ERROR_OUT_OF_MEMORY");
3336 res = E_OUT_OF_MEMORY;
3340 case CAMERA_ERROR_DEVICE_FAILED:
3342 AppLogDebug("camera error occurred - CAMERA_ERROR_DEVICE_FAILED");
3343 res = E_DEVICE_FAILED;
3347 case CAMERA_ERROR_DEVICE_INTERRUPTED:
3349 AppLogDebug("camera error occurred - CAMERA_ERROR_DEVICE_INTERRUPTED");
3350 res = E_DEVICE_BUSY;
3361 result ret = GetValue(CURRENT_MODE, currentCameraMode);
3362 TryReturnVoid(ret == E_SUCCESS, "Faled to set value to registry[%s]", GetErrorMessage(ret));
3364 if (currentCameraMode == CAMERA_MODE_RECORD)
3366 AppLogDebug("RECORD error occurred");
3367 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_VIDEO_RECORDER_ERROR_OCCURRED);
3371 AppLogDebug("SNAPSHOT error occurred");
3372 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_ERROR_OCCURRED);
3374 AppLogDebug("EXIT");
3378 CameraPresentationModel::OnVideoRecorderCanceled(result r)
3380 AppLogDebug("ENTER");
3381 if (__pVideoRecorder != null)
3383 __pVideoRecorder->Close();
3386 if (__recorderStopException)
3388 r = __pCamera->StopPreview();
3389 TryReturnVoid(r == E_SUCCESS, "Camera::StopPreview() [%s]", GetErrorMessage(r));
3391 if (__pCamera->IsPoweredOn() == true)
3393 r = __pCamera->PowerOff();
3394 TryReturnVoid(r == E_SUCCESS, "Camera::PowerOff() [%s]", GetErrorMessage(r));
3397 AppLogDebug("EXIT");
3401 CameraPresentationModel::OnVideoRecorderClosed(result r)
3403 AppLogDebug("ENTER");
3404 # if 0 //Unused code
3405 ContentManager* pContentManager = null;
3407 ContentId contentId;
3408 String replaceFilePath;
3409 String camcorderTemporaryFilePath;
3410 int storageType = STORAGE_TYPE_PHONE;
3411 result ret = E_SUCCESS;
3413 ret = SetFlashModeOnRecord(false);
3414 AppLogDebug("SetFlashModeOnRecord fail[%s]", GetErrorMessage(ret));
3416 AppLogDebug("isCancelRecord", __isCancelRecord);
3418 if (__isCancelRecord)
3420 __onVideoRecorderStarted = false;
3421 AppLogDebug("isCancelRecord %d", __isCancelRecord);
3423 ret = RemoveVideoFile();
3424 AppLogDebug("RemoveVideoFile fail[%s]", GetErrorMessage(ret));
3426 SetAppControlRequestType(APP_CONTROL_REQUEST_TYPE_CANCELED);
3427 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_VIDEO_RECORDER_CANCELED);
3429 AppLogDebug("CANCELRECORD - EXIT");
3435 AppLogDebug("ENTER: E_SUCCESS");
3437 ret = GetValue(STORAGE_TYPE, storageType);
3438 if (ret != E_SUCCESS)
3440 storageType = STORAGE_TYPE_PHONE;
3443 if (storageType == STORAGE_TYPE_PHONE)
3445 camcorderTemporaryFilePath.Format(MAX_DIRECTORY_PATH_LENGTH, L"%ls%ls", App::GetInstance()->GetAppRootPath().GetPointer(), STRING_CAMCORDER_TEMPORARY_FILE);
3449 camcorderTemporaryFilePath.Format(MAX_DIRECTORY_PATH_LENGTH, L"%ls%ls", Environment::GetExternalStoragePath().GetPointer(), STRING_CAMCORDER_TEMPORARY_FILE_EXT);
3452 # if 0 //Contnet Manager is nto used
3453 pContentManager = new (std::nothrow) ContentManager();
3454 ret = pContentManager->Construct();
3455 TryCatch(ret == E_SUCCESS, , "ContentManager->Construct() failed(%s)", GetErrorMessage(r));
3458 AppLogDebug("latest content name is %ls",__latestContentName.GetPointer());
3459 r = ContentManager::ScanFile(__latestContentName);
3460 __CurrentVideoFileName = __latestContentName;
3462 if (storageType == STORAGE_TYPE_PHONE)
3464 replaceFilePath = Environment::GetMediaPath();
3468 replaceFilePath = Environment::GetExternalStoragePath();
3471 replaceFilePath.Append(STRING_CAMERA_FOLDER_NAME);
3472 replaceFilePath.Append("/");
3473 AppLogDebug("Replace filepath is %ls",replaceFilePath.GetPointer());
3474 __CurrentVideoFileName.Replace(replaceFilePath,"");
3475 AppLogDebug("__CurrentVideoFileName path is %ls",__CurrentVideoFileName.GetPointer());
3477 __pBitmap = CmUtility::CreateThumbnailN(__CurrentVideoFileName,CONTENT_TYPE_VIDEO);
3479 SetAppControlRequestType(APP_CONTROL_REQUEST_TYPE_SUCCEEDED);
3481 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_VIDEO_RECORDER_CLOSED);
3485 AppLogDebug("ENTER: E_FAILED");
3487 SetErrorResult(STRING_VIDEO_RECORDER_CLOSED_ERROR);
3489 SetAppControlRequestType(APP_CONTROL_REQUEST_TYPE_FAILED);
3490 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_VIDEO_RECORDER_ERROR_OCCURRED);
3493 __onVideoRecorderStarted = false;
3495 AppLogDebug("EXIT");
3500 CameraPresentationModel::OnVideoRecorderEndReached(RecordingEndCondition endCondition)
3502 AppLogDebug("ENTER");
3503 ContentManager* pContentManager = null;
3504 VideoContentInfo* videoContentInfo = null;
3505 ContentId contentId;
3506 String camcorderTemporaryFilePath;
3507 int storageType = STORAGE_TYPE_PHONE;
3508 result ret = E_SUCCESS;
3510 ret = SetFlashModeOnRecord(false);
3511 AppLogDebug("SetFlashModeOnRecord fail[%s]", GetErrorMessage(ret));
3515 ret = GetValue(STORAGE_TYPE, storageType);
3516 if (ret != E_SUCCESS)
3518 storageType = STORAGE_TYPE_PHONE;
3521 if (storageType == STORAGE_TYPE_PHONE)
3523 camcorderTemporaryFilePath.Format(MAX_DIRECTORY_PATH_LENGTH, L"%ls%ls", App::GetInstance()->GetAppRootPath().GetPointer(), STRING_CAMCORDER_TEMPORARY_FILE);
3527 camcorderTemporaryFilePath.Format(MAX_DIRECTORY_PATH_LENGTH, L"%ls%ls", Environment::GetExternalStoragePath().GetPointer(), STRING_CAMCORDER_TEMPORARY_FILE_EXT);
3530 pContentManager = new (std::nothrow) ContentManager();
3532 ret = pContentManager->Construct();
3533 TryCatch(ret == E_SUCCESS, , "ContentManager->Construct() failed(%s)", GetErrorMessage(ret));
3535 contentId = pContentManager->CreateContent(camcorderTemporaryFilePath, __latestContentName, true);
3536 TryCatch(Tizen::Base::UuId::GetInvalidUuId() != contentId, GetLastResult(), "CreateContent failed.");
3538 videoContentInfo = static_cast<VideoContentInfo*>(pContentManager->GetContentInfoN(contentId));
3539 TryCatch(videoContentInfo != null, , "videoContentInfo is null");
3544 __pBitmap = videoContentInfo->GetThumbnailN();
3545 TryCatch(__pBitmap != null, , "__pBitmap is null");
3547 delete videoContentInfo;
3548 videoContentInfo = null;
3550 delete pContentManager;
3551 pContentManager = null;
3553 SetAppControlRequestType(APP_CONTROL_REQUEST_TYPE_SUCCEEDED);
3555 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_VIDEO_RECORDER_END_REACHED);
3557 __onVideoRecorderStarted = false;
3558 AppLogDebug("EXIT");
3562 AppLogDebug("EXIT - CATCH");
3563 delete pContentManager;
3564 pContentManager = null;
3566 delete videoContentInfo;
3567 videoContentInfo = null;
3572 SetErrorResult(STRING_VIDEO_RECORDER_END_REACHED_ERROR);
3573 SetAppControlRequestType(APP_CONTROL_REQUEST_TYPE_FAILED);
3574 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_VIDEO_RECORDER_ERROR_OCCURRED);
3578 CameraPresentationModel::OnVideoRecorderErrorOccurred(RecorderErrorReason r)
3580 AppLogDebug("ENTER OnVideoRecorderErrorOccurred (%ld)", r);
3582 __recorderError = r;
3583 __pVideoRecorder->Close();
3585 SetAppControlRequestType(APP_CONTROL_REQUEST_TYPE_FAILED);
3587 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_VIDEO_RECORDER_ERROR_OCCURRED);
3589 __onVideoRecorderStarted = false;
3590 AppLogDebug("EXIT");
3594 CameraPresentationModel::OnVideoRecorderPaused(result r)
3596 AppLogDebug("ENTER");
3597 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_VIDEO_RECORDER_PAUSED);
3598 AppLogDebug("EXIT");
3602 CameraPresentationModel::OnVideoRecorderStarted(result r)
3604 AppLogDebug("ENTER");
3605 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_VIDEO_RECORDER_STARTED);
3606 AppLogDebug("EXIT");
3610 CameraPresentationModel::GetOnVideoRecorderStopped(void)
3612 AppLogDebug("ENTER");
3613 AppLogDebug("EXIT");
3614 return __onVideoRecorderStarted;
3618 CameraPresentationModel::SetOnVideoRecorderStopped(bool isCompleted)
3620 AppLogDebug("ENTER");
3621 __onVideoRecorderStarted = isCompleted;
3622 AppLogDebug("EXIT");
3626 CameraPresentationModel::OnVideoRecorderStopped(result r)
3628 AppLogDebug("ENTER");
3629 result localResult = E_SUCCESS;
3631 if (__pVideoRecorder != null)
3633 localResult = __pVideoRecorder->Close();
3634 TryCatch(localResult == E_SUCCESS, , "__pVideoRecorder::Close() fail[%s]", GetErrorMessage(localResult));
3636 __onVideoRecorderStarted = true;
3638 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_VIDEO_RECORDER_STOPPED);
3640 AppLogDebug("EXIT");
3644 AppLogDebug("EXIT - CATCH");
3645 SetAppControlRequestType(APP_CONTROL_REQUEST_TYPE_FAILED);
3646 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_VIDEO_RECORDER_ERROR_OCCURRED);
3650 CameraPresentationModel::DestroyPresentationModelInstance(void)
3652 AppLogDebug("ENTER");
3653 CameraPresentationModel* pCameraPresentationModel = CameraPresentationModel::GetInstance();
3655 delete pCameraPresentationModel;
3656 AppLogDebug("EXIT");
3660 CameraPresentationModel::UpdateThumbnail(int currentCameraMode)
3662 AppLogDebug("ENTER");
3663 result r = E_SUCCESS;
3665 r = CreateThumbnail(currentCameraMode);
3666 TryReturnVoid(r == E_SUCCESS, "CreateThumbnail() fail[%s]", GetErrorMessage(r));
3667 AppLogDebug("EXIT");
3671 CameraPresentationModel::GetStorageCardState(void) const
3673 AppLogDebug("ENTER");
3674 AppLogDebug("EXIT");
3675 return __storageCardState;
3679 CameraPresentationModel::SetStorageCardState(int storageCardState)
3681 AppLogDebug("ENTER");
3682 __storageCardState = storageCardState;
3683 AppLogDebug("EXIT");
3687 CameraPresentationModel::GetStorageCardChageState(void) const
3689 AppLogDebug("ENTER");
3690 AppLogDebug("EXIT");
3691 return __storageCardChageState;
3695 CameraPresentationModel::SetStorageCardChageState(int storageCardChageState)
3697 AppLogDebug("ENTER");
3698 __storageCardChageState = storageCardChageState;
3699 AppLogDebug("EXIT");
3703 CameraPresentationModel::StorageCardStateChaged(bool isMounted)
3705 AppLogDebug("ENTER");
3708 __storageCardState = STORAGE_CARD_STATE_MOUNT;
3712 __storageCardState = STORAGE_CARD_STATE_UNMOUNT;
3714 __pCameraSettingsPresentationModel->SetValue(SECTION_CAMERA, STORAGE_TYPE, STORAGE_TYPE_PHONE);
3716 __pCameraSettingsPresentationModel->SetValue(SECTION_CAMCORDER, STORAGE_TYPE, STORAGE_TYPE_PHONE);
3718 AppLogDebug("EXIT");
3722 CameraPresentationModel::SetDeviceManagerEventListner(void)
3724 AppLogDebug("ENTER");
3725 result r = E_SUCCESS;
3727 r = DeviceManager::AddDeviceEventListener(DEVICE_TYPE_STORAGE_CARD, *this);
3728 AppLogDebug("AddDeviceEventListener [%s] fail", GetErrorMessage(r));
3729 AppLogDebug("EXIT");
3733 CameraPresentationModel::RemoveDeviceManagerEventListner(void)
3735 AppLogDebug("ENTER");
3736 result r = E_SUCCESS;
3738 r = DeviceManager::RemoveDeviceEventListener(DEVICE_TYPE_STORAGE_CARD, *this);
3739 AppLogDebug("RemoveDeviceManagerEventListner [%s] fail", GetErrorMessage(r));
3740 AppLogDebug("EXIT");
3744 CameraPresentationModel::OnDeviceStateChanged(Tizen::System::DeviceType deviceType, const Tizen::Base::String& state)
3746 AppLogDebug("ENTER");
3747 int currentCameraMode = 0;
3748 int storageType = STORAGE_TYPE_PHONE;
3750 result r = E_SUCCESS;
3751 r = GetValue(CURRENT_MODE, currentCameraMode);
3752 TryReturnVoid(r == E_SUCCESS, "GetValue returns not E_SUCCESS", GetErrorMessage(r));
3754 if (deviceType == DEVICE_TYPE_STORAGE_CARD)
3756 switch (currentCameraMode)
3758 case CAMERA_MODE_RECORD:
3760 __pCameraSettingsPresentationModel->GetValue(SECTION_CAMCORDER, STORAGE_TYPE, storageType);
3762 if (storageType == STORAGE_TYPE_MEMORYCARD)
3764 if (IsStorageCardMounted()== false)
3766 AppLogDebug("RemoveVideoFile::GetRecorderState() = %d", __pVideoRecorder->GetState());
3768 if (__pVideoRecorder->GetState() == RECORDER_STATE_RECORDING
3769 || __pVideoRecorder->GetState() == RECORDER_STATE_PAUSED
3770 || __pVideoRecorder->GetState() == RECORDER_STATE_STARTING
3771 || __pVideoRecorder->GetState() == RECORDER_STATE_PAUSING
3774 r = RemoveVideoFile();
3775 AppLogDebug("RemoveVideoFile fail[%s]", GetErrorMessage(r));
3778 StorageCardStateChaged(false);
3780 SetAppControlRequestType(APP_CONTROL_REQUEST_TYPE_FAILED);
3782 SetStorageCardChageState(STORAGE_CARD_CHAGE_STATE_MOUNT_TO_UNMOUNT);
3783 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_STORAGE_CARD_UNMOUNT);
3787 StorageCardStateChaged(true);
3788 SetStorageCardChageState(STORAGE_CARD_CHAGE_STATE_UNKNOWN);
3793 if ( IsStorageCardMounted()== false)
3795 StorageCardStateChaged(false);
3796 SetStorageCardChageState(STORAGE_CARD_CHAGE_STATE_UNKNOWN);
3800 StorageCardStateChaged(true);
3801 SetStorageCardChageState(STORAGE_CARD_CHAGE_STATE_UNKNOWN);
3807 case CAMERA_MODE_SNAPSHOT:
3809 __pCameraSettingsPresentationModel->GetValue(SECTION_CAMERA, STORAGE_TYPE, storageType);
3811 if (storageType == STORAGE_TYPE_MEMORYCARD)
3813 if ( IsStorageCardMounted()== false)
3815 AppLogDebug("OnDeviceStateChanged state=%d", __pCamera->GetState());
3817 if (GetCameraState() == CAMERA_STATE_CAPTURED || GetCameraState() == CAMERA_STATE_CAPTURING)
3819 __isStopCaptured = true;
3823 __isStopCaptured = false;
3826 StorageCardStateChaged(false);
3828 SetAppControlRequestType(APP_CONTROL_REQUEST_TYPE_FAILED);
3829 SetStorageCardChageState(STORAGE_CARD_CHAGE_STATE_MOUNT_TO_UNMOUNT);
3830 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_STORAGE_CARD_UNMOUNT);
3834 StorageCardStateChaged(true);
3835 SetStorageCardChageState(STORAGE_CARD_CHAGE_STATE_UNKNOWN);
3840 __isStopCaptured = false;
3842 if ( IsStorageCardMounted()== false)
3844 StorageCardStateChaged(false);
3845 SetStorageCardChageState(STORAGE_CARD_CHAGE_STATE_UNKNOWN);
3849 StorageCardStateChaged(true);
3850 SetStorageCardChageState(STORAGE_CARD_CHAGE_STATE_UNKNOWN);
3860 AppLogDebug("EXIT");
3864 CameraPresentationModel::RemoveVideoFile(void)
3866 AppLogDebug("ENTER");
3867 String removeFileName;
3869 result r = E_SUCCESS;
3870 int storageType = STORAGE_TYPE_PHONE;
3872 r = GetValue(STORAGE_TYPE, storageType);
3875 storageType = STORAGE_TYPE_PHONE;
3878 removeFileName = __latestContentName;
3880 AppLogDebug("removeFileName is %ls",removeFileName.GetPointer());
3881 AppLogDebug("RemoveVideoFile::GetRecorderState() = %d", __pVideoRecorder->GetState());
3882 if (__pVideoRecorder->GetState()== RECORDER_STATE_RECORDING
3883 || __pVideoRecorder->GetState() == RECORDER_STATE_PAUSED
3884 || __pVideoRecorder->GetState() == RECORDER_STATE_STARTING
3885 || __pVideoRecorder->GetState() == RECORDER_STATE_PAUSING
3891 r = file.Construct(removeFileName, "w+");
3892 TryCatch(r == E_SUCCESS, , "file::Construct() fail[%s]", GetErrorMessage(r));
3894 r = file.Remove(removeFileName);
3895 TryCatch(r == E_SUCCESS, , "file::Remove() fail[%s]", GetErrorMessage(r));
3897 AppLogDebug("EXIT");
3901 AppLogDebug("EXIT - CATCH");
3906 CameraPresentationModel::SetDisplayResolutionType(int type)
3908 AppLogDebug("ENTER");
3909 __displayResolution = type;
3910 AppLogDebug("EXIT");
3914 CameraPresentationModel::GetDisplayResolutionType(void)
3916 AppLogDebug("ENTER");
3917 AppLogDebug("EXIT");
3918 return __displayResolution;
3921 Tizen::Media::RecordingRotation
3922 CameraPresentationModel::GetRecordingRotation(void)
3924 AppLogDebug("ENTER");
3925 RecordingRotation rotate = RECORDING_ROTATION_NONE;
3926 int selfPortraitEnable = 0;
3927 result r = E_SUCCESS;
3928 int count = sizeof(_RecordRotate) / sizeof(_RecordRotate[0]);
3930 r = GetValue(SELF_PORTRAIT_ENABLE, selfPortraitEnable);
3932 for (int i=0; i < count; i++)
3934 if ((_RecordRotate[i].camType == selfPortraitEnable) && _RecordRotate[i].orientation == GetOrientation())
3936 return _RecordRotate[i].rotate;
3939 AppLogDebug("EXIT");
3944 CameraPresentationModel::OnContentScanCompleted (RequestId reqId, const Tizen::Base::String &scanPath, result r)
3946 AppLogDebug("Enter");
3947 AppLogDebug("Exit");
3951 CameraPresentationModel::SetStartPreviewException(bool status)
3953 __startPreviewException = status;
3957 CameraPresentationModel::UpdateContentFile(void)
3959 AppLogDebug("latest content name is %ls",__latestContentName.GetPointer());
3960 ContentManager::ScanFile(__latestContentName);
3961 SetAppControlRequestType(APP_CONTROL_REQUEST_TYPE_SUCCEEDED);
3965 CameraPresentationModel::SetRecordStopException(bool currentStatus)
3967 __recorderStopException = currentStatus;
3971 CameraPresentationModel::GetRecorderErrorStatus(void)
3973 return __recorderError;
3977 CameraPresentationModel::GetUpdatedContentName(Tizen::Base::String& latestContentName)
3979 latestContentName = __latestContentName;
3983 CameraPresentationModel::SetMemoryFullException(bool status)
3985 __memoryFullException = status;
3989 CameraPresentationModel::GetMemoryFullExceptionStatus(void)
3991 long long allocatedMemory = 0;
3992 bool memoryStatus = false;
3994 allocatedMemory = CmUtility::GetAvailableMemory();
3996 if (__memoryFullException && allocatedMemory < MIN_MEMORY_NEEDED)
3998 memoryStatus = true;
4001 return memoryStatus;
4005 CameraPresentationModel::SetCurrentSourceForm(SourceForm source)
4007 __pCurrentSource = source;
4011 CameraPresentationModel::GetCurrentSourceForm(void)
4013 return __pCurrentSource;
4017 CameraPresentationModel::GetCancelRecord(void)
4019 return __isCancelRecord;