Enhance muxer functionality to facilitate testing of FHD video muxing. 67/56967/1 accepted/tizen/mobile/20160115.111247 accepted/tizen/tv/20160115.111300 accepted/tizen/wearable/20160115.111322 submit/tizen/20160115.024320
authorMahesh Kondiparthi <kd.mahesh@samsung.com>
Thu, 14 Jan 2016 03:52:40 +0000 (09:22 +0530)
committerMahesh Kondiparthi <kd.mahesh@samsung.com>
Thu, 14 Jan 2016 03:53:26 +0000 (09:23 +0530)
Also, Fixed bug in calling media_format_get_audio_info for video case.

Change-Id: I5126d7d9f11d4a9d4131b95ac8ab335435b474f2
Signed-off-by: Joungkook Seo <jk7704.seo@samsung.com>
src/port_gst/mediamuxer_port_gst.c
test/mediamuxer_test.c
test/mediamuxer_test_gst.c

index fd712a0..3439ce5 100644 (file)
@@ -827,7 +827,7 @@ int _gst_set_caps(MMHandleType pHandle, media_packet_h packet, int track_index)
                        if (media_format_get_audio_info((media_format_h)(format), &current_mime, NULL, NULL, NULL, NULL)
                                == MEDIA_FORMAT_ERROR_NONE) {
                                if (track_mime != current_mime) {
-                                       MX_E("audio track_mime is not matching with packet mime. returning");
+                                       MX_E("audio track_mime is not matching with packet mime. returning\n");
                                        return MX_ERROR_INVALID_ARGUMENT;
                                }
                        } else {
@@ -922,10 +922,10 @@ int _gst_set_caps(MMHandleType pHandle, media_packet_h packet, int track_index)
                /* return if track_mime is different to current_mime */
                if (media_format_get_video_info((media_format_h)(current->media_format), &track_mime, NULL, NULL, NULL, NULL)
                        == MEDIA_FORMAT_ERROR_NONE) {
-                       if (media_format_get_audio_info((media_format_h)(format), &current_mime, NULL, NULL, NULL, NULL)
+                       if (media_format_get_video_info((media_format_h)(format), &current_mime, NULL, NULL, NULL, NULL)
                                == MEDIA_FORMAT_ERROR_NONE) {
                                if (track_mime != current_mime) {
-                                       MX_E("video track_mime is not matching with packet mime. returning");
+                                       MX_E("video track_mime is not matching with packet mime. returning\n");
                                        return MX_ERROR_INVALID_ARGUMENT;
                                }
                        } else {
index 747c34b..f265492 100644 (file)
@@ -99,9 +99,9 @@ char data_sink[MAX_INPUT_SIZE];
 bool have_mp4 = false;
 bool have_vid_track = false;
 bool have_aud_track = false;
-int track_index_vid;
-int track_index_aud;
-int track_index_aud2;
+int track_index_vid = -1;
+int track_index_aud = -1;
+int track_index_aud2 = -1;
 int g_menu_state = CURRENT_STATUS_MAINMENU;
 
 int demux_mp4();
@@ -276,13 +276,12 @@ int test_mediamuxer_add_track_audio()
 
        /* To add audio track */
        mediamuxer_add_track(myMuxer, media_format_a, &track_index_aud);
+       g_print("Audio Track index returned is: %d\n", track_index_aud);
 
        if (validate_multitrack) {
                mediamuxer_add_track(myMuxer, media_format_a, &track_index_aud2);
-               g_print("Audio Track index is returned : %d\n", track_index_aud2);
+               g_print("Audio Multi-Track index returned is: %d\n", track_index_aud2);
        }
-
-       g_print("Audio Track index is returned : %d\n", track_index_aud);
        return 0;
 }
 
index c342c33..a43d12b 100644 (file)
@@ -85,8 +85,12 @@ static void __audio_app_sink_callback(GstElement *sink, CustomData *data)
        int key;
        GstMapInfo map;
 
-       if (count == 0)
-               g_print("Called __audio_app_sink_callback\n");
+       if (count == 0) {
+               g_print("Called __audio_app_sink_callback, track_index_aud = %d\n", track_index_aud);
+               if (validate_multitrack)
+                       g_print("track_index_aud2 = %d\n", track_index_aud2);
+               g_print("audio data_sink = %s\n", data_sink);
+       }
 
        g_signal_emit_by_name(sink, "pull-sample", &sample);
        buffer = gst_sample_get_buffer(sample);
@@ -228,14 +232,20 @@ static void __video_app_sink_callback(GstElement *sink, CustomData *data)
        media_packet_h vid_pkt;
        uint64_t ns;
        static int count = 0;
-       unsigned int vsize;
        int key;
        guint8 *dptr;
        GstMapInfo map;
        GstSample *sample;
-
-       if (count == 0)
-               g_print("Called __video_app_sink_callback\n");
+       GstStructure *caps_struc = NULL;
+       GstCaps *vid_caps_gst = NULL;
+       gint video_width;
+       gint video_height;
+       gboolean ret = false;
+
+       if (count == 0) {
+               g_print("Called __video_app_sink_callback. track_index_vid = %d\n", track_index_vid);
+               g_print("video data_sink = %s\n", data_sink);
+       }
 
        g_signal_emit_by_name(sink, "pull-sample", &sample);
        buffer = gst_sample_get_buffer(sample);
@@ -280,9 +290,20 @@ static void __video_app_sink_callback(GstElement *sink, CustomData *data)
                                key = 0;
                        }
 
-                       vsize = map.size;
-                       media_format_set_video_width(vidfmt, vsize/2+1);
-                       media_format_set_video_height(vidfmt, vsize/2+1);
+                       vid_caps_gst = gst_caps_from_string(vid_caps);
+                       caps_struc = gst_caps_get_structure(vid_caps_gst, 0);
+
+                       ret = gst_structure_get_int(caps_struc, "width", &video_width);
+                       ret = ret && gst_structure_get_int(caps_struc, "height", &video_height);
+                       if (!ret) {
+                               g_print("Failed to retrive video width/height. returning. \n");
+                               return;
+                       }
+
+                       if (count == 0)
+                               g_print("Extracted width=%d, height=%d\n", video_width, video_height);
+                       media_format_set_video_width(vidfmt, video_width);
+                       media_format_set_video_height(vidfmt, video_height);
                        /* frame rate is came from the caps filter of demuxer */
                        if (media_format_set_video_frame_rate(vidfmt, 30)) {
                                g_print("media_format_set_video_frame_rate failed\n");