From: Andoni Morales Alastruey Date: Wed, 20 Oct 2010 09:05:49 +0000 (+0200) Subject: matroskamux: try to write timestamps in all the outgoing buffers X-Git-Tag: 1.19.3~509^2~7932^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fd6bc949c8c3a9fc5ee48b0f0c3eef96f721a3ec;p=platform%2Fupstream%2Fgstreamer.git matroskamux: try to write timestamps in all the outgoing buffers Fixes #632654. --- diff --git a/gst/matroska/ebml-write.c b/gst/matroska/ebml-write.c index 4d131c3..ed39c51 100644 --- a/gst/matroska/ebml-write.c +++ b/gst/matroska/ebml-write.c @@ -223,12 +223,14 @@ gst_ebml_writer_send_new_segment_event (GstEbmlWrite * ebml, guint64 new_pos) /** * gst_ebml_write_flush_cache: - * @ebml: a #GstEbmlWrite. + * @ebml: a #GstEbmlWrite. + * @timestamp: timestamp of the buffer. * * Flush the cache. */ void -gst_ebml_write_flush_cache (GstEbmlWrite * ebml, gboolean is_keyframe) +gst_ebml_write_flush_cache (GstEbmlWrite * ebml, gboolean is_keyframe, + GstClockTime timestamp) { GstBuffer *buffer; @@ -239,6 +241,7 @@ gst_ebml_write_flush_cache (GstEbmlWrite * ebml, gboolean is_keyframe) ebml->cache = NULL; GST_DEBUG ("Flushing cache of size %d", GST_BUFFER_SIZE (buffer)); gst_buffer_set_caps (buffer, ebml->caps); + GST_BUFFER_TIMESTAMP (buffer) = timestamp; GST_BUFFER_OFFSET (buffer) = ebml->pos - GST_BUFFER_SIZE (buffer); GST_BUFFER_OFFSET_END (buffer) = ebml->pos; if (ebml->last_write_result == GST_FLOW_OK) { @@ -466,7 +469,7 @@ gst_ebml_write_seek (GstEbmlWrite * ebml, guint64 pos) return; } else { GST_LOG ("Seek outside cache range. Clearing..."); - gst_ebml_write_flush_cache (ebml, FALSE); + gst_ebml_write_flush_cache (ebml, FALSE, GST_CLOCK_TIME_NONE); } } @@ -825,5 +828,5 @@ gst_ebml_write_header (GstEbmlWrite * ebml, const gchar * doctype, gst_ebml_write_uint (ebml, GST_EBML_ID_DOCTYPEVERSION, version); gst_ebml_write_uint (ebml, GST_EBML_ID_DOCTYPEREADVERSION, version); gst_ebml_write_master_finish (ebml, pos); - gst_ebml_write_flush_cache (ebml, FALSE); + gst_ebml_write_flush_cache (ebml, FALSE, 0); } diff --git a/gst/matroska/ebml-write.h b/gst/matroska/ebml-write.h index 7b0ef45..4d0293d 100644 --- a/gst/matroska/ebml-write.h +++ b/gst/matroska/ebml-write.h @@ -84,7 +84,8 @@ GstBuffer* gst_ebml_stop_streamheader (GstEbmlWrite *ebml); void gst_ebml_write_set_cache (GstEbmlWrite *ebml, guint size); void gst_ebml_write_flush_cache (GstEbmlWrite *ebml, - gboolean is_keyframe); + gboolean is_keyframe, + GstClockTime timestamp); /* * Seeking. diff --git a/gst/matroska/matroska-mux.c b/gst/matroska/matroska-mux.c index 0039851..fea9c35 100644 --- a/gst/matroska/matroska-mux.c +++ b/gst/matroska/matroska-mux.c @@ -2124,7 +2124,7 @@ gst_matroska_mux_start (GstMatroskaMux * mux) gst_ebml_write_master_finish (ebml, master); /* lastly, flush the cache */ - gst_ebml_write_flush_cache (ebml, FALSE); + gst_ebml_write_flush_cache (ebml, FALSE, 0); } static void @@ -2233,7 +2233,7 @@ gst_matroska_mux_finish (GstMatroskaMux * mux) } gst_ebml_write_master_finish (ebml, master); - gst_ebml_write_flush_cache (ebml, FALSE); + gst_ebml_write_flush_cache (ebml, FALSE, GST_CLOCK_TIME_NONE); } /* tags */ @@ -2600,7 +2600,7 @@ gst_matroska_mux_write_data (GstMatroskaMux * mux, GstMatroskaPad * collect_pad) GST_LOG_OBJECT (mux, "cluster timestamp %" G_GUINT64_FORMAT, gst_util_uint64_scale (GST_BUFFER_TIMESTAMP (buf), 1, mux->time_scale)); - gst_ebml_write_flush_cache (ebml, TRUE); + gst_ebml_write_flush_cache (ebml, TRUE, GST_BUFFER_TIMESTAMP (buf)); mux->cluster_time = GST_BUFFER_TIMESTAMP (buf); gst_ebml_write_uint (ebml, GST_MATROSKA_ID_PREVSIZE, mux->prev_cluster_size); @@ -2613,7 +2613,7 @@ gst_matroska_mux_write_data (GstMatroskaMux * mux, GstMatroskaPad * collect_pad) mux->cluster = gst_ebml_write_master_start (ebml, GST_MATROSKA_ID_CLUSTER); gst_ebml_write_uint (ebml, GST_MATROSKA_ID_CLUSTERTIMECODE, gst_util_uint64_scale (GST_BUFFER_TIMESTAMP (buf), 1, mux->time_scale)); - gst_ebml_write_flush_cache (ebml, TRUE); + gst_ebml_write_flush_cache (ebml, TRUE, GST_BUFFER_TIMESTAMP (buf)); mux->cluster_time = GST_BUFFER_TIMESTAMP (buf); } @@ -2691,7 +2691,7 @@ gst_matroska_mux_write_data (GstMatroskaMux * mux, GstMatroskaPad * collect_pad) gst_ebml_write_buffer_header (ebml, GST_MATROSKA_ID_SIMPLEBLOCK, GST_BUFFER_SIZE (buf) + GST_BUFFER_SIZE (hdr)); gst_ebml_write_buffer (ebml, hdr); - gst_ebml_write_flush_cache (ebml, FALSE); + gst_ebml_write_flush_cache (ebml, FALSE, GST_BUFFER_TIMESTAMP (buf)); gst_ebml_write_buffer (ebml, buf); return gst_ebml_last_write_result (ebml); @@ -2711,8 +2711,9 @@ gst_matroska_mux_write_data (GstMatroskaMux * mux, GstMatroskaPad * collect_pad) GST_BUFFER_SIZE (buf) + GST_BUFFER_SIZE (hdr)); gst_ebml_write_buffer (ebml, hdr); gst_ebml_write_master_finish_full (ebml, blockgroup, GST_BUFFER_SIZE (buf)); - gst_ebml_write_flush_cache (ebml, FALSE); + gst_ebml_write_flush_cache (ebml, FALSE, GST_BUFFER_TIMESTAMP (buf)); gst_ebml_write_buffer (ebml, buf); + return gst_ebml_last_write_result (ebml); } }