2010-12-31 00:43:37 +00:00
|
|
|
/* GStreamer output selector
|
2008-01-29 07:38:31 +00:00
|
|
|
* Copyright (C) 2008 Nokia Corporation. (contact <stefan.kost@nokia.com>)
|
|
|
|
*
|
|
|
|
* 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
|
2012-11-03 20:44:48 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2008-01-29 07:38:31 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* SECTION:element-output-selector
|
2009-05-28 07:12:58 +00:00
|
|
|
* @see_also: #GstOutputSelector, #GstInputSelector
|
2008-01-29 07:38:31 +00:00
|
|
|
*
|
|
|
|
* Direct input stream to one out of N output pads.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "gstoutputselector.h"
|
|
|
|
|
|
|
|
GST_DEBUG_CATEGORY_STATIC (output_selector_debug);
|
|
|
|
#define GST_CAT_DEFAULT output_selector_debug
|
|
|
|
|
|
|
|
static GstStaticPadTemplate gst_output_selector_sink_factory =
|
|
|
|
GST_STATIC_PAD_TEMPLATE ("sink",
|
|
|
|
GST_PAD_SINK,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS_ANY);
|
|
|
|
|
|
|
|
static GstStaticPadTemplate gst_output_selector_src_factory =
|
2011-11-03 16:49:45 +00:00
|
|
|
GST_STATIC_PAD_TEMPLATE ("src_%u",
|
2008-01-29 07:38:31 +00:00
|
|
|
GST_PAD_SRC,
|
|
|
|
GST_PAD_REQUEST,
|
|
|
|
GST_STATIC_CAPS_ANY);
|
|
|
|
|
2011-01-04 15:42:50 +00:00
|
|
|
enum GstOutputSelectorPadNegotiationMode
|
|
|
|
{
|
|
|
|
GST_OUTPUT_SELECTOR_PAD_NEGOTIATION_MODE_NONE,
|
|
|
|
GST_OUTPUT_SELECTOR_PAD_NEGOTIATION_MODE_ALL,
|
|
|
|
GST_OUTPUT_SELECTOR_PAD_NEGOTIATION_MODE_ACTIVE
|
|
|
|
};
|
|
|
|
#define GST_TYPE_OUTPUT_SELECTOR_PAD_NEGOTIATION_MODE (gst_output_selector_pad_negotiation_mode_get_type())
|
|
|
|
static GType
|
|
|
|
gst_output_selector_pad_negotiation_mode_get_type (void)
|
|
|
|
{
|
|
|
|
static GType pad_negotiation_mode_type = 0;
|
|
|
|
static GEnumValue pad_negotiation_modes[] = {
|
|
|
|
{GST_OUTPUT_SELECTOR_PAD_NEGOTIATION_MODE_NONE, "None", "none"},
|
|
|
|
{GST_OUTPUT_SELECTOR_PAD_NEGOTIATION_MODE_ALL, "All", "all"},
|
|
|
|
{GST_OUTPUT_SELECTOR_PAD_NEGOTIATION_MODE_ACTIVE, "Active", "active"},
|
|
|
|
{0, NULL, NULL}
|
|
|
|
};
|
|
|
|
|
|
|
|
if (!pad_negotiation_mode_type) {
|
|
|
|
pad_negotiation_mode_type =
|
|
|
|
g_enum_register_static ("GstOutputSelectorPadNegotiationMode",
|
|
|
|
pad_negotiation_modes);
|
|
|
|
}
|
|
|
|
return pad_negotiation_mode_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-01-29 07:38:31 +00:00
|
|
|
enum
|
|
|
|
{
|
plugins/elements/gstinputselector.*: Various cleanups.
Original commit message from CVS:
* plugins/elements/gstinputselector.c: (gst_selector_pad_class_init),
(gst_selector_pad_finalize), (gst_selector_pad_get_property),
(gst_selector_pad_event), (gst_input_selector_class_init),
(gst_input_selector_init), (gst_input_selector_set_active_pad),
(gst_input_selector_set_property),
(gst_input_selector_get_property),
(gst_input_selector_request_new_pad),
(gst_input_selector_release_pad),
(gst_input_selector_push_pending_stop),
(gst_input_selector_switch):
* plugins/elements/gstinputselector.h:
Various cleanups.
Added tags to the pads.
Select active pad based on the pad object instead of its name.
Fix refcount in set_active_pad.
Add property to get the number of pads.
* plugins/elements/gstoutputselector.c:
(gst_output_selector_class_init),
(gst_output_selector_set_property),
(gst_output_selector_get_property):
Various cleanups.
Select the active pad based on the pad object instead of its name.
Fix locking when setting the active pad.
* plugins/elements/gstselector-marshal.list:
* tests/check/elements/selector.c: (cleanup_pad),
(selector_set_active_pad), (run_input_selector_buffer_count):
Fixes for pad instead of padname for pad selection.
2008-03-13 16:46:04 +00:00
|
|
|
PROP_0,
|
|
|
|
PROP_ACTIVE_PAD,
|
2011-01-04 15:42:50 +00:00
|
|
|
PROP_RESEND_LATEST,
|
|
|
|
PROP_PAD_NEGOTIATION_MODE
|
2008-01-29 07:38:31 +00:00
|
|
|
};
|
|
|
|
|
2011-01-04 15:42:50 +00:00
|
|
|
#define DEFAULT_PAD_NEGOTIATION_MODE GST_OUTPUT_SELECTOR_PAD_NEGOTIATION_MODE_ALL
|
|
|
|
|
2011-04-18 16:07:06 +00:00
|
|
|
#define _do_init \
|
2010-08-24 08:50:47 +00:00
|
|
|
GST_DEBUG_CATEGORY_INIT (output_selector_debug, \
|
2010-12-31 00:43:37 +00:00
|
|
|
"output-selector", 0, "Output stream selector");
|
2011-04-18 16:07:06 +00:00
|
|
|
#define gst_output_selector_parent_class parent_class
|
|
|
|
G_DEFINE_TYPE_WITH_CODE (GstOutputSelector, gst_output_selector,
|
2010-08-24 08:50:47 +00:00
|
|
|
GST_TYPE_ELEMENT, _do_init);
|
2008-06-19 13:18:24 +00:00
|
|
|
|
2008-01-29 07:38:31 +00:00
|
|
|
static void gst_output_selector_dispose (GObject * object);
|
|
|
|
static void gst_output_selector_set_property (GObject * object,
|
|
|
|
guint prop_id, const GValue * value, GParamSpec * pspec);
|
|
|
|
static void gst_output_selector_get_property (GObject * object,
|
|
|
|
guint prop_id, GValue * value, GParamSpec * pspec);
|
|
|
|
static GstPad *gst_output_selector_request_new_pad (GstElement * element,
|
2011-05-10 14:41:36 +00:00
|
|
|
GstPadTemplate * templ, const gchar * unused, const GstCaps * caps);
|
2008-01-29 07:38:31 +00:00
|
|
|
static void gst_output_selector_release_pad (GstElement * element,
|
|
|
|
GstPad * pad);
|
2011-11-17 11:40:45 +00:00
|
|
|
static GstFlowReturn gst_output_selector_chain (GstPad * pad,
|
|
|
|
GstObject * parent, GstBuffer * buf);
|
2008-01-29 07:38:31 +00:00
|
|
|
static GstStateChangeReturn gst_output_selector_change_state (GstElement *
|
|
|
|
element, GstStateChange transition);
|
2011-11-17 11:40:45 +00:00
|
|
|
static gboolean gst_output_selector_event (GstPad * pad, GstObject * parent,
|
|
|
|
GstEvent * event);
|
2011-11-16 16:22:56 +00:00
|
|
|
static gboolean gst_output_selector_query (GstPad * pad, GstObject * parent,
|
|
|
|
GstQuery * query);
|
2011-01-04 15:42:50 +00:00
|
|
|
static void gst_output_selector_switch_pad_negotiation_mode (GstOutputSelector *
|
|
|
|
sel, gint mode);
|
2008-01-29 07:38:31 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
gst_output_selector_class_init (GstOutputSelectorClass * klass)
|
|
|
|
{
|
|
|
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
|
|
|
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
|
|
|
|
|
plugins/elements/gstinputselector.*: Various cleanups.
Original commit message from CVS:
* plugins/elements/gstinputselector.c: (gst_selector_pad_class_init),
(gst_selector_pad_finalize), (gst_selector_pad_get_property),
(gst_selector_pad_event), (gst_input_selector_class_init),
(gst_input_selector_init), (gst_input_selector_set_active_pad),
(gst_input_selector_set_property),
(gst_input_selector_get_property),
(gst_input_selector_request_new_pad),
(gst_input_selector_release_pad),
(gst_input_selector_push_pending_stop),
(gst_input_selector_switch):
* plugins/elements/gstinputselector.h:
Various cleanups.
Added tags to the pads.
Select active pad based on the pad object instead of its name.
Fix refcount in set_active_pad.
Add property to get the number of pads.
* plugins/elements/gstoutputselector.c:
(gst_output_selector_class_init),
(gst_output_selector_set_property),
(gst_output_selector_get_property):
Various cleanups.
Select the active pad based on the pad object instead of its name.
Fix locking when setting the active pad.
* plugins/elements/gstselector-marshal.list:
* tests/check/elements/selector.c: (cleanup_pad),
(selector_set_active_pad), (run_input_selector_buffer_count):
Fixes for pad instead of padname for pad selection.
2008-03-13 16:46:04 +00:00
|
|
|
gobject_class->dispose = gst_output_selector_dispose;
|
|
|
|
|
2010-12-31 00:43:37 +00:00
|
|
|
gobject_class->set_property = gst_output_selector_set_property;
|
|
|
|
gobject_class->get_property = gst_output_selector_get_property;
|
plugins/elements/gstinputselector.*: Various cleanups.
Original commit message from CVS:
* plugins/elements/gstinputselector.c: (gst_selector_pad_class_init),
(gst_selector_pad_finalize), (gst_selector_pad_get_property),
(gst_selector_pad_event), (gst_input_selector_class_init),
(gst_input_selector_init), (gst_input_selector_set_active_pad),
(gst_input_selector_set_property),
(gst_input_selector_get_property),
(gst_input_selector_request_new_pad),
(gst_input_selector_release_pad),
(gst_input_selector_push_pending_stop),
(gst_input_selector_switch):
* plugins/elements/gstinputselector.h:
Various cleanups.
Added tags to the pads.
Select active pad based on the pad object instead of its name.
Fix refcount in set_active_pad.
Add property to get the number of pads.
* plugins/elements/gstoutputselector.c:
(gst_output_selector_class_init),
(gst_output_selector_set_property),
(gst_output_selector_get_property):
Various cleanups.
Select the active pad based on the pad object instead of its name.
Fix locking when setting the active pad.
* plugins/elements/gstselector-marshal.list:
* tests/check/elements/selector.c: (cleanup_pad),
(selector_set_active_pad), (run_input_selector_buffer_count):
Fixes for pad instead of padname for pad selection.
2008-03-13 16:46:04 +00:00
|
|
|
|
2008-01-29 07:38:31 +00:00
|
|
|
g_object_class_install_property (gobject_class, PROP_ACTIVE_PAD,
|
plugins/elements/gstinputselector.*: Various cleanups.
Original commit message from CVS:
* plugins/elements/gstinputselector.c: (gst_selector_pad_class_init),
(gst_selector_pad_finalize), (gst_selector_pad_get_property),
(gst_selector_pad_event), (gst_input_selector_class_init),
(gst_input_selector_init), (gst_input_selector_set_active_pad),
(gst_input_selector_set_property),
(gst_input_selector_get_property),
(gst_input_selector_request_new_pad),
(gst_input_selector_release_pad),
(gst_input_selector_push_pending_stop),
(gst_input_selector_switch):
* plugins/elements/gstinputselector.h:
Various cleanups.
Added tags to the pads.
Select active pad based on the pad object instead of its name.
Fix refcount in set_active_pad.
Add property to get the number of pads.
* plugins/elements/gstoutputselector.c:
(gst_output_selector_class_init),
(gst_output_selector_set_property),
(gst_output_selector_get_property):
Various cleanups.
Select the active pad based on the pad object instead of its name.
Fix locking when setting the active pad.
* plugins/elements/gstselector-marshal.list:
* tests/check/elements/selector.c: (cleanup_pad),
(selector_set_active_pad), (run_input_selector_buffer_count):
Fixes for pad instead of padname for pad selection.
2008-03-13 16:46:04 +00:00
|
|
|
g_param_spec_object ("active-pad", "Active pad",
|
2010-10-19 10:43:14 +00:00
|
|
|
"Currently active src pad", GST_TYPE_PAD,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
2008-01-29 07:38:31 +00:00
|
|
|
g_object_class_install_property (gobject_class, PROP_RESEND_LATEST,
|
|
|
|
g_param_spec_boolean ("resend-latest", "Resend latest buffer",
|
|
|
|
"Resend latest buffer after a switch to a new pad", FALSE,
|
2010-10-19 10:43:14 +00:00
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
2011-01-04 15:42:50 +00:00
|
|
|
g_object_class_install_property (gobject_class, PROP_PAD_NEGOTIATION_MODE,
|
|
|
|
g_param_spec_enum ("pad-negotiation-mode", "Pad negotiation mode",
|
|
|
|
"The mode to be used for pad negotiation",
|
|
|
|
GST_TYPE_OUTPUT_SELECTOR_PAD_NEGOTIATION_MODE,
|
|
|
|
DEFAULT_PAD_NEGOTIATION_MODE,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
plugins/elements/gstinputselector.*: Various cleanups.
Original commit message from CVS:
* plugins/elements/gstinputselector.c: (gst_selector_pad_class_init),
(gst_selector_pad_finalize), (gst_selector_pad_get_property),
(gst_selector_pad_event), (gst_input_selector_class_init),
(gst_input_selector_init), (gst_input_selector_set_active_pad),
(gst_input_selector_set_property),
(gst_input_selector_get_property),
(gst_input_selector_request_new_pad),
(gst_input_selector_release_pad),
(gst_input_selector_push_pending_stop),
(gst_input_selector_switch):
* plugins/elements/gstinputselector.h:
Various cleanups.
Added tags to the pads.
Select active pad based on the pad object instead of its name.
Fix refcount in set_active_pad.
Add property to get the number of pads.
* plugins/elements/gstoutputselector.c:
(gst_output_selector_class_init),
(gst_output_selector_set_property),
(gst_output_selector_get_property):
Various cleanups.
Select the active pad based on the pad object instead of its name.
Fix locking when setting the active pad.
* plugins/elements/gstselector-marshal.list:
* tests/check/elements/selector.c: (cleanup_pad),
(selector_set_active_pad), (run_input_selector_buffer_count):
Fixes for pad instead of padname for pad selection.
2008-03-13 16:46:04 +00:00
|
|
|
|
2012-04-09 12:05:07 +00:00
|
|
|
gst_element_class_set_static_metadata (gstelement_class, "Output selector",
|
2011-04-18 16:07:06 +00:00
|
|
|
"Generic", "1-to-N output stream selector",
|
|
|
|
"Stefan Kost <stefan.kost@nokia.com>");
|
|
|
|
gst_element_class_add_pad_template (gstelement_class,
|
|
|
|
gst_static_pad_template_get (&gst_output_selector_sink_factory));
|
|
|
|
gst_element_class_add_pad_template (gstelement_class,
|
|
|
|
gst_static_pad_template_get (&gst_output_selector_src_factory));
|
|
|
|
|
2008-01-29 07:38:31 +00:00
|
|
|
gstelement_class->request_new_pad =
|
|
|
|
GST_DEBUG_FUNCPTR (gst_output_selector_request_new_pad);
|
|
|
|
gstelement_class->release_pad =
|
|
|
|
GST_DEBUG_FUNCPTR (gst_output_selector_release_pad);
|
|
|
|
|
plugins/elements/gstinputselector.*: Various cleanups.
Original commit message from CVS:
* plugins/elements/gstinputselector.c: (gst_selector_pad_class_init),
(gst_selector_pad_finalize), (gst_selector_pad_get_property),
(gst_selector_pad_event), (gst_input_selector_class_init),
(gst_input_selector_init), (gst_input_selector_set_active_pad),
(gst_input_selector_set_property),
(gst_input_selector_get_property),
(gst_input_selector_request_new_pad),
(gst_input_selector_release_pad),
(gst_input_selector_push_pending_stop),
(gst_input_selector_switch):
* plugins/elements/gstinputselector.h:
Various cleanups.
Added tags to the pads.
Select active pad based on the pad object instead of its name.
Fix refcount in set_active_pad.
Add property to get the number of pads.
* plugins/elements/gstoutputselector.c:
(gst_output_selector_class_init),
(gst_output_selector_set_property),
(gst_output_selector_get_property):
Various cleanups.
Select the active pad based on the pad object instead of its name.
Fix locking when setting the active pad.
* plugins/elements/gstselector-marshal.list:
* tests/check/elements/selector.c: (cleanup_pad),
(selector_set_active_pad), (run_input_selector_buffer_count):
Fixes for pad instead of padname for pad selection.
2008-03-13 16:46:04 +00:00
|
|
|
gstelement_class->change_state = gst_output_selector_change_state;
|
2008-01-29 07:38:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-04-18 16:07:06 +00:00
|
|
|
gst_output_selector_init (GstOutputSelector * sel)
|
2008-01-29 07:38:31 +00:00
|
|
|
{
|
|
|
|
sel->sinkpad =
|
|
|
|
gst_pad_new_from_static_template (&gst_output_selector_sink_factory,
|
|
|
|
"sink");
|
|
|
|
gst_pad_set_chain_function (sel->sinkpad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_output_selector_chain));
|
|
|
|
gst_pad_set_event_function (sel->sinkpad,
|
2011-11-15 10:20:48 +00:00
|
|
|
GST_DEBUG_FUNCPTR (gst_output_selector_event));
|
|
|
|
gst_pad_set_query_function (sel->sinkpad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_output_selector_query));
|
2009-05-28 07:12:58 +00:00
|
|
|
|
|
|
|
gst_element_add_pad (GST_ELEMENT (sel), sel->sinkpad);
|
|
|
|
|
2008-01-29 07:38:31 +00:00
|
|
|
/* srcpad management */
|
|
|
|
sel->active_srcpad = NULL;
|
|
|
|
sel->nb_srcpads = 0;
|
2011-12-07 10:01:31 +00:00
|
|
|
gst_segment_init (&sel->segment, GST_FORMAT_UNDEFINED);
|
2008-01-29 07:38:31 +00:00
|
|
|
sel->pending_srcpad = NULL;
|
|
|
|
|
|
|
|
sel->resend_latest = FALSE;
|
|
|
|
sel->latest_buffer = NULL;
|
2011-01-04 15:42:50 +00:00
|
|
|
gst_output_selector_switch_pad_negotiation_mode (sel,
|
|
|
|
DEFAULT_PAD_NEGOTIATION_MODE);
|
2008-01-29 07:38:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-03-27 10:20:02 +00:00
|
|
|
gst_output_selector_reset (GstOutputSelector * osel)
|
2008-01-29 07:38:31 +00:00
|
|
|
{
|
|
|
|
if (osel->pending_srcpad != NULL) {
|
|
|
|
gst_object_unref (osel->pending_srcpad);
|
|
|
|
osel->pending_srcpad = NULL;
|
|
|
|
}
|
|
|
|
if (osel->latest_buffer != NULL) {
|
|
|
|
gst_buffer_unref (osel->latest_buffer);
|
|
|
|
osel->latest_buffer = NULL;
|
|
|
|
}
|
2009-03-27 10:20:02 +00:00
|
|
|
gst_segment_init (&osel->segment, GST_FORMAT_UNDEFINED);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_output_selector_dispose (GObject * object)
|
|
|
|
{
|
|
|
|
GstOutputSelector *osel = GST_OUTPUT_SELECTOR (object);
|
|
|
|
|
|
|
|
gst_output_selector_reset (osel);
|
2008-01-29 07:38:31 +00:00
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_output_selector_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
|
|
|
GstOutputSelector *sel = GST_OUTPUT_SELECTOR (object);
|
|
|
|
|
|
|
|
switch (prop_id) {
|
plugins/elements/gstinputselector.*: Various cleanups.
Original commit message from CVS:
* plugins/elements/gstinputselector.c: (gst_selector_pad_class_init),
(gst_selector_pad_finalize), (gst_selector_pad_get_property),
(gst_selector_pad_event), (gst_input_selector_class_init),
(gst_input_selector_init), (gst_input_selector_set_active_pad),
(gst_input_selector_set_property),
(gst_input_selector_get_property),
(gst_input_selector_request_new_pad),
(gst_input_selector_release_pad),
(gst_input_selector_push_pending_stop),
(gst_input_selector_switch):
* plugins/elements/gstinputselector.h:
Various cleanups.
Added tags to the pads.
Select active pad based on the pad object instead of its name.
Fix refcount in set_active_pad.
Add property to get the number of pads.
* plugins/elements/gstoutputselector.c:
(gst_output_selector_class_init),
(gst_output_selector_set_property),
(gst_output_selector_get_property):
Various cleanups.
Select the active pad based on the pad object instead of its name.
Fix locking when setting the active pad.
* plugins/elements/gstselector-marshal.list:
* tests/check/elements/selector.c: (cleanup_pad),
(selector_set_active_pad), (run_input_selector_buffer_count):
Fixes for pad instead of padname for pad selection.
2008-03-13 16:46:04 +00:00
|
|
|
case PROP_ACTIVE_PAD:
|
|
|
|
{
|
|
|
|
GstPad *next_pad;
|
|
|
|
|
|
|
|
next_pad = g_value_get_object (value);
|
|
|
|
|
2009-06-12 07:14:27 +00:00
|
|
|
GST_INFO_OBJECT (sel, "Activating pad %s:%s",
|
2008-06-19 13:18:24 +00:00
|
|
|
GST_DEBUG_PAD_NAME (next_pad));
|
plugins/elements/gstinputselector.*: Various cleanups.
Original commit message from CVS:
* plugins/elements/gstinputselector.c: (gst_selector_pad_class_init),
(gst_selector_pad_finalize), (gst_selector_pad_get_property),
(gst_selector_pad_event), (gst_input_selector_class_init),
(gst_input_selector_init), (gst_input_selector_set_active_pad),
(gst_input_selector_set_property),
(gst_input_selector_get_property),
(gst_input_selector_request_new_pad),
(gst_input_selector_release_pad),
(gst_input_selector_push_pending_stop),
(gst_input_selector_switch):
* plugins/elements/gstinputselector.h:
Various cleanups.
Added tags to the pads.
Select active pad based on the pad object instead of its name.
Fix refcount in set_active_pad.
Add property to get the number of pads.
* plugins/elements/gstoutputselector.c:
(gst_output_selector_class_init),
(gst_output_selector_set_property),
(gst_output_selector_get_property):
Various cleanups.
Select the active pad based on the pad object instead of its name.
Fix locking when setting the active pad.
* plugins/elements/gstselector-marshal.list:
* tests/check/elements/selector.c: (cleanup_pad),
(selector_set_active_pad), (run_input_selector_buffer_count):
Fixes for pad instead of padname for pad selection.
2008-03-13 16:46:04 +00:00
|
|
|
|
|
|
|
GST_OBJECT_LOCK (object);
|
2008-02-07 13:48:20 +00:00
|
|
|
if (next_pad != sel->active_srcpad) {
|
2008-01-29 07:38:31 +00:00
|
|
|
/* switch to new srcpad in next chain run */
|
|
|
|
if (sel->pending_srcpad != NULL) {
|
|
|
|
GST_INFO ("replacing pending switch");
|
|
|
|
gst_object_unref (sel->pending_srcpad);
|
|
|
|
}
|
plugins/elements/gstinputselector.*: Various cleanups.
Original commit message from CVS:
* plugins/elements/gstinputselector.c: (gst_selector_pad_class_init),
(gst_selector_pad_finalize), (gst_selector_pad_get_property),
(gst_selector_pad_event), (gst_input_selector_class_init),
(gst_input_selector_init), (gst_input_selector_set_active_pad),
(gst_input_selector_set_property),
(gst_input_selector_get_property),
(gst_input_selector_request_new_pad),
(gst_input_selector_release_pad),
(gst_input_selector_push_pending_stop),
(gst_input_selector_switch):
* plugins/elements/gstinputselector.h:
Various cleanups.
Added tags to the pads.
Select active pad based on the pad object instead of its name.
Fix refcount in set_active_pad.
Add property to get the number of pads.
* plugins/elements/gstoutputselector.c:
(gst_output_selector_class_init),
(gst_output_selector_set_property),
(gst_output_selector_get_property):
Various cleanups.
Select the active pad based on the pad object instead of its name.
Fix locking when setting the active pad.
* plugins/elements/gstselector-marshal.list:
* tests/check/elements/selector.c: (cleanup_pad),
(selector_set_active_pad), (run_input_selector_buffer_count):
Fixes for pad instead of padname for pad selection.
2008-03-13 16:46:04 +00:00
|
|
|
if (next_pad)
|
|
|
|
gst_object_ref (next_pad);
|
2008-01-29 07:38:31 +00:00
|
|
|
sel->pending_srcpad = next_pad;
|
|
|
|
} else {
|
2008-02-07 13:48:20 +00:00
|
|
|
GST_INFO ("pad already active");
|
2008-02-26 12:01:37 +00:00
|
|
|
if (sel->pending_srcpad != NULL) {
|
|
|
|
gst_object_unref (sel->pending_srcpad);
|
|
|
|
sel->pending_srcpad = NULL;
|
|
|
|
}
|
2008-01-29 07:38:31 +00:00
|
|
|
}
|
plugins/elements/gstinputselector.*: Various cleanups.
Original commit message from CVS:
* plugins/elements/gstinputselector.c: (gst_selector_pad_class_init),
(gst_selector_pad_finalize), (gst_selector_pad_get_property),
(gst_selector_pad_event), (gst_input_selector_class_init),
(gst_input_selector_init), (gst_input_selector_set_active_pad),
(gst_input_selector_set_property),
(gst_input_selector_get_property),
(gst_input_selector_request_new_pad),
(gst_input_selector_release_pad),
(gst_input_selector_push_pending_stop),
(gst_input_selector_switch):
* plugins/elements/gstinputselector.h:
Various cleanups.
Added tags to the pads.
Select active pad based on the pad object instead of its name.
Fix refcount in set_active_pad.
Add property to get the number of pads.
* plugins/elements/gstoutputselector.c:
(gst_output_selector_class_init),
(gst_output_selector_set_property),
(gst_output_selector_get_property):
Various cleanups.
Select the active pad based on the pad object instead of its name.
Fix locking when setting the active pad.
* plugins/elements/gstselector-marshal.list:
* tests/check/elements/selector.c: (cleanup_pad),
(selector_set_active_pad), (run_input_selector_buffer_count):
Fixes for pad instead of padname for pad selection.
2008-03-13 16:46:04 +00:00
|
|
|
GST_OBJECT_UNLOCK (object);
|
2008-01-29 07:38:31 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PROP_RESEND_LATEST:{
|
|
|
|
sel->resend_latest = g_value_get_boolean (value);
|
|
|
|
break;
|
|
|
|
}
|
2011-01-04 15:42:50 +00:00
|
|
|
case PROP_PAD_NEGOTIATION_MODE:{
|
|
|
|
gst_output_selector_switch_pad_negotiation_mode (sel,
|
|
|
|
g_value_get_enum (value));
|
|
|
|
break;
|
|
|
|
}
|
2008-01-29 07:38:31 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_output_selector_get_property (GObject * object, guint prop_id,
|
|
|
|
GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
|
|
|
GstOutputSelector *sel = GST_OUTPUT_SELECTOR (object);
|
|
|
|
|
|
|
|
switch (prop_id) {
|
plugins/elements/gstinputselector.*: Various cleanups.
Original commit message from CVS:
* plugins/elements/gstinputselector.c: (gst_selector_pad_class_init),
(gst_selector_pad_finalize), (gst_selector_pad_get_property),
(gst_selector_pad_event), (gst_input_selector_class_init),
(gst_input_selector_init), (gst_input_selector_set_active_pad),
(gst_input_selector_set_property),
(gst_input_selector_get_property),
(gst_input_selector_request_new_pad),
(gst_input_selector_release_pad),
(gst_input_selector_push_pending_stop),
(gst_input_selector_switch):
* plugins/elements/gstinputselector.h:
Various cleanups.
Added tags to the pads.
Select active pad based on the pad object instead of its name.
Fix refcount in set_active_pad.
Add property to get the number of pads.
* plugins/elements/gstoutputselector.c:
(gst_output_selector_class_init),
(gst_output_selector_set_property),
(gst_output_selector_get_property):
Various cleanups.
Select the active pad based on the pad object instead of its name.
Fix locking when setting the active pad.
* plugins/elements/gstselector-marshal.list:
* tests/check/elements/selector.c: (cleanup_pad),
(selector_set_active_pad), (run_input_selector_buffer_count):
Fixes for pad instead of padname for pad selection.
2008-03-13 16:46:04 +00:00
|
|
|
case PROP_ACTIVE_PAD:
|
2008-01-29 07:38:31 +00:00
|
|
|
GST_OBJECT_LOCK (object);
|
2009-07-31 08:27:03 +00:00
|
|
|
g_value_set_object (value,
|
|
|
|
sel->pending_srcpad ? sel->pending_srcpad : sel->active_srcpad);
|
2008-01-29 07:38:31 +00:00
|
|
|
GST_OBJECT_UNLOCK (object);
|
|
|
|
break;
|
|
|
|
case PROP_RESEND_LATEST:{
|
|
|
|
GST_OBJECT_LOCK (object);
|
|
|
|
g_value_set_boolean (value, sel->resend_latest);
|
|
|
|
GST_OBJECT_UNLOCK (object);
|
|
|
|
break;
|
|
|
|
}
|
2011-01-04 15:42:50 +00:00
|
|
|
case PROP_PAD_NEGOTIATION_MODE:
|
|
|
|
g_value_set_enum (value, sel->pad_negotiation_mode);
|
|
|
|
break;
|
2008-01-29 07:38:31 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-15 10:20:48 +00:00
|
|
|
static GstPad *
|
|
|
|
gst_output_selector_get_active (GstOutputSelector * sel)
|
2011-01-04 15:42:50 +00:00
|
|
|
{
|
2011-01-10 17:19:17 +00:00
|
|
|
GstPad *active = NULL;
|
2011-01-06 17:11:31 +00:00
|
|
|
|
2011-01-04 15:42:50 +00:00
|
|
|
GST_OBJECT_LOCK (sel);
|
|
|
|
if (sel->pending_srcpad)
|
|
|
|
active = gst_object_ref (sel->pending_srcpad);
|
2011-01-10 17:19:17 +00:00
|
|
|
else if (sel->active_srcpad)
|
2011-01-04 15:42:50 +00:00
|
|
|
active = gst_object_ref (sel->active_srcpad);
|
|
|
|
GST_OBJECT_UNLOCK (sel);
|
|
|
|
|
2011-11-15 10:20:48 +00:00
|
|
|
return active;
|
2011-01-04 15:42:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_output_selector_switch_pad_negotiation_mode (GstOutputSelector * sel,
|
|
|
|
gint mode)
|
|
|
|
{
|
|
|
|
sel->pad_negotiation_mode = mode;
|
|
|
|
}
|
|
|
|
|
2011-11-23 16:50:17 +00:00
|
|
|
static gboolean
|
|
|
|
forward_sticky_events (GstPad * pad, GstEvent ** event, gpointer user_data)
|
2011-05-24 14:14:57 +00:00
|
|
|
{
|
|
|
|
GstPad *srcpad = GST_PAD_CAST (user_data);
|
|
|
|
|
2011-11-23 16:50:17 +00:00
|
|
|
gst_pad_push_event (srcpad, gst_event_ref (*event));
|
2011-05-24 14:14:57 +00:00
|
|
|
|
2011-11-23 16:50:17 +00:00
|
|
|
return TRUE;
|
2011-05-24 14:14:57 +00:00
|
|
|
}
|
|
|
|
|
2008-01-29 07:38:31 +00:00
|
|
|
static GstPad *
|
|
|
|
gst_output_selector_request_new_pad (GstElement * element,
|
2011-05-10 14:41:36 +00:00
|
|
|
GstPadTemplate * templ, const gchar * name, const GstCaps * caps)
|
2008-01-29 07:38:31 +00:00
|
|
|
{
|
|
|
|
gchar *padname;
|
|
|
|
GstPad *srcpad;
|
|
|
|
GstOutputSelector *osel;
|
|
|
|
|
|
|
|
osel = GST_OUTPUT_SELECTOR (element);
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (osel, "requesting pad");
|
|
|
|
|
|
|
|
GST_OBJECT_LOCK (osel);
|
2011-11-03 16:49:45 +00:00
|
|
|
padname = g_strdup_printf ("src_%u", osel->nb_srcpads++);
|
2008-01-29 07:38:31 +00:00
|
|
|
srcpad = gst_pad_new_from_template (templ, padname);
|
|
|
|
GST_OBJECT_UNLOCK (osel);
|
|
|
|
|
|
|
|
gst_pad_set_active (srcpad, TRUE);
|
2011-05-24 14:14:57 +00:00
|
|
|
|
|
|
|
/* Forward sticky events to the new srcpad */
|
|
|
|
gst_pad_sticky_events_foreach (osel->sinkpad, forward_sticky_events, srcpad);
|
|
|
|
|
2008-01-29 07:38:31 +00:00
|
|
|
gst_element_add_pad (GST_ELEMENT (osel), srcpad);
|
|
|
|
|
|
|
|
/* Set the first requested src pad as active by default */
|
|
|
|
if (osel->active_srcpad == NULL) {
|
|
|
|
osel->active_srcpad = srcpad;
|
|
|
|
}
|
|
|
|
g_free (padname);
|
|
|
|
|
|
|
|
return srcpad;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_output_selector_release_pad (GstElement * element, GstPad * pad)
|
|
|
|
{
|
|
|
|
GstOutputSelector *osel;
|
|
|
|
|
|
|
|
osel = GST_OUTPUT_SELECTOR (element);
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (osel, "releasing pad");
|
|
|
|
|
|
|
|
gst_pad_set_active (pad, FALSE);
|
|
|
|
|
|
|
|
gst_element_remove_pad (GST_ELEMENT_CAST (osel), pad);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_output_selector_switch (GstOutputSelector * osel)
|
|
|
|
{
|
2009-06-01 13:31:42 +00:00
|
|
|
gboolean res = FALSE;
|
2008-01-29 07:38:31 +00:00
|
|
|
GstEvent *ev = NULL;
|
|
|
|
GstSegment *seg = NULL;
|
|
|
|
gint64 start = 0, position = 0;
|
|
|
|
|
2009-06-01 13:31:42 +00:00
|
|
|
/* Switch */
|
|
|
|
GST_OBJECT_LOCK (GST_OBJECT (osel));
|
2011-12-29 19:56:46 +00:00
|
|
|
GST_INFO_OBJECT (osel, "switching to pad %" GST_PTR_FORMAT,
|
|
|
|
osel->pending_srcpad);
|
2008-01-29 07:38:31 +00:00
|
|
|
if (gst_pad_is_linked (osel->pending_srcpad)) {
|
2009-06-01 13:31:42 +00:00
|
|
|
osel->active_srcpad = osel->pending_srcpad;
|
|
|
|
res = TRUE;
|
|
|
|
}
|
|
|
|
gst_object_unref (osel->pending_srcpad);
|
|
|
|
osel->pending_srcpad = NULL;
|
|
|
|
GST_OBJECT_UNLOCK (GST_OBJECT (osel));
|
|
|
|
|
2011-12-08 00:39:10 +00:00
|
|
|
/* Send SEGMENT event and latest buffer if switching succeeded
|
2011-12-07 10:01:31 +00:00
|
|
|
* and we already have a valid segment configured */
|
2011-12-29 19:56:46 +00:00
|
|
|
if (res) {
|
|
|
|
if (osel->segment.format != GST_FORMAT_UNDEFINED) {
|
2012-01-02 02:21:40 +00:00
|
|
|
/* Send SEGMENT to the pad we are going to switch to */
|
2011-12-29 19:56:46 +00:00
|
|
|
seg = &osel->segment;
|
2012-01-02 02:21:40 +00:00
|
|
|
/* If resending then mark segment start and position accordingly */
|
2011-12-29 19:56:46 +00:00
|
|
|
if (osel->resend_latest && osel->latest_buffer &&
|
|
|
|
GST_BUFFER_TIMESTAMP_IS_VALID (osel->latest_buffer)) {
|
|
|
|
start = position = GST_BUFFER_TIMESTAMP (osel->latest_buffer);
|
|
|
|
} else {
|
2012-01-02 02:21:40 +00:00
|
|
|
start = position = seg->position;
|
2011-12-29 19:56:46 +00:00
|
|
|
}
|
2011-05-13 16:07:24 +00:00
|
|
|
|
2012-01-02 02:21:40 +00:00
|
|
|
seg->start = start;
|
|
|
|
seg->position = position;
|
|
|
|
ev = gst_event_new_segment (seg);
|
2011-05-13 16:07:24 +00:00
|
|
|
|
2011-12-29 19:56:46 +00:00
|
|
|
if (!gst_pad_push_event (osel->active_srcpad, ev)) {
|
|
|
|
GST_WARNING_OBJECT (osel,
|
|
|
|
"newsegment handling failed in %" GST_PTR_FORMAT,
|
|
|
|
osel->active_srcpad);
|
|
|
|
}
|
2008-01-29 07:38:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Resend latest buffer to newly switched pad */
|
|
|
|
if (osel->resend_latest && osel->latest_buffer) {
|
|
|
|
GST_INFO ("resending latest buffer");
|
2010-09-17 12:52:12 +00:00
|
|
|
gst_pad_push (osel->active_srcpad, gst_buffer_ref (osel->latest_buffer));
|
2008-01-29 07:38:31 +00:00
|
|
|
}
|
|
|
|
} else {
|
2008-06-19 13:18:24 +00:00
|
|
|
GST_WARNING_OBJECT (osel, "switch failed, pad not linked");
|
2008-01-29 07:38:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstFlowReturn
|
2011-11-17 11:40:45 +00:00
|
|
|
gst_output_selector_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
|
2008-01-29 07:38:31 +00:00
|
|
|
{
|
|
|
|
GstFlowReturn res;
|
|
|
|
GstOutputSelector *osel;
|
2011-05-13 16:07:24 +00:00
|
|
|
GstClockTime position, duration;
|
2008-01-29 07:38:31 +00:00
|
|
|
|
2011-11-17 11:40:45 +00:00
|
|
|
osel = GST_OUTPUT_SELECTOR (parent);
|
2008-01-29 07:38:31 +00:00
|
|
|
|
2010-09-17 12:44:02 +00:00
|
|
|
/*
|
|
|
|
* The _switch function might push a buffer if 'resend-latest' is true.
|
|
|
|
*
|
|
|
|
* Elements/Applications (e.g. camerabin) might use pad probes to
|
|
|
|
* switch output-selector's active pad. If we simply switch and don't
|
|
|
|
* recheck any pending pad switch the following codepath could end
|
|
|
|
* up pushing a buffer on a non-active pad. This is bad.
|
|
|
|
*
|
|
|
|
* So we always should check the pending_srcpad before going further down
|
|
|
|
* the chain and pushing the new buffer
|
|
|
|
*/
|
|
|
|
while (osel->pending_srcpad) {
|
2008-01-29 07:38:31 +00:00
|
|
|
/* Do the switch */
|
|
|
|
gst_output_selector_switch (osel);
|
|
|
|
}
|
2009-05-04 09:29:54 +00:00
|
|
|
|
|
|
|
if (osel->latest_buffer) {
|
|
|
|
gst_buffer_unref (osel->latest_buffer);
|
|
|
|
osel->latest_buffer = NULL;
|
|
|
|
}
|
2009-06-01 13:31:42 +00:00
|
|
|
|
2009-04-16 14:32:03 +00:00
|
|
|
if (osel->resend_latest) {
|
|
|
|
/* Keep reference to latest buffer to resend it after switch */
|
|
|
|
osel->latest_buffer = gst_buffer_ref (buf);
|
|
|
|
}
|
2008-01-29 07:38:31 +00:00
|
|
|
|
2012-12-14 14:22:27 +00:00
|
|
|
/* Keep track of last stop and use it in SEGMENT start after
|
2008-01-29 07:38:31 +00:00
|
|
|
switching to a new src pad */
|
2011-05-13 16:07:24 +00:00
|
|
|
position = GST_BUFFER_TIMESTAMP (buf);
|
|
|
|
if (GST_CLOCK_TIME_IS_VALID (position)) {
|
2008-01-29 07:38:31 +00:00
|
|
|
duration = GST_BUFFER_DURATION (buf);
|
|
|
|
if (GST_CLOCK_TIME_IS_VALID (duration)) {
|
2011-05-13 16:07:24 +00:00
|
|
|
position += duration;
|
2008-01-29 07:38:31 +00:00
|
|
|
}
|
2008-06-19 13:18:24 +00:00
|
|
|
GST_LOG_OBJECT (osel, "setting last stop %" GST_TIME_FORMAT,
|
2011-05-13 16:07:24 +00:00
|
|
|
GST_TIME_ARGS (position));
|
|
|
|
osel->segment.position = position;
|
2008-01-29 07:38:31 +00:00
|
|
|
}
|
|
|
|
|
2008-06-19 13:18:24 +00:00
|
|
|
GST_LOG_OBJECT (osel, "pushing buffer to %" GST_PTR_FORMAT,
|
|
|
|
osel->active_srcpad);
|
2008-01-29 07:38:31 +00:00
|
|
|
res = gst_pad_push (osel->active_srcpad, buf);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstStateChangeReturn
|
|
|
|
gst_output_selector_change_state (GstElement * element,
|
|
|
|
GstStateChange transition)
|
|
|
|
{
|
2009-03-27 10:20:02 +00:00
|
|
|
GstOutputSelector *sel;
|
|
|
|
GstStateChangeReturn result;
|
|
|
|
|
|
|
|
sel = GST_OUTPUT_SELECTOR (element);
|
|
|
|
|
|
|
|
switch (transition) {
|
|
|
|
case GST_STATE_CHANGE_READY_TO_PAUSED:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
result = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
|
|
|
|
|
|
|
|
switch (transition) {
|
|
|
|
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
|
|
|
gst_output_selector_reset (sel);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
2008-01-29 07:38:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2011-11-17 11:40:45 +00:00
|
|
|
gst_output_selector_event (GstPad * pad, GstObject * parent, GstEvent * event)
|
2008-01-29 07:38:31 +00:00
|
|
|
{
|
|
|
|
gboolean res = TRUE;
|
|
|
|
GstOutputSelector *sel;
|
2011-06-07 08:04:52 +00:00
|
|
|
GstPad *active = NULL;
|
2008-01-29 07:38:31 +00:00
|
|
|
|
2011-11-17 11:40:45 +00:00
|
|
|
sel = GST_OUTPUT_SELECTOR (parent);
|
2008-01-29 07:38:31 +00:00
|
|
|
|
|
|
|
switch (GST_EVENT_TYPE (event)) {
|
2011-06-07 08:04:52 +00:00
|
|
|
case GST_EVENT_CAPS:
|
|
|
|
{
|
|
|
|
switch (sel->pad_negotiation_mode) {
|
|
|
|
case GST_OUTPUT_SELECTOR_PAD_NEGOTIATION_MODE_ALL:
|
|
|
|
/* Send caps to all src pads */
|
2011-11-17 11:40:45 +00:00
|
|
|
res = gst_pad_event_default (pad, parent, event);
|
2011-06-07 08:04:52 +00:00
|
|
|
break;
|
|
|
|
case GST_OUTPUT_SELECTOR_PAD_NEGOTIATION_MODE_NONE:
|
2011-06-07 08:51:23 +00:00
|
|
|
gst_event_unref (event);
|
2011-06-07 08:04:52 +00:00
|
|
|
break;
|
|
|
|
default:
|
2011-11-15 10:20:48 +00:00
|
|
|
active = gst_output_selector_get_active (sel);
|
2011-06-07 08:04:52 +00:00
|
|
|
if (active) {
|
2011-06-07 08:51:23 +00:00
|
|
|
res = gst_pad_push_event (active, event);
|
2011-06-07 08:04:52 +00:00
|
|
|
gst_object_unref (active);
|
2011-06-07 08:51:23 +00:00
|
|
|
} else {
|
|
|
|
gst_event_unref (event);
|
2011-06-07 08:04:52 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2011-05-13 16:07:24 +00:00
|
|
|
case GST_EVENT_SEGMENT:
|
2008-01-29 07:38:31 +00:00
|
|
|
{
|
2011-05-18 14:56:13 +00:00
|
|
|
gst_event_copy_segment (event, &sel->segment);
|
2008-01-29 07:38:31 +00:00
|
|
|
|
2011-06-07 08:04:52 +00:00
|
|
|
GST_DEBUG_OBJECT (sel, "configured SEGMENT %" GST_SEGMENT_FORMAT,
|
2011-05-13 16:07:24 +00:00
|
|
|
&sel->segment);
|
2008-01-29 07:38:31 +00:00
|
|
|
|
|
|
|
/* Send newsegment to all src pads */
|
2011-11-17 11:40:45 +00:00
|
|
|
res = gst_pad_event_default (pad, parent, event);
|
2008-01-29 07:38:31 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case GST_EVENT_EOS:
|
|
|
|
/* Send eos to all src pads */
|
2011-11-17 11:40:45 +00:00
|
|
|
res = gst_pad_event_default (pad, parent, event);
|
2008-01-29 07:38:31 +00:00
|
|
|
break;
|
|
|
|
default:
|
2011-06-07 08:04:52 +00:00
|
|
|
{
|
2008-10-07 13:14:40 +00:00
|
|
|
/* Send other events to pending or active src pad */
|
2011-11-15 10:20:48 +00:00
|
|
|
active = gst_output_selector_get_active (sel);
|
2011-06-07 08:04:52 +00:00
|
|
|
if (active) {
|
2011-06-07 08:51:23 +00:00
|
|
|
res = gst_pad_push_event (active, event);
|
2011-06-07 08:04:52 +00:00
|
|
|
gst_object_unref (active);
|
2011-06-07 08:51:23 +00:00
|
|
|
} else {
|
|
|
|
gst_event_unref (event);
|
2011-06-07 08:04:52 +00:00
|
|
|
}
|
2008-01-29 07:38:31 +00:00
|
|
|
break;
|
2011-06-07 08:04:52 +00:00
|
|
|
}
|
2008-01-29 07:38:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
2011-11-15 10:20:48 +00:00
|
|
|
|
|
|
|
static gboolean
|
2011-11-16 16:22:56 +00:00
|
|
|
gst_output_selector_query (GstPad * pad, GstObject * parent, GstQuery * query)
|
2011-11-15 10:20:48 +00:00
|
|
|
{
|
|
|
|
gboolean res = TRUE;
|
|
|
|
GstOutputSelector *sel;
|
|
|
|
GstPad *active = NULL;
|
|
|
|
|
2011-11-16 16:22:56 +00:00
|
|
|
sel = GST_OUTPUT_SELECTOR (parent);
|
2011-11-15 10:20:48 +00:00
|
|
|
|
|
|
|
switch (GST_QUERY_TYPE (query)) {
|
|
|
|
case GST_QUERY_CAPS:
|
|
|
|
{
|
|
|
|
switch (sel->pad_negotiation_mode) {
|
|
|
|
case GST_OUTPUT_SELECTOR_PAD_NEGOTIATION_MODE_ALL:
|
|
|
|
/* Send caps to all src pads */
|
|
|
|
res = gst_pad_proxy_query_caps (pad, query);
|
|
|
|
break;
|
|
|
|
case GST_OUTPUT_SELECTOR_PAD_NEGOTIATION_MODE_NONE:
|
|
|
|
res = FALSE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
active = gst_output_selector_get_active (sel);
|
|
|
|
if (active) {
|
|
|
|
res = gst_pad_peer_query (active, query);
|
|
|
|
gst_object_unref (active);
|
|
|
|
} else {
|
|
|
|
res = FALSE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
2011-11-16 16:22:56 +00:00
|
|
|
res = gst_pad_query_default (pad, parent, query);
|
2011-11-15 10:20:48 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|