matroskamux: try to write timestamps in all the outgoing buffers

Fixes #632654.
This commit is contained in:
Andoni Morales Alastruey 2010-10-20 11:05:49 +02:00 committed by Mark Nauwelaerts
parent 1d4496254d
commit fd6bc949c8
3 changed files with 16 additions and 11 deletions

View File

@ -223,12 +223,14 @@ gst_ebml_writer_send_new_segment_event (GstEbmlWrite * ebml, guint64 new_pos)
/** /**
* gst_ebml_write_flush_cache: * gst_ebml_write_flush_cache:
* @ebml: a #GstEbmlWrite. * @ebml: a #GstEbmlWrite.
* @timestamp: timestamp of the buffer.
* *
* Flush the cache. * Flush the cache.
*/ */
void 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; GstBuffer *buffer;
@ -239,6 +241,7 @@ gst_ebml_write_flush_cache (GstEbmlWrite * ebml, gboolean is_keyframe)
ebml->cache = NULL; ebml->cache = NULL;
GST_DEBUG ("Flushing cache of size %d", GST_BUFFER_SIZE (buffer)); GST_DEBUG ("Flushing cache of size %d", GST_BUFFER_SIZE (buffer));
gst_buffer_set_caps (buffer, ebml->caps); 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 (buffer) = ebml->pos - GST_BUFFER_SIZE (buffer);
GST_BUFFER_OFFSET_END (buffer) = ebml->pos; GST_BUFFER_OFFSET_END (buffer) = ebml->pos;
if (ebml->last_write_result == GST_FLOW_OK) { if (ebml->last_write_result == GST_FLOW_OK) {
@ -466,7 +469,7 @@ gst_ebml_write_seek (GstEbmlWrite * ebml, guint64 pos)
return; return;
} else { } else {
GST_LOG ("Seek outside cache range. Clearing..."); 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_DOCTYPEVERSION, version);
gst_ebml_write_uint (ebml, GST_EBML_ID_DOCTYPEREADVERSION, version); gst_ebml_write_uint (ebml, GST_EBML_ID_DOCTYPEREADVERSION, version);
gst_ebml_write_master_finish (ebml, pos); gst_ebml_write_master_finish (ebml, pos);
gst_ebml_write_flush_cache (ebml, FALSE); gst_ebml_write_flush_cache (ebml, FALSE, 0);
} }

View File

@ -84,7 +84,8 @@ GstBuffer* gst_ebml_stop_streamheader (GstEbmlWrite *ebml);
void gst_ebml_write_set_cache (GstEbmlWrite *ebml, void gst_ebml_write_set_cache (GstEbmlWrite *ebml,
guint size); guint size);
void gst_ebml_write_flush_cache (GstEbmlWrite *ebml, void gst_ebml_write_flush_cache (GstEbmlWrite *ebml,
gboolean is_keyframe); gboolean is_keyframe,
GstClockTime timestamp);
/* /*
* Seeking. * Seeking.

View File

@ -2124,7 +2124,7 @@ gst_matroska_mux_start (GstMatroskaMux * mux)
gst_ebml_write_master_finish (ebml, master); gst_ebml_write_master_finish (ebml, master);
/* lastly, flush the cache */ /* lastly, flush the cache */
gst_ebml_write_flush_cache (ebml, FALSE); gst_ebml_write_flush_cache (ebml, FALSE, 0);
} }
static void static void
@ -2233,7 +2233,7 @@ gst_matroska_mux_finish (GstMatroskaMux * mux)
} }
gst_ebml_write_master_finish (ebml, master); 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 */ /* 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_LOG_OBJECT (mux, "cluster timestamp %" G_GUINT64_FORMAT,
gst_util_uint64_scale (GST_BUFFER_TIMESTAMP (buf), 1, gst_util_uint64_scale (GST_BUFFER_TIMESTAMP (buf), 1,
mux->time_scale)); 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); mux->cluster_time = GST_BUFFER_TIMESTAMP (buf);
gst_ebml_write_uint (ebml, GST_MATROSKA_ID_PREVSIZE, gst_ebml_write_uint (ebml, GST_MATROSKA_ID_PREVSIZE,
mux->prev_cluster_size); 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); mux->cluster = gst_ebml_write_master_start (ebml, GST_MATROSKA_ID_CLUSTER);
gst_ebml_write_uint (ebml, GST_MATROSKA_ID_CLUSTERTIMECODE, gst_ebml_write_uint (ebml, GST_MATROSKA_ID_CLUSTERTIMECODE,
gst_util_uint64_scale (GST_BUFFER_TIMESTAMP (buf), 1, mux->time_scale)); 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); 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_ebml_write_buffer_header (ebml, GST_MATROSKA_ID_SIMPLEBLOCK,
GST_BUFFER_SIZE (buf) + GST_BUFFER_SIZE (hdr)); GST_BUFFER_SIZE (buf) + GST_BUFFER_SIZE (hdr));
gst_ebml_write_buffer (ebml, 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); gst_ebml_write_buffer (ebml, buf);
return gst_ebml_last_write_result (ebml); 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_BUFFER_SIZE (buf) + GST_BUFFER_SIZE (hdr));
gst_ebml_write_buffer (ebml, hdr); gst_ebml_write_buffer (ebml, hdr);
gst_ebml_write_master_finish_full (ebml, blockgroup, GST_BUFFER_SIZE (buf)); 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); gst_ebml_write_buffer (ebml, buf);
return gst_ebml_last_write_result (ebml); return gst_ebml_last_write_result (ebml);
} }
} }