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)
32 10/23/14 p.gamov@samsung.com Upgraded to Gstreamer 1.0
36 /*=======================================================================================
38 =======================================================================================*/
44 #include "../src/include/mm_camcorder.h"
45 #include "../src/include/mm_camcorder_internal.h"
46 #include "../src/include/mm_camcorder_util.h"
47 #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 TARGET_FILENAME_PATH "/opt/usr/media/"
153 #define STILL_CAPTURE_FILE_PATH_NAME TARGET_FILENAME_PATH"StillshotCapture"
154 #define MULTI_CAPTURE_FILE_PATH_NAME TARGET_FILENAME_PATH"MultishotCapture"
155 #define IMAGE_CAPTURE_THUMBNAIL_PATH TARGET_FILENAME_PATH"thumbnail.jpg"
156 #define IMAGE_CAPTURE_SCREENNAIL_PATH TARGET_FILENAME_PATH"screennail.yuv"
157 #define IMAGE_CAPTURE_EXIF_PATH TARGET_FILENAME_PATH"exif.raw"
158 #define TARGET_FILENAME_VIDEO TARGET_FILENAME_PATH"test_rec_video.mp4"
159 #define TARGET_FILENAME_AUDIO TARGET_FILENAME_PATH"test_rec_audio.m4a"
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 g_print("[%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) {free(x); x = NULL;}
221 #define SAFE_G_FREE(x) if(x) {g_free(x); x = NULL;}
230 * Enumerations for command
232 #define SENSOR_WHITEBALANCE_NUM 10
233 #define SENSOR_COLOR_TONE_NUM 30
234 #define SENSOR_FLIP_NUM 3
235 #define SENSOR_PROGRAM_MODE_NUM 15
236 #define SENSOR_FOCUS_NUM 6
237 #define SENSOR_INPUT_ROTATION 4
238 #define SENSOR_AF_SCAN_NUM 4
239 #define SENSOR_ISO_NUM 8
240 #define SENSOR_EXPOSURE_NUM 9
241 #define SENSOR_IMAGE_FORMAT 9
244 /*-----------------------------------------------------------------------
245 | LOCAL CONSTANT DEFINITIONS: |
246 -----------------------------------------------------------------------*/
249 MODE_VIDEO_CAPTURE, /* recording and image capture mode */
250 MODE_AUDIO, /* audio recording*/
261 /*-----------------------------------------------------------------------
262 | LOCAL DATA TYPE DEFINITIONS: |
263 -----------------------------------------------------------------------*/
264 typedef struct _cam_handle
266 MMHandleType camcorder;
267 int mode; /* image(capture)/video(recording) mode */
268 bool isMultishot; /* flag for multishot mode */
269 int stillshot_count; /* total stillshot count */
270 int multishot_count; /* total multishot count */
271 const char *stillshot_filename; /* stored filename of stillshot */
272 const char *multishot_filename; /* stored filename of multishot */
276 unsigned long long elapsed_time;
279 typedef struct _cam_xypair
281 const char *attr_subcat_x;
282 const char *attr_subcat_y;
287 /*---------------------------------------------------------------------------
288 | LOCAL VARIABLE DEFINITIONS: |
289 ---------------------------------------------------------------------------*/
290 static cam_handle_t *hcamcorder ;
292 const char *wb[SENSOR_WHITEBALANCE_NUM]={
305 const char *ct[SENSOR_COLOR_TONE_NUM] = {
331 "SELECTVE_COLOR_RED",
332 "SELECTVE_COLOR_GREEN",
333 "SELECTVE_COLOR_BLUE",
334 "SELECTVE_COLOR_YELLOW",
335 "SELECTVE_COLOR_RED_YELLOW",
338 const char *flip[SENSOR_FLIP_NUM] = {
344 const char *program_mode[SENSOR_PROGRAM_MODE_NUM] = {
362 const char *focus_mode[SENSOR_FOCUS_NUM] = {
371 const char *camera_rotation[SENSOR_INPUT_ROTATION] = {
378 const char *af_scan[SENSOR_AF_SCAN_NUM] = {
385 const char *iso_name[SENSOR_ISO_NUM] = {
396 const char *exposure_mode[SENSOR_EXPOSURE_NUM] = {
408 const char *image_fmt[SENSOR_IMAGE_FORMAT] = {
420 const char *face_zoom_mode[] = {
425 const char *display_mode[] = {
427 "Primary Video ON and Secondary Video Full Screen",
428 "Primary Video OFF and Secondary Video Full Screen",
431 const char *output_mode[] = {
433 "Original Size mode",
435 "Cropped Full Screen mode",
439 const char *capture_sound[] = {
445 const char *rotate_mode[] = {
452 const char* strobe_mode[] = {
456 "Strobe RedEyeReduction",
458 "Strobe FrontCurtain",
459 "Strobe RearCurtain",
463 const char *detection_mode[2] = {
464 "Face Detection OFF",
468 const char *wdr_mode[] = {
474 const char *hdr_mode[] = {
477 "HDR ON and Original",
480 const char *ahs_mode[] = {
481 "Anti-handshake OFF",
483 "Anti-handshake AUTO",
484 "Anti-handshake MOVIE",
487 const char *vs_mode[] = {
488 "Video-stabilization OFF",
489 "Video-stabilization ON",
492 const char *visible_mode[] = {
498 /*---------------------------------------------------------------------------
499 | LOCAL FUNCTION PROTOTYPES: |
500 ---------------------------------------------------------------------------*/
501 static void print_menu();
503 static gboolean cmd_input(GIOChannel *channel);
504 //static bool filename_callback (int format, char *filename, void *user_param);
505 static gboolean msg_callback(int message, void *msg_param, void *user_param);
506 static gboolean init(int type);
507 static gboolean mode_change();
508 int camcordertest_set_attr_int(const char* attr_subcategory, int value);
511 static inline void flush_stdin()
514 while((ch=getchar()) != EOF && ch != '\n');
518 cam_utils_convert_YUYV_to_UYVY(unsigned char* dst, unsigned char* src, gint length)
523 memset(dst, 0x00, length);
524 memcpy(dst, src + 1, length-1);
526 for ( i = 0 ; i < length; i ++)
535 #ifdef USE_AUDIO_STREAM_CB
536 static int camcordertest_audio_stream_cb(MMCamcorderAudioStreamDataType *stream, void *user_param)
538 audio_stream_cb_cnt++;
539 g_print("audio_stream cb is called (stream:%p, data:%p, format:%d, channel:%d, volume_dB:%f, length:%d, timestamp:%d)\n",
540 stream, stream->data, stream->format, stream->channel, stream->volume_dB, stream->length, stream->timestamp);
544 #endif /* USE_AUDIO_STREAM_CB */
546 static int camcordertest_video_stream_cb(MMCamcorderVideoStreamDataType *stream, void *user_param)
548 video_stream_cb_cnt++;
550 g_print("VIDEO STREAM CALLBACK total length :%u, size %dx%d\n", stream->length_total, stream->width, stream->height);
555 static void _file_write(char *path, void *data, int size)
559 if (!path || !data || size <= 0) {
560 g_print("ERROR %p %p %d\n", path, data, size);
564 fp = fopen(path, "w");
566 g_print("open error! [%s], errno %d\n", path, errno);
569 g_print("open success [%s]\n", path);
570 if (fwrite(data, size, 1, fp) != 1) {
571 g_print("write error! errno %d\n", errno);
573 g_print("write success [%s]\n", path);
581 static void _file_write2(const char *path, void *data, int size)
585 if (!path || !data || size <= 0) {
586 g_print("ERROR %p %p %d\n", path, data, size);
590 fp = fopen(path, "w");
592 g_print("open error! [%s], errno %d\n", path, errno);
595 g_print("open success [%s]\n", path);
596 if (fwrite(data, size, 1, fp) != 1) {
597 g_print("write error! errno %d\n", errno);
599 g_print("write success [%s]\n", path);
609 camcordertest_video_capture_cb(MMCamcorderCaptureDataType *main, MMCamcorderCaptureDataType *thumb, void *data)
614 char m_filename[CAPTURE_FILENAME_LEN];
615 MMCamcorderCaptureDataType *scrnl = NULL;
616 unsigned char *exif_data = NULL;
619 warn_msg_t("Capture callback : Main image buffer is NULL!!!");
623 if (hcamcorder->isMultishot) {
624 snprintf(m_filename, CAPTURE_FILENAME_LEN, "%s%03d.jpg", hcamcorder->multishot_filename, hcamcorder->multishot_count++);
626 snprintf(m_filename, CAPTURE_FILENAME_LEN, "%s%03d.jpg", hcamcorder->stillshot_filename, hcamcorder->stillshot_count++);
629 debug_msg_t("hcamcorder->isMultishot=%d =>1: MULTI, 0: STILL, filename : %s",
630 hcamcorder->isMultishot, m_filename);
632 if (main->format != MM_PIXEL_FORMAT_ENCODED) {
633 unsigned int dst_size = 0;
636 nret = _mmcamcorder_encode_jpeg(main->data, main->width, main->height, main->format,
637 main->length, 90, &dst, &dst_size);
639 _file_write(m_filename, dst, dst_size);
641 g_print("Failed to encode YUV(%d) -> JPEG. \n", main->format);
644 } else if (!hcamcorder->isMultishot) {
646 g_print("MM_PIXEL_FORMAT_ENCODED main->data=%p main->length=%d, main->width=%d, main->heigtht=%d \n",
647 main->data, main->length, main->width, main->height);
650 _file_write(m_filename, main->data, main->length);
654 _file_write2(IMAGE_CAPTURE_THUMBNAIL_PATH, thumb->data, thumb->length);
658 mm_camcorder_get_attributes(hcamcorder->camcorder, NULL,
659 "captured-screennail", &scrnl, &scrnl_size,
662 _file_write2(IMAGE_CAPTURE_SCREENNAIL_PATH, scrnl->data, scrnl->length);
664 g_print( "Screennail buffer is NULL.\n" );
668 mm_camcorder_get_attributes(hcamcorder->camcorder, NULL,
669 "captured-exif-raw-data", &exif_data, &exif_size,
672 _file_write2(IMAGE_CAPTURE_EXIF_PATH, exif_data, exif_size);
679 static gboolean test_idle_capture_start()
683 camcordertest_set_attr_int(MMCAM_CAPTURE_FORMAT, MM_PIXEL_FORMAT_ENCODED);
684 camcordertest_set_attr_int(MMCAM_IMAGE_ENCODER, MM_IMAGE_CODEC_JPEG);
686 g_timer_reset(timer);
687 err = mm_camcorder_capture_start(hcamcorder->camcorder);
690 warn_msg_t("Multishot mm_camcorder_capture_start = %x", err);
695 int camcordertest_set_attr_int(const char * attr_subcategory, int value)
697 char * err_attr_name = NULL;
701 if (hcamcorder->camcorder) {
702 debug_msg_t("camcordertest_set_attr_int(%s, %d)", attr_subcategory, value);
704 err = mm_camcorder_set_attributes(hcamcorder->camcorder, &err_attr_name,
705 attr_subcategory, value,
707 if (err != MM_ERROR_NONE) {
708 err_msg_t("camcordertest_set_attr_int : Error(%s:%x)!!!!!!!", err_attr_name, err);
709 SAFE_FREE(err_attr_name);
717 debug_msg_t("camcordertest_set_attr_int(!hcamcorder->camcorde)");
720 debug_msg_t("camcordertest_set_attr_int(!hcamcorder)");
725 int camcordertest_set_attr_xypair(cam_xypair_t pair)
727 char * err_attr_name = NULL;
731 if (hcamcorder->camcorder) {
732 debug_msg_t("camcordertest_set_attr_xypair((%s, %s), (%d, %d))", pair.attr_subcat_x, pair.attr_subcat_y, pair.x, pair.y);
734 err = mm_camcorder_set_attributes(hcamcorder->camcorder, &err_attr_name,
735 pair.attr_subcat_x, pair.x,
736 pair.attr_subcat_y, pair.y,
739 err_msg_t("camcordertest_set_attr_xypair : Error(%s:%x)!!", err_attr_name, err);
740 SAFE_FREE(err_attr_name);
745 SAFE_FREE(err_attr_name);
749 debug_msg_t("camcordertest_set_attr_xypair(!hcamcorder->camcorde)");
752 debug_msg_t("camcordertest_set_attr_xypair(!hcamcorder)");
756 int camcordertest_get_attr_valid_intarray(const char * attr_name, int ** array, int *count)
763 if (hcamcorder->camcorder)
765 debug_msg_t("camcordertest_get_attr_valid_intarray(%s)", attr_name);
767 err = mm_camcorder_get_attribute_info(hcamcorder->camcorder, attr_name, &info);
768 if (err != MM_ERROR_NONE) {
769 err_msg_t("camcordertest_get_attr_valid_intarray : Error(%x)!!", err);
772 if (info.type == MM_CAM_ATTRS_TYPE_INT) {
773 if (info.validity_type == MM_CAM_ATTRS_VALID_TYPE_INT_ARRAY) {
774 *array = info.int_array.array;
775 *count = info.int_array.count;
776 debug_msg_t("INT ARRAY - default value : %d", info.int_array.def);
781 err_msg_t("camcordertest_get_attr_valid_intarray : Type mismatched!!");
787 debug_msg_t("camcordertest_get_attr_valid_intarray(!hcamcorder->camcorde)");
790 debug_msg_t("camcordertest_get_attr_valid_intarray(!hcamcorder)");
794 int camcordertest_get_attr_valid_intrange(const char * attr_name, int *min, int *max)
801 if (hcamcorder->camcorder)
803 debug_msg_t("camcordertest_get_attr_valid_intrange(%s)", attr_name);
805 err = mm_camcorder_get_attribute_info(hcamcorder->camcorder, attr_name, &info);
806 if (err != MM_ERROR_NONE) {
807 err_msg_t("camcordertest_get_attr_valid_intrange : Error(%x)!!", err);
810 if (info.type == MM_CAM_ATTRS_TYPE_INT) {
811 if (info.validity_type == MM_CAM_ATTRS_VALID_TYPE_INT_RANGE) {
812 *min = info.int_range.min;
813 *max = info.int_range.max;
814 debug_msg_t("INT RANGE - default : %d", info.int_range.def);
819 err_msg_t("camcordertest_get_attr_valid_intrange : Type mismatched!!");
826 debug_msg_t("camcordertest_get_attr_valid_intrange(!hcamcorder->camcorde)");
829 debug_msg_t("camcordertest_get_attr_valid_intrange(!hcamcorder)");
836 mm_camcorder_capture_stop(hcamcorder->camcorder);
839 static void print_menu()
841 switch(hcamcorder->menu_state)
843 case MENU_STATE_MAIN:
844 if (hcamcorder->mode == MODE_VIDEO_CAPTURE) {
845 g_print("\n\t=======================================\n");
846 if ( cam_info.videodev_type == MM_VIDEO_DEVICE_CAMERA1 )
847 g_print("\t Video Capture (Front camera)\n");
848 else if( cam_info.videodev_type == MM_VIDEO_DEVICE_CAMERA0 )
849 g_print("\t Video Capture (Rear camera)\n");
850 g_print("\t=======================================\n");
852 if(mmcamcorder_print_state <= MM_CAMCORDER_STATE_PREPARE) {
853 g_print("\t '1' Take a photo\n");
854 g_print("\t '2' Start Recording\n");
855 g_print("\t '3' Setting\n");
856 g_print("\t '4' Print FPS\n");
857 g_print("\t 'b' back\n");
858 } else if(mmcamcorder_print_state == MM_CAMCORDER_STATE_RECORDING) {
859 g_print("\t 'p' Pause Recording\n");
860 g_print("\t 'c' Cancel\n");
861 g_print("\t 's' Save\n");
862 g_print("\t 'n' Capture video snapshot\n");
863 } else if(mmcamcorder_print_state == MM_CAMCORDER_STATE_PAUSED) {
864 g_print("\t 'r' Resume Recording\n");
865 g_print("\t 'c' Cancel\n");
866 g_print("\t 's' Save\n");
867 g_print("\t 'n' Capture video snapshot\n");
869 g_print("\t=======================================\n");
870 } else if (hcamcorder->mode == MODE_AUDIO) {
871 g_print("\n\t=======================================\n");
872 g_print("\t Audio Recording\n");
873 g_print("\t=======================================\n");
874 if(mmcamcorder_print_state <= MM_CAMCORDER_STATE_PREPARE) {
875 g_print("\t '1' Start Recording\n");
876 g_print("\t 'b' back\n");
878 else if(mmcamcorder_print_state == MM_CAMCORDER_STATE_RECORDING) {
879 g_print("\t 'p' Pause Recording\n");
880 g_print("\t 'c' Cancel\n");
881 g_print("\t 's' Save\n");
883 else if(mmcamcorder_print_state == MM_CAMCORDER_STATE_PAUSED) {
884 g_print("\t 'r' Resume Recording\n");
885 g_print("\t 'c' Cancel\n");
886 g_print("\t 's' Save\n");
888 g_print("\t=======================================\n");
892 case MENU_STATE_SETTING:
893 g_print("\n\t=======================================\n");
894 g_print("\t Video Capture > Setting\n");
895 g_print("\t=======================================\n");
896 g_print("\t >>>>>>>>>>>>>>>>>>>>>>>>>>>> [Camera] \n");
897 g_print("\t '0' Preview resolution \n");
898 g_print("\t '1' Capture resolution \n");
899 g_print("\t '2' Digital zoom level \n");
900 g_print("\t '3' Optical zoom level \n");
901 g_print("\t '4' AF mode \n");
902 g_print("\t '5' AF scan range \n");
903 g_print("\t '6' Exposure mode \n");
904 g_print("\t '7' Exposure value \n");
905 g_print("\t '8' F number \n");
906 g_print("\t '9' Shutter speed \n");
907 g_print("\t 'i' ISO \n");
908 g_print("\t 'r' Rotate camera input \n");
909 g_print("\t 'f' Flip camera input \n");
910 g_print("\t 'j' Jpeg quality \n");
911 g_print("\t 'p' Picture format \n");
912 g_print("\t 'E' EXIF orientation \n");
913 g_print("\t >>>>>>>>>>>>>>>>>>>> [Display/Filter]\n");
914 g_print("\t 'v' Visible \n");
915 g_print("\t 'n' Display mode \n");
916 g_print("\t 'o' Output mode \n");
917 g_print("\t 'y' Rotate display \n");
918 g_print("\t 'Y' Flip display \n");
919 g_print("\t 'g' Brightness \n");
920 g_print("\t 'c' Contrast \n");
921 g_print("\t 's' Saturation \n");
922 g_print("\t 'h' Hue \n");
923 g_print("\t 'a' Sharpness \n");
924 g_print("\t 'w' White balance \n");
925 g_print("\t 't' Color tone \n");
926 g_print("\t 'd' WDR \n");
927 g_print("\t 'e' EV program mode \n");
928 g_print("\t >>>>>>>>>>>>>>>>>>>>>>>>>>>>>> [etc.]\n");
929 g_print("\t 'z' Strobe (Flash) \n");
930 g_print("\t 'x' Capture mode (Still/Multishot/HDR)\n");
931 g_print("\t 'l' Face detection \n");
932 g_print("\t 'k' Anti-handshake \n");
933 g_print("\t 'K' Video-stabilization \n");
934 g_print("\t 'u' Touch AF area \n");
935 g_print("\t 'm' Stream callback function \n");
936 g_print("\t 'M' Camcorder Motion Rate setting \n");
937 g_print("\t 'b' back\n");
938 g_print("\t=======================================\n");
942 warn_msg_t("unknow menu state !!\n");
949 static void main_menu(gchar buf)
954 char *err_attr_name = NULL;
956 if (hcamcorder->mode == MODE_VIDEO_CAPTURE) {
957 if (mmcamcorder_state == MM_CAMCORDER_STATE_PREPARE) {
960 if(hcamcorder->isMultishot) {
963 g_print("\ninput interval(ms) \n");
964 err = scanf("%d", &interval);
966 g_print("\nscanf error : errno %d\n", errno);
969 err = mm_camcorder_set_attributes(hcamcorder->camcorder, &err_attr_name,
970 MMCAM_CAPTURE_INTERVAL, interval,
972 if (err != MM_ERROR_NONE) {
973 err_msg_t("Attribute setting fail : (%s:%x)", err_attr_name, err);
974 SAFE_FREE(err_attr_name);
977 err = mm_camcorder_set_attributes(hcamcorder->camcorder, &err_attr_name,
978 MMCAM_CAPTURE_COUNT, IMAGE_CAPTURE_COUNT_STILL,
980 if (err != MM_ERROR_NONE) {
981 err_msg_t("Attribute setting fail : (%s:%x)", err_attr_name, err);
982 SAFE_FREE(err_attr_name);
986 g_idle_add_full(G_PRIORITY_DEFAULT_IDLE, (GSourceFunc)test_idle_capture_start, NULL, NULL);
989 case '2' : // Start Recording
990 g_print("*Recording start!\n");
991 video_stream_cb_cnt = 0;
992 audio_stream_cb_cnt = 0;
993 hcamcorder->elapsed_time = 0;
995 g_timer_reset(timer);
996 err = mm_camcorder_record(hcamcorder->camcorder);
998 if (err != MM_ERROR_NONE) {
999 warn_msg_t("Rec start mm_camcorder_record 0x%x", err);
1002 mmcamcorder_print_state = MM_CAMCORDER_STATE_RECORDING;
1005 case '3' : // Setting
1006 hcamcorder->menu_state = MENU_STATE_SETTING;
1009 case '4' : // Print frame rate
1010 current_fps = _mmcamcorder_video_current_framerate(hcamcorder->camcorder);
1011 average_fps = _mmcamcorder_video_average_framerate(hcamcorder->camcorder);
1012 g_print("\tVideo Frame Rate[Current : %d.0 fps, Average : %d.0 fps]\n", current_fps, average_fps);
1016 hcamcorder->menu_state = MENU_STATE_MAIN;
1021 g_print("\t Invalid input \n");
1024 } else if (mmcamcorder_state == MM_CAMCORDER_STATE_RECORDING || mmcamcorder_state == MM_CAMCORDER_STATE_PAUSED) {
1026 if (mmcamcorder_state == MM_CAMCORDER_STATE_RECORDING) {
1027 case 'p' : // Pause Recording
1028 g_print("*Pause!\n");
1029 err = mm_camcorder_pause(hcamcorder->camcorder);
1032 warn_msg_t("Rec pause mm_camcorder_pause = %x", err);
1034 mmcamcorder_print_state = MM_CAMCORDER_STATE_PAUSED;
1038 case 'r' : // Resume Recording
1039 g_print("*Resume!\n");
1040 err = mm_camcorder_record(hcamcorder->camcorder);
1042 warn_msg_t("Rec start mm_camcorder_record = %x", err);
1044 mmcamcorder_print_state = MM_CAMCORDER_STATE_RECORDING;
1048 case 'c' : // Cancel
1049 g_print("*Cancel Recording !\n");
1051 err = mm_camcorder_cancel(hcamcorder->camcorder);
1054 warn_msg_t("Cancel recording mm_camcorder_cancel = %x", err);
1056 mmcamcorder_print_state = MM_CAMCORDER_STATE_PREPARE;
1060 g_print("*Save Recording!\n");
1061 g_timer_reset(timer);
1063 err = mm_camcorder_commit(hcamcorder->camcorder);
1066 warn_msg_t("Save recording mm_camcorder_commit = %x", err);
1068 mmcamcorder_print_state = MM_CAMCORDER_STATE_PREPARE;
1071 case 'n' : /* Capture video snapshot */
1072 err = mm_camcorder_capture_start(hcamcorder->camcorder);
1076 g_print("\t Invalid input \n");
1080 err_msg_t("Wrong camcorder state, check status!!");
1082 } else if (hcamcorder->mode == MODE_AUDIO) {
1083 if (mmcamcorder_state == MM_CAMCORDER_STATE_PREPARE) {
1085 case '1' : // Start Recording
1086 g_print("*Recording start!\n");
1087 hcamcorder->elapsed_time = 0;
1088 g_timer_reset(timer);
1089 err = mm_camcorder_record(hcamcorder->camcorder);
1092 warn_msg_t("Rec start mm_camcorder_record = %x", err);
1094 mmcamcorder_print_state = MM_CAMCORDER_STATE_RECORDING;
1098 hcamcorder->menu_state = MENU_STATE_MAIN;
1103 g_print("\t Invalid input \n");
1106 } else if (mmcamcorder_state == MM_CAMCORDER_STATE_RECORDING || mmcamcorder_state == MM_CAMCORDER_STATE_PAUSED) {
1108 if (mmcamcorder_state == MM_CAMCORDER_STATE_RECORDING) {
1109 case 'p' : // Pause Recording
1110 g_print("*Pause!\n");
1111 err = mm_camcorder_pause(hcamcorder->camcorder);
1114 warn_msg_t("Rec pause mm_camcorder_pause = %x", err);
1116 mmcamcorder_print_state = MM_CAMCORDER_STATE_PAUSED;
1119 case 'r' : // Resume Recording
1120 g_print("*Resume!\n");
1121 err = mm_camcorder_record(hcamcorder->camcorder);
1123 warn_msg_t("Rec start mm_camcorder_record = %x", err);
1125 mmcamcorder_print_state = MM_CAMCORDER_STATE_RECORDING;
1129 case 'c' : // Cancel
1130 g_print("*Cancel Recording !\n");
1131 err = mm_camcorder_cancel(hcamcorder->camcorder);
1134 warn_msg_t("Cancel recording mm_camcorder_cancel = %x", err);
1136 mmcamcorder_print_state = MM_CAMCORDER_STATE_PREPARE;
1140 g_print("*Save Recording!\n");
1141 g_timer_reset(timer);
1142 err = mm_camcorder_commit(hcamcorder->camcorder);
1145 warn_msg_t("Save recording mm_camcorder_commit = %x", err);
1147 mmcamcorder_print_state = MM_CAMCORDER_STATE_PREPARE;
1151 g_print("\t Invalid input \n");
1155 err_msg_t("Wrong camcorder state, check status!!");
1159 g_print("\t Invalid mode, back to upper menu \n");
1160 hcamcorder->menu_state = MENU_STATE_MAIN;
1166 static void setting_menu(gchar buf)
1168 gboolean bret = FALSE;
1172 int width_count = 0;
1173 int height_count = 0;
1178 int *width_array = NULL;
1179 int *height_array = NULL;
1180 char *err_attr_name = NULL;
1181 cam_xypair_t input_pair;
1182 int err = MM_ERROR_NONE;
1183 int x = 0, y = 0, width = 0, height = 0;
1186 if (hcamcorder->mode == MODE_VIDEO_CAPTURE) {
1188 /* Camera setting */
1189 case '0': // Setting > Preview Resolution setting
1190 g_print("*Select the preview resolution!\n");
1191 camcordertest_get_attr_valid_intarray(MMCAM_CAMERA_WIDTH, &width_array, &width_count);
1192 camcordertest_get_attr_valid_intarray(MMCAM_CAMERA_HEIGHT, &height_array, &height_count);
1194 if(width_count != height_count) {
1195 err_msg_t("System has wrong information!!\n");
1196 } else if (width_count == 0) {
1197 g_print("Not supported!!\n");
1201 for ( i = 0; i < width_count; i++) {
1202 g_print("\t %d. %d*%d\n", i+1, width_array[i], height_array[i]);
1204 err = scanf("%d",&idx);
1206 g_print("\nscanf error : errno %d\n", errno);
1208 if( idx > 0 && idx <= width_count ) {
1209 //Set capture size first
1210 input_pair.attr_subcat_x = MMCAM_CAMERA_WIDTH;
1211 input_pair.attr_subcat_y = MMCAM_CAMERA_HEIGHT;
1212 input_pair.x = width_array[idx-1];
1213 input_pair.y = height_array[idx-1];
1214 bret = camcordertest_set_attr_xypair(input_pair);
1219 case '1' : // Setting > Capture Resolution setting
1220 /* check recommend preview resolution */
1221 camcordertest_get_attr_valid_intarray(MMCAM_RECOMMEND_CAMERA_WIDTH, &width_array, &width_count);
1222 camcordertest_get_attr_valid_intarray(MMCAM_RECOMMEND_CAMERA_HEIGHT, &height_array, &height_count);
1223 if(width_count != height_count) {
1224 err_msg_t("System has wrong information!!\n");
1225 } else if (width_count == 0) {
1226 g_print("MMCAM_RECOMMEND_CAMERA_WIDTH/HEIGHT Not supported!!\n");
1228 g_print("\n - MMCAM_RECOMMEND_CAMERA_WIDTH and HEIGHT (count %d) -\n", width_count);
1229 if (width_count > 0) {
1230 g_print("\t NORMAL ratio : %dx%d\n", width_array[MM_CAMCORDER_PREVIEW_TYPE_NORMAL], height_array[MM_CAMCORDER_PREVIEW_TYPE_NORMAL]);
1232 if (width_count > 1) {
1233 g_print("\t WIDE ratio : %dx%d\n", width_array[MM_CAMCORDER_PREVIEW_TYPE_WIDE], height_array[MM_CAMCORDER_PREVIEW_TYPE_WIDE]);
1235 if (width_count > 2) {
1236 g_print("\t SQUARE ratio : %dx%d\n", width_array[MM_CAMCORDER_PREVIEW_TYPE_SQUARE], height_array[MM_CAMCORDER_PREVIEW_TYPE_SQUARE]);
1240 g_print("*Select the resolution!\n");
1241 camcordertest_get_attr_valid_intarray("capture-width", &width_array, &width_count);
1242 camcordertest_get_attr_valid_intarray("capture-height", &height_array, &height_count);
1244 if(width_count != height_count) {
1245 err_msg_t("System has wrong information!!\n");
1246 } else if (width_count == 0) {
1247 g_print("Not supported!!\n");
1249 g_print("\n Select resolution \n");
1252 for ( i = 0; i < width_count; i++) {
1253 g_print("\t %d. %d*%d\n", i+1, width_array[i], height_array[i]);
1255 err = scanf("%d",&idx);
1257 g_print("\nscanf error : errno %d\n", errno);
1259 if( idx > 0 && idx <= width_count ) {
1260 //Set capture size first
1261 input_pair.attr_subcat_x = "capture-width";
1262 input_pair.attr_subcat_y = "capture-height";
1263 input_pair.x = width_array[idx-1];
1264 input_pair.y = height_array[idx-1];
1265 bret = camcordertest_set_attr_xypair(input_pair);
1271 case '2' : // Setting > Digital zoom level
1272 g_print("*Digital zoom level !\n");
1273 camcordertest_get_attr_valid_intrange("camera-digital-zoom", &min, &max);
1276 g_print("Not supported !! \n");
1279 g_print("\n Select Digital zoom level (%d ~ %d)\n", min, max);
1280 err = scanf("%d",&idx);
1281 bret = camcordertest_set_attr_int("camera-digital-zoom", idx);
1285 case '3' : // Setting > Optical zoom level
1286 g_print("*Optical zoom level !\n");
1287 camcordertest_get_attr_valid_intrange("camera-optical-zoom", &min, &max);
1290 g_print("Not supported !! \n");
1293 g_print("\n Select Optical zoom level (%d ~ %d)\n", min, max);
1294 err = scanf("%d",&idx);
1295 bret = camcordertest_set_attr_int("camera-optical-zoom", idx);
1299 case '4' : // Setting > AF mode
1300 g_print("\t0. AF Mode setting !\n");
1301 g_print("\t1. AF Start !\n");
1302 g_print("\t2. AF Stop !\n\n");
1305 err = scanf("%d", &idx);
1310 g_print("*Focus mode !\n");
1311 camcordertest_get_attr_valid_intarray("camera-focus-mode", &array, &count);
1314 g_print("Not supported !! \n");
1316 g_print("\n Select Focus mode \n");
1318 for (i = 0 ; i < count ; i++) {
1319 g_print("\t %d. %s\n", array[i], focus_mode[array[i]]);
1321 err = scanf("%d",&idx);
1322 bret = camcordertest_set_attr_int("camera-focus-mode", idx);
1327 mm_camcorder_start_focusing(hcamcorder->camcorder);
1330 mm_camcorder_stop_focusing(hcamcorder->camcorder);
1333 g_print("Wrong Input[%d] !! \n", idx);
1338 case '5' : // Setting > AF scan range
1339 g_print("*AF scan range !\n");
1340 camcordertest_get_attr_valid_intarray("camera-af-scan-range", &array, &count);
1343 g_print("Not supported !! \n");
1345 g_print("\n Select AF scan range \n");
1347 for ( i = 0; i < count; i++) {
1348 g_print("\t %d. %s\n", array[i], af_scan[array[i]]);
1350 err = scanf("%d",&idx);
1351 camcordertest_set_attr_int("camera-af-scan-range", idx);
1355 case '6' : // Setting > Exposure mode
1356 g_print("* Exposure mode!\n");
1357 camcordertest_get_attr_valid_intarray("camera-exposure-mode", &array, &count);
1360 g_print("Not supported !! \n");
1362 g_print("\n Select Exposure mode \n");
1364 for ( i = 0; i < count; i++) {
1365 g_print("\t %d. %s\n", array[i], exposure_mode[array[i]]);
1367 err = scanf("%d",&idx);
1368 bret = camcordertest_set_attr_int("camera-exposure-mode", idx);
1372 case '7' : // Setting > Exposure value
1373 g_print("*Exposure value !\n");
1374 camcordertest_get_attr_valid_intrange("camera-exposure-value", &min, &max);
1377 g_print("Not supported !! \n");
1380 g_print("\n Select Exposure value(%d ~ %d)\n", min, max);
1381 err = scanf("%d",&idx);
1382 bret = camcordertest_set_attr_int("camera-exposure-value", idx);
1386 case '8' : // Setting > F number
1387 g_print("Not supported !! \n");
1390 case '9' : // Setting > Shutter speed
1391 g_print("*Shutter speed !\n");
1392 camcordertest_get_attr_valid_intarray("camera-shutter-speed", &array, &count);
1395 g_print("Not supported !! \n");
1397 g_print("\n Select Shutter speed \n");
1399 for ( i = 0; i < count; i++) {
1400 g_print("\t %d. %d \n", i+1, array[i]);
1402 err = scanf("%d",&idx);
1404 if( idx > 0 && idx <= count && count <= 30) {
1405 bret = camcordertest_set_attr_int("camera-shutter-speed", array[idx-1]);
1410 case 'i' : // Setting > ISO
1411 g_print("*ISO !\n");
1412 camcordertest_get_attr_valid_intarray("camera-iso", &array, &count);
1415 g_print("Not supported !! \n");
1417 g_print("\n Select ISO \n");
1419 for ( i = 0; i < count; i++) {
1420 g_print("\t %d. %s\n", array[i], iso_name[array[i]]);
1422 err = scanf("%d",&idx);
1423 bret = camcordertest_set_attr_int("camera-iso", idx);
1427 case 'r' : // Setting > Rotate camera input when recording
1428 g_print("*Rotate camera input\n");
1429 camcordertest_get_attr_valid_intarray(MMCAM_CAMERA_ROTATION, &array, &count);
1432 g_print("Not supported !! \n");
1435 for ( i = 0; i < count; i++) {
1436 g_print("\t %d. %s\n", array[i], camera_rotation[array[i]]);
1438 err = scanf("%d",&idx);
1439 CHECK_MM_ERROR(mm_camcorder_stop(hcamcorder->camcorder));
1440 bret = camcordertest_set_attr_int(MMCAM_CAMERA_ROTATION, idx);
1441 CHECK_MM_ERROR(mm_camcorder_start(hcamcorder->camcorder));
1445 case 'f' : // Setting > Flip camera input
1447 g_print("*Flip camera input\n");
1448 g_print(" 0. Flip NONE\n");
1449 g_print(" 1. Flip HORIZONTAL\n");
1450 g_print(" 2. Flip VERTICAL\n");
1451 g_print(" 3. Flip BOTH\n");
1453 err = scanf("%d", &idx);
1455 CHECK_MM_ERROR(mm_camcorder_stop(hcamcorder->camcorder));
1456 CHECK_MM_ERROR(mm_camcorder_unrealize(hcamcorder->camcorder));
1458 camcordertest_set_attr_int(MMCAM_CAMERA_FLIP, idx);
1460 CHECK_MM_ERROR(mm_camcorder_realize(hcamcorder->camcorder));
1461 CHECK_MM_ERROR(mm_camcorder_start(hcamcorder->camcorder));
1464 case 'j' : // Setting > Jpeg quality
1465 g_print("*Jpeg quality !\n");
1466 camcordertest_get_attr_valid_intrange("image-encoder-quality", &min, &max);
1469 g_print("Not supported !! \n");
1472 g_print("\n Select Jpeg quality (%d ~ %d)\n", min, max);
1473 err = scanf("%d",&idx);
1474 bret = camcordertest_set_attr_int("image-encoder-quality", idx);
1478 case 'p' : // Setting > Picture format
1479 g_print("* Picture format!\n");
1480 camcordertest_get_attr_valid_intarray("camera-format", &array, &count);
1483 g_print("Not supported !! \n");
1485 g_print("\n Select Picture format \n");
1487 for ( i = 0; i < count; i++) {
1488 g_print("\t %d. %s\n", array[i], image_fmt[array[i]]);
1490 err = scanf("%d",&idx);
1491 bret = camcordertest_set_attr_int("camera-format", idx);
1492 CHECK_MM_ERROR(mm_camcorder_stop(hcamcorder->camcorder));
1493 CHECK_MM_ERROR(mm_camcorder_unrealize(hcamcorder->camcorder));
1494 CHECK_MM_ERROR(mm_camcorder_realize(hcamcorder->camcorder));
1495 CHECK_MM_ERROR(mm_camcorder_start(hcamcorder->camcorder));
1499 case 'E' : // Setting > EXIF orientation
1500 g_print("* EXIF Orientation\n");
1502 g_print("\t 1. TOP_LEFT\n");
1503 g_print("\t 2. TOP_RIGHT(flipped)\n");
1504 g_print("\t 3. BOTTOM_RIGHT\n");
1505 g_print("\t 4. BOTTOM_LEFT(flipped)\n");
1506 g_print("\t 5. LEFT_TOP(flipped)\n");
1507 g_print("\t 6. RIGHT_TOP\n");
1508 g_print("\t 7. RIGHT_BOTTOM(flipped)\n");
1509 g_print("\t 8. LEFT_BOTTOM\n");
1512 err = scanf("%d", &idx);
1514 if (idx < 1 || idx > 8) {
1515 g_print("Wrong INPUT[%d]!! \n", idx);
1517 camcordertest_set_attr_int(MMCAM_TAG_ORIENTATION, idx);
1522 /* Display / Filter setting */
1523 case 'v' : // Display visible
1524 g_print("* Display visible setting !\n");
1525 camcordertest_get_attr_valid_intarray( "display-visible", &array, &count );
1528 g_print("Not supported !! \n");
1530 g_print("\n Select Display visible \n");
1532 for ( i = 0; i < count; i++) {
1533 g_print("\t %d. %s\n", array[i], visible_mode[array[i]]);
1535 err = scanf("%d",&value);
1536 bret = camcordertest_set_attr_int( "display-visible", value );
1540 case 'n' : // Setting > Display mode
1541 g_print("* Display mode!\n");
1542 camcordertest_get_attr_valid_intarray(MMCAM_DISPLAY_MODE, &array, &count);
1544 if (count <= 0 || count > 255) {
1545 g_print("Not supported !! \n");
1548 g_print("\n Select Display mode\n");
1549 for (i = 0 ; i < count ; i++) {
1550 g_print("\t %d. %s\n", array[i], display_mode[array[i]]);
1552 err = scanf("%d",&idx);
1553 bret = camcordertest_set_attr_int(MMCAM_DISPLAY_MODE, idx);
1557 case 'o' : // Setting > Output mode
1558 g_print("* Output mode!\n");
1559 camcordertest_get_attr_valid_intrange("display-geometry-method", &min, &max);
1562 g_print("Not supported !! \n");
1565 g_print("\n Select Output mode(%d ~ %d)\n", min, max);
1566 for( i = min ; i <= max ; i++ ) {
1567 g_print( "%d. %s\n", i, output_mode[i] );
1569 err = scanf("%d",&idx);
1570 bret = camcordertest_set_attr_int("display-geometry-method", idx);
1574 case 'y' : // Setting > Rotate Display
1575 camcordertest_get_attr_valid_intrange(MMCAM_DISPLAY_ROTATION, &min, &max);
1578 g_print("Not supported !! \n");
1581 g_print("\n Select Rotate mode(%d ~ %d)\n", min, max);
1582 g_print("\t0. 0\n\t1. 90\n\t2. 180\n\t3. 270\n\n");
1583 err = scanf("%d",&idx);
1584 bret = camcordertest_set_attr_int(MMCAM_DISPLAY_ROTATION, idx);
1588 case 'Y' : // Setting > Flip Display
1590 g_print("\n Select Rotate mode(%d ~ %d)\n", min, max);
1591 g_print("\t0. NONE\n\t1. HORIZONTAL\n\t2. VERTICAL\n\t3. BOTH\n\n");
1592 err = scanf("%d",&idx);
1593 camcordertest_set_attr_int(MMCAM_DISPLAY_FLIP, idx);
1596 case 'g' : // Setting > Brightness
1597 g_print("*Brightness !\n");
1598 camcordertest_get_attr_valid_intrange("filter-brightness", &min, &max);
1601 g_print("Not supported !! \n");
1604 g_print("\n Select brightness (%d ~ %d)\n", min, max);
1605 err = scanf("%d",&idx);
1606 bret = camcordertest_set_attr_int("filter-brightness", idx);
1610 case 'c' : // Setting > Contrast
1611 g_print("*Contrast !\n");
1612 camcordertest_get_attr_valid_intrange("filter-contrast", &min, &max);
1615 g_print("Not supported !! \n");
1618 g_print("\n Select Contrast (%d ~ %d)\n", min, max);
1619 err = scanf("%d",&idx);
1620 bret = camcordertest_set_attr_int("filter-contrast", idx);
1624 case 's' : // Setting > Saturation
1625 g_print("*Saturation !\n");
1626 camcordertest_get_attr_valid_intrange("filter-saturation", &min, &max);
1629 g_print("Not supported !! \n");
1632 g_print("\n Select Saturation (%d ~ %d)\n", min, max);
1633 err = scanf("%d",&idx);
1634 bret = camcordertest_set_attr_int("filter-saturation", idx);
1638 case 'h' : // Setting > Hue
1639 g_print("*Hue !\n");
1640 camcordertest_get_attr_valid_intrange("filter-hue", &min, &max);
1643 g_print("Not supported !! \n");
1646 g_print("\n Select Hue (%d ~ %d)\n", min, max);
1647 err = scanf("%d",&idx);
1648 bret = camcordertest_set_attr_int("filter-hue", idx);
1652 case 'a' : // Setting > Sharpness
1653 g_print("*Sharpness !\n");
1654 camcordertest_get_attr_valid_intrange("filter-sharpness", &min, &max);
1657 g_print("Not supported !! \n");
1660 g_print("\n Select Sharpness (%d ~ %d)\n", min, max);
1661 err = scanf("%d",&idx);
1662 bret = camcordertest_set_attr_int("filter-sharpness", idx);
1666 case 'w' : // Setting > White balance
1667 g_print("*White balance !\n");
1668 camcordertest_get_attr_valid_intarray("filter-wb", &array, &count);
1671 g_print("Not supported !! \n");
1674 g_print("\n Select White balance \n");
1675 for ( i = 0; i < count; i++) {
1676 g_print("\t %d. %s\n", array[i], wb[array[i]]);
1678 err = scanf("%d",&idx);
1679 bret = camcordertest_set_attr_int("filter-wb", idx);
1683 case 't' : // Setting > Color tone
1684 g_print("*Color tone !\n");
1685 camcordertest_get_attr_valid_intarray("filter-color-tone", &array, &count);
1688 g_print("Not supported !! \n");
1690 g_print("\n Select Color tone \n");
1692 for ( i = 0; i < count; i++) {
1693 g_print("\t %d. %s\n", array[i], ct[array[i]]);
1695 err = scanf("%d",&idx);
1696 bret = camcordertest_set_attr_int("filter-color-tone", idx);
1700 case 'd' : // Setting > WDR
1701 g_print("*WDR !\n");
1702 camcordertest_get_attr_valid_intarray("camera-wdr", &array, &count);
1705 g_print("Not supported !! \n");
1708 g_print("\n Select WDR Mode \n");
1710 for ( i = 0; i < count; i++) {
1711 g_print("\t %d. %s\n", array[i], wdr_mode[array[i]]);
1713 err = scanf("%d",&idx);
1714 bret = camcordertest_set_attr_int("camera-wdr", idx);
1718 case 'e' : // Setting > EV program mode
1719 g_print("* EV program mode!\n");
1720 camcordertest_get_attr_valid_intarray("filter-scene-mode", &array, &count);
1723 g_print("Not supported !! \n");
1725 g_print("\n Select EV program mode \n");
1727 for ( i = 0; i < count; i++) {
1728 g_print("\t %d. %s\n", array[i], program_mode[array[i]]);
1730 err = scanf("%d",&idx);
1731 bret = camcordertest_set_attr_int("filter-scene-mode", idx);
1736 case 'z' : // Setting > Strobe setting
1737 g_print("*Strobe Mode\n");
1738 camcordertest_get_attr_valid_intarray("strobe-mode", &array, &count);
1740 g_print("Not supported !! \n");
1742 g_print("\n Select Strobe Mode \n");
1744 for ( i = 0; i < count; i++) {
1745 g_print("\t %d. %s\n", array[i], strobe_mode[array[i]]);
1747 err = scanf("%d",&idx);
1748 bret = camcordertest_set_attr_int("strobe-mode", idx);
1752 case 'x' : // Setting > Capture mode ,Muitishot?
1753 g_print("*Select Capture mode!\n");
1755 g_print(" \n\t1. Stillshot mode\n\t2. Multishot mode\n\t3. HDR capture\n");
1756 err = scanf("%d",&idx);
1760 g_print("stillshot mode selected and capture callback is set!!!!\n");
1761 hcamcorder->isMultishot = FALSE;
1762 camcordertest_set_attr_int(MMCAM_CAMERA_HDR_CAPTURE, 0);
1765 g_print("Multilshot mode selected!!\n");
1767 camcordertest_set_attr_int(MMCAM_CAMERA_HDR_CAPTURE, 0);
1773 camcordertest_get_attr_valid_intrange("capture-count", &min, &max);
1775 g_print("Not supported !! \n");
1778 //g_print("\n Check Point!!! [Change resolution to 800x480]\n");
1779 g_print("Select mulitshot number (%d ~ %d)\n", min, max);
1780 err = scanf("%d",&idx);
1781 if( idx >= min && idx <= max ) {
1782 multishot_num = idx;
1783 mm_camcorder_set_attributes(hcamcorder->camcorder, &err_attr_name,
1784 MMCAM_CAPTURE_COUNT, multishot_num,
1786 hcamcorder->isMultishot = TRUE;
1788 g_print("Wrong input value, Multishot setting failed!!\n");
1793 g_print("HDR Capture mode selected\n");
1794 hcamcorder->isMultishot = FALSE;
1796 camcordertest_get_attr_valid_intarray(MMCAM_CAMERA_HDR_CAPTURE, &array, &count);
1798 g_print("Not supported !! \n");
1800 g_print("\nSelect HDR capture mode\n");
1802 for ( i = 0; i < count; i++) {
1803 g_print("\t %d. %s\n", array[i], hdr_mode[array[i]]);
1805 err = scanf("%d",&idx);
1806 bret = camcordertest_set_attr_int(MMCAM_CAMERA_HDR_CAPTURE, idx);
1810 g_print("Wrong input, select again!!\n");
1815 case 'l' : // Setting > Face detection setting
1816 //hcamcorder->menu_state = MENU_STATE_SETTING_DETECTION;
1817 g_print("* Face detect mode !\n");
1819 camcordertest_get_attr_valid_intarray("detect-mode", &array, &count);
1820 if(count <= 0 || count > 256) {
1821 g_print("Not supported !! \n");
1823 g_print("\n Face detect mode \n");
1825 for ( i = 0; i < count; i++) {
1826 g_print("\t %d. %s \n", array[i], detection_mode[array[i]]);
1828 err = scanf("%d",&idx);
1830 if( idx >= 0 && idx < count ) {
1831 bret = camcordertest_set_attr_int("detect-mode", array[idx]);
1833 g_print("Wrong input value. Try again!!\n");
1839 case 'k' : // Setting > Anti-handshake
1840 g_print("*Anti-handshake !\n");
1841 camcordertest_get_attr_valid_intarray(MMCAM_CAMERA_ANTI_HANDSHAKE, &array, &count);
1844 g_print("Not supported !! \n");
1846 g_print("\n Select Anti-handshake mode \n");
1848 for ( i = 0; i < count; i++) {
1849 g_print("\t %d. %s\n", array[i], ahs_mode[array[i]]);
1851 err = scanf("%d",&idx);
1852 bret = camcordertest_set_attr_int(MMCAM_CAMERA_ANTI_HANDSHAKE, idx);
1856 case 'K' : // Setting > Video-stabilization
1857 g_print("*Video-stabilization !\n");
1858 camcordertest_get_attr_valid_intarray(MMCAM_CAMERA_VIDEO_STABILIZATION, &array, &count);
1861 g_print("Not supported !! \n");
1863 g_print("\n Select Video-stabilization mode \n");
1865 for ( i = 0; i < count; i++) {
1866 g_print("\t %d. %s\n", array[i], vs_mode[array[i]]);
1868 err = scanf("%d",&idx);
1870 if (idx == MM_CAMCORDER_VIDEO_STABILIZATION_ON) {
1871 g_print("\n Restart preview with NV12 and 720p resolution\n");
1873 err = mm_camcorder_stop(hcamcorder->camcorder);
1874 if (err == MM_ERROR_NONE) {
1875 err = mm_camcorder_unrealize(hcamcorder->camcorder);
1878 input_pair.attr_subcat_x = MMCAM_CAMERA_WIDTH;
1879 input_pair.attr_subcat_y = MMCAM_CAMERA_HEIGHT;
1880 input_pair.x = 1280;
1882 camcordertest_set_attr_xypair(input_pair);
1883 camcordertest_set_attr_int(MMCAM_CAMERA_FORMAT, MM_PIXEL_FORMAT_NV12);
1884 camcordertest_set_attr_int(MMCAM_CAMERA_VIDEO_STABILIZATION, idx);
1886 if (err == MM_ERROR_NONE) {
1887 err = mm_camcorder_realize(hcamcorder->camcorder);
1888 if (err == MM_ERROR_NONE) {
1889 err = mm_camcorder_start(hcamcorder->camcorder);
1893 if (err != MM_ERROR_NONE) {
1894 g_print("\n Restart FAILED! %x\n", err);
1897 camcordertest_set_attr_int(MMCAM_CAMERA_VIDEO_STABILIZATION, idx);
1902 case 'u': // Touch AF area
1903 g_print("* Touch AF area !\n");
1904 camcordertest_get_attr_valid_intrange("camera-af-touch-x", &min, &max);
1906 g_print( "Not Supported camera-af-touch-x !!\n" );
1909 camcordertest_get_attr_valid_intrange("camera-af-touch-y", &min, &max);
1911 g_print( "Not Supported camera-af-touch-y !!\n" );
1914 camcordertest_get_attr_valid_intrange("camera-af-touch-width", &min, &max);
1916 g_print( "Not Supported camera-af-touch-width !!\n" );
1919 camcordertest_get_attr_valid_intrange("camera-af-touch-height", &min, &max);
1921 g_print( "Not Supported camera-af-touch-height!!\n" );
1926 g_print( "\n Input x,y,width,height \n" );
1927 err = scanf( "%d,%d,%d,%d", &x, &y, &width, &height );
1928 err = mm_camcorder_set_attributes(hcamcorder->camcorder, &err_attr_name,
1929 MMCAM_CAMERA_AF_TOUCH_X, x,
1930 MMCAM_CAMERA_AF_TOUCH_Y, y,
1931 MMCAM_CAMERA_AF_TOUCH_WIDTH, width,
1932 MMCAM_CAMERA_AF_TOUCH_HEIGHT, height,
1935 if( err != MM_ERROR_NONE ) {
1936 g_print( "Failed to set touch AF area.(%x)(%s)\n", err, err_attr_name );
1937 SAFE_FREE(err_attr_name);
1939 g_print( "Succeed to set touch AF area.\n" );
1943 case 'm' : // Setting > Stream callback function
1944 g_print("\n Select Stream Callback Function\n");
1945 g_print("\t 1. Set Video Stream Callback \n");
1946 g_print("\t 2. Unset Video Stream Callback \n");
1948 err = scanf("%d", &idx);
1950 video_stream_cb_cnt = 0;
1951 error_num = mm_camcorder_set_video_stream_callback(hcamcorder->camcorder, (mm_camcorder_video_stream_callback)camcordertest_video_stream_cb, (void*)hcamcorder->camcorder);
1952 if( error_num == MM_ERROR_NONE ) {
1953 g_print("\n Setting Success\n");
1955 g_print("\n Setting Failure\n");
1957 } else if(idx == 2) {
1958 mm_camcorder_set_video_stream_callback(hcamcorder->camcorder, NULL, (void*)hcamcorder->camcorder);
1959 video_stream_cb_cnt = 0;
1960 audio_stream_cb_cnt = 0;
1961 g_print("\n Unset stream callback success\n");
1963 g_print("\t Invalid input \n");
1969 float motion_rate = 0.0;
1973 g_print("*Camcorder Motion Rate setting! (should be bigger than zero)\n");
1975 err = scanf("%f", &motion_rate);
1976 err = mm_camcorder_set_attributes(hcamcorder->camcorder, &err_attr_name,
1977 MMCAM_CAMERA_RECORDING_MOTION_RATE, motion_rate,
1979 if (err != MM_ERROR_NONE) {
1980 g_print("Failed to set Camcorder Motion Rate %f [err:0x%x]\n", motion_rate, err);
1981 SAFE_FREE(err_attr_name);
1983 g_print("Succeed to set Motion Rate %f\n", motion_rate);
1989 hcamcorder->menu_state = MENU_STATE_MAIN;
1993 g_print("\t Invalid input \n");
1997 g_print("\t Invalid mode, back to upper menu \n");
1998 hcamcorder->menu_state = MENU_STATE_MAIN;
2001 g_print("\t bret : 0x%x \n", bret);
2003 SAFE_FREE(err_attr_name);
2010 * This function is to execute command.
2012 * @param channel [in] 1st parameter
2014 * @return This function returns TRUE/FALSE
2018 static gboolean cmd_input(GIOChannel *channel)
2022 GError *g_error = NULL;
2024 debug_msg_t("ENTER");
2026 g_io_channel_read_line(channel, &buf, &read_size, NULL, &g_error);
2028 debug_msg_t("g_io_channel_read_chars error");
2029 g_error_free(g_error);
2036 debug_msg_t("Menu Status : %d", hcamcorder->menu_state);
2037 switch(hcamcorder->menu_state)
2039 case MENU_STATE_MAIN:
2042 case MENU_STATE_SETTING:
2043 setting_menu(buf[0]);
2052 debug_msg_t("No read input");
2058 void validity_print(MMCamAttrsInfo *info)
2060 g_print("info(%d,%d, %d))\n", info->type, info->flag, info->validity_type);
2061 if (info->validity_type == MM_CAM_ATTRS_VALID_TYPE_INT_ARRAY)
2063 g_print("int array(%p, %d)\n", info->int_array.array, info->int_array.count);
2065 else if (info->validity_type == MM_CAM_ATTRS_VALID_TYPE_INT_RANGE)
2067 g_print("int range(%d, %d)\n", info->int_range.min, info->int_range.max);
2069 else if (info->validity_type == MM_CAM_ATTRS_VALID_TYPE_DOUBLE_ARRAY)
2071 g_print("double array(%p, %d)\n", info->double_array.array, info->double_array.count);
2073 else if(info->validity_type == MM_CAM_ATTRS_VALID_TYPE_DOUBLE_RANGE)
2075 g_print("double range(%f, %f)\n", info->double_range.min, info->double_range.max);
2079 g_print("validity none\n");
2086 * This function is to initiate camcorder attributes .
2088 * @param type [in] image(capture)/video(recording) mode
2090 * @return This function returns TRUE/FALSE
2092 * @see other functions
2094 static gboolean init(int type)
2098 int preview_format = MM_PIXEL_FORMAT_NV12;
2099 int support_zero_copy_format = 0;
2100 int support_media_packet_preview_cb = 0;
2101 int recommend_display_rotation = 0;
2102 MMHandleType cam_handle = 0;
2104 char *err_attr_name = NULL;
2109 if(!hcamcorder->camcorder)
2112 cam_handle = (MMHandleType)(hcamcorder->camcorder);
2114 /*================================================================================
2116 *=================================================================================*/
2117 if (type == MODE_VIDEO_CAPTURE) {
2118 mm_camcorder_get_attributes((MMHandleType)cam_handle, NULL,
2119 MMCAM_RECOMMEND_PREVIEW_FORMAT_FOR_CAPTURE, &preview_format,
2120 MMCAM_SUPPORT_ZERO_COPY_FORMAT, &support_zero_copy_format,
2121 MMCAM_SUPPORT_MEDIA_PACKET_PREVIEW_CB, &support_media_packet_preview_cb,
2122 MMCAM_RECOMMEND_DISPLAY_ROTATION, &recommend_display_rotation,
2125 warn_msg_t("MMCAM_SUPPORT_ZERO_COPY_FORMAT %d", support_zero_copy_format);
2126 warn_msg_t("MMCAM_SUPPORT_MEDIA_PACKET_PREVIEW_CB %d", support_media_packet_preview_cb);
2127 warn_msg_t("MMCAM_RECOMMEND_DISPLAY_ROTATION %d", recommend_display_rotation);
2129 /* camcorder attribute setting */
2130 err = mm_camcorder_set_attributes( (MMHandleType)cam_handle, &err_attr_name,
2131 MMCAM_MODE, MM_CAMCORDER_MODE_VIDEO_CAPTURE,
2132 MMCAM_CAMERA_FORMAT, preview_format,
2133 "camera-delay-attr-setting", TRUE,
2134 MMCAM_IMAGE_ENCODER, MM_IMAGE_CODEC_JPEG,
2135 MMCAM_IMAGE_ENCODER_QUALITY, IMAGE_ENC_QUALITY,
2136 MMCAM_TAG_ENABLE, 1,
2137 MMCAM_TAG_LATITUDE, 35.3036944,
2138 MMCAM_TAG_LONGITUDE, 176.67837,
2139 MMCAM_TAG_ALTITUDE, 190.3455,
2140 MMCAM_DISPLAY_SURFACE, MM_DISPLAY_SURFACE_OVERLAY,
2141 MMCAM_DISPLAY_GEOMETRY_METHOD, MM_DISPLAY_METHOD_LETTER_BOX,
2142 MMCAM_CAPTURE_COUNT, IMAGE_CAPTURE_COUNT_STILL,
2143 MMCAM_TAG_GPS_ENABLE, TRUE,
2144 "tag-gps-time-stamp", 72815.5436243543,
2145 "tag-gps-date-stamp", "2010:09:20", 10,
2146 "tag-gps-processing-method", "GPS NETWORK HYBRID ARE ALL FINE.", 32,
2147 MMCAM_AUDIO_DEVICE, MM_AUDIO_DEVICE_MIC,
2148 MMCAM_AUDIO_ENCODER, MM_AUDIO_CODEC_AAC,
2149 MMCAM_VIDEO_ENCODER, MM_VIDEO_CODEC_MPEG4,
2150 MMCAM_VIDEO_ENCODER_BITRATE, VIDEO_ENCODE_BITRATE,
2151 MMCAM_FILE_FORMAT, MM_FILE_FORMAT_MP4,
2152 MMCAM_CAMERA_FPS, SRC_VIDEO_FRAME_RATE_30,
2153 MMCAM_CAMERA_FPS_AUTO, 0,
2154 MMCAM_CAMERA_ROTATION, MM_VIDEO_INPUT_ROTATION_NONE,
2155 MMCAM_AUDIO_SAMPLERATE, AUDIO_SOURCE_SAMPLERATE_AAC,
2156 MMCAM_AUDIO_FORMAT, AUDIO_SOURCE_FORMAT,
2157 MMCAM_AUDIO_CHANNEL, AUDIO_SOURCE_CHANNEL_AAC,
2158 //MMCAM_AUDIO_DISABLE, TRUE,
2159 MMCAM_TARGET_FILENAME, TARGET_FILENAME_VIDEO, strlen(TARGET_FILENAME_VIDEO),
2160 //MMCAM_TARGET_TIME_LIMIT, 360000,
2161 //MMCAM_TARGET_MAX_SIZE, 102400,
2162 MMCAM_RECORDER_TAG_ENABLE, 1,
2163 MMCAM_TAG_VIDEO_ORIENTATION, 1,
2164 MMCAM_DISPLAY_ROTATION, recommend_display_rotation,
2167 if (err != MM_ERROR_NONE) {
2168 warn_msg_t("Init fail. (%s:%x)", err_attr_name, err);
2169 SAFE_FREE(err_attr_name);
2173 mm_camcorder_set_video_capture_callback(hcamcorder->camcorder, (mm_camcorder_video_capture_callback)camcordertest_video_capture_cb, hcamcorder);
2175 /*================================================================================
2177 *=================================================================================*/
2178 else if (type == MODE_AUDIO)
2180 size = strlen(TARGET_FILENAME_AUDIO)+1;
2182 /* camcorder attribute setting */
2183 err = mm_camcorder_set_attributes( hcamcorder->camcorder, &err_attr_name,
2184 MMCAM_MODE, MM_CAMCORDER_MODE_AUDIO,
2185 MMCAM_AUDIO_DEVICE, MM_AUDIO_DEVICE_MIC,
2186 MMCAM_AUDIO_ENCODER, MM_AUDIO_CODEC_AAC,
2187 MMCAM_FILE_FORMAT, MM_FILE_FORMAT_MP4,
2188 MMCAM_AUDIO_SAMPLERATE, AUDIO_SOURCE_SAMPLERATE_AAC,
2189 MMCAM_AUDIO_FORMAT, AUDIO_SOURCE_FORMAT,
2190 MMCAM_AUDIO_CHANNEL, AUDIO_SOURCE_CHANNEL_AAC,
2191 MMCAM_TARGET_FILENAME, TARGET_FILENAME_AUDIO, size,
2192 MMCAM_TARGET_TIME_LIMIT, 360000,
2193 MMCAM_AUDIO_ENCODER_BITRATE, 128000,
2194 MMCAM_TARGET_MAX_SIZE, 300,
2198 warn_msg_t("Init fail. (%s:%x)", err_attr_name, err);
2199 SAFE_FREE(err_attr_name);
2203 #ifdef USE_AUDIO_STREAM_CB
2204 mm_camcorder_set_audio_stream_callback(hcamcorder->camcorder, (mm_camcorder_audio_stream_callback)camcordertest_audio_stream_cb, (void*)hcamcorder->camcorder);
2205 #endif /* USE_AUDIO_STREAM_CB */
2207 SAFE_FREE (err_attr_name);
2208 debug_msg_t("Init DONE.");
2213 err_msg_t("init failed.");
2218 * This function is to represent messagecallback
2220 * @param message [in] Specifies the message
2221 * @param param [in] Specifies the message type
2222 * @param user_param [in] Specifies the user poiner for passing to callback function
2223 * @return This function returns TRUE/FALSE
2225 * @see other functions
2227 static gboolean msg_callback(int message, void *msg_param, void *user_param)
2230 MMMessageParamType *param = (MMMessageParamType *) msg_param;
2233 case MM_MESSAGE_CAMCORDER_ERROR:
2234 g_print("MM_MESSAGE_ERROR : code = %x", param->code);
2236 case MM_MESSAGE_CAMCORDER_STATE_CHANGED:
2237 g_current_state = param->state.current;
2238 switch(g_current_state)
2240 case MM_CAMCORDER_STATE_NULL :
2241 mmcamcorder_state = MM_CAMCORDER_STATE_NULL;
2242 debug_msg_t("Camcorder State is [NULL]");
2244 case MM_CAMCORDER_STATE_READY :
2245 mmcamcorder_state = MM_CAMCORDER_STATE_READY;
2246 debug_msg_t("Camcorder State is [READY]");
2248 case MM_CAMCORDER_STATE_PREPARE :
2249 mmcamcorder_state = MM_CAMCORDER_STATE_PREPARE;
2250 debug_msg_t("Camcorder State is [PREPARE]");
2252 case MM_CAMCORDER_STATE_CAPTURING :
2253 mmcamcorder_state = MM_CAMCORDER_STATE_CAPTURING;
2254 debug_msg_t("Camcorder State is [CAPTURING]");
2256 case MM_CAMCORDER_STATE_RECORDING :
2257 mmcamcorder_state = MM_CAMCORDER_STATE_RECORDING;
2258 time_msg_t("Recording start time : %12.6lf s", g_timer_elapsed(timer, NULL));
2259 debug_msg_t("Camcorder State is [RECORDING]");
2261 case MM_CAMCORDER_STATE_PAUSED :
2262 mmcamcorder_state = MM_CAMCORDER_STATE_PAUSED;
2263 debug_msg_t("Camcorder State is [PAUSED]");
2266 debug_msg_t("Unknown State [%d]", g_current_state);
2271 case MM_MESSAGE_CAMCORDER_CAPTURED:
2272 time_msg_t("Stillshot capture : %12.6lf s", g_timer_elapsed(timer, NULL));
2273 if (hcamcorder->isMultishot) {
2274 //g_print("[CamcorderApp] Camcorder Captured(Capture Count=%d)\n", param->code);
2275 if (param->code >= multishot_num) {
2277 // g_timeout_add (100, (GSourceFunc)get_me_out, NULL);
2278 // hcamcorder->isMultishot = FALSE;
2282 // g_timeout_add (1000, (GSourceFunc)get_me_out, NULL);
2285 case MM_MESSAGE_CAMCORDER_VIDEO_CAPTURED:
2286 case MM_MESSAGE_CAMCORDER_AUDIO_CAPTURED:
2288 MMCamRecordingReport* report ;
2290 time_msg_t("Recording commit time : %12.6lf s", g_timer_elapsed(timer, NULL));
2293 report = (MMCamRecordingReport*)(param->data);
2298 if (report != NULL) {
2299 g_print("*******************************************************\n");
2300 g_print("[Camcorder Testsuite] Camcorder Captured(filename=%s)\n", report->recording_filename);
2301 g_print("*******************************************************\n");
2303 g_print( "[Camcorder Testsuite] report is NULL.\n" );
2307 case MM_MESSAGE_CAMCORDER_TIME_LIMIT:
2309 debug_msg_t("Got TIME LIMIT MESSAGE");
2312 case MM_MESSAGE_CAMCORDER_RECORDING_STATUS:
2314 unsigned long long elapsed;
2315 elapsed = param->recording_status.elapsed / 1000;
2316 if (hcamcorder->elapsed_time != elapsed) {
2317 unsigned long temp_time;
2318 unsigned long long hour, minute, second;
2319 hcamcorder->elapsed_time = elapsed;
2320 temp_time = elapsed;
2321 hour = temp_time / 3600;
2322 temp_time = elapsed % 3600;
2323 minute = temp_time / 60;
2324 second = temp_time % 60;
2325 debug_msg_t("Current Time - %lld:%lld:%lld, remained %lld ms, filesize %lld KB",
2326 hour, minute, second, param->recording_status.remained_time, param->recording_status.filesize);
2330 case MM_MESSAGE_CAMCORDER_MAX_SIZE:
2333 g_print("*Save Recording because receives message : MM_MESSAGE_CAMCORDER_MAX_SIZE\n");
2334 g_timer_reset(timer);
2335 err = mm_camcorder_commit(hcamcorder->camcorder);
2339 warn_msg_t("Save recording mm_camcorder_commit = %x", err);
2344 case MM_MESSAGE_CAMCORDER_CURRENT_VOLUME:
2346 case MM_MESSAGE_CAMCORDER_NO_FREE_SPACE:
2349 g_print("*Save Recording because receives message : MM_MESSAGE_CAMCORDER_NO_FREE_SPACE\n");
2350 g_timer_reset(timer);
2351 err = mm_camcorder_commit(hcamcorder->camcorder);
2355 warn_msg_t("Save recording mm_camcorder_commit = %x", err);
2360 case MM_MESSAGE_CAMCORDER_FOCUS_CHANGED:
2362 g_print( "Focus State changed. State:[%d]\n", param->code );
2365 case MM_MESSAGE_CAMCORDER_FACE_DETECT_INFO:
2367 MMCamFaceDetectInfo *cam_fd_info = NULL;
2369 cam_fd_info = (MMCamFaceDetectInfo *)(param->data);
2374 g_print("\tface detect num %d, pointer %p\n", cam_fd_info->num_of_faces, cam_fd_info);
2376 for (i = 0 ; i < cam_fd_info->num_of_faces ; i++) {
2377 g_print("\t\t[%2d][score %d] position %d,%d %dx%d\n",
2378 cam_fd_info->face_info[i].id,
2379 cam_fd_info->face_info[i].score,
2380 cam_fd_info->face_info[i].rect.x,
2381 cam_fd_info->face_info[i].rect.y,
2382 cam_fd_info->face_info[i].rect.width,
2383 cam_fd_info->face_info[i].rect.height);
2389 g_print("Message %x received\n", message);
2396 static gboolean init_handle()
2398 hcamcorder->mode = MODE_VIDEO_CAPTURE; /* image(capture)/video(recording) mode */
2399 hcamcorder->isMultishot = FALSE;
2400 hcamcorder->stillshot_count = 0; /* total stillshot count */
2401 hcamcorder->multishot_count = 0; /* total multishot count */
2402 hcamcorder->stillshot_filename = STILL_CAPTURE_FILE_PATH_NAME; /* stored filename of stillshot */
2403 hcamcorder->multishot_filename = MULTI_CAPTURE_FILE_PATH_NAME; /* stored filename of multishot */
2404 hcamcorder->menu_state = MENU_STATE_MAIN;
2405 hcamcorder->isMute = FALSE;
2406 hcamcorder->elapsed_time = 0;
2407 hcamcorder->fps = SRC_VIDEO_FRAME_RATE_15; /*SRC_VIDEO_FRAME_RATE_30;*/
2408 multishot_num = IMAGE_CAPTURE_COUNT_MULTI;
2413 * This function is to change camcorder mode.
2415 * @param type [in] image(capture)/video(recording) mode
2417 * @return This function returns TRUE/FALSE
2419 * @see other functions
2421 static gboolean mode_change()
2423 int err = MM_ERROR_NONE;
2424 int state = MM_CAMCORDER_STATE_NONE;
2426 int device_count = 0;
2427 int facing_direction = 0;
2428 char media_type = '\0';
2429 char *evassink_name = NULL;
2432 debug_msg_t("MMCamcorder State : %d", mmcamcorder_state);
2434 err = mm_camcorder_get_state(hcamcorder->camcorder, (MMCamcorderStateType *)&state);
2435 if(state != MM_CAMCORDER_STATE_NONE)
2437 if ((state == MM_CAMCORDER_STATE_RECORDING)
2438 || (state == MM_CAMCORDER_STATE_PAUSED))
2440 debug_msg_t("mm_camcorder_cancel");
2441 err = mm_camcorder_cancel(hcamcorder->camcorder);
2445 warn_msg_t("exit mm_camcorder_cancel = %x", err);
2449 else if (state == MM_CAMCORDER_STATE_CAPTURING)
2451 debug_msg_t("mm_camcorder_capture_stop");
2452 err = mm_camcorder_capture_stop(hcamcorder->camcorder);
2456 warn_msg_t("exit mmcamcorder_capture_stop = %x", err);
2461 err = mm_camcorder_get_state(hcamcorder->camcorder, (MMCamcorderStateType *)&state);
2462 if(state == MM_CAMCORDER_STATE_PREPARE)
2464 debug_msg_t("mm_camcorder_stop");
2465 mm_camcorder_stop(hcamcorder->camcorder);
2468 err = mm_camcorder_get_state(hcamcorder->camcorder, (MMCamcorderStateType *)&state);
2469 if(state == MM_CAMCORDER_STATE_READY)
2471 debug_msg_t("mm_camcorder_unrealize");
2472 mm_camcorder_unrealize(hcamcorder->camcorder);
2475 err = mm_camcorder_get_state(hcamcorder->camcorder, (MMCamcorderStateType *)&state);
2476 if(state == MM_CAMCORDER_STATE_NULL)
2478 debug_msg_t("mm_camcorder_destroy");
2479 mm_camcorder_destroy(hcamcorder->camcorder);
2481 mmcamcorder_state = MM_CAMCORDER_STATE_NONE;
2486 mmcamcorder_print_state = MM_CAMCORDER_STATE_PREPARE;
2488 g_print("\n\t=======================================\n");
2489 g_print("\t MM_CAMCORDER_TESTSUIT\n");
2490 g_print("\t=======================================\n");
2491 g_print("\t '1' Video Capture - Front Camera\n");
2492 g_print("\t '2' Video Capture - Rear Camera\n");
2493 g_print("\t '3' Audio Recording\n");
2494 g_print("\t 'q' Exit\n");
2495 g_print("\t=======================================\n");
2497 g_print("\t Enter the media type:\n\t");
2499 err = scanf("%c", &media_type);
2501 g_print("\t!!!read input error!!!\n");
2505 switch (media_type) {
2507 hcamcorder->mode= MODE_VIDEO_CAPTURE;
2508 cam_info.videodev_type = MM_VIDEO_DEVICE_CAMERA1;
2512 hcamcorder->mode= MODE_VIDEO_CAPTURE;
2513 cam_info.videodev_type = MM_VIDEO_DEVICE_CAMERA0;
2517 hcamcorder->mode= MODE_AUDIO;
2518 cam_info.videodev_type = MM_VIDEO_DEVICE_NONE;
2522 g_print("\t Quit Camcorder Testsuite!!\n");
2523 hcamcorder->mode = -1;
2524 if(g_main_loop_is_running(g_loop)) {
2525 g_main_loop_quit(g_loop);
2529 g_print("\t Invalid media type(%d)\n", media_type);
2534 debug_msg_t("mm_camcorder_create");
2535 g_get_current_time(&previous);
2536 g_timer_reset(timer);
2538 err = mm_camcorder_create(&hcamcorder->camcorder, &cam_info);
2539 time_msg_t("mm_camcorder_create() : %12.6lfs", g_timer_elapsed(timer, NULL));
2541 if (err != MM_ERROR_NONE) {
2542 err_msg_t("mmcamcorder_create = %x", err);
2545 mmcamcorder_state = MM_CAMCORDER_STATE_NULL;
2548 /* get evassink name */
2549 mm_camcorder_get_attributes(hcamcorder->camcorder, NULL,
2550 MMCAM_DISPLAY_EVAS_SURFACE_SINK, &evassink_name, &name_size,
2551 MMCAM_CAMERA_DEVICE_COUNT, &device_count,
2552 MMCAM_CAMERA_FACING_DIRECTION, &facing_direction,
2554 debug_msg_t("evassink name[%s], device count[%d], facing direction[%d]",
2555 evassink_name, device_count, facing_direction);
2557 mm_camcorder_set_message_callback(hcamcorder->camcorder, (MMMessageCallback)msg_callback, hcamcorder);
2559 if (!init(hcamcorder->mode)) {
2560 err_msg_t("testsuite init() failed.");
2564 debug_msg_t("mm_camcorder_realize");
2566 g_timer_reset(timer);
2568 err = mm_camcorder_realize(hcamcorder->camcorder);
2569 time_msg_t("mm_camcorder_realize() : %12.6lfs", g_timer_elapsed(timer, NULL));
2570 if (err != MM_ERROR_NONE) {
2571 err_msg_t("mm_camcorder_realize = %x", err);
2575 /* start camcorder */
2576 debug_msg_t("mm_camcorder_start");
2578 g_timer_reset(timer);
2580 err = mm_camcorder_start(hcamcorder->camcorder);
2581 time_msg_t("mm_camcorder_start() : %12.6lfs", g_timer_elapsed(timer, NULL));
2583 if (err != MM_ERROR_NONE) {
2584 err_msg_t("mm_camcorder_start = %x", err);
2588 g_get_current_time(¤t);
2589 timersub(¤t, &previous, &result);
2590 time_msg_t("Camera Starting Time : %ld.%lds", result.tv_sec, result.tv_usec);
2597 * This function is the example main function for mmcamcorder API.
2601 * @return This function returns 0.
2603 * @see other functions
2605 int main(int argc, char **argv)
2609 timer = g_timer_new();
2611 gst_init(&argc, &argv);
2613 time_msg_t("gst_init() : %12.6lfs", g_timer_elapsed(timer, NULL));
2615 hcamcorder = (cam_handle_t *) g_malloc0(sizeof(cam_handle_t));
2616 mmcamcorder_state = MM_CAMCORDER_STATE_NONE;
2618 g_timer_reset(timer);
2620 bret = mode_change();
2627 g_loop = g_main_loop_new(NULL, FALSE);
2629 stdin_channel = g_io_channel_unix_new(fileno(stdin));/* read from stdin */
2630 g_io_add_watch(stdin_channel, G_IO_IN, (GIOFunc)cmd_input, NULL);
2632 debug_msg_t("RUN main loop");
2634 g_main_loop_run(g_loop);
2636 debug_msg_t("STOP main loop");
2639 g_timer_stop(timer);
2640 g_timer_destroy(timer);
2643 //g_print("\t Exit from the application.\n");
2645 g_main_loop_unref(g_loop);
2646 g_io_channel_unref(stdin_channel);