add setting buffer duration before push 95/85795/1
authorEunhae Choi <eunhae1.choi@samsung.com>
Mon, 29 Aug 2016 06:15:26 +0000 (15:15 +0900)
committerEunhae Choi <eunhae1.choi@samsung.com>
Mon, 29 Aug 2016 06:39:58 +0000 (15:39 +0900)
Change-Id: I26df277d2771b5ce92bfaa854853da431c80ff07

packaging/libmm-player.spec
src/mm_player_es.c

index 6721aa3bebfe874847d1a7b94132fd5375e8446a..d58a534864309dc372830716e67d66cc6c43dd43 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmm-player
 Summary:    Multimedia Framework Player Library
-Version:    0.5.96
+Version:    0.5.97
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0
index 5033f13b770c6bc4f7c9723d388a50e07ed0e2b0..c90924c745e138433c3e72fd65c9ac4f5ae8b2bf 100644 (file)
 #include <gst/app/gstappsrc.h>
 
 /*---------------------------------------------------------------------------
-|    LOCAL VARIABLE DEFINITIONS for internal                                                           |
+|    LOCAL VARIABLE DEFINITIONS for internal                                |
 ---------------------------------------------------------------------------*/
+#define DEFAULT_FRAMERATE_NUM 30
+#define DEFAULT_FRAMERATE_DEN 1
+#define DEFAULT_VIDEO_FRAME_DURATION 33 /* ms */
 
 /*---------------------------------------------------------------------------
-|    LOCAL FUNCTION PROTOTYPES:                                                                                                |
+|    LOCAL FUNCTION PROTOTYPES:                                             |
 ---------------------------------------------------------------------------*/
 static int __parse_media_format(MMPlayerVideoStreamInfo * video, MMPlayerAudioStreamInfo * audio, media_format_h format);
 static int __convert_media_format_video_mime_to_str(MMPlayerVideoStreamInfo * video, media_format_mimetype_e mime);
@@ -115,8 +118,6 @@ __parse_media_format(MMPlayerVideoStreamInfo * video,
        }
 
        if (video) {
-#define DEFAULT_FRAMERATE_NUM 30
-#define DEFAULT_FRAMERATE_DEN 1
                media_format_mimetype_e mime;
                int width = 0;
                int height = 0;
@@ -478,6 +479,7 @@ _mmplayer_submit_packet(MMHandleType hplayer, media_packet_h packet)
        if (buf != NULL && size > 0) {
                GstMapInfo buff_info = GST_MAP_INFO_INIT;
                uint64_t pts = 0;
+               uint64_t duration = 0;
 
                /* get size */
                _buffer = gst_buffer_new_and_alloc(size);
@@ -506,13 +508,25 @@ _mmplayer_submit_packet(MMHandleType hplayer, media_packet_h packet)
                                }
                                media_format_unref(fmt);
                        }
+
+                       /* get duration */
+                       if (media_packet_get_duration(packet, &duration) != MEDIA_PACKET_ERROR_NONE) {
+                               LOGW("failed to get duration info");
+                               /* keep push without error handling */
+                       }
+
+                       if (duration == 0) {
+                               duration = DEFAULT_VIDEO_FRAME_DURATION * GST_MSECOND;
+                       }
+
+                       GST_BUFFER_DURATION(_buffer) = (GstClockTime)duration;
                }
 
                /* get pts */
                if (media_packet_get_pts(packet, &pts) != MEDIA_PACKET_ERROR_NONE) {
-               LOGE("failed to get pts info");
-               ret = MM_ERROR_PLAYER_INTERNAL;
-               goto ERROR;
+                       LOGE("failed to get pts info");
+                       ret = MM_ERROR_PLAYER_INTERNAL;
+                       goto ERROR;
                }
                GST_BUFFER_PTS(_buffer) = (GstClockTime)pts;
                gst_app_src_push_buffer(GST_APP_SRC(element), _buffer);