3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.tizenopensource.org/license
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
20 #include "AppConfig.h"
21 #include "UnitTestFactory.h"
22 #include "VideoRecorderForm.h"
23 #include "MediaPlayerForm.h"
25 using namespace Osp::Base;
26 using namespace Osp::Base::Collection;
27 using namespace Osp::Graphics;
28 using namespace Osp::Ui;
29 using namespace Osp::Ui::Controls;
30 using namespace Osp::Io;
31 using namespace Osp::App;
32 using namespace Osp::System;
36 #define SECTION_NAME L"VideoRecorder"
37 #define _TIMER_VALUE_ 500
38 #define DEFAULT_MAXTIME 60 //Sec
39 #define DEFAULT_MAXSIZE 5000 //KB
40 #define METHOD_FILE_LINENO __FUNCTION__, __FILE__, (__LINE__ - 3)
45 //Supported codec pop up
46 #define SUPPORTED_CODEC_POPUP_WIDTH 470
47 #define SUPPORTED_CODEC_POPUP_HEIGHT 480
49 #define SUPPORTED_CODEC_POPUP_BUTTON_X 150
50 #define SUPPORTED_CODEC_POPUP_BUTTON_Y 336
51 #define SUPPORTED_CODEC_POPUP_BUTTON_W 100
52 #define SUPPORTED_CODEC_POPUP_BUTTON_H 60
54 #define SUPPORTED_CODEC_POPUP_LABEL_X 0
55 #define SUPPORTED_CODEC_POPUP_LABEL_Y 0
56 #define SUPPORTED_CODEC_POPUP_LABEL_W 440
57 #define SUPPORTED_CODEC_POPUP_LABEL_H 300
58 #define SUPPORTED_CODEC_POPUP_LABEL_TEXT_FONT 30
60 /*Setting Pop coordinates*/
61 #define VR_FORM_POPUP_W 400
62 #define VR_FORM_POPUP_H 400
63 #define VR_FORM_OK_BUTTON_X 120
64 #define VR_FORM_OK_BUTTON_Y 270
65 #define VR_FORM_OK_BUTTON_W 120
66 #define VR_FORM_OK_BUTTON_H 60
68 #define VR_FORM_POPUP_SLIDER_W VR_FORM_POPUP_W
69 #define VR_FORM_POPUP_SLIDER_H 340
70 #define VR_FORM_SLIDER_X 0
71 #define VR_FORM_SLIDER_Y 30
72 #define VR_FORM_SLIDER_W (VR_FORM_POPUP_SLIDER_W - 30)
73 #define VR_FORM_SLIDER_H 150
76 #define VR_FORM_SLIDER_OK_BUTTON_X 140
77 #define VR_FORM_SLIDER_OK_BUTTON_Y 200
78 #define VR_FORM_SLIDER_OK_BUTTON_W 120
79 #define VR_FORM_SLIDER_OK_BUTTON_H 60
80 #define VR_FORM_LISTVIEW_H 250
81 #define MIN_THREAD_SLEEP_TIME 200
83 MULTI_FORM_REGISTER(VideoRecorderForm, L"VideoRecorderForm");
86 RecorderFormFunc(void* param)
88 MultiForm::ActivateForm(L"VideoRecorderForm", 0, MultiForm::GetCurrentForm(), null);
92 static UnitTestInfo tc01(L"Recorder", L"2.Video Recorder", (TestCaseFunc) RecorderFormFunc, 0);
96 Osp::Media::MediaContainerType container;
97 Osp::Media::CodecType audioCodec;
98 Osp::Media::CodecType videoCodec;
99 }VideoCodecContainerT;
101 const static VideoCodecContainerT supportedCodecContainerT[] =
103 {MEDIA_CONTAINER_3GP, CODEC_AMR_NB, CODEC_MPEG4},
104 {MEDIA_CONTAINER_3GP, CODEC_AAC, CODEC_MPEG4},
105 {MEDIA_CONTAINER_3GP, CODEC_AMR_NB, CODEC_H263},
106 {MEDIA_CONTAINER_MP4, CODEC_AAC, CODEC_MPEG4},
109 VideoRecorderForm::VideoRecorderForm(void)
111 , __pVideoRecorder(null)
113 , __pPopupMessage(null)
114 , __pPopupEffect(null)
116 , __pPopupWhiteBalance(null)
117 , __pPopupFrameRate(null)
118 , __pPopupRecordingResolution(null)
119 , __pPopupRecordingQuality(null)
120 , __pPopupVideoCodec(null)
121 , __pPopupAudioCodec(null)
122 , __pPopupFileFormat(null)
123 , __pPopupSetting(null)
124 , __pPopupExposure(null)
125 , __pPopupBrightness(null)
126 , __pPopupContrast(null)
129 , __pListViewEffect(null)
130 , __pListViewIso(null)
131 , __pListViewWhitebalance(null)
132 , __pListViewFrameRate(null)
133 , __pListViewQuality(null)
134 , __pListViewSetting(null)
135 , __pListViewRecordingResolution(null)
136 , __pListViewVideoCodec(null)
137 , __pListViewAudioCodec(null)
138 , __pListViewFileFormat(null)
139 , __pListViewFlipType(null)
140 , __pButnEffectOK(null)
142 , __pButnWhitebalanceOK(null)
143 , __pButnFrameRateOK(null)
144 , __pButnRecordingResolutionOK(null)
145 , __pButnQualityOK(null)
146 , __pButnVideoCodecOK(null)
147 , __pButnAudioCodecOK(null)
148 , __pButnFileFormatOK(null)
149 , __pButnSettingOK(null)
150 , __pButnExposureOK(null)
151 , __pButnBrightnessOK(null)
152 , __pButnContrastOK(null)
153 , __pButnZoomOK(null)
154 , __pButnFlipTypeOK(null)
155 , __pPreviewFrameRateList(null)
156 , __pRecordingResolutionList(null)
157 , __pRecorderVideoCodecList(null)
158 , __pRecorderAudioCodecList(null)
159 , __pRecorderVideoContainerList(null)
160 , __pBrightnessSlider(null)
161 , __pContrastSlider(null)
162 , __pExposureSlider(null)
163 , __pZoomLevelSlider(null)
167 , __pSupportedCodecPopup(null)
168 , __pSupportedCodecPopupLable(null)
169 , __pSupportedCodecPopupBtn(null)
170 , __pElapsedTimeLable(null)
171 , __pElapsedRecordSizeLable(null)
181 __frameRateIndex = -1;
182 __frameRateIndexSec = -1;
183 __resolutionIndex = -1;
184 __resolutionIndexSec = -1;
186 __videoCodecIndex = -1;
187 __audioCodecIndex = -1;
189 __backGround = false;
190 __currentListViewId = -1;
191 __camType = CAMERA_PRIMARY;
192 __flipType = CAMERA_FLIP_NONE;
193 __orientationStatus = ORIENTATION_STATUS_PORTRAIT;
194 __previewByCallback = 1;
196 __batteryLevelFlag = false;
197 __rotateFlagSet = false;
198 __pSettingItemArrayList = null;
199 __pEffectList = null;
204 __effectIndex = INIT;
205 __cameraError = false;
206 __brightnessSliderValue = 0;
207 __contrastSliderValue = 0;
208 __exposureSliderValue = 0;
211 VideoRecorderForm::~VideoRecorderForm(void)
213 SAFE_DELETE(__pOverlay);
214 DeletePopup(&__pPopupMessage);
215 DeletePopup(&__pPopupEffect);
216 DeletePopup(&__pPopupIso);
217 DeletePopup(&__pPopupWhiteBalance);
218 DeletePopup(&__pPopupFrameRate);
219 DeletePopup(&__pPopupRecordingResolution);
220 DeletePopup(&__pPopupRecordingQuality);
221 DeletePopup(&__pPopupVideoCodec);
222 DeletePopup(&__pPopupAudioCodec);
223 DeletePopup(&__pPopupFileFormat);
224 DeletePopup(&__pPopupSetting);
225 DeletePopup(&__pPopupExposure);
226 DeletePopup(&__pPopupBrightness);
227 DeletePopup(&__pPopupContrast);
228 DeletePopup(&__pPopupZoom);
234 SAFE_DELETE(__pTimer);
236 AppLog("VideoRecorderForm::~VideoRecorderForm");
240 VideoRecorderForm::Initialize()
242 result r = E_SUCCESS;
243 r = Construct(L"IDF_VIDEO_RECORDER");
244 AppLog("Initialize return = %s", GetErrorMessage(r));
249 VideoRecorderForm::OnInitializing(void)
251 result r = E_SUCCESS;
252 Footer* pFooter = GetFooter();
253 Header* pHeader = GetHeader();
254 Rectangle rect = GetClientAreaBounds();
255 Rectangle clientRect = GetClientAreaBounds();
258 SetHeaderText("Video Recorder");
259 SetFooterStyle(FOOTER_STYLE_BUTTON_TEXT, ID_BACK, this);
260 AddFooterItem(L"Settings", ID_SETTING);
261 AddFooterItem(L"Primary", ID_TOGGLE_CAMERA_TYPE);
262 AddFooterItem(L"Start", ID_START);
265 __startTime.Append(L"00");
266 __startTime.Append(L"");
267 __startTime.Append(L":");
268 __startTime.Append(L"00");
269 __startTime.Append(L"");
270 __startTime.Append(L":");
271 __startTime.Append(L"00");
274 __startSize.Append(L"00");
277 recSize.Append(__startSize);
278 recSize.Append(L" ");
279 recSize.Append(L"MB");
281 HideAndGetBounds(GetControl(L"IDC_BUTTON1"), rect);
282 AppLog("Original rect (%d,%d,%d,%d)", rect.x, rect.y, rect.width, rect.height);
284 __pProgress = static_cast< Progress* >(GetControl(L"IDC_PROGRESS1"));
285 if (__pProgress == null)
290 clientRect = __pProgress->GetBounds();
291 AppLog("PROGRESS BOUNDS %d %d %d %d", clientRect.x, clientRect.y, clientRect.width, clientRect.height);
293 __pElapsedTimeLable = static_cast< Label* >(GetControl(L"IDC_ELAPSEDTIME"));
294 if (__pElapsedTimeLable == null)
296 AppLog("__pElapsedTimeLable handle from UI builder is NULL");
299 __pElapsedRecordSizeLable = static_cast< Label* >(GetControl(L"IDC_ELAPSEDSIZE"));
300 if (__pElapsedRecordSizeLable == null)
302 AppLog("__pElapsedRecordSizeLable handle from UI builder is NULL");
306 __pElapsedTimeLable->SetText(__startTime);
307 __pElapsedRecordSizeLable->SetText(__startSize);
309 __pElapsedTimeLable->RequestRedraw();
310 __pElapsedRecordSizeLable->RequestRedraw();
312 __pProgress->SetValue(0);
315 __pTimer = new (std::nothrow) Osp::Base::Runtime::Timer;
316 if (__pTimer == null)
322 r = __pTimer->Construct(*this);
329 AddTouchEventListener(*this);
330 pFooter->AddTouchEventListener(*this);
331 pHeader->AddTouchEventListener(*this);
332 __pConfig = AppConfig::GetInstance();
333 if (__pConfig == null)
335 ShowError(E_FAILURE, METHOD_FILE_LINENO);
339 AddKeyEventListener(*this);
342 SAFE_DELETE(__pTimer);
347 VideoRecorderForm::ShowError(result r, const char* pMethod, const char* pSrcfileName, int lineNo)
349 AppLog("method %s file name %s line no. %d", pMethod, pSrcfileName, lineNo);
350 ShowErrorMessagePopup(SECTION_NAME, L"VideoRecorderForm", pMethod, r, pSrcfileName, lineNo, GetErrorMessage(r));
354 VideoRecorderForm::DeletePopup(Popup** pPopup)
356 if (pPopup != null && *pPopup != null)
358 (*pPopup)->RemoveAllControls();
365 VideoRecorderForm::CreatePopUp(Popup** pPopupCtrl, String title, Dimension dimension, bool hasTitle)
367 result r = E_SUCCESS;
368 Popup* pCtrl = new (std::nothrow) Popup();
375 r = pCtrl->Construct(hasTitle, dimension);
378 ShowError(r, METHOD_FILE_LINENO);
384 r = pCtrl->SetTitleText(String(title));
387 ShowError(r, METHOD_FILE_LINENO);
398 VideoRecorderForm::AddButton(Button** pButtonCtrl, String text, int actionId, Popup* pPopup, Rectangle dimension)
400 result r = E_SUCCESS;
401 Button* pCtrl = new (std::nothrow) Button();
408 r = pCtrl->Construct(dimension, text);
411 ShowError(r, METHOD_FILE_LINENO);
415 pCtrl->SetActionId(actionId);
416 pCtrl->AddActionEventListener(*this);
417 r = pPopup->AddControl(*pCtrl);
420 ShowError(r, METHOD_FILE_LINENO);
424 *pButtonCtrl = pCtrl;
431 VideoRecorderForm::ClearSupportedCodecPopup()
433 if (__pSupportedCodecPopup)
435 __pSupportedCodecPopup->RemoveAllControls();
436 __pSupportedCodecPopup->SetShowState(false);
437 SAFE_DELETE(__pSupportedCodecPopup);
442 VideoRecorderForm::GetSupportedVideoRecordingList(String* pVideoFileFormat, String* pVideoCodecType, ArrayList* pAudioCodecList)
445 tableCount = sizeof(supportedCodecContainerT) / sizeof(supportedCodecContainerT[0]);
447 String tempVideoContainer;
448 String tempVideoCodec;
449 String* pTempAudioCodec = null;
450 Osp::Media::MediaContainerType* pVideoContainer = null;
451 Osp::Media::CodecType* pAudioCodec = null;
452 Osp::Media::CodecType* pVideoCodec = null;
454 for (int i = 0; i < tableCount; i++)
456 pTempAudioCodec = null;
458 //pTempAudioCodec string is deleted when ArrayList is deleted
459 pTempAudioCodec = new (std::nothrow) String;
460 if (pTempAudioCodec == null)
462 AppLog("pTempAudioCodec failed, no memory");
465 pTempAudioCodec->Clear();
467 pVideoContainer = new (std::nothrow) MediaContainerType;
468 if (pVideoContainer == null)
470 AppLog("pVideoContainer failed, no memory");
473 *pVideoContainer = supportedCodecContainerT[i].container;
475 pVideoCodec = new (std::nothrow) CodecType;
476 if (pVideoCodec == null)
478 AppLog("pVideoCodec failed, no memory");
481 *pVideoCodec = supportedCodecContainerT[i].videoCodec;
483 pAudioCodec = new (std::nothrow) CodecType;
484 if (pAudioCodec == null)
486 AppLog("pAudioCodec failed, no memory");
489 *pAudioCodec = supportedCodecContainerT[i].audioCodec;
491 ConvertContainerToRawString(*pVideoContainer, tempVideoContainer);
492 AppLog("ConvertContainerToRawString container is %ls", tempVideoContainer.GetPointer());
494 ConvertCodecToString(*pVideoCodec, tempVideoCodec);
495 AppLog("ConvertCodecToString video codec is %ls", tempVideoCodec.GetPointer());
497 if ((String::Compare(tempVideoContainer, *pVideoFileFormat) == 0) &&
498 (String::Compare(tempVideoCodec, *pVideoCodecType) == 0))
500 ConvertCodecToString(*pAudioCodec, *pTempAudioCodec);
501 AppLog("ConvertCodecToString pTempAudioCodec is %ls", pTempAudioCodec->GetPointer());
502 pAudioCodecList->Add(*pTempAudioCodec);
505 SAFE_DELETE(pVideoContainer);
506 SAFE_DELETE(pAudioCodec);
507 SAFE_DELETE(pVideoCodec);
512 SAFE_DELETE(pTempAudioCodec);
513 SAFE_DELETE(pVideoContainer);
514 SAFE_DELETE(pAudioCodec);
515 SAFE_DELETE(pVideoCodec);
519 VideoRecorderForm::GetVideoCodecSelected(String* pVideoCodec)
521 if (__pRecorderVideoCodecList && (__pRecorderVideoCodecList->GetCount() > 0))
523 CodecType* pCodec = null;
526 pCodec = new (std::nothrow) CodecType;
529 AppLog("pCodec failed, no memory");
530 pVideoCodec->Clear();
531 pVideoCodec->Append("NULL");
535 __pRecorderVideoCodecList->GetAt(__videoCodecIndex, *pCodec);
538 AppLog("__pRecorderVideoCodecList get at index %d is wrong", __videoCodecIndex);
539 pVideoCodec->Clear();
540 pVideoCodec->Append("NULL");
545 flag = ConvertCodecToString(*pCodec, *pVideoCodec);
548 AppLog("ConvertCodecToString returned error");
556 VideoRecorderForm::GetVideoFileFormatSelected(String* pVideoFileFormat)
558 if (__pRecorderVideoContainerList && (__pRecorderVideoContainerList->GetCount() > 0))
560 MediaContainerType* pFileType = null;
563 pFileType = new (std::nothrow) MediaContainerType;
564 __pRecorderVideoContainerList->GetAt(__formatIndex, *pFileType);
565 if (pFileType == null)
567 AppLog("__pCodecTypeList get at index %d is wrong", __formatIndex);
568 pVideoFileFormat->Clear();
569 pVideoFileFormat->Append("NULL");
570 SAFE_DELETE(pFileType);
574 flag = ConvertContainerToRawString(*pFileType, *pVideoFileFormat);
577 AppLog("ConvertContainerToRawString returned error");
580 SAFE_DELETE(pFileType);
585 VideoRecorderForm::ShowSupportedCodecListPopUp()
588 String videoFileFormatSelected;
589 String videoCodecSelected;
590 ArrayList* pAudioCodecList = null;
591 result r = E_SUCCESS;
593 AppLog("VideoRecorderForm::ShowSupportedCodecListPopUp\n");
595 pAudioCodecList = new (std::nothrow) ArrayList;
596 if (pAudioCodecList == null)
598 AppLog("pAudioCodecList created failed");
601 __pSupportedCodecPopup = new (std::nothrow) Popup;
602 if (__pSupportedCodecPopup == null)
604 AppLog("__pSupportedCodecPopup creation failed");
607 __pSupportedCodecPopup->Construct(true, Dimension(SUPPORTED_CODEC_POPUP_WIDTH, SUPPORTED_CODEC_POPUP_HEIGHT));
608 __pSupportedCodecPopup->SetTitleText(L"Supported Recording Options");
610 __pSupportedCodecPopupLable = new (std::nothrow) Label;
611 if (__pSupportedCodecPopupLable == null)
613 AppLog("__pSupportedCodecPopupLable creation failed");
616 __pSupportedCodecPopupLable->Construct(Rectangle(SUPPORTED_CODEC_POPUP_LABEL_X,
617 SUPPORTED_CODEC_POPUP_LABEL_Y,
618 SUPPORTED_CODEC_POPUP_LABEL_W,
619 SUPPORTED_CODEC_POPUP_LABEL_H), L"");
620 __pSupportedCodecPopup->AddControl(*__pSupportedCodecPopupLable);
622 __pSupportedCodecPopupBtn = new (std::nothrow) Button;
623 if (__pSupportedCodecPopupBtn == null)
625 AppLog("__pSupportedCodecPopupBtn creation failed");
628 __pSupportedCodecPopupBtn->Construct(Rectangle(SUPPORTED_CODEC_POPUP_BUTTON_X,
629 SUPPORTED_CODEC_POPUP_BUTTON_Y,
630 SUPPORTED_CODEC_POPUP_BUTTON_W,
631 SUPPORTED_CODEC_POPUP_BUTTON_H),
633 __pSupportedCodecPopupBtn->SetActionId(ID_BUTTON_SUPPORTED_CODEC_POPUP_OK);
634 __pSupportedCodecPopupBtn->AddActionEventListener(*this);
636 __pSupportedCodecPopup->AddControl(*__pSupportedCodecPopupBtn);
638 __pSupportedCodecPopup->SetShowState(true);
640 GetVideoFileFormatSelected(&videoFileFormatSelected);
641 //Check if we were able to retrieve it
642 if (String::Compare(videoFileFormatSelected, String(L"NULL")) == 0)
644 AppLog("videoFileFormatSelected is NULL");
648 GetVideoCodecSelected(&videoCodecSelected);
649 //Check if we were able to retrieve it
650 if (String::Compare(videoCodecSelected, String(L"NULL")) == 0)
652 AppLog("videoCodecSelected is NULL");
656 GetSupportedVideoRecordingList(&videoFileFormatSelected, &videoCodecSelected, pAudioCodecList);
658 //Convert to simple for display
659 if (String::Compare(videoFileFormatSelected, String(L"MEDIA_CONTAINER_3GP")) == 0)
661 videoFileFormatSelected.Clear();
662 videoFileFormatSelected.Append(L"3GP");
664 else if (String::Compare(videoFileFormatSelected, String(L"MEDIA_CONTAINER_MP4")) == 0)
666 videoFileFormatSelected.Clear();
667 videoFileFormatSelected.Append(L"MP4");
674 if (pAudioCodecList->GetCount() == 0)
677 message.Append("File");
678 message.Append("\t");
679 message.Append("\t");
680 message.Append("\t");
681 message.Append("\t");
682 message.Append("\t");
683 message.Append("\t");
684 message.Append("\t");
685 message.Append("\t");
686 message.Append("Video");
687 message.Append("\t");
688 message.Append("\t");
689 message.Append("\t");
690 message.Append("\t");
691 message.Append("\t");
692 message.Append("\t");
693 message.Append("Audio");
694 message.Append("\n");
696 message.Append("Format");
697 message.Append("\t");
698 message.Append("\t");
699 message.Append("\t");
700 message.Append("\t");
701 message.Append("Codec");
702 message.Append("\t");
703 message.Append("\t");
704 message.Append("\t");
705 message.Append("\t");
706 message.Append("Codec");
707 message.Append("\n");
708 message.Append("\n");
710 message.Append("3GP");
711 message.Append("\t");
712 message.Append("\t");
713 message.Append("\t");
714 message.Append("\t");
715 message.Append("\t");
716 message.Append("\t");
717 message.Append("\t");
718 message.Append("MPEG4");
719 message.Append("\t");
720 message.Append("\t");
721 message.Append("\t");
722 message.Append("\t");
723 message.Append("\t");
724 message.Append("\t");
725 message.Append("\t");
726 message.Append("AMR");
727 message.Append("\n");
729 message.Append("3GP");
730 message.Append("\t");
731 message.Append("\t");
732 message.Append("\t");
733 message.Append("\t");
734 message.Append("\t");
735 message.Append("\t");
736 message.Append("\t");
737 message.Append("MPEG4");
738 message.Append("\t");
739 message.Append("\t");
740 message.Append("\t");
741 message.Append("\t");
742 message.Append("\t");
743 message.Append("\t");
744 message.Append("AAC");
745 message.Append("\n");
747 message.Append("3GP");
748 message.Append("\t");
749 message.Append("\t");
750 message.Append("\t");
751 message.Append("\t");
752 message.Append("\t");
753 message.Append("\t");
754 message.Append("\t");
755 message.Append("H263");
756 message.Append("\t");
757 message.Append("\t");
758 message.Append("\t");
759 message.Append("\t");
760 message.Append("\t");
761 message.Append("\t");
762 message.Append("\t");
763 message.Append("\t");
764 message.Append("\t");
765 message.Append("\t");
766 message.Append("AMR");
767 message.Append("\n");
769 message.Append("MP4");
770 message.Append("\t");
771 message.Append("\t");
772 message.Append("\t");
773 message.Append("\t");
774 message.Append("\t");
775 message.Append("\t");
776 message.Append("\t");
777 message.Append("MPEG4");
778 message.Append("\t");
779 message.Append("\t");
780 message.Append("\t");
781 message.Append("\t");
782 message.Append("\t");
783 message.Append("\t");
784 message.Append("\t");
785 message.Append("AAC");
786 message.Append("\n");
790 message.Append(L"Selected Video Format is ");
791 message.Append('\n');
792 message.Append(videoFileFormatSelected.GetPointer());
793 message.Append('\n');
794 message.Append(L"Selected Video Codec is ");
795 message.Append('\n');
796 message.Append(videoCodecSelected.GetPointer());
797 message.Append('\n');
798 message.Append('\n');
799 message.Append("Possible Audio Codec options");
800 message.Append('\n');
801 message.Append((static_cast< String* >(pAudioCodecList->GetAt(0)))->GetPointer());
804 __pSupportedCodecPopupLable->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
805 __pSupportedCodecPopupLable->SetTextConfig(SUPPORTED_CODEC_POPUP_LABEL_TEXT_FONT, LABEL_TEXT_STYLE_NORMAL);
806 __pSupportedCodecPopupLable->SetText(message);
807 __pSupportedCodecPopupLable->RequestRedraw();
809 r = __pSupportedCodecPopup->Show();
810 AppLog("__pSupportedCodecPopup Show: %s\n", GetErrorMessage(r));
812 if (pAudioCodecList->GetCount())
814 pAudioCodecList->RemoveAll(true);
817 SAFE_DELETE(pAudioCodecList);
821 SAFE_DELETE(pAudioCodecList);
822 if (__pSupportedCodecPopup)
824 __pSupportedCodecPopup->RemoveAllControls();
825 __pSupportedCodecPopup->SetShowState(false);
826 SAFE_DELETE(__pSupportedCodecPopup);
832 VideoRecorderForm::ShowPopUp(Popup* pPopUp)
834 result r = E_SUCCESS;
840 r = pPopUp->SetShowState(true);
843 ShowError(r, METHOD_FILE_LINENO);
849 ShowError(r, METHOD_FILE_LINENO);
859 VideoRecorderForm::HidePopUp(Popup* pPopUp)
865 pPopUp->SetShowState(false);
871 VideoRecorderForm::AddListView(ListView** pListView, Popup* pPopup, int id)
873 result r = E_SUCCESS;
874 Rectangle popupRect = pPopup->GetClientAreaBounds();
875 ListView* pCtrl = new (std::nothrow) ListView();
876 if (pCtrl == null && (popupRect.width > 0 && popupRect.height > 0))
881 //If listview height is lesser than popup area, use that height
882 if (popupRect.height > VR_FORM_LISTVIEW_H)
884 popupRect.height = VR_FORM_LISTVIEW_H;
887 r = pCtrl->Construct(Rectangle(0, 0, popupRect.width, popupRect.height), true, false);
890 ShowError(r, METHOD_FILE_LINENO);
894 SetCurrentListViewType(id);
895 pCtrl->SetItemProvider(*this);
896 pCtrl->AddListViewItemEventListener(*this);
897 r = pPopup->AddControl(*pCtrl);
900 ShowError(r, METHOD_FILE_LINENO);
912 VideoRecorderForm::AddSlider(Slider** pSliderCtrl, int minval, int maxval, String title, Popup* pPopup)
914 result r = E_SUCCESS;
915 Slider* pCtrl = new (std::nothrow) Slider();
922 r = pCtrl->Construct(Rectangle(VR_FORM_SLIDER_X, VR_FORM_SLIDER_Y, VR_FORM_SLIDER_W, VR_FORM_SLIDER_H), BACKGROUND_STYLE_DEFAULT, true, minval, maxval);
925 ShowError(r, METHOD_FILE_LINENO);
929 pCtrl->AddAdjustmentEventListener(*this);
930 r = pPopup->AddControl(*pCtrl);
933 ShowError(r, METHOD_FILE_LINENO);
936 *pSliderCtrl = pCtrl;
943 VideoRecorderForm::SetCurrentListViewType(int id)
945 AppLog("Enter value = %d", id);
946 __currentListViewId = id;
950 VideoRecorderForm::GetItemCount(void)
952 AppLog("Enter here ");
953 switch (__currentListViewId)
955 case ID_BUTTON_SETTING_OK:
956 case ID_BUTTON_EFFECT_OK:
957 case ID_BUTTON_ISO_OK:
958 case ID_BUTTON_WHITEBALANCE_OK:
959 case ID_BUTTON_QUALITY_OK:
960 case ID_BUTTON_FRAMERATE_OK:
961 case ID_BUTTON_RECORDINGRESOLUTION_OK:
962 case ID_BUTTON_VIDEOCODEC_OK:
963 case ID_BUTTON_AUDIOCODEC_OK:
964 case ID_BUTTON_FILEFORMAT_OK:
965 case ID_BUTTON_FLIP_OK:
967 if (__pSettingItemArrayList)
969 int count = __pSettingItemArrayList->GetCount();
970 AppLog("count = %d ", count);
987 VideoRecorderForm::OnListViewItemSwept(Osp::Ui::Controls::ListView& listView, int index, Osp::Ui::Controls::SweepDirection direction)
989 AppLog("Enter here");
992 VideoRecorderForm::OnListViewContextItemStateChanged(Osp::Ui::Controls::ListView& listView, int index, int elementId, Osp::Ui::Controls::ListContextItemStatus state)
994 AppLog("Enter here");
997 Osp::Ui::Controls::ListItemBase*
998 VideoRecorderForm::CreateItem(int index, int itemWidth)
1000 result r = E_SUCCESS;
1001 AppLog("Enter here index = %d", index);
1002 ListAnnexStyle style = (__currentListViewId != ID_BUTTON_SETTING_OK) ? LIST_ANNEX_STYLE_RADIO : LIST_ANNEX_STYLE_NORMAL;
1003 CustomItem* pItem = new (std::nothrow) CustomItem();
1008 r = pItem->Construct(Osp::Graphics::Dimension(itemWidth, LISTVIEW_ITEM_HEIGHT), style);
1011 ShowError(r, METHOD_FILE_LINENO);
1014 switch (__currentListViewId)
1016 case ID_BUTTON_SETTING_OK:
1017 case ID_BUTTON_EFFECT_OK:
1018 case ID_BUTTON_ISO_OK:
1019 case ID_BUTTON_WHITEBALANCE_OK:
1020 case ID_BUTTON_QUALITY_OK:
1021 case ID_BUTTON_FRAMERATE_OK:
1022 case ID_BUTTON_RECORDINGRESOLUTION_OK:
1023 case ID_BUTTON_VIDEOCODEC_OK:
1024 case ID_BUTTON_AUDIOCODEC_OK:
1025 case ID_BUTTON_FILEFORMAT_OK:
1026 case ID_BUTTON_FLIP_OK:
1028 if (__pSettingItemArrayList)
1030 SettingListData* pItemValue = (SettingListData*) __pSettingItemArrayList->GetAt(index);
1033 AppLog("item name at %d = %ls", index, pItemValue->pItemName->GetPointer());
1034 r = pItem->AddElement(Rectangle(0, 0, itemWidth, LISTVIEW_ITEM_HEIGHT), pItemValue->elementId, *(pItemValue->pItemName), true);
1037 ShowError(r, METHOD_FILE_LINENO);
1042 if (index == (__pSettingItemArrayList->GetCount() - 1))
1044 SAFE_DELETE_ARRAYLIST(__pSettingItemArrayList);
1051 AppLog("default case matching = %d", __currentListViewId);
1066 VideoRecorderForm::DeleteItem(int index, Osp::Ui::Controls::ListItemBase* pItem, int itemWidth)
1068 AppLog("Enter here");
1075 VideoRecorderForm::OnActivate(void* activateParam)
1077 result r = E_SUCCESS;
1083 Dimension tempDimention(INIT, INIT);
1084 CodecType tempAudioCodecType = CODEC_NONE;
1085 CodecType tempVideoCodecType = CODEC_NONE;
1086 MediaContainerType tempContainerType = MEDIA_CONTAINER_NONE;
1088 AppLog("VideoRecorderForm::OnActivate enter CAM TYPE = %d", __camType);
1090 Osp::System::BatteryLevel batteryLevel;
1091 Osp::System::Battery::GetCurrentLevel(batteryLevel);
1095 recSize.Append(__startSize);
1096 recSize.Append(L" ");
1097 recSize.Append(L"MB");
1099 if (batteryLevel == BATTERY_CRITICAL || batteryLevel == BATTERY_EMPTY || batteryLevel == BATTERY_LOW)
1101 bool isCharging = false;
1102 Osp::System::RuntimeInfo::GetValue(String(L"IsCharging"), isCharging);
1107 msgBox.Construct("Info", "Please Charge the Battery to use the recorder", MSGBOX_STYLE_OK, 3000);
1108 msgBox.ShowAndWait(reslut_a);
1109 __pProgress->SetValue(0);
1110 __pProgress->Draw();
1111 __pElapsedTimeLable->SetText(__startTime);
1112 __pElapsedRecordSizeLable->SetText(__startSize);
1114 __pElapsedTimeLable->RequestRedraw();
1115 __pElapsedRecordSizeLable->RequestRedraw();
1117 EnableFooterItem(ID_SETTING, false);
1118 EnableFooterItem(ID_TOGGLE_CAMERA_TYPE, false);
1119 EnableFooterItem(ID_START, false);
1120 __batteryLevelFlag = true;
1125 EnableFooterItem(ID_SETTING, true);
1126 EnableFooterItem(ID_START, true);
1131 EnableFooterItem(ID_SETTING, true);
1132 EnableFooterItem(ID_START, true);
1134 __batteryLevelFlag = false;
1135 __backGround = false;
1136 __cameraError = false;
1138 Osp::System::PowerManager::KeepScreenOnState(true, false);
1139 r = Osp::Media::MediaCapability::GetValue(CAMERA_COUNT, __cameraCount);
1140 AppLog("Camera Count = %d", __cameraCount);
1142 SetOrientation(ORIENTATION_AUTOMATIC);
1143 r = CreateOverlayRegion();
1149 AppLog("CreateOverlayRegion return %s", GetErrorMessage(r));
1151 __pProgress->SetValue(0);
1152 __pProgress->Draw();
1154 __pElapsedTimeLable->SetText(__startTime);
1155 __pElapsedRecordSizeLable->SetText(__startSize);
1157 __pElapsedTimeLable->RequestRedraw();
1158 __pElapsedRecordSizeLable->RequestRedraw();
1160 ShowFooterItem(0, true);
1162 if (__cameraCount > 1) //if camera count is 2 then only use secondary camera.
1164 ShowFooterItem(1, true);
1168 ShowFooterItem(1, false);
1171 ShowFooterItem(2, true);
1172 SetFooterItem(2, L"Start", ID_START);
1174 __pCamera = new (std::nothrow) Camera();
1175 if (__pCamera == null)
1177 ShowError(GetLastResult(), METHOD_FILE_LINENO);
1181 r = __pCamera->Construct(*this, __camType);
1184 ShowError(r, METHOD_FILE_LINENO);
1189 r = __pCamera->PowerOn();
1192 ShowError(r, METHOD_FILE_LINENO);
1196 __pVideoRecorder = new (std::nothrow) Osp::Media::VideoRecorder();
1197 if (__pVideoRecorder == null)
1199 ShowError(GetLastResult(), METHOD_FILE_LINENO);
1203 r = __pVideoRecorder->Construct(*this, *__pCamera);
1206 ShowError(r, METHOD_FILE_LINENO);
1210 __pPreviewFrameRateList = __pCamera->GetSupportedPreviewFrameRateListN();
1211 if (__pPreviewFrameRateList == null)
1213 ShowError(GetLastResult(), METHOD_FILE_LINENO);
1217 __pRecordingResolutionList = __pVideoRecorder->GetSupportedRecordingResolutionListN();
1218 if (__pRecordingResolutionList == null)
1220 ShowError(GetLastResult(), METHOD_FILE_LINENO);
1224 __pRecorderVideoCodecList = __pVideoRecorder->GetSupportedVideoCodecListN();
1225 if (__pRecorderVideoCodecList == null)
1227 ShowError(GetLastResult(), METHOD_FILE_LINENO);
1231 __pRecorderAudioCodecList = __pVideoRecorder->GetSupportedAudioCodecListN();
1232 if (__pRecorderAudioCodecList == null)
1234 ShowError(GetLastResult(), METHOD_FILE_LINENO);
1238 __pRecorderVideoContainerList = __pVideoRecorder->GetSupportedContainerListN();
1239 if (__pRecorderVideoContainerList == null)
1241 ShowError(GetLastResult(), METHOD_FILE_LINENO);
1245 __previewByCallback = __pConfig->GetInt(1, SECTION_NAME, String(L"previewByCallback"));
1246 AppLog("Camera __bPreviewByCallback is = %d", __previewByCallback);
1248 tempVal = (__camType == CAMERA_PRIMARY) ? __pConfig->GetInt(-1, SECTION_NAME, String(L"framerate")) : __pConfig->GetInt(-1, SECTION_NAME, String(L"framerateSec"));
1251 tempVal = __pCamera->GetPreviewFrameRate();
1254 count = __pPreviewFrameRateList->GetCount();
1256 for (index = 0; index < count; index++)
1259 r = __pPreviewFrameRateList->GetAt(index, object);
1262 ShowError(r, METHOD_FILE_LINENO);
1266 if (tempVal == object)
1268 (__camType == CAMERA_PRIMARY) ? __frameRateIndex = index : __frameRateIndexSec = index;
1275 ShowError(E_FAILURE, METHOD_FILE_LINENO);
1279 tempDimention.width = (__camType == CAMERA_PRIMARY) ? __pConfig->GetInt(-1, SECTION_NAME, String(L"resolutionWidth")) : __pConfig->GetInt(-1, SECTION_NAME, String(L"resolutionWidthSec"));
1280 tempDimention.height = (__camType == CAMERA_PRIMARY) ? __pConfig->GetInt(-1, SECTION_NAME, String(L"resolutionHeight")) : __pConfig->GetInt(-1, SECTION_NAME, String(L"resolutionHeightSec"));
1281 if ((-1 == tempDimention.width) || (-1 == tempDimention.height))
1283 tempDimention = __pVideoRecorder->GetRecordingResolution();
1286 count = __pRecordingResolutionList->GetCount();
1288 for (index = 0; index < count; index++)
1290 Dimension* pDimention = null;
1291 pDimention = static_cast< Dimension* >(__pRecordingResolutionList->GetAt(index));
1292 if (pDimention == null)
1294 ShowError(E_FAILURE, METHOD_FILE_LINENO);
1298 if (*pDimention == tempDimention)
1300 (__camType == CAMERA_PRIMARY) ? __resolutionIndex = index : __resolutionIndexSec = index;
1307 ShowError(E_FAILURE, METHOD_FILE_LINENO);
1311 tempVal = __pConfig->GetInt(-1, SECTION_NAME, String(L"videocodec"));
1314 r = __pVideoRecorder->GetFormat(tempAudioCodecType, tempVideoCodecType, tempContainerType);
1317 ShowError(r, METHOD_FILE_LINENO);
1323 tempVideoCodecType = static_cast< CodecType >(tempVal);
1326 count = __pRecorderVideoCodecList->GetCount();
1328 for (index = 0; index < count; index++)
1330 CodecType codec = CODEC_NONE;
1331 r = __pRecorderVideoCodecList->GetAt(index, codec);
1334 ShowError(r, METHOD_FILE_LINENO);
1337 if (codec == tempVideoCodecType)
1339 __videoCodecIndex = index;
1346 ShowError(E_FAILURE, METHOD_FILE_LINENO);
1350 tempVal = __pConfig->GetInt(-1, SECTION_NAME, String(L"audiocodec"));
1354 r = __pVideoRecorder->GetFormat(tempAudioCodecType, tempVideoCodecType, tempContainerType);
1357 ShowError(r, METHOD_FILE_LINENO);
1363 tempAudioCodecType = static_cast< CodecType >(tempVal);
1366 count = __pRecorderAudioCodecList->GetCount();
1368 for (index = 0; index < count; index++)
1370 CodecType codec = CODEC_NONE;
1371 r = __pRecorderAudioCodecList->GetAt(index, codec);
1374 ShowError(r, METHOD_FILE_LINENO);
1377 if (codec == tempAudioCodecType)
1379 __audioCodecIndex = index;
1386 ShowError(E_FAILURE, METHOD_FILE_LINENO);
1390 tempVal = __pConfig->GetInt(-1, SECTION_NAME, String(L"fileformat"));
1393 r = __pVideoRecorder->GetFormat(tempAudioCodecType, tempVideoCodecType, tempContainerType);
1396 ShowError(r, METHOD_FILE_LINENO);
1402 tempContainerType = static_cast< MediaContainerType >(tempVal);
1404 tempContainerType = MEDIA_CONTAINER_MP4;
1406 pTemp = (char*) &tempContainerType;
1408 AppLog("codec type %c %c %c %c", pTemp[0], pTemp[1], pTemp[2], pTemp[3]);
1410 count = __pRecorderVideoContainerList->GetCount();
1412 for (index = 0; index < count; index++)
1414 MediaContainerType container = MEDIA_CONTAINER_NONE;
1415 r = __pRecorderVideoContainerList->GetAt(index, container);
1418 ShowError(r, METHOD_FILE_LINENO);
1422 pTemp = (char*) &container;
1423 AppLog("[index = %d] codec type %c %c %c %c", index, pTemp[0], pTemp[1], pTemp[2], pTemp[3]);
1424 if (container == tempContainerType)
1426 if (__formatIndex == INIT)
1428 __formatIndex = index;
1436 ShowError(E_FAILURE, METHOD_FILE_LINENO);
1440 __qualityIndex = __pConfig->GetInt(-1, SECTION_NAME, String(L"quality"));
1441 if (__qualityIndex == -1)
1443 r = __pVideoRecorder->SetQuality(RECORDING_QUALITY_HIGH);
1446 ShowError(r, METHOD_FILE_LINENO);
1449 __qualityIndex = __pVideoRecorder->GetQuality();
1451 AppLog("quality index = %d", __qualityIndex);
1453 r = __pOverlay->GetBackgroundBufferInfo(__bufferInfo);
1456 ShowError(r, METHOD_FILE_LINENO);
1460 r = __pPreviewFrameRateList->GetAt((CAMERA_PRIMARY == __camType) ? __frameRateIndex : __frameRateIndexSec, tempVal);
1463 ShowError(r, METHOD_FILE_LINENO);
1467 tempDimention = *(Dimension*) __pRecordingResolutionList->GetAt((CAMERA_PRIMARY == __camType) ? __resolutionIndex : __resolutionIndexSec);
1469 r = __pCamera->SetPreviewResolution(tempDimention);
1472 ShowError(r, METHOD_FILE_LINENO);
1476 r = __pCamera->SetPreviewFrameRate(tempVal);
1479 ShowError(r, METHOD_FILE_LINENO);
1483 if (__previewByCallback == 1)
1485 r = __pCamera->StartPreview(NULL, true);
1488 ShowError(r, METHOD_FILE_LINENO);
1494 r = __pCamera->StartPreview(&__bufferInfo, false);
1497 ShowError(r, METHOD_FILE_LINENO);
1502 //Enable the fotter details
1503 SetFooterItem(0, String(L"Settings"), ID_SETTING);
1504 if (CAMERA_PRIMARY == __camType)
1506 SetFooterItem(1, String(L"Primary"), ID_TOGGLE_CAMERA_TYPE);
1510 SetFooterItem(1, String(L"Secondary"), ID_TOGGLE_CAMERA_TYPE);
1512 SetFooterItem(2, String(L"Start"), ID_START);
1514 ShowFooterItem(0, true);
1515 ShowFooterItem(1, true);
1516 ShowFooterItem(2, true);
1520 __cameraError = true;
1526 VideoRecorderForm::StartRecord(void)
1528 result r = E_SUCCESS;
1530 r = InitCameraRecorder();
1536 r = __pTimer->Start(_TIMER_VALUE_);
1537 if (IsFailed(r) && r != E_INVALID_STATE)
1539 ShowError(r, METHOD_FILE_LINENO);
1548 VideoRecorderForm::StopRecord()
1550 result r = E_SUCCESS;
1552 AppLog("StopRecord called");
1553 r = __pVideoRecorder->Stop();
1554 //Once stop is called. close will be called in OnVideoRecorderStopped()
1558 VideoRecorderForm::InitCameraRecorder()
1560 result r = E_SUCCESS;
1562 CodecType audioCodec = CODEC_NONE;
1563 CodecType videoCodec = CODEC_NONE;
1564 Osp::Graphics::Dimension* pResolution = null;
1565 MediaContainerType container = MEDIA_CONTAINER_NONE;
1566 String strFileFormat;
1569 __filePath.Append(Osp::App::App::GetInstance()->GetAppRootPath());
1570 __filePath.Append(__pConfig->GetString(SECTION_NAME, String(L"filename")));
1571 __filePath.Append(L".");
1573 pResolution = static_cast< Dimension* >(__pRecordingResolutionList->GetAt((__camType == CAMERA_PRIMARY) ? __resolutionIndex : __resolutionIndexSec));
1574 if (pResolution == null)
1576 ShowError(E_FAILURE, METHOD_FILE_LINENO);
1581 r = __pVideoRecorder->SetRecordingResolution(*pResolution);
1584 ShowError(r, METHOD_FILE_LINENO);
1588 r = __pRecorderVideoCodecList->GetAt(__videoCodecIndex, videoCodec);
1591 ShowError(r, METHOD_FILE_LINENO);
1595 r = __pRecorderAudioCodecList->GetAt(__audioCodecIndex, audioCodec);
1598 ShowError(r, METHOD_FILE_LINENO);
1602 r = __pRecorderVideoContainerList->GetAt(__formatIndex, container);
1605 ShowError(r, METHOD_FILE_LINENO);
1609 retVal = ConvertContainerToString(container, strFileFormat);
1613 ShowError(r, METHOD_FILE_LINENO);
1617 r = __filePath.Append(strFileFormat);
1620 ShowError(r, METHOD_FILE_LINENO);
1624 r = __pVideoRecorder->SetFormat(audioCodec, videoCodec, container);
1627 ShowSupportedCodecListPopUp();
1628 //Enable Setting and primary button
1632 r = __pVideoRecorder->SetQuality(static_cast< RecordingQuality >(__qualityIndex));
1635 ShowError(r, METHOD_FILE_LINENO);
1639 __maxRecordingTime = __pConfig->GetInt(DEFAULT_MAXTIME, SECTION_NAME, String(L"maxtime"));
1640 r = __pVideoRecorder->SetMaxRecordingTime(__maxRecordingTime * KILOBYTE);
1643 ShowError(r, METHOD_FILE_LINENO);
1649 AppLog("recording max time is = %d", __maxRecordingTime);
1650 __pProgress->SetRange(0, 100); //progress based on recorded %
1653 r = __pVideoRecorder->CreateVideoFile(__filePath, true);
1656 ShowError(r, METHOD_FILE_LINENO);
1660 r = __pVideoRecorder->Record();
1663 ShowError(r, METHOD_FILE_LINENO);
1667 AppLog("After record, state is %d", __pVideoRecorder->GetState());
1671 __pVideoRecorder->Cancel();
1672 __pVideoRecorder->Close();
1677 VideoRecorderForm::OnTerminating(void)
1679 result r = E_SUCCESS;
1681 DeletePopup(&__pPopupMessage);
1682 DeletePopup(&__pPopupEffect);
1683 DeletePopup(&__pPopupIso);
1684 DeletePopup(&__pPopupWhiteBalance);
1685 DeletePopup(&__pPopupFrameRate);
1686 DeletePopup(&__pPopupRecordingResolution);
1687 DeletePopup(&__pPopupRecordingQuality);
1688 DeletePopup(&__pPopupVideoCodec);
1689 DeletePopup(&__pPopupAudioCodec);
1690 DeletePopup(&__pPopupFileFormat);
1696 SAFE_DELETE(__pTimer);
1698 AppLog("VideoRecorderForm::OnTerminating");
1703 VideoRecorderForm::OnActionPerformed(const Osp::Ui::Control& source, int actionId)
1705 result r = E_SUCCESS;
1706 AppLog("Enter action id = %d", actionId);
1714 recSize.Append(__startSize);
1715 recSize.Append(L" ");
1716 recSize.Append(L"MB");
1719 if (__pVideoRecorder->GetState() == RECORDER_STATE_RECORDING)
1721 __pVideoRecorder->Cancel();
1727 SetFooterItem(2, L"Start", ID_START);
1728 __pProgress->SetValue(0);
1729 __pProgress->Draw();
1731 __pElapsedTimeLable->SetText(__startTime);
1732 __pElapsedRecordSizeLable->SetText(__startSize);
1734 __pElapsedTimeLable->RequestRedraw();
1735 __pElapsedRecordSizeLable->RequestRedraw();
1743 if (RECORDER_STATE_RECORDING != __pVideoRecorder->GetState())
1745 CreateSettingPopUp();
1746 ShowPopUp(__pPopupSetting);
1751 int modalResult = 0;
1752 msgBox.Construct(L"", L"Operation not allowed", MSGBOX_STYLE_NONE, 3000);
1753 msgBox.ShowAndWait(modalResult);
1758 case ID_TOGGLE_CAMERA_TYPE:
1760 if (RECORDER_STATE_RECORDING != __pVideoRecorder->GetState())
1762 ShowFooterItem(0, false);
1763 ShowFooterItem(1, false);
1764 ShowFooterItem(2, false);
1765 SendUserEvent(RECORDER_TOGGLE_CAMERA, null);
1770 int modalResult = 0;
1771 msgBox.Construct(L"", L"Operation not allowed", MSGBOX_STYLE_NONE, 3000);
1772 msgBox.ShowAndWait(modalResult);
1777 case ID_BUTTON_SETTING_OK:
1779 HidePopUp(__pPopupSetting);
1780 DeletePopup(&__pPopupSetting);
1786 Footer* pFotter = null;
1787 ShowFooterItem(0, false);
1788 ShowFooterItem(1, false);
1789 ShowFooterItem(2, false);
1790 SendUserEvent(RECORDER_START_STOP, null);
1791 pFotter = GetFooter();
1794 pFotter->SetBackButtonEnabled(false);
1800 case ID_BUTTON_EFFECT_OK:
1802 HidePopUp(__pPopupEffect);
1803 DeletePopup(&__pPopupEffect);
1807 case ID_BUTTON_ISO_OK:
1809 HidePopUp(__pPopupIso);
1810 DeletePopup(&__pPopupIso);
1814 case ID_BUTTON_WHITEBALANCE_OK:
1816 HidePopUp(__pPopupWhiteBalance);
1817 DeletePopup(&__pPopupWhiteBalance);
1821 case ID_BUTTON_FRAMERATE_OK:
1823 HidePopUp(__pPopupFrameRate);
1824 DeletePopup(&__pPopupFrameRate);
1828 case ID_BUTTON_RECORDINGRESOLUTION_OK:
1830 HidePopUp(__pPopupRecordingResolution);
1831 DeletePopup(&__pPopupRecordingResolution);
1835 case ID_BUTTON_QUALITY_OK:
1837 HidePopUp(__pPopupRecordingQuality);
1838 DeletePopup(&__pPopupRecordingQuality);
1842 case ID_BUTTON_VIDEOCODEC_OK:
1844 HidePopUp(__pPopupVideoCodec);
1845 DeletePopup(&__pPopupVideoCodec);
1849 case ID_BUTTON_AUDIOCODEC_OK:
1851 HidePopUp(__pPopupAudioCodec);
1852 DeletePopup(&__pPopupAudioCodec);
1856 case ID_BUTTON_FILEFORMAT_OK:
1858 HidePopUp(__pPopupFileFormat);
1859 DeletePopup(&__pPopupFileFormat);
1863 case ID_BUTTON_ERROR_POPUP_OK:
1866 if (__cameraError == true)
1868 AppLog("VideoRecorderForm::OnActionPerformed");
1875 case ID_BUTTON_EXPOSURE_OK:
1877 HidePopUp(__pPopupExposure);
1878 DeletePopup(&__pPopupExposure);
1879 __pExposureSlider = null;
1884 case ID_BUTTON_BRIGHTNESS_OK:
1886 HidePopUp(__pPopupBrightness);
1887 DeletePopup(&__pPopupBrightness);
1888 __pBrightnessSlider = null;
1893 case ID_BUTTON_CONTRAST_OK:
1895 HidePopUp(__pPopupContrast);
1896 DeletePopup(&__pPopupContrast);
1897 __pContrastSlider = null;
1902 case ID_BUTTON_ZOOM_OK:
1904 HidePopUp(__pPopupZoom);
1905 DeletePopup(&__pPopupZoom);
1906 __pZoomLevelSlider = null;
1911 case ID_BUTTON_FLIP_OK:
1913 CameraFlipType flipType = __pCamera->GetFlip();
1914 HidePopUp(__pPopupFlip);
1915 if (flipType != __flipType)
1917 r = __pCamera->StopPreview();
1920 ShowError(r, METHOD_FILE_LINENO);
1922 r = __pCamera->SetFlip(__flipType);
1925 ShowError(r, METHOD_FILE_LINENO);
1927 AppLog("Set Flip return = %s value = %d", GetErrorMessage(r), __flipType);
1928 if (__previewByCallback == 1)
1930 r = __pCamera->StartPreview(NULL, true);
1933 ShowError(r, METHOD_FILE_LINENO);
1938 r = __pCamera->StartPreview(&__bufferInfo, false);
1941 ShowError(r, METHOD_FILE_LINENO);
1945 DeletePopup(&__pPopupFlip);
1949 case ID_BUTTON_SUPPORTED_CODEC_POPUP_OK:
1951 ClearSupportedCodecPopup();
1963 VideoRecorderForm::ToggleCamera()
1965 AppLog("ToggleCamera is triggered ");
1967 SAFE_DELETE(__pOverlay);
1969 if (__camType == CAMERA_PRIMARY)
1971 __camType = CAMERA_SECONDARY;
1972 CreateOverlayRegion();
1973 SetFooterItem(1, L"Secondary", ID_TOGGLE_CAMERA_TYPE);
1977 __camType = CAMERA_PRIMARY;
1978 CreateOverlayRegion();
1979 SetFooterItem(1, L"Primary", ID_TOGGLE_CAMERA_TYPE);
1988 VideoRecorderForm::OnUserEventReceivedN(RequestId requestId, Osp::Base::Collection::IList* pArgs)
1990 result r = E_SUCCESS;
1991 AppLog("VideoRecorderForm::OnUserEventReceivedN : request id = %d", requestId);
1994 case RECORDER_START_STOP:
1996 if (__pVideoRecorder == null)
2000 RecorderState state = __pVideoRecorder->GetState();
2001 AppLog("recorder state = %d", state);
2002 if (state == RECORDER_STATE_STARTING)
2004 AppLog("It is trying to start the recording ");
2008 if ((RECORDER_STATE_INITIALIZED == state) || (RECORDER_STATE_OPENED == state) || \
2009 (RECORDER_STATE_PAUSED == state) || (RECORDER_STATE_CLOSED == state) || \
2010 (RECORDER_STATE_STOPPED == state))
2012 AppLog("StartRecord");
2013 __cameraError = false;
2019 AppLog("__orientationStatus set to = %d", __orientationStatus);
2020 SetOrientation((Orientation) __orientationStatus);
2021 SetFooterItem(2, L"Stop", ID_START);
2022 r = GetFooter()->Draw();
2025 ShowError(r, METHOD_FILE_LINENO);
2033 recSize.Append(__startSize);
2034 recSize.Append(L" ");
2035 recSize.Append(L"MB");
2037 SetFooterItem(2, L"Start", ID_START);
2038 ShowFooterItem(2, false);
2042 ShowError(r, METHOD_FILE_LINENO);
2045 __pProgress->SetValue(0);
2046 __pProgress->Draw();
2048 __pElapsedTimeLable->SetText(__startTime);
2049 __pElapsedRecordSizeLable->SetText(__startSize);
2051 __pElapsedTimeLable->RequestRedraw();
2052 __pElapsedRecordSizeLable->RequestRedraw();
2057 case RECORDER_ON_CLOSE:
2060 //To complete freeResource activity before launching MediaPlayerForm
2061 Osp::Base::Runtime::Thread::Sleep(MIN_THREAD_SLEEP_TIME);
2062 LaunchMediaPlayer(false);
2066 case RECORDER_ON_STOP:
2068 if (__pVideoRecorder != null)
2070 AppLog("__pVideoRecorder->Close() is called");
2071 __pVideoRecorder->Close();
2076 case RECORDER_TOGGLE_CAMERA:
2083 case RECORDER_ROTATION:
2093 __cameraError = true;
2094 Footer* pFotter = null;
2095 ShowFooterItem(0, true);
2096 ShowFooterItem(1, true);
2097 ShowFooterItem(2, true);
2098 pFotter = GetFooter();
2101 pFotter->SetBackButtonEnabled(true);
2108 VideoRecorderForm::OnCameraAutoFocused(bool completeCondition)
2114 VideoRecorderForm::OnCameraCaptured(Osp::Base::ByteBuffer& capturedData, result r)
2120 VideoRecorderForm::OnCameraErrorOccurred(CameraErrorReason r)
2126 VideoRecorderForm::OnCameraPreviewed(Osp::Base::ByteBuffer& previewedData, result r)
2128 result res = E_SUCCESS;
2131 if (__pOverlay == NULL || __pCamera == NULL || __pRecordingResolutionList == NULL)
2133 AppLog("Overlay regions is null");
2137 dataDim = (Dimension) __pCamera->GetPreviewResolution();
2139 if (dataDim.width <= 0 || dataDim.height <= 0)
2141 AppLog("dimenstion is null");
2145 PixelFormat pixelFormat = PIXEL_FORMAT_YCbCr420_PLANAR;
2146 OverlayRegionBufferPixelFormat bufferPixelFormat = OVERLAY_REGION_BUFFER_PIXEL_FORMAT_YCbCr420_PLANAR;
2147 switch (pixelFormat)
2149 case PIXEL_FORMAT_RGB565:
2150 bufferPixelFormat = OVERLAY_REGION_BUFFER_PIXEL_FORMAT_RGB565;
2153 case PIXEL_FORMAT_ARGB8888:
2154 bufferPixelFormat = OVERLAY_REGION_BUFFER_PIXEL_FORMAT_ARGB8888;
2157 case PIXEL_FORMAT_YCbCr420_PLANAR:
2158 bufferPixelFormat = OVERLAY_REGION_BUFFER_PIXEL_FORMAT_YCbCr420_PLANAR;
2164 res = __pOverlay->SetInputBuffer(previewedData, dataDim, bufferPixelFormat);
2166 // AppLog("SetInputbuffer return = %s pixel format = %d", GetErrorMessage(r), pixelFormat);
2171 VideoRecorderForm::OnListViewItemStateChanged(Osp::Ui::Controls::ListView& source, int index, int elementId, Osp::Ui::Controls::ListItemStatus status)
2173 AppLog("OnItemStateChanged enter index = %d elementId = %d", index, elementId);
2174 result r = E_SUCCESS;
2176 if (&source == __pListViewEffect)
2179 __pListViewEffect->Draw();
2180 if (__effectIndex == index)
2182 r = __pListViewEffect->SetItemChecked(index, true);
2185 ShowError(r, METHOD_FILE_LINENO);
2190 r = __pEffectList->GetAt(index, tempVal);
2193 ShowError(r, METHOD_FILE_LINENO);
2196 AppLog("__pEffectList->GetAt: tempVal = %d, r = %s", tempVal, GetErrorMessage(r));
2198 r = __pCamera->SetEffect((CameraEffect) tempVal);
2201 ShowError(r, METHOD_FILE_LINENO);
2202 __pListViewEffect->SetItemChecked(index, false);
2203 __pListViewEffect->SetItemChecked(GetIndexFromValue(__pEffectList, __pCamera->GetEffect()), true);
2207 r = __pListViewEffect->SetItemChecked(__effectIndex, false);
2210 ShowError(r, METHOD_FILE_LINENO);
2213 __effectIndex = index;
2215 else if (&source == __pListViewIso)
2218 __pListViewIso->Draw();
2219 if (__isoIndex == index)
2221 r = __pListViewIso->SetItemChecked(index, true);
2224 ShowError(r, METHOD_FILE_LINENO);
2230 r = __pIsoList->GetAt(index, tempVal);
2233 ShowError(r, METHOD_FILE_LINENO);
2237 AppLog("__pIsoList->GetAt: tempVal = %d, r = %s", tempVal, GetErrorMessage(r));
2238 r = __pCamera->SetIsoLevel((CameraIsoLevel) tempVal);
2241 ShowError(r, METHOD_FILE_LINENO);
2242 __pListViewIso->SetItemChecked(index, false);
2243 __pListViewIso->SetItemChecked(GetIndexFromValue(__pIsoList, __pCamera->GetIsoLevel()), true);
2247 r = __pListViewIso->SetItemChecked(__isoIndex, false);
2250 ShowError(r, METHOD_FILE_LINENO);
2255 else if (&source == __pListViewWhitebalance)
2258 __pListViewWhitebalance->Draw();
2259 if (__wbIndex == index)
2261 r = __pListViewWhitebalance->SetItemChecked(index, true);
2264 ShowError(r, METHOD_FILE_LINENO);
2269 r = __pWbList->GetAt(index, tempVal);
2272 ShowError(r, METHOD_FILE_LINENO);
2275 AppLog("__pWbList->GetAt: tempVal = %d, r = %s", tempVal, GetErrorMessage(r));
2277 r = __pCamera->SetWhiteBalance((CameraWhiteBalance) tempVal);
2280 ShowError(r, METHOD_FILE_LINENO);
2281 __pListViewWhitebalance->SetItemChecked(index, false);
2282 __pListViewWhitebalance->SetItemChecked(GetIndexFromValue(__pWbList, __pCamera->GetWhiteBalance()), true);
2286 r = __pListViewWhitebalance->SetItemChecked(__wbIndex, false);
2289 ShowError(r, METHOD_FILE_LINENO);
2294 else if (&source == __pListViewFrameRate)
2297 __pListViewFrameRate->Draw();
2298 if (__camType == CAMERA_PRIMARY && __frameRateIndex == index)
2300 r = __pListViewFrameRate->SetItemChecked(index, true);
2303 ShowError(r, METHOD_FILE_LINENO);
2308 if (__camType == CAMERA_SECONDARY && __frameRateIndexSec == index)
2310 r = __pListViewFrameRate->SetItemChecked(index, true);
2313 ShowError(r, METHOD_FILE_LINENO);
2319 r = __pPreviewFrameRateList->GetAt(index, tempVal);
2322 ShowError(r, METHOD_FILE_LINENO);
2326 r = __pCamera->StopPreview();
2329 ShowError(r, METHOD_FILE_LINENO);
2333 r = __pCamera->SetPreviewFrameRate(tempVal);
2336 ShowError(r, METHOD_FILE_LINENO);
2340 r = __pOverlay->GetBackgroundBufferInfo(__bufferInfo);
2343 ShowError(r, METHOD_FILE_LINENO);
2347 if (__previewByCallback == 1)
2349 r = __pCamera->StartPreview(NULL, true);
2352 ShowError(r, METHOD_FILE_LINENO);
2358 r = __pCamera->StartPreview(&__bufferInfo, false);
2361 ShowError(r, METHOD_FILE_LINENO);
2366 r = __pListViewFrameRate->SetItemChecked((__camType == CAMERA_PRIMARY ? __frameRateIndex : __frameRateIndexSec), false);
2369 ShowError(r, METHOD_FILE_LINENO);
2373 (__camType == CAMERA_PRIMARY) ? __frameRateIndex = index : __frameRateIndexSec = index;
2374 (__camType == CAMERA_PRIMARY) ? __pConfig->SetValue(SECTION_NAME, String(L"framerate"), tempVal) : __pConfig->SetValue(SECTION_NAME, String(L"framerateSec"), tempVal); //
2376 else if (&source == __pListViewRecordingResolution)
2378 Dimension* pResolution = static_cast< Dimension* >(__pRecordingResolutionList->GetAt(index));
2379 if (pResolution == null)
2381 ShowError(E_FAILURE, METHOD_FILE_LINENO);
2385 __pListViewRecordingResolution->Draw();
2387 if (__camType == CAMERA_PRIMARY && __resolutionIndex == index)
2389 r = __pListViewRecordingResolution->SetItemChecked(index, true);
2392 ShowError(r, METHOD_FILE_LINENO);
2397 if (__camType == CAMERA_SECONDARY && __resolutionIndexSec == index)
2399 r = __pListViewRecordingResolution->SetItemChecked(index, true);
2402 ShowError(r, METHOD_FILE_LINENO);
2408 r = __pCamera->StopPreview();
2411 ShowError(r, METHOD_FILE_LINENO);
2415 r = __pCamera->SetPreviewResolution(*pResolution);
2418 ShowError(r, METHOD_FILE_LINENO);
2422 r = __pOverlay->GetBackgroundBufferInfo(__bufferInfo);
2425 ShowError(r, METHOD_FILE_LINENO);
2429 if (__previewByCallback == 1)
2431 r = __pCamera->StartPreview(NULL, true);
2434 ShowError(r, METHOD_FILE_LINENO);
2440 r = __pCamera->StartPreview(&__bufferInfo, false);
2443 ShowError(r, METHOD_FILE_LINENO);
2448 r = __pListViewRecordingResolution->SetItemChecked((__camType == CAMERA_PRIMARY ? __resolutionIndex : __resolutionIndexSec), false);
2451 ShowError(r, METHOD_FILE_LINENO);
2455 (__camType == CAMERA_PRIMARY) ? __resolutionIndex = index : __resolutionIndexSec = index;
2456 (__camType == CAMERA_PRIMARY) ? __pConfig->SetValue(SECTION_NAME, String(L"resolutionWidth"), pResolution->width) : __pConfig->SetValue(SECTION_NAME, String(L"resolutionWidthSec"), pResolution->width); //
2457 (__camType == CAMERA_PRIMARY) ? __pConfig->SetValue(SECTION_NAME, String(L"resolutionHeight"), pResolution->height) : __pConfig->SetValue(SECTION_NAME, String(L"resolutionHeightSec"), pResolution->height); //
2459 else if (&source == __pListViewQuality)
2461 __pListViewQuality->Draw();
2462 if (__qualityIndex == index)
2464 r = __pListViewQuality->SetItemChecked(index, true);
2467 ShowError(r, METHOD_FILE_LINENO);
2473 r = __pListViewQuality->SetItemChecked(__qualityIndex, false);
2476 ShowError(r, METHOD_FILE_LINENO);
2479 __qualityIndex = index;
2480 __pConfig->SetValue(SECTION_NAME, String(L"quality"), __qualityIndex);
2482 else if (&source == __pListViewVideoCodec)
2484 CodecType videoCodec = CODEC_NONE;
2485 __pListViewVideoCodec->Draw();
2486 if (__videoCodecIndex == index)
2488 r = __pListViewVideoCodec->SetItemChecked(index, true);
2491 ShowError(r, METHOD_FILE_LINENO);
2497 r = __pListViewVideoCodec->SetItemChecked(__videoCodecIndex, false);
2500 ShowError(r, METHOD_FILE_LINENO);
2503 __videoCodecIndex = index;
2504 r = __pRecorderVideoCodecList->GetAt(__videoCodecIndex, videoCodec);
2507 ShowError(r, METHOD_FILE_LINENO);
2511 __pConfig->SetValue(SECTION_NAME, String(L"videocodec"), videoCodec);
2513 else if (&source == __pListViewAudioCodec)
2515 CodecType audioCodec = CODEC_NONE;
2516 __pListViewAudioCodec->Draw();
2517 if (__audioCodecIndex == index)
2519 r = __pListViewAudioCodec->SetItemChecked(index, true);
2522 ShowError(r, METHOD_FILE_LINENO);
2528 r = __pListViewAudioCodec->SetItemChecked(__audioCodecIndex, false);
2531 ShowError(r, METHOD_FILE_LINENO);
2534 __audioCodecIndex = index;
2535 r = __pRecorderAudioCodecList->GetAt(__audioCodecIndex, audioCodec);
2538 ShowError(r, METHOD_FILE_LINENO);
2541 __pConfig->SetValue(SECTION_NAME, String(L"audiocodec"), audioCodec);
2543 else if (&source == __pListViewFileFormat)
2545 MediaContainerType container = MEDIA_CONTAINER_NONE;
2546 __pListViewFileFormat->Draw();
2547 if (__formatIndex == index)
2549 r = __pListViewFileFormat->SetItemChecked(index, true);
2552 ShowError(r, METHOD_FILE_LINENO);
2558 r = __pListViewFileFormat->SetItemChecked(__formatIndex, false);
2561 ShowError(r, METHOD_FILE_LINENO);
2564 __formatIndex = index;
2565 r = __pRecorderVideoContainerList->GetAt(__formatIndex, container);
2568 ShowError(r, METHOD_FILE_LINENO);
2571 __pConfig->SetValue(SECTION_NAME, String(L"fileformat"), container);
2573 else if (&source == __pListViewFlipType)
2575 __pListViewFlipType->Draw();
2576 if (__flipType == index)
2578 r = __pListViewFlipType->SetItemChecked(index, true);
2581 ShowError(r, METHOD_FILE_LINENO);
2586 r = __pListViewFlipType->SetItemChecked(__flipType, false);
2589 ShowError(r, METHOD_FILE_LINENO);
2592 __flipType = (CameraFlipType) index;
2593 AppLog("flip type = %d selected", index);
2595 else if (&source == __pListViewSetting)
2597 HidePopUp(__pPopupSetting);
2600 case ID_MENU_BRIGHTNESS:
2601 CreateBrightnessSlider();
2604 case ID_MENU_EXPOSURE:
2605 CreateExposureSlider();
2608 case ID_MENU_CONTRAST:
2609 CreateContrastSlider();
2612 case ID_MENU_EFFECT:
2616 case ID_MENU_ISOLEVEL:
2620 case ID_MENU_WHITEBALANCE:
2621 CreateWhiteBalance();
2624 case ID_MENU_ZOOMLEVEL:
2625 CreateZoomLevelSlider();
2628 case ID_MENU_FRAME_RATE:
2632 case ID_MENU_RECORDING_RESOLUTION:
2633 CreateRecordingResolution();
2636 case ID_MENU_RECORDING_QUALITY:
2640 case ID_MENU_VIDEO_CODEC:
2644 case ID_MENU_AUDIO_CODEC:
2648 case ID_MENU_FILE_FORMAT:
2652 case ID_MENU_FLIP_TYPE:
2660 if (&source == __pListViewRecordingResolution)
2662 __pListViewRecordingResolution->Draw();
2663 __pListViewRecordingResolution->SetItemChecked(index, false);
2669 VideoRecorderForm::CreateEffect()
2671 result r = E_SUCCESS;
2672 IList* pList = null;
2673 int effectCount = 0;
2675 const mchar* EffectMap[] =
2686 DeletePopup(&__pPopupEffect);
2688 SAFE_DELETE_ARRAYLISTT(__pEffectList);
2690 if (null == __pPopupEffect)
2692 Dimension dim(VR_FORM_POPUP_W, VR_FORM_POPUP_H);
2693 Rectangle rect(VR_FORM_OK_BUTTON_X, VR_FORM_OK_BUTTON_Y, VR_FORM_OK_BUTTON_W, VR_FORM_OK_BUTTON_H);
2694 r = CreatePopUp(&__pPopupEffect, L"Effect", dim, true);
2699 r = AddButton(&__pButnEffectOK, L"OK", ID_BUTTON_EFFECT_OK, __pPopupEffect, rect);
2705 if (__camType == CAMERA_PRIMARY)
2707 pList = MediaCapability::GetValueN(CAMERA_PRIMARY_EFFECT);
2711 pList = MediaCapability::GetValueN(CAMERA_SECONDARY_EFFECT);
2714 if (pList && pList->GetCount() > 0)
2716 effectCount = pList->GetCount();
2718 SAFE_DELETE_ARRAYLIST(__pSettingItemArrayList);
2719 __pSettingItemArrayList = new (std::nothrow) ArrayList;
2720 __pEffectList = new (std::nothrow) ArrayListT< int >;
2721 for (index = 0; index < effectCount; index++)
2723 Osp::Base::Integer* effectObj = (Osp::Base::Integer*) pList->GetAt(index);
2724 int effectType = effectObj ? effectObj->ToInt() : -1;
2726 if (effectType <= 6 && effectType != -1)
2728 SettingListData* pItemData = new (std::nothrow) SettingListData(new String(EffectMap[effectType]), effectType);
2729 __pSettingItemArrayList->Add(*pItemData);
2730 __pEffectList->Add(effectType);
2731 AppLog("effect return is = %d VALUE = %ls", effectType, EffectMap[effectType]);
2735 AppLog("effect is out of range");
2739 SAFE_DELETE_ARRAYLIST(pList);
2743 r = AddListView(&__pListViewEffect, __pPopupEffect, ID_BUTTON_EFFECT_OK);
2749 __effectIndex = GetIndexFromValue(__pEffectList, __pCamera->GetEffect());
2750 if (__effectIndex == INIT)
2755 ShowPopUp(__pPopupEffect);
2756 __pListViewEffect->Draw();
2757 __pListViewEffect->SetItemChecked(GetIndexFromValue(__pEffectList, __pCamera->GetEffect()), true);
2761 DeletePopup(&__pPopupEffect);
2762 SAFE_DELETE_ARRAYLISTT(__pEffectList);
2763 AppLog("%s", GetErrorMessage(r));
2768 VideoRecorderForm::CreateISO()
2770 result r = E_SUCCESS;
2771 IList* pList = null;
2775 const mchar* isoMap[] =
2777 L"CAMERA_ISO_DEFAULT", //< The device dependent default ISO level
2778 L"CAMERA_ISO_MIN", //< The minimum supported ISO level
2779 L"AUTO", //< The auto ISO level
2780 L"50", //< The ISO 50 level
2781 L"100", //< The ISO 100 level
2782 L"200", //< The ISO 200 level
2783 L"400", //< The ISO 400 level
2784 L"800", //< The ISO 800 level
2785 L"1600", //< The ISO 1600 level
2786 L"CAMERA_ISO_MAX" //< The maximum supported ISO level
2788 DeletePopup(&__pPopupIso);
2789 SAFE_DELETE_ARRAYLISTT(__pIsoList);
2791 if (null == __pPopupIso)
2793 Dimension dim(VR_FORM_POPUP_W, VR_FORM_POPUP_H);
2794 Rectangle rect(VR_FORM_OK_BUTTON_X, VR_FORM_OK_BUTTON_Y, VR_FORM_OK_BUTTON_W, VR_FORM_OK_BUTTON_H);
2795 r = CreatePopUp(&__pPopupIso, L"Iso", dim, true);
2801 r = AddButton(&__pButnIsoOK, L"OK", ID_BUTTON_ISO_OK, __pPopupIso, rect);
2807 SAFE_DELETE_ARRAYLIST(__pSettingItemArrayList);
2808 __pSettingItemArrayList = new (std::nothrow) ArrayList;
2809 __pIsoList = new (std::nothrow) ArrayListT< int >;
2811 // Adding DEFAULT and MIN values to the iso list, since these won't
2812 // be returned by the capability class.
2813 for (index = 0; index < 2; index++)
2815 String* pIsoStrValue = new (std::nothrow) String(isoMap[index]);
2816 SettingListData* pItemData = new (std::nothrow) SettingListData(pIsoStrValue, 0);
2817 __pSettingItemArrayList->Add(*pItemData);
2818 __pIsoList->Add(index);
2819 AppLog("ISO return is = %d VALUE = %ls", index, pIsoStrValue->GetPointer());
2822 if (__camType == CAMERA_PRIMARY)
2824 pList = MediaCapability::GetValueN(CAMERA_PRIMARY_ISO_LEVEL);
2828 pList = MediaCapability::GetValueN(CAMERA_SECONDARY_ISO_LEVEL);
2831 if (pList && pList->GetCount() > 0)
2833 isoCount = pList->GetCount();
2834 for (index = 0; index < isoCount; index++)
2836 Osp::Base::Integer* isoObj = (Osp::Base::Integer*) pList->GetAt(index);
2838 int isoType = isoObj ? isoObj->ToInt() : -1;
2839 if (isoType > 0 && isoType < 9)
2841 String* pIsoStrValue = new (std::nothrow) String(isoMap[isoType]);
2842 SettingListData* pItemData = new (std::nothrow) SettingListData(pIsoStrValue, isoType);
2843 __pSettingItemArrayList->Add(*pItemData);
2844 __pIsoList->Add(isoType);
2845 AppLog("ISO return is = %d VALUE = %ls", isoType, pIsoStrValue->GetPointer());
2849 AppLog("isoType out of range");
2853 pList->RemoveAll(true);
2859 r = AddListView(&__pListViewIso, __pPopupIso, ID_BUTTON_ISO_OK);
2865 isoIndex = GetIndexFromValue(__pIsoList, __pCamera->GetIsoLevel());
2867 if (isoIndex == INIT)
2872 __isoIndex = isoIndex;
2874 ShowPopUp(__pPopupIso);
2875 __pListViewIso->Draw();
2876 __pListViewIso->SetItemChecked(isoIndex, true);
2880 DeletePopup(&__pPopupIso);
2881 SAFE_DELETE_ARRAYLISTT(__pIsoList);
2882 AppLog("%s", GetErrorMessage(r));
2887 VideoRecorderForm::CreateWhiteBalance()
2889 result r = E_SUCCESS;
2890 IList* pList = null;
2894 const mchar* whitebalance[] =
2902 DeletePopup(&__pPopupWhiteBalance);
2903 SAFE_DELETE_ARRAYLISTT(__pWbList);
2905 if (null == __pPopupWhiteBalance)
2907 Dimension dim(VR_FORM_POPUP_W, VR_FORM_POPUP_H);
2908 Rectangle rect(VR_FORM_OK_BUTTON_X, VR_FORM_OK_BUTTON_Y, VR_FORM_OK_BUTTON_W, VR_FORM_OK_BUTTON_H);
2909 r = CreatePopUp(&__pPopupWhiteBalance, L"White Balance", dim, true);
2915 r = AddButton(&__pButnWhitebalanceOK, L"OK", ID_BUTTON_WHITEBALANCE_OK, __pPopupWhiteBalance, rect);
2921 if (__camType == CAMERA_PRIMARY)
2923 pList = MediaCapability::GetValueN(CAMERA_PRIMARY_WHITE_BALANCE);
2927 pList = MediaCapability::GetValueN(CAMERA_SECONDARY_WHITE_BALANCE);
2931 if (pList && pList->GetCount() > 0)
2933 wbCount = pList->GetCount();
2934 SAFE_DELETE_ARRAYLIST(__pSettingItemArrayList);
2935 __pSettingItemArrayList = new (std::nothrow) ArrayList;
2936 __pWbList = new (std::nothrow) ArrayListT< int >;
2937 for (index = 0; index < wbCount; index++)
2939 Osp::Base::Integer* wbObj = (Osp::Base::Integer*) pList->GetAt(index);
2941 int wbType = wbObj ? wbObj->ToInt() : -1;
2942 if (wbType >= 0 && wbType <= 4)
2944 String* pWbStrValue = new (std::nothrow) String(whitebalance[wbType]);
2945 SettingListData* pItemData = new (std::nothrow) SettingListData(pWbStrValue, wbType);
2946 __pSettingItemArrayList->Add(*pItemData);
2947 __pWbList->Add(wbType);
2948 AppLog("wb return is = %d VALUE = %ls", wbType, pWbStrValue->GetPointer());
2952 AppLog("wb out of range");
2956 pList->RemoveAll(true);
2962 r = AddListView(&__pListViewWhitebalance, __pPopupWhiteBalance, ID_BUTTON_WHITEBALANCE_OK);
2968 wbIndex = GetIndexFromValue(__pWbList, __pCamera->GetWhiteBalance());
2970 if (wbIndex == INIT)
2975 __wbIndex = wbIndex;
2977 ShowPopUp(__pPopupWhiteBalance);
2978 __pListViewWhitebalance->Draw();
2979 __pListViewWhitebalance->SetItemChecked(wbIndex, true);
2984 DeletePopup(&__pPopupWhiteBalance);
2985 SAFE_DELETE_ARRAYLISTT(__pWbList);
2986 AppLog("%s", GetErrorMessage(r));
2991 VideoRecorderForm::CreateFrameRate()
2993 result r = E_SUCCESS;
2998 DeletePopup(&__pPopupFrameRate);
3000 if (null == __pPopupFrameRate)
3002 Dimension dim(VR_FORM_POPUP_W, VR_FORM_POPUP_H);
3003 Rectangle rect(VR_FORM_OK_BUTTON_X, VR_FORM_OK_BUTTON_Y, VR_FORM_OK_BUTTON_W, VR_FORM_OK_BUTTON_H);
3004 r = CreatePopUp(&__pPopupFrameRate, L"Frame Rate", dim, true);
3010 r = AddButton(&__pButnFrameRateOK, L"OK", ID_BUTTON_FRAMERATE_OK, __pPopupFrameRate, rect);
3016 if (__pPreviewFrameRateList && __pPreviewFrameRateList->GetCount() > 0)
3018 fpsCount = __pPreviewFrameRateList->GetCount();
3019 SAFE_DELETE_ARRAYLIST(__pSettingItemArrayList);
3020 __pSettingItemArrayList = new (std::nothrow) ArrayList;
3021 AppLog("fps count = %d", fpsCount);
3022 for (index = 0; index < fpsCount; index++)
3025 r = __pPreviewFrameRateList->GetAt(index, fpsType);
3027 if (fpsType > 0 && r == E_SUCCESS)
3029 String* pfpsStrValue = new (std::nothrow) String();
3030 pfpsStrValue->Append(fpsType);
3031 SettingListData* pItemData = new (std::nothrow) SettingListData(pfpsStrValue, index);
3032 __pSettingItemArrayList->Add(*pItemData);
3033 AppLog("FPS return is = %d VALUE = %ls", fpsType, pfpsStrValue->GetPointer());
3039 r = AddListView(&__pListViewFrameRate, __pPopupFrameRate, ID_BUTTON_FRAMERATE_OK);
3045 fpsIndex = GetIndexFromValue(__pPreviewFrameRateList, __pCamera->GetPreviewFrameRate());
3046 if (fpsIndex == INIT)
3051 if (__camType == CAMERA_PRIMARY)
3053 __frameRateIndex = fpsIndex;
3057 __frameRateIndexSec = fpsIndex;
3060 ShowPopUp(__pPopupFrameRate);
3061 __pListViewFrameRate->Draw();
3062 __pListViewFrameRate->SetItemChecked(fpsIndex, true);
3067 DeletePopup(&__pPopupFrameRate);
3068 SAFE_DELETE_ARRAYLIST(__pSettingItemArrayList);
3069 AppLog("%s", GetErrorMessage(r));
3074 VideoRecorderForm::CreateRecordingResolution()
3076 result r = E_SUCCESS;
3077 Dimension* dim = null;
3078 String* pRecordingResolutionStrValue = null;
3079 SettingListData* pItemData = null;
3080 Dimension recordingdim;
3081 DeletePopup(&__pPopupRecordingResolution);
3082 if (null == __pPopupRecordingResolution)
3084 Dimension dimn(VR_FORM_POPUP_W, VR_FORM_POPUP_H);
3085 Rectangle rect(VR_FORM_OK_BUTTON_X, VR_FORM_OK_BUTTON_Y, VR_FORM_OK_BUTTON_W, VR_FORM_OK_BUTTON_H);
3087 int recordResCount = __pRecordingResolutionList->GetCount();
3089 SAFE_DELETE_ARRAYLIST(__pSettingItemArrayList);
3091 if (recordResCount > 0)
3093 __pSettingItemArrayList = new (std::nothrow) ArrayList;
3100 r = CreatePopUp(&__pPopupRecordingResolution, L"Recording Resolution", dimn, true);
3106 r = AddButton(&__pButnRecordingResolutionOK, L"OK", ID_BUTTON_RECORDINGRESOLUTION_OK, __pPopupRecordingResolution, rect);
3112 for (int count = 0; count < recordResCount; count++)
3115 dim = (Dimension*) __pRecordingResolutionList->GetAt(count);
3121 strTemp.Append(dim->width);
3122 strTemp.Append(L"x");
3123 strTemp.Append(dim->height);
3125 pRecordingResolutionStrValue = new (std::nothrow) String(strTemp);
3126 pItemData = new (std::nothrow) SettingListData(pRecordingResolutionStrValue, count);
3127 __pSettingItemArrayList->Add(*pItemData);
3130 r = AddListView(&__pListViewRecordingResolution, __pPopupRecordingResolution, ID_BUTTON_RECORDINGRESOLUTION_OK);
3137 ShowPopUp(__pPopupRecordingResolution);
3138 __pListViewRecordingResolution->Draw();
3139 if (__camType == CAMERA_PRIMARY)
3141 __pListViewRecordingResolution->SetItemChecked(__resolutionIndex, true);
3145 __pListViewRecordingResolution->SetItemChecked(__resolutionIndexSec, true);
3150 DeletePopup(&__pPopupRecordingResolution);
3151 AppLog("%s", GetErrorMessage(r));
3156 VideoRecorderForm::CreateQuality()
3158 result r = E_SUCCESS;
3160 if (__pPopupRecordingQuality == null)
3163 Dimension dim(VR_FORM_POPUP_W, VR_FORM_POPUP_H);
3164 Rectangle rect(VR_FORM_OK_BUTTON_X, VR_FORM_OK_BUTTON_Y, VR_FORM_OK_BUTTON_W, VR_FORM_OK_BUTTON_H);
3166 r = CreatePopUp(&__pPopupRecordingQuality, L"Recording Quality", dim, true);
3172 r = AddButton(&__pButnQualityOK, L"OK", ID_BUTTON_QUALITY_OK, __pPopupRecordingQuality, rect);
3178 SAFE_DELETE_ARRAYLIST(__pSettingItemArrayList);
3180 __pSettingItemArrayList = new (std::nothrow) ArrayList;
3182 String* pQualityStrValue = new (std::nothrow) String(L"Low");
3183 SettingListData* pItemData = new (std::nothrow) SettingListData(pQualityStrValue, RECORDING_QUALITY_LOW);
3184 __pSettingItemArrayList->Add(*pItemData);
3186 pQualityStrValue = new (std::nothrow) String(L"Medium");
3187 pItemData = new (std::nothrow) SettingListData(pQualityStrValue, RECORDING_QUALITY_MEDIUM);
3188 __pSettingItemArrayList->Add(*pItemData);
3190 pQualityStrValue = new (std::nothrow) String(L"High");
3191 pItemData = new (std::nothrow) SettingListData(pQualityStrValue, RECORDING_QUALITY_HIGH);
3192 __pSettingItemArrayList->Add(*pItemData);
3194 r = AddListView(&__pListViewQuality, __pPopupRecordingQuality, ID_BUTTON_QUALITY_OK);
3201 if (__qualityIndex == INIT)
3206 ShowPopUp(__pPopupRecordingQuality);
3207 __pListViewQuality->Draw();
3208 __pListViewQuality->SetItemChecked(__qualityIndex, true);
3212 DeletePopup(&__pPopupRecordingQuality);
3213 AppLog("%s", GetErrorMessage(r));
3219 VideoRecorderForm::CreateVideoCodec()
3221 result r = E_SUCCESS;
3223 String* pVideoCodecStrValue = null;
3224 SettingListData* pItemData = null;
3225 DeletePopup(&__pPopupVideoCodec);
3226 if (__pPopupVideoCodec == null)
3228 int count = __pRecorderVideoCodecList->GetCount();
3229 CodecType tempCodec = CODEC_NONE;
3230 Dimension dim(VR_FORM_POPUP_W, VR_FORM_POPUP_H);
3231 Rectangle rect(VR_FORM_OK_BUTTON_X, VR_FORM_OK_BUTTON_Y, VR_FORM_OK_BUTTON_W, VR_FORM_OK_BUTTON_H);
3234 SAFE_DELETE_ARRAYLIST(__pSettingItemArrayList);
3238 __pSettingItemArrayList = new (std::nothrow) ArrayList;
3245 r = CreatePopUp(&__pPopupVideoCodec, L"Video Codec", dim, true);
3248 ShowError(r, METHOD_FILE_LINENO);
3252 r = AddButton(&__pButnVideoCodecOK, L"OK", ID_BUTTON_VIDEOCODEC_OK, __pPopupVideoCodec, rect);
3255 ShowError(r, METHOD_FILE_LINENO);
3259 for (int i = 0; i < count; i++)
3261 r = __pRecorderVideoCodecList->GetAt(i, tempCodec);
3264 ShowError(r, METHOD_FILE_LINENO);
3267 ConvertCodecToString(tempCodec, strTemp);
3268 pVideoCodecStrValue = new (std::nothrow) String(strTemp);
3269 pItemData = new (std::nothrow) SettingListData(pVideoCodecStrValue, i);
3270 __pSettingItemArrayList->Add(*pItemData);
3272 r = AddListView(&__pListViewVideoCodec, __pPopupVideoCodec, ID_BUTTON_VIDEOCODEC_OK);
3279 ShowPopUp(__pPopupVideoCodec);
3280 __pListViewVideoCodec->Draw();
3281 __pListViewVideoCodec->SetItemChecked(__videoCodecIndex, true);
3285 DeletePopup(&__pPopupVideoCodec);
3286 AppLog("%s", GetErrorMessage(r));
3291 VideoRecorderForm::CreateAudioCodec()
3293 result r = E_SUCCESS;
3295 String* pAudioCodecStrValue = null;
3296 SettingListData* pItemData = null;
3297 DeletePopup(&__pPopupAudioCodec);
3298 if (__pPopupAudioCodec == null)
3300 int count = __pRecorderAudioCodecList->GetCount();
3301 CodecType tempCodec = CODEC_NONE;
3302 Dimension dim(VR_FORM_POPUP_W, VR_FORM_POPUP_H);
3303 Rectangle rect(VR_FORM_OK_BUTTON_X, VR_FORM_OK_BUTTON_Y, VR_FORM_OK_BUTTON_W, VR_FORM_OK_BUTTON_H);
3305 SAFE_DELETE_ARRAYLIST(__pSettingItemArrayList);
3308 __pSettingItemArrayList = new (std::nothrow) ArrayList;
3315 r = CreatePopUp(&__pPopupAudioCodec, L"Audio Codec", dim, true);
3321 r = AddButton(&__pButnAudioCodecOK, L"OK", ID_BUTTON_AUDIOCODEC_OK, __pPopupAudioCodec, rect);
3324 ShowError(r, METHOD_FILE_LINENO);
3328 for (int i = 0; i < count; i++)
3330 r = __pRecorderAudioCodecList->GetAt(i, tempCodec);
3333 ShowError(r, METHOD_FILE_LINENO);
3336 ConvertCodecToString(tempCodec, strTemp);
3337 pAudioCodecStrValue = new (std::nothrow) String(strTemp);
3338 pItemData = new (std::nothrow) SettingListData(pAudioCodecStrValue, i);
3339 __pSettingItemArrayList->Add(*pItemData);
3342 r = AddListView(&__pListViewAudioCodec, __pPopupAudioCodec, ID_BUTTON_AUDIOCODEC_OK);
3349 if (__audioCodecIndex == INIT)
3353 ShowPopUp(__pPopupAudioCodec);
3354 __pListViewAudioCodec->Draw();
3355 __pListViewAudioCodec->SetItemChecked(__audioCodecIndex, true);
3359 DeletePopup(&__pPopupAudioCodec);
3360 SAFE_DELETE_ARRAYLIST(__pSettingItemArrayList);
3361 AppLog("%s", GetErrorMessage(r));
3368 VideoRecorderForm::CreateFlip()
3370 result r = E_SUCCESS;
3371 DeletePopup(&__pPopupFlip);
3372 if (__pPopupFlip == null)
3375 Dimension dim(VR_FORM_POPUP_W, VR_FORM_POPUP_H);
3376 Rectangle rect(VR_FORM_OK_BUTTON_X, VR_FORM_OK_BUTTON_Y, VR_FORM_OK_BUTTON_W, VR_FORM_OK_BUTTON_H);
3378 r = CreatePopUp(&__pPopupFlip, L"Flip Type", dim, true);
3384 r = AddButton(&__pButnFlipTypeOK, L"OK", ID_BUTTON_FLIP_OK, __pPopupFlip, rect);
3387 ShowError(r, METHOD_FILE_LINENO);
3391 SAFE_DELETE_ARRAYLIST(__pSettingItemArrayList);
3393 __pSettingItemArrayList = new (std::nothrow) ArrayList;
3395 String* pFlipStrValue = new (std::nothrow) String(L"FLIP NONE");
3396 SettingListData* pItemData = new (std::nothrow) SettingListData(pFlipStrValue, 0);
3397 __pSettingItemArrayList->Add(*pItemData);
3399 pFlipStrValue = new (std::nothrow) String(L"FLIP HORIZONTAL");
3400 pItemData = new (std::nothrow) SettingListData(pFlipStrValue, 1);
3401 __pSettingItemArrayList->Add(*pItemData);
3403 pFlipStrValue = new (std::nothrow) String(L"FLIP VERTICAL");
3404 pItemData = new (std::nothrow) SettingListData(pFlipStrValue, 2);
3405 __pSettingItemArrayList->Add(*pItemData);
3407 r = AddListView(&__pListViewFlipType, __pPopupFlip, ID_BUTTON_FLIP_OK);
3414 __flipType = __pCamera->GetFlip();
3416 AppLog("Camera return flip type = %d", __flipType);
3418 ShowPopUp(__pPopupFlip);
3419 __pListViewFlipType->Draw();
3420 __pListViewFlipType->SetItemChecked(__flipType, true);
3424 DeletePopup(&__pPopupFlip);
3425 SAFE_DELETE_ARRAYLIST(__pSettingItemArrayList);
3426 AppLog("%s", GetErrorMessage(r));
3431 VideoRecorderForm::CreateFileFormat()
3433 result r = E_SUCCESS;
3435 String* pFileFormatStrValue = null;
3436 SettingListData* pItemData = null;
3437 DeletePopup(&__pPopupFileFormat);
3438 if (__pPopupFileFormat == null)
3440 int count = __pRecorderVideoContainerList->GetCount();
3441 MediaContainerType tempFormat;
3442 Dimension dim(VR_FORM_POPUP_W, VR_FORM_POPUP_H);
3443 Rectangle rect(VR_FORM_OK_BUTTON_X, VR_FORM_OK_BUTTON_Y, VR_FORM_OK_BUTTON_W, VR_FORM_OK_BUTTON_H);
3445 r = CreatePopUp(&__pPopupFileFormat, L"File Format", dim, true);
3451 r = AddButton(&__pButnFileFormatOK, L"OK", ID_BUTTON_FILEFORMAT_OK, __pPopupFileFormat, rect);
3456 SAFE_DELETE_ARRAYLIST(__pSettingItemArrayList);
3459 __pSettingItemArrayList = new (std::nothrow) ArrayList;
3466 for (int i = 0; i < count; i++)
3468 r = __pRecorderVideoContainerList->GetAt(i, tempFormat);
3471 ShowError(r, METHOD_FILE_LINENO);
3474 ConvertContainerToString(tempFormat, strTemp);
3475 if (0 == String::Compare(strTemp, String(L"WAV")))
3478 strTemp.Append(L"Wave");
3480 pFileFormatStrValue = new (std::nothrow) String(strTemp);
3481 pItemData = new (std::nothrow) SettingListData(pFileFormatStrValue, i);
3482 __pSettingItemArrayList->Add(*pItemData);
3486 r = AddListView(&__pListViewFileFormat, __pPopupFileFormat, ID_BUTTON_FILEFORMAT_OK);
3493 if (__formatIndex == INIT)
3498 ShowPopUp(__pPopupFileFormat);
3499 __pListViewFileFormat->Draw();
3500 __pListViewFileFormat->SetItemChecked(__formatIndex, true);
3504 DeletePopup(&__pPopupFileFormat);
3505 SAFE_DELETE_ARRAYLIST(__pSettingItemArrayList);
3506 AppLog("%s", GetErrorMessage(r));
3511 VideoRecorderForm::CreateSettingPopUp()
3513 result r = E_SUCCESS;
3516 DeletePopup(&__pPopupSetting);
3517 if (__pPopupSetting == null)
3519 SettingListData* pData;
3520 Dimension dim(VR_FORM_POPUP_W, VR_FORM_POPUP_H);
3521 Rectangle rect(VR_FORM_OK_BUTTON_X, VR_FORM_OK_BUTTON_Y, VR_FORM_OK_BUTTON_W, VR_FORM_OK_BUTTON_H);
3523 r = CreatePopUp(&__pPopupSetting, L"Settings", dim, true);
3529 r = AddButton(&__pButnSettingOK, L"OK", ID_BUTTON_SETTING_OK, __pPopupSetting, rect);
3535 SAFE_DELETE_ARRAYLIST(__pSettingItemArrayList);
3537 __pSettingItemArrayList = new (std::nothrow) ArrayList();
3539 if (__camType == CAMERA_PRIMARY)
3541 r = GetMediaCapability(CAMERA_PRIMARY_SUPPORT_BRIGHTNESS, value);
3545 r = GetMediaCapability(CAMERA_SECONDARY_SUPPORT_BRIGHTNESS, value);
3547 if (value == true && r == E_SUCCESS)
3550 pData = new (std::nothrow) SettingListData(new String(L"Brightness"), (int) ID_MENU_BRIGHTNESS);
3551 __pSettingItemArrayList->Add(*pData);
3554 if (__camType == CAMERA_PRIMARY)
3556 r = GetMediaCapability(CAMERA_PRIMARY_SUPPORT_EXPOSURE, value);
3560 r = GetMediaCapability(CAMERA_SECONDARY_SUPPORT_EXPOSURE, value);
3563 if (value == true && r == E_SUCCESS)
3565 pData = new (std::nothrow) SettingListData(new String(L"Exposure"), (int) ID_MENU_EXPOSURE);
3566 __pSettingItemArrayList->Add(*pData);
3569 if (__camType == CAMERA_PRIMARY)
3571 r = GetMediaCapability(CAMERA_PRIMARY_SUPPORT_CONTRAST, value);
3575 r = GetMediaCapability(CAMERA_SECONDARY_SUPPORT_CONTRAST, value);
3577 if (value == true && r == E_SUCCESS)
3579 pData = new (std::nothrow) SettingListData(new String(L"Contrast"), (int) ID_MENU_CONTRAST);
3580 __pSettingItemArrayList->Add(*pData);
3583 if (__camType == CAMERA_PRIMARY)
3585 r = GetMediaCapability(CAMERA_PRIMARY_EFFECT);
3589 r = GetMediaCapability(CAMERA_SECONDARY_EFFECT);
3594 pData = new (std::nothrow) SettingListData(new String(L"Effect"), (int) ID_MENU_EFFECT);
3595 __pSettingItemArrayList->Add(*pData);
3597 if (__camType == CAMERA_PRIMARY)
3599 r = GetMediaCapability(CAMERA_PRIMARY_ISO_LEVEL);
3603 r = GetMediaCapability(CAMERA_SECONDARY_ISO_LEVEL);
3607 pData = new (std::nothrow) SettingListData(new String(L"IsoLevel"), (int) ID_MENU_ISOLEVEL);
3608 __pSettingItemArrayList->Add(*pData);
3611 if (__camType == CAMERA_PRIMARY)
3613 r = GetMediaCapability(CAMERA_PRIMARY_WHITE_BALANCE);
3617 r = GetMediaCapability(CAMERA_SECONDARY_WHITE_BALANCE);
3621 pData = new (std::nothrow) SettingListData(new String(L"WhiteBalance"), (int) ID_MENU_WHITEBALANCE);
3622 __pSettingItemArrayList->Add(*pData);
3625 if (__camType == CAMERA_PRIMARY)
3627 r = GetMediaCapability(CAMERA_PRIMARY_SUPPORT_ZOOM, value);
3631 r = GetMediaCapability(CAMERA_SECONDARY_SUPPORT_ZOOM, value);
3633 if (value == true && r == E_SUCCESS)
3635 pData = new (std::nothrow) SettingListData(new String(L"ZoomLevel"), (int) ID_MENU_ZOOMLEVEL);
3636 __pSettingItemArrayList->Add(*pData);
3639 if (__camType == CAMERA_PRIMARY)
3641 r = GetMediaCapability(CAMERA_PRIMARY_PREVIEW_FRAMERATE);
3645 r = GetMediaCapability(CAMERA_SECONDARY_PREVIEW_FRAMERATE);
3649 pData = new (std::nothrow) SettingListData(new String(L"Frame Rate"), (int) ID_MENU_FRAME_RATE);
3650 __pSettingItemArrayList->Add(*pData);
3653 if (__camType == CAMERA_PRIMARY)
3655 AppLog("CAMERA_PRIMARY_FLIP check");
3656 r = GetMediaCapability(CAMERA_PRIMARY_FLIP);
3660 AppLog("CAMERA_SECONDARY_FLIP check");
3661 r = GetMediaCapability(CAMERA_SECONDARY_FLIP);
3665 pData = new (std::nothrow) SettingListData(new String(L"Flip Type"), (int) ID_MENU_FLIP_TYPE);
3666 __pSettingItemArrayList->Add(*pData);
3669 if (__camType == CAMERA_PRIMARY)
3671 r = GetMediaCapability(CAMERA_PRIMARY_RECORDING_RESOLUTION);
3675 r = GetMediaCapability(CAMERA_SECONDARY_RECORDING_RESOLUTION);
3679 pData = new (std::nothrow) SettingListData(new String(L"Recording Resolution"), (int) ID_MENU_RECORDING_RESOLUTION);
3680 __pSettingItemArrayList->Add(*pData);
3684 pData = new (std::nothrow) SettingListData(new String(L"Recording Quality"), (int) ID_MENU_RECORDING_QUALITY);
3685 __pSettingItemArrayList->Add(*pData);
3687 r = GetMediaCapability(VIDEORECORDER_VIDEO_CODEC);
3690 pData = new (std::nothrow) SettingListData(new String(L"Video Codec"), (int) ID_MENU_VIDEO_CODEC);
3691 __pSettingItemArrayList->Add(*pData);
3694 r = GetMediaCapability(VIDEORECORDER_AUDIO_CODEC);
3697 pData = new (std::nothrow) SettingListData(new String(L"Audio Codec"), (int) ID_MENU_AUDIO_CODEC);
3698 __pSettingItemArrayList->Add(*pData);
3701 r = GetMediaCapability(VIDEORECORDER_FORMAT);
3704 pData = new (std::nothrow) SettingListData(new String(L"File Format"), (int) ID_MENU_FILE_FORMAT);
3705 __pSettingItemArrayList->Add(*pData);
3707 r = AddListView(&__pListViewSetting, __pPopupSetting, ID_BUTTON_SETTING_OK);
3716 DeletePopup(&__pPopupSetting);
3717 SAFE_DELETE_ARRAYLIST(__pSettingItemArrayList);
3718 AppLog("%s", GetErrorMessage(r));
3725 VideoRecorderForm::OnVideoRecorderCanceled(result r)
3727 AppLog("RECORDER_STATE_RECORDING");
3733 VideoRecorderForm::OnVideoRecorderClosed(result r)
3735 AppLog("VideoRecorderForm::OnVideoRecorderClosed");
3737 if (!__backGround && __cameraError == false)
3739 SendUserEvent(RECORDER_ON_CLOSE, null);
3744 VideoRecorderForm::OnVideoRecorderEndReached(Osp::Media::RecordingEndCondition endCondition)
3746 AppLog("VideoRecorderForm::OnVideoRecorderEndReached ");
3747 __pVideoRecorder->Close();
3749 SetFooterItem(2, L"Start", ID_START);
3750 __pProgress->SetValue(100);
3751 __pProgress->Draw();
3752 __pProgress->Show();
3756 VideoRecorderForm::OnVideoRecorderErrorOccurred(Osp::Media::RecorderErrorReason r)
3758 AppLog("VideoRecorderForm::OnVideoRecorderErrorOccurred");
3759 __pVideoRecorder->Close();
3763 ShowError(r, METHOD_FILE_LINENO);
3771 VideoRecorderForm::OnVideoRecorderPaused(result r)
3773 AppLog("VideoRecorderForm::OnVideoRecorderPaused");
3777 VideoRecorderForm::OnVideoRecorderStarted(result r)
3779 Footer* pFotter = null;
3780 AppLog("OnVideoRecorderStarted");
3781 ShowFooterItem(0, true);
3782 ShowFooterItem(1, true);
3783 ShowFooterItem(2, true);
3784 pFotter = GetFooter();
3787 pFotter->SetBackButtonEnabled(true);
3793 VideoRecorderForm::OnVideoRecorderStopped(result r)
3795 Footer* pFotter = null;
3796 AppLog("VideoRecorderForm::OnVideoRecorderStopped ");
3797 SendUserEvent(RECORDER_ON_STOP, null);
3798 ShowFooterItem(0, true);
3799 ShowFooterItem(1, true);
3800 ShowFooterItem(2, true);
3801 pFotter = GetFooter();
3804 pFotter->SetBackButtonEnabled(true);
3810 VideoRecorderForm::LaunchMediaPlayer(bool flag)
3812 result r = E_SUCCESS;
3813 MediaPlayerForm* pMediaPlayerForm = null;
3814 Frame* pFrame = null;
3818 AppLog("MediaPlayerForm's LaunchMediaPlayer invoked file path %ls", __filePath.GetPointer());
3821 mediaType.Append(L"VIDEO");
3823 pMediaPlayerForm = new (std::nothrow) MediaPlayerForm(this, &mediaType, &__filePath);
3824 if (pMediaPlayerForm == null)
3826 AppLog("pMediaPlayerForm failed , no memory");
3830 if (pMediaPlayerForm->Initialize() == false)
3832 AppLog("pMediaPlayerForm->Initialize() failed");
3836 // Add the form to the frame
3837 pFrame = Osp::App::UiApp::GetInstance()->GetAppFrame()->GetFrame();
3840 AppLog("pFrame returned null");
3843 r = pFrame->AddControl(*pMediaPlayerForm);
3846 ShowError(r, METHOD_FILE_LINENO);
3847 AppLog("pFrame->AddControl failed %s", GetErrorMessage(r));
3851 // Set the current form
3852 r = pFrame->SetCurrentForm(*pMediaPlayerForm);
3855 ShowError(r, METHOD_FILE_LINENO);
3856 AppLog("pFrame->SetCurrentForm failed %s", GetErrorMessage(r));
3861 // Draw and Show the form
3862 pMediaPlayerForm->Draw();
3863 pMediaPlayerForm->Show();
3865 if (pMediaPlayerForm->Start() == false)
3867 ShowError(r, METHOD_FILE_LINENO);
3868 AppLog("pMediaPlayerForm->Start()");
3875 VideoRecorderForm::LaunchMediaPlayer()
3877 result r = E_SUCCESS;
3878 ArrayList* pDataList = null;
3879 String* pData = null;
3884 AppControl* pAc = AppManager::FindAppControlN(L"http://tizen.org/appcontrol/provider/video", L"http://tizen.org/appcontrol/operation/play");
3887 ShowError(GetLastResult(), METHOD_FILE_LINENO);
3891 pDataList = new (std::nothrow) ArrayList();
3892 if (pDataList == null)
3894 ShowError(GetLastResult(), METHOD_FILE_LINENO);
3898 r = pDataList->Construct();
3901 ShowError(r, METHOD_FILE_LINENO);
3906 pData = new (std::nothrow) String(L"type:video");
3909 ShowError(GetLastResult(), METHOD_FILE_LINENO);
3913 r = pDataList->Add(*pData);
3916 ShowError(r, METHOD_FILE_LINENO);
3920 pData = new (std::nothrow) String(L"path:");
3923 ShowError(GetLastResult(), METHOD_FILE_LINENO);
3926 (*pData).Append(__filePath);
3927 r = pDataList->Add(*pData);
3930 ShowError(r, METHOD_FILE_LINENO);
3934 r = pAc->Start(pDataList, null);
3937 ShowError(r, METHOD_FILE_LINENO);
3945 pDataList->RemoveAll(true);
3947 SAFE_DELETE(pDataList);
3949 __backGround = true;
3950 SetOrientation(ORIENTATION_AUTOMATIC);
3957 pDataList->RemoveAll(true);
3959 SAFE_DELETE(pDataList);
3965 VideoRecorderForm::GetMediaCapability(String key, bool& Value)
3967 result r = E_SUCCESS;
3968 r = MediaCapability::GetValue(key, Value);
3969 AppLog("GetMediaCapability for %ls value = %d return = %s", key.GetPointer(), Value, GetErrorMessage(r));
3974 VideoRecorderForm::GetMediaCapability(String key)
3976 result r = E_FAILURE;
3977 IList* pList = null;
3978 pList = MediaCapability::GetValueN(key);
3980 if (pList && pList->GetCount() > 0)
3983 pList->RemoveAll(true);
3987 AppLog("GetMediaCapability for %ls return = %s", key.GetPointer(), GetErrorMessage(r));
3992 VideoRecorderForm::OnTimerExpired(Osp::Base::Runtime::Timer& timer)
3994 AppLog("VideoRecorderForm::OnTimerExpired");
3995 if (&timer == __pTimer && __pVideoRecorder != null)
3997 long duration = __pVideoRecorder->GetRecordingTime();
3998 long recordedSize = __pVideoRecorder->GetRecordingSize(); //size is in KB
3999 if (__maxRecordingTime && (duration > 0) && (recordedSize > 0))
4004 // (duration / 1000) ==>convert to seconds
4005 // (((duration / 1000)/__maxRecordingTime))*100 ==> convert to %
4006 int currTimePer = (duration) / (__maxRecordingTime * 10);
4008 int recSizeMB = recordedSize / KILOBYTE;
4010 AppLog("Recorded Duration = %d current time percentage = %d recorded size = %d", duration, currTimePer, recordedSize);
4012 __pProgress->SetValue(currTimePer);
4014 __pProgress->Draw();
4015 __pProgress->Show();
4017 sec = duration / KILOBYTE;
4018 min = sec / SIXTY_SECS;
4019 sec = sec - min * SIXTY_SECS;
4020 hour = min / SIXTY_SECS;
4021 min = min - hour * SIXTY_SECS;
4023 String endtime = L"";
4025 endtime.Append(L"0");
4026 endtime.Append(hour);
4027 endtime.Append(L"");
4028 endtime.Append(L":");
4030 endtime.Append(L"0");
4031 endtime.Append(min);
4032 endtime.Append(L"");
4033 endtime.Append(L":");
4035 endtime.Append(L"0");
4036 endtime.Append(sec);
4039 if (recSizeMB < TEN)
4041 size.Append(recSizeMB);
4043 __pElapsedRecordSizeLable->SetText(size);
4044 __pElapsedRecordSizeLable->RequestRedraw();
4046 __pElapsedTimeLable->SetText(endtime);
4047 __pElapsedTimeLable->RequestRedraw();
4050 timer.Start(_TIMER_VALUE_);
4054 VideoRecorderForm::CreateExposureSlider()
4056 result r = E_SUCCESS;
4060 if (__pPopupExposure == null)
4062 Dimension dim(VR_FORM_POPUP_SLIDER_W, VR_FORM_POPUP_SLIDER_H);
4063 Rectangle rect(VR_FORM_SLIDER_OK_BUTTON_X, VR_FORM_SLIDER_OK_BUTTON_Y, VR_FORM_SLIDER_OK_BUTTON_W, VR_FORM_SLIDER_OK_BUTTON_H);
4064 r = CreatePopUp(&__pPopupExposure, L"Exposure", dim, true);
4069 r = AddSlider(&__pExposureSlider, 0, 9, L"", __pPopupExposure);
4074 r = AddButton(&__pButnExposureOK, L"OK", ID_BUTTON_EXPOSURE_OK, __pPopupExposure, rect);
4081 exposure = __pCamera->GetExposure();
4082 if (IsFailed(GetLastResult()))
4084 ShowError(r, METHOD_FILE_LINENO);
4088 if (__exposureSliderValue != exposure &&
4089 __exposureSliderValue != 0)
4091 exposure = __exposureSliderValue;
4094 __pExposureSlider->SetValue(exposure);
4095 strTemp.Format(50, L"Exposure : %d", exposure);
4096 __pExposureSlider->SetTitleText(strTemp);
4098 EnableFooterItem(ID_SETTING, false);
4099 EnableFooterItem(ID_TOGGLE_CAMERA_TYPE, false);
4100 EnableFooterItem(ID_START, false);
4102 ShowPopUp(__pPopupExposure);
4106 AppLog(" VideoRecorderForm::CreateExposureSlider() failed");
4107 DeletePopup(&__pPopupExposure);
4112 VideoRecorderForm::CreateBrightnessSlider()
4114 result r = E_SUCCESS;
4118 if (__pPopupBrightness == null)
4120 Dimension dim(VR_FORM_POPUP_SLIDER_W, VR_FORM_POPUP_SLIDER_H);
4121 Rectangle rect(VR_FORM_SLIDER_OK_BUTTON_X, VR_FORM_SLIDER_OK_BUTTON_Y, VR_FORM_SLIDER_OK_BUTTON_W, VR_FORM_SLIDER_OK_BUTTON_H);
4122 r = CreatePopUp(&__pPopupBrightness, L"Brightness", dim, true);
4127 r = AddSlider(&__pBrightnessSlider, 0, 9, L"", __pPopupBrightness);
4132 r = AddButton(&__pButnBrightnessOK, L"OK", ID_BUTTON_BRIGHTNESS_OK, __pPopupBrightness, rect);
4139 brightness = __pCamera->GetBrightness();
4140 if (IsFailed(GetLastResult()))
4142 ShowError(r, METHOD_FILE_LINENO);
4146 if (__brightnessSliderValue != brightness &&
4147 __brightnessSliderValue != 0)
4149 brightness = __brightnessSliderValue;
4152 __pBrightnessSlider->SetValue(brightness);
4153 strTemp.Format(50, L"Brightness : %d", brightness);
4154 __pBrightnessSlider->SetTitleText(strTemp);
4156 ShowPopUp(__pPopupBrightness);
4158 EnableFooterItem(ID_SETTING, false);
4159 EnableFooterItem(ID_TOGGLE_CAMERA_TYPE, false);
4160 EnableFooterItem(ID_START, false);
4161 GetFooter()->SetBackButtonEnabled(false);
4162 GetFooter()->Draw();
4166 AppLog("VideoRecorderForm::CreateBrightnessSlider() failed");
4167 DeletePopup(&__pPopupBrightness);
4172 VideoRecorderForm::CreateContrastSlider()
4174 result r = E_SUCCESS;
4178 if (__pPopupContrast == null)
4180 Dimension dim(VR_FORM_POPUP_SLIDER_W, VR_FORM_POPUP_SLIDER_H);
4181 Rectangle rect(VR_FORM_SLIDER_OK_BUTTON_X, VR_FORM_SLIDER_OK_BUTTON_Y, VR_FORM_SLIDER_OK_BUTTON_W, VR_FORM_SLIDER_OK_BUTTON_H);
4182 r = CreatePopUp(&__pPopupContrast, L"Contrast", dim, true);
4187 r = AddSlider(&__pContrastSlider, 0, 9, L"", __pPopupContrast);
4192 r = AddButton(&__pButnContrastOK, L"OK", ID_BUTTON_CONTRAST_OK, __pPopupContrast, rect);
4199 contrast = __pCamera->GetContrast();
4200 if (IsFailed(GetLastResult()))
4202 ShowError(r, METHOD_FILE_LINENO);
4206 if (__contrastSliderValue != contrast &&
4207 __contrastSliderValue != 0)
4209 contrast = __contrastSliderValue;
4212 __pContrastSlider->SetValue(contrast);
4213 strTemp.Format(50, L"Contrast : %d", contrast);
4214 __pContrastSlider->SetTitleText(strTemp);
4216 EnableFooterItem(ID_SETTING, false);
4217 EnableFooterItem(ID_TOGGLE_CAMERA_TYPE, false);
4218 EnableFooterItem(ID_START, false);
4219 GetFooter()->SetBackButtonEnabled(false);
4220 GetFooter()->Draw();
4222 ShowPopUp(__pPopupContrast);
4225 AppLog("VideoRecorderForm::Contrast() failed");
4226 DeletePopup(&__pPopupContrast);
4231 VideoRecorderForm::CreateZoomLevelSlider()
4233 result r = E_SUCCESS;
4237 AppLog("VideoRecorderForm::CreateZoomLevelSlider() ");
4239 if (__pPopupZoom == null)
4241 zoom = __pCamera->GetMaxZoomLevel();
4244 if (IsFailed(GetLastResult()))
4246 ShowError(r, METHOD_FILE_LINENO);
4251 Dimension dim(VR_FORM_POPUP_SLIDER_W, VR_FORM_POPUP_SLIDER_H);
4252 Rectangle rect(VR_FORM_SLIDER_OK_BUTTON_X, VR_FORM_SLIDER_OK_BUTTON_Y, VR_FORM_SLIDER_OK_BUTTON_W, VR_FORM_SLIDER_OK_BUTTON_H);
4253 r = CreatePopUp(&__pPopupZoom, L"Zoom Level", dim, true);
4258 r = AddSlider(&__pZoomLevelSlider, 0, zoom, L"", __pPopupZoom);
4263 r = AddButton(&__pButnZoomOK, L"OK", ID_BUTTON_ZOOM_OK, __pPopupZoom, rect);
4270 zoom = __pCamera->GetZoomLevel();
4272 __pZoomLevelSlider->SetValue(zoom);
4273 strTemp.Format(50, L"Zoom : %d", zoom);
4274 __pZoomLevelSlider->SetTitleText(strTemp);
4276 ShowPopUp(__pPopupZoom);
4278 EnableFooterItem(ID_SETTING, false);
4279 EnableFooterItem(ID_TOGGLE_CAMERA_TYPE, false);
4280 EnableFooterItem(ID_START, false);
4281 GetFooter()->SetBackButtonEnabled(false);
4282 GetFooter()->Draw();
4286 AppLog("VideoRecorderForm::CreateZoomLevelSlider() failed");
4287 DeletePopup(&__pPopupZoom);
4291 VideoRecorderForm::OnAdjustmentValueChanged(const Osp::Ui::Control& source, int adjustment)
4293 result r = E_SUCCESS;
4296 AppLog("VideoRecorderForm::OnAdjustmentValueChanged() called");
4301 if (&source == __pBrightnessSlider)
4303 r = __pCamera->SetBrightness(adjustment);
4306 ShowError(r, METHOD_FILE_LINENO);
4309 strTemp.Format(50, L"Brightness : %d", adjustment);
4310 __pBrightnessSlider->SetTitleText(strTemp);
4311 __pBrightnessSlider->Draw();
4313 __brightnessSliderValue = adjustment;
4315 else if (&source == __pContrastSlider)
4317 r = __pCamera->SetContrast(adjustment);
4320 ShowError(r, METHOD_FILE_LINENO);
4323 strTemp.Format(50, L"Contrast : %d", adjustment);
4324 __pContrastSlider->SetTitleText(strTemp);
4325 __pContrastSlider->Draw();
4327 __contrastSliderValue = adjustment;
4329 else if (&source == __pExposureSlider)
4331 r = __pCamera->SetExposure(adjustment);
4334 ShowError(r, METHOD_FILE_LINENO);
4337 strTemp.Format(50, L"Exposure : %d", adjustment);
4338 __pExposureSlider->SetTitleText(strTemp);
4339 __pExposureSlider->Draw();
4341 __exposureSliderValue = adjustment;
4343 else if (&source == __pZoomLevelSlider)
4345 int zoomValue = __pCamera->GetZoomLevel();
4346 if (zoomValue < adjustment)
4348 for (int i = zoomValue; i < adjustment; i++)
4350 r = __pCamera->ZoomIn();
4353 ShowError(r, METHOD_FILE_LINENO);
4360 for (int i = zoomValue; i > adjustment; i--)
4362 r = __pCamera->ZoomOut();
4365 ShowError(r, METHOD_FILE_LINENO);
4370 strTemp.Format(50, L"Zoom : %d", adjustment);
4371 __pZoomLevelSlider->SetTitleText(strTemp);
4372 __pZoomLevelSlider->SetValue(__pCamera->GetZoomLevel());
4373 __pZoomLevelSlider->Draw();
4378 AppLog("VideoRecorderForm::OnAdjustmentValueChanged() failed");
4385 VideoRecorderForm::OnTouchReleased(const Osp::Ui::Control& source, const Osp::Graphics::Point& currentPosition, const Osp::Ui::TouchEventInfo& touchInfo)
4387 AppLog("VideoRecorderForm::OnTouchReleased() ");
4391 VideoRecorderForm::OnBackground(void)
4394 AppLog("VideoRecorderForm::OnBackground Enter");
4396 if (__pVideoRecorder)
4398 AppLog("VideoRecorderForm::OnBackground setting");
4401 __backGround = true;
4402 __pProgress->SetValue(0);
4406 VideoRecorderForm::OnForeground(void)
4408 AppLog("VideoRecorderForm::OnForeground Enter");
4410 if (__backGround == true)
4412 VideoRecorderForm::OnActivate(null);
4413 AppLog("VideoRecorderForm::OnForeground Enter 1");
4416 AppLog("VideoRecorderForm::OnForeground Exit");
4417 __backGround = false;
4422 VideoRecorderForm::ConvertContainerToRawString(MediaContainerType& containerType, String& strString)
4426 switch (containerType)
4428 case MEDIA_CONTAINER_NONE:
4430 strString.Append(L"MEDIA_CONTAINER_NONE");
4435 case MEDIA_CONTAINER_WAV:
4436 strString.Append(L"MEDIA_CONTAINER_WAV");
4439 case MEDIA_CONTAINER_AMR:
4440 strString.Append(L"MEDIA_CONTAINER_AMR");
4443 case MEDIA_CONTAINER_AAC:
4444 strString.Append(L"MEDIA_CONTAINER_AAC");
4447 case MEDIA_CONTAINER_MP3:
4448 strString.Append(L"MEDIA_CONTAINER_MP3");
4451 case MEDIA_CONTAINER_FLAC:
4452 strString.Append(L"MEDIA_CONTAINER_FLAC");
4455 case MEDIA_CONTAINER_3GP:
4456 strString.Append(L"MEDIA_CONTAINER_3GP");
4459 case MEDIA_CONTAINER_MP4:
4460 strString.Append(L"MEDIA_CONTAINER_MP4");
4463 case MEDIA_CONTAINER_AVI:
4464 strString.Append(L"MEDIA_CONTAINER_AVI");
4467 case MEDIA_CONTAINER_ASF:
4468 strString.Append(L"MEDIA_CONTAINER_ASF");
4471 case MEDIA_CONTAINER_MKV:
4472 strString.Append(L"MEDIA_CONTAINER_MKV");
4475 case MEDIA_CONTAINER_MOV:
4476 strString.Append(L"MEDIA_CONTAINER_MOV");
4479 case MEDIA_CONTAINER_OGG:
4480 strString.Append(L"MEDIA_CONTAINER_OGG");
4483 case MEDIA_CONTAINER_UNKNOWN:
4485 strString.Append(L"MEDIA_CONTAINER_UNKNOWN");
4498 VideoRecorderForm::ConvertContainerToString(MediaContainerType& containerType, String& strString)
4502 switch (containerType)
4504 case MEDIA_CONTAINER_NONE:
4508 case MEDIA_CONTAINER_WAV:
4509 strString.Append(L"WAV");
4512 case MEDIA_CONTAINER_AMR:
4513 strString.Append(L"AMR");
4516 case MEDIA_CONTAINER_AAC:
4517 strString.Append(L"AAC");
4520 case MEDIA_CONTAINER_MP3:
4521 strString.Append(L"MP3");
4524 case MEDIA_CONTAINER_FLAC:
4525 strString.Append(L"FLAC");
4528 case MEDIA_CONTAINER_3GP:
4529 strString.Append(L"3GP");
4532 case MEDIA_CONTAINER_MP4:
4533 strString.Append(L"MP4");
4536 case MEDIA_CONTAINER_AVI:
4537 strString.Append(L"AVI");
4540 case MEDIA_CONTAINER_ASF:
4541 strString.Append(L"ASF");
4544 case MEDIA_CONTAINER_MKV:
4545 strString.Append(L"MKV");
4548 case MEDIA_CONTAINER_MOV:
4549 strString.Append(L"MOV");
4552 case MEDIA_CONTAINER_OGG:
4553 strString.Append(L"OGG");
4556 case MEDIA_CONTAINER_UNKNOWN:
4567 VideoRecorderForm::ConvertCodecToString(CodecType& codecType, String& strString)
4578 strString.Append(L"Linear PCM");
4582 strString.Append(L"G.711 A-Law");
4586 strString.Append(L"G.711 u-Law");
4589 case CODEC_IMA_ADPCM:
4590 strString.Append(L"IMA ADPCM");
4593 case CODEC_MS_ADPCM:
4594 strString.Append(L"MS ADPCM");
4598 strString.Append(L"AMR-NB");
4602 strString.Append(L"FLAC");
4606 strString.Append(L"MP3");
4610 strString.Append(L"AAC");
4614 strString.Append(L"Enhanced AAC");
4617 case CODEC_HEAAC_V2:
4618 strString.Append(L"Enhanced AAC V2");
4622 strString.Append(L"AC-3");
4626 strString.Append(L"VORBIS");
4630 strString.Append(L"WMA");
4634 strString.Append(L"MIDI");
4638 strString.Append(L"H.263");
4642 strString.Append(L"MPEG4");
4646 strString.Append(L"H.264");
4650 strString.Append(L"THEORA");
4654 strString.Append(L"WMV");
4658 strString.Append(L"JPEG");
4662 strString.Append(L"PNG");
4666 strString.Append(L"GIF");
4685 VideoRecorderForm::FreeResources()
4687 AppLog("VideoRecorderForm::FreeResources enter");
4688 if (__pVideoRecorder)
4690 __pVideoRecorder->Cancel();
4691 __pVideoRecorder->Close();
4694 if (__pCamera && __pCamera->IsPoweredOn())
4696 __pCamera->StopPreview();
4699 if (__pCamera && __pCamera->IsPoweredOn())
4701 __pCamera->PowerOff();
4704 SAFE_DELETE(__pVideoRecorder);
4705 SAFE_DELETE(__pCamera);
4706 SAFE_DELETE(__pOverlay);
4708 SAFE_DELETE_ARRAYLIST(__pSettingItemArrayList);
4709 SAFE_DELETE_ARRAYLISTT(__pPreviewFrameRateList);
4710 SAFE_DELETE_ARRAYLISTT(__pRecorderVideoCodecList);
4711 SAFE_DELETE_ARRAYLISTT(__pRecorderAudioCodecList);
4712 SAFE_DELETE_ARRAYLISTT(__pRecorderVideoContainerList);
4713 SAFE_DELETE_ARRAYLIST(__pRecordingResolutionList);
4714 SAFE_DELETE_ARRAYLISTT(__pEffectList);
4715 SAFE_DELETE_ARRAYLISTT(__pIsoList);
4716 SAFE_DELETE_ARRAYLISTT(__pWbList);
4720 VideoRecorderForm::OnFormBackRequested(Osp::Ui::Controls::Form& source)
4722 AppLog("VideoRecorderForm::OnFormBackRequested called");
4724 if (__pTimer != null)
4729 //When Back is pressed, then perform FreeResource(), cancel
4730 //and close VideoRecording
4733 SetFooterItem(2, L"Start", ID_START);
4738 VideoRecorderForm::CreateOverlayRegion()
4740 Rectangle rect = GetClientAreaBounds();
4741 Rectangle clientRect = GetClientAreaBounds();
4742 bool modified = false;
4743 bool isValidRect = false;
4745 SAFE_DELETE(__pOverlay);
4747 AppLog("Client area rect (%d,%d,%d,%d)", clientRect.x, clientRect.y, clientRect.width, clientRect.height);
4748 HideAndGetBounds(GetControl(L"IDC_BUTTON1"), rect);
4749 AppLog("Original w.r.t IDC_BUTTON1 rect (%d,%d,%d,%d)", rect.x, rect.y, rect.width, rect.height);
4751 if (rect.width > clientRect.width || rect.height > clientRect.height)
4753 rect.width = clientRect.width;
4754 rect.height = clientRect.height;
4757 __orientationStatus = GetOrientationStatus();
4758 AppLog("Current orientation is %d", __orientationStatus);
4760 AppLog("Rect passed to OverlayRegion::EvaluateBounds is (%d,%d,%d,%d)", rect.x, rect.y, rect.width, rect.height);
4761 isValidRect = OverlayRegion::EvaluateBounds(OVERLAY_REGION_EVALUATION_OPTION_LESS_THAN, rect, modified);
4762 if (false == isValidRect)
4764 ShowError(GetLastResult(), METHOD_FILE_LINENO);
4770 AppLog("Bounds is modified to (%d,%d,%d,%d)", rect.x, rect.y, rect.width, rect.height);
4773 AppLog("Overlay region width = %d height = %d", rect.width, rect.height);
4775 __pOverlay = Osp::Ui::Controls::Form::GetOverlayRegionN(rect, (__camType == CAMERA_PRIMARY) ? OVERLAY_REGION_TYPE_PRIMARY_CAMERA : OVERLAY_REGION_TYPE_SECONDARY_CAMERA);
4776 AppLog("Overlay region pointer = %X width = %d height = %d", __pOverlay, rect.width, rect.height);
4778 if (__pOverlay == null)
4780 ShowError(GetLastResult(), METHOD_FILE_LINENO);
4784 rect = __pOverlay->GetBounds();
4785 AppLog("overlay region rect (%d,%d,%d,%d)", rect.x, rect.y, rect.width, rect.height);
4794 VideoRecorderForm::DoRotation()
4796 result r = E_SUCCESS;
4799 AppLog("VideoRecorderForm::DoRotation");
4801 r = CreateOverlayRegion();
4802 if (__pOverlay == NULL)
4804 AppLog("failed to get overlay region");
4808 AppLog("GetBackgroundBufferInfo handle ");
4809 r = __pOverlay->GetBackgroundBufferInfo(__bufferInfo);
4812 ShowError(r, METHOD_FILE_LINENO);
4816 if (__pCamera->GetState() == CAMERA_STATE_INITIALIZED ||
4817 __pCamera->GetState() == CAMERA_STATE_CAPTURED)
4819 AppLog("start preview invoking = %s", GetErrorMessage(r));
4820 if (__previewByCallback == 1)
4822 r = __pCamera->StartPreview(NULL, true);
4825 ShowError(r, METHOD_FILE_LINENO);
4831 r = __pCamera->StartPreview(&__bufferInfo, false);
4834 ShowError(r, METHOD_FILE_LINENO);
4846 AppLog("something failed in rotation");
4852 VideoRecorderForm::OnOrientationChanged(const Osp::Ui::Control& source, Osp::Ui::OrientationStatus orientationStatus)
4854 result r = E_SUCCESS;
4856 if (__pCamera == NULL || __pVideoRecorder == NULL)
4858 AppLog("Video Recorder is null");
4862 AppLog("VideoRecorderForm::OnOrientationChanged called current = %d new (std::nothrow) = %d recorder state = %d", __orientationStatus, orientationStatus, __pVideoRecorder->GetState());
4864 if (orientationStatus == __orientationStatus)
4866 AppLog("No change in orientation");
4870 if (__pVideoRecorder->GetState() != RECORDER_STATE_RECORDING)
4876 if (__pCamera->GetState() == CAMERA_STATE_PREVIEW)
4878 r = __pCamera->StopPreview();
4881 ShowError(r, METHOD_FILE_LINENO);
4885 //stop preview and recreate overlay region
4888 SendUserEvent(RECORDER_ROTATION, null);
4893 VideoRecorderForm::OnDraw()
4899 VideoRecorderForm::ClearCanvas()
4901 Osp::Graphics::Canvas* pCanvas = null;
4902 AppLog("ClearCanvas Invoked");
4903 if (__backGround == true)
4905 AppLog("No need to draw anything in background mode");
4908 pCanvas = GetClientAreaCanvasN();
4909 if (pCanvas == null)
4913 pCanvas->SetBackgroundColor(Color::GetColor(COLOR_ID_BLACK));
4922 VideoRecorderForm::OnKeyPressed(const Osp::Ui::Control& source, Osp::Ui::KeyCode keyCode)
4928 ConsumeInputEvent();
4934 ConsumeInputEvent();
4945 VideoRecorderForm::OnBatteryLevelChanged(Osp::System::BatteryLevel batteryLevel)
4947 if (batteryLevel == BATTERY_CRITICAL || batteryLevel == BATTERY_EMPTY || batteryLevel == BATTERY_LOW)
4949 bool isCharging = false;
4950 Osp::System::RuntimeInfo::GetValue(String(L"IsCharging"), isCharging);
4959 if (__batteryLevelFlag)
4961 this->OnActivate(null);
4967 VideoRecorderForm::EnableFooterItem(int actionId, bool enable)
4969 result r = E_SUCCESS;
4970 Footer* pFooter = GetFooter();
4973 ShowError(GetLastResult(), METHOD_FILE_LINENO);
4976 r = pFooter->SetItemEnabled((actionId - ID_SETTING), enable);
4979 ShowError(r, METHOD_FILE_LINENO);
4983 pFooter->RequestRedraw();
4990 VideoRecorderForm::GetIndexFromValue(Osp::Base::Collection::IListT< int >* pList, int value)
4992 int count = pList->GetCount();
4993 result r = E_SUCCESS;
4994 int valueInList = INIT;
4995 for (int index = 0; index < count; index++)
4997 r = pList->GetAt(index, valueInList);
4998 if (r == E_SUCCESS && value == valueInList)
5000 AppLog("matching found at index = %d for value = %d", index, value);
5004 AppLog("no matching for value = %d", value);
5009 VideoRecorderForm::GetIndexFromValue(Osp::Base::Collection::IList* pList, Osp::Graphics::Dimension& value)
5011 int count = pList->GetCount();
5012 Osp::Graphics::Dimension* pDim = null;
5013 for (int index = 0; index < count; index++)
5015 pDim = (Dimension*) pList->GetAt(index);
5016 if ((pDim != null) && value.Equals((*pDim)))
5018 AppLog("matching found at index = %d for width = %d height = %d", index, value.width, value.height);
5022 AppLog("no matching for value = %d %d", value.width, value.height);
5027 VideoRecorderForm::ShowFooterItems()
5029 result r = E_SUCCESS;
5030 EnableFooterItem(ID_SETTING, true);
5031 EnableFooterItem(ID_TOGGLE_CAMERA_TYPE, true);
5032 EnableFooterItem(ID_START, true);
5033 r = GetFooter()->SetBackButtonEnabled(true);
5036 ShowError(r, METHOD_FILE_LINENO);
5039 GetFooter()->Draw();