diff options
author | Stéphane Cerveau <scerveau@collabora.com> | 2021-06-30 10:30:43 +0200 |
---|---|---|
committer | GStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org> | 2021-07-07 13:50:35 +0000 |
commit | a8c2b658807367e52ddbb996e827bd90b642a304 (patch) | |
tree | f6aa716bac1efb80eae9ae85fbe0d881a096bf71 /ext | |
parent | 506bd90bf770232da80ece095b45dcf6bab94137 (diff) | |
download | gstreamer-plugins-bad-a8c2b658807367e52ddbb996e827bd90b642a304.tar.gz |
dashsink: fix crash with no pad name for representation
if there is no pad name, the representation id
was NULL, causing a crash when writing the mpd file.
gst-launch-1.0 videotestsrc num-buffers=900 ! video/x-raw, width=800,
height=600, framerate=30/1 ! x264enc ! video/x-h264, profile=high !
dashsink
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2064>
Diffstat (limited to 'ext')
-rw-r--r-- | ext/dash/gstdashsink.c | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/ext/dash/gstdashsink.c b/ext/dash/gstdashsink.c index 770eb07fe..e6c948e3c 100644 --- a/ext/dash/gstdashsink.c +++ b/ext/dash/gstdashsink.c @@ -334,6 +334,37 @@ gst_dash_sink_stream_from_splitmuxsink (GList * streams, GstElement * element) return NULL; } +static gchar * +gst_dash_sink_stream_get_next_name (GList * streams, GstDashSinkStreamType type) +{ + GList *l; + guint count = 0; + GstDashSinkStream *stream = NULL; + gchar *name = NULL; + + for (l = streams; l != NULL; l = l->next) { + stream = l->data; + if (stream->type == type) + count++; + } + + switch (type) { + case DASH_SINK_STREAM_TYPE_VIDEO: + name = g_strdup_printf ("video_%d", count); + break; + case DASH_SINK_STREAM_TYPE_AUDIO: + name = g_strdup_printf ("audio_%d", count); + break; + case DASH_SINK_STREAM_TYPE_SUBTITLE: + name = g_strdup_printf ("sub_%d", count); + break; + default: + name = g_strdup_printf ("unknown_%d", count); + } + + return name; +} + static void gst_dash_sink_stream_free (gpointer s) { @@ -936,7 +967,13 @@ gst_dash_sink_request_new_pad (GstElement * element, GstPadTemplate * templ, stream->adaptation_set_id = ADAPTATION_SET_ID_SUBTITLE; } - stream->representation_id = g_strdup (pad_name); + if (pad_name) + stream->representation_id = g_strdup (pad_name); + else + stream->representation_id = + gst_dash_sink_stream_get_next_name (sink->streams, stream->type); + + stream->mimetype = g_strdup (dash_muxer_list[sink->muxer].mimetype); |