From dbb8ec4639f225c57384a876749c27a59f21baf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 7 Jul 2016 18:23:07 +0300 Subject: [PATCH] matroskamux: Error out if we start writing data with some pads not having a codec id yet This can only happen if a) upstream somehow gets around the CAPS event failing or b) there never being any CAPS event. The following code assumes that all pads have a codec-id. https://bugzilla.gnome.org/show_bug.cgi?id=768509 --- gst/matroska/matroska-mux.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/gst/matroska/matroska-mux.c b/gst/matroska/matroska-mux.c index b5b94854fe..1f5142871c 100644 --- a/gst/matroska/matroska-mux.c +++ b/gst/matroska/matroska-mux.c @@ -2881,7 +2881,7 @@ gst_matroska_mux_start (GstMatroskaMux * mux) thepad = collect_pad->collect.pad; if (gst_pad_is_linked (thepad) && gst_pad_is_active (thepad) && - collect_pad->track->codec_id != 0) { + collect_pad->track->codec_id != NULL) { collect_pad->track->num = tracknum++; child = gst_ebml_write_master_start (ebml, GST_MATROSKA_ID_TRACKENTRY); gst_matroska_mux_track_header (mux, collect_pad->track); @@ -3544,12 +3544,11 @@ gst_matroska_mux_write_data (GstMatroskaMux * mux, GstMatroskaPad * collect_pad, } /* for dirac we have to queue up everything up to a picture unit */ - if (!g_strcmp0 (collect_pad->track->codec_id, - GST_MATROSKA_CODEC_ID_VIDEO_DIRAC)) { + if (!strcmp (collect_pad->track->codec_id, GST_MATROSKA_CODEC_ID_VIDEO_DIRAC)) { buf = gst_matroska_mux_handle_dirac_packet (mux, collect_pad, buf); if (!buf) return GST_FLOW_OK; - } else if (!g_strcmp0 (collect_pad->track->codec_id, + } else if (!strcmp (collect_pad->track->codec_id, GST_MATROSKA_CODEC_ID_VIDEO_PRORES)) { /* Remove the 'Frame container atom' header' */ buf = gst_buffer_make_writable (buf); @@ -3820,6 +3819,12 @@ gst_matroska_mux_handle_buffer (GstCollectPads * pads, GstCollectData * data, goto exit; } + if (best->track->codec_id == NULL) { + GST_ERROR_OBJECT (best->collect.pad, "No codec-id for pad"); + ret = GST_FLOW_NOT_NEGOTIATED; + goto exit; + } + /* if we have a best stream, should also have a buffer */ g_assert (buf);