mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-17 11:45:25 +00:00
gst/playback/: Implement muting/unmuting of streams, mute streams that are not used.
Original commit message from CVS: * 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.
This commit is contained in:
parent
96ead4ff7f
commit
72570f800a
3 changed files with 85 additions and 17 deletions
|
@ -1,3 +1,11 @@
|
|||
2004-10-07 Wim Taymans <wim@fluendo.com>
|
||||
|
||||
* 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 <wim@fluendo.com>
|
||||
|
||||
* gst/typefind/gsttypefindfunctions.c: (ac3_type_find),
|
||||
|
|
|
@ -739,17 +739,69 @@ gst_play_base_bin_found_tag (GstElement * element,
|
|||
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);
|
||||
}
|
||||
|
||||
void
|
||||
gst_play_base_bin_link_stream (GstPlayBaseBin * play_base_bin,
|
||||
GstStreamInfo * info, GstPad * pad)
|
||||
{
|
||||
GST_DEBUG ("link stream");
|
||||
|
||||
if (info == NULL) {
|
||||
GList *streams;
|
||||
|
||||
|
|
|
@ -382,8 +382,9 @@ setup_sinks (GstPlayBin * play_bin)
|
|||
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 @@ setup_sinks (GstPlayBin * play_bin)
|
|||
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 @@ setup_sinks (GstPlayBin * play_bin)
|
|||
} else if (type == 2) {
|
||||
if (have_video) {
|
||||
g_warning ("two video streams found, playing first one");
|
||||
continue;
|
||||
mute = TRUE;
|
||||
} else {
|
||||
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);
|
||||
mute = TRUE;
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue