Improve PP(PredefinedPreprocessor) score
[platform/core/api/recorder.git] / test / recorder_test.c
index d0ecfd5..f53dbd7 100644 (file)
   -----------------------------------------------------------------------*/
 #define EXPORT_API __attribute__((__visibility__("default")))
 
-#ifdef LOG_TAG
-#undef LOG_TAG
-#endif
-#define LOG_TAG "RECORDER_TESTSUITE"
-
-#ifdef PACKAGE
-#undef PACKAGE
-#endif
-#define PACKAGE "recorder_test"
-
 
 static int app_create(void *data);
 static int app_terminate(void *data);
@@ -348,15 +338,20 @@ static void _recording_muxed_stream_cb(void *stream, int size, unsigned long lon
        return;
 }
 
-static bool _recording_video_encode_decision_cb(recorder_video_data_s *frame, void *user_data)
+
+static void _dump_video_frame(recorder_video_data_s *frame)
 {
-#if 0
        FILE *fp = NULL;
 
+       if (!frame) {
+               g_print("\n==== NULL video frame ====\n");
+               return;
+       }
+
        fp = fopen(TARGET_FILENAME_VE_DECISION_CB, "a");
        if (fp == NULL) {
                g_print("\n==== file[%s] open failed ====\n", TARGET_FILENAME_VE_DECISION_CB);
-               return true;
+               return;
        }
 
        if (frame->format == CAMERA_PIXEL_FORMAT_RGBA ||
@@ -387,12 +382,17 @@ static bool _recording_video_encode_decision_cb(recorder_video_data_s *frame, vo
 
        fclose(fp);
        fp = NULL;
-#endif
+}
+
 
+static bool _recording_video_encode_decision_cb(recorder_video_data_s *frame, void *user_data)
+{
        if (ve_frame_count == 0) {
                g_print("==== VE decision cb : file[%s][fmt %d, %dx%d, plane %d] ====\n",
                        TARGET_FILENAME_VE_DECISION_CB,
                        frame->format, frame->width, frame->height, frame->num_of_planes);
+
+               _dump_video_frame(frame);
        }
 
        if ((ve_frame_count++ % 10) >= 5) {
@@ -610,8 +610,8 @@ static void print_menu()
                g_print("\t   RECORDER_TESTSUIT\n");
                g_print("\t=======================================\n");
                g_print("\t   '1' Video Recording - Rear Camera\n");
-               g_print("\t   '2' Audio Recording - MIC\n");
-               g_print("\t   '3' Audio Recording - MODEM\n");
+               g_print("\t   '2' Audio Recording\n");
+               g_print("\t   '3' Audio Recording with stream info\n");
                g_print("\t   '4' Add recorder device changed callback\n");
                g_print("\t   '5' Remove recorder device changed callback\n");
                g_print("\t   '6' Get recorder device state\n");
@@ -1258,14 +1258,13 @@ static gboolean init_handle()
        return TRUE;
 }
 
-#ifdef USE_SOUND_STREAM_INFO
 static void _sound_stream_focus_state_changed_cb(sound_stream_info_h stream_info, sound_stream_focus_mask_e focus_mask, sound_stream_focus_state_e focus_state,
        sound_stream_focus_change_reason_e reason_for_change, int sound_behavior, const char *additional_info, void *user_data)
 {
        g_print("focus changed : reason %d\n", reason_for_change);
        return;
 }
-#endif /* USE_SOUND_STREAM_INFO */
+
 
 /**
  * This function is to change camcorder mode.
@@ -1283,6 +1282,7 @@ static gboolean mode_change(gchar buf)
        char media_type = '\0';
        bool check = FALSE;
        recorder_device_state_e device_state = RECORDER_DEVICE_STATE_IDLE;
+       sound_stream_info_h stream_info = NULL;
 
        gettimeofday(&previous, NULL);
        g_timer_reset(timer);
@@ -1359,26 +1359,6 @@ static gboolean mode_change(gchar buf)
                        return FALSE;
                }
 
-#ifdef USE_SOUND_STREAM_INFO
-               {
-                       sound_stream_info_h stream_info = NULL;
-
-                       sound_manager_create_stream_information(SOUND_STREAM_TYPE_MEDIA, _sound_stream_focus_state_changed_cb, hcamcorder, &stream_info);
-                       if (stream_info) {
-                               recorder_set_sound_stream_info(hcamcorder->recorder, stream_info);
-                               sound_manager_destroy_stream_information(stream_info);
-                       }
-               }
-#endif /* USE_SOUND_STREAM_INFO */
-
-               err = recorder_attr_set_audio_device(hcamcorder->recorder, RECORDER_AUDIO_DEVICE_MIC);
-               if (err != RECORDER_ERROR_NONE) {
-                       g_print("set audio device failed 0x%x\n", err);
-                       recorder_destroy(hcamcorder->recorder);
-                       hcamcorder->recorder = NULL;
-                       return FALSE;
-               }
-
                check = TRUE;
                break;
        case '3':
@@ -1389,12 +1369,10 @@ static gboolean mode_change(gchar buf)
                        return FALSE;
                }
 
-               err = recorder_attr_set_audio_device(hcamcorder->recorder, RECORDER_AUDIO_DEVICE_MODEM);
-               if (err != RECORDER_ERROR_NONE) {
-                       g_print("set audio device failed 0x%d\n", err);
-                       recorder_destroy(hcamcorder->recorder);
-                       hcamcorder->recorder = NULL;
-                       return FALSE;
+               sound_manager_create_stream_information(SOUND_STREAM_TYPE_MEDIA, _sound_stream_focus_state_changed_cb, hcamcorder, &stream_info);
+               if (stream_info) {
+                       recorder_set_sound_stream_info(hcamcorder->recorder, stream_info);
+                       sound_manager_destroy_stream_information(stream_info);
                }
 
                check = TRUE;
@@ -1573,7 +1551,7 @@ int main(int argc, char **argv)
        memset(&ad, 0x0, sizeof(appdata));
        ops.data = &ad;
 
-       bret = appcore_efl_main(PACKAGE, &argc, &argv, &ops);
+       bret = appcore_efl_main("recorder_test", &argc, &argv, &ops);
 
        g_print("\n\treturn appcore_efl : %d\n\n", bret);