gstreamer/gst/playback/gststreamselector.c

290 lines
8.9 KiB
C
Raw Normal View History

2005-01-08 18:31:22 +00:00
/* GStreamer
* Copyright (C) 2003 Julien Moutte <julien@moutte.net>
* Copyright (C) 2005 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
* !!!!!!!!!!!!!!!!! Big phat warning. !!!!!!!!!!!!!!!!!!!!!!
*
* The pads on the sinkside can be filled and the application is
* supposed to enable/disable them. The plugin will receive input
* data over the currently active pad and take care of data
* forwarding and negotiation. This plugin does nothing fancy. It
* exists to be light-weight and simple.
*
* This is not a generic switch element. This is not to be used for
* any such purpose. Patches to make it do that will be rejected.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "gststreamselector.h"
GST_DEBUG_CATEGORY_STATIC (stream_selector_debug);
#define GST_CAT_DEFAULT stream_selector_debug
static GstStaticPadTemplate gst_stream_selector_sink_factory =
GST_STATIC_PAD_TEMPLATE ("sink%d",
GST_PAD_SINK,
GST_PAD_REQUEST,
GST_STATIC_CAPS_ANY);
static GstStaticPadTemplate gst_stream_selector_src_factory =
GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS_ANY);
static void gst_stream_selector_dispose (GObject * object);
static void gst_stream_selector_init (GstStreamSelector * sel);
static void gst_stream_selector_base_init (GstStreamSelectorClass * klass);
static void gst_stream_selector_class_init (GstStreamSelectorClass * klass);
static GstCaps *gst_stream_selector_get_caps (GstPad * pad);
Raw and crude port of decodebin. Original commit message from CVS: * gst/playback/README: * gst/playback/gstdecodebin.c: (gst_decode_bin_class_init), (compare_ranks), (print_feature), (gst_decode_bin_init), (dynamic_create), (dynamic_free), (find_compatibles), (mimetype_is_raw), (close_pad_link), (got_redirect), (try_to_link_1), (get_our_ghost_pad), (remove_element_chain), (new_pad), (no_more_pads), (unlinked), (close_link), (type_found), (gst_decode_bin_change_state): * gst/playback/gstplaybasebin.c: (gst_play_base_bin_class_init), (gst_play_base_bin_init), (group_destroy), (group_commit), (check_queue), (queue_overrun), (queue_threshold_reached), (queue_out_of_data), (gen_preroll_element), (unknown_type), (new_decoded_pad), (setup_subtitle), (gen_source_element), (got_redirect), (setup_source), (play_base_eos), (gst_play_base_bin_change_state), (gst_play_base_bin_add_element), (gst_play_base_bin_remove_element): * gst/playback/gstplaybasebin.h: * gst/playback/gstplaybin.c: (gst_play_bin_class_init), (gst_play_bin_init), (gst_play_bin_dispose), (gst_play_bin_set_property), (gen_video_element), (gen_text_element), (gen_audio_element), (remove_sinks), (gst_play_bin_send_event): * gst/playback/gststreaminfo.c: (gst_stream_info_dispose), (stream_info_change_state), (gst_stream_info_set_mute): * gst/playback/gststreamselector.c: (gst_stream_selector_init), (gst_stream_selector_get_caps), (gst_stream_selector_setcaps), (gst_stream_selector_request_new_pad), (gst_stream_selector_event), (gst_stream_selector_chain): * gst/playback/test.c: (gen_video_element), (gen_audio_element), (main): * sys/xvimage/xvimagesink.c: (gst_xvimagesink_getcaps), (gst_xvimagesink_setcaps), (gst_xvimagesink_get_times), (gst_xvimagesink_show_frame), (gst_xvimagesink_chain), (gst_xvimagesink_buffer_alloc), (gst_xvimagesink_class_init): Raw and crude port of decodebin. Make playbin compile.
2005-04-12 10:48:58 +00:00
static gboolean gst_stream_selector_setcaps (GstPad * pad, GstCaps * caps);
2005-01-08 18:31:22 +00:00
static GList *gst_stream_selector_get_linked_pads (GstPad * pad);
static GstPad *gst_stream_selector_request_new_pad (GstElement * element,
GstPadTemplate * templ, const gchar * unused);
Raw and crude port of decodebin. Original commit message from CVS: * gst/playback/README: * gst/playback/gstdecodebin.c: (gst_decode_bin_class_init), (compare_ranks), (print_feature), (gst_decode_bin_init), (dynamic_create), (dynamic_free), (find_compatibles), (mimetype_is_raw), (close_pad_link), (got_redirect), (try_to_link_1), (get_our_ghost_pad), (remove_element_chain), (new_pad), (no_more_pads), (unlinked), (close_link), (type_found), (gst_decode_bin_change_state): * gst/playback/gstplaybasebin.c: (gst_play_base_bin_class_init), (gst_play_base_bin_init), (group_destroy), (group_commit), (check_queue), (queue_overrun), (queue_threshold_reached), (queue_out_of_data), (gen_preroll_element), (unknown_type), (new_decoded_pad), (setup_subtitle), (gen_source_element), (got_redirect), (setup_source), (play_base_eos), (gst_play_base_bin_change_state), (gst_play_base_bin_add_element), (gst_play_base_bin_remove_element): * gst/playback/gstplaybasebin.h: * gst/playback/gstplaybin.c: (gst_play_bin_class_init), (gst_play_bin_init), (gst_play_bin_dispose), (gst_play_bin_set_property), (gen_video_element), (gen_text_element), (gen_audio_element), (remove_sinks), (gst_play_bin_send_event): * gst/playback/gststreaminfo.c: (gst_stream_info_dispose), (stream_info_change_state), (gst_stream_info_set_mute): * gst/playback/gststreamselector.c: (gst_stream_selector_init), (gst_stream_selector_get_caps), (gst_stream_selector_setcaps), (gst_stream_selector_request_new_pad), (gst_stream_selector_event), (gst_stream_selector_chain): * gst/playback/test.c: (gen_video_element), (gen_audio_element), (main): * sys/xvimage/xvimagesink.c: (gst_xvimagesink_getcaps), (gst_xvimagesink_setcaps), (gst_xvimagesink_get_times), (gst_xvimagesink_show_frame), (gst_xvimagesink_chain), (gst_xvimagesink_buffer_alloc), (gst_xvimagesink_class_init): Raw and crude port of decodebin. Make playbin compile.
2005-04-12 10:48:58 +00:00
static gboolean gst_stream_selector_event (GstPad * pad, GstEvent * event);
static GstFlowReturn gst_stream_selector_chain (GstPad * pad,
GstBuffer * buffer);
2005-01-08 18:31:22 +00:00
static GstElementClass *parent_class = NULL;
GType
gst_stream_selector_get_type (void)
{
static GType stream_selector_type = 0;
if (!stream_selector_type) {
static const GTypeInfo stream_selector_info = {
sizeof (GstStreamSelectorClass),
(GBaseInitFunc) gst_stream_selector_base_init,
NULL,
(GClassInitFunc) gst_stream_selector_class_init,
NULL,
NULL,
sizeof (GstStreamSelector),
0,
(GInstanceInitFunc) gst_stream_selector_init,
};
stream_selector_type =
g_type_register_static (GST_TYPE_ELEMENT,
"GstStreamSelector", &stream_selector_info, 0);
GST_DEBUG_CATEGORY_INIT (stream_selector_debug,
"streamselector", 0, "A stream-selector element");
}
return stream_selector_type;
}
static void
gst_stream_selector_base_init (GstStreamSelectorClass * klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
static GstElementDetails gst_stream_selector_details =
GST_ELEMENT_DETAILS ("StreamSelector",
"Generic",
"N-to-1 input stream_selectoring",
"Julien Moutte <julien@moutte.net>\n"
"Ronald S. Bultje <rbultje@ronald.bitfreak.net>");
gst_element_class_set_details (element_class, &gst_stream_selector_details);
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_stream_selector_sink_factory));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_stream_selector_src_factory));
}
static void
gst_stream_selector_class_init (GstStreamSelectorClass * klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
gobject_class->dispose = gst_stream_selector_dispose;
gstelement_class->request_new_pad = gst_stream_selector_request_new_pad;
}
static void
gst_stream_selector_init (GstStreamSelector * sel)
{
sel->srcpad = gst_pad_new ("src", GST_PAD_SRC);
gst_pad_set_internal_link_function (sel->srcpad,
GST_DEBUG_FUNCPTR (gst_stream_selector_get_linked_pads));
Raw and crude port of decodebin. Original commit message from CVS: * gst/playback/README: * gst/playback/gstdecodebin.c: (gst_decode_bin_class_init), (compare_ranks), (print_feature), (gst_decode_bin_init), (dynamic_create), (dynamic_free), (find_compatibles), (mimetype_is_raw), (close_pad_link), (got_redirect), (try_to_link_1), (get_our_ghost_pad), (remove_element_chain), (new_pad), (no_more_pads), (unlinked), (close_link), (type_found), (gst_decode_bin_change_state): * gst/playback/gstplaybasebin.c: (gst_play_base_bin_class_init), (gst_play_base_bin_init), (group_destroy), (group_commit), (check_queue), (queue_overrun), (queue_threshold_reached), (queue_out_of_data), (gen_preroll_element), (unknown_type), (new_decoded_pad), (setup_subtitle), (gen_source_element), (got_redirect), (setup_source), (play_base_eos), (gst_play_base_bin_change_state), (gst_play_base_bin_add_element), (gst_play_base_bin_remove_element): * gst/playback/gstplaybasebin.h: * gst/playback/gstplaybin.c: (gst_play_bin_class_init), (gst_play_bin_init), (gst_play_bin_dispose), (gst_play_bin_set_property), (gen_video_element), (gen_text_element), (gen_audio_element), (remove_sinks), (gst_play_bin_send_event): * gst/playback/gststreaminfo.c: (gst_stream_info_dispose), (stream_info_change_state), (gst_stream_info_set_mute): * gst/playback/gststreamselector.c: (gst_stream_selector_init), (gst_stream_selector_get_caps), (gst_stream_selector_setcaps), (gst_stream_selector_request_new_pad), (gst_stream_selector_event), (gst_stream_selector_chain): * gst/playback/test.c: (gen_video_element), (gen_audio_element), (main): * sys/xvimage/xvimagesink.c: (gst_xvimagesink_getcaps), (gst_xvimagesink_setcaps), (gst_xvimagesink_get_times), (gst_xvimagesink_show_frame), (gst_xvimagesink_chain), (gst_xvimagesink_buffer_alloc), (gst_xvimagesink_class_init): Raw and crude port of decodebin. Make playbin compile.
2005-04-12 10:48:58 +00:00
gst_pad_set_setcaps_function (sel->srcpad,
GST_DEBUG_FUNCPTR (gst_stream_selector_setcaps));
2005-01-08 18:31:22 +00:00
gst_pad_set_getcaps_function (sel->srcpad,
GST_DEBUG_FUNCPTR (gst_stream_selector_get_caps));
gst_element_add_pad (GST_ELEMENT (sel), sel->srcpad);
/* sinkpad management */
sel->last_active_sinkpad = NULL;
sel->nb_sinkpads = 0;
sel->in_chain = FALSE;
2005-01-08 18:31:22 +00:00
}
static void
gst_stream_selector_dispose (GObject * object)
{
GstStreamSelector *sel = GST_STREAM_SELECTOR (object);
sel->last_active_sinkpad = NULL;
G_OBJECT_CLASS (parent_class)->dispose (object);
}
static GstPad *
gst_stream_selector_get_linked_pad (GstPad * pad)
{
GstStreamSelector *sel = GST_STREAM_SELECTOR (gst_pad_get_parent (pad));
GstPad *otherpad = NULL;
if (pad == sel->srcpad)
otherpad = sel->last_active_sinkpad;
else if (pad == sel->last_active_sinkpad)
otherpad = sel->srcpad;
return otherpad;
}
static GstCaps *
gst_stream_selector_get_caps (GstPad * pad)
{
GstPad *otherpad = gst_stream_selector_get_linked_pad (pad);
if (!otherpad) {
GST_DEBUG_OBJECT (gst_pad_get_parent (pad),
"Pad %s not linked, returning ANY", gst_pad_get_name (pad));
return gst_caps_new_any ();
}
GST_DEBUG_OBJECT (gst_pad_get_parent (pad),
Raw and crude port of decodebin. Original commit message from CVS: * gst/playback/README: * gst/playback/gstdecodebin.c: (gst_decode_bin_class_init), (compare_ranks), (print_feature), (gst_decode_bin_init), (dynamic_create), (dynamic_free), (find_compatibles), (mimetype_is_raw), (close_pad_link), (got_redirect), (try_to_link_1), (get_our_ghost_pad), (remove_element_chain), (new_pad), (no_more_pads), (unlinked), (close_link), (type_found), (gst_decode_bin_change_state): * gst/playback/gstplaybasebin.c: (gst_play_base_bin_class_init), (gst_play_base_bin_init), (group_destroy), (group_commit), (check_queue), (queue_overrun), (queue_threshold_reached), (queue_out_of_data), (gen_preroll_element), (unknown_type), (new_decoded_pad), (setup_subtitle), (gen_source_element), (got_redirect), (setup_source), (play_base_eos), (gst_play_base_bin_change_state), (gst_play_base_bin_add_element), (gst_play_base_bin_remove_element): * gst/playback/gstplaybasebin.h: * gst/playback/gstplaybin.c: (gst_play_bin_class_init), (gst_play_bin_init), (gst_play_bin_dispose), (gst_play_bin_set_property), (gen_video_element), (gen_text_element), (gen_audio_element), (remove_sinks), (gst_play_bin_send_event): * gst/playback/gststreaminfo.c: (gst_stream_info_dispose), (stream_info_change_state), (gst_stream_info_set_mute): * gst/playback/gststreamselector.c: (gst_stream_selector_init), (gst_stream_selector_get_caps), (gst_stream_selector_setcaps), (gst_stream_selector_request_new_pad), (gst_stream_selector_event), (gst_stream_selector_chain): * gst/playback/test.c: (gen_video_element), (gen_audio_element), (main): * sys/xvimage/xvimagesink.c: (gst_xvimagesink_getcaps), (gst_xvimagesink_setcaps), (gst_xvimagesink_get_times), (gst_xvimagesink_show_frame), (gst_xvimagesink_chain), (gst_xvimagesink_buffer_alloc), (gst_xvimagesink_class_init): Raw and crude port of decodebin. Make playbin compile.
2005-04-12 10:48:58 +00:00
"Pad %s is linked (to %s), returning peer-caps",
2005-01-08 18:31:22 +00:00
gst_pad_get_name (pad), gst_pad_get_name (otherpad));
Raw and crude port of decodebin. Original commit message from CVS: * gst/playback/README: * gst/playback/gstdecodebin.c: (gst_decode_bin_class_init), (compare_ranks), (print_feature), (gst_decode_bin_init), (dynamic_create), (dynamic_free), (find_compatibles), (mimetype_is_raw), (close_pad_link), (got_redirect), (try_to_link_1), (get_our_ghost_pad), (remove_element_chain), (new_pad), (no_more_pads), (unlinked), (close_link), (type_found), (gst_decode_bin_change_state): * gst/playback/gstplaybasebin.c: (gst_play_base_bin_class_init), (gst_play_base_bin_init), (group_destroy), (group_commit), (check_queue), (queue_overrun), (queue_threshold_reached), (queue_out_of_data), (gen_preroll_element), (unknown_type), (new_decoded_pad), (setup_subtitle), (gen_source_element), (got_redirect), (setup_source), (play_base_eos), (gst_play_base_bin_change_state), (gst_play_base_bin_add_element), (gst_play_base_bin_remove_element): * gst/playback/gstplaybasebin.h: * gst/playback/gstplaybin.c: (gst_play_bin_class_init), (gst_play_bin_init), (gst_play_bin_dispose), (gst_play_bin_set_property), (gen_video_element), (gen_text_element), (gen_audio_element), (remove_sinks), (gst_play_bin_send_event): * gst/playback/gststreaminfo.c: (gst_stream_info_dispose), (stream_info_change_state), (gst_stream_info_set_mute): * gst/playback/gststreamselector.c: (gst_stream_selector_init), (gst_stream_selector_get_caps), (gst_stream_selector_setcaps), (gst_stream_selector_request_new_pad), (gst_stream_selector_event), (gst_stream_selector_chain): * gst/playback/test.c: (gen_video_element), (gen_audio_element), (main): * sys/xvimage/xvimagesink.c: (gst_xvimagesink_getcaps), (gst_xvimagesink_setcaps), (gst_xvimagesink_get_times), (gst_xvimagesink_show_frame), (gst_xvimagesink_chain), (gst_xvimagesink_buffer_alloc), (gst_xvimagesink_class_init): Raw and crude port of decodebin. Make playbin compile.
2005-04-12 10:48:58 +00:00
return gst_pad_peer_get_caps (otherpad);
2005-01-08 18:31:22 +00:00
}
Raw and crude port of decodebin. Original commit message from CVS: * gst/playback/README: * gst/playback/gstdecodebin.c: (gst_decode_bin_class_init), (compare_ranks), (print_feature), (gst_decode_bin_init), (dynamic_create), (dynamic_free), (find_compatibles), (mimetype_is_raw), (close_pad_link), (got_redirect), (try_to_link_1), (get_our_ghost_pad), (remove_element_chain), (new_pad), (no_more_pads), (unlinked), (close_link), (type_found), (gst_decode_bin_change_state): * gst/playback/gstplaybasebin.c: (gst_play_base_bin_class_init), (gst_play_base_bin_init), (group_destroy), (group_commit), (check_queue), (queue_overrun), (queue_threshold_reached), (queue_out_of_data), (gen_preroll_element), (unknown_type), (new_decoded_pad), (setup_subtitle), (gen_source_element), (got_redirect), (setup_source), (play_base_eos), (gst_play_base_bin_change_state), (gst_play_base_bin_add_element), (gst_play_base_bin_remove_element): * gst/playback/gstplaybasebin.h: * gst/playback/gstplaybin.c: (gst_play_bin_class_init), (gst_play_bin_init), (gst_play_bin_dispose), (gst_play_bin_set_property), (gen_video_element), (gen_text_element), (gen_audio_element), (remove_sinks), (gst_play_bin_send_event): * gst/playback/gststreaminfo.c: (gst_stream_info_dispose), (stream_info_change_state), (gst_stream_info_set_mute): * gst/playback/gststreamselector.c: (gst_stream_selector_init), (gst_stream_selector_get_caps), (gst_stream_selector_setcaps), (gst_stream_selector_request_new_pad), (gst_stream_selector_event), (gst_stream_selector_chain): * gst/playback/test.c: (gen_video_element), (gen_audio_element), (main): * sys/xvimage/xvimagesink.c: (gst_xvimagesink_getcaps), (gst_xvimagesink_setcaps), (gst_xvimagesink_get_times), (gst_xvimagesink_show_frame), (gst_xvimagesink_chain), (gst_xvimagesink_buffer_alloc), (gst_xvimagesink_class_init): Raw and crude port of decodebin. Make playbin compile.
2005-04-12 10:48:58 +00:00
static gboolean
gst_stream_selector_setcaps (GstPad * pad, GstCaps * caps)
2005-01-08 18:31:22 +00:00
{
GstPad *otherpad = gst_stream_selector_get_linked_pad (pad);
if (!otherpad) {
GST_DEBUG_OBJECT (gst_pad_get_parent (pad),
"Pad %s not linked, returning %s",
gst_pad_get_name (pad), GST_PAD_IS_SINK (pad) ? "ok" : "delayed");
Raw and crude port of decodebin. Original commit message from CVS: * gst/playback/README: * gst/playback/gstdecodebin.c: (gst_decode_bin_class_init), (compare_ranks), (print_feature), (gst_decode_bin_init), (dynamic_create), (dynamic_free), (find_compatibles), (mimetype_is_raw), (close_pad_link), (got_redirect), (try_to_link_1), (get_our_ghost_pad), (remove_element_chain), (new_pad), (no_more_pads), (unlinked), (close_link), (type_found), (gst_decode_bin_change_state): * gst/playback/gstplaybasebin.c: (gst_play_base_bin_class_init), (gst_play_base_bin_init), (group_destroy), (group_commit), (check_queue), (queue_overrun), (queue_threshold_reached), (queue_out_of_data), (gen_preroll_element), (unknown_type), (new_decoded_pad), (setup_subtitle), (gen_source_element), (got_redirect), (setup_source), (play_base_eos), (gst_play_base_bin_change_state), (gst_play_base_bin_add_element), (gst_play_base_bin_remove_element): * gst/playback/gstplaybasebin.h: * gst/playback/gstplaybin.c: (gst_play_bin_class_init), (gst_play_bin_init), (gst_play_bin_dispose), (gst_play_bin_set_property), (gen_video_element), (gen_text_element), (gen_audio_element), (remove_sinks), (gst_play_bin_send_event): * gst/playback/gststreaminfo.c: (gst_stream_info_dispose), (stream_info_change_state), (gst_stream_info_set_mute): * gst/playback/gststreamselector.c: (gst_stream_selector_init), (gst_stream_selector_get_caps), (gst_stream_selector_setcaps), (gst_stream_selector_request_new_pad), (gst_stream_selector_event), (gst_stream_selector_chain): * gst/playback/test.c: (gen_video_element), (gen_audio_element), (main): * sys/xvimage/xvimagesink.c: (gst_xvimagesink_getcaps), (gst_xvimagesink_setcaps), (gst_xvimagesink_get_times), (gst_xvimagesink_show_frame), (gst_xvimagesink_chain), (gst_xvimagesink_buffer_alloc), (gst_xvimagesink_class_init): Raw and crude port of decodebin. Make playbin compile.
2005-04-12 10:48:58 +00:00
return FALSE;
2005-01-08 18:31:22 +00:00
}
GST_DEBUG_OBJECT (gst_pad_get_parent (pad),
"Pad %s is linked (to %s), returning other-trysetcaps",
gst_pad_get_name (pad), gst_pad_get_name (otherpad));
Raw and crude port of decodebin. Original commit message from CVS: * gst/playback/README: * gst/playback/gstdecodebin.c: (gst_decode_bin_class_init), (compare_ranks), (print_feature), (gst_decode_bin_init), (dynamic_create), (dynamic_free), (find_compatibles), (mimetype_is_raw), (close_pad_link), (got_redirect), (try_to_link_1), (get_our_ghost_pad), (remove_element_chain), (new_pad), (no_more_pads), (unlinked), (close_link), (type_found), (gst_decode_bin_change_state): * gst/playback/gstplaybasebin.c: (gst_play_base_bin_class_init), (gst_play_base_bin_init), (group_destroy), (group_commit), (check_queue), (queue_overrun), (queue_threshold_reached), (queue_out_of_data), (gen_preroll_element), (unknown_type), (new_decoded_pad), (setup_subtitle), (gen_source_element), (got_redirect), (setup_source), (play_base_eos), (gst_play_base_bin_change_state), (gst_play_base_bin_add_element), (gst_play_base_bin_remove_element): * gst/playback/gstplaybasebin.h: * gst/playback/gstplaybin.c: (gst_play_bin_class_init), (gst_play_bin_init), (gst_play_bin_dispose), (gst_play_bin_set_property), (gen_video_element), (gen_text_element), (gen_audio_element), (remove_sinks), (gst_play_bin_send_event): * gst/playback/gststreaminfo.c: (gst_stream_info_dispose), (stream_info_change_state), (gst_stream_info_set_mute): * gst/playback/gststreamselector.c: (gst_stream_selector_init), (gst_stream_selector_get_caps), (gst_stream_selector_setcaps), (gst_stream_selector_request_new_pad), (gst_stream_selector_event), (gst_stream_selector_chain): * gst/playback/test.c: (gen_video_element), (gen_audio_element), (main): * sys/xvimage/xvimagesink.c: (gst_xvimagesink_getcaps), (gst_xvimagesink_setcaps), (gst_xvimagesink_get_times), (gst_xvimagesink_show_frame), (gst_xvimagesink_chain), (gst_xvimagesink_buffer_alloc), (gst_xvimagesink_class_init): Raw and crude port of decodebin. Make playbin compile.
2005-04-12 10:48:58 +00:00
gst_pad_set_caps (otherpad, caps);
return TRUE;
2005-01-08 18:31:22 +00:00
}
static GList *
gst_stream_selector_get_linked_pads (GstPad * pad)
{
GstPad *otherpad = gst_stream_selector_get_linked_pad (pad);
if (!otherpad)
return NULL;
return g_list_append (NULL, otherpad);
}
static GstPad *
gst_stream_selector_request_new_pad (GstElement * element,
GstPadTemplate * templ, const gchar * unused)
{
GstStreamSelector *sel = GST_STREAM_SELECTOR (element);
gchar *name = NULL;
GstPad *sinkpad = NULL;
g_return_val_if_fail (templ->direction == GST_PAD_SINK, NULL);
GST_LOG_OBJECT (sel, "Creating new pad %d", sel->nb_sinkpads);
name = g_strdup_printf ("sink%d", sel->nb_sinkpads++);
sinkpad = gst_pad_new_from_template (templ, name);
if (sel->nb_sinkpads == 1)
sel->last_active_sinkpad = sinkpad;
2005-01-08 18:31:22 +00:00
g_free (name);
gst_pad_set_getcaps_function (sinkpad,
GST_DEBUG_FUNCPTR (gst_stream_selector_get_caps));
gst_pad_set_chain_function (sinkpad,
GST_DEBUG_FUNCPTR (gst_stream_selector_chain));
Raw and crude port of decodebin. Original commit message from CVS: * gst/playback/README: * gst/playback/gstdecodebin.c: (gst_decode_bin_class_init), (compare_ranks), (print_feature), (gst_decode_bin_init), (dynamic_create), (dynamic_free), (find_compatibles), (mimetype_is_raw), (close_pad_link), (got_redirect), (try_to_link_1), (get_our_ghost_pad), (remove_element_chain), (new_pad), (no_more_pads), (unlinked), (close_link), (type_found), (gst_decode_bin_change_state): * gst/playback/gstplaybasebin.c: (gst_play_base_bin_class_init), (gst_play_base_bin_init), (group_destroy), (group_commit), (check_queue), (queue_overrun), (queue_threshold_reached), (queue_out_of_data), (gen_preroll_element), (unknown_type), (new_decoded_pad), (setup_subtitle), (gen_source_element), (got_redirect), (setup_source), (play_base_eos), (gst_play_base_bin_change_state), (gst_play_base_bin_add_element), (gst_play_base_bin_remove_element): * gst/playback/gstplaybasebin.h: * gst/playback/gstplaybin.c: (gst_play_bin_class_init), (gst_play_bin_init), (gst_play_bin_dispose), (gst_play_bin_set_property), (gen_video_element), (gen_text_element), (gen_audio_element), (remove_sinks), (gst_play_bin_send_event): * gst/playback/gststreaminfo.c: (gst_stream_info_dispose), (stream_info_change_state), (gst_stream_info_set_mute): * gst/playback/gststreamselector.c: (gst_stream_selector_init), (gst_stream_selector_get_caps), (gst_stream_selector_setcaps), (gst_stream_selector_request_new_pad), (gst_stream_selector_event), (gst_stream_selector_chain): * gst/playback/test.c: (gen_video_element), (gen_audio_element), (main): * sys/xvimage/xvimagesink.c: (gst_xvimagesink_getcaps), (gst_xvimagesink_setcaps), (gst_xvimagesink_get_times), (gst_xvimagesink_show_frame), (gst_xvimagesink_chain), (gst_xvimagesink_buffer_alloc), (gst_xvimagesink_class_init): Raw and crude port of decodebin. Make playbin compile.
2005-04-12 10:48:58 +00:00
gst_pad_set_event_function (sinkpad,
GST_DEBUG_FUNCPTR (gst_stream_selector_event));
2005-01-08 18:31:22 +00:00
gst_pad_set_internal_link_function (sinkpad,
GST_DEBUG_FUNCPTR (gst_stream_selector_get_linked_pads));
gst_element_add_pad (GST_ELEMENT (sel), sinkpad);
return sinkpad;
}
Raw and crude port of decodebin. Original commit message from CVS: * gst/playback/README: * gst/playback/gstdecodebin.c: (gst_decode_bin_class_init), (compare_ranks), (print_feature), (gst_decode_bin_init), (dynamic_create), (dynamic_free), (find_compatibles), (mimetype_is_raw), (close_pad_link), (got_redirect), (try_to_link_1), (get_our_ghost_pad), (remove_element_chain), (new_pad), (no_more_pads), (unlinked), (close_link), (type_found), (gst_decode_bin_change_state): * gst/playback/gstplaybasebin.c: (gst_play_base_bin_class_init), (gst_play_base_bin_init), (group_destroy), (group_commit), (check_queue), (queue_overrun), (queue_threshold_reached), (queue_out_of_data), (gen_preroll_element), (unknown_type), (new_decoded_pad), (setup_subtitle), (gen_source_element), (got_redirect), (setup_source), (play_base_eos), (gst_play_base_bin_change_state), (gst_play_base_bin_add_element), (gst_play_base_bin_remove_element): * gst/playback/gstplaybasebin.h: * gst/playback/gstplaybin.c: (gst_play_bin_class_init), (gst_play_bin_init), (gst_play_bin_dispose), (gst_play_bin_set_property), (gen_video_element), (gen_text_element), (gen_audio_element), (remove_sinks), (gst_play_bin_send_event): * gst/playback/gststreaminfo.c: (gst_stream_info_dispose), (stream_info_change_state), (gst_stream_info_set_mute): * gst/playback/gststreamselector.c: (gst_stream_selector_init), (gst_stream_selector_get_caps), (gst_stream_selector_setcaps), (gst_stream_selector_request_new_pad), (gst_stream_selector_event), (gst_stream_selector_chain): * gst/playback/test.c: (gen_video_element), (gen_audio_element), (main): * sys/xvimage/xvimagesink.c: (gst_xvimagesink_getcaps), (gst_xvimagesink_setcaps), (gst_xvimagesink_get_times), (gst_xvimagesink_show_frame), (gst_xvimagesink_chain), (gst_xvimagesink_buffer_alloc), (gst_xvimagesink_class_init): Raw and crude port of decodebin. Make playbin compile.
2005-04-12 10:48:58 +00:00
static gboolean
gst_stream_selector_event (GstPad * pad, GstEvent * event)
2005-01-08 18:31:22 +00:00
{
Raw and crude port of decodebin. Original commit message from CVS: * gst/playback/README: * gst/playback/gstdecodebin.c: (gst_decode_bin_class_init), (compare_ranks), (print_feature), (gst_decode_bin_init), (dynamic_create), (dynamic_free), (find_compatibles), (mimetype_is_raw), (close_pad_link), (got_redirect), (try_to_link_1), (get_our_ghost_pad), (remove_element_chain), (new_pad), (no_more_pads), (unlinked), (close_link), (type_found), (gst_decode_bin_change_state): * gst/playback/gstplaybasebin.c: (gst_play_base_bin_class_init), (gst_play_base_bin_init), (group_destroy), (group_commit), (check_queue), (queue_overrun), (queue_threshold_reached), (queue_out_of_data), (gen_preroll_element), (unknown_type), (new_decoded_pad), (setup_subtitle), (gen_source_element), (got_redirect), (setup_source), (play_base_eos), (gst_play_base_bin_change_state), (gst_play_base_bin_add_element), (gst_play_base_bin_remove_element): * gst/playback/gstplaybasebin.h: * gst/playback/gstplaybin.c: (gst_play_bin_class_init), (gst_play_bin_init), (gst_play_bin_dispose), (gst_play_bin_set_property), (gen_video_element), (gen_text_element), (gen_audio_element), (remove_sinks), (gst_play_bin_send_event): * gst/playback/gststreaminfo.c: (gst_stream_info_dispose), (stream_info_change_state), (gst_stream_info_set_mute): * gst/playback/gststreamselector.c: (gst_stream_selector_init), (gst_stream_selector_get_caps), (gst_stream_selector_setcaps), (gst_stream_selector_request_new_pad), (gst_stream_selector_event), (gst_stream_selector_chain): * gst/playback/test.c: (gen_video_element), (gen_audio_element), (main): * sys/xvimage/xvimagesink.c: (gst_xvimagesink_getcaps), (gst_xvimagesink_setcaps), (gst_xvimagesink_get_times), (gst_xvimagesink_show_frame), (gst_xvimagesink_chain), (gst_xvimagesink_buffer_alloc), (gst_xvimagesink_class_init): Raw and crude port of decodebin. Make playbin compile.
2005-04-12 10:48:58 +00:00
GstStreamSelector *sel = GST_STREAM_SELECTOR (GST_PAD_PARENT (pad));
/* forward */
GST_DEBUG_OBJECT (sel, "Forwarding event %p from pad %s",
event, GST_OBJECT_NAME (pad));
return gst_pad_push_event (sel->srcpad, event);
}
static GstFlowReturn
gst_stream_selector_chain (GstPad * pad, GstBuffer * buffer)
{
GstStreamSelector *sel = GST_STREAM_SELECTOR (GST_PAD_PARENT (pad));
2005-01-08 18:31:22 +00:00
/* first, check if the active pad changed. If so, redo
* negotiation and fail if that fails. */
if (pad != sel->last_active_sinkpad) {
GST_LOG_OBJECT (sel, "stream change detected, switching from %s to %s",
sel->last_active_sinkpad ?
gst_pad_get_name (sel->last_active_sinkpad) : "none",
gst_pad_get_name (pad));
sel->last_active_sinkpad = pad;
}
/* forward */
Raw and crude port of decodebin. Original commit message from CVS: * gst/playback/README: * gst/playback/gstdecodebin.c: (gst_decode_bin_class_init), (compare_ranks), (print_feature), (gst_decode_bin_init), (dynamic_create), (dynamic_free), (find_compatibles), (mimetype_is_raw), (close_pad_link), (got_redirect), (try_to_link_1), (get_our_ghost_pad), (remove_element_chain), (new_pad), (no_more_pads), (unlinked), (close_link), (type_found), (gst_decode_bin_change_state): * gst/playback/gstplaybasebin.c: (gst_play_base_bin_class_init), (gst_play_base_bin_init), (group_destroy), (group_commit), (check_queue), (queue_overrun), (queue_threshold_reached), (queue_out_of_data), (gen_preroll_element), (unknown_type), (new_decoded_pad), (setup_subtitle), (gen_source_element), (got_redirect), (setup_source), (play_base_eos), (gst_play_base_bin_change_state), (gst_play_base_bin_add_element), (gst_play_base_bin_remove_element): * gst/playback/gstplaybasebin.h: * gst/playback/gstplaybin.c: (gst_play_bin_class_init), (gst_play_bin_init), (gst_play_bin_dispose), (gst_play_bin_set_property), (gen_video_element), (gen_text_element), (gen_audio_element), (remove_sinks), (gst_play_bin_send_event): * gst/playback/gststreaminfo.c: (gst_stream_info_dispose), (stream_info_change_state), (gst_stream_info_set_mute): * gst/playback/gststreamselector.c: (gst_stream_selector_init), (gst_stream_selector_get_caps), (gst_stream_selector_setcaps), (gst_stream_selector_request_new_pad), (gst_stream_selector_event), (gst_stream_selector_chain): * gst/playback/test.c: (gen_video_element), (gen_audio_element), (main): * sys/xvimage/xvimagesink.c: (gst_xvimagesink_getcaps), (gst_xvimagesink_setcaps), (gst_xvimagesink_get_times), (gst_xvimagesink_show_frame), (gst_xvimagesink_chain), (gst_xvimagesink_buffer_alloc), (gst_xvimagesink_class_init): Raw and crude port of decodebin. Make playbin compile.
2005-04-12 10:48:58 +00:00
GST_DEBUG_OBJECT (sel, "Forwarding buffer %p from pad %s",
buffer, GST_OBJECT_NAME (pad));
return gst_pad_push (sel->srcpad, buffer);
2005-01-08 18:31:22 +00:00
}