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 int MAX_CONTENTSEARCH_COUNTPERPAGE = 10;
42 static const int DOUBLE_DIGIT_NUMBER_TEN = 10;
43 static const int MAX_QUERY_LENGTH = 1024;
44 static const bool CAPTURE_NORMAL_MODE = 0;
45 static const bool CAPTURE_BURST_MODE = 1;
46 static const int MAX_CAMERA_EXPOSURE_VALUE = 8;
47 static const int PREVIEW_RESOLOTION_WIDTH = 640;
48 static const int PREVIEW_RESOLOTION_HEIGHT = 480;
49 static const int PREVIEW_RESOLOTION_WVGA_WIDTH = 320;
50 static const int PREVIEW_RESOLOTION_WVGA_HEIGHT = 240;
51 static const int SEARCH_PAGE_NO = 1;
52 static const long INIT = -1;
54 static const wchar_t* STRING_CAMERA_FOLDER_NAME = L"Camera";
55 static const wchar_t* STRING_EXTENSION_JPG = L".jpg";
56 static const wchar_t* STRING_EXTENSION_MP4 = L".mp4";
57 static const wchar_t* STRING_ZERO_CHAR = L"0";
58 static const wchar_t* STRING_UNDERBAR_CHAR = L"_";
59 static const wchar_t* STRING_QUERY_PREFIX = L"ContentFileName LIKE '%";
60 static const wchar_t* STRING_QUERY_SUFFIX = L"'";
61 static const wchar_t* STRING_SDCARD_MOUNTED_STATE = L"Mounted";
62 static const wchar_t* STRING_KEY_STORAGE_PHONE = L"http://tizen.org/runtime/storage.available.internal.media";
63 static const wchar_t* STRING_KEY_STORAGE_SDCARD = L"http://tizen.org/runtime/storage.available.external";
64 static const wchar_t* STRING_CAMCORDER_TEMPORARY_FILE = L"data/temp.mp4";
65 static const wchar_t* STRING_CAMCORDER_TEMPORARY_FILE_EXT = L"Camera/temp.mp4";
66 static const wchar_t* STRING_CAMERA_CAPTURED_ERROR = L"Captured Error";
67 static const wchar_t* STRING_VIDEO_RECORDER_CLOSED_ERROR = L"Video Recorder Closed Error";
68 static const wchar_t* STRING_VIDEO_RECORDER_END_REACHED_ERROR = L"Video Recorder End Reached Error";
69 static const String STRING_CONTENT_CAMERA_PATH = Environment::GetMediaPath() + L"Camera";
70 static const String STRING_CONTENT_CAMERA_PATH_EXT = Environment::GetExternalStoragePath() + L"Camera";
71 static const String CONTENT_INFO_ORDER = L"ContentName";
72 static const wchar_t* EMPTY_SPACE = L"";
74 CameraPresentationModel* CameraPresentationModel::__pPresentationModel = null;
78 Tizen::Ui::OrientationStatus orientation;
79 CameraSelection camType;
80 RecordingRotation rotate;
81 }_RecordingRotationTable;
83 static const _RecordingRotationTable _RecordRotate[] =
85 {ORIENTATION_STATUS_PORTRAIT, CAMERA_PRIMARY, RECORDING_ROTATION_90},
86 {ORIENTATION_STATUS_LANDSCAPE, CAMERA_PRIMARY, RECORDING_ROTATION_NONE},
87 {ORIENTATION_STATUS_PORTRAIT_REVERSE, CAMERA_PRIMARY, RECORDING_ROTATION_180},
88 {ORIENTATION_STATUS_LANDSCAPE_REVERSE, CAMERA_PRIMARY, RECORDING_ROTATION_270},
90 {ORIENTATION_STATUS_PORTRAIT, CAMERA_SECONDARY, RECORDING_ROTATION_90},
91 {ORIENTATION_STATUS_LANDSCAPE, CAMERA_SECONDARY, RECORDING_ROTATION_NONE},
92 {ORIENTATION_STATUS_PORTRAIT_REVERSE, CAMERA_SECONDARY, RECORDING_ROTATION_180},
93 {ORIENTATION_STATUS_LANDSCAPE_REVERSE, CAMERA_SECONDARY, RECORDING_ROTATION_270},
96 enum CamSetExifOrientationMode
98 CAM_SET_EXIF_ORIENTATION_MODE_NONE = 0,
99 CAM_SET_EXIF_ORIENTATION_MODE_PORTRAIT,
100 CAM_SET_EXIF_ORIENTATION_MODE_LANDSCAPE,
101 CAM_SET_EXIF_ORIENTATION_MODE_PORTRAIT_REVERSE,
102 CAM_SET_EXIF_ORIENTATION_MODE_LANDSCAPE_REVERSE,
106 GetDirectoryPath(int storageType, Tizen::Base::String& directoryPath)
108 AppLogDebug("ENTER");
109 result r = E_SUCCESS;
111 if (storageType == STORAGE_TYPE_MEMORYCARD)
113 r = directoryPath.Format(MAX_DIRECTORY_PATH_LENGTH, L"%ls%ls", Environment::GetExternalStoragePath().GetPointer(), STRING_CAMERA_FOLDER);
114 TryCatch(r == E_SUCCESS, , "String::Format() fail[%s]", GetErrorMessage(r));
116 else if (storageType == STORAGE_TYPE_PHONE)
118 r = directoryPath.Format(MAX_DIRECTORY_PATH_LENGTH, L"%ls%ls", Environment::GetMediaPath().GetPointer(), STRING_CAMERA_FOLDER);
119 TryCatch(r == E_SUCCESS, , "String::Format() fail[%s]", GetErrorMessage(r));
123 r = directoryPath.Format(MAX_DIRECTORY_PATH_LENGTH, L"%ls%ls", Environment::GetMediaPath().GetPointer(), STRING_CAMERA_FOLDER);
124 TryCatch(r == E_SUCCESS, , "String::Format() fail[%s]", GetErrorMessage(r));
127 AppLogDebug("FilePath %ls", directoryPath.GetPointer());
132 AppLogDebug("EXIT - CATCH");
137 GetFileName(int currentCameraMode, Tizen::Base::String& fileName)
139 AppLogDebug("ENTER");
140 result r = E_SUCCESS;
141 DateTime currentDateTime;
143 r = SystemTime::GetCurrentTime(currentDateTime);
144 TryCatch(r == E_SUCCESS, , "SystemTime::GetCurrentTime() fail[%s]", GetErrorMessage(r));
147 r = fileName.Append(currentDateTime.GetYear());
148 TryCatch(r == E_SUCCESS, , "fileName::Append() fail[%s]", GetErrorMessage(r));
149 if (currentDateTime.GetMonth() < DOUBLE_DIGIT_NUMBER_TEN)
151 r = fileName.Append(STRING_ZERO_CHAR);
152 TryCatch(r == E_SUCCESS, , "fileName::Append() fail[%s]", GetErrorMessage(r));
153 r = fileName.Append(currentDateTime.GetMonth());
154 TryCatch(r == E_SUCCESS, , "fileName::Append() fail[%s]", GetErrorMessage(r));
158 r = fileName.Append(currentDateTime.GetMonth());
159 TryCatch(r == E_SUCCESS, , "fileName::Append() fail[%s]", GetErrorMessage(r));
162 if (currentDateTime.GetDay() < DOUBLE_DIGIT_NUMBER_TEN)
164 r = fileName.Append(STRING_ZERO_CHAR);
165 TryCatch(r == E_SUCCESS, , "fileName::Append() fail[%s]", GetErrorMessage(r));
167 r = fileName.Append(currentDateTime.GetDay());
168 TryCatch(r == E_SUCCESS, , "fileName::Append() fail[%s]", GetErrorMessage(r));
172 r = fileName.Append(currentDateTime.GetDay());
173 TryCatch(r == E_SUCCESS, , "fileName::Append() fail[%s]", GetErrorMessage(r));
176 r = fileName.Append(STRING_UNDERBAR_CHAR);
177 TryCatch(r == E_SUCCESS, , "fileName::Append() fail[%s]", GetErrorMessage(r));
179 if (currentDateTime.GetHour() < DOUBLE_DIGIT_NUMBER_TEN)
181 r = fileName.Append(STRING_ZERO_CHAR);
182 TryCatch(r == E_SUCCESS, , "fileName::Append() fail[%s]", GetErrorMessage(r));
184 r = fileName.Append(currentDateTime.GetHour());
185 TryCatch(r == E_SUCCESS, , "fileName::Append() fail[%s]", GetErrorMessage(r));
189 r = fileName.Append(currentDateTime.GetHour());
190 TryCatch(r == E_SUCCESS, , "fileName::Append() fail[%s]", GetErrorMessage(r));
193 if (currentDateTime.GetMinute() < DOUBLE_DIGIT_NUMBER_TEN)
195 r = fileName.Append(STRING_ZERO_CHAR);
196 TryCatch(r == E_SUCCESS, , "fileName::Append() fail[%s]", GetErrorMessage(r));
198 r = fileName.Append(currentDateTime.GetMinute());
199 TryCatch(r == E_SUCCESS, , "fileName::Append() fail[%s]", GetErrorMessage(r));
203 r = fileName.Append(currentDateTime.GetMinute());
204 TryCatch(r == E_SUCCESS, , "fileName::Append() fail[%s]", GetErrorMessage(r));
207 if (currentDateTime.GetSecond() < DOUBLE_DIGIT_NUMBER_TEN)
209 r = fileName.Append(STRING_ZERO_CHAR);
210 TryCatch(r == E_SUCCESS, , "fileName::Append() fail[%s]", GetErrorMessage(r));
212 r = fileName.Append(currentDateTime.GetSecond());
213 TryCatch(r == E_SUCCESS, , "fileName::Append() fail[%s]", GetErrorMessage(r));
217 r = fileName.Append(currentDateTime.GetSecond());
218 TryCatch(r == E_SUCCESS, , "fileName::Append() fail[%s]", GetErrorMessage(r));
221 if (currentCameraMode == CameraPresentationModel::CAMERA_MODE_SNAPSHOT)
223 r = fileName.Append(STRING_EXTENSION_JPG);
224 TryCatch(r == E_SUCCESS, , "fileName::Append() fail[%s]", GetErrorMessage(r));
228 r = fileName.Append(STRING_EXTENSION_MP4);
229 TryCatch(r == E_SUCCESS, , "fileName::Append() fail[%s]", GetErrorMessage(r));
232 AppLogDebug("FileName %ls", fileName.GetPointer());
237 AppLogDebug("EXIT - CATCH");
242 MakeQuerybyContentFileName(const Tizen::Base::String& QueryString)
244 AppLogDebug("ENTER");
245 String contentNameTypeQuery = L"";
246 String sourceFileName = L"";
247 result r = E_SUCCESS;
249 sourceFileName = QueryString;
251 AppLogDebug("strTemp %ls", sourceFileName.GetPointer());
252 r = contentNameTypeQuery.SetCapacity(MAX_QUERY_LENGTH);
253 TryCatch(r == E_SUCCESS, , "String::SetCapacity() fail[%s]", GetErrorMessage(r));
255 r = sourceFileName.SetCapacity(MAX_QUERY_LENGTH);
256 TryCatch(r == E_SUCCESS, , "String::SetCapacity() fail[%s]", GetErrorMessage(r));
258 if (!sourceFileName.IsEmpty())
260 r = contentNameTypeQuery.Append(STRING_QUERY_PREFIX);
261 TryCatch(r == E_SUCCESS, , "String::SetCapacity() fail[%s]", GetErrorMessage(r));
263 r = contentNameTypeQuery.Append(sourceFileName);
264 TryCatch(r == E_SUCCESS, , "String::SetCapacity() fail[%s]", GetErrorMessage(r));
266 r = contentNameTypeQuery.Append(STRING_QUERY_SUFFIX);
267 TryCatch(r == E_SUCCESS, , "String::SetCapacity() fail[%s]", GetErrorMessage(r));
270 AppLogDebug("strQuery %ls", contentNameTypeQuery.GetPointer());
272 return contentNameTypeQuery;
275 AppLogDebug("EXIT - CATCH");
276 contentNameTypeQuery.Clear();
277 return contentNameTypeQuery;
280 Tizen::Graphics::Bitmap*
281 CreateThumbnailN(Tizen::Base::String& pFilename, ContentType contentType)
283 AppLogDebug("ENTER");
284 Bitmap* pThumbnailImage = null;
285 ContentSearch contentSearch;
286 IList* pSearchResultList = null;
287 ContentSearchResult* pContentSearchResult = null;
289 String strQuery = L"";
290 String sortColumn = L"DateTime";
296 int contentResultCount = 0;
298 result r = E_SUCCESS;
300 contentSearch.Construct(contentType);
301 AppLogDebug("pFilename : %ls",pFilename.GetPointer());
302 strQuery = MakeQuerybyContentFileName(pFilename);
303 AppLogDebug("strQuery : %ls",strQuery.GetPointer());
305 pSearchResultList = contentSearch.SearchN(page, MAX_CONTENTSEARCH_COUNTPERPAGE, totalPage, totalCount, strQuery, sortColumn, SORT_ORDER_NONE);
306 TryCatch(pSearchResultList != null, r = E_SYSTEM, "pSearchResultList is null");
308 AppLogDebug("SearchN Err = %s %d %d", GetErrorMessage(GetLastResult()), totalPage, totalCount);
310 if (pSearchResultList != null)
312 r = CameraPresentationModel::GetInstance()->GetValue(STORAGE_TYPE, storageType);
314 if (storageType == STORAGE_TYPE_PHONE)
316 filePath = Environment::GetMediaPath();
320 filePath = Environment::GetExternalStoragePath();
323 filePath.Append(STRING_CAMERA_FOLDER_NAME);
324 filePath.Append("/");
327 if ((pSearchResultList != null) && (pSearchResultList->GetCount() > 0))
329 for(contentResultCount=0;contentResultCount<pSearchResultList->GetCount();contentResultCount++)
331 pContentSearchResult = static_cast<ContentSearchResult*>(pSearchResultList->GetAt(contentResultCount));
332 TryCatch(pContentSearchResult != null, r = E_SYSTEM, "pContentSearchResult is null");
333 fullFilePath = pContentSearchResult->GetContentInfo()->GetContentPath();
334 if (fullFilePath.StartsWith(filePath,0))
336 AppLogDebug("Content Search Result found");
337 fullFilePath = pContentSearchResult->GetContentInfo()->GetContentPath();
342 pThumbnailImage = pContentSearchResult->GetContentInfo()->GetThumbnailN();
343 TryCatch(pThumbnailImage != null, r = E_SYSTEM, "pThumbnailImage is null");
352 if (pSearchResultList)
354 pSearchResultList->RemoveAll(true);
355 delete pSearchResultList;
356 pSearchResultList = null;
362 return pThumbnailImage;
371 AppLogDebug("EXIT - CATCH");
372 if (pSearchResultList)
374 pSearchResultList->RemoveAll(true);
375 delete pSearchResultList;
376 pSearchResultList = null;
382 CameraPresentationModel::CameraPresentationModel(void)
384 , __pPreviewResolutionList(null)
385 , __pCaptureResolutionList(null)
386 , __pRecordingResolutionList(null)
388 , __pVideoRecorder(null)
389 , __pCameraListener(null)
391 , __pContentManager(null)
392 , __pImageContentInfo(null)
393 , __pVideoContentInfo(null)
395 , __pCameraSettingsPresentationModel(null)
397 , __latestContentName(L"")
399 , __appControlRequestType(APP_CONTROL_REQUEST_TYPE_CANCELED)
400 , __dir(ORIENTATION_STATUS_NONE)
401 , __cameraMode(CAMERA_MODE_SNAPSHOT)
402 , __storageCardState(STORAGE_CARD_STATE_UNMOUNT)
403 , __storageCardChageState(STORAGE_CARD_CHAGE_STATE_UNKNOWN)
404 , __isStopCaptured(false)
406 , __onVideoRecorderStarted(false)
407 , __displayResolution(DISPLAY_RESOLUTION_HD)
408 , __startPreviewException(false)
409 , __isCancelRecord(false)
410 , __isInitCamera(false)
411 , __isPreviewExit(false)
412 , __isIntervalTimerRun(false)
413 ,__recorderStopException(false)
414 ,__memoryFullException(false)
415 ,__recorderError(RECORDER_ERROR_OUT_OF_STORAGE)
417 AppLogDebug("ENTER");
421 CameraPresentationModel::~CameraPresentationModel(void)
423 AppLogDebug("ENTER");
424 result r = E_SUCCESS;
426 if (__isInitCamera == true)
428 if (__pVideoRecorder != null)
430 AppLogDebug("VideoRecorder State[%d]", __pVideoRecorder->GetState());
432 if (__pVideoRecorder->GetState()== RECORDER_STATE_RECORDING
433 || __pVideoRecorder->GetState() == RECORDER_STATE_STARTING
434 || __pVideoRecorder->GetState() == RECORDER_STATE_PAUSING
435 || __pVideoRecorder->GetState() == RECORDER_STATE_PAUSED
438 r = __pVideoRecorder->Stop();
439 TryReturnVoid(r == E_SUCCESS, "__pVideoRecorder::Stop() [%s]", GetErrorMessage(r));
442 if (__pVideoRecorder->GetState()== RECORDER_STATE_STOPPING
443 || __pVideoRecorder->GetState() == RECORDER_STATE_STOPPED
446 r = __pVideoRecorder->Close();
447 TryReturnVoid(r == E_SUCCESS, "__pVideoRecorder::Close() [%s]", GetErrorMessage(r));
450 delete __pVideoRecorder;
451 __pVideoRecorder = null;
454 if (__pCamera != null)
456 AppLogDebug("Camera State[%d]", __pCamera->GetState());
458 if (__pCamera->GetState() == CAMERA_STATE_PREVIEW)
460 r = __pCamera->StopPreview();
461 TryReturnVoid(r == E_SUCCESS, "Camera::StopPreview() [%s]", GetErrorMessage(r));
464 if (__pCamera->IsPoweredOn() == true)
466 r = __pCamera->PowerOff();
467 TryReturnVoid(r == E_SUCCESS, "Camera::PowerOff() [%s]", GetErrorMessage(r));
476 if (__pCamera != null)
483 if (__pPreviewResolutionList)
485 __pPreviewResolutionList->RemoveAll(true);
486 delete __pPreviewResolutionList;
487 __pPreviewResolutionList = null;
490 if (__pCaptureResolutionList)
492 __pCaptureResolutionList->RemoveAll(true);
493 delete __pCaptureResolutionList;
494 __pCaptureResolutionList = null;
497 if (__pRecordingResolutionList)
499 __pRecordingResolutionList->RemoveAll(true);
500 delete __pRecordingResolutionList;
501 __pRecordingResolutionList = null;
506 __pIsoList->RemoveAll(true);
512 if (__pContentManager)
514 delete __pContentManager;
516 if (__pImageContentInfo)
518 delete __pImageContentInfo;
520 if (__pVideoContentInfo)
522 delete __pVideoContentInfo;
531 __isInitCamera = false;
533 __isStopCaptured = false;
537 __onVideoRecorderStarted = false;
539 __isPreviewExit = false;
541 __isIntervalTimerRun = false;
543 __displayResolution = DISPLAY_RESOLUTION_HD;
545 RemoveDeviceManagerEventListner();
547 __pCameraSettingsPresentationModel = null;
552 CameraPresentationModel::CreateThumbnail(int currentCameraMode)
554 AppLogDebug("ENTER");
555 String latestContentName = L"";
556 result r = E_SUCCESS;
562 r = GetLatestContentName(currentCameraMode, latestContentName);
563 AppLogDebug("latestContentName : %ls",latestContentName.GetPointer());
564 TryCatch(r == E_SUCCESS, , "GetLatestContentName() fail[%s]", GetErrorMessage(r));
566 if (currentCameraMode == CAMERA_MODE_SNAPSHOT)
568 __pBitmap = CreateThumbnailN(latestContentName, CONTENT_TYPE_IMAGE);
570 if (latestContentName == L"")
577 r = GetValue(STORAGE_TYPE, storageType);
579 if (storageType == STORAGE_TYPE_PHONE)
581 filePath = Environment::GetMediaPath();
585 filePath = Environment::GetExternalStoragePath();
588 filePath.Append(STRING_CAMERA_FOLDER_NAME);
589 filePath.Append("/");
590 filePath.Append(__CurrentVideoFileName);
591 if (!File::IsFileExist(filePath) || __CurrentVideoFileName.IsEmpty())
593 AppLogDebug("Latest content name is %ls",latestContentName.GetPointer());
594 __pBitmap = CreateThumbnailN(latestContentName,CONTENT_TYPE_VIDEO);
599 AppLogDebug("Current content name is %ls",__CurrentVideoFileName.GetPointer());
600 __pBitmap = CreateThumbnailN(__CurrentVideoFileName,CONTENT_TYPE_VIDEO);
603 if (latestContentName == L"")
609 if (__pBitmap == null)
611 AppLogDebug("__pBitmap : null");
618 AppLogDebug("EXIT - CATCH");
623 CameraPresentationModel::IsExistThumbnail(int currentCameraMode)
625 AppLogDebug("ENTER");
626 String latestContentName = L"";
627 result r = E_SUCCESS;
628 Bitmap* pThumbnailBitmap = null;
630 r = GetLatestContentName(currentCameraMode, latestContentName);
633 AppLogDebug("GetLatestContentName() fail[%s]", GetErrorMessage(r));
637 if (currentCameraMode == CAMERA_MODE_SNAPSHOT)
639 pThumbnailBitmap = CreateThumbnailN(latestContentName, CONTENT_TYPE_IMAGE);
641 if (pThumbnailBitmap != null)
643 delete pThumbnailBitmap;
644 pThumbnailBitmap = null;
647 if (latestContentName == L"")
649 AppLogDebug("EXIT - FILE NOT FOUND");
660 pThumbnailBitmap = CreateThumbnailN(latestContentName, CONTENT_TYPE_VIDEO);
662 if (pThumbnailBitmap != null)
664 delete pThumbnailBitmap;
665 pThumbnailBitmap = null;
668 if (latestContentName == L"")
670 AppLogDebug("EXIT - FILE NOT FOUND");
682 CameraPresentationModel::GetfilePath(int storageType)
684 AppLogDebug("ENTER");
685 result r = E_SUCCESS;
686 String filePath = L"";
688 if (storageType == STORAGE_TYPE_MEMORYCARD)
690 r = filePath.Format(MAX_DIRECTORY_PATH_LENGTH, L"%ls%ls", Environment::GetExternalStoragePath().GetPointer(), STRING_CAMERA_FOLDER);
691 TryCatch(r == E_SUCCESS, , "String::Format() fail[%s]", GetErrorMessage(r));
693 else if (storageType == STORAGE_TYPE_PHONE)
695 r = filePath.Format(MAX_DIRECTORY_PATH_LENGTH, L"%ls%ls", Environment::GetMediaPath().GetPointer(), STRING_CAMERA_FOLDER);
696 TryCatch(r == E_SUCCESS, , "String::Format() fail[%s]", GetErrorMessage(r));
700 r = filePath.Format(MAX_DIRECTORY_PATH_LENGTH, L"%ls%ls", Environment::GetMediaPath().GetPointer(), STRING_CAMERA_FOLDER);
701 TryCatch(r == E_SUCCESS, , "String::Format() fail[%s]", GetErrorMessage(r));
704 AppLogDebug("EXIT - filePath : %ls", filePath.GetPointer());
708 AppLogDebug("EXIT - CATCH");
713 CameraPresentationModel::CreateFileName(Tizen::Base::String& fullFileName)
715 AppLogDebug("ENTER");
716 String* pFilePath = null;
717 String* pFileName = null;
719 int currentCameraMode = 0;
720 result r = E_SUCCESS;
721 bool checkFileAvailability = false;
722 String updatedFileName;
723 int currentNameCount = 0;
724 String currentFileName;
725 String fileExtension;
726 int fileExtensionLength = 0;
727 int generatedFileLength = 0;
729 r = GetValue(STORAGE_TYPE, storageType);
730 TryCatch(r == E_SUCCESS, , "GetValue() fail[%s]", GetErrorMessage(r));
732 r = GetValue(CURRENT_MODE, currentCameraMode);
733 TryCatch(r == E_SUCCESS, , "GetValue() fail[%s]", GetErrorMessage(r));
735 pFilePath = new (std::nothrow) String();
736 pFileName = new (std::nothrow) String();
738 r = GetDirectoryPath(storageType, *pFilePath);
739 TryCatch(r == E_SUCCESS, , "GetDirectoryPath() fail[%s]", GetErrorMessage(r));
741 r = GetFileName(currentCameraMode, *pFileName);
742 TryCatch(r == E_SUCCESS, , "GetFileName() fail[%s]", GetErrorMessage(r));
744 updatedFileName.Clear();
745 updatedFileName.Format(MAX_FULL_FILE_PATH, L"%ls%ls", pFilePath->GetPointer(), pFileName->GetPointer());
746 currentFileName = *pFileName;
747 checkFileAvailability = File::IsFileExist(updatedFileName);
749 generatedFileLength = pFileName->GetLength();
750 if (checkFileAvailability)
752 if (currentCameraMode == CameraPresentationModel::CAMERA_MODE_SNAPSHOT)
754 r = fileExtension.Append(STRING_EXTENSION_JPG);
755 TryCatch(r == E_SUCCESS, , "fileName::Append() fail[%s]", GetErrorMessage(r));
759 r = fileExtension.Append(STRING_EXTENSION_MP4);
760 TryCatch(r == E_SUCCESS, , "fileName::Append() fail[%s]", GetErrorMessage(r));
762 fileExtensionLength = fileExtension.GetLength();
765 while (checkFileAvailability)
768 currentFileName.Clear();
769 currentFileName = *pFileName;
770 currentFileName.Remove(generatedFileLength -fileExtensionLength,fileExtensionLength);
771 AppLogDebug("filename after remove is %ls",currentFileName.GetPointer());
772 currentFileName.Append("_");
773 currentFileName.Append(currentNameCount);
774 if (currentCameraMode == CameraPresentationModel::CAMERA_MODE_SNAPSHOT)
776 currentFileName.Append(STRING_EXTENSION_JPG);
780 currentFileName.Append(STRING_EXTENSION_MP4);
782 updatedFileName.Clear();
783 updatedFileName.Format(MAX_FULL_FILE_PATH, L"%ls%ls", pFilePath->GetPointer(), currentFileName.GetPointer());
784 checkFileAvailability = File::IsFileExist(updatedFileName);
787 if (currentNameCount != 0)
790 pFileName->Append(currentFileName);
791 AppLogDebug("updated file name is %ls",pFileName->GetPointer());
794 fullFileName.Clear();
795 r = fullFileName.Format(MAX_FULL_FILE_PATH, L"%ls%ls", pFilePath->GetPointer(), pFileName->GetPointer());
796 TryCatch(r == E_SUCCESS, , "String::Format() fail[%s]", GetErrorMessage(r));
804 AppLogDebug("EXIT - pFullFileName %ls", fullFileName.GetPointer());
808 AppLogDebug("EXIT - CATCH");
819 CameraPresentationModel::CreateInstance(void)
821 AppLogDebug("ENTER");
822 __pPresentationModel = new (std::nothrow) CameraPresentationModel();
824 result r = __pPresentationModel->Construct();
828 delete __pPresentationModel;
829 __pPresentationModel = null;
833 // std::atexit(DestroyInstance);
838 CameraPresentationModel::DestroyInstance(void)
840 AppLogDebug("ENTER");
841 delete __pPresentationModel;
842 __pPresentationModel = null;
846 CameraPresentationModel*
847 CameraPresentationModel::GetInstance(void)
849 AppLogDebug("ENTER");
850 if (__pPresentationModel == null)
856 return __pPresentationModel;
860 CameraPresentationModel::Construct(void)
862 AppLogDebug("ENTER");
863 result r = E_SUCCESS;
865 __pCameraSettingsPresentationModel = CameraSettingsPresentationModel::GetInstance();
866 TryCatch(__pCameraSettingsPresentationModel != null, r = E_SYSTEM, "__pCameraSettingsPresentationModel is null");
868 SetDeviceManagerEventListner();
874 AppLogDebug("EXIT - CATCH");
879 CameraPresentationModel::Terminate(int mode)
881 AppLogDebug("ENTER Terminate :: mode = %d", mode);
882 result r = E_SUCCESS;
884 if (mode == CAMERA_MODE_SNAPSHOT)
886 if (__pVideoRecorder != null)
888 AppLogDebug("VideoRecorder State[%d]", __pVideoRecorder->GetState());
890 if (__pVideoRecorder->GetState()== RECORDER_STATE_RECORDING
891 || __pVideoRecorder->GetState() == RECORDER_STATE_STARTING
892 || __pVideoRecorder->GetState() == RECORDER_STATE_PAUSING
893 || __pVideoRecorder->GetState() == RECORDER_STATE_PAUSED
896 r = __pVideoRecorder->Stop();
897 TryReturnVoid(r == E_SUCCESS, "__pVideoRecorder::Stop() [%s]", GetErrorMessage(r));
900 if (__pVideoRecorder->GetState()== RECORDER_STATE_STOPPING
901 || __pVideoRecorder->GetState() == RECORDER_STATE_STOPPED
904 r = __pVideoRecorder->Close();
905 TryReturnVoid(r == E_SUCCESS, "__pVideoRecorder::Close() [%s]", GetErrorMessage(r));
908 delete __pVideoRecorder;
909 __pVideoRecorder = null;
912 if (__pCamera != null)
914 AppLogDebug("Camera State[%d]", __pCamera->GetState());
916 if (__pCamera->GetState() == CAMERA_STATE_PREVIEW)
918 r = __pCamera->StopPreview();
919 TryReturnVoid(r == E_SUCCESS, "Camera::StopPreview() [%s]", GetErrorMessage(r));
922 if (__pCamera->IsPoweredOn() == true)
924 r = __pCamera->PowerOff();
926 AppLogDebug("Camera::PowerOff() [%s]", GetErrorMessage(r));
928 if (r == E_DEVICE_BUSY)
930 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_PREVIEW_START_FAILED);
938 else if (mode == CAMERA_MODE_RECORD)
940 if (__pCamera != null)
942 AppLogDebug("Camera State[%d]", __pCamera->GetState());
944 if (__pCamera->GetState() == CAMERA_STATE_PREVIEW)
946 r = __pCamera->StopPreview();
947 TryReturnVoid(r == E_SUCCESS, "Camera::StopPreview() [%s]", GetErrorMessage(r));
950 if (__pCamera->IsPoweredOn() == true)
952 r = __pCamera->PowerOff();
954 AppLogDebug("Camera::PowerOff() [%s]", GetErrorMessage(r));
956 if (r == E_DEVICE_BUSY)
958 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_PREVIEW_START_FAILED);
966 if (__pVideoRecorder != null)
968 AppLogDebug("VideoRecorder State[%d]", __pVideoRecorder->GetState());
970 if (__pVideoRecorder->GetState()== RECORDER_STATE_RECORDING
971 || __pVideoRecorder->GetState() == RECORDER_STATE_STARTING
972 || __pVideoRecorder->GetState() == RECORDER_STATE_PAUSING
973 || __pVideoRecorder->GetState() == RECORDER_STATE_PAUSED
976 r = __pVideoRecorder->Stop();
977 TryReturnVoid(r == E_SUCCESS, "__pVideoRecorder::Stop() [%s]", GetErrorMessage(r));
980 if (__pVideoRecorder->GetState()== RECORDER_STATE_STOPPING
981 || __pVideoRecorder->GetState() == RECORDER_STATE_STOPPED
984 r = __pVideoRecorder->Close();
985 TryReturnVoid(r == E_SUCCESS, "__pVideoRecorder::Close() [%s]", GetErrorMessage(r));
988 delete __pVideoRecorder;
989 __pVideoRecorder = null;
996 CameraPresentationModel::InitializeFlashMode(void)
998 AppLogDebug("ENTER");
999 result r = E_SUCCESS;
1001 int selfPortraitEnable = 0;
1003 r = GetValue(SELF_PORTRAIT_ENABLE, selfPortraitEnable);
1004 if (selfPortraitEnable == CAM_SELF_PORTRAIT_MODE_PRIMARY)
1006 r = GetMediaCapability(CAMERA_PRIMARY_FLASH_MODE);
1010 r = GetMediaCapability(CAMERA_SECONDARY_FLASH_MODE);
1015 if (selfPortraitEnable == CAM_SELF_PORTRAIT_MODE_PRIMARY)
1017 r = GetValue(FLASH_MODE_PRIMARY, flashMode);
1021 r = GetValue(FLASH_MODE_SECONDARY, flashMode);
1023 TryCatch(r == E_SUCCESS, , "GetValue() fail[%s]", GetErrorMessage(r));
1025 AppLogDebug("flashMode = %d", flashMode);
1026 SetFlashMode(CameraFlashMode(flashMode));
1029 AppLogDebug("EXIT");
1033 AppLogDebug("EXIT - CATCH");
1038 CameraPresentationModel::InitializeCamera(void)
1040 AppLogDebug("ENTER");
1041 Dimension* pCaptureResolution = null;
1042 int selfPortraitEnable = 0;
1043 int captureResolutionCount = 0;
1044 result r = E_SUCCESS;
1045 int resolutionIndex = 0;
1047 r = GetValue(SELF_PORTRAIT_ENABLE, selfPortraitEnable);
1048 TryCatch(r == E_SUCCESS, , "GetValue() fail[%s]", GetErrorMessage(r));
1050 if (selfPortraitEnable == CameraPresentationModel::CAM_SELF_PORTRAIT_MODE_PRIMARY)
1052 r = GetValue(PRIMARY_RESOLUTION_INDEX, resolutionIndex);
1053 TryCatch(r == E_SUCCESS, , "GetValue() fail[%s]", GetErrorMessage(r));
1057 r = GetValue(SECONDARY_RESOLUTION_INDEX, resolutionIndex);
1058 TryCatch(r == E_SUCCESS, , "GetValue() fail[%s]", GetErrorMessage(r));
1061 if (__pCamera == null)
1063 __pCamera = new (std::nothrow) Camera();
1064 TryCatch(__pCamera != null, , "[FAILURE] new (std::nothrow) Camera()");
1066 if (selfPortraitEnable == CAM_SELF_PORTRAIT_MODE_PRIMARY)
1068 AppLogDebug("CAMERA_PRIMARY_MODE !!!");
1069 r = __pCamera->Construct(*this, CAMERA_PRIMARY);
1073 AppLogDebug("CAMERA_SECONDARY_MODE !!!");
1074 r = __pCamera->Construct(*this, CAMERA_SECONDARY);
1076 TryCatch(r == E_SUCCESS, , "__pCamera->Construct() [%s]", GetErrorMessage(r));
1079 r = __pCamera->PowerOn();
1080 TryCatch(r == E_SUCCESS, , "Camera::PowerOn fail[%s]", GetErrorMessage(r));
1082 r = SetCameraPreviewResolution();
1083 TryCatch(r == E_SUCCESS, , "Camera::SetCameraPreviewResolution fail[%s]", GetErrorMessage(r));
1085 __pCaptureResolutionList = __pCamera->GetSupportedCaptureResolutionListN();
1086 TryCatch(__pCaptureResolutionList != null, , "pCaptureResolutionList is null");
1088 captureResolutionCount = __pCaptureResolutionList->GetCount();
1089 AppLogDebug("__pCaptureResolutionList Count : %d", captureResolutionCount);
1092 pCaptureResolution = static_cast< Dimension*>(__pCaptureResolutionList->GetAt(captureResolutionCount -1 - resolutionIndex));
1093 TryCatch(pCaptureResolution != null, , "pCaptureResolution is null");
1095 r = __pCamera->SetCaptureResolution(*pCaptureResolution);
1096 TryCatch(r == E_SUCCESS, , "Camera::SetCaptureResolution fail[%s]", GetErrorMessage(r));
1098 AppLogDebug("EXIT");
1102 AppLogDebug("EXIT - CATCH");
1104 if ( __pCamera != null ) //Deleting Camera if something goes wrong.
1109 if (__pPreviewResolutionList)
1111 __pPreviewResolutionList->RemoveAll(true);
1114 delete __pPreviewResolutionList;
1115 __pPreviewResolutionList = null;
1117 if (__pCaptureResolutionList)
1119 __pCaptureResolutionList->RemoveAll(true);
1122 delete __pCaptureResolutionList;
1123 __pCaptureResolutionList = null;
1125 __isInitCamera = false;
1126 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_INITIALIZE_FAILED);
1132 CameraPresentationModel::SetCameraPreviewResolution(void)
1134 AppLogDebug("ENTER");
1135 Dimension* pPreviewResolution = null;
1136 Dimension PreviewResolutionDim;
1137 Dimension tempDimention(PREVIEW_RESOLOTION_WIDTH, PREVIEW_RESOLOTION_HEIGHT);
1138 Dimension tempDimentionWvga(PREVIEW_RESOLOTION_WVGA_WIDTH, PREVIEW_RESOLOTION_WVGA_HEIGHT);
1139 int previewResolutionCount = 0;
1140 int previewResolutionIdx = 0;
1142 result r = E_SUCCESS;
1144 if (__pPreviewResolutionList == null)
1146 __pPreviewResolutionList = __pCamera->GetSupportedPreviewResolutionListN();
1147 TryCatch(__pPreviewResolutionList != null, , "__pPreviewResolutionList is null");
1149 previewResolutionCount = __pPreviewResolutionList->GetCount();
1150 AppLogDebug("pPreviewResolutionList Count : %d", previewResolutionCount);
1152 if (previewResolutionCount > 0)
1154 for (idx = 0; idx < previewResolutionCount; idx++)
1156 pPreviewResolution = static_cast<Dimension*>(__pPreviewResolutionList->GetAt(idx));
1158 AppLogDebug("InitializeCamcorder pPreviewResolution w:%d,h:%d", pPreviewResolution->width, pPreviewResolution->height);
1160 if (GetDisplayResolutionType() == DISPLAY_RESOLUTION_WVGA)
1162 AppLogDebug("DISPLAY_RESOLUTION_WVGA");
1163 if (*pPreviewResolution == tempDimentionWvga)
1165 previewResolutionIdx = idx;
1171 if (*pPreviewResolution == tempDimention)
1173 previewResolutionIdx = idx;
1180 pPreviewResolution = static_cast<Dimension*>(__pPreviewResolutionList->GetAt(previewResolutionIdx));
1181 TryCatch(pPreviewResolution != null, , "pPreviewResolution is null");
1183 AppLogDebug("InitializeCamcorder::pPreviewResolution w:%d,h:%d", pPreviewResolution->width, pPreviewResolution->height);
1185 r = __pCamera->SetPreviewResolution(*pPreviewResolution);
1186 TryCatch(r == E_SUCCESS, , "Camera::SetPreviewResolution fail[%s]", GetErrorMessage(r));
1190 PreviewResolutionDim = __pCamera->GetPreviewResolution();
1192 AppLogDebug("InitializeCamcorder::pPreviewResolution w:%d,h:%d", PreviewResolutionDim.width, PreviewResolutionDim.height);
1194 r = __pCamera->SetPreviewResolution(PreviewResolutionDim);
1195 TryCatch(r == E_SUCCESS, , "Camera::SetPreviewResolution fail[%s]", GetErrorMessage(r));
1198 AppLogDebug("EXIT");
1202 AppLogDebug("EXIT - CATCH");
1203 if (__pPreviewResolutionList)
1205 __pPreviewResolutionList->RemoveAll(true);
1206 delete __pPreviewResolutionList;
1207 __pPreviewResolutionList = null;
1213 CameraPresentationModel::SetCamcorderRecordingResolution(void)
1215 AppLogDebug("ENTER");
1216 Dimension* pRecordingResolution = null;
1217 Dimension RecordingResolutionDim;
1218 Dimension tempDimention(PREVIEW_RESOLOTION_WIDTH, PREVIEW_RESOLOTION_HEIGHT);
1219 Dimension tempDimentionWvga(PREVIEW_RESOLOTION_WVGA_WIDTH, PREVIEW_RESOLOTION_WVGA_HEIGHT);
1220 int recordingResolutionCount = 0;
1221 int recordingResolutionIdx = 0;
1223 result r = E_SUCCESS;
1225 if (__pRecordingResolutionList == null)
1227 __pRecordingResolutionList = __pVideoRecorder->GetSupportedRecordingResolutionListN();
1228 TryCatch(__pRecordingResolutionList != null, , "__pRecordingResolutionList is null");
1230 recordingResolutionCount = __pRecordingResolutionList->GetCount();
1231 AppLogDebug("__pRecordingResolutionList Count : %d", recordingResolutionCount);
1233 if (recordingResolutionCount > 0)
1235 for (idx = 0; idx < recordingResolutionCount; idx++)
1237 pRecordingResolution = static_cast<Dimension*>(__pRecordingResolutionList->GetAt(idx));
1239 AppLogDebug("pRecordingResolution w:%d,h:%d", pRecordingResolution->width, pRecordingResolution->height);
1241 if (GetDisplayResolutionType() == DISPLAY_RESOLUTION_WVGA)
1243 AppLogDebug("DISPLAY_RESOLUTION_WVGA");
1244 if (*pRecordingResolution == tempDimentionWvga)
1246 recordingResolutionIdx = idx;
1247 __pCamera->SetPreviewResolution(tempDimentionWvga);
1253 if (*pRecordingResolution == tempDimention)
1255 __pCamera->SetPreviewResolution(tempDimention);
1256 recordingResolutionIdx = idx;
1263 pRecordingResolution = static_cast<Dimension*>(__pRecordingResolutionList->GetAt(recordingResolutionIdx));
1264 TryCatch(pRecordingResolution != null, , "pRecordingResolution is null");
1266 AppLogDebug("pRecordingResolution w:%d,h:%d", pRecordingResolution->width, pRecordingResolution->height);
1268 r = __pVideoRecorder->SetRecordingResolution(*pRecordingResolution);
1269 TryCatch(r == E_SUCCESS, , "VideoRecorder::SetRecordingResolution() fail[%s]", GetErrorMessage(r));
1273 RecordingResolutionDim = __pVideoRecorder->GetRecordingResolution();
1275 AppLogDebug("pPreviewResolution w:%d,h:%d", RecordingResolutionDim.width, RecordingResolutionDim.height);
1277 if (__pVideoRecorder->GetState() != RECORDER_STATE_STOPPING)
1279 __pVideoRecorder->SetRecordingResolution(RecordingResolutionDim);
1280 TryCatch(r == E_SUCCESS, , "VideoRecorder::SetRecordingResolution() fail[%s]", GetErrorMessage(r));
1284 AppLogDebug("EXIT");
1288 AppLogDebug("EXIT - CATCH");
1289 if (__pRecordingResolutionList)
1291 __pRecordingResolutionList->RemoveAll(true);
1294 delete __pRecordingResolutionList;
1295 __pRecordingResolutionList = null;
1300 CameraPresentationModel::InitializeCamcorder(void)
1302 AppLogDebug("ENTER");
1303 int selfPortraitEnable = 0;
1304 result r = E_SUCCESS;
1306 r = GetValue(SELF_PORTRAIT_ENABLE, selfPortraitEnable);
1307 TryCatch(r == E_SUCCESS, , "GetValue() fail[%s]", GetErrorMessage(r));
1309 if (__pCamera == null)
1311 __pCamera = new (std::nothrow) Camera();
1312 TryCatch(__pCamera != null, , "[FAILURE] new (std::nothrow) Camera()");
1314 if (selfPortraitEnable == CAM_SELF_PORTRAIT_MODE_PRIMARY)
1316 AppLogDebug("CAMERA_PRIMARY_MODE !!!");
1317 r = __pCamera->Construct(*this, CAMERA_PRIMARY);
1321 AppLogDebug("CAMERA_SECONDARY_MODE !!!");
1322 r = __pCamera->Construct(*this, CAMERA_SECONDARY);
1324 TryCatch(r == E_SUCCESS, , "__pCamera->Construct() [%s]", GetErrorMessage(r));
1327 if( __pCamera->IsPoweredOn() == false)
1329 r = __pCamera->PowerOn();
1330 TryCatch(r == E_SUCCESS, , "Camera::PowerOn fail[%s]", GetErrorMessage(r));
1334 AppLogDebug("Camera was already powered on");
1337 if (__pVideoRecorder == null)
1339 __pVideoRecorder = new (std::nothrow) VideoRecorder();
1340 __pVideoRecorder->Construct(*this, *__pCamera);
1343 r = SetCameraPreviewResolution();
1344 TryCatch(r == E_SUCCESS, , "SetCameraPreviewResolution fail[%s]", GetErrorMessage(r));
1346 r = SetCamcorderRecordingResolution();
1347 TryCatch(r == E_SUCCESS, , "SetCamcorderRecordingResolution fail[%s]", GetErrorMessage(r));
1349 AppLogDebug("EXIT");
1353 AppLogDebug("EXIT - CATCH");
1354 if (__pPreviewResolutionList)
1356 __pPreviewResolutionList->RemoveAll(true);
1357 delete __pPreviewResolutionList;
1358 __pPreviewResolutionList = null;
1361 __isInitCamera = false;
1362 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_INITIALIZE_FAILED);
1368 CameraPresentationModel::ToggleCameraCamcorder(int mode)
1370 AppLogDebug("ENTER");
1371 Dimension PreviewResolutionDim;
1372 result r = E_SUCCESS;
1374 if (mode == CAMERA_MODE_SNAPSHOT)
1376 r = __pCamera->PowerOn();
1377 TryCatch(r == E_SUCCESS, , "Camera::PowerOn fail[%s]", GetErrorMessage(r));
1379 else if (mode == CAMERA_MODE_RECORD)
1381 r = __pCamera->PowerOn();
1382 TryCatch(r == E_SUCCESS, , "Camera::PowerOn fail[%s]", GetErrorMessage(r));
1384 r = SetCameraPreviewResolution();
1385 TryCatch(r == E_SUCCESS, , "ToggleCameraCamcorder::SetCameraPreviewResolution fail[%s]", GetErrorMessage(r));
1387 r = SetCamcorderRecordingResolution();
1388 TryCatch(r == E_SUCCESS, , "ToggleCameraCamcorder::SetCamcorderRecordingResolution fail[%s]", GetErrorMessage(r));
1391 AppLogDebug("EXIT");
1395 AppLogDebug("EXIT - CATCH");
1400 CameraPresentationModel::ToggleCameraDirection(int mode, int direction)
1402 AppLogDebug("ENTER");
1403 result r = E_SUCCESS;
1404 int captureResolutionCount = 0;
1405 Dimension* pCaptureResolution = null;
1409 __pCamera = new (std::nothrow) Camera();
1410 TryCatch(__pCamera != null, , "[FAILURE] new (std::nothrow) Camera()");
1412 if (direction == CAMERA_DIRECTION_BACK)
1414 AppLogDebug("BACK");
1416 r = __pCamera->Construct(*this, CAMERA_PRIMARY);
1417 TryCatch(r == E_SUCCESS, , "__pCamera->Construct() [%s]", GetErrorMessage(r));
1419 else if (direction == CAMERA_DIRECTION_FRONT)
1421 AppLogDebug("FRONT");
1423 r = __pCamera->Construct(*this, CAMERA_SECONDARY);
1424 TryCatch(r == E_SUCCESS, , "__pCamera->Construct() [%s]", GetErrorMessage(r));
1427 r = __pCamera->PowerOn();
1428 TryCatch(r == E_SUCCESS, , "__pCamera->PowerOn() [%s]", GetErrorMessage(r));
1430 if (mode == CAMERA_MODE_RECORD)
1432 if (__pVideoRecorder == null)
1434 __pVideoRecorder = new (std::nothrow) VideoRecorder();
1435 __pVideoRecorder->Construct(*this, *__pCamera);
1439 if (mode == CAMERA_MODE_SNAPSHOT && direction == CAMERA_DIRECTION_FRONT)
1441 __pCaptureResolutionList = __pCamera->GetSupportedCaptureResolutionListN();
1442 TryCatch(__pCaptureResolutionList != null, , "pCaptureResolutionList is null");
1444 captureResolutionCount = __pCaptureResolutionList->GetCount();
1446 pCaptureResolution = static_cast< Dimension*>(__pCaptureResolutionList->GetAt(captureResolutionCount - 1));
1447 TryCatch(pCaptureResolution != null, , " pCaptureResolution->GetAt()");
1449 r = __pCamera->SetCaptureResolution(*pCaptureResolution);
1450 TryCatch(r == E_SUCCESS, , "Camera::SetCaptureResolution fail[%s]", GetErrorMessage(r));
1453 if (direction == CAMERA_DIRECTION_FRONT)
1455 SetFlip(CAMERA_FLIP_HORIZONTAL);
1458 AppLogDebug("EXIT");
1462 AppLogDebug("EXIT - CATCH");
1463 if (__pCaptureResolutionList)
1465 __pCaptureResolutionList->RemoveAll(true);
1468 delete __pCaptureResolutionList;
1469 __pCaptureResolutionList = null;
1471 __isInitCamera = false;
1472 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_INITIALIZE_FAILED);
1478 CameraPresentationModel::GetInitCameraStatus(void) const
1480 AppLogDebug("ENTER");
1481 AppLogDebug("EXIT - __isInitCamera = %d", __isInitCamera);
1482 return __isInitCamera;
1486 CameraPresentationModel::SetMode(int mode)
1488 AppLogDebug("ENTER");
1489 result r = E_SUCCESS;
1490 String contentSubDirectory = STRING_CAMERA_FOLDER_NAME;
1491 Directory contentDirectory;
1492 int cameraSelfPortraitEnable = CAM_SELF_PORTRAIT_MODE_PRIMARY;
1493 int camcorderSelfPortraitEnable = CAM_SELF_PORTRAIT_MODE_PRIMARY;
1494 int direction = CAMERA_DIRECTION_BACK;
1495 int selfPortraitEnable = 0;
1497 AppLogDebug("SetMode __SetMode = %d && mode = %d", __cameraMode, mode);
1499 if (__pCamera != null)
1501 if (__pCamera->IsPoweredOn() == true)
1503 AppLogDebug("StopCamera or Terminate");
1505 __pCameraSettingsPresentationModel->GetValue(SECTION_CAMERA, SELF_PORTRAIT_ENABLE, cameraSelfPortraitEnable);
1507 __pCameraSettingsPresentationModel->GetValue(SECTION_CAMCORDER, SELF_PORTRAIT_ENABLE, camcorderSelfPortraitEnable);
1509 AppLogDebug("SECTION_CAMERA mode = %d && SECTION_CAMCORDER mode = %d", cameraSelfPortraitEnable, camcorderSelfPortraitEnable);
1511 GetMediaCapability(CAMERA_SECONDARY_DIRECTION, direction);
1513 if ((cameraSelfPortraitEnable == CAM_SELF_PORTRAIT_MODE_SECONDARY && camcorderSelfPortraitEnable == CAM_SELF_PORTRAIT_MODE_PRIMARY)
1514 || (cameraSelfPortraitEnable == CAM_SELF_PORTRAIT_MODE_PRIMARY && camcorderSelfPortraitEnable == CAM_SELF_PORTRAIT_MODE_SECONDARY)
1517 if (__cameraMode == mode && direction == CAMERA_DIRECTION_FRONT)
1519 AppLogDebug("StopCamera");
1524 AppLogDebug("Terminate");
1530 AppLogDebug("StopCamera");
1536 if (mode == CAMERA_MODE_SNAPSHOT)
1538 if (__pCamera == null)
1540 AppLogDebug("CAMERA_MODE_SNAPSHOT::NOT_INITIALIZED");
1543 if (__pContentManager == null)
1545 __pContentManager = new (std::nothrow) ContentManager();
1547 r = __pContentManager->Construct();
1548 TryCatch(r == E_SUCCESS, , "__pContentManager->Construct [%s]", GetErrorMessage(r));
1550 if (__pImageContentInfo == null)
1552 __pImageContentInfo = new (std::nothrow) ImageContentInfo();
1553 r = __pImageContentInfo->Construct(null);
1554 TryCatch(r == E_SUCCESS, , "__pImageContentInfo->Construct [%s]", GetErrorMessage(r));
1558 r = CreateThumbnail(CAMERA_MODE_SNAPSHOT);
1559 AppLogDebug("CreateThumbnail [%s]", GetErrorMessage(r));
1561 r = InitializeCamera();
1562 TryCatch(r == E_SUCCESS, , "InitializeCamera [%s]", GetErrorMessage(r));
1564 r = InitializeFlashMode();
1565 AppLogDebug("InitFlashMode fail [%s]", GetErrorMessage(r));
1567 r = GetValue(SELF_PORTRAIT_ENABLE, selfPortraitEnable);
1570 selfPortraitEnable = CAM_SELF_PORTRAIT_MODE_PRIMARY;
1573 if (selfPortraitEnable == CAM_SELF_PORTRAIT_MODE_SECONDARY)
1575 SetFlip(CAMERA_FLIP_HORIZONTAL);
1578 else if (__pCamera != null)
1580 AppLogDebug("CAMERA_MODE_SNAPSHOT::INITIALIZED");
1582 r = CreateThumbnail(CAMERA_MODE_SNAPSHOT);
1583 AppLogDebug("CreateThumbnail [%s]", GetErrorMessage(r));
1585 r = ToggleCameraCamcorder(CAMERA_MODE_SNAPSHOT);
1586 TryCatch(r == E_SUCCESS, , "ToggleCameraCamcorder [%s]", GetErrorMessage(r));
1589 else if (mode == CAMERA_MODE_RECORD)
1591 if (__pCamera == null)
1593 AppLogDebug("CAMERA_MODE_RECORD::NOT_INITIALIZED");
1594 #if 0 //varialbe not in use
1595 if (__pContentManager == null)
1597 __pContentManager = new (std::nothrow) ContentManager();
1599 r = __pContentManager->Construct();
1600 TryCatch(r == E_SUCCESS, , "__pContentManager->Construct [%s]", GetErrorMessage(r));
1602 if (__pVideoContentInfo == null)
1604 __pVideoContentInfo = new (std::nothrow) VideoContentInfo();
1606 r = __pVideoContentInfo->Construct(null);
1607 TryCatch(r == E_SUCCESS, , "__pVideoContentInfo->Construct [%s]", GetErrorMessage(r));
1611 r = CreateThumbnail(CAMERA_MODE_RECORD);
1612 AppLogDebug("CreateThumbnail [%s]", GetErrorMessage(r));
1614 r = InitializeCamcorder();
1615 TryCatch(r == E_SUCCESS, , "InitializeCamcorder [%s]", GetErrorMessage(r));
1617 r = InitializeFlashMode();
1618 AppLogDebug("InitFlashMode fail [%s]", GetErrorMessage(r));
1620 r = GetValue(SELF_PORTRAIT_ENABLE, selfPortraitEnable);
1623 selfPortraitEnable = CAM_SELF_PORTRAIT_MODE_PRIMARY;
1626 if (selfPortraitEnable == CAM_SELF_PORTRAIT_MODE_SECONDARY)
1628 SetFlip(CAMERA_FLIP_HORIZONTAL);
1631 else if (__pCamera != null)
1633 AppLogDebug("CAMERA_MODE_RECORD::INITIALIZED");
1635 if (__pVideoRecorder == null)
1637 __pVideoRecorder = new (std::nothrow) VideoRecorder();
1638 __pVideoRecorder->Construct(*this, *__pCamera);
1641 r = CreateThumbnail(CAMERA_MODE_RECORD);
1642 AppLogDebug("CreateThumbnail [%s]", GetErrorMessage(r));
1644 r = ToggleCameraCamcorder(CAMERA_MODE_RECORD);
1645 TryCatch(r == E_SUCCESS, , "ToggleCameraCamcorder [%s]", GetErrorMessage(r));
1646 InitializeFlashMode();
1649 __cameraMode = mode;
1651 __isInitCamera = true;
1653 AppLogDebug("EXIT");
1657 AppLogDebug("EXIT - CATCH");
1658 __isInitCamera = false;
1662 Tizen::Graphics::Bitmap*
1663 CameraPresentationModel::GetLatestThumbnail(void)
1665 AppLogDebug("ENTER");
1668 AppLogDebug("__pBitmap NOT null");
1669 AppLogDebug("EXIT");
1674 AppLogDebug("__pBitmap null");
1675 AppLogDebug("EXIT");
1681 CameraPresentationModel::GetContentCount(void)
1683 AppLogDebug("ENTER");
1684 AppLogDebug("EXIT");
1685 return __contentCount;
1688 Tizen::Base::Collection::ArrayList*
1689 CameraPresentationModel::GetContentPathListN(int mode)
1691 AppLogDebug("ENTER");
1692 result r = E_SUCCESS;
1693 ContentDirectory contentDirectory;
1694 IList* pContentList = null;
1695 String contentFullPath = L"";
1696 String filePath = L"";
1697 String combineText = L"";
1698 int storageType = 0;
1699 int countPerPage = 0;
1700 ArrayList* pContentPath = null;
1702 r = GetValue(STORAGE_TYPE, storageType);
1705 storageType = STORAGE_TYPE_PHONE;
1708 if (storageType == STORAGE_TYPE_MEMORYCARD)
1710 filePath = STRING_CONTENT_CAMERA_PATH_EXT;
1712 else if (storageType == STORAGE_TYPE_PHONE)
1714 filePath = STRING_CONTENT_CAMERA_PATH;
1716 AppLogDebug("SearchContentFilePath :: pFilePath = %ls", filePath.GetPointer());
1718 if (mode == CAMERA_MODE_SNAPSHOT)
1720 r = contentDirectory.Construct(CONTENT_TYPE_IMAGE);
1724 r = contentDirectory.Construct(CONTENT_TYPE_VIDEO);
1726 TryCatch(r == E_SUCCESS, , "contentDirectory.Construct[%s]", GetErrorMessage(r));
1728 countPerPage = contentDirectory.GetContentDirectoryItemCount(filePath);
1729 AppLogDebug("SearchContentFilePath :: countPerPage = %d", countPerPage);
1731 pContentList = contentDirectory.GetContentDirectoryItemListN(filePath,
1735 SORT_ORDER_ASCENDING);
1736 TryCatch(pContentList != null, , "pContentList is null");
1738 __contentCount = pContentList->GetCount();
1739 AppLogDebug("SearchContentFilePath :: __contentCount = %d", __contentCount);
1741 pContentPath = new (std::nothrow) ArrayList();
1742 pContentPath->Construct();
1744 if ((pContentList != null) && (pContentList->GetCount() > 0))
1746 IEnumerator* pEnum = pContentList->GetEnumeratorN();
1747 while (pEnum->MoveNext() == E_SUCCESS)
1749 ContentInfo* pContentInfo = static_cast<ContentInfo*>(pEnum->GetCurrent());
1750 contentFullPath = pContentInfo->GetContentPath();
1752 AppLogDebug("SearchContentFilePath :: contentFullPath = %ls", contentFullPath.GetPointer());
1754 pContentPath->Add(*(new (std::nothrow) String(contentFullPath)));
1761 if (pContentList != null)
1763 pContentList->RemoveAll(true);
1764 delete pContentList;
1767 AppLogDebug("EXIT");
1768 return pContentPath;
1771 AppLogDebug("EXIT - CATCH");
1772 return pContentPath;
1776 CameraPresentationModel::SearchContentFilePath(int mode)
1778 AppLogDebug("ENTER");
1779 result r = E_SUCCESS;
1780 ContentDirectory contentDirectory;
1781 IList* pContentList = null;
1782 String contentFullPath = L"";
1783 String filePath = L"";
1784 String combineText = L"";
1785 int storageType = 0;
1786 int countPerPage = 0;
1788 r = GetValue(STORAGE_TYPE, storageType);
1791 storageType = STORAGE_TYPE_PHONE;
1794 if (storageType == STORAGE_TYPE_MEMORYCARD)
1796 filePath = STRING_CONTENT_CAMERA_PATH_EXT;
1798 else if (storageType == STORAGE_TYPE_PHONE)
1800 filePath = STRING_CONTENT_CAMERA_PATH;
1802 AppLogDebug("SearchContentFilePath :: pFilePath = %ls", filePath.GetPointer());
1804 if (mode == CAMERA_MODE_SNAPSHOT)
1806 r = contentDirectory.Construct(CONTENT_TYPE_IMAGE);
1810 r = contentDirectory.Construct(CONTENT_TYPE_VIDEO);
1812 TryCatch(r == E_SUCCESS, , "contentDirectory.Construct[%s]", GetErrorMessage(r));
1814 countPerPage = contentDirectory.GetContentDirectoryItemCount(filePath);
1815 AppLogDebug("SearchContentFilePath :: countPerPage = %d", countPerPage);
1817 pContentList = contentDirectory.GetContentDirectoryItemListN(filePath,
1821 SORT_ORDER_ASCENDING);
1822 TryCatch(pContentList != null, , "pContentList is null");
1824 __contentCount = pContentList->GetCount();
1825 AppLogDebug("SearchContentFilePath :: __contentCount = %d", __contentCount);
1827 if ((pContentList != null) && (pContentList->GetCount() > 0))
1829 IEnumerator* pEnum = pContentList->GetEnumeratorN();
1830 while (pEnum->MoveNext() == E_SUCCESS)
1832 ContentInfo* pContentInfo = static_cast<ContentInfo*>(pEnum->GetCurrent());
1833 contentFullPath = pContentInfo->GetContentPath();
1835 if (combineText.CompareTo(EMPTY_SPACE) != 0)
1837 combineText.Append(L";");
1840 combineText.Append(contentFullPath);
1847 AppLogDebug("SearchContentFilePath :: combineText = %ls", combineText.GetPointer());
1849 if (pContentList != null)
1851 pContentList->RemoveAll(true);
1852 delete pContentList;
1855 AppLogDebug("EXIT");
1859 AppLogDebug("EXIT - CATCH");
1864 CameraPresentationModel::GetContentFilePath(int currentCameraMode)
1866 AppLogDebug("ENTER");
1867 String contentFullName = L"";
1869 contentFullName = SearchContentFilePath(currentCameraMode);
1871 AppLogDebug("EXIT");
1872 return contentFullName;
1876 CameraPresentationModel::GetLatestContentName(int currentCameraMode, Tizen::Base::String& latestContentName)
1878 AppLogDebug("ENTER");
1879 String contentSubDirectory = STRING_CAMERA_FOLDER_NAME;
1880 String fileExtension = L"";
1881 String directoryEntryName = L"";
1882 String temporaryEntryName = L"";
1883 Directory contentDirectory;
1884 result r = E_SUCCESS;
1885 DirEnumerator* pDirEnum = null;
1886 DateTime directoryEntryDateTime;
1887 DateTime temporaryEntryDateTime = DateTime::GetMinValue();
1888 int storageType = STORAGE_TYPE_PHONE;
1890 AppLogDebug("__lastestContentName content name is %ls",__latestContentName.GetPointer());
1892 r = GetValue(STORAGE_TYPE, storageType);
1893 TryCatch(r == E_SUCCESS, , "Err catch [%s]", GetErrorMessage(r));
1895 if (storageType == STORAGE_TYPE_PHONE)
1897 r = contentDirectory.Construct(Environment::GetMediaPath().GetPointer() + contentSubDirectory);
1899 AppLogDebug("GetLatestContentName::contentDirectory.Construct r = %s", GetErrorMessage(r));
1900 if (r == E_FILE_NOT_FOUND)
1902 r = contentDirectory.Create((Environment::GetMediaPath().GetPointer() + contentSubDirectory), true);
1903 TryCatch(r == E_SUCCESS, , "contentDirectory Create Fail");
1905 contentDirectory.Construct(Environment::GetMediaPath().GetPointer() + contentSubDirectory);
1908 else if (storageType == STORAGE_TYPE_MEMORYCARD)
1910 r = contentDirectory.Construct(Environment::GetExternalStoragePath().GetPointer() + contentSubDirectory);
1912 if (r == E_FILE_NOT_FOUND)
1914 r = contentDirectory.Create((Environment::GetExternalStoragePath().GetPointer() + contentSubDirectory), true);
1915 TryCatch(r == E_SUCCESS, , "contentDirectory Create Fail");
1917 contentDirectory.Construct(Environment::GetExternalStoragePath().GetPointer() + contentSubDirectory);
1921 pDirEnum = contentDirectory.ReadN();
1922 AppLogDebug("contentDirectory.ReadN()r = %s", GetErrorMessage(GetLastResult()));
1923 TryCatch(pDirEnum != null, r = E_SYSTEM, "pDirEnum is null");
1925 if (currentCameraMode == CAMERA_MODE_SNAPSHOT)
1927 r = fileExtension.Append(STRING_EXTENSION_JPG);
1928 TryCatch(r == E_SUCCESS, , "String::Append() fail[%s]", GetErrorMessage(r));
1932 r = fileExtension.Append(STRING_EXTENSION_MP4);
1933 TryCatch(r == E_SUCCESS, , "String::Append() fail[%s]", GetErrorMessage(r));
1936 while (pDirEnum->MoveNext() == E_SUCCESS)
1938 DirEntry directoryEntry = pDirEnum->GetCurrentDirEntry();
1939 directoryEntryName = directoryEntry.GetName();
1940 if (directoryEntryName.Contains(fileExtension))
1942 directoryEntryDateTime = directoryEntry.GetDateTime();
1943 AppLogDebug("DirEntry::GetDateTime() name %ls Time %ls", directoryEntryName.GetPointer(), directoryEntryDateTime.ToString().GetPointer());
1945 if (directoryEntryDateTime > temporaryEntryDateTime)
1947 temporaryEntryDateTime = directoryEntryDateTime;
1948 temporaryEntryName = directoryEntryName;
1949 AppLogDebug("dt_temp change Str %ls Time %ls", temporaryEntryName.GetPointer(), temporaryEntryDateTime.ToString().GetPointer());
1954 AppLogDebug("Dont Contains(fileExtension)");
1958 if (!(temporaryEntryName.IsEmpty()))
1960 latestContentName.Clear();
1961 r = latestContentName.Append(temporaryEntryName);
1962 TryCatch(r == E_SUCCESS, , "String::Append() fail[%s]", GetErrorMessage(r));
1964 AppLogDebug("latestContentName = %ls", latestContentName.GetPointer());
1970 AppLogDebug("EXIT");
1974 AppLogDebug("EXIT - CATCH");
1981 Tizen::Graphics::Dimension
1982 CameraPresentationModel::GetPreviewResolution(void) const
1984 AppLogDebug("ENTER");
1985 Dimension dimension(INIT, INIT);
1987 if (__pCamera != null)
1989 dimension = __pCamera->GetPreviewResolution();
1992 AppLogDebug("CameraPresentationModel::GetPreviewResolution(%d, %d)", dimension.width, dimension.height);
1994 AppLogDebug("EXIT");
1999 CameraPresentationModel::SetPreviewResolution(Tizen::Graphics::Dimension previewResolution)
2001 AppLogDebug("ENTER");
2002 result r = E_SUCCESS;
2004 r = __pCamera->SetPreviewResolution(previewResolution);
2005 TryCatch(r == E_SUCCESS, , "Camera::SetPreviewResolution fail[%s]", GetErrorMessage(r));
2007 AppLogDebug("EXIT");
2011 AppLogDebug("EXIT - CATCH");
2015 Tizen::Graphics::Dimension
2016 CameraPresentationModel::GetCaptureResolution(void) const
2018 AppLogDebug("ENTER");
2019 Dimension dimension(INIT, INIT);
2021 if (__pCamera != null)
2023 dimension = __pCamera->GetCaptureResolution();
2026 AppLogDebug("CameraPresentationModel::GetCaptureResolution(%d, %d)", dimension.width, dimension.height);
2028 AppLogDebug("EXIT");
2033 CameraPresentationModel::SetCaptureResolution(Tizen::Graphics::Dimension captureResolution)
2035 AppLogDebug("ENTER");
2036 result r = E_SUCCESS;
2038 if (__pCamera != null)
2040 r = __pCamera->SetCaptureResolution(captureResolution);
2041 TryCatch(r == E_SUCCESS, , "Camera::SetCaptureResolution fail[%s]", GetErrorMessage(r));
2043 AppLogDebug("EXIT");
2047 AppLogDebug("EXIT - CATCH");
2051 Tizen::Graphics::Dimension
2052 CameraPresentationModel::GetRecordingResolution(void) const
2054 AppLogDebug("ENTER");
2055 Dimension dimension(INIT, INIT);
2057 if (__pVideoRecorder != null)
2059 dimension = __pVideoRecorder->GetRecordingResolution();
2061 AppLogDebug("CameraPresentationModel::GetRecordingResolution(%d, %d)", dimension.width, dimension.height);
2063 AppLogDebug("EXIT");
2068 CameraPresentationModel::SetRecordingResolution(Tizen::Graphics::Dimension previewResolution)
2070 AppLogDebug("ENTER");
2071 result r = E_SUCCESS;
2073 r = __pVideoRecorder->SetRecordingResolution(previewResolution);
2074 TryCatch(r == E_SUCCESS, , "Camera::SetRecordingResolution fail[%s]", GetErrorMessage(r));
2076 AppLogDebug("EXIT");
2080 AppLogDebug("EXIT - CATCH");
2084 Tizen::Base::Collection::IList*
2085 CameraPresentationModel::GetCaptureResolutionList(void)
2087 AppLogDebug("ENTER");
2088 result r = E_SUCCESS;
2089 int selfPortraitEnable = 0;
2091 r = GetValue(SELF_PORTRAIT_ENABLE, selfPortraitEnable);
2093 if (selfPortraitEnable == CAM_SELF_PORTRAIT_MODE_PRIMARY)
2095 AppLogDebug("CAM_SELF_PORTRAIT_MODE_PRIMARY");
2096 __pCaptureResolutionList = MediaCapability::GetValueN(CAMERA_PRIMARY_CAPTURE_RESOLUTION);
2097 TryCatch(__pCaptureResolutionList != null, , "MediaCapability::GetValueN() fail[%s]", GetErrorMessage(GetLastResult()));
2101 AppLogDebug("CAM_SELF_PORTRAIT_MODE_SECONDARY");
2102 __pCaptureResolutionList = MediaCapability::GetValueN(CAMERA_SECONDARY_CAPTURE_RESOLUTION);
2103 TryCatch(__pCaptureResolutionList != null, , "MediaCapability::GetValueN() fail[%s]", GetErrorMessage(GetLastResult()));
2106 AppLogDebug("EXIT");
2107 return __pCaptureResolutionList;
2110 AppLogDebug("EXIT - CATCH");
2111 if (__pCaptureResolutionList)
2113 __pCaptureResolutionList->RemoveAll(true);
2116 delete __pCaptureResolutionList;
2118 __pCaptureResolutionList = null;
2120 return __pCaptureResolutionList;
2123 Tizen::Base::Collection::IList*
2124 CameraPresentationModel::GetPreviewResolutionList(void)
2126 AppLogDebug("ENTER");
2127 result r = E_SUCCESS;
2128 int selfPortraitEnable = 0;
2130 r = GetValue(SELF_PORTRAIT_ENABLE, selfPortraitEnable);
2132 if (selfPortraitEnable == CAM_SELF_PORTRAIT_MODE_PRIMARY)
2134 if (__pPreviewResolutionList != null)
2136 __pPreviewResolutionList->RemoveAll(true);
2137 delete __pPreviewResolutionList;
2138 __pPreviewResolutionList = null;
2140 __pPreviewResolutionList = MediaCapability::GetValueN(CAMERA_PRIMARY_PREVIEW_RESOLUTION);
2141 TryCatch(__pPreviewResolutionList != null, , "MediaCapability::GetValueN() fail[%s]", GetErrorMessage(GetLastResult()));
2145 __pPreviewResolutionList = MediaCapability::GetValueN(CAMERA_SECONDARY_PREVIEW_RESOLUTION);
2146 TryCatch(__pPreviewResolutionList != null, , "MediaCapability::GetValueN() fail[%s]", GetErrorMessage(GetLastResult()));
2149 AppLogDebug("EXIT");
2150 return __pPreviewResolutionList;
2153 AppLogDebug("EXIT - CATCH");
2154 if (__pPreviewResolutionList)
2156 __pPreviewResolutionList->RemoveAll(true);
2159 delete __pPreviewResolutionList;
2161 __pPreviewResolutionList = null;
2163 return __pPreviewResolutionList;
2166 Tizen::Base::Collection::IList*
2167 CameraPresentationModel::GetRecordingResolutionList(void)
2169 AppLogDebug("ENTER");
2170 result r = E_SUCCESS;
2171 int selfPortraitEnable = 0;
2173 r = GetValue(SELF_PORTRAIT_ENABLE, selfPortraitEnable);
2175 if (selfPortraitEnable == CAM_SELF_PORTRAIT_MODE_PRIMARY)
2177 __pRecordingResolutionList = MediaCapability::GetValueN(CAMERA_PRIMARY_RECORDING_RESOLUTION);
2178 TryCatch(__pRecordingResolutionList != null, , "MediaCapability::GetValueN() fail[%s]", GetErrorMessage(GetLastResult()));
2182 __pRecordingResolutionList = MediaCapability::GetValueN(CAMERA_PRIMARY_RECORDING_RESOLUTION);
2183 TryCatch(__pRecordingResolutionList != null, , "MediaCapability::GetValueN() fail[%s]", GetErrorMessage(GetLastResult()));
2186 AppLogDebug("EXIT");
2187 return __pRecordingResolutionList;
2190 AppLogDebug("EXIT - CATCH");
2191 if (__pRecordingResolutionList)
2193 __pRecordingResolutionList->RemoveAll(true);
2196 delete __pRecordingResolutionList;
2198 __pRecordingResolutionList = null;
2200 return __pRecordingResolutionList;
2204 CameraPresentationModel::IsPreviewState(void)
2206 AppLogDebug("ENTER");
2207 if (GetCameraState() == CAMERA_STATE_PREVIEW)
2209 AppLogDebug("IsPreviewState YES");
2210 AppLogDebug("EXIT");
2215 AppLogDebug("IsPreviewState NOT");
2216 AppLogDebug("EXIT");
2220 AppLogDebug("EXIT");
2225 CameraPresentationModel::IsCameraInstance(void)
2227 AppLogDebug("ENTER");
2228 if (__pCamera == null)
2230 AppLogDebug("EXIT - __pCamera is null");
2234 AppLogDebug("EXIT");
2239 CameraPresentationModel::IsCameraPoweredOn(void)
2241 AppLogDebug("ENTER");
2242 AppLogDebug("IsPoweredOn State[%d]", __pCamera->IsPoweredOn());
2243 AppLogDebug("EXIT");
2244 return __pCamera->IsPoweredOn();
2248 CameraPresentationModel::IsStorageCardMounted(void) const
2250 AppLogDebug("ENTER");
2251 String strState = L"";
2253 DeviceManager::GetState(StorageCard, strState);
2255 if (strState == STRING_SDCARD_MOUNTED_STATE)
2257 AppLogDebug("EXIT");
2262 AppLogDebug("EXIT");
2268 CameraPresentationModel::IsCharging(void)
2270 AppLogDebug("ENTER");
2271 bool isCharging = false;
2272 isCharging = PowerManager::IsCharging();
2273 AppLogDebug("charging status is %d",isCharging);
2274 AppLogDebug("EXIT");
2279 CameraPresentationModel::GetStartPreviewException(void)
2281 AppLogDebug("ENTER");
2282 AppLogDebug("EXIT - Error %d", __startPreviewException);
2283 return __startPreviewException;
2287 CameraPresentationModel::GetIntervalTimerRun(void) const
2289 AppLogDebug("ENTER");
2290 AppLogDebug("EXIT - __isIntervalTimerRun = %d", __isIntervalTimerRun);
2291 return __isIntervalTimerRun;
2295 CameraPresentationModel::SetIntervalTimerRun(bool intervalTimerRun)
2297 AppLogDebug("ENTER");
2298 __isIntervalTimerRun = intervalTimerRun;
2299 AppLogDebug("EXIT");
2303 CameraPresentationModel::GetPreviewState(void) const
2305 AppLogDebug("ENTER");
2306 AppLogDebug("EXIT - __isPreviewExit = %d", __isPreviewExit);
2307 return __isPreviewExit;
2311 CameraPresentationModel::StartPreview(const Tizen::Graphics::BufferInfo* pBufferInfo)
2313 AppLogDebug("ENTER");
2314 result r = E_SUCCESS;
2316 AppLogDebug("GetCameraState = %d", __pCamera->GetState());
2317 if (GetCameraState() == CAMERA_STATE_INITIALIZED || GetCameraState() == CAMERA_STATE_CAPTURED)
2319 r = __pCamera->StartPreview(pBufferInfo, false);
2320 if (r == E_DEVICE_BUSY || r == E_DEVICE_UNAVAILABLE || r == E_SYSTEM)
2322 __startPreviewException = true;
2326 __startPreviewException = false;
2328 __isPreviewExit = true;
2329 TryReturnVoid(r == E_SUCCESS, "Camera::StartPreview() fail[%s]", GetErrorMessage(r));
2333 AppLogDebug("Before the StartPreview() method is called, camera state should be CAMERA_STATE_INITIALIZED or CAMERA_STATE_CAPTURED");
2336 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_BACK_BUTTON_ACTIVATED);
2337 AppLogDebug("EXIT");
2341 CameraPresentationModel::StopPreview(void)
2343 AppLogDebug("ENTER");
2344 result r = E_SUCCESS;
2346 if (__pCamera != null)
2348 if (__pCamera->GetState() == CAMERA_STATE_PREVIEW)
2350 r = __pCamera->StopPreview();
2351 TryReturnVoid(r == E_SUCCESS, "Camera::StopPreview() [%s]", GetErrorMessage(r));
2354 AppLogDebug("EXIT");
2358 CameraPresentationModel::StopCamera(void)
2360 AppLogDebug("ENTER");
2361 result r = E_SUCCESS;
2363 if (__isInitCamera == false)
2365 AppLogDebug("Camera Construct fail or Memory allocation Fail");
2369 if (__pVideoRecorder != null)
2371 AppLogDebug("VideoRecorder State[%d]", __pVideoRecorder->GetState());
2373 if (__pVideoRecorder->GetState()== RECORDER_STATE_RECORDING
2374 || __pVideoRecorder->GetState() == RECORDER_STATE_PAUSED
2377 r = __pVideoRecorder->Stop();
2378 TryReturnVoid(r == E_SUCCESS, "__pVideoRecorder::Stop() [%s]", GetErrorMessage(r));
2382 if (__pCamera != null)
2384 AppLogDebug("Camera State[%d]", __pCamera->GetState());
2386 if (__pCamera->GetState() == CAMERA_STATE_PREVIEW)
2388 r = __pCamera->StopPreview();
2389 TryReturnVoid(r == E_SUCCESS, "Camera::StopPreview() [%s]", GetErrorMessage(r));
2392 if (__pCamera->IsPoweredOn() == true)
2394 r = __pCamera->PowerOff();
2395 TryReturnVoid(r == E_SUCCESS, "Camera::PowerOff() [%s]", GetErrorMessage(r));
2398 AppLogDebug("EXIT");
2402 CameraPresentationModel::Capture(void)
2404 AppLogDebug("ENTER");
2405 result r = E_SUCCESS;
2407 if (GetCameraState() == CAMERA_STATE_PREVIEW)
2409 r = __pCamera->Capture();
2410 TryReturnVoid( r == E_SUCCESS, "Camera::Capture() fail[%s]", GetErrorMessage(r));
2414 AppLogDebug("Before the Capture() method is called, camera state should be CAMERA_STATE_PREVIEW");
2416 AppLogDebug("EXIT");
2420 CameraPresentationModel::GetMaxRecordingTime(void)
2422 AppLogDebug("ENTER");
2423 long getMaxRecordingTime = 0;
2425 getMaxRecordingTime = __pVideoRecorder->GetMaxRecordingTime();
2427 AppLogDebug("GetMaxRecordingTime = %d EXIT", getMaxRecordingTime);
2428 return getMaxRecordingTime;
2432 CameraPresentationModel::GetRecordingSize(void)
2434 AppLogDebug("ENTER");
2435 long getRecordingSize = 0;
2437 getRecordingSize = __pVideoRecorder->GetRecordingSize();
2439 AppLogDebug("EXIT - GetRecordingSize = %d", getRecordingSize);
2440 return getRecordingSize;
2444 CameraPresentationModel::StartRecord(void)
2446 AppLogDebug("ENTER");
2447 String* pFullFileName = null;
2448 result r = E_SUCCESS;
2449 long maxRecordDefaultTime = 0;
2450 String camcorderTemporaryFilePath;
2451 RecordingRotation rotate = RECORDING_ROTATION_NONE;
2452 int storageType = STORAGE_TYPE_PHONE;
2454 __onVideoRecorderStarted = true;
2456 AppLogDebug("Record GetRecorderState = %d", GetRecorderState());
2457 if (GetRecorderState() == RECORDER_STATE_PAUSED || GetRecorderState() == RECORDER_STATE_PAUSING)
2459 AppLogDebug("RECORDER_STATE_PAUSED or RECORDER_STATE_PAUSING ==> RECORDER_STATE_RECORDING");
2461 r = __pVideoRecorder->Record();
2462 TryCatch(r == E_SUCCESS, , "VideoRecorder::Record() fail[%s]", GetErrorMessage(r));
2464 r = SetFlashModeOnRecord(true);
2465 AppLogDebug("SetFlashModeOnRecord fail[%s]", GetErrorMessage(r));
2467 AppLogDebug("EXIT");
2471 r = GetValue(STORAGE_TYPE, storageType);
2474 storageType = STORAGE_TYPE_PHONE;
2477 if (storageType == STORAGE_TYPE_PHONE)
2479 camcorderTemporaryFilePath.Format(MAX_DIRECTORY_PATH_LENGTH, L"%ls%ls", App::GetInstance()->GetAppRootPath().GetPointer(), STRING_CAMCORDER_TEMPORARY_FILE);
2483 camcorderTemporaryFilePath.Format(MAX_DIRECTORY_PATH_LENGTH, L"%ls%ls", Environment::GetExternalStoragePath().GetPointer(), STRING_CAMCORDER_TEMPORARY_FILE_EXT);
2486 pFullFileName = new (std::nothrow) String();
2487 r = CreateFileName(*pFullFileName);
2488 TryCatch(r == E_SUCCESS, , "pFullFileName is null");
2490 __latestContentName.Clear();
2491 r = __latestContentName.Append(pFullFileName->GetPointer());
2492 TryCatch(r == E_SUCCESS, , "String::Append() fail[%s]", GetErrorMessage(r));
2494 AppLogDebug("Record pFullFileName = %ls", pFullFileName->GetPointer());
2495 if (__pVideoRecorder == null)
2497 __pVideoRecorder = new (std::nothrow) VideoRecorder();
2498 __pVideoRecorder->Construct(*this, *__pCamera);
2501 r = __pVideoRecorder->SetQuality(RECORDING_QUALITY_HIGH);
2502 TryCatch(r == E_SUCCESS, , "VideoRecorder::SetQuality() fail[%s]", GetErrorMessage(r));
2504 maxRecordDefaultTime = RECORD_DEFAULT_SEC * SECONDS_PER_MINUTE;
2506 r = __pVideoRecorder->SetMaxRecordingTime(maxRecordDefaultTime);
2507 TryCatch(r == E_SUCCESS, , "VideoRecorder::SetMaxRecordingTime() fail[%s]", GetErrorMessage(r));
2509 r = __pVideoRecorder->SetFormat(CODEC_AAC, CODEC_MPEG4, MEDIA_CONTAINER_MP4);
2510 TryCatch(r == E_SUCCESS, , "VideoRecorder::SetFormat() fail[%s]", GetErrorMessage(r));
2512 rotate = GetRecordingRotation();
2513 AppLogDebug("StartRecord rotate = %d",rotate);
2515 r = __pVideoRecorder->SetRecordingRotation(rotate);
2516 TryCatch(r == E_SUCCESS, , "VideoRecorder::SetRecordingRotation() fail[%s]", GetErrorMessage(r));
2518 AppLogDebug("latest file name is %ls",__latestContentName.GetPointer());
2519 r = __pVideoRecorder->CreateVideoFile(__latestContentName, true);
2520 AppLogDebug("create video file result is %s",GetErrorMessage(r));
2521 TryCatch(r == E_SUCCESS, , "VideoRecorder::CreateVideoFile() fail[%s]", GetErrorMessage(r));
2523 r = __pVideoRecorder->Record();
2524 TryCatch(r == E_SUCCESS, , "VideoRecorder::Record() fail[%s]", GetErrorMessage(r));
2526 delete pFullFileName;
2527 pFullFileName = null;
2529 r = SetFlashModeOnRecord(true);
2530 AppLogDebug("SetFlashModeOnRecord fail[%s]", GetErrorMessage(r));
2532 AppLogDebug("EXIT");
2536 AppLogDebug("EXIT - CATCH");
2537 __onVideoRecorderStarted = false;
2538 delete pFullFileName;
2539 pFullFileName = null;
2543 CameraPresentationModel::SetCancelRecord(bool isCancel)
2545 AppLogDebug("ENTER");
2546 __isCancelRecord = isCancel;
2547 AppLogDebug("EXIT");
2551 CameraPresentationModel::StopRecord(void)
2553 AppLogDebug("ENTER");
2554 result r = E_SUCCESS;
2556 if (__pVideoRecorder != null)
2558 r = __pVideoRecorder->Stop();
2559 AppLogDebug("stop record result is %s",GetErrorMessage(r));
2560 //TryReturnVoid(r == E_SUCCESS, "VideoRecorder::Stop() fail[%s]", GetErrorMessage(r));
2562 AppLogDebug("EXIT");
2567 CameraPresentationModel::CloseRecord(void)
2569 AppLogDebug("ENTER");
2570 result r = E_SUCCESS;
2572 if (__pVideoRecorder != null)
2574 r = __pVideoRecorder->Close();
2575 TryReturnVoid(r == E_SUCCESS, "VideoRecorder::Close() fail[%s]", GetErrorMessage(r));
2577 AppLogDebug("EXIT");
2581 CameraPresentationModel::CancelRecord(void)
2583 AppLogDebug("ENTER");
2584 result r = E_SUCCESS;
2586 if (__pVideoRecorder != null)
2588 r = __pVideoRecorder->Cancel();
2589 TryReturnVoid(r == E_SUCCESS, "VideoRecorder::Cancel() fail[%s]", GetErrorMessage(r));
2591 AppLogDebug("EXIT");
2595 CameraPresentationModel::PauseRecord(void)
2597 AppLogDebug("ENTER");
2598 result r = E_SUCCESS;
2600 if (__pVideoRecorder != null)
2602 r = __pVideoRecorder->Pause();
2603 TryReturnVoid(r == E_SUCCESS, "VideoRecorder::Pause() fail[%s]", GetErrorMessage(r));
2605 AppLogDebug("EXIT");
2609 CameraPresentationModel::SetFlip(CameraFlipType type)
2611 AppLogDebug("ENTER");
2612 result r = E_SUCCESS;
2613 int selfPortraitEnable = 0;
2615 r = GetValue(SELF_PORTRAIT_ENABLE, selfPortraitEnable);
2617 if (selfPortraitEnable == CAM_SELF_PORTRAIT_MODE_PRIMARY)
2619 r = GetMediaCapability(CAMERA_PRIMARY_FLIP);
2623 r = GetMediaCapability(CAMERA_SECONDARY_FLIP);
2628 r = __pCamera->SetFlip(type);
2629 TryReturnVoid(r == E_SUCCESS, "Camera::SetFlip() [%s]", GetErrorMessage(r));
2633 AppLogDebug("SetFlip is not support");
2635 AppLogDebug("EXIT");
2639 CameraPresentationModel::GetFlip(void) const
2641 AppLogDebug("ENTER");
2642 AppLogDebug("EXIT");
2643 return __pCamera->GetFlip();
2647 CameraPresentationModel::SetFocusMode(CameraFocusMode mode)
2649 AppLogDebug("ENTER");
2650 result r = E_SUCCESS;
2652 r = __pCamera->SetFocusMode(mode);
2653 TryReturnVoid(r == E_SUCCESS, "Camera::SetFocusMode() [%s]", GetErrorMessage(r));
2654 AppLogDebug("EXIT");
2658 CameraPresentationModel::SetContinuousAutoFocus(void)
2660 AppLogDebug("ENTER");
2661 result r = E_SUCCESS;
2663 if (__pCamera != null)
2665 r = __pCamera->SetFocusMode(CAMERA_FOCUS_MODE_CONTINUOUS_AUTO);
2666 TryReturnVoid(r == E_SUCCESS, "Camera::SetFocusMode() [%s]", GetErrorMessage(r));
2668 r = __pCamera->SetAutoFocus(true);
2669 TryReturnVoid(r == E_SUCCESS, "Camera::SetAutoFocus() [%s]", GetErrorMessage(r));
2671 AppLogDebug("EXIT");
2675 CameraPresentationModel::SetAutoFocusPoint(const Tizen::Graphics::Point& currentPosition)
2677 AppLogDebug("ENTER");
2678 result r = E_SUCCESS;
2679 ArrayList currentPositionList;
2680 currentPositionList.Construct();
2681 currentPositionList.Add(currentPosition);
2683 r = __pCamera->SetFocusMode(CAMERA_FOCUS_MODE_NORMAL);
2684 TryReturnVoid(r == E_SUCCESS, "Camera::SetFocusMode() [%s]", GetErrorMessage(r));
2686 r = __pCamera->SetAutoFocusPoint(currentPositionList);
2687 TryReturnVoid(r == E_SUCCESS, "Camera::SetAutoFocusPoint() [%s]", GetErrorMessage(r));
2689 r = __pCamera->SetAutoFocus(true);
2690 TryReturnVoid(r == E_SUCCESS, "Camera::SetAutoFocus() [%s]", GetErrorMessage(r));
2691 AppLogDebug("EXIT");
2695 CameraPresentationModel::GetExposure(void) const
2697 AppLogDebug("ENTER");
2698 int exposureValue = 0;
2700 exposureValue = __pCamera->GetExposure();
2702 AppLogDebug("EXIT");
2703 return exposureValue;
2707 CameraPresentationModel::SetExposure(int exposureValue)
2709 AppLogDebug("ENTER");
2710 result r = E_SUCCESS;
2712 exposureValue = MAX_CAMERA_EXPOSURE_VALUE - exposureValue;
2714 r = __pCamera->SetExposure(exposureValue);
2715 TryReturnVoid(r == E_SUCCESS, "SetExposure() fail[%s]", GetErrorMessage(r));
2716 AppLogDebug("EXIT");
2720 CameraPresentationModel::GetBrightness(void) const
2722 AppLogDebug("ENTER");
2723 int brightnessValue = 0;
2725 brightnessValue = __pCamera->GetBrightness();
2727 AppLogDebug("EXIT");
2728 return brightnessValue;
2732 CameraPresentationModel::SetBrightness(int brightnessValue)
2734 AppLogDebug("ENTER");
2735 result r = E_SUCCESS;
2737 brightnessValue = MAX_CAMERA_EXPOSURE_VALUE - brightnessValue;
2739 r = __pCamera->SetBrightness(brightnessValue);
2740 TryReturnVoid(r == E_SUCCESS, "Camera::SetBrightness() fail[%s]", GetErrorMessage(r));
2741 AppLogDebug("EXIT");
2745 CameraPresentationModel::GetWhiteBalance(void) const
2747 AppLogDebug("ENTER");
2748 CameraWhiteBalance whiteBalanceValue = CAMERA_WHITE_BALANCE_AUTO;
2750 whiteBalanceValue = __pCamera->GetWhiteBalance();
2752 AppLogDebug("EXIT");
2753 return whiteBalanceValue;
2757 CameraPresentationModel::SetWhiteBalance(CameraWhiteBalance whitebalanceValue)
2759 AppLogDebug("ENTER");
2760 result r = E_SUCCESS;
2762 r = __pCamera->SetWhiteBalance(whitebalanceValue);
2764 AppLogDebug("EXIT");
2768 Tizen::Base::Collection::IList*
2769 CameraPresentationModel::GetIsoList(void)
2771 AppLogDebug("ENTER");
2772 result r = E_SUCCESS;
2773 int selfPortraitEnable = 0;
2775 r = GetValue(SELF_PORTRAIT_ENABLE, selfPortraitEnable);
2777 if (selfPortraitEnable == CAM_SELF_PORTRAIT_MODE_PRIMARY)
2779 __pIsoList = MediaCapability::GetValueN(CAMERA_PRIMARY_ISO_LEVEL);
2780 TryCatch(__pIsoList != null, , "MediaCapability::GetValueN() fail[%s]", GetErrorMessage(GetLastResult()));
2784 __pIsoList = MediaCapability::GetValueN(CAMERA_SECONDARY_ISO_LEVEL);
2785 TryCatch(__pIsoList != null, , "MediaCapability::GetValueN() fail[%s]", GetErrorMessage(GetLastResult()));
2788 AppLogDebug("EXIT");
2792 AppLogDebug("EXIT - CATCH");
2795 __pIsoList->RemoveAll(true);
2806 CameraPresentationModel::GetIsoLevel(void) const
2808 AppLogDebug("ENTER");
2809 CameraIsoLevel isoValue = CAMERA_ISO_DEFAULT;
2811 isoValue = __pCamera->GetIsoLevel();
2813 AppLogDebug("EXIT");
2818 CameraPresentationModel::SetIsoLevel(CameraIsoLevel isoValue)
2820 AppLogDebug("ENTER");
2821 result r = E_SUCCESS;
2823 r = __pCamera->SetIsoLevel(isoValue);
2824 TryReturnVoid(r == E_SUCCESS, "SetIsoLevel() fail[%s]", GetErrorMessage(r));
2825 AppLogDebug("EXIT");
2829 CameraPresentationModel::GetMaxZoomLevel(void) const
2831 AppLogDebug("ENTER");
2834 zoomLevel = __pCamera->GetMaxZoomLevel();
2836 AppLogDebug("EXIT");
2841 CameraPresentationModel::GetZoomLevel(void) const
2843 AppLogDebug("ENTER");
2846 zoomLevel = __pCamera->GetZoomLevel();
2848 AppLogDebug("EXIT");
2853 CameraPresentationModel::SetZoomValue(int zoomValue)
2855 AppLogDebug("ENTER");
2856 result r = E_SUCCESS;
2858 int currentZoomValue = __pCamera->GetZoomLevel();
2860 if (currentZoomValue < zoomValue)
2862 for (int i = currentZoomValue; i < zoomValue; i++)
2864 r = __pCamera->ZoomIn();
2865 TryReturnVoid(r == E_SUCCESS, "ZoomIn() fail[%s]", GetErrorMessage(r));
2870 for (int i = currentZoomValue; i > zoomValue; i--)
2872 r = __pCamera->ZoomOut();
2873 TryReturnVoid(r == E_SUCCESS, "ZoomOut() fail[%s]", GetErrorMessage(r));
2876 AppLogDebug("EXIT");
2880 CameraPresentationModel::GetFlashMode(void) const
2882 AppLogDebug("ENTER");
2883 CameraFlashMode cameraFlashMode = CAMERA_FLASH_MODE_OFF;
2885 cameraFlashMode = __pCamera->GetFlashMode();
2887 AppLogDebug("Get flashMode = %d", cameraFlashMode);
2889 AppLogDebug("EXIT");
2890 return cameraFlashMode;
2894 CameraPresentationModel::SetFlashModeOnRecord(bool flashOn)
2896 AppLogDebug("ENTER");
2897 result ret = E_SUCCESS;
2898 int selfPortraitEnable = 0;
2901 ret = GetValue(SELF_PORTRAIT_ENABLE, selfPortraitEnable);
2902 if (ret != E_SUCCESS)
2904 selfPortraitEnable = CAM_SELF_PORTRAIT_MODE_PRIMARY;
2907 if (selfPortraitEnable == CAM_SELF_PORTRAIT_MODE_PRIMARY)
2909 ret = GetMediaCapability(CAMERA_PRIMARY_FLASH_MODE);
2913 ret = GetMediaCapability(CAMERA_SECONDARY_FLASH_MODE);
2916 if (ret == E_SUCCESS)
2918 if (selfPortraitEnable == CAM_SELF_PORTRAIT_MODE_PRIMARY)
2920 ret = __pCameraSettingsPresentationModel->GetValue(SECTION_CAMCORDER, FLASH_MODE_PRIMARY, flashMode);
2924 ret = __pCameraSettingsPresentationModel->GetValue(SECTION_CAMCORDER, FLASH_MODE_SECONDARY, flashMode);
2926 TryCatch(ret == E_SUCCESS, , "GetValue() fail[%s]", GetErrorMessage(ret));
2928 AppLogDebug("flashMode = %d", flashMode);
2930 if (__pCamera->IsPoweredOn() == true && flashMode == FLASH_TYPE_ON)
2932 AppLogDebug("SetFlashModeOnRecord flashOn = %d", flashOn);
2936 ret = __pCamera->SetFlashMode(CAMERA_FLASH_MODE_CONTINUOUS);
2937 TryCatch(ret == E_SUCCESS, , "SetFlashMode() fail[%s]", GetErrorMessage(ret));
2941 ret = __pCamera->SetFlashMode(CAMERA_FLASH_MODE_ON); //CAMERA_FLASH_MODE_OFF >>is TAF don't flash on
2942 TryCatch(ret == E_SUCCESS, , "SetFlashMode() fail[%s]", GetErrorMessage(ret));
2947 AppLogDebug("Camera PoweredOff status");
2951 AppLogDebug("EXIT");
2955 AppLogDebug("EXIT - CATCH");
2960 CameraPresentationModel::SetFlashMode(CameraFlashMode mode)
2962 AppLogDebug("ENTER");
2963 result r = E_SUCCESS;
2965 AppLogDebug("Set flashMode = %d", mode);
2967 if (__pCamera != null)
2969 if (mode == CAMERA_FLASH_MODE_OFF)
2971 if (__pCamera->IsFlashOn())
2973 r = __pCamera->SetFlashMode(CAMERA_FLASH_MODE_OFF);
2974 AppLogDebug("Set SetFlashMode = %s", GetErrorMessage(r));
2979 r = __pCamera->SetFlashMode(mode);
2980 AppLogDebug("Set SetFlashMode = %s", GetErrorMessage(r));
2985 AppLogDebug("__pCamera is null");
2988 AppLogDebug("EXIT");
2992 Tizen::Ui::OrientationStatus
2993 CameraPresentationModel::GetOrientation(void) const
2995 AppLogDebug("ENTER");
2996 AppLogDebug("EXIT");
3001 CameraPresentationModel::SetOrientation(Tizen::Ui::OrientationStatus dir)
3003 AppLogDebug("ENTER");
3004 AppLogDebug("EXIT");
3009 CameraPresentationModel::GetAppControlRequestType(void) const
3011 AppLogDebug("ENTER");
3012 AppLogDebug("EXIT");
3013 return __appControlRequestType;
3017 CameraPresentationModel::SetAppControlRequestType(int requestType)
3019 AppLogDebug("ENTER");
3020 __appControlRequestType = requestType;
3021 AppLogDebug("EXIT");
3025 CameraPresentationModel::GetErrorResult(void) const
3027 AppLogDebug("ENTER");
3028 AppLogDebug("EXIT");
3029 return __errorResult;
3033 CameraPresentationModel::SetErrorResult(const Tizen::Base::String& string)
3035 AppLogDebug("ENTER");
3036 __errorResult = string;
3037 AppLogDebug("EXIT");
3040 Tizen::System::BatteryLevel
3041 CameraPresentationModel::GetBatteryLevel(void) const
3043 AppLogDebug("ENTER");
3044 BatteryLevel batteryLevel;
3046 batteryLevel = PowerManager::GetCurrentBatteryLevel();
3048 AppLogDebug("EXIT");
3049 return batteryLevel;
3052 Tizen::Media::CameraState
3053 CameraPresentationModel::GetCameraState(void) const
3055 AppLogDebug("ENTER");
3056 TryCatch(__pCamera != null, , "__pCamera is null");
3058 AppLogDebug("EXIT");
3059 return __pCamera->GetState();
3062 AppLogDebug("EXIT - CATCH");
3063 return CAMERA_STATE_ERROR;
3066 Tizen::Media::RecorderState
3067 CameraPresentationModel::GetRecorderState(void) const
3069 AppLogDebug("ENTER");
3070 TryCatch(__pVideoRecorder != null, , "__pVideoRecorder is null");
3072 AppLogDebug("EXIT");
3073 return __pVideoRecorder->GetState();
3076 AppLogDebug("EXIT - CATCH");
3077 return RECORDER_STATE_ERROR;
3081 CameraPresentationModel::GetAvailableStorageSpace(void) const
3083 AppLogDebug("ENTER");
3084 result r = E_SUCCESS;
3085 int storageType = STORAGE_TYPE_PHONE;
3086 long long availableStorageSpace = 0;
3088 r = GetValue(STORAGE_TYPE, storageType);
3091 storageType = STORAGE_TYPE_PHONE;
3094 if (storageType == STORAGE_TYPE_PHONE)
3096 String key(STRING_KEY_STORAGE_PHONE);
3097 r = RuntimeInfo::GetValue(key, availableStorageSpace);
3098 TryCatch(r == E_SUCCESS, , "To get a value is fail");
3100 else if (storageType == STORAGE_TYPE_MEMORYCARD)
3102 if (IsStorageCardMounted() == true)
3104 String key(STRING_KEY_STORAGE_SDCARD);
3106 r = RuntimeInfo::GetValue(key, availableStorageSpace);
3107 TryCatch(r == E_SUCCESS, , "To get a value is fail");
3111 availableStorageSpace = 0;
3115 AppLogDebug("EXIT - availableStorageSpace = %ld", availableStorageSpace);
3116 return availableStorageSpace;
3119 AppLogDebug("EXIT - CATCH");
3120 availableStorageSpace = 0;
3121 return availableStorageSpace;
3125 CameraPresentationModel::ZoomIn(void)
3127 AppLogDebug("ENTER");
3128 result r = E_SUCCESS;
3130 r = __pCamera->ZoomIn();
3131 TryReturnVoid(r == E_SUCCESS, "ZoomIn() fail[%s]", GetErrorMessage(r));
3132 AppLogDebug("EXIT");
3136 CameraPresentationModel::ZoomOut(void)
3138 AppLogDebug("ENTER");
3139 result r = E_SUCCESS;
3141 r = __pCamera->ZoomOut();
3142 TryReturnVoid(r == E_SUCCESS, "ZoomOut() fail[%s]", GetErrorMessage(r));
3143 AppLogDebug("EXIT");
3147 CameraPresentationModel::SetExifOrientation(int orientation)
3149 AppLogDebug("ENTER");
3150 result r = E_SUCCESS;
3152 switch (orientation)
3154 case CAM_SET_EXIF_ORIENTATION_MODE_PORTRAIT:
3156 r = __pCamera->SetExifOrientation(CAMERA_EXIF_ORIENTATION_RIGHT_TOP);
3160 case CAM_SET_EXIF_ORIENTATION_MODE_PORTRAIT_REVERSE:
3162 r = __pCamera->SetExifOrientation(CAMERA_EXIF_ORIENTATION_LEFT_BOTTOM);
3166 case CAM_SET_EXIF_ORIENTATION_MODE_LANDSCAPE:
3168 r = __pCamera->SetExifOrientation(CAMERA_EXIF_ORIENTATION_TOP_LEFT);
3172 case CAM_SET_EXIF_ORIENTATION_MODE_LANDSCAPE_REVERSE:
3174 r = __pCamera->SetExifOrientation(CAMERA_EXIF_ORIENTATION_BOTTOM_RIGHT);
3181 AppLogDebug("__pCamera->SetExifOrientation() fail[%s]", GetErrorMessage(r));
3183 AppLogDebug("EXIT");
3188 CameraPresentationModel::KeepScreenOnState(bool keepOn, bool dimming)
3190 result r = E_FAILURE;
3191 AppLogDebug("ENTER");
3193 AppLogDebug("PowerManager keepOn : %d dimming : %d", keepOn, dimming);
3195 r = PowerManager::KeepScreenOnState(keepOn, dimming);
3196 TryReturnVoid(r == E_SUCCESS, "PowerManager::KeepScreenOnState() failed:%s", GetErrorMessage(r));
3197 AppLogDebug("EXIT");
3201 CameraPresentationModel::AddPresentationChangedEventListener(ICameraEventListner& pObserverListener)
3203 AppLogDebug("ENTER");
3204 __pCameraListener = &pObserverListener;
3205 AppLogDebug("EXIT");
3209 CameraPresentationModel::RemovePresentationChangedEventListener(ICameraEventListner* pObserverListener)
3211 AppLogDebug("ENTER");
3212 __pCameraListener = pObserverListener;
3213 AppLogDebug("EXIT");
3217 CameraPresentationModel::CallOnPresentationModeChanged(CameraActionEvent event)
3219 AppLogDebug("ENTER");
3220 AppLogDebug("CallOnPresentationModeChanged - event = %d", event);
3221 if (__pCameraListener != null)
3223 __pCameraListener->OnCameraActionPerformed(event);
3225 AppLogDebug("EXIT");
3229 CameraPresentationModel::ResetCameraSettingsRegistry(void)
3231 AppLogDebug("ENTER");
3232 result r = E_SUCCESS;
3234 r = __pCameraSettingsPresentationModel->ResetCameraSettingsRegistry();
3235 TryCatch(r == E_SUCCESS, , "Registry::SetValue() failed[%s]", GetErrorMessage(r));
3237 AppLogDebug("EXIT");
3241 AppLogDebug("EXIT - CATCH");
3246 CameraPresentationModel::ResetCameraSettings(void)
3248 AppLogDebug("ENTER");
3249 result r = E_SUCCESS;
3251 TryCatch(__pCameraSettingsPresentationModel!=null, r = E_FAILURE,"Camera Settings Presentation Model is NULL");
3253 r = __pCameraSettingsPresentationModel->SetValue(SECTION_CAMERA, EXPOSURE_VALUE, EXPOSURE_DEFAULT_VALUE);
3254 TryCatch(r == E_SUCCESS, , "Registry::GetValue() failed[%s]", GetErrorMessage(r));
3256 r = __pCameraSettingsPresentationModel->SetValue(SECTION_CAMCORDER, EXPOSURE_VALUE, EXPOSURE_DEFAULT_VALUE);
3257 TryCatch(r == E_SUCCESS, , "Registry::GetValue() failed[%s]", GetErrorMessage(r));
3259 r = __pCameraSettingsPresentationModel->SetValue(SECTION_CAMERA, BRIGHTNESS_VALUE, BRIGHTNESS_DEFAULT_VALUE);
3260 TryCatch(r == E_SUCCESS, , "Registry::GetValue() failed[%s]", GetErrorMessage(r));
3262 r = __pCameraSettingsPresentationModel->SetValue(SECTION_CAMCORDER, BRIGHTNESS_VALUE, BRIGHTNESS_DEFAULT_VALUE);
3263 TryCatch(r == E_SUCCESS, , "Registry::GetValue() failed[%s]", GetErrorMessage(r));
3265 AppLogDebug("EXIT");
3269 AppLogDebug("EXIT - CATCH %s", GetErrorMessage(r));
3274 CameraPresentationModel::GetValue(const Tizen::Base::String& entryName, int& value) const
3276 AppLogDebug("ENTER");
3277 AppLogDebug("entry name is %ls",entryName.GetPointer());
3278 AppLogDebug("entry value is %d",value);
3279 result r = E_SUCCESS;
3281 String strSectionName = SECTION_CAMERA;
3283 if (entryName.Equals(String(CURRENT_MODE)))
3285 strSectionName = SECTION_CAMERA;
3289 r = __pCameraSettingsPresentationModel->GetValue(SECTION_CAMERA, CURRENT_MODE, mode);
3290 TryCatch(r == E_SUCCESS, , "Registry::GetValue() failed[%s]", GetErrorMessage(r));
3292 if (mode == CAMERA_MODE_SNAPSHOT)
3294 strSectionName = SECTION_CAMERA;
3298 strSectionName = SECTION_CAMCORDER;
3302 r = __pCameraSettingsPresentationModel->GetValue(strSectionName, entryName, value);
3303 TryCatch(r == E_SUCCESS, , "Registry::GetValue() failed[%s]", GetErrorMessage(r));
3305 AppLogDebug("EXIT");
3309 AppLogDebug("EXIT - CATCH");
3314 CameraPresentationModel::SetValue(const Tizen::Base::String& entryName, const int value)
3316 AppLogDebug("ENTER");
3317 result r = E_SUCCESS;
3319 String strSectionName = SECTION_CAMERA;
3321 AppLogDebug("entry name is %ls",entryName.GetPointer());
3322 AppLogDebug("entry value is %d",value);
3324 if (entryName.Equals(String(CURRENT_MODE)))
3326 strSectionName = SECTION_CAMERA;
3330 r = __pCameraSettingsPresentationModel->GetValue(SECTION_CAMERA, CURRENT_MODE, mode);
3331 TryCatch(r == E_SUCCESS, , "Registry::GetValue() failed[%s]", GetErrorMessage(r));
3333 if (mode == CAMERA_MODE_SNAPSHOT)
3335 strSectionName = SECTION_CAMERA;
3339 strSectionName = SECTION_CAMCORDER;
3343 r = __pCameraSettingsPresentationModel->SetValue(strSectionName, entryName, value);
3345 /*if ( entryName.CompareTo(L"PRIMARY_FLASH_MODE") == 0)
3347 AppLogDebug("flash mode is set to value %d",value);
3348 SetFlashMode(CameraFlashMode(value));
3350 TryCatch(r == E_SUCCESS, , "Registry::SetValue() failed[%s]", GetErrorMessage(r));
3352 AppLogDebug("EXIT");
3356 AppLogDebug("EXIT - CATCH");
3361 CameraPresentationModel::GetMediaCapability(Tizen::Base::String key, bool& value) const
3363 AppLogDebug("ENTER");
3364 result r = E_SUCCESS;
3365 r = MediaCapability::GetValue(key, value);
3367 AppLogDebug("GetMediaCapability for %ls value = %d return = %s", key.GetPointer(), value, GetErrorMessage(r));
3368 TryCatch(r == E_SUCCESS, , "MediaCapability::GetValue() fail[%s]", GetErrorMessage(r));
3370 AppLogDebug("EXIT");
3374 AppLogDebug("EXIT - CATCH");
3379 CameraPresentationModel::GetMediaCapability(Tizen::Base::String key, int& value) const
3381 AppLogDebug("ENTER");
3382 result r = E_SUCCESS;
3383 r = MediaCapability::GetValue(key, value);
3385 AppLogDebug("GetMediaCapability for %ls value = %d return = %s", key.GetPointer(), value, GetErrorMessage(r));
3386 TryCatch(r == E_SUCCESS, , "MediaCapability::GetValue() fail[%s]", GetErrorMessage(r));
3388 AppLogDebug("EXIT");
3392 AppLogDebug("EXIT - CATCH");
3397 CameraPresentationModel::GetMediaCapability(Tizen::Base::String key) const
3399 AppLogDebug("ENTER");
3400 result r = E_SUCCESS;
3401 IList* pList = null;
3402 pList = MediaCapability::GetValueN(key);
3403 r = GetLastResult();
3404 AppLogDebug("GetMediaCapability for %ls return = %s", key.GetPointer(), GetErrorMessage(r));
3405 TryCatch(pList != null, , "MediaCapability::GetValueN() fail[%s]", GetErrorMessage(r));
3407 pList->RemoveAll(true);
3411 AppLogDebug("EXIT");
3415 AppLogDebug("EXIT - CATCH");
3420 CameraPresentationModel::OnCameraAutoFocused(bool completeCondition)
3422 AppLogDebug("ENTER");
3423 CameraFocusMode focusMode = CAMERA_FOCUS_MODE_NONE;
3425 if (__isIntervalTimerRun == true)
3427 AppLogDebug("__isIntervalTimerRun: true");
3431 if (completeCondition == true)
3433 focusMode = __pCamera->GetFocusMode();
3435 if (focusMode == CAMERA_FOCUS_MODE_CONTINUOUS_AUTO)
3437 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_AUTO_FOCUSED);
3439 else if (focusMode == CAMERA_FOCUS_MODE_NORMAL)
3441 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_TOUCH_AUTO_FOCUSED);
3446 AppLogDebug("completeCondition:false");
3447 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_AUTO_FOCUS_FAILED);
3449 AppLogDebug("EXIT");
3453 CameraPresentationModel::OnCameraPreviewed(Tizen::Base::ByteBuffer& previewedData, result r)
3455 AppLogDebug("ENTER");
3456 AppLogDebug("EXIT");
3460 CameraPresentationModel::OnCameraCaptured(Tizen::Base::ByteBuffer& capturedData, result r)
3462 AppLogDebug("ENTER");
3463 int shootingMode = 0;
3464 String* pFullFileName = null;
3465 ContentManager* pContentManager = null;
3466 ImageContentInfo* pImageContentInfo = null;
3467 result ret = E_SUCCESS;
3468 int storageType = 0;
3469 String FilePath= null;
3470 bool bDoScanDir= false;
3472 AppLogDebug("OnCameraCaptured :: StopCaptured = %d", __isStopCaptured);
3474 if (__isStopCaptured == true)
3476 AppLogDebug("OnCameraCaptured :: StopCaptured");
3477 __isStopCaptured = false;
3479 SetErrorResult(STRING_CAMERA_CAPTURED_ERROR);
3481 SetAppControlRequestType(APP_CONTROL_REQUEST_TYPE_FAILED);
3483 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_ERROR_OCCURRED);
3487 ret = GetValue(SHOOTING_MODE, shootingMode);
3488 TryCatch(ret == E_SUCCESS, , "GetValue() fail[%s]", GetErrorMessage(ret));
3490 if (shootingMode == CAPTURE_NORMAL_MODE)
3494 ContentId contentId;
3496 pFullFileName = new (std::nothrow) String();
3497 ret = CreateFileName(*pFullFileName);
3498 TryCatch(ret == E_SUCCESS, , "pFullFileName is null");
3500 __latestContentName.Clear();
3501 ret = __latestContentName.Append(pFullFileName->GetPointer());
3502 TryCatch(ret == E_SUCCESS, , "String::Append() fail[%s]", GetErrorMessage(ret));
3504 AppLogDebug("OnCameraCaptured pFullFileName = %ls", pFullFileName->GetPointer());
3505 pContentManager = new (std::nothrow) ContentManager();
3507 ret = pContentManager->Construct();
3508 TryCatch(ret == E_SUCCESS, , "ContentManager->Construct() failed(%s)", GetErrorMessage(r));
3511 //Code for doing ScanDirectory!!!
3512 r = GetValue(STORAGE_TYPE, storageType);
3513 TryCatch(r == E_SUCCESS, , "GetValue() fail[%s]", GetErrorMessage(r));
3515 r = GetDirectoryPath(storageType, FilePath);
3516 TryCatch(r == E_SUCCESS, , "GetDirectoryPath() fail[%s]", GetErrorMessage(r));
3518 if( File::IsFileExist(FilePath) != true)
3524 contentId = pContentManager->CreateContent(capturedData, pFullFileName->GetPointer());
3525 TryCatch(Tizen::Base::UuId::GetInvalidUuId() != contentId, GetLastResult(), "CreateContent failed.");
3527 pImageContentInfo = static_cast<ImageContentInfo*>(pContentManager->GetContentInfoN(contentId));
3528 TryCatch(pImageContentInfo != null, , "pImageContentInfo is null");
3533 pContentManager->ScanDirectory(FilePath, true, null , reqId);
3539 __pBitmap = pImageContentInfo->GetThumbnailN();
3540 TryCatch(__pBitmap != null, , "__pBitmap is null");
3542 delete pContentManager;
3543 pContentManager = null;
3545 delete pImageContentInfo;
3546 pImageContentInfo = null;
3548 delete pFullFileName;
3549 pFullFileName = null;
3551 AppLogDebug("ENTER:E_SUCCESS");
3553 SetAppControlRequestType(APP_CONTROL_REQUEST_TYPE_SUCCEEDED);
3555 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_CAPTURED);
3559 AppLogDebug("ENTER:E_FAILED");
3560 SetErrorResult(STRING_CAMERA_CAPTURED_ERROR);
3562 SetAppControlRequestType(APP_CONTROL_REQUEST_TYPE_FAILED);
3564 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_ERROR_OCCURRED);
3567 else if (shootingMode == CAPTURE_BURST_MODE)
3573 AppLogDebug("EXIT");
3577 AppLogDebug("EXIT - CATCH");
3578 if (__pBitmap != null)
3584 if (pContentManager != null)
3586 delete pContentManager;
3587 pContentManager = null;
3590 if (pImageContentInfo)
3592 delete pImageContentInfo;
3593 pImageContentInfo = null;
3598 delete pFullFileName;
3599 pFullFileName = null;
3602 SetErrorResult(STRING_CAMERA_CAPTURED_ERROR);
3604 SetAppControlRequestType(APP_CONTROL_REQUEST_TYPE_FAILED);
3606 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_ERROR_OCCURRED);
3610 CameraPresentationModel::OnCameraErrorOccurred(Tizen::Media::CameraErrorReason r)
3612 AppLogDebug("ENTER");
3613 result res = E_FAILURE;
3614 int currentCameraMode = 0;
3618 case CAMERA_ERROR_OUT_OF_MEMORY:
3620 AppLogDebug("camera error occurred - CAMERA_ERROR_OUT_OF_MEMORY");
3621 res = E_OUT_OF_MEMORY;
3625 case CAMERA_ERROR_DEVICE_FAILED:
3627 AppLogDebug("camera error occurred - CAMERA_ERROR_DEVICE_FAILED");
3628 res = E_DEVICE_FAILED;
3632 case CAMERA_ERROR_DEVICE_INTERRUPTED:
3634 AppLogDebug("camera error occurred - CAMERA_ERROR_DEVICE_INTERRUPTED");
3635 res = E_DEVICE_BUSY;
3646 result ret = GetValue(CURRENT_MODE, currentCameraMode);
3647 TryReturnVoid(ret == E_SUCCESS, "Faled to set value to registry[%s]", GetErrorMessage(ret));
3649 if (currentCameraMode == CAMERA_MODE_RECORD)
3651 AppLogDebug("RECORD error occurred");
3652 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_VIDEO_RECORDER_ERROR_OCCURRED);
3656 AppLogDebug("SNAPSHOT error occurred");
3657 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_ERROR_OCCURRED);
3659 AppLogDebug("EXIT");
3663 CameraPresentationModel::OnVideoRecorderCanceled(result r)
3665 AppLogDebug("ENTER");
3666 if (__pVideoRecorder != null)
3668 __pVideoRecorder->Close();
3671 if (__recorderStopException)
3673 r = __pCamera->StopPreview();
3674 TryReturnVoid(r == E_SUCCESS, "Camera::StopPreview() [%s]", GetErrorMessage(r));
3676 if (__pCamera->IsPoweredOn() == true)
3678 r = __pCamera->PowerOff();
3679 TryReturnVoid(r == E_SUCCESS, "Camera::PowerOff() [%s]", GetErrorMessage(r));
3682 AppLogDebug("EXIT");
3686 CameraPresentationModel::OnVideoRecorderClosed(result r)
3688 AppLogDebug("ENTER");
3689 # if 0 //Unused code
3690 ContentManager* pContentManager = null;
3692 ContentId contentId;
3693 String replaceFilePath;
3694 String camcorderTemporaryFilePath;
3695 int storageType = STORAGE_TYPE_PHONE;
3696 result ret = E_SUCCESS;
3698 ret = SetFlashModeOnRecord(false);
3699 AppLogDebug("SetFlashModeOnRecord fail[%s]", GetErrorMessage(ret));
3701 if (__isCancelRecord)
3703 __onVideoRecorderStarted = false;
3704 __isCancelRecord = false;
3705 AppLogDebug("isCancelRecord");
3707 ret = RemoveVideoFile();
3708 AppLogDebug("RemoveVideoFile fail[%s]", GetErrorMessage(ret));
3710 SetAppControlRequestType(APP_CONTROL_REQUEST_TYPE_CANCELED);
3711 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_VIDEO_RECORDER_CANCELED);
3713 AppLogDebug("CANCELRECORD - EXIT");
3719 AppLogDebug("ENTER: E_SUCCESS");
3721 ret = GetValue(STORAGE_TYPE, storageType);
3722 if (ret != E_SUCCESS)
3724 storageType = STORAGE_TYPE_PHONE;
3727 if (storageType == STORAGE_TYPE_PHONE)
3729 camcorderTemporaryFilePath.Format(MAX_DIRECTORY_PATH_LENGTH, L"%ls%ls", App::GetInstance()->GetAppRootPath().GetPointer(), STRING_CAMCORDER_TEMPORARY_FILE);
3733 camcorderTemporaryFilePath.Format(MAX_DIRECTORY_PATH_LENGTH, L"%ls%ls", Environment::GetExternalStoragePath().GetPointer(), STRING_CAMCORDER_TEMPORARY_FILE_EXT);
3736 # if 0 //Contnet Manager is nto used
3737 pContentManager = new (std::nothrow) ContentManager();
3738 ret = pContentManager->Construct();
3739 TryCatch(ret == E_SUCCESS, , "ContentManager->Construct() failed(%s)", GetErrorMessage(r));
3742 AppLogDebug("latest content name is %ls",__latestContentName.GetPointer());
3743 r = ContentManager::ScanFile(__latestContentName);
3744 __CurrentVideoFileName = __latestContentName;
3746 if (storageType == STORAGE_TYPE_PHONE)
3748 replaceFilePath = Environment::GetMediaPath();
3752 replaceFilePath = Environment::GetExternalStoragePath();
3755 replaceFilePath.Append(STRING_CAMERA_FOLDER_NAME);
3756 replaceFilePath.Append("/");
3757 AppLogDebug("Replace filepath is %ls",replaceFilePath.GetPointer());
3758 __CurrentVideoFileName.Replace(replaceFilePath,"");
3759 AppLogDebug("__CurrentVideoFileName path is %ls",__CurrentVideoFileName.GetPointer());
3761 __pBitmap = CreateThumbnailN(__CurrentVideoFileName,CONTENT_TYPE_VIDEO);
3763 SetAppControlRequestType(APP_CONTROL_REQUEST_TYPE_SUCCEEDED);
3765 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_VIDEO_RECORDER_CLOSED);
3769 AppLogDebug("ENTER: E_FAILED");
3771 SetErrorResult(STRING_VIDEO_RECORDER_CLOSED_ERROR);
3773 SetAppControlRequestType(APP_CONTROL_REQUEST_TYPE_FAILED);
3774 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_VIDEO_RECORDER_ERROR_OCCURRED);
3777 __onVideoRecorderStarted = false;
3779 AppLogDebug("EXIT");
3784 CameraPresentationModel::OnVideoRecorderEndReached(RecordingEndCondition endCondition)
3786 AppLogDebug("ENTER");
3787 ContentManager* pContentManager = null;
3788 VideoContentInfo* videoContentInfo = null;
3789 ContentId contentId;
3790 String camcorderTemporaryFilePath;
3791 int storageType = STORAGE_TYPE_PHONE;
3792 result ret = E_SUCCESS;
3794 ret = SetFlashModeOnRecord(false);
3795 AppLogDebug("SetFlashModeOnRecord fail[%s]", GetErrorMessage(ret));
3799 ret = GetValue(STORAGE_TYPE, storageType);
3800 if (ret != E_SUCCESS)
3802 storageType = STORAGE_TYPE_PHONE;
3805 if (storageType == STORAGE_TYPE_PHONE)
3807 camcorderTemporaryFilePath.Format(MAX_DIRECTORY_PATH_LENGTH, L"%ls%ls", App::GetInstance()->GetAppRootPath().GetPointer(), STRING_CAMCORDER_TEMPORARY_FILE);
3811 camcorderTemporaryFilePath.Format(MAX_DIRECTORY_PATH_LENGTH, L"%ls%ls", Environment::GetExternalStoragePath().GetPointer(), STRING_CAMCORDER_TEMPORARY_FILE_EXT);
3814 pContentManager = new (std::nothrow) ContentManager();
3816 ret = pContentManager->Construct();
3817 TryCatch(ret == E_SUCCESS, , "ContentManager->Construct() failed(%s)", GetErrorMessage(ret));
3819 contentId = pContentManager->CreateContent(camcorderTemporaryFilePath, __latestContentName, true);
3820 TryCatch(Tizen::Base::UuId::GetInvalidUuId() != contentId, GetLastResult(), "CreateContent failed.");
3822 videoContentInfo = static_cast<VideoContentInfo*>(pContentManager->GetContentInfoN(contentId));
3823 TryCatch(videoContentInfo != null, , "videoContentInfo is null");
3828 __pBitmap = videoContentInfo->GetThumbnailN();
3829 TryCatch(__pBitmap != null, , "__pBitmap is null");
3831 delete videoContentInfo;
3832 videoContentInfo = null;
3834 delete pContentManager;
3835 pContentManager = null;
3837 SetAppControlRequestType(APP_CONTROL_REQUEST_TYPE_SUCCEEDED);
3839 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_VIDEO_RECORDER_END_REACHED);
3841 __onVideoRecorderStarted = false;
3842 AppLogDebug("EXIT");
3846 AppLogDebug("EXIT - CATCH");
3847 delete pContentManager;
3848 pContentManager = null;
3850 delete videoContentInfo;
3851 videoContentInfo = null;
3856 SetErrorResult(STRING_VIDEO_RECORDER_END_REACHED_ERROR);
3857 SetAppControlRequestType(APP_CONTROL_REQUEST_TYPE_FAILED);
3858 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_VIDEO_RECORDER_ERROR_OCCURRED);
3862 CameraPresentationModel::OnVideoRecorderErrorOccurred(RecorderErrorReason r)
3864 AppLogDebug("ENTER OnVideoRecorderErrorOccurred (%ld)", r);
3866 __recorderError = r;
3867 __pVideoRecorder->Close();
3869 SetAppControlRequestType(APP_CONTROL_REQUEST_TYPE_FAILED);
3871 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_VIDEO_RECORDER_ERROR_OCCURRED);
3873 __onVideoRecorderStarted = false;
3874 AppLogDebug("EXIT");
3878 CameraPresentationModel::OnVideoRecorderPaused(result r)
3880 AppLogDebug("ENTER");
3881 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_VIDEO_RECORDER_PAUSED);
3882 AppLogDebug("EXIT");
3886 CameraPresentationModel::OnVideoRecorderStarted(result r)
3888 AppLogDebug("ENTER");
3889 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_VIDEO_RECORDER_STARTED);
3890 AppLogDebug("EXIT");
3894 CameraPresentationModel::GetOnVideoRecorderStopped(void)
3896 AppLogDebug("ENTER");
3897 AppLogDebug("EXIT");
3898 return __onVideoRecorderStarted;
3902 CameraPresentationModel::SetOnVideoRecorderStopped(bool isCompleted)
3904 AppLogDebug("ENTER");
3905 __onVideoRecorderStarted = isCompleted;
3906 AppLogDebug("EXIT");
3910 CameraPresentationModel::OnVideoRecorderStopped(result r)
3912 AppLogDebug("ENTER");
3913 result localResult = E_SUCCESS;
3915 if (__pVideoRecorder != null)
3917 localResult = __pVideoRecorder->Close();
3918 TryCatch(localResult == E_SUCCESS, , "__pVideoRecorder::Close() fail[%s]", GetErrorMessage(localResult));
3920 __onVideoRecorderStarted = true;
3922 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_VIDEO_RECORDER_STOPPED);
3924 AppLogDebug("EXIT");
3928 AppLogDebug("EXIT - CATCH");
3929 SetAppControlRequestType(APP_CONTROL_REQUEST_TYPE_FAILED);
3930 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_VIDEO_RECORDER_ERROR_OCCURRED);
3934 CameraPresentationModel::DestroyPresentationModelInstance(void)
3936 AppLogDebug("ENTER");
3937 CameraPresentationModel* pCameraPresentationModel = CameraPresentationModel::GetInstance();
3939 delete pCameraPresentationModel;
3940 AppLogDebug("EXIT");
3944 CameraPresentationModel::UpdateThumbnail(int currentCameraMode)
3946 AppLogDebug("ENTER");
3947 result r = E_SUCCESS;
3949 r = CreateThumbnail(currentCameraMode);
3950 TryReturnVoid(r == E_SUCCESS, "CreateThumbnail() fail[%s]", GetErrorMessage(r));
3951 AppLogDebug("EXIT");
3955 CameraPresentationModel::GetStorageCardState(void) const
3957 AppLogDebug("ENTER");
3958 AppLogDebug("EXIT");
3959 return __storageCardState;
3963 CameraPresentationModel::SetStorageCardState(int storageCardState)
3965 AppLogDebug("ENTER");
3966 __storageCardState = storageCardState;
3967 AppLogDebug("EXIT");
3971 CameraPresentationModel::GetStorageCardChageState(void) const
3973 AppLogDebug("ENTER");
3974 AppLogDebug("EXIT");
3975 return __storageCardChageState;
3979 CameraPresentationModel::SetStorageCardChageState(int storageCardChageState)
3981 AppLogDebug("ENTER");
3982 __storageCardChageState = storageCardChageState;
3983 AppLogDebug("EXIT");
3987 CameraPresentationModel::StorageCardStateChaged(bool isMounted)
3989 AppLogDebug("ENTER");
3992 __storageCardState = STORAGE_CARD_STATE_MOUNT;
3996 __storageCardState = STORAGE_CARD_STATE_UNMOUNT;
3998 __pCameraSettingsPresentationModel->SetValue(SECTION_CAMERA, STORAGE_TYPE, STORAGE_TYPE_PHONE);
4000 __pCameraSettingsPresentationModel->SetValue(SECTION_CAMCORDER, STORAGE_TYPE, STORAGE_TYPE_PHONE);
4002 AppLogDebug("EXIT");
4006 CameraPresentationModel::SetDeviceManagerEventListner(void)
4008 AppLogDebug("ENTER");
4009 result r = E_SUCCESS;
4011 r = DeviceManager::AddDeviceEventListener(DEVICE_TYPE_STORAGE_CARD, *this);
4012 AppLogDebug("AddDeviceEventListener [%s] fail", GetErrorMessage(r));
4013 AppLogDebug("EXIT");
4017 CameraPresentationModel::RemoveDeviceManagerEventListner(void)
4019 AppLogDebug("ENTER");
4020 result r = E_SUCCESS;
4022 r = DeviceManager::RemoveDeviceEventListener(DEVICE_TYPE_STORAGE_CARD, *this);
4023 AppLogDebug("RemoveDeviceManagerEventListner [%s] fail", GetErrorMessage(r));
4024 AppLogDebug("EXIT");
4028 CameraPresentationModel::OnDeviceStateChanged(Tizen::System::DeviceType deviceType, const Tizen::Base::String& state)
4030 AppLogDebug("ENTER");
4031 int currentCameraMode = 0;
4032 int storageType = STORAGE_TYPE_PHONE;
4034 result r = E_SUCCESS;
4035 r = GetValue(CURRENT_MODE, currentCameraMode);
4036 TryReturnVoid(r == E_SUCCESS, "GetValue returns not E_SUCCESS", GetErrorMessage(r));
4038 if (deviceType == DEVICE_TYPE_STORAGE_CARD)
4040 switch (currentCameraMode)
4042 case CAMERA_MODE_RECORD:
4044 __pCameraSettingsPresentationModel->GetValue(SECTION_CAMCORDER, STORAGE_TYPE, storageType);
4046 if (storageType == STORAGE_TYPE_MEMORYCARD)
4048 if (IsStorageCardMounted()== false)
4050 AppLogDebug("RemoveVideoFile::GetRecorderState() = %d", __pVideoRecorder->GetState());
4052 if (__pVideoRecorder->GetState() == RECORDER_STATE_RECORDING
4053 || __pVideoRecorder->GetState() == RECORDER_STATE_PAUSED
4054 || __pVideoRecorder->GetState() == RECORDER_STATE_STARTING
4055 || __pVideoRecorder->GetState() == RECORDER_STATE_PAUSING
4058 r = RemoveVideoFile();
4059 AppLogDebug("RemoveVideoFile fail[%s]", GetErrorMessage(r));
4062 StorageCardStateChaged(false);
4064 SetAppControlRequestType(APP_CONTROL_REQUEST_TYPE_FAILED);
4066 SetStorageCardChageState(STORAGE_CARD_CHAGE_STATE_MOUNT_TO_UNMOUNT);
4067 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_STORAGE_CARD_UNMOUNT);
4071 StorageCardStateChaged(true);
4072 SetStorageCardChageState(STORAGE_CARD_CHAGE_STATE_UNKNOWN);
4077 if ( IsStorageCardMounted()== false)
4079 StorageCardStateChaged(false);
4080 SetStorageCardChageState(STORAGE_CARD_CHAGE_STATE_UNKNOWN);
4084 StorageCardStateChaged(true);
4085 SetStorageCardChageState(STORAGE_CARD_CHAGE_STATE_UNKNOWN);
4091 case CAMERA_MODE_SNAPSHOT:
4093 __pCameraSettingsPresentationModel->GetValue(SECTION_CAMERA, STORAGE_TYPE, storageType);
4095 if (storageType == STORAGE_TYPE_MEMORYCARD)
4097 if ( IsStorageCardMounted()== false)
4099 AppLogDebug("OnDeviceStateChanged state=%d", __pCamera->GetState());
4101 if (GetCameraState() == CAMERA_STATE_CAPTURED || GetCameraState() == CAMERA_STATE_CAPTURING)
4103 __isStopCaptured = true;
4107 __isStopCaptured = false;
4110 StorageCardStateChaged(false);
4112 SetAppControlRequestType(APP_CONTROL_REQUEST_TYPE_FAILED);
4113 SetStorageCardChageState(STORAGE_CARD_CHAGE_STATE_MOUNT_TO_UNMOUNT);
4114 CallOnPresentationModeChanged(CAMERA_ACTION_EVENT_STORAGE_CARD_UNMOUNT);
4118 StorageCardStateChaged(true);
4119 SetStorageCardChageState(STORAGE_CARD_CHAGE_STATE_UNKNOWN);
4124 __isStopCaptured = false;
4126 if ( IsStorageCardMounted()== false)
4128 StorageCardStateChaged(false);
4129 SetStorageCardChageState(STORAGE_CARD_CHAGE_STATE_UNKNOWN);
4133 StorageCardStateChaged(true);
4134 SetStorageCardChageState(STORAGE_CARD_CHAGE_STATE_UNKNOWN);
4144 AppLogDebug("EXIT");
4148 CameraPresentationModel::RemoveVideoFile(void)
4150 AppLogDebug("ENTER");
4151 String removeFileName;
4153 result r = E_SUCCESS;
4154 int storageType = STORAGE_TYPE_PHONE;
4156 r = GetValue(STORAGE_TYPE, storageType);
4159 storageType = STORAGE_TYPE_PHONE;
4162 removeFileName = __latestContentName;
4164 AppLogDebug("removeFileName is %ls",removeFileName.GetPointer());
4165 AppLogDebug("RemoveVideoFile::GetRecorderState() = %d", __pVideoRecorder->GetState());
4166 if (__pVideoRecorder->GetState()== RECORDER_STATE_RECORDING
4167 || __pVideoRecorder->GetState() == RECORDER_STATE_PAUSED
4168 || __pVideoRecorder->GetState() == RECORDER_STATE_STARTING
4169 || __pVideoRecorder->GetState() == RECORDER_STATE_PAUSING
4175 r = file.Construct(removeFileName, "w+");
4176 TryCatch(r == E_SUCCESS, , "file::Construct() fail[%s]", GetErrorMessage(r));
4178 r = file.Remove(removeFileName);
4179 TryCatch(r == E_SUCCESS, , "file::Remove() fail[%s]", GetErrorMessage(r));
4181 AppLogDebug("EXIT");
4185 AppLogDebug("EXIT - CATCH");
4190 CameraPresentationModel::SetDisplayResolutionType(int type)
4192 AppLogDebug("ENTER");
4193 __displayResolution = type;
4194 AppLogDebug("EXIT");
4198 CameraPresentationModel::GetDisplayResolutionType(void)
4200 AppLogDebug("ENTER");
4201 AppLogDebug("EXIT");
4202 return __displayResolution;
4205 Tizen::Media::RecordingRotation
4206 CameraPresentationModel::GetRecordingRotation(void)
4208 AppLogDebug("ENTER");
4209 RecordingRotation rotate = RECORDING_ROTATION_NONE;
4210 int selfPortraitEnable = 0;
4211 result r = E_SUCCESS;
4212 int count = sizeof(_RecordRotate) / sizeof(_RecordRotate[0]);
4214 r = GetValue(SELF_PORTRAIT_ENABLE, selfPortraitEnable);
4216 for (int i=0; i < count; i++)
4218 if ((_RecordRotate[i].camType == selfPortraitEnable) && _RecordRotate[i].orientation == GetOrientation())
4220 return _RecordRotate[i].rotate;
4223 AppLogDebug("EXIT");
4228 CameraPresentationModel::OnContentScanCompleted (RequestId reqId, const Tizen::Base::String &scanPath, result r)
4230 AppLogDebug("Enter");
4231 AppLogDebug("Exit");
4235 CameraPresentationModel::SetStartPreviewException(bool status)
4237 __startPreviewException = status;
4241 CameraPresentationModel::UpdateContentFile(void)
4243 AppLogDebug("latest content name is %ls",__latestContentName.GetPointer());
4244 ContentManager::ScanFile(__latestContentName);
4245 SetAppControlRequestType(APP_CONTROL_REQUEST_TYPE_SUCCEEDED);
4249 CameraPresentationModel::SetRecordStopException(bool currentStatus)
4251 __recorderStopException = currentStatus;
4255 CameraPresentationModel::GetRecorderErrorStatus(void)
4257 return __recorderError;
4261 CameraPresentationModel::GetUpdatedContentName(Tizen::Base::String& latestContentName)
4263 latestContentName = __latestContentName;
4267 CameraPresentationModel::SetMemoryFullException(bool status)
4269 __memoryFullException = status;
4273 CameraPresentationModel::GetMemoryFullExceptionStatus(void)
4275 long long allocatedMemory = 0;
4276 bool memoryStatus = false;
4278 allocatedMemory = CmUtility::GetAvailableMemory();
4280 if (__memoryFullException && allocatedMemory < MIN_MEMORY_NEEDED)
4282 memoryStatus = true;
4285 return memoryStatus;