From: <wt...@fr...> - 2004-10-07 11:15:03
|
CVS Root: /cvs/gstreamer Module: gst-plugins Changes by: wtay Date: Thu Oct 07 2004 04:15:00 PDT Log message: * gst/playback/gstplaybasebin.c: (play_base_bin_mute_pad), (gst_play_base_bin_mute_stream), (gst_play_base_bin_link_stream): * gst/playback/gstplaybin.c: (setup_sinks): Implement muting/unmuting of streams, mute streams that are not used. Modified files: . : ChangeLog gst/playback : gstplaybasebin.c gstplaybin.c Links: http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins/ChangeLog.diff?r1=1.1140&r2=1.1141 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins/gst/playback/gstplaybasebin.c.diff?r1=1.19&r2=1.20 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins/gst/playback/gstplaybin.c.diff?r1=1.15&r2=1.16 ====Begin Diffs==== Index: ChangeLog =================================================================== RCS file: /cvs/gstreamer/gst-plugins/ChangeLog,v retrieving revision 1.1140 retrieving revision 1.1141 diff -u -d -r1.1140 -r1.1141 --- ChangeLog 7 Oct 2004 09:56:43 -0000 1.1140 +++ ChangeLog 7 Oct 2004 11:14:46 -0000 1.1141 @@ -1,5 +1,13 @@ 2004-10-07 Wim Taymans <wi...@fl...> + * gst/playback/gstplaybasebin.c: (play_base_bin_mute_pad), + (gst_play_base_bin_mute_stream), (gst_play_base_bin_link_stream): + * gst/playback/gstplaybin.c: (setup_sinks): + Implement muting/unmuting of streams, mute streams that are not + used. + +2004-10-07 Wim Taymans <wi...@fl...> * gst/typefind/gsttypefindfunctions.c: (ac3_type_find), (plugin_init): Added lame audio/x-ac3 typefind function. Index: gstplaybasebin.c RCS file: /cvs/gstreamer/gst-plugins/gst/playback/gstplaybasebin.c,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- gstplaybasebin.c 6 Oct 2004 16:33:06 -0000 1.19 +++ gstplaybasebin.c 7 Oct 2004 11:14:48 -0000 1.20 @@ -739,17 +739,69 @@ gst_object_unref (parent); } +static void +play_base_bin_mute_pad (GstPlayBaseBin * play_base_bin, + GstPad * pad, gboolean mute) +{ + GList *int_links; + gboolean activate = !mute; + gchar *debug_str = (activate ? "activate" : "inactivate"); + GST_DEBUG_OBJECT (play_base_bin, "%s %s:%s", debug_str, + GST_DEBUG_PAD_NAME (pad)); + gst_pad_set_active (pad, activate); + for (int_links = gst_pad_get_internal_links (pad); + int_links; int_links = g_list_next (int_links)) { + GstPad *pad = GST_PAD (int_links->data); + GstPad *peer = gst_pad_get_peer (pad); + GstElement *peer_elem = gst_pad_get_parent (peer); + GST_DEBUG_OBJECT (play_base_bin, "%s internal pad %s:%s", + debug_str, GST_DEBUG_PAD_NAME (pad)); + gst_pad_set_active (pad, activate); + if (peer_elem->numsrcpads == 1) { + GST_DEBUG_OBJECT (play_base_bin, "recursing element %s on pad %s:%s", + gst_element_get_name (peer_elem), GST_DEBUG_PAD_NAME (peer)); + play_base_bin_mute_pad (play_base_bin, peer, mute); + } else { + GST_DEBUG_OBJECT (play_base_bin, "%s final pad %s:%s", + debug_str, GST_DEBUG_PAD_NAME (peer)); + gst_pad_set_active (peer, activate); + } + } +} +/* muting a stream follows the flow downstream and dis/enables all + * pads it encounters until an element with more than one source pad + * (a demuxer or equivalent) is met. + */ void gst_play_base_bin_mute_stream (GstPlayBaseBin * play_base_bin, GstStreamInfo * info, gboolean mute) { - GST_DEBUG ("mute"); + GST_DEBUG ("mute stream"); + g_return_if_fail (play_base_bin != NULL); + g_return_if_fail (GST_IS_PLAY_BASE_BIN (play_base_bin)); + g_return_if_fail (info != NULL); + g_return_if_fail (GST_IS_STREAM_INFO (info)); + /* check if info contains a pad */ + if (info->pad == NULL) + return; + play_base_bin_mute_pad (play_base_bin, info->pad, mute); gst_play_base_bin_link_stream (GstPlayBaseBin * play_base_bin, GstStreamInfo * info, GstPad * pad) + GST_DEBUG ("link stream"); if (info == NULL) { GList *streams; Index: gstplaybin.c RCS file: /cvs/gstreamer/gst-plugins/gst/playback/gstplaybin.c,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- gstplaybin.c 6 Oct 2004 16:33:06 -0000 1.15 +++ gstplaybin.c 7 Oct 2004 11:14:48 -0000 1.16 @@ -382,8 +382,9 @@ GObject *obj = G_OBJECT (s->data); int type; GstPad *srcpad, *sinkpad; - GstElement *sink; + GstElement *sink = NULL; gboolean res; + gboolean mute = FALSE; g_object_get (obj, "type", &type, NULL); g_object_get (obj, "pad", &srcpad, NULL); @@ -394,7 +395,7 @@ if (type == 1) { if (have_audio) { g_warning ("two audio streams found, playing first one"); - continue; + mute = TRUE; } else { sink = gen_audio_element (play_bin); have_audio = TRUE; @@ -402,29 +403,36 @@ } else if (type == 2) { if (have_video) { g_warning ("two video streams found, playing first one"); sink = gen_video_element (play_bin); have_video = TRUE; } } else { g_warning ("unknown stream found"); - continue; + mute = TRUE; } - gst_bin_add (GST_BIN (play_bin), sink); - sinkpad = gst_element_get_pad (sink, "sink"); - res = gst_pad_link (srcpad, sinkpad); - if (!res) { - gchar *capsstr; + if (sink != NULL) { + gst_bin_add (GST_BIN (play_bin), sink); + sinkpad = gst_element_get_pad (sink, "sink"); + res = gst_pad_link (srcpad, sinkpad); + if (!res) { + gchar *capsstr; - capsstr = gst_caps_to_string (gst_pad_get_caps (srcpad)); - g_warning ("could not link %s", capsstr); - g_free (capsstr); - GST_LOG ("removing sink %p", sink); - gst_bin_remove (GST_BIN (play_bin), sink); - } else { - play_bin->sinks = g_list_prepend (play_bin->sinks, sink); + capsstr = gst_caps_to_string (gst_pad_get_caps (srcpad)); + g_warning ("could not link %s", capsstr); + g_free (capsstr); + GST_LOG ("removing sink %p", sink); + gst_bin_remove (GST_BIN (play_bin), sink); + } else { + play_bin->sinks = g_list_prepend (play_bin->sinks, sink); + } + if (mute) { + gst_play_base_bin_mute_stream (GST_PLAY_BASE_BIN (play_bin), + GST_STREAM_INFO (obj), TRUE); } |