autoconvert: Small cleanups

This commit is contained in:
Sebastian Dröge 2009-08-09 14:55:26 +02:00
parent 182dad5c66
commit abe33a5526
2 changed files with 24 additions and 39 deletions

View file

@ -46,13 +46,6 @@ GST_DEBUG_CATEGORY (autoconvert_debug);
#define GST_CAT_DEFAULT (autoconvert_debug) #define GST_CAT_DEFAULT (autoconvert_debug)
/* elementfactory information */ /* elementfactory information */
static const GstElementDetails gst_auto_convert_details =
GST_ELEMENT_DETAILS ("Select convertor based on caps",
"Generic/Bin",
"Selects the right transform element based on the caps",
"Olivier Crete <olivier.crete@collabora.co.uk>");
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink", static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK, GST_PAD_SINK,
GST_PAD_ALWAYS, GST_PAD_ALWAYS,
@ -63,7 +56,6 @@ static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_ALWAYS, GST_PAD_ALWAYS,
GST_STATIC_CAPS_ANY); GST_STATIC_CAPS_ANY);
static GstStaticPadTemplate sink_internal_template = static GstStaticPadTemplate sink_internal_template =
GST_STATIC_PAD_TEMPLATE ("sink_internal", GST_STATIC_PAD_TEMPLATE ("sink_internal",
GST_PAD_SINK, GST_PAD_SINK,
@ -86,10 +78,9 @@ enum
enum enum
{ {
PROP_0, PROP_0,
PROP_FACTORIES, PROP_FACTORIES
}; };
static void gst_auto_convert_set_property (GObject * object, static void gst_auto_convert_set_property (GObject * object,
guint prop_id, const GValue * value, GParamSpec * pspec); guint prop_id, const GValue * value, GParamSpec * pspec);
static void gst_auto_convert_get_property (GObject * object, static void gst_auto_convert_get_property (GObject * object,
@ -118,7 +109,6 @@ static gboolean gst_auto_convert_src_event (GstPad * pad, GstEvent * event);
static gboolean gst_auto_convert_src_query (GstPad * pad, GstQuery * query); static gboolean gst_auto_convert_src_query (GstPad * pad, GstQuery * query);
static const GstQueryType *gst_auto_convert_src_query_type (GstPad * pad); static const GstQueryType *gst_auto_convert_src_query_type (GstPad * pad);
static GstFlowReturn gst_auto_convert_internal_sink_chain (GstPad * pad, static GstFlowReturn gst_auto_convert_internal_sink_chain (GstPad * pad,
GstBuffer * buffer); GstBuffer * buffer);
static gboolean gst_auto_convert_internal_sink_event (GstPad * pad, static gboolean gst_auto_convert_internal_sink_event (GstPad * pad,
@ -140,18 +130,21 @@ static gboolean gst_auto_convert_internal_src_query (GstPad * pad,
static const GstQueryType *gst_auto_convert_internal_src_query_type (GstPad * static const GstQueryType *gst_auto_convert_internal_src_query_type (GstPad *
pad); pad);
static void gst_auto_convert_load_factories (GstAutoConvert * autoconvert); static void gst_auto_convert_load_factories (GstAutoConvert * autoconvert);
GQuark internal_srcpad_quark = 0; static GQuark internal_srcpad_quark = 0;
GQuark internal_sinkpad_quark = 0; static GQuark internal_sinkpad_quark = 0;
GQuark parent_quark = 0; static GQuark parent_quark = 0;
static void static void
gst_auto_convert_do_init (GType type) gst_auto_convert_do_init (GType type)
{ {
GST_DEBUG_CATEGORY_INIT (autoconvert_debug, "autoconvert", 0, GST_DEBUG_CATEGORY_INIT (autoconvert_debug, "autoconvert", 0,
"Auto convert based on caps"); "Auto convert based on caps");
internal_srcpad_quark = g_quark_from_static_string ("internal_srcpad");
internal_sinkpad_quark = g_quark_from_static_string ("internal_sinkpad");
parent_quark = g_quark_from_static_string ("parent");
} }
GST_BOILERPLATE_FULL (GstAutoConvert, gst_auto_convert, GstBin, GST_BOILERPLATE_FULL (GstAutoConvert, gst_auto_convert, GstBin,
@ -167,53 +160,39 @@ gst_auto_convert_base_init (gpointer klass)
gst_element_class_add_pad_template (element_class, gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&sinktemplate)); gst_static_pad_template_get (&sinktemplate));
gst_element_class_set_details (element_class, &gst_auto_convert_details); gst_element_class_set_details_simple (element_class,
"Select convertor based on caps", "Generic/Bin",
"Selects the right transform element based on the caps",
"Olivier Crete <olivier.crete@collabora.co.uk>");
} }
static void static void
gst_auto_convert_class_init (GstAutoConvertClass * klass) gst_auto_convert_class_init (GstAutoConvertClass * klass)
{ {
GObjectClass *gobject_class; GObjectClass *gobject_class = (GObjectClass *) klass;
GstElementClass *gstelement_class;
GstBinClass *gstbin_class;
gobject_class = (GObjectClass *) klass; gobject_class->dispose = gst_auto_convert_dispose;
gstelement_class = (GstElementClass *) klass;
gstbin_class = (GstBinClass *) klass;
gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_auto_convert_dispose); gobject_class->set_property = gst_auto_convert_set_property;
gobject_class->get_property = gst_auto_convert_get_property;
gobject_class->set_property =
GST_DEBUG_FUNCPTR (gst_auto_convert_set_property);
gobject_class->get_property =
GST_DEBUG_FUNCPTR (gst_auto_convert_get_property);
g_object_class_install_property (gobject_class, PROP_FACTORIES, g_object_class_install_property (gobject_class, PROP_FACTORIES,
g_param_spec_pointer ("factories", g_param_spec_pointer ("factories",
"GList of GstElementFactory", "GList of GstElementFactory",
"GList of GstElementFactory objects to pick from (the element takes" "GList of GstElementFactory objects to pick from (the element takes"
" ownership of the list (NULL means it will go through all possible" " ownership of the list (NULL means it will go through all possible"
" elements), can only be set once", G_PARAM_READWRITE)); " elements), can only be set once",
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
parent_class = g_type_class_peek_parent (klass);
internal_srcpad_quark = g_quark_from_static_string ("internal_srcpad");
internal_sinkpad_quark = g_quark_from_static_string ("internal_sinkpad");
parent_quark = g_quark_from_static_string ("parent");
} }
static void static void
gst_auto_convert_init (GstAutoConvert * autoconvert, gst_auto_convert_init (GstAutoConvert * autoconvert,
GstAutoConvertClass * klass) GstAutoConvertClass * klass)
{ {
autoconvert->sinkpad = autoconvert->sinkpad =
gst_pad_new_from_static_template (&sinktemplate, "sink"); gst_pad_new_from_static_template (&sinktemplate, "sink");
autoconvert->srcpad = gst_pad_new_from_static_template (&srctemplate, "src"); autoconvert->srcpad = gst_pad_new_from_static_template (&srctemplate, "src");
gst_element_add_pad (GST_ELEMENT (autoconvert), autoconvert->sinkpad);
gst_element_add_pad (GST_ELEMENT (autoconvert), autoconvert->srcpad);
gst_pad_set_setcaps_function (autoconvert->sinkpad, gst_pad_set_setcaps_function (autoconvert->sinkpad,
GST_DEBUG_FUNCPTR (gst_auto_convert_sink_setcaps)); GST_DEBUG_FUNCPTR (gst_auto_convert_sink_setcaps));
gst_pad_set_getcaps_function (autoconvert->sinkpad, gst_pad_set_getcaps_function (autoconvert->sinkpad,
@ -235,6 +214,9 @@ gst_auto_convert_init (GstAutoConvert * autoconvert,
GST_DEBUG_FUNCPTR (gst_auto_convert_src_query)); GST_DEBUG_FUNCPTR (gst_auto_convert_src_query));
gst_pad_set_query_type_function (autoconvert->srcpad, gst_pad_set_query_type_function (autoconvert->srcpad,
GST_DEBUG_FUNCPTR (gst_auto_convert_src_query_type)); GST_DEBUG_FUNCPTR (gst_auto_convert_src_query_type));
gst_element_add_pad (GST_ELEMENT (autoconvert), autoconvert->sinkpad);
gst_element_add_pad (GST_ELEMENT (autoconvert), autoconvert->srcpad);
} }
static void static void

View file

@ -52,6 +52,9 @@ struct _GstAutoConvert
GstElement *current_subelement; GstElement *current_subelement;
GstPad *current_internal_srcpad; GstPad *current_internal_srcpad;
GstPad *current_internal_sinkpad; GstPad *current_internal_sinkpad;
GstSegment segment;
GList *cached_events;
}; };
struct _GstAutoConvertClass struct _GstAutoConvertClass