gst/matroska/matroska-mux.c: Don't strcmp() NULL strings.
authorTim-Philipp Müller <tim@centricular.net>
Wed, 3 May 2006 18:41:47 +0000 (18:41 +0000)
committerTim-Philipp Müller <tim@centricular.net>
Wed, 3 May 2006 18:41:47 +0000 (18:41 +0000)
Original commit message from CVS:
* gst/matroska/matroska-mux.c:
(gst_matroska_mux_stream_is_vorbis_header),
(gst_matroska_mux_write_data):
Don't strcmp() NULL strings.
Only start new clusters on video keyframes, not on any
random audio buffer that doesn't have the DELTA_UNIT
flag set (fixes 'make check' again).

ChangeLog
gst/matroska/matroska-mux.c

index 252f92d..353c6d5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2006-05-03  Tim-Philipp Müller  <tim at centricular dot net>
 
+       * gst/matroska/matroska-mux.c:
+       (gst_matroska_mux_stream_is_vorbis_header),
+       (gst_matroska_mux_write_data):
+         Don't strcmp() NULL strings.
+         Only start new clusters on video keyframes, not on any
+         random audio buffer that doesn't have the DELTA_UNIT
+         flag set (fixes 'make check' again).
+
+2006-05-03  Tim-Philipp Müller  <tim at centricular dot net>
+
        Patch by: Mark Nauwelaerts  <manauw at skynet be>
 
        * gst/matroska/matroska-mux.c: (gst_matroska_mux_best_pad),
index 20d5cfa..96d2e1a 100644 (file)
@@ -1318,7 +1318,8 @@ gst_matroska_mux_stream_is_vorbis_header (GstMatroskaMux * mux,
   if (audio_ctx->first_frame != FALSE)
     return FALSE;
 
-  if (strcmp (collect_pad->track->codec_id, GST_MATROSKA_CODEC_ID_AUDIO_VORBIS))
+  if (collect_pad->track->codec_id == NULL ||
+      strcmp (collect_pad->track->codec_id, GST_MATROSKA_CODEC_ID_AUDIO_VORBIS))
     return FALSE;
 
   /* HACK: three frame headers are counted using pos */
@@ -1379,6 +1380,7 @@ gst_matroska_mux_write_data (GstMatroskaMux * mux, GstMatroskaPad * collect_pad)
   gint16 relative_timestamp;
   gint64 relative_timestamp64;
   guint64 block_duration;
+  gboolean is_video_keyframe = FALSE;
 
   /* write data */
   buf = collect_pad->buffer;
@@ -1386,6 +1388,7 @@ gst_matroska_mux_write_data (GstMatroskaMux * mux, GstMatroskaPad * collect_pad)
 
   /* vorbis header are retrieved from caps and placed in CodecPrivate */
   if (gst_matroska_mux_stream_is_vorbis_header (mux, collect_pad)) {
+    GST_LOG_OBJECT (collect_pad->collect.pad, "dropping vorbis header buffer");
     gst_buffer_unref (buf);
     return GST_FLOW_OK;
   }
@@ -1402,10 +1405,17 @@ gst_matroska_mux_write_data (GstMatroskaMux * mux, GstMatroskaPad * collect_pad)
   /* set the timestamp for outgoing buffers */
   ebml->timestamp = GST_BUFFER_TIMESTAMP (buf);
 
+  if (collect_pad->track->type == GST_MATROSKA_TRACK_TYPE_VIDEO &&
+      !GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_DELTA_UNIT)) {
+    GST_LOG_OBJECT (mux, "have video keyframe, ts=%" GST_TIME_FORMAT,
+        GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)));
+    is_video_keyframe = TRUE;
+  }
+
   if (mux->cluster) {
     /* start a new cluster every two seconds or at keyframe */
     if (mux->cluster_time + GST_SECOND * 2 < GST_BUFFER_TIMESTAMP (buf)
-        || !GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_DELTA_UNIT)) {
+        || is_video_keyframe) {
       GstMatroskaMetaSeekIndex *idx;
 
       gst_ebml_write_master_finish (ebml, mux->cluster);
@@ -1453,8 +1463,7 @@ gst_matroska_mux_write_data (GstMatroskaMux * mux, GstMatroskaPad * collect_pad)
    * for audio only files. This can be largely improved, such as doing
    * one for each keyframe or each second (for all-keyframe
    * streams), only the *first* video track. But that'll come later... */
-  if (collect_pad->track->type == GST_MATROSKA_TRACK_TYPE_VIDEO &&
-      !GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_DELTA_UNIT)) {
+  if (is_video_keyframe) {
     GstMatroskaIndex *idx;
 
     if (mux->num_indexes % 32 == 0) {