2 * mm_camcorder_testsuite
4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Jeongmo Yang <jm80.yang@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
22 /* ===========================================================================================
23 EDIT HISTORY FOR MODULE
24 This section contains comments describing changes made to the module.
25 Notice that changes are listed in reverse chronological order.
26 when who what, where, why
27 --------- -------------------- ----------------------------------------------------------
28 10/08/07 soyeon.kang@samsung.com Created
29 10/10/07 wh01.cho@samsung.com Created
30 12/30/08 jh1979.park@samsung.com Modified
31 08/31/11 sc11.lee@samsung.com Modified (Reorganized for easy look)
35 /*=======================================================================================
37 =======================================================================================*/
43 #include "../src/include/mm_camcorder.h"
44 #include "../src/include/mm_camcorder_internal.h"
45 #include "../src/include/mm_camcorder_util.h"
46 #include <gst/video/colorbalance.h>
49 /*-----------------------------------------------------------------------
50 | GLOBAL VARIABLE DEFINITIONS: |
51 -----------------------------------------------------------------------*/
52 #define EXPORT_API __attribute__((__visibility__("default")))
54 #define PACKAGE "mm_camcorder_testsuite"
57 GIOChannel *stdin_channel;
64 int mmcamcorder_state;
65 int mmcamcorder_print_state;
67 static int audio_stream_cb_cnt;
68 static int video_stream_cb_cnt;
69 static GTimer *timer = NULL;
71 /*-----------------------------------------------------------------------
72 | GLOBAL CONSTANT DEFINITIONS: |
73 -----------------------------------------------------------------------*/
76 /*-----------------------------------------------------------------------
77 | IMPORTED VARIABLE DECLARATIONS: |
78 -----------------------------------------------------------------------*/
81 /*-----------------------------------------------------------------------
82 | IMPORTED FUNCTION DECLARATIONS: |
83 -----------------------------------------------------------------------*/
86 /*-----------------------------------------------------------------------
88 -----------------------------------------------------------------------*/
89 #define test_ffmux_mp4
92 #define SRC_W_1920 1920
93 #define SRC_H_1080 1080
97 #define SRC_W_1600 1600
98 #define SRC_H_1200 1200
101 #define SRC_W_640 640
102 #define SRC_H_480 480
105 #define SRC_W_320 320 // video input width
106 #define SRC_H_240 240 // video input height
109 #define SRC_W_176 176 // video input width
110 #define SRC_H_144 144 // video input height
113 #define SRC_W_160 160 // video input width
114 #define SRC_H_120 120 // video input heith
117 #define SRC_W_400 400 // video input width
118 #define SRC_H_300 300 // video input height
120 #define SRC_W_192 192 // video input width
121 #define SRC_H_256 256 // video input height
123 #define SRC_W_144 144 // video input width
124 #define SRC_H_176 176 // video input height
126 #define SRC_W_300 300
127 #define SRC_W_400 400
130 #define DISPLAY_X_0 0 //for direct FB
131 #define DISPLAY_Y_0 0 //for direct FB
133 #define DISPLAY_W_320 320 //for direct FB
134 #define DISPLAY_H_240 240 //for direct FB
137 #define SRC_VIDEO_FRAME_RATE_15 15 // video input frame rate
138 #define SRC_VIDEO_FRAME_RATE_30 30 // video input frame rate
139 #define IMAGE_ENC_QUALITY 85 // quality of jpeg
140 #define IMAGE_CAPTURE_COUNT_STILL 1 // the number of still-shot
141 #define IMAGE_CAPTURE_COUNT_MULTI 3 // default the number of multi-shot
142 #define IMAGE_CAPTURE_COUNT_INTERVAL 100 // mili seconds
144 #define MAX_FILE_SIZE_FOR_MMS (250 * 1024)
146 #define EXT_JPEG "jpg"
147 #define EXT_MP4 "mp4"
148 #define EXT_3GP "3gp"
149 #define EXT_AMR "amr"
150 #define EXT_MKV "mkv"
152 #define STILL_CAPTURE_FILE_PATH_NAME "/opt/media/StillshotCapture"
153 #define MULTI_CAPTURE_FILE_PATH_NAME "/opt/media/MultishotCapture"
154 #define IMAGE_CAPTURE_THUMBNAIL_PATH "/opt/media/thumbnail.jpg"
155 #define IMAGE_CAPTURE_SCREENNAIL_PATH "/opt/media/screennail.yuv"
156 #define IMAGE_CAPTURE_EXIF_PATH "/opt/media/exif.raw"
157 #define TARGET_FILENAME_PATH "/opt/media/"
158 #define TARGET_FILENAME_VIDEO "/opt/media/test_rec_video.3gp"
159 #define TARGET_FILENAME_AUDIO "/opt/media/test_rec_audio.amr"
160 #define CAPTURE_FILENAME_LEN 256
162 #define AUDIO_SOURCE_SAMPLERATE_AAC 44100
163 #define AUDIO_SOURCE_SAMPLERATE_AMR 8000
164 #define AUDIO_SOURCE_FORMAT MM_CAMCORDER_AUDIO_FORMAT_PCM_S16_LE
165 #define AUDIO_SOURCE_CHANNEL_AAC 2
166 #define AUDIO_SOURCE_CHANNEL_AMR 1
167 #define VIDEO_ENCODE_BITRATE 40000000 /* bps */
169 #define DEFAULT_CAM_DEVICE MM_VIDEO_DEVICE_CAMERA1
172 * D E B U G M E S S A G E
174 #define MMF_DEBUG "** (mmcamcorder testsuite) DEBUG: "
175 #define MMF_ERR "** (mmcamcorder testsuite) ERROR: "
176 #define MMF_INFO "** (mmcamcorder testsuite) INFO: "
177 #define MMF_WARN "** (mmcamcorder testsuite) WARNING: "
178 #define MMF_TIME "** (mmcamcorder testsuite) TIME: "
180 #define CHECK_MM_ERROR(expr) \
184 if (ret != MM_ERROR_NONE) {\
185 printf("[%s:%d] error code : %x \n", __func__, __LINE__, ret); \
190 #define time_msg_t(fmt,arg...) \
192 fprintf(stderr,"\x1b[44m\x1b[37m"MMF_TIME"[%s:%05d] " fmt ,__func__, __LINE__, ##arg); \
193 fprintf(stderr,"\x1b[0m\n"); \
196 #define debug_msg_t(fmt,arg...)\
198 fprintf(stderr, MMF_DEBUG"[%s:%05d] " fmt "\n",__func__, __LINE__, ##arg); \
201 #define err_msg_t(fmt,arg...) \
203 fprintf(stderr, MMF_ERR"[%s:%05d] " fmt "\n",__func__, __LINE__, ##arg); \
206 #define info_msg_t(fmt,arg...) \
208 fprintf(stderr, MMF_INFO"[%s:%05d] " fmt "\n",__func__, __LINE__, ##arg); \
211 #define warn_msg_t(fmt,arg...) \
213 fprintf(stderr, MMF_WARN"[%s:%05d] " fmt "\n",__func__, __LINE__, ##arg); \
217 #define SAFE_FREE(x) if(x) {g_free(x); x = NULL;}
227 * Enumerations for command
229 #define SENSOR_WHITEBALANCE_NUM 10
230 #define SENSOR_COLOR_TONE_NUM 37
231 #define SENSOR_FLIP_NUM 3
232 #define SENSOR_PROGRAM_MODE_NUM 15
233 #define SENSOR_FOCUS_NUM 6
234 #define SENSOR_INPUT_ROTATION 4
235 #define SENSOR_AF_SCAN_NUM 4
236 #define SENSOR_ISO_NUM 8
237 #define SENSOR_EXPOSURE_NUM 9
238 #define SENSOR_IMAGE_FORMAT 9
241 /*-----------------------------------------------------------------------
242 | LOCAL CONSTANT DEFINITIONS: |
243 -----------------------------------------------------------------------*/
246 MODE_VIDEO_CAPTURE, /* recording and image capture mode */
247 MODE_AUDIO, /* audio recording*/
258 /*-----------------------------------------------------------------------
259 | LOCAL DATA TYPE DEFINITIONS: |
260 -----------------------------------------------------------------------*/
261 typedef struct _cam_handle
263 MMHandleType camcorder;
264 int mode; /* image(capture)/video(recording) mode */
265 bool isMultishot; /* flag for multishot mode */
266 int stillshot_count; /* total stillshot count */
267 int multishot_count; /* total multishot count */
268 char *stillshot_filename; /* stored filename of stillshot */
269 char *multishot_filename; /* stored filename of multishot */
273 unsigned long long elapsed_time;
276 typedef struct _cam_xypair
284 /*---------------------------------------------------------------------------
285 | LOCAL VARIABLE DEFINITIONS: |
286 ---------------------------------------------------------------------------*/
287 static cam_handle_t *hcamcorder ;
289 char *wb[SENSOR_WHITEBALANCE_NUM]={
302 char *ct[SENSOR_COLOR_TONE_NUM] = {
328 "SELECTVE_COLOR_RED",
329 "SELECTVE_COLOR_GREEN",
330 "SELECTVE_COLOR_BLUE",
331 "SELECTVE_COLOR_YELLOW",
332 "SELECTVE_COLOR_RED_YELLOW",
335 char *flip[SENSOR_FLIP_NUM] = {
341 char *program_mode[SENSOR_PROGRAM_MODE_NUM] = {
359 char *focus_mode[SENSOR_FOCUS_NUM] = {
368 char *camera_rotation[SENSOR_INPUT_ROTATION] = {
375 char *af_scan[SENSOR_AF_SCAN_NUM] = {
382 char *iso_name[SENSOR_ISO_NUM] = {
393 char *exposure_mode[SENSOR_EXPOSURE_NUM] = {
405 char *image_fmt[SENSOR_IMAGE_FORMAT] = {
417 char *face_zoom_mode[] = {
422 char *display_mode[] = {
424 "Primary Video ON and Secondary Video Full Screen",
425 "Primary Video OFF and Secondary Video Full Screen",
428 char *output_mode[] = {
430 "Original Size mode",
432 "Cropped Full Screen mode",
436 char *rotate_mode[] = {
443 char* strobe_mode[] = {
447 "Strobe RedEyeReduction",
449 "Strobe FrontCurtain",
450 "Strobe RearCurtain",
454 char *detection_mode[2] = {
455 "Face Detection OFF",
468 "HDR ON and Original",
472 "Anti-handshake OFF",
474 "Anti-handshake AUTO",
475 "Anti-handshake MOVIE",
479 "Video-stabilization OFF",
480 "Video-stabilization ON",
483 char *visible_mode[] = {
489 /*---------------------------------------------------------------------------
490 | LOCAL FUNCTION PROTOTYPES: |
491 ---------------------------------------------------------------------------*/
492 static void print_menu();
494 static gboolean cmd_input(GIOChannel *channel);
495 //static bool filename_callback (int format, char *filename, void *user_param);
496 static gboolean msg_callback(int message, void *msg_param, void *user_param);
497 static gboolean init(int type);
498 static gboolean mode_change();
499 int camcordertest_set_attr_int(char* attr_subcategory, int value);
502 static inline void flush_stdin()
505 while((ch=getchar()) != EOF && ch != '\n');
509 cam_utils_convert_YUYV_to_UYVY(unsigned char* dst, unsigned char* src, gint length)
514 memset(dst, 0x00, length);
515 memcpy(dst, src + 1, length-1);
517 for ( i = 0 ; i < length; i ++)
526 #ifdef USE_AUDIO_STREAM_CB
527 static int camcordertest_audio_stream_cb(MMCamcorderAudioStreamDataType *stream, void *user_param)
529 audio_stream_cb_cnt++;
530 printf("audio_stream cb is called (stream:%p, data:%p, format:%d, channel:%d, volume_dB:%f, length:%d, timestamp:%d)\n",
531 stream, stream->data, stream->format, stream->channel, stream->volume_dB, stream->length, stream->timestamp);
535 #endif /* USE_AUDIO_STREAM_CB */
537 static int camcordertest_video_stream_cb(MMCamcorderVideoStreamDataType *stream, void *user_param)
539 video_stream_cb_cnt++;
541 printf("VIDEO STREAM CALLBACK total length :%u, size %dx%d\n", stream->length_total, stream->width, stream->height);
546 static void _file_write(char *path, void *data, int size)
550 if (!path || !data || size <= 0) {
551 printf("ERROR %p %p %d\n", path, data, size);
555 fp = fopen(path, "w");
557 printf("open error! [%s], errno %d\n", path, errno);
560 printf("open success [%s]\n", path);
561 if (fwrite(data, size, 1, fp) != 1) {
562 printf("write error! errno %d\n", errno);
564 printf("write success [%s]\n", path);
574 camcordertest_video_capture_cb(MMCamcorderCaptureDataType *main, MMCamcorderCaptureDataType *thumb, void *data)
579 char m_filename[CAPTURE_FILENAME_LEN];
580 MMCamcorderCaptureDataType *scrnl = NULL;
581 unsigned char *exif_data = NULL;
584 warn_msg_t("Capture callback : Main image buffer is NULL!!!");
588 if (hcamcorder->isMultishot) {
589 snprintf(m_filename, CAPTURE_FILENAME_LEN, "%s%03d.jpg", hcamcorder->multishot_filename, hcamcorder->multishot_count++);
591 snprintf(m_filename, CAPTURE_FILENAME_LEN, "%s%03d.jpg", hcamcorder->stillshot_filename, hcamcorder->stillshot_count++);
594 debug_msg_t("hcamcorder->isMultishot=%d =>1: MULTI, 0: STILL, filename : %s",
595 hcamcorder->isMultishot, m_filename);
597 if (main->format != MM_PIXEL_FORMAT_ENCODED) {
598 unsigned int dst_size = 0;
601 nret = _mmcamcorder_encode_jpeg(main->data, main->width, main->height, main->format,
602 main->length, 90, &dst, &dst_size);
604 _file_write(m_filename, dst, dst_size);
606 printf("Failed to encode YUV(%d) -> JPEG. \n", main->format);
611 } else if (!hcamcorder->isMultishot) {
613 printf("MM_PIXEL_FORMAT_ENCODED main->data=%p main->length=%d, main->width=%d, main->heigtht=%d \n",
614 main->data, main->length, main->width, main->height);
617 _file_write(m_filename, main->data, main->length);
621 _file_write(IMAGE_CAPTURE_THUMBNAIL_PATH, thumb->data, thumb->length);
625 mm_camcorder_get_attributes(hcamcorder->camcorder, NULL,
626 "captured-screennail", &scrnl, &scrnl_size,
629 _file_write(IMAGE_CAPTURE_SCREENNAIL_PATH, scrnl->data, scrnl->length);
631 printf( "Screennail buffer is NULL.\n" );
635 mm_camcorder_get_attributes(hcamcorder->camcorder, NULL,
636 "captured-exif-raw-data", &exif_data, &exif_size,
639 _file_write(IMAGE_CAPTURE_EXIF_PATH, exif_data, exif_size);
646 static gboolean test_idle_capture_start()
650 camcordertest_set_attr_int(MMCAM_CAPTURE_FORMAT, MM_PIXEL_FORMAT_ENCODED);
651 camcordertest_set_attr_int(MMCAM_IMAGE_ENCODER, MM_IMAGE_CODEC_JPEG);
653 g_timer_reset(timer);
654 err = mm_camcorder_capture_start(hcamcorder->camcorder);
658 // if(hcamcorder->isMultishot == TRUE)
659 // hcamcorder->isMultishot = FALSE;
660 warn_msg_t("Multishot mm_camcorder_capture_start = %x", err);
665 int camcordertest_set_attr_int(char * attr_subcategory, int value)
667 char * err_attr_name = NULL;
671 if (hcamcorder->camcorder) {
672 debug_msg_t("camcordertest_set_attr_int(%s, %d)", attr_subcategory, value);
674 err = mm_camcorder_set_attributes(hcamcorder->camcorder, &err_attr_name,
675 attr_subcategory, value,
677 if (err != MM_ERROR_NONE) {
678 err_msg_t("camcordertest_set_attr_int : Error(%s:%x)!!!!!!!", err_attr_name, err);
679 SAFE_FREE(err_attr_name);
687 debug_msg_t("camcordertest_set_attr_int(!hcamcorder->camcorde)");
690 debug_msg_t("camcordertest_set_attr_int(!hcamcorder)");
695 int camcordertest_set_attr_xypair(cam_xypair_t pair)
697 char * err_attr_name = NULL;
702 if (hcamcorder->camcorder)
704 debug_msg_t("camcordertest_set_attr_xypair((%s, %s), (%d, %d))", pair.attr_subcat_x, pair.attr_subcat_y, pair.x, pair.y);
706 err = mm_camcorder_set_attributes(hcamcorder->camcorder, &err_attr_name,
707 pair.attr_subcat_x, pair.x,
708 pair.attr_subcat_y, pair.y,
712 err_msg_t("camcordertest_set_attr_xypair : Error(%s:%x)!!", err_attr_name, err);
713 SAFE_FREE (err_attr_name);
721 debug_msg_t("camcordertest_set_attr_xypair(!hcamcorder->camcorde)");
724 debug_msg_t("camcordertest_set_attr_xypair(!hcamcorder)");
728 int camcordertest_get_attr_valid_intarray(char * attr_name, int ** array, int *count)
735 if (hcamcorder->camcorder)
737 debug_msg_t("camcordertest_get_attr_valid_intarray(%s)", attr_name);
739 err = mm_camcorder_get_attribute_info(hcamcorder->camcorder, attr_name, &info);
740 if (err != MM_ERROR_NONE) {
741 err_msg_t("camcordertest_get_attr_valid_intarray : Error(%x)!!", err);
744 if (info.type == MM_CAM_ATTRS_TYPE_INT) {
745 if (info.validity_type == MM_CAM_ATTRS_VALID_TYPE_INT_ARRAY) {
746 *array = info.int_array.array;
747 *count = info.int_array.count;
748 debug_msg_t("INT ARRAY - default value : %d", info.int_array.def);
753 err_msg_t("camcordertest_get_attr_valid_intarray : Type mismatched!!");
759 debug_msg_t("camcordertest_get_attr_valid_intarray(!hcamcorder->camcorde)");
762 debug_msg_t("camcordertest_get_attr_valid_intarray(!hcamcorder)");
766 int camcordertest_get_attr_valid_intrange(char * attr_name, int *min, int *max)
773 if (hcamcorder->camcorder)
775 debug_msg_t("camcordertest_get_attr_valid_intrange(%s)", attr_name);
777 err = mm_camcorder_get_attribute_info(hcamcorder->camcorder, attr_name, &info);
778 if (err != MM_ERROR_NONE) {
779 err_msg_t("camcordertest_get_attr_valid_intarray : Error(%x)!!", err);
782 if (info.type == MM_CAM_ATTRS_TYPE_INT) {
783 if (info.validity_type == MM_CAM_ATTRS_VALID_TYPE_INT_RANGE) {
784 *min = info.int_range.min;
785 *max = info.int_range.max;
786 debug_msg_t("INT RANGE - default : %d", info.int_range.def);
791 err_msg_t("camcordertest_get_attr_valid_intarray : Type mismatched!!");
798 debug_msg_t("camcordertest_get_attr_valid_intarray(!hcamcorder->camcorde)");
801 debug_msg_t("camcordertest_get_attr_valid_intarray(!hcamcorder)");
808 mm_camcorder_capture_stop(hcamcorder->camcorder);
811 static void print_menu()
813 switch(hcamcorder->menu_state)
815 case MENU_STATE_MAIN:
816 if (hcamcorder->mode == MODE_VIDEO_CAPTURE) {
817 g_print("\n\t=======================================\n");
818 if ( cam_info.videodev_type == MM_VIDEO_DEVICE_CAMERA1 )
819 g_print("\t Video Capture (Front camera)\n");
820 else if( cam_info.videodev_type == MM_VIDEO_DEVICE_CAMERA0 )
821 g_print("\t Video Capture (Rear camera)\n");
822 g_print("\t=======================================\n");
824 if(mmcamcorder_print_state <= MM_CAMCORDER_STATE_PREPARE) {
825 g_print("\t '1' Take a photo\n");
826 g_print("\t '2' Start Recording\n");
827 g_print("\t '3' Setting\n");
828 g_print("\t '4' Print FPS\n");
829 g_print("\t 'b' back\n");
830 } else if(mmcamcorder_print_state == MM_CAMCORDER_STATE_RECORDING) {
831 g_print("\t 'p' Pause Recording\n");
832 g_print("\t 'c' Cancel\n");
833 g_print("\t 's' Save\n");
834 g_print("\t 'n' Capture video snapshot\n");
835 } else if(mmcamcorder_print_state == MM_CAMCORDER_STATE_PAUSED) {
836 g_print("\t 'r' Resume Recording\n");
837 g_print("\t 'c' Cancel\n");
838 g_print("\t 's' Save\n");
839 g_print("\t 'n' Capture video snapshot\n");
841 g_print("\t=======================================\n");
842 } else if (hcamcorder->mode == MODE_AUDIO) {
843 g_print("\n\t=======================================\n");
844 g_print("\t Audio Recording\n");
845 g_print("\t=======================================\n");
846 if(mmcamcorder_print_state <= MM_CAMCORDER_STATE_PREPARE) {
847 g_print("\t '1' Start Recording\n");
848 g_print("\t 'b' back\n");
850 else if(mmcamcorder_print_state == MM_CAMCORDER_STATE_RECORDING) {
851 g_print("\t 'p' Pause Recording\n");
852 g_print("\t 'c' Cancel\n");
853 g_print("\t 's' Save\n");
855 else if(mmcamcorder_print_state == MM_CAMCORDER_STATE_PAUSED) {
856 g_print("\t 'r' Resume Recording\n");
857 g_print("\t 'c' Cancel\n");
858 g_print("\t 's' Save\n");
860 g_print("\t=======================================\n");
864 case MENU_STATE_SETTING:
865 g_print("\n\t=======================================\n");
866 g_print("\t Video Capture > Setting\n");
867 g_print("\t=======================================\n");
868 g_print("\t >>>>>>>>>>>>>>>>>>>>>>>>>>>> [Camera] \n");
869 g_print("\t '1' Capture resolution \n");
870 g_print("\t '2' Digital zoom level \n");
871 g_print("\t '3' Optical zoom level \n");
872 g_print("\t '4' AF mode \n");
873 g_print("\t '5' AF scan range \n");
874 g_print("\t '6' Exposure mode \n");
875 g_print("\t '7' Exposure value \n");
876 g_print("\t '8' F number \n");
877 g_print("\t '9' Shutter speed \n");
878 g_print("\t 'i' ISO \n");
879 g_print("\t 'r' Rotate camera input \n");
880 g_print("\t 'f' Flip camera input \n");
881 g_print("\t 'j' Jpeg quality \n");
882 g_print("\t 'p' Picture format \n");
883 g_print("\t 'E' EXIF orientation \n");
884 g_print("\t >>>>>>>>>>>>>>>>>>>> [Display/Filter]\n");
885 g_print("\t 'v' Visible \n");
886 g_print("\t 'n' Display mode \n");
887 g_print("\t 'o' Output mode \n");
888 g_print("\t 'y' Rotate display \n");
889 g_print("\t 'Y' Flip display \n");
890 g_print("\t 'g' Brightness \n");
891 g_print("\t 'c' Contrast \n");
892 g_print("\t 's' Saturation \n");
893 g_print("\t 'h' Hue \n");
894 g_print("\t 'a' Sharpness \n");
895 g_print("\t 'w' White balance \n");
896 g_print("\t 't' Color tone \n");
897 g_print("\t 'd' WDR \n");
898 g_print("\t 'e' EV program mode \n");
899 g_print("\t >>>>>>>>>>>>>>>>>>>>>>>>>>>>>> [etc.]\n");
900 g_print("\t 'z' Strobe (Flash) \n");
901 g_print("\t 'x' Capture mode (Still/Multishot/HDR)\n");
902 g_print("\t 'l' Face detection \n");
903 g_print("\t 'k' Anti-handshake \n");
904 g_print("\t 'K' Video-stabilization \n");
905 g_print("\t 'u' Touch AF area \n");
906 g_print("\t 'm' Stream callback function \n");
907 g_print("\t 'b' back\n");
908 g_print("\t=======================================\n");
912 warn_msg_t("unknow menu state !!\n");
919 static void main_menu(gchar buf)
924 char *err_attr_name = NULL;
926 if (hcamcorder->mode == MODE_VIDEO_CAPTURE) {
927 if (mmcamcorder_state == MM_CAMCORDER_STATE_PREPARE) {
930 if(hcamcorder->isMultishot) {
933 printf("\ninput interval(ms) \n");
934 err = scanf("%d", &interval);
936 printf("\nscanf error : errno %d\n", errno);
939 err = mm_camcorder_set_attributes(hcamcorder->camcorder, &err_attr_name,
940 MMCAM_CAPTURE_INTERVAL, interval,
942 if (err != MM_ERROR_NONE) {
943 err_msg_t("Attribute setting fail : (%s:%x)", err_attr_name, err);
944 SAFE_FREE (err_attr_name);
947 err = mm_camcorder_set_attributes(hcamcorder->camcorder, &err_attr_name,
948 MMCAM_CAPTURE_COUNT, IMAGE_CAPTURE_COUNT_STILL,
950 if (err != MM_ERROR_NONE) {
951 err_msg_t("Attribute setting fail : (%s:%x)", err_attr_name, err);
952 SAFE_FREE (err_attr_name);
956 g_idle_add_full(G_PRIORITY_DEFAULT_IDLE, (GSourceFunc)test_idle_capture_start, NULL, NULL);
959 case '2' : // Start Recording
960 g_print("*Recording start!\n");
961 video_stream_cb_cnt = 0;
962 audio_stream_cb_cnt = 0;
964 g_timer_reset(timer);
965 err = mm_camcorder_record(hcamcorder->camcorder);
967 if (err != MM_ERROR_NONE) {
968 warn_msg_t("Rec start mm_camcorder_record 0x%x", err);
971 mmcamcorder_print_state = MM_CAMCORDER_STATE_RECORDING;
974 case '3' : // Setting
975 hcamcorder->menu_state = MENU_STATE_SETTING;
978 case '4' : // Print frame rate
979 current_fps = _mmcamcorder_video_current_framerate(hcamcorder->camcorder);
980 average_fps = _mmcamcorder_video_average_framerate(hcamcorder->camcorder);
981 g_print("\tVideo Frame Rate[Current : %d.0 fps, Average : %d.0 fps]\n", current_fps, average_fps);
985 hcamcorder->menu_state = MENU_STATE_MAIN;
990 g_print("\t Invalid input \n");
993 } else if (mmcamcorder_state == MM_CAMCORDER_STATE_RECORDING || mmcamcorder_state == MM_CAMCORDER_STATE_PAUSED) {
995 if (mmcamcorder_state == MM_CAMCORDER_STATE_RECORDING) {
996 case 'p' : // Pause Recording
997 g_print("*Pause!\n");
998 err = mm_camcorder_pause(hcamcorder->camcorder);
1001 warn_msg_t("Rec pause mm_camcorder_pause = %x", err);
1003 mmcamcorder_print_state = MM_CAMCORDER_STATE_PAUSED;
1007 case 'r' : // Resume Recording
1008 g_print("*Resume!\n");
1009 err = mm_camcorder_record(hcamcorder->camcorder);
1011 warn_msg_t("Rec start mm_camcorder_record = %x", err);
1013 mmcamcorder_print_state = MM_CAMCORDER_STATE_RECORDING;
1017 case 'c' : // Cancel
1018 g_print("*Cancel Recording !\n");
1020 err = mm_camcorder_cancel(hcamcorder->camcorder);
1023 warn_msg_t("Cancel recording mm_camcorder_cancel = %x", err);
1025 mmcamcorder_print_state = MM_CAMCORDER_STATE_PREPARE;
1029 g_print("*Save Recording!\n");
1030 g_timer_reset(timer);
1032 err = mm_camcorder_commit(hcamcorder->camcorder);
1035 warn_msg_t("Save recording mm_camcorder_commit = %x", err);
1037 mmcamcorder_print_state = MM_CAMCORDER_STATE_PREPARE;
1040 case 'n' : /* Capture video snapshot */
1041 err = mm_camcorder_capture_start(hcamcorder->camcorder);
1045 g_print("\t Invalid input \n");
1049 err_msg_t("Wrong camcorder state, check status!!");
1051 } else if (hcamcorder->mode == MODE_AUDIO) {
1052 if (mmcamcorder_state == MM_CAMCORDER_STATE_PREPARE) {
1054 case '1' : // Start Recording
1055 g_print("*Recording start!\n");
1056 g_timer_reset(timer);
1057 err = mm_camcorder_record(hcamcorder->camcorder);
1060 warn_msg_t("Rec start mm_camcorder_record = %x", err);
1062 mmcamcorder_print_state = MM_CAMCORDER_STATE_RECORDING;
1066 hcamcorder->menu_state = MENU_STATE_MAIN;
1071 g_print("\t Invalid input \n");
1074 } else if (mmcamcorder_state == MM_CAMCORDER_STATE_RECORDING || mmcamcorder_state == MM_CAMCORDER_STATE_PAUSED) {
1076 if (mmcamcorder_state == MM_CAMCORDER_STATE_RECORDING) {
1077 case 'p' : // Pause Recording
1078 g_print("*Pause!\n");
1079 err = mm_camcorder_pause(hcamcorder->camcorder);
1082 warn_msg_t("Rec pause mm_camcorder_pause = %x", err);
1084 mmcamcorder_print_state = MM_CAMCORDER_STATE_PAUSED;
1087 case 'r' : // Resume Recording
1088 g_print("*Resume!\n");
1089 err = mm_camcorder_record(hcamcorder->camcorder);
1091 warn_msg_t("Rec start mm_camcorder_record = %x", err);
1093 mmcamcorder_print_state = MM_CAMCORDER_STATE_RECORDING;
1097 case 'c' : // Cancel
1098 g_print("*Cancel Recording !\n");
1099 err = mm_camcorder_cancel(hcamcorder->camcorder);
1102 warn_msg_t("Cancel recording mm_camcorder_cancel = %x", err);
1104 mmcamcorder_print_state = MM_CAMCORDER_STATE_PREPARE;
1108 g_print("*Save Recording!\n");
1109 g_timer_reset(timer);
1110 err = mm_camcorder_commit(hcamcorder->camcorder);
1113 warn_msg_t("Save recording mm_camcorder_commit = %x", err);
1115 mmcamcorder_print_state = MM_CAMCORDER_STATE_PREPARE;
1119 g_print("\t Invalid input \n");
1123 err_msg_t("Wrong camcorder state, check status!!");
1127 g_print("\t Invalid mode, back to upper menu \n");
1128 hcamcorder->menu_state = MENU_STATE_MAIN;
1134 static void setting_menu(gchar buf)
1136 gboolean bret = FALSE;
1140 int width_count = 0;
1141 int height_count = 0;
1146 int *width_array = NULL;
1147 int *height_array = NULL;
1148 char *err_attr_name = NULL;
1149 cam_xypair_t input_pair;
1150 int err = MM_ERROR_NONE;
1151 int x = 0, y = 0, width = 0, height = 0;
1154 if (hcamcorder->mode == MODE_VIDEO_CAPTURE) {
1156 /* Camera setting */
1157 case '1' : // Setting > Capture Resolution setting
1158 /* check recommend preview resolution */
1159 camcordertest_get_attr_valid_intarray(MMCAM_RECOMMEND_CAMERA_WIDTH, &width_array, &width_count);
1160 camcordertest_get_attr_valid_intarray(MMCAM_RECOMMEND_CAMERA_HEIGHT, &height_array, &height_count);
1161 if(width_count != height_count) {
1162 err_msg_t("System has wrong information!!\n");
1163 } else if (width_count == 0) {
1164 g_print("MMCAM_RECOMMEND_CAMERA_WIDTH/HEIGHT Not supported!!\n");
1166 g_print("\n - MMCAM_RECOMMEND_CAMERA_WIDTH and HEIGHT (count %d) -\n", width_count);
1167 g_print("\t NORMAL ratio : %dx%d\n",
1168 width_array[MM_CAMCORDER_PREVIEW_TYPE_NORMAL], height_array[MM_CAMCORDER_PREVIEW_TYPE_NORMAL]);
1169 if (width_count >= 2) {
1170 g_print("\t WIDE ratio : %dx%d\n\n",
1171 width_array[MM_CAMCORDER_PREVIEW_TYPE_WIDE], height_array[MM_CAMCORDER_PREVIEW_TYPE_WIDE]);
1173 g_print("\t There is ONLY NORMAL resolution\n\n");
1177 g_print("*Select the resolution!\n");
1178 camcordertest_get_attr_valid_intarray("capture-width", &width_array, &width_count);
1179 camcordertest_get_attr_valid_intarray("capture-height", &height_array, &height_count);
1181 if(width_count != height_count) {
1182 err_msg_t("System has wrong information!!\n");
1183 } else if (width_count == 0) {
1184 g_print("Not supported!!\n");
1186 g_print("\n Select resolution \n");
1189 for ( i = 0; i < width_count; i++) {
1190 g_print("\t %d. %d*%d\n", i+1, width_array[i], height_array[i]);
1192 err = scanf("%d",&index);
1194 printf("\nscanf error : errno %d\n", errno);
1196 if( index > 0 && index <= width_count ) {
1197 //Set capture size first
1198 input_pair.attr_subcat_x = "capture-width";
1199 input_pair.attr_subcat_y = "capture-height";
1200 input_pair.x = width_array[index-1];
1201 input_pair.y = height_array[index-1];
1202 bret = camcordertest_set_attr_xypair(input_pair);
1208 case '2' : // Setting > Digital zoom level
1209 g_print("*Digital zoom level !\n");
1210 camcordertest_get_attr_valid_intrange("camera-digital-zoom", &min, &max);
1213 g_print("Not supported !! \n");
1216 g_print("\n Select Digital zoom level (%d ~ %d)\n", min, max);
1217 err = scanf("%d",&index);
1218 bret = camcordertest_set_attr_int("camera-digital-zoom", index);
1222 case '3' : // Setting > Optical zoom level
1223 g_print("*Optical zoom level !\n");
1224 camcordertest_get_attr_valid_intrange("camera-optical-zoom", &min, &max);
1227 g_print("Not supported !! \n");
1230 g_print("\n Select Optical zoom level (%d ~ %d)\n", min, max);
1231 err = scanf("%d",&index);
1232 bret = camcordertest_set_attr_int("camera-optical-zoom", index);
1236 case '4' : // Setting > AF mode
1237 g_print("\t0. AF Mode setting !\n");
1238 g_print("\t1. AF Start !\n");
1239 g_print("\t2. AF Stop !\n\n");
1242 err = scanf("%d", &index);
1247 g_print("*Focus mode !\n");
1248 camcordertest_get_attr_valid_intarray("camera-focus-mode", &array, &count);
1251 g_print("Not supported !! \n");
1253 g_print("\n Select Focus mode \n");
1255 for (i = 0 ; i < count ; i++) {
1256 g_print("\t %d. %s\n", array[i], focus_mode[array[i]]);
1258 err = scanf("%d",&index);
1259 bret = camcordertest_set_attr_int("camera-focus-mode", index);
1264 mm_camcorder_start_focusing(hcamcorder->camcorder);
1267 mm_camcorder_stop_focusing(hcamcorder->camcorder);
1270 g_print("Wrong Input[%d] !! \n", index);
1275 case '5' : // Setting > AF scan range
1276 g_print("*AF scan range !\n");
1277 camcordertest_get_attr_valid_intarray("camera-af-scan-range", &array, &count);
1280 g_print("Not supported !! \n");
1282 g_print("\n Select AF scan range \n");
1284 for ( i = 0; i < count; i++) {
1285 g_print("\t %d. %s\n", array[i], af_scan[array[i]]);
1287 err = scanf("%d",&index);
1288 camcordertest_set_attr_int("camera-af-scan-range", index);
1292 case '6' : // Setting > Exposure mode
1293 g_print("* Exposure mode!\n");
1294 camcordertest_get_attr_valid_intarray("camera-exposure-mode", &array, &count);
1297 g_print("Not supported !! \n");
1299 g_print("\n Select Exposure mode \n");
1301 for ( i = 0; i < count; i++) {
1302 g_print("\t %d. %s\n", array[i], exposure_mode[array[i]]);
1304 err = scanf("%d",&index);
1305 bret = camcordertest_set_attr_int("camera-exposure-mode", index);
1309 case '7' : // Setting > Exposure value
1310 g_print("*Exposure value !\n");
1311 camcordertest_get_attr_valid_intrange("camera-exposure-value", &min, &max);
1314 g_print("Not supported !! \n");
1317 g_print("\n Select Exposure value(%d ~ %d)\n", min, max);
1318 err = scanf("%d",&index);
1319 bret = camcordertest_set_attr_int("camera-exposure-value", index);
1323 case '8' : // Setting > F number
1324 g_print("Not supported !! \n");
1327 case '9' : // Setting > Shutter speed
1328 g_print("*Shutter speed !\n");
1329 camcordertest_get_attr_valid_intarray("camera-shutter-speed", &array, &count);
1332 g_print("Not supported !! \n");
1334 g_print("\n Select Shutter speed \n");
1336 for ( i = 0; i < count; i++) {
1337 g_print("\t %d. %d \n", i+1, array[i]);
1339 err = scanf("%d",&index);
1341 if( index > 0 && index <= count ) {
1342 bret = camcordertest_set_attr_int("camera-shutter-speed", array[index-1]);
1347 case 'i' : // Setting > ISO
1348 g_print("*ISO !\n");
1349 camcordertest_get_attr_valid_intarray("camera-iso", &array, &count);
1352 g_print("Not supported !! \n");
1354 g_print("\n Select ISO \n");
1356 for ( i = 0; i < count; i++) {
1357 g_print("\t %d. %s\n", array[i], iso_name[array[i]]);
1359 err = scanf("%d",&index);
1360 bret = camcordertest_set_attr_int("camera-iso", index);
1364 case 'r' : // Setting > Rotate camera input when recording
1365 g_print("*Rotate camera input\n");
1366 camcordertest_get_attr_valid_intrange(MMCAM_CAMERA_ROTATION, &min, &max);
1369 g_print("Not supported !! \n");
1372 for (i = min ; i <= max ; i++) {
1373 g_print("\t %d. %s\n", i, camera_rotation[i]);
1375 err = scanf("%d",&index);
1376 CHECK_MM_ERROR(mm_camcorder_stop(hcamcorder->camcorder));
1377 bret = camcordertest_set_attr_int(MMCAM_CAMERA_ROTATION, index);
1378 CHECK_MM_ERROR(mm_camcorder_start(hcamcorder->camcorder));
1382 case 'f' : // Setting > Flip camera input
1384 g_print("*Flip camera input\n");
1385 g_print(" 0. Flip NONE\n");
1386 g_print(" 1. Flip HORIZONTAL\n");
1387 g_print(" 2. Flip VERTICAL\n");
1388 g_print(" 3. Flip BOTH\n");
1390 err = scanf("%d", &index);
1392 CHECK_MM_ERROR(mm_camcorder_stop(hcamcorder->camcorder));
1393 CHECK_MM_ERROR(mm_camcorder_unrealize(hcamcorder->camcorder));
1395 camcordertest_set_attr_int(MMCAM_CAMERA_FLIP, index);
1397 CHECK_MM_ERROR(mm_camcorder_realize(hcamcorder->camcorder));
1398 CHECK_MM_ERROR(mm_camcorder_start(hcamcorder->camcorder));
1401 case 'j' : // Setting > Jpeg quality
1402 g_print("*Jpeg quality !\n");
1403 camcordertest_get_attr_valid_intrange("image-encoder-quality", &min, &max);
1406 g_print("Not supported !! \n");
1409 g_print("\n Select Jpeg quality (%d ~ %d)\n", min, max);
1410 err = scanf("%d",&index);
1411 bret = camcordertest_set_attr_int("image-encoder-quality", index);
1415 case 'p' : // Setting > Picture format
1416 g_print("* Picture format!\n");
1417 camcordertest_get_attr_valid_intarray("camera-format", &array, &count);
1420 g_print("Not supported !! \n");
1422 g_print("\n Select Picture format \n");
1424 for ( i = 0; i < count; i++) {
1425 g_print("\t %d. %s\n", array[i], image_fmt[array[i]]);
1427 err = scanf("%d",&index);
1428 bret = camcordertest_set_attr_int("camera-format", index);
1429 CHECK_MM_ERROR(mm_camcorder_stop(hcamcorder->camcorder));
1430 CHECK_MM_ERROR(mm_camcorder_unrealize(hcamcorder->camcorder));
1431 CHECK_MM_ERROR(mm_camcorder_realize(hcamcorder->camcorder));
1432 CHECK_MM_ERROR(mm_camcorder_start(hcamcorder->camcorder));
1436 case 'E' : // Setting > EXIF orientation
1437 g_print("* EXIF Orientation\n");
1439 g_print("\t 1. TOP_LEFT\n");
1440 g_print("\t 2. TOP_RIGHT(flipped)\n");
1441 g_print("\t 3. BOTTOM_RIGHT\n");
1442 g_print("\t 4. BOTTOM_LEFT(flipped)\n");
1443 g_print("\t 5. LEFT_TOP(flipped)\n");
1444 g_print("\t 6. RIGHT_TOP\n");
1445 g_print("\t 7. RIGHT_BOTTOM(flipped)\n");
1446 g_print("\t 8. LEFT_BOTTOM\n");
1449 err = scanf("%d", &index);
1451 if (index < 1 || index > 8) {
1452 g_print("Wrong INPUT[%d]!! \n", index);
1454 camcordertest_set_attr_int(MMCAM_TAG_ORIENTATION, index);
1459 /* Display / Filter setting */
1460 case 'v' : // Display visible
1461 g_print("* Display visible setting !\n");
1462 camcordertest_get_attr_valid_intarray( "display-visible", &array, &count );
1465 g_print("Not supported !! \n");
1467 g_print("\n Select Display visible \n");
1469 for ( i = 0; i < count; i++) {
1470 g_print("\t %d. %s\n", array[i], visible_mode[array[i]]);
1472 err = scanf("%d",&value);
1473 bret = camcordertest_set_attr_int( "display-visible", value );
1477 case 'n' : // Setting > Display mode
1478 g_print("* Display mode!\n");
1479 camcordertest_get_attr_valid_intarray(MMCAM_DISPLAY_MODE, &array, &count);
1481 if (count <= 0 || count > 255) {
1482 g_print("Not supported !! \n");
1485 g_print("\n Select Display mode\n");
1486 for (i = 0 ; i < count ; i++) {
1487 g_print("\t %d. %s\n", array[i], display_mode[array[i]]);
1489 err = scanf("%d",&index);
1490 bret = camcordertest_set_attr_int(MMCAM_DISPLAY_MODE, index);
1494 case 'o' : // Setting > Output mode
1495 g_print("* Output mode!\n");
1496 camcordertest_get_attr_valid_intrange("display-geometry-method", &min, &max);
1499 g_print("Not supported !! \n");
1502 g_print("\n Select Output mode(%d ~ %d)\n", min, max);
1503 for( i = min ; i <= max ; i++ ) {
1504 g_print( "%d. %s\n", i, output_mode[i] );
1506 err = scanf("%d",&index);
1507 bret = camcordertest_set_attr_int("display-geometry-method", index);
1511 case 'y' : // Setting > Rotate Display
1512 camcordertest_get_attr_valid_intrange(MMCAM_DISPLAY_ROTATION, &min, &max);
1515 g_print("Not supported !! \n");
1518 g_print("\n Select Rotate mode(%d ~ %d)\n", min, max);
1519 g_print("\t0. 0\n\t1. 90\n\t2. 180\n\t3. 270\n\n");
1520 err = scanf("%d",&index);
1521 bret = camcordertest_set_attr_int(MMCAM_DISPLAY_ROTATION, index);
1525 case 'Y' : // Setting > Flip Display
1527 g_print("\n Select Rotate mode(%d ~ %d)\n", min, max);
1528 g_print("\t0. NONE\n\t1. HORIZONTAL\n\t2. VERTICAL\n\t3. BOTH\n\n");
1529 err = scanf("%d",&index);
1530 camcordertest_set_attr_int(MMCAM_DISPLAY_FLIP, index);
1533 case 'g' : // Setting > Brightness
1534 g_print("*Brightness !\n");
1535 camcordertest_get_attr_valid_intrange("filter-brightness", &min, &max);
1538 g_print("Not supported !! \n");
1541 g_print("\n Select brightness (%d ~ %d)\n", min, max);
1542 err = scanf("%d",&index);
1543 bret = camcordertest_set_attr_int("filter-brightness", index);
1547 case 'c' : // Setting > Contrast
1548 g_print("*Contrast !\n");
1549 camcordertest_get_attr_valid_intrange("filter-contrast", &min, &max);
1552 g_print("Not supported !! \n");
1555 g_print("\n Select Contrast (%d ~ %d)\n", min, max);
1556 err = scanf("%d",&index);
1557 bret = camcordertest_set_attr_int("filter-contrast", index);
1561 case 's' : // Setting > Saturation
1562 g_print("*Saturation !\n");
1563 camcordertest_get_attr_valid_intrange("filter-saturation", &min, &max);
1566 g_print("Not supported !! \n");
1569 g_print("\n Select Saturation (%d ~ %d)\n", min, max);
1570 err = scanf("%d",&index);
1571 bret = camcordertest_set_attr_int("filter-saturation", index);
1575 case 'h' : // Setting > Hue
1576 g_print("*Hue !\n");
1577 camcordertest_get_attr_valid_intrange("filter-hue", &min, &max);
1580 g_print("Not supported !! \n");
1583 g_print("\n Select Hue (%d ~ %d)\n", min, max);
1584 err = scanf("%d",&index);
1585 bret = camcordertest_set_attr_int("filter-hue", index);
1589 case 'a' : // Setting > Sharpness
1590 g_print("*Sharpness !\n");
1591 camcordertest_get_attr_valid_intrange("filter-sharpness", &min, &max);
1594 g_print("Not supported !! \n");
1597 g_print("\n Select Sharpness (%d ~ %d)\n", min, max);
1598 err = scanf("%d",&index);
1599 bret = camcordertest_set_attr_int("filter-sharpness", index);
1603 case 'w' : // Setting > White balance
1604 g_print("*White balance !\n");
1605 camcordertest_get_attr_valid_intarray("filter-wb", &array, &count);
1608 g_print("Not supported !! \n");
1611 g_print("\n Select White balance \n");
1612 for ( i = 0; i < count; i++) {
1613 g_print("\t %d. %s\n", array[i], wb[array[i]]);
1615 err = scanf("%d",&index);
1616 bret = camcordertest_set_attr_int("filter-wb", index);
1620 case 't' : // Setting > Color tone
1621 g_print("*Color tone !\n");
1622 camcordertest_get_attr_valid_intarray("filter-color-tone", &array, &count);
1625 g_print("Not supported !! \n");
1627 g_print("\n Select Color tone \n");
1629 for ( i = 0; i < count; i++) {
1630 g_print("\t %d. %s\n", array[i], ct[array[i]]);
1632 err = scanf("%d",&index);
1633 bret = camcordertest_set_attr_int("filter-color-tone", index);
1637 case 'd' : // Setting > WDR
1638 g_print("*WDR !\n");
1639 camcordertest_get_attr_valid_intarray("camera-wdr", &array, &count);
1642 g_print("Not supported !! \n");
1645 g_print("\n Select WDR Mode \n");
1647 for ( i = 0; i < count; i++) {
1648 g_print("\t %d. %s\n", array[i], wdr_mode[array[i]]);
1650 err = scanf("%d",&index);
1651 bret = camcordertest_set_attr_int("camera-wdr", index);
1655 case 'e' : // Setting > EV program mode
1656 g_print("* EV program mode!\n");
1657 camcordertest_get_attr_valid_intarray("filter-scene-mode", &array, &count);
1660 g_print("Not supported !! \n");
1662 g_print("\n Select EV program mode \n");
1664 for ( i = 0; i < count; i++) {
1665 g_print("\t %d. %s\n", array[i], program_mode[array[i]]);
1667 err = scanf("%d",&index);
1668 bret = camcordertest_set_attr_int("filter-scene-mode", index);
1673 case 'z' : // Setting > Strobe setting
1674 g_print("*Strobe Mode\n");
1675 camcordertest_get_attr_valid_intarray("strobe-mode", &array, &count);
1677 g_print("Not supported !! \n");
1679 g_print("\n Select Strobe Mode \n");
1681 for ( i = 0; i < count; i++) {
1682 g_print("\t %d. %s\n", array[i], strobe_mode[array[i]]);
1684 err = scanf("%d",&index);
1685 bret = camcordertest_set_attr_int("strobe-mode", index);
1689 case 'x' : // Setting > Capture mode ,Muitishot?
1690 g_print("*Select Capture mode!\n");
1692 g_print(" \n\t1. Stillshot mode\n\t2. Multishot mode\n\t3. HDR capture\n");
1693 err = scanf("%d",&index);
1697 g_print("stillshot mode selected and capture callback is set!!!!\n");
1698 hcamcorder->isMultishot = FALSE;
1699 camcordertest_set_attr_int(MMCAM_CAMERA_HDR_CAPTURE, 0);
1702 g_print("Multilshot mode selected!!\n");
1704 camcordertest_set_attr_int(MMCAM_CAMERA_HDR_CAPTURE, 0);
1710 camcordertest_get_attr_valid_intrange("capture-count", &min, &max);
1712 g_print("Not supported !! \n");
1715 //g_print("\n Check Point!!! [Change resolution to 800x480]\n");
1716 g_print("Select mulitshot number (%d ~ %d)\n", min, max);
1717 err = scanf("%d",&index);
1718 if( index >= min && index <= max ) {
1719 multishot_num = index;
1720 mm_camcorder_set_attributes(hcamcorder->camcorder, &err_attr_name,
1721 MMCAM_CAPTURE_COUNT, multishot_num,
1723 hcamcorder->isMultishot = TRUE;
1725 g_print("Wrong input value, Multishot setting failed!!\n");
1730 g_print("HDR Capture mode selected\n");
1731 hcamcorder->isMultishot = FALSE;
1733 camcordertest_get_attr_valid_intarray(MMCAM_CAMERA_HDR_CAPTURE, &array, &count);
1735 g_print("Not supported !! \n");
1737 g_print("\nSelect HDR capture mode\n");
1739 for ( i = 0; i < count; i++) {
1740 g_print("\t %d. %s\n", array[i], hdr_mode[array[i]]);
1742 err = scanf("%d",&index);
1743 bret = camcordertest_set_attr_int(MMCAM_CAMERA_HDR_CAPTURE, index);
1747 g_print("Wrong input, select again!!\n");
1752 case 'l' : // Setting > Face detection setting
1753 //hcamcorder->menu_state = MENU_STATE_SETTING_DETECTION;
1754 g_print("* Face detect mode !\n");
1756 camcordertest_get_attr_valid_intarray("detect-mode", &array, &count);
1757 if(count <= 0 || count > 256) {
1758 g_print("Not supported !! \n");
1760 g_print("\n Face detect mode \n");
1762 for ( i = 0; i < count; i++) {
1763 g_print("\t %d. %s \n", array[i], detection_mode[array[i]]);
1765 err = scanf("%d",&index);
1767 if( index >= 0 && index < count ) {
1768 bret = camcordertest_set_attr_int("detect-mode", array[index]);
1770 g_print("Wrong input value. Try again!!\n");
1776 case 'k' : // Setting > Anti-handshake
1777 g_print("*Anti-handshake !\n");
1778 camcordertest_get_attr_valid_intarray(MMCAM_CAMERA_ANTI_HANDSHAKE, &array, &count);
1781 g_print("Not supported !! \n");
1783 g_print("\n Select Anti-handshake mode \n");
1785 for ( i = 0; i < count; i++) {
1786 g_print("\t %d. %s\n", array[i], ahs_mode[array[i]]);
1788 err = scanf("%d",&index);
1789 bret = camcordertest_set_attr_int(MMCAM_CAMERA_ANTI_HANDSHAKE, index);
1793 case 'K' : // Setting > Video-stabilization
1794 g_print("*Video-stabilization !\n");
1795 camcordertest_get_attr_valid_intarray(MMCAM_CAMERA_VIDEO_STABILIZATION, &array, &count);
1798 g_print("Not supported !! \n");
1800 g_print("\n Select Video-stabilization mode \n");
1802 for ( i = 0; i < count; i++) {
1803 g_print("\t %d. %s\n", array[i], vs_mode[array[i]]);
1805 err = scanf("%d",&index);
1807 if (index == MM_CAMCORDER_VIDEO_STABILIZATION_ON) {
1808 g_print("\n Restart preview with NV12 and 720p resolution\n");
1810 err = mm_camcorder_stop(hcamcorder->camcorder);
1811 if (err == MM_ERROR_NONE) {
1812 err = mm_camcorder_unrealize(hcamcorder->camcorder);
1815 input_pair.attr_subcat_x = MMCAM_CAMERA_WIDTH;
1816 input_pair.attr_subcat_y = MMCAM_CAMERA_HEIGHT;
1817 input_pair.x = 1280;
1819 camcordertest_set_attr_xypair(input_pair);
1820 camcordertest_set_attr_int(MMCAM_CAMERA_FORMAT, MM_PIXEL_FORMAT_NV12);
1821 camcordertest_set_attr_int(MMCAM_CAMERA_VIDEO_STABILIZATION, index);
1823 if (err == MM_ERROR_NONE) {
1824 err = mm_camcorder_realize(hcamcorder->camcorder);
1825 if (err == MM_ERROR_NONE) {
1826 err = mm_camcorder_start(hcamcorder->camcorder);
1830 if (err != MM_ERROR_NONE) {
1831 g_print("\n Restart FAILED! %x\n", err);
1834 camcordertest_set_attr_int(MMCAM_CAMERA_VIDEO_STABILIZATION, index);
1839 case 'u': // Touch AF area
1840 g_print("* Touch AF area !\n");
1841 camcordertest_get_attr_valid_intrange("camera-af-touch-x", &min, &max);
1843 g_print( "Not Supported camera-af-touch-x !!\n" );
1846 camcordertest_get_attr_valid_intrange("camera-af-touch-y", &min, &max);
1848 g_print( "Not Supported camera-af-touch-y !!\n" );
1851 camcordertest_get_attr_valid_intrange("camera-af-touch-width", &min, &max);
1853 g_print( "Not Supported camera-af-touch-width !!\n" );
1856 camcordertest_get_attr_valid_intrange("camera-af-touch-height", &min, &max);
1858 g_print( "Not Supported camera-af-touch-height!!\n" );
1863 g_print( "\n Input x,y,width,height \n" );
1864 err = scanf( "%d,%d,%d,%d", &x, &y, &width, &height );
1865 err = mm_camcorder_set_attributes(hcamcorder->camcorder, &err_attr_name,
1866 MMCAM_CAMERA_AF_TOUCH_X, x,
1867 MMCAM_CAMERA_AF_TOUCH_Y, y,
1868 MMCAM_CAMERA_AF_TOUCH_WIDTH, width,
1869 MMCAM_CAMERA_AF_TOUCH_HEIGHT, height,
1872 if( err != MM_ERROR_NONE ) {
1873 g_print( "Failed to set touch AF area.(%x)(%s)\n", err, err_attr_name );
1874 free( err_attr_name );
1875 err_attr_name = NULL;
1877 g_print( "Succeed to set touch AF area.\n" );
1881 case 'm' : // Setting > Stream callback function
1882 g_print("\n Select Stream Callback Function\n");
1883 g_print("\t 1. Set Video Stream Callback \n");
1884 g_print("\t 2. Unset Video Stream Callback \n");
1886 err = scanf("%d", &index);
1888 video_stream_cb_cnt = 0;
1889 error_num = mm_camcorder_set_video_stream_callback(hcamcorder->camcorder, (mm_camcorder_video_stream_callback)camcordertest_video_stream_cb, (void*)hcamcorder->camcorder);
1890 if( error_num == MM_ERROR_NONE ) {
1891 g_print("\n Setting Success\n");
1893 g_print("\n Setting Failure\n");
1895 } else if(index == 2) {
1896 mm_camcorder_set_video_stream_callback(hcamcorder->camcorder, NULL, (void*)hcamcorder->camcorder);
1897 video_stream_cb_cnt = 0;
1898 audio_stream_cb_cnt = 0;
1899 g_print("\n Unset stream callback success\n");
1901 g_print("\t Invalid input \n");
1906 hcamcorder->menu_state = MENU_STATE_MAIN;
1910 g_print("\t Invalid input \n");
1914 g_print("\t Invalid mode, back to upper menu \n");
1915 hcamcorder->menu_state = MENU_STATE_MAIN;
1921 * This function is to execute command.
1923 * @param channel [in] 1st parameter
1925 * @return This function returns TRUE/FALSE
1929 static gboolean cmd_input(GIOChannel *channel)
1934 debug_msg_t("ENTER");
1936 g_io_channel_read(channel, buf, CAPTURE_FILENAME_LEN, &read);
1940 debug_msg_t("Menu Status : %d", hcamcorder->menu_state);
1941 switch(hcamcorder->menu_state)
1943 case MENU_STATE_MAIN:
1946 case MENU_STATE_SETTING:
1947 setting_menu(buf[0]);
1956 void validity_print(MMCamAttrsInfo *info)
1958 printf("info(%d,%d, %d))\n", info->type, info->flag, info->validity_type);
1959 if (info->validity_type == MM_CAM_ATTRS_VALID_TYPE_INT_ARRAY)
1961 printf("int array(%p, %d)\n", info->int_array.array, info->int_array.count);
1963 else if (info->validity_type == MM_CAM_ATTRS_VALID_TYPE_INT_RANGE)
1965 printf("int range(%d, %d)\n", info->int_range.min, info->int_range.max);
1967 else if (info->validity_type == MM_CAM_ATTRS_VALID_TYPE_DOUBLE_ARRAY)
1969 printf("double array(%p, %d)\n", info->double_array.array, info->double_array.count);
1971 else if(info->validity_type == MM_CAM_ATTRS_VALID_TYPE_DOUBLE_RANGE)
1973 printf("double range(%f, %f)\n", info->double_range.min, info->double_range.max);
1977 printf("validity none\n");
1984 * This function is to initiate camcorder attributes .
1986 * @param type [in] image(capture)/video(recording) mode
1988 * @return This function returns TRUE/FALSE
1990 * @see other functions
1992 static gboolean init(int type)
1996 int preview_format = MM_PIXEL_FORMAT_NV12;
1997 MMHandleType cam_handle = 0;
1999 char *err_attr_name = NULL;
2004 if(!hcamcorder->camcorder)
2007 cam_handle = (MMHandleType)(hcamcorder->camcorder);
2009 /*================================================================================
2011 *=================================================================================*/
2012 if (type == MODE_VIDEO_CAPTURE) {
2013 mm_camcorder_get_attributes((MMHandleType)cam_handle, NULL,
2014 MMCAM_RECOMMEND_PREVIEW_FORMAT_FOR_CAPTURE, &preview_format,
2017 /* camcorder attribute setting */
2018 err = mm_camcorder_set_attributes( (MMHandleType)cam_handle, &err_attr_name,
2019 MMCAM_MODE, MM_CAMCORDER_MODE_VIDEO_CAPTURE,
2020 MMCAM_CAMERA_FORMAT, preview_format,
2021 "camera-delay-attr-setting", TRUE,
2022 MMCAM_IMAGE_ENCODER, MM_IMAGE_CODEC_JPEG,
2023 MMCAM_IMAGE_ENCODER_QUALITY, IMAGE_ENC_QUALITY,
2024 MMCAM_TAG_ENABLE, 1,
2025 MMCAM_TAG_LATITUDE, 35.3036944,
2026 MMCAM_TAG_LONGITUDE, 176.67837,
2027 MMCAM_TAG_ALTITUDE, 190.3455,
2028 MMCAM_DISPLAY_DEVICE, MM_DISPLAY_DEVICE_MAINLCD,
2029 MMCAM_DISPLAY_SURFACE, MM_DISPLAY_SURFACE_X,
2030 MMCAM_DISPLAY_RECT_X, DISPLAY_X_0,
2031 MMCAM_DISPLAY_RECT_Y, DISPLAY_Y_0,
2032 MMCAM_DISPLAY_RECT_WIDTH, 480,
2033 MMCAM_DISPLAY_RECT_HEIGHT, 640,
2034 MMCAM_DISPLAY_ROTATION, MM_DISPLAY_ROTATION_270,
2035 //MMCAM_DISPLAY_FLIP, MM_FLIP_HORIZONTAL,
2036 MMCAM_DISPLAY_GEOMETRY_METHOD, MM_DISPLAY_METHOD_LETTER_BOX,
2037 MMCAM_CAPTURE_COUNT, IMAGE_CAPTURE_COUNT_STILL,
2038 "capture-thumbnail", TRUE,
2039 "tag-gps-time-stamp", 72815.5436243543,
2040 "tag-gps-date-stamp", "2010:09:20", 10,
2041 "tag-gps-processing-method", "GPS NETWORK HYBRID ARE ALL FINE.", 32,
2042 MMCAM_AUDIO_DEVICE, MM_AUDIO_DEVICE_MIC,
2043 MMCAM_AUDIO_ENCODER, MM_AUDIO_CODEC_AAC,
2044 MMCAM_VIDEO_ENCODER, MM_VIDEO_CODEC_MPEG4,
2045 MMCAM_VIDEO_ENCODER_BITRATE, VIDEO_ENCODE_BITRATE,
2046 MMCAM_FILE_FORMAT, MM_FILE_FORMAT_3GP,
2047 MMCAM_CAMERA_FPS, SRC_VIDEO_FRAME_RATE_30,
2048 MMCAM_CAMERA_FPS_AUTO, 0,
2049 MMCAM_CAMERA_ROTATION, MM_VIDEO_INPUT_ROTATION_NONE,
2050 MMCAM_AUDIO_SAMPLERATE, AUDIO_SOURCE_SAMPLERATE_AAC,
2051 MMCAM_AUDIO_FORMAT, AUDIO_SOURCE_FORMAT,
2052 MMCAM_AUDIO_CHANNEL, AUDIO_SOURCE_CHANNEL_AAC,
2053 //MMCAM_AUDIO_DISABLE, TRUE,
2054 MMCAM_TARGET_FILENAME, TARGET_FILENAME_VIDEO, strlen(TARGET_FILENAME_VIDEO),
2055 //MMCAM_TARGET_TIME_LIMIT, 360000,
2056 #ifndef _TIZEN_PUBLIC_
2057 //MMCAM_TARGET_MAX_SIZE, 102400,
2058 #endif /* _TIZEN_PUBLIC_ */
2061 if (err != MM_ERROR_NONE) {
2062 warn_msg_t("Init fail. (%s:%x)", err_attr_name, err);
2063 SAFE_FREE (err_attr_name);
2067 mm_camcorder_set_video_capture_callback(hcamcorder->camcorder, (mm_camcorder_video_capture_callback)camcordertest_video_capture_cb, hcamcorder);
2069 /*================================================================================
2071 *=================================================================================*/
2072 else if (type == MODE_AUDIO)
2074 size = strlen(TARGET_FILENAME_AUDIO)+1;
2076 /* camcorder attribute setting */
2077 err = mm_camcorder_set_attributes( hcamcorder->camcorder, &err_attr_name,
2078 MMCAM_MODE, MM_CAMCORDER_MODE_AUDIO,
2079 MMCAM_AUDIO_DEVICE, MM_AUDIO_DEVICE_MIC,
2080 MMCAM_AUDIO_ENCODER, MM_AUDIO_CODEC_AMR,
2081 MMCAM_FILE_FORMAT, MM_FILE_FORMAT_AMR,
2082 MMCAM_AUDIO_SAMPLERATE, AUDIO_SOURCE_SAMPLERATE_AMR,
2083 MMCAM_AUDIO_FORMAT, AUDIO_SOURCE_FORMAT,
2084 MMCAM_AUDIO_CHANNEL, AUDIO_SOURCE_CHANNEL_AAC,
2085 MMCAM_TARGET_FILENAME, TARGET_FILENAME_AUDIO, size,
2086 MMCAM_TARGET_TIME_LIMIT, 360000,
2087 MMCAM_AUDIO_ENCODER_BITRATE, 12200,
2088 #ifndef _TIZEN_PUBLIC_
2089 MMCAM_TARGET_MAX_SIZE, 300,
2090 #endif /* _TIZEN_PUBLIC_ */
2094 warn_msg_t("Init fail. (%s:%x)", err_attr_name, err);
2095 SAFE_FREE (err_attr_name);
2099 #ifdef USE_AUDIO_STREAM_CB
2100 mm_camcorder_set_audio_stream_callback(hcamcorder->camcorder, (mm_camcorder_audio_stream_callback)camcordertest_audio_stream_cb, (void*)hcamcorder->camcorder);
2101 #endif /* USE_AUDIO_STREAM_CB */
2104 debug_msg_t("Init DONE.");
2109 err_msg_t("init failed.");
2114 * This function is to represent messagecallback
2116 * @param message [in] Specifies the message
2117 * @param param [in] Specifies the message type
2118 * @param user_param [in] Specifies the user poiner for passing to callback function
2119 * @return This function returns TRUE/FALSE
2121 * @see other functions
2123 static gboolean msg_callback(int message, void *msg_param, void *user_param)
2126 MMMessageParamType *param = (MMMessageParamType *) msg_param;
2129 case MM_MESSAGE_CAMCORDER_ERROR:
2130 g_print("MM_MESSAGE_ERROR : code = %x", param->code);
2132 case MM_MESSAGE_CAMCORDER_STATE_CHANGED:
2133 g_current_state = param->state.current;
2134 switch(g_current_state)
2136 case MM_CAMCORDER_STATE_NULL :
2137 mmcamcorder_state = MM_CAMCORDER_STATE_NULL;
2138 debug_msg_t("Camcorder State is [NULL]");
2140 case MM_CAMCORDER_STATE_READY :
2141 mmcamcorder_state = MM_CAMCORDER_STATE_READY;
2142 debug_msg_t("Camcorder State is [READY]");
2144 case MM_CAMCORDER_STATE_PREPARE :
2145 mmcamcorder_state = MM_CAMCORDER_STATE_PREPARE;
2146 debug_msg_t("Camcorder State is [PREPARE]");
2148 case MM_CAMCORDER_STATE_CAPTURING :
2149 mmcamcorder_state = MM_CAMCORDER_STATE_CAPTURING;
2150 debug_msg_t("Camcorder State is [CAPTURING]");
2152 case MM_CAMCORDER_STATE_RECORDING :
2153 mmcamcorder_state = MM_CAMCORDER_STATE_RECORDING;
2154 time_msg_t("Recording start time : %12.6lf s", g_timer_elapsed(timer, NULL));
2155 debug_msg_t("Camcorder State is [RECORDING]");
2157 case MM_CAMCORDER_STATE_PAUSED :
2158 mmcamcorder_state = MM_CAMCORDER_STATE_PAUSED;
2159 debug_msg_t("Camcorder State is [PAUSED]");
2164 case MM_MESSAGE_CAMCORDER_CAPTURED:
2165 time_msg_t("Stillshot capture : %12.6lf s", g_timer_elapsed(timer, NULL));
2166 if (hcamcorder->isMultishot) {
2167 //g_print("[CamcorderApp] Camcorder Captured(Capture Count=%d)\n", param->code);
2168 if (param->code >= multishot_num) {
2170 // g_timeout_add (100, (GSourceFunc)get_me_out, NULL);
2171 // hcamcorder->isMultishot = FALSE;
2175 // g_timeout_add (1000, (GSourceFunc)get_me_out, NULL);
2178 case MM_MESSAGE_CAMCORDER_VIDEO_CAPTURED:
2179 case MM_MESSAGE_CAMCORDER_AUDIO_CAPTURED:
2181 MMCamRecordingReport* report ;
2183 time_msg_t("Recording commit time : %12.6lf s", g_timer_elapsed(timer, NULL));
2186 report = (MMCamRecordingReport*)(param->data);
2191 if (report != NULL) {
2192 g_print("*******************************************************\n");
2193 g_print("[Camcorder Testsuite] Camcorder Captured(filename=%s)\n", report->recording_filename);
2194 g_print("*******************************************************\n");
2196 SAFE_FREE (report->recording_filename);
2199 g_print( "[Camcorder Testsuite] report is NULL.\n" );
2203 case MM_MESSAGE_CAMCORDER_TIME_LIMIT:
2205 debug_msg_t("Got TIME LIMIT MESSAGE");
2208 case MM_MESSAGE_CAMCORDER_RECORDING_STATUS:
2210 unsigned long long elapsed;
2211 elapsed = param->recording_status.elapsed / 1000;
2212 if (hcamcorder->elapsed_time != elapsed) {
2213 unsigned long temp_time;
2214 unsigned long long hour, minute, second;
2215 hcamcorder->elapsed_time = elapsed;
2216 temp_time = elapsed;
2217 hour = temp_time / 3600;
2218 temp_time = elapsed % 3600;
2219 minute = temp_time / 60;
2220 second = temp_time % 60;
2221 debug_msg_t("Current Time - %lld:%lld:%lld, remained %lld ms, filesize %lld KB",
2222 hour, minute, second, param->recording_status.remained_time, param->recording_status.filesize);
2226 case MM_MESSAGE_CAMCORDER_MAX_SIZE:
2229 g_print("*Save Recording because receives message : MM_MESSAGE_CAMCORDER_MAX_SIZE\n");
2230 g_timer_reset(timer);
2231 err = mm_camcorder_commit(hcamcorder->camcorder);
2235 warn_msg_t("Save recording mm_camcorder_commit = %x", err);
2240 case MM_MESSAGE_CAMCORDER_CURRENT_VOLUME:
2242 case MM_MESSAGE_CAMCORDER_NO_FREE_SPACE:
2245 g_print("*Save Recording because receives message : MM_MESSAGE_CAMCORDER_NO_FREE_SPACE\n");
2246 g_timer_reset(timer);
2247 err = mm_camcorder_commit(hcamcorder->camcorder);
2251 warn_msg_t("Save recording mm_camcorder_commit = %x", err);
2256 case MM_MESSAGE_CAMCORDER_FOCUS_CHANGED:
2258 g_print( "Focus State changed. State:[%d]\n", param->code );
2261 case MM_MESSAGE_CAMCORDER_FACE_DETECT_INFO:
2263 static int info_count = 0;
2264 MMCamFaceDetectInfo *cam_fd_info = NULL;
2266 cam_fd_info = (MMCamFaceDetectInfo *)(param->data);
2271 g_print("\tface detect num %d, pointer %p\n", cam_fd_info->num_of_faces, cam_fd_info);
2273 for (i = 0 ; i < cam_fd_info->num_of_faces ; i++) {
2274 g_print("\t\t[%2d][score %d] position %d,%d %dx%d\n",
2275 cam_fd_info->face_info[i].id,
2276 cam_fd_info->face_info[i].score,
2277 cam_fd_info->face_info[i].rect.x,
2278 cam_fd_info->face_info[i].rect.y,
2279 cam_fd_info->face_info[i].rect.width,
2280 cam_fd_info->face_info[i].rect.height);
2283 if (info_count == 0) {
2284 mm_camcorder_set_attributes(hcamcorder->camcorder, NULL,
2285 MMCAM_CAMERA_FACE_ZOOM_MODE, MM_CAMCORDER_FACE_ZOOM_MODE_ON,
2286 MMCAM_CAMERA_FACE_ZOOM_X, cam_fd_info->face_info[0].rect.x + (cam_fd_info->face_info[0].rect.width>>1),
2287 MMCAM_CAMERA_FACE_ZOOM_Y, cam_fd_info->face_info[0].rect.y + (cam_fd_info->face_info[0].rect.height>>1),
2288 MMCAM_CAMERA_FACE_ZOOM_LEVEL, 0,
2291 g_print("\n\t##### START FACE ZOOM [%d,%d] #####\n", cam_fd_info->face_info[0].rect.x, cam_fd_info->face_info[0].rect.y);
2292 } else if (info_count++ == 90) {
2293 mm_camcorder_set_attributes(hcamcorder->camcorder, NULL,
2294 MMCAM_CAMERA_FACE_ZOOM_MODE, MM_CAMCORDER_FACE_ZOOM_MODE_OFF,
2296 g_print("\n\t##### STOP FACE ZOOM #####\n");
2303 g_print("Message %x received\n", message);
2310 static gboolean init_handle()
2312 hcamcorder->mode = MODE_VIDEO_CAPTURE; /* image(capture)/video(recording) mode */
2313 hcamcorder->isMultishot = FALSE;
2314 hcamcorder->stillshot_count = 0; /* total stillshot count */
2315 hcamcorder->multishot_count = 0; /* total multishot count */
2316 hcamcorder->stillshot_filename = STILL_CAPTURE_FILE_PATH_NAME; /* stored filename of stillshot */
2317 hcamcorder->multishot_filename = MULTI_CAPTURE_FILE_PATH_NAME; /* stored filename of multishot */
2318 hcamcorder->menu_state = MENU_STATE_MAIN;
2319 hcamcorder->isMute = FALSE;
2320 hcamcorder->elapsed_time = 0;
2321 hcamcorder->fps = SRC_VIDEO_FRAME_RATE_15; /*SRC_VIDEO_FRAME_RATE_30;*/
2322 multishot_num = IMAGE_CAPTURE_COUNT_MULTI;
2327 * This function is to change camcorder mode.
2329 * @param type [in] image(capture)/video(recording) mode
2331 * @return This function returns TRUE/FALSE
2333 * @see other functions
2335 static gboolean mode_change()
2337 int err = MM_ERROR_NONE;
2338 int state = MM_CAMCORDER_STATE_NONE;
2340 int device_count = 0;
2341 int facing_direction = 0;
2342 char media_type = '\0';
2343 char *evassink_name = NULL;
2346 debug_msg_t("MMCamcorder State : %d", mmcamcorder_state);
2348 err = mm_camcorder_get_state(hcamcorder->camcorder, (MMCamcorderStateType *)&state);
2349 if(state != MM_CAMCORDER_STATE_NONE)
2351 if ((state == MM_CAMCORDER_STATE_RECORDING)
2352 || (state == MM_CAMCORDER_STATE_PAUSED))
2354 debug_msg_t("mm_camcorder_cancel");
2355 err = mm_camcorder_cancel(hcamcorder->camcorder);
2359 warn_msg_t("exit mm_camcorder_cancel = %x", err);
2363 else if (state == MM_CAMCORDER_STATE_CAPTURING)
2365 debug_msg_t("mm_camcorder_capture_stop");
2366 err = mm_camcorder_capture_stop(hcamcorder->camcorder);
2370 warn_msg_t("exit mmcamcorder_capture_stop = %x", err);
2375 err = mm_camcorder_get_state(hcamcorder->camcorder, (MMCamcorderStateType *)&state);
2376 if(state == MM_CAMCORDER_STATE_PREPARE)
2378 debug_msg_t("mm_camcorder_stop");
2379 mm_camcorder_stop(hcamcorder->camcorder);
2382 err = mm_camcorder_get_state(hcamcorder->camcorder, (MMCamcorderStateType *)&state);
2383 if(state == MM_CAMCORDER_STATE_READY)
2385 debug_msg_t("mm_camcorder_unrealize");
2386 mm_camcorder_unrealize(hcamcorder->camcorder);
2389 err = mm_camcorder_get_state(hcamcorder->camcorder, (MMCamcorderStateType *)&state);
2390 if(state == MM_CAMCORDER_STATE_NULL)
2392 debug_msg_t("mm_camcorder_destroy");
2393 mm_camcorder_destroy(hcamcorder->camcorder);
2395 mmcamcorder_state = MM_CAMCORDER_STATE_NONE;
2400 mmcamcorder_print_state = MM_CAMCORDER_STATE_PREPARE;
2402 g_print("\n\t=======================================\n");
2403 g_print("\t MM_CAMCORDER_TESTSUIT\n");
2404 g_print("\t=======================================\n");
2405 g_print("\t '1' Video Capture - Front Camera\n");
2406 g_print("\t '2' Video Capture - Rear Camera\n");
2407 g_print("\t '3' Audio Recording\n");
2408 g_print("\t 'q' Exit\n");
2409 g_print("\t=======================================\n");
2411 g_print("\t Enter the media type:\n\t");
2413 err = scanf("%c", &media_type);
2415 switch (media_type) {
2417 hcamcorder->mode= MODE_VIDEO_CAPTURE;
2418 cam_info.videodev_type = MM_VIDEO_DEVICE_CAMERA1;
2422 hcamcorder->mode= MODE_VIDEO_CAPTURE;
2423 cam_info.videodev_type = MM_VIDEO_DEVICE_CAMERA0;
2427 hcamcorder->mode= MODE_AUDIO;
2428 cam_info.videodev_type = MM_VIDEO_DEVICE_NONE;
2432 g_print("\t Quit Camcorder Testsuite!!\n");
2433 hcamcorder->mode = -1;
2434 if(g_main_loop_is_running(g_loop)) {
2435 g_main_loop_quit(g_loop);
2439 g_print("\t Invalid media type(%d)\n", media_type);
2444 debug_msg_t("mm_camcorder_create");
2445 g_get_current_time(&previous);
2446 g_timer_reset(timer);
2448 err = mm_camcorder_create(&hcamcorder->camcorder, &cam_info);
2449 time_msg_t("mm_camcorder_create() : %12.6lfs", g_timer_elapsed(timer, NULL));
2451 if (err != MM_ERROR_NONE) {
2452 err_msg_t("mmcamcorder_create = %x", err);
2455 mmcamcorder_state = MM_CAMCORDER_STATE_NULL;
2458 /* get evassink name */
2459 mm_camcorder_get_attributes(hcamcorder->camcorder, NULL,
2460 MMCAM_DISPLAY_EVAS_SURFACE_SINK, &evassink_name, &name_size,
2461 MMCAM_CAMERA_DEVICE_COUNT, &device_count,
2462 MMCAM_CAMERA_FACING_DIRECTION, &facing_direction,
2464 debug_msg_t("evassink name[%s], device count[%d], facing direction[%d]",
2465 evassink_name, device_count, facing_direction);
2467 mm_camcorder_set_message_callback(hcamcorder->camcorder, (MMMessageCallback)msg_callback, hcamcorder);
2469 if (!init(hcamcorder->mode)) {
2470 err_msg_t("testsuite init() failed.");
2474 debug_msg_t("mm_camcorder_realize");
2476 g_timer_reset(timer);
2478 err = mm_camcorder_realize(hcamcorder->camcorder);
2479 time_msg_t("mm_camcorder_realize() : %12.6lfs", g_timer_elapsed(timer, NULL));
2480 if (err != MM_ERROR_NONE) {
2481 err_msg_t("mm_camcorder_realize = %x", err);
2485 /* start camcorder */
2486 debug_msg_t("mm_camcorder_start");
2488 g_timer_reset(timer);
2490 err = mm_camcorder_start(hcamcorder->camcorder);
2491 time_msg_t("mm_camcorder_start() : %12.6lfs", g_timer_elapsed(timer, NULL));
2493 if (err != MM_ERROR_NONE) {
2494 err_msg_t("mm_camcorder_start = %x", err);
2498 g_get_current_time(¤t);
2499 timersub(¤t, &previous, &result);
2500 time_msg_t("Camera Starting Time : %ld.%lds", result.tv_sec, result.tv_usec);
2507 * This function is the example main function for mmcamcorder API.
2511 * @return This function returns 0.
2513 * @see other functions
2515 int main(int argc, char **argv)
2519 if (!g_thread_supported())
2520 g_thread_init (NULL);
2522 timer = g_timer_new();
2524 gst_init(&argc, &argv);
2526 time_msg_t("gst_init() : %12.6lfs", g_timer_elapsed(timer, NULL));
2528 hcamcorder = (cam_handle_t *) g_malloc0(sizeof(cam_handle_t));
2529 mmcamcorder_state = MM_CAMCORDER_STATE_NONE;
2531 g_timer_reset(timer);
2533 bret = mode_change();
2540 g_loop = g_main_loop_new(NULL, FALSE);
2542 stdin_channel = g_io_channel_unix_new(fileno(stdin));/* read from stdin */
2543 g_io_add_watch(stdin_channel, G_IO_IN, (GIOFunc)cmd_input, NULL);
2545 debug_msg_t("RUN main loop");
2547 g_main_loop_run(g_loop);
2549 debug_msg_t("STOP main loop");
2552 g_timer_stop(timer);
2553 g_timer_destroy(timer);
2556 //g_print("\t Exit from the application.\n");
2558 g_main_loop_unref(g_loop);
2559 g_io_channel_unref(stdin_channel);