From 26f9ce012cc8e869af3b9df252cf3bbfc3fc5c85 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 24 Sep 2004 16:38:28 +0000 Subject: [PATCH] gst/playback/: Don't try to preroll or decode more than one audio/video track. Original commit message from CVS: * gst/playback/gstplaybasebin.c: (remove_prerolls), (new_decoded_pad): * gst/playback/gstplaybasebin.h: * gst/playback/gstplaybin.c: (setup_sinks): Don't try to preroll or decode more than one audio/video track. --- ChangeLog | 9 +++++++++ gst/playback/gstplaybasebin.c | 22 ++++++++++++++++++++-- gst/playback/gstplaybasebin.h | 4 ++++ gst/playback/gstplaybin.c | 18 ++++++++++++++++-- 4 files changed, 49 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8623b259c7..8ee27ec7b8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2004-09-24 Wim Taymans + + * gst/playback/gstplaybasebin.c: (remove_prerolls), + (new_decoded_pad): + * gst/playback/gstplaybasebin.h: + * gst/playback/gstplaybin.c: (setup_sinks): + Don't try to preroll or decode more than one audio/video + track. + 2004-09-24 Ronald S. Bultje * gst/playback/gstplaybasebin.c: (gst_play_base_bin_change_state): diff --git a/gst/playback/gstplaybasebin.c b/gst/playback/gstplaybasebin.c index 5520d1c4e3..c15aa41b65 100644 --- a/gst/playback/gstplaybasebin.c +++ b/gst/playback/gstplaybasebin.c @@ -250,6 +250,9 @@ remove_prerolls (GstPlayBaseBin * play_base_bin) g_list_free (play_base_bin->streaminfo); play_base_bin->streaminfo = NULL; play_base_bin->nstreams = 0; + play_base_bin->naudiopads = 0; + play_base_bin->nvideopads = 0; + play_base_bin->nunknownpads = 0; } static void @@ -285,6 +288,7 @@ new_decoded_pad (GstElement * element, GstPad * pad, gboolean last, GstStreamInfo *info; GstStreamType type; GstPad *srcpad; + gboolean need_preroll; GST_DEBUG ("play base: new decoded pad"); @@ -300,17 +304,31 @@ new_decoded_pad (GstElement * element, GstPad * pad, gboolean last, play_base_bin->nstreams++; + need_preroll = FALSE; + if (g_str_has_prefix (mimetype, "audio/")) { type = GST_STREAM_TYPE_AUDIO; + play_base_bin->naudiopads++; + /* first audio pad gets a preroll element */ + if (play_base_bin->naudiopads == 1) { + need_preroll = TRUE; + } } else if (g_str_has_prefix (mimetype, "video/")) { type = GST_STREAM_TYPE_VIDEO; + play_base_bin->nvideopads++; + /* first video pad gets a preroll element */ + if (play_base_bin->nvideopads == 1) { + need_preroll = TRUE; + } } else { type = GST_STREAM_TYPE_UNKNOWN; + play_base_bin->nunknownpads++; } - if (last) { + if (last || !need_preroll) { srcpad = pad; - no_more_pads (NULL, play_base_bin); + if (last) + no_more_pads (NULL, play_base_bin); } else { new_element = gen_preroll_element (play_base_bin, pad); srcpad = gst_element_get_pad (new_element, "src"); diff --git a/gst/playback/gstplaybasebin.h b/gst/playback/gstplaybasebin.h index 703ce2d6dc..405e5a7806 100644 --- a/gst/playback/gstplaybasebin.h +++ b/gst/playback/gstplaybasebin.h @@ -55,6 +55,10 @@ struct _GstPlayBaseBin { gint nstreams; GList *streaminfo; + gint naudiopads; + gint nvideopads; + gint nunknownpads; + /* list of usable factories */ GList *factories; }; diff --git a/gst/playback/gstplaybin.c b/gst/playback/gstplaybin.c index 5967b393ed..d5f648728d 100644 --- a/gst/playback/gstplaybin.c +++ b/gst/playback/gstplaybin.c @@ -368,6 +368,8 @@ setup_sinks (GstPlayBin * play_bin) { GList *streaminfo; GList *s; + gboolean have_audio = FALSE; + gboolean have_video = FALSE; /* get info about the stream */ g_object_get (G_OBJECT (play_bin), "stream-info", &streaminfo, NULL); @@ -386,9 +388,21 @@ setup_sinks (GstPlayBin * play_bin) continue; if (type == 1) { - sink = gen_audio_element (play_bin); + if (have_audio) { + g_warning ("two audio streams found, playing first one"); + continue; + } else { + sink = gen_audio_element (play_bin); + have_audio = TRUE; + } } else if (type == 2) { - sink = gen_video_element (play_bin); + if (have_video) { + g_warning ("two video streams found, playing first one"); + continue; + } else { + sink = gen_video_element (play_bin); + have_video = TRUE; + } } else { g_warning ("unknown stream found"); continue;