diff options
Diffstat (limited to 'gst')
36 files changed, 756 insertions, 1219 deletions
diff --git a/gst/cdxaparse/gstcdxaparse.c b/gst/cdxaparse/gstcdxaparse.c index 6600fbcb..0cfa010e 100644 --- a/gst/cdxaparse/gstcdxaparse.c +++ b/gst/cdxaparse/gstcdxaparse.c @@ -58,27 +58,23 @@ enum { /* FILL ME */ }; -GST_PAD_TEMPLATE_FACTORY (sink_templ, +static GstStaticPadTemplate sink_templ = +GST_STATIC_PAD_TEMPLATE ( "sink", GST_PAD_SINK, GST_PAD_ALWAYS, - GST_CAPS_NEW ( - "cdxaparse_sink", - "video/x-cdxa", - NULL - ) -) + GST_STATIC_CAPS ( "video/x-cdxa" ) +); -GST_PAD_TEMPLATE_FACTORY (src_templ, +static GstStaticPadTemplate src_templ = +GST_STATIC_PAD_TEMPLATE ( "src", GST_PAD_SRC, GST_PAD_ALWAYS, - GST_CAPS_NEW ( - "cdxaparse_src", - "video/mpeg", - "systemstream", GST_PROPS_BOOLEAN (TRUE) + GST_STATIC_CAPS ( "video/mpeg, " + "systemstream = (boolean) TRUE" ) -) +); static void gst_cdxa_parse_base_init (gpointer g_class); static void gst_cdxa_parse_class_init (GstCDXAParseClass *klass); @@ -120,8 +116,10 @@ gst_cdxa_parse_base_init (gpointer g_class) { GstElementClass *element_class = GST_ELEMENT_CLASS (g_class); - gst_element_class_add_pad_template (element_class, GST_PAD_TEMPLATE_GET (src_templ)); - gst_element_class_add_pad_template (element_class, GST_PAD_TEMPLATE_GET (sink_templ)); + gst_element_class_add_pad_template (element_class, + gst_static_pad_template_get (&src_templ)); + gst_element_class_add_pad_template (element_class, + gst_static_pad_template_get (&sink_templ)); gst_element_class_set_details (element_class, &gst_cdxa_parse_details); } @@ -145,11 +143,11 @@ gst_cdxa_parse_init (GstCDXAParse *cdxa_parse) GST_FLAG_SET (cdxa_parse, GST_ELEMENT_EVENT_AWARE); cdxa_parse->sinkpad = gst_pad_new_from_template ( - GST_PAD_TEMPLATE_GET (sink_templ), "sink"); + gst_static_pad_template_get (&sink_templ), "sink"); gst_element_add_pad (GST_ELEMENT (cdxa_parse), cdxa_parse->sinkpad); cdxa_parse->srcpad = gst_pad_new_from_template ( - GST_PAD_TEMPLATE_GET (src_templ), "src"); + gst_static_pad_template_get (&src_templ), "src"); gst_element_add_pad (GST_ELEMENT (cdxa_parse), cdxa_parse->srcpad); gst_element_set_loop_function (GST_ELEMENT (cdxa_parse), gst_cdxa_parse_loop); diff --git a/gst/chart/gstchart.c b/gst/chart/gstchart.c index ab712834..329b672e 100644 --- a/gst/chart/gstchart.c +++ b/gst/chart/gstchart.c @@ -38,7 +38,6 @@ struct _GstChart { /* pads */ GstPad *sinkpad,*srcpad; - GstBufferPool *peerpool; /* the timestamp of the next frame */ guint64 next_time; @@ -50,7 +49,7 @@ struct _GstChart { gint height; gint samplerate; - gfloat framerate; /* desired frame rate */ + gdouble framerate; /* desired frame rate */ gint samples_between_frames; /* number of samples between start of successive frames */ gint samples_since_last_frame; /* number of samples between start of successive frames */ }; @@ -81,29 +80,26 @@ enum { /* FILL ME */ }; -GST_PAD_TEMPLATE_FACTORY (src_factory, +static GstStaticPadTemplate src_factory = +GST_STATIC_PAD_TEMPLATE ( "src", GST_PAD_SRC, GST_PAD_ALWAYS, - gst_caps_new ("chartsrc", - "video/x-raw-rgb", - GST_VIDEO_RGB_PAD_TEMPLATE_PROPS_16 - ) + GST_STATIC_CAPS ( GST_VIDEO_RGB_PAD_TEMPLATE_CAPS_16) ); -GST_PAD_TEMPLATE_FACTORY (sink_factory, +static GstStaticPadTemplate sink_factory = +GST_STATIC_PAD_TEMPLATE ( "sink", GST_PAD_SINK, GST_PAD_ALWAYS, - GST_CAPS_NEW ("chartsink", - "audio/x-raw-int", - "endianness", GST_PROPS_INT (G_BYTE_ORDER), - "signed", GST_PROPS_BOOLEAN (TRUE), - "width", GST_PROPS_INT (16), - "depth", GST_PROPS_INT (16), - "rate", GST_PROPS_INT_RANGE (8000, 96000), - "channels", GST_PROPS_INT (1) - ) + GST_STATIC_CAPS ("audio/x-raw-int, " + "endianness = (int) BYTE_ORDER, " + "signed = (boolean) TRUE, " + "width = (int) 16, " + "depth = (int) 16, " + "rate = (int) [ 8000, 96000 ], " + "channels = (int) 1") ); static void gst_chart_base_init (gpointer g_class); @@ -116,9 +112,9 @@ static void gst_chart_get_property (GObject *object, guint prop_id, GValue *valu static void gst_chart_chain (GstPad *pad, GstData *_data); static GstPadLinkReturn - gst_chart_sinkconnect (GstPad *pad, GstCaps *caps); + gst_chart_sinkconnect (GstPad *pad, const GstCaps *caps); static GstPadLinkReturn - gst_chart_srcconnect (GstPad *pad, GstCaps *caps); + gst_chart_srcconnect (GstPad *pad, const GstCaps *caps); static GstElementClass *parent_class = NULL; @@ -149,8 +145,8 @@ gst_chart_base_init (gpointer g_class) { GstElementClass *element_class = GST_ELEMENT_CLASS (g_class); - gst_element_class_add_pad_template (element_class, GST_PAD_TEMPLATE_GET (src_factory)); - gst_element_class_add_pad_template (element_class, GST_PAD_TEMPLATE_GET (sink_factory)); + gst_element_class_add_pad_template (element_class, gst_static_pad_template_get (&src_factory)); + gst_element_class_add_pad_template (element_class, gst_static_pad_template_get (&sink_factory)); gst_element_class_set_details (element_class, &gst_chart_details); } @@ -174,10 +170,10 @@ gst_chart_init (GstChart *chart) { /* create the sink and src pads */ chart->sinkpad = gst_pad_new_from_template ( - GST_PAD_TEMPLATE_GET (sink_factory), + gst_static_pad_template_get (&sink_factory), "sink"); chart->srcpad = gst_pad_new_from_template ( - GST_PAD_TEMPLATE_GET (src_factory), + gst_static_pad_template_get (&src_factory), "src"); gst_element_add_pad (GST_ELEMENT (chart), chart->sinkpad); gst_element_add_pad (GST_ELEMENT (chart), chart->srcpad); @@ -187,7 +183,6 @@ gst_chart_init (GstChart *chart) gst_pad_set_link_function (chart->sinkpad, gst_chart_srcconnect); chart->next_time = 0; - chart->peerpool = NULL; /* reset the initial video state */ chart->bpp = 16; @@ -202,12 +197,16 @@ gst_chart_init (GstChart *chart) } static GstPadLinkReturn -gst_chart_sinkconnect (GstPad *pad, GstCaps *caps) +gst_chart_sinkconnect (GstPad *pad, const GstCaps *caps) { GstChart *chart; + GstStructure *structure; + chart = GST_CHART (gst_pad_get_parent (pad)); - gst_caps_get_int (caps, "rate", &chart->samplerate); + structure = gst_caps_get_structure (caps, 0); + + gst_structure_get_int (structure, "rate", &chart->samplerate); chart->samples_between_frames = chart->samplerate / chart->framerate; GST_DEBUG ("CHART: new sink caps: rate %d", @@ -218,50 +217,25 @@ gst_chart_sinkconnect (GstPad *pad, GstCaps *caps) } static GstPadLinkReturn -gst_chart_srcconnect (GstPad *pad, GstCaps *caps) +gst_chart_srcconnect (GstPad *pad, const GstCaps*caps) { GstChart *chart; + GstStructure *structure; + chart = GST_CHART (gst_pad_get_parent (pad)); - if (gst_caps_has_property_typed (caps, "framerate", - GST_PROPS_FLOAT_TYPE)) { - gst_caps_get_float (caps, "framerate", &chart->framerate); + structure = gst_caps_get_structure (caps, 0); + + if (gst_structure_get_double (structure, "framerate", &chart->framerate)) { chart->samples_between_frames = chart->samplerate / chart->framerate; } - if (gst_caps_has_property_typed (caps, "width", - GST_PROPS_INT_TYPE)) { - gst_caps_get_int (caps, "width", &chart->width); - } - if (gst_caps_has_property_typed (caps, "height", - GST_PROPS_INT_TYPE)) { - gst_caps_get_int (caps, "height", &chart->height); - } + gst_structure_get_int (structure, "width", &chart->width); + gst_structure_get_int (structure, "height", &chart->height); GST_DEBUG ("CHART: new src caps: framerate %f, %dx%d", chart->framerate, chart->width, chart->height); - if (!GST_CAPS_IS_FIXED (caps)) { - GstPadLinkReturn ret; - GstCaps *newcaps; - newcaps = GST_CAPS_NEW ("chartsrc", - "video/x-raw-rgb", - "bpp", GST_PROPS_INT (chart->bpp), - "depth", GST_PROPS_INT (chart->depth), - "endianness", GST_PROPS_INT (G_BYTE_ORDER), - "red_mask", GST_PROPS_INT (R_MASK_16), - "green_mask", GST_PROPS_INT (G_MASK_16), - "blue_mask", GST_PROPS_INT (B_MASK_16), - "width", GST_PROPS_INT (chart->width), - "height", GST_PROPS_INT (chart->height), - "framerate", GST_PROPS_FLOAT (chart->framerate)); - ret = gst_pad_try_set_caps (chart->srcpad, newcaps); - if (ret > 0) { - return GST_PAD_LINK_DONE; - } - return ret; - } - return GST_PAD_LINK_OK; } @@ -367,28 +341,6 @@ gst_chart_chain (GstPad *pad, GstData *_data) /* set timestamp */ GST_BUFFER_TIMESTAMP (bufout) = chart->next_time; - /* Check if we need to renegotiate size. */ - if (!GST_PAD_CAPS (chart->srcpad)) { - GstCaps *newcaps; - GST_DEBUG ("making new pad"); - newcaps = GST_CAPS_NEW ("chartsrc", - "video/x-raw-rgb", - "bpp", GST_PROPS_INT (chart->bpp), - "depth", GST_PROPS_INT (chart->depth), - "endianness", GST_PROPS_INT (G_BYTE_ORDER), - "red_mask", GST_PROPS_INT (R_MASK_16), - "green_mask", GST_PROPS_INT (G_MASK_16), - "blue_mask", GST_PROPS_INT (B_MASK_16), - "width", GST_PROPS_INT (chart->width), - "height", GST_PROPS_INT (chart->height), - "framerate", GST_PROPS_FLOAT (chart->framerate)); - if (gst_pad_try_set_caps (chart->srcpad, newcaps) <= 0) { - gst_element_error (GST_ELEMENT (chart), - "chart: could not negotiate format"); - return; - } - } - GST_DEBUG ("CHART: outputting buffer"); /* output buffer */ GST_BUFFER_FLAG_SET (bufout, GST_BUFFER_READONLY); diff --git a/gst/deinterlace/gstdeinterlace.c b/gst/deinterlace/gstdeinterlace.c index d5e1bce3..7b2c3ee3 100644 --- a/gst/deinterlace/gstdeinterlace.c +++ b/gst/deinterlace/gstdeinterlace.c @@ -24,6 +24,7 @@ #endif #include <string.h> #include <gst/gst.h> +#include <gst/video/video.h> #include "gstdeinterlace.h" /* elementfactory information */ @@ -49,33 +50,21 @@ enum { ARG_EDGE_DETECT, }; -GST_PAD_TEMPLATE_FACTORY (deinterlace_src_factory, +static GstStaticPadTemplate deinterlace_src_factory = +GST_STATIC_PAD_TEMPLATE ( "src", GST_PAD_SRC, GST_PAD_ALWAYS, - GST_CAPS_NEW ( - "deinterlace_src", - "video/x-raw-yuv", - "format", GST_PROPS_FOURCC (GST_STR_FOURCC ("I420")), - "width", GST_PROPS_INT_POSITIVE, - "height", GST_PROPS_INT_POSITIVE, - "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT) - ) -) - -GST_PAD_TEMPLATE_FACTORY (deinterlace_sink_factory, + GST_STATIC_CAPS ( GST_VIDEO_YUV_PAD_TEMPLATE_CAPS ("I420")) +); + +static GstStaticPadTemplate deinterlace_sink_factory = +GST_STATIC_PAD_TEMPLATE ( "sink", GST_PAD_SINK, GST_PAD_ALWAYS, - GST_CAPS_NEW ( - "deinterlace_src", - "video/x-raw-yuv", - "format", GST_PROPS_FOURCC (GST_STR_FOURCC ("I420")), - "width", GST_PROPS_INT_POSITIVE, - "height", GST_PROPS_INT_POSITIVE, - "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT) - ) -) + GST_STATIC_CAPS ( GST_VIDEO_YUV_PAD_TEMPLATE_CAPS ("I420")) +); static GType gst_deinterlace_get_type (void); @@ -120,9 +109,9 @@ gst_deinterlace_base_init (gpointer g_class) GstElementClass *element_class = GST_ELEMENT_CLASS (g_class); gst_element_class_add_pad_template (element_class, - GST_PAD_TEMPLATE_GET (deinterlace_src_factory)); + gst_static_pad_template_get (&deinterlace_src_factory)); gst_element_class_add_pad_template (element_class, - GST_PAD_TEMPLATE_GET (deinterlace_sink_factory)); + gst_static_pad_template_get (&deinterlace_sink_factory)); gst_element_class_set_details (element_class, &deinterlace_details); } @@ -156,17 +145,17 @@ gst_deinterlace_class_init (GstDeInterlaceClass *klass) } static GstPadLinkReturn -gst_deinterlace_sinkconnect (GstPad *pad, GstCaps *caps) +gst_deinterlace_sinkconnect (GstPad *pad, const GstCaps *caps) { GstDeInterlace *filter; + GstStructure *structure; filter = GST_DEINTERLACE(gst_pad_get_parent (pad)); - if (!GST_CAPS_IS_FIXED (caps)) - return GST_PAD_LINK_DELAYED; + structure = gst_caps_get_structure (caps, 0); - gst_caps_get_int (caps, "width", &filter->width); - gst_caps_get_int (caps, "height", &filter->height); + gst_structure_get_int (structure, "width", &filter->width); + gst_structure_get_int (structure, "height", &filter->height); if (filter->picsize != (filter->width*filter->height)) { if (filter->src) @@ -174,18 +163,20 @@ gst_deinterlace_sinkconnect (GstPad *pad, GstCaps *caps) filter->picsize = filter->width*filter->height; filter->src = g_malloc(filter->picsize); } - return gst_pad_try_set_caps (filter->srcpad, gst_caps_ref (caps)); + return gst_pad_try_set_caps (filter->srcpad, caps); } static void gst_deinterlace_init (GstDeInterlace *filter) { - filter->sinkpad = gst_pad_new_from_template(deinterlace_sink_factory (),"sink"); + filter->sinkpad = gst_pad_new_from_template( + gst_static_pad_template_get(&deinterlace_sink_factory),"sink"); gst_pad_set_chain_function(filter->sinkpad,gst_deinterlace_chain); gst_pad_set_link_function(filter->sinkpad,gst_deinterlace_sinkconnect); gst_element_add_pad(GST_ELEMENT(filter),filter->sinkpad); - filter->srcpad = gst_pad_new_from_template(deinterlace_src_factory (),"src"); + filter->srcpad = gst_pad_new_from_template( + gst_static_pad_template_get(&deinterlace_src_factory),"src"); gst_element_add_pad(GST_ELEMENT(filter),filter->srcpad); filter->show_deinterlaced_area_only = FALSE; diff --git a/gst/festival/gstfestival.c b/gst/festival/gstfestival.c index 18822e3f..d59a8518 100644 --- a/gst/festival/gstfestival.c +++ b/gst/festival/gstfestival.c @@ -97,27 +97,28 @@ static GstElementDetails gst_festival_details = GST_ELEMENT_DETAILS ( "Wim Taymans <wim.taymans@chello.be>" ); -GST_PAD_TEMPLATE_FACTORY (sink_template_factory, +static GstStaticPadTemplate sink_template_factory = +GST_STATIC_PAD_TEMPLATE ( "festival_sink", GST_PAD_SINK, GST_PAD_ALWAYS, - GST_CAPS_NEW ( - "festival_wav", - "text/plain", - NULL - ) -) + GST_STATIC_CAPS ( "text/plain" ) +); -GST_PAD_TEMPLATE_FACTORY (src_template_factory, +static GstStaticPadTemplate src_template_factory = +GST_STATIC_PAD_TEMPLATE ( "festival_src", GST_PAD_SRC, GST_PAD_ALWAYS, - gst_caps_new ( - "festival_raw", - "audio/x-raw-int", - GST_AUDIO_INT_PAD_TEMPLATE_PROPS + GST_STATIC_CAPS ( "audio/x-raw-int, " + "endianness = (int) BYTE_ORDER, " + "signed = (boolean) TRUE, " + "width = (int) 16, " + "depth = (int) 16, " + "rate = (int) 16000, " + "channels = (int) 1" ) -) +); /* Festival signals and args */ enum { @@ -161,8 +162,10 @@ gst_festival_base_init (gpointer g_class) GstElementClass *element_class = GST_ELEMENT_CLASS (g_class); /* register src pads */ - gst_element_class_add_pad_template (element_class, GST_PAD_TEMPLATE_GET (sink_template_factory)); - gst_element_class_add_pad_template (element_class, GST_PAD_TEMPLATE_GET (src_template_factory)); + gst_element_class_add_pad_template (element_class, + gst_static_pad_template_get (&sink_template_factory)); + gst_element_class_add_pad_template (element_class, + gst_static_pad_template_get (&src_template_factory)); gst_element_class_set_details (element_class, &gst_festival_details); } @@ -183,12 +186,12 @@ static void gst_festival_init (GstFestival *festival) { festival->sinkpad = gst_pad_new_from_template ( - GST_PAD_TEMPLATE_GET (sink_template_factory), "sink"); + gst_static_pad_template_get (&sink_template_factory), "sink"); gst_pad_set_chain_function (festival->sinkpad, gst_festival_chain); gst_element_add_pad (GST_ELEMENT (festival), festival->sinkpad); festival->srcpad = gst_pad_new_from_template ( - GST_PAD_TEMPLATE_GET (src_template_factory), "src"); + gst_static_pad_template_get (&src_template_factory), "src"); gst_element_add_pad (GST_ELEMENT (festival), festival->srcpad); festival->info = festival_default_info(); @@ -254,19 +257,6 @@ gst_festival_chain (GstPad *pad, GstData *_data) GST_BUFFER_DATA (outbuf) = wavefile; GST_BUFFER_SIZE (outbuf) = filesize; - if (!GST_PAD_CAPS (festival->srcpad)) { - gst_pad_try_set_caps (festival->srcpad, - GST_CAPS_NEW ( - "festival_src", - "audio/x-raw-int", - "endianness", GST_PROPS_INT (G_BYTE_ORDER), - "signed", GST_PROPS_BOOLEAN (TRUE), - "width", GST_PROPS_INT (16), - "depth", GST_PROPS_INT (16), - "rate", GST_PROPS_INT (16000), - "channels", GST_PROPS_INT (1) - )); - } gst_pad_push (festival->srcpad, GST_DATA (outbuf)); wavefile = NULL; diff --git a/gst/filter/gstbpwsinc.c b/gst/filter/gstbpwsinc.c index c7144621..77529053 100644 --- a/gst/filter/gstbpwsinc.c +++ b/gst/filter/gstbpwsinc.c @@ -105,7 +105,7 @@ static void gst_bpwsinc_get_property (GObject * object, guint prop_id, static void gst_bpwsinc_chain (GstPad * pad, GstData *_data); static GstPadLinkReturn - gst_bpwsinc_sink_connect (GstPad * pad, GstCaps * caps); + gst_bpwsinc_sink_connect (GstPad * pad, const GstCaps * caps); static GstElementClass *parent_class = NULL; /*static guint gst_bpwsinc_signals[LAST_SIGNAL] = { 0 }; */ @@ -136,8 +136,10 @@ gst_bpwsinc_base_init (gpointer g_class) GstElementClass *element_class = GST_ELEMENT_CLASS (g_class); /* register src pads */ - gst_element_class_add_pad_template (element_class, gst_filter_src_factory ()); - gst_element_class_add_pad_template (element_class, gst_filter_sink_factory ()); + gst_element_class_add_pad_template (element_class, + gst_static_pad_template_get (&gst_filter_src_template)); + gst_element_class_add_pad_template (element_class, + gst_static_pad_template_get (&gst_filter_sink_template)); gst_element_class_set_details (element_class, &gst_bpwsinc_details); } @@ -176,12 +178,14 @@ gst_bpwsinc_class_init (GstBPWSincClass * klass) static void gst_bpwsinc_init (GstBPWSinc * filter) { - filter->sinkpad = gst_pad_new_from_template (gst_filter_sink_factory (), "sink"); + filter->sinkpad = gst_pad_new_from_template ( + gst_static_pad_template_get (&gst_filter_sink_template), "sink"); gst_pad_set_chain_function (filter->sinkpad, gst_bpwsinc_chain); gst_pad_set_link_function (filter->sinkpad, gst_bpwsinc_sink_connect); gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad); - filter->srcpad = gst_pad_new_from_template (gst_filter_src_factory (), "src"); + filter->srcpad = gst_pad_new_from_template ( + gst_static_pad_template_get (&gst_filter_src_template), "src"); gst_element_add_pad (GST_ELEMENT (filter), filter->srcpad); filter->wing_size = 50; @@ -191,7 +195,7 @@ gst_bpwsinc_init (GstBPWSinc * filter) } static GstPadLinkReturn -gst_bpwsinc_sink_connect (GstPad * pad, GstCaps * caps) +gst_bpwsinc_sink_connect (GstPad * pad, const GstCaps * caps) { int i = 0; double sum = 0.0; @@ -204,10 +208,7 @@ gst_bpwsinc_sink_connect (GstPad * pad, GstCaps * caps) g_assert (GST_IS_PAD (pad)); g_assert (caps != NULL); - if (!GST_CAPS_IS_FIXED (caps)) - return GST_PAD_LINK_DELAYED; - - set_retval = gst_pad_try_set_caps (filter->srcpad, gst_caps_ref (caps)); + set_retval = gst_pad_try_set_caps (filter->srcpad, caps); if (set_retval > 0) { diff --git a/gst/filter/gstfilter.c b/gst/filter/gstfilter.c index cb7fe554..7a5d4248 100644 --- a/gst/filter/gstfilter.c +++ b/gst/filter/gstfilter.c @@ -39,43 +39,21 @@ static struct _elements_entry _elements[] = { { NULL, 0 }, }; -GstPadTemplate* -gst_filter_src_factory (void) -{ - static GstPadTemplate *templ = NULL; - if (!templ) { - templ = GST_PAD_TEMPLATE_NEW ( - "src", - GST_PAD_SRC, - GST_PAD_ALWAYS, - gst_caps_new ( - "filter_src", - "audio/x-raw-float", - GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_PROPS - ) - ); - } - return templ; -} +GstStaticPadTemplate gst_filter_src_template = +GST_STATIC_PAD_TEMPLATE ( + "src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ( GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS ) +); -GstPadTemplate* -gst_filter_sink_factory (void) -{ - static GstPadTemplate *templ = NULL; - if (!templ) { - templ = GST_PAD_TEMPLATE_NEW ( - "sink", - GST_PAD_SINK, - GST_PAD_ALWAYS, - gst_caps_new ( - "filter_src", - "audio/x-raw-float", - GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_PROPS - ) - ); - } - return templ; -} +GstStaticPadTemplate gst_filter_sink_template = +GST_STATIC_PAD_TEMPLATE ( + "sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ( GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS ) +); static gboolean plugin_init (GstPlugin * plugin) diff --git a/gst/filter/gstfilter.h b/gst/filter/gstfilter.h index 4669e554..1ad53a81 100644 --- a/gst/filter/gstfilter.h +++ b/gst/filter/gstfilter.h @@ -29,7 +29,7 @@ GType gst_iir_get_type (void); GType gst_lpwsinc_get_type (void); GType gst_bpwsinc_get_type (void); -extern GstPadTemplate *gst_filter_sink_factory (); -extern GstPadTemplate *gst_filter_src_factory (); +extern GstStaticPadTemplate gst_filter_sink_template; +extern GstStaticPadTemplate gst_filter_src_template; #endif /* __GST_FILTER_H__ */ diff --git a/gst/filter/gstiir.c b/gst/filter/gstiir.c index 007bdb7a..4ccf9f09 100644 --- a/gst/filter/gstiir.c +++ b/gst/filter/gstiir.c @@ -89,7 +89,7 @@ static void gst_iir_get_property (GObject * object, guint prop_id, static void gst_iir_chain (GstPad * pad, GstData *_data); static GstPadLinkReturn - gst_iir_sink_connect (GstPad * pad, GstCaps * caps); + gst_iir_sink_connect (GstPad * pad, const GstCaps * caps); static GstElementClass *parent_class = NULL; /*static guint gst_iir_signals[LAST_SIGNAL] = { 0 }; */ @@ -120,8 +120,10 @@ gst_iir_base_init (gpointer g_class) GstElementClass *element_class = GST_ELEMENT_CLASS (g_class); /* register src pads */ - gst_element_class_add_pad_template (element_class, gst_filter_src_factory ()); - gst_element_class_add_pad_template (element_class, gst_filter_sink_factory ()); + gst_element_class_add_pad_template (element_class, + gst_static_pad_template_get (&gst_filter_src_template)); + gst_element_class_add_pad_template (element_class, + gst_static_pad_template_get (&gst_filter_sink_template)); gst_element_class_set_details (element_class, &gst_iir_details); } @@ -161,12 +163,14 @@ gst_iir_class_init (GstIIRClass * klass) static void gst_iir_init (GstIIR * filter) { - filter->sinkpad = gst_pad_new_from_template (gst_filter_sink_factory (), "sink"); + filter->sinkpad = gst_pad_new_from_template ( + gst_static_pad_template_get (&gst_filter_sink_template), "sink"); gst_pad_set_chain_function (filter->sinkpad, gst_iir_chain); gst_pad_set_link_function (filter->sinkpad, gst_iir_sink_connect); gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad); - filter->srcpad = gst_pad_new_from_template (gst_filter_src_factory (), "src"); + filter->srcpad = gst_pad_new_from_template ( + gst_static_pad_template_get (&gst_filter_src_template), "src"); gst_element_add_pad (GST_ELEMENT (filter), filter->srcpad); filter->A = 0.0; @@ -177,17 +181,14 @@ gst_iir_init (GstIIR * filter) } static GstPadLinkReturn -gst_iir_sink_connect (GstPad * pad, GstCaps * caps) +gst_iir_sink_connect (GstPad * pad, const GstCaps * caps) { GstIIR *filter; GstPadLinkReturn set_retval; filter = GST_IIR (gst_pad_get_parent (pad)); - if (!GST_CAPS_IS_FIXED (caps)) - return GST_PAD_LINK_DELAYED; - - set_retval = gst_pad_try_set_caps(filter->srcpad, gst_caps_ref (caps)); + set_retval = gst_pad_try_set_caps(filter->srcpad, caps); if (set_retval > 0) { /* connection works, so init the filter */ /* FIXME: remember to free it */ diff --git a/gst/filter/gstlpwsinc.c b/gst/filter/gstlpwsinc.c index aaa7463e..603d8775 100644 --- a/gst/filter/gstlpwsinc.c +++ b/gst/filter/gstlpwsinc.c @@ -102,7 +102,7 @@ static void gst_lpwsinc_get_property (GObject * object, guint prop_id, static void gst_lpwsinc_chain (GstPad * pad, GstData *_data); static GstPadLinkReturn - gst_lpwsinc_sink_connect (GstPad * pad, GstCaps * caps); + gst_lpwsinc_sink_connect (GstPad * pad, const GstCaps * caps); static GstElementClass *parent_class = NULL; /*static guint gst_lpwsinc_signals[LAST_SIGNAL] = { 0 }; */ @@ -133,8 +133,10 @@ gst_lpwsinc_base_init (gpointer g_class) GstElementClass *element_class = GST_ELEMENT_CLASS (g_class); /* register src pads */ - gst_element_class_add_pad_template (element_class, gst_filter_src_factory ()); - gst_element_class_add_pad_template (element_class, gst_filter_sink_factory ()); + gst_element_class_add_pad_template (element_class, + gst_static_pad_template_get (&gst_filter_src_template)); + gst_element_class_add_pad_template (element_class, + gst_static_pad_template_get (&gst_filter_sink_template)); gst_element_class_set_details (element_class, &gst_lpwsinc_details); } @@ -168,12 +170,14 @@ gst_lpwsinc_class_init (GstLPWSincClass * klass) static void gst_lpwsinc_init (GstLPWSinc * filter) { - filter->sinkpad = gst_pad_new_from_template (gst_filter_sink_factory (), "sink"); + filter->sinkpad = gst_pad_new_from_template ( + gst_static_pad_template_get (&gst_filter_sink_template), "sink"); gst_pad_set_chain_function (filter->sinkpad, gst_lpwsinc_chain); gst_pad_set_link_function (filter->sinkpad, gst_lpwsinc_sink_connect); gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad); - filter->srcpad = gst_pad_new_from_template (gst_filter_src_factory (), "src"); + filter->srcpad = gst_pad_new_from_template ( + gst_static_pad_template_get (&gst_filter_src_template), "src"); gst_element_add_pad (GST_ELEMENT (filter), filter->srcpad); filter->wing_size = 50; @@ -182,7 +186,7 @@ gst_lpwsinc_init (GstLPWSinc * filter) } static GstPadLinkReturn -gst_lpwsinc_sink_connect (GstPad * pad, GstCaps * caps) +gst_lpwsinc_sink_connect (GstPad * pad, const GstCaps * caps) { int i = 0; double sum = 0.0; @@ -193,10 +197,7 @@ gst_lpwsinc_sink_connect (GstPad * pad, GstCaps * caps) g_assert (GST_IS_PAD (pad)); g_assert (caps != NULL); - if (!GST_CAPS_IS_FIXED (caps)) - return GST_PAD_LINK_DELAYED; - - set_retval = gst_pad_try_set_caps(filter->srcpad, gst_caps_ref (caps)); + set_retval = gst_pad_try_set_caps(filter->srcpad, caps); if (set_retval > 0) { diff --git a/gst/flx/gstflxdec.c b/gst/flx/gstflxdec.c index 4a144804..ca893394 100644 --- a/gst/flx/gstflxdec.c +++ b/gst/flx/gstflxdec.c @@ -47,36 +47,22 @@ enum { }; /* input */ -GST_PAD_TEMPLATE_FACTORY (sink_factory, +static GstStaticPadTemplate sink_factory = +GST_STATIC_PAD_TEMPLATE ( "sink", GST_PAD_SINK, GST_PAD_ALWAYS, - GST_CAPS_NEW ( - "flxdec_sink", - "video/x-fli", - NULL - ) -) + GST_STATIC_CAPS ( "video/x-fli" ) +); /* output */ -GST_PAD_TEMPLATE_FACTORY (src_video_factory, +static GstStaticPadTemplate src_video_factory = +GST_STATIC_PAD_TEMPLATE ( "src", GST_PAD_SRC, GST_PAD_ALWAYS, - GST_CAPS_NEW ( - "src_video", - "video/x-raw-rgb", - "bpp", GST_PROPS_INT (32), - "depth", GST_PROPS_INT (32), - "endianness", GST_PROPS_INT (G_BIG_ENDIAN), - "red_mask", GST_PROPS_INT (R_MASK_32), - "green_mask", GST_PROPS_INT (G_MASK_32), - "blue_mask", GST_PROPS_INT (B_MASK_32), - "width", GST_PROPS_INT_RANGE(320, 1280), - "height", GST_PROPS_INT_RANGE(200, 1024), - "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT) - ) -) + GST_STATIC_CAPS ( GST_VIDEO_RGB_PAD_TEMPLATE_CAPS_32 ) +); static void gst_flxdec_class_init (GstFlxDecClass *klass); @@ -130,9 +116,9 @@ gst_flxdec_base_init (GstFlxDecClass *klass) gst_element_class_set_details (gstelement_class, &flxdec_details); gst_element_class_add_pad_template (gstelement_class, - GST_PAD_TEMPLATE_GET (sink_factory)); + gst_static_pad_template_get (&sink_factory)); gst_element_class_add_pad_template (gstelement_class, - GST_PAD_TEMPLATE_GET (src_video_factory)); + gst_static_pad_template_get (&src_video_factory)); } static void @@ -158,12 +144,12 @@ static void gst_flxdec_init(GstFlxDec *flxdec) { flxdec->sinkpad = gst_pad_new_from_template ( - GST_PAD_TEMPLATE_GET (sink_factory), "sink"); + gst_static_pad_template_get (&sink_factory), "sink"); gst_element_add_pad(GST_ELEMENT(flxdec),flxdec->sinkpad); gst_element_set_loop_function(GST_ELEMENT(flxdec),gst_flxdec_loop); flxdec->srcpad = gst_pad_new_from_template ( - GST_PAD_TEMPLATE_GET (src_video_factory), "src"); + gst_static_pad_template_get (&src_video_factory), "src"); gst_element_add_pad(GST_ELEMENT(flxdec),flxdec->srcpad); flxdec->bs = NULL; @@ -444,6 +430,7 @@ gst_flxdec_loop (GstElement *element) GstBuffer *buf; GstBuffer *databuf; guchar *data, *chunk; + GstCaps *caps; GstFlxDec *flxdec; FlxHeader *flxh; @@ -497,19 +484,11 @@ gst_flxdec_loop (GstElement *element) flxdec->frame_time = flxh->speed * GST_MSECOND; } - gst_pad_try_set_caps (flxdec->srcpad, - GST_CAPS_NEW ( - "src_video", - "video/x-raw-rgb", - "bpp", GST_PROPS_INT (32), - "depth", GST_PROPS_INT (32), - "endianness", GST_PROPS_INT (G_BIG_ENDIAN), - "red_mask", GST_PROPS_INT (R_MASK_32), - "green_mask", GST_PROPS_INT (G_MASK_32), - "blue_mask", GST_PROPS_INT (B_MASK_32), - "width", GST_PROPS_INT (flxh->width), - "height", GST_PROPS_INT (flxh->height), - "framerate", GST_PROPS_FLOAT (GST_SECOND/flxdec->frame_time))); + caps = gst_caps_from_string (GST_VIDEO_RGB_PAD_TEMPLATE_CAPS_32); + gst_caps_set_simple (caps, + "width", G_TYPE_INT, flxh->width, + "height", G_TYPE_INT, flxh->height, + "framerate", G_TYPE_DOUBLE, GST_SECOND/flxdec->frame_time, NULL); if (flxh->depth <= 8) flxdec->converter = flx_colorspace_converter_new(flxh->width, flxh->height); @@ -521,7 +500,6 @@ gst_flxdec_loop (GstElement *element) g_print("GstFlxDec: (FLC) oframe1 : 0x%08x\n", flxh->oframe1); g_print("GstFlxDec: (FLC) oframe2 : 0x%08x\n", flxh->oframe2); } - flxdec->size = (flxh->width * flxh->height); diff --git a/gst/mixmatrix/mixmatrix.c b/gst/mixmatrix/mixmatrix.c index babb7f30..0551cac0 100644 --- a/gst/mixmatrix/mixmatrix.c +++ b/gst/mixmatrix/mixmatrix.c @@ -88,26 +88,20 @@ enum { ARG_MATRIXPTR, }; -GST_PAD_TEMPLATE_FACTORY (mixmatrix_sink_factory, +static GstStaticPadTemplate mixmatrix_sink_template = +GST_STATIC_PAD_TEMPLATE ( "sink%d", GST_PAD_SINK, GST_PAD_REQUEST, - gst_caps_new ( - "float_src", - "audio/x-raw-float", - GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_PROPS - ) + GST_STATIC_CAPS ( GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS ) ); -GST_PAD_TEMPLATE_FACTORY (mixmatrix_src_factory, +static GstStaticPadTemplate mixmatrix_src_template = +GST_STATIC_PAD_TEMPLATE ( "src%d", GST_PAD_SRC, GST_PAD_REQUEST, - gst_caps_new ( - "float_sink", - "audio/x-raw-float", - GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_PROPS - ) + GST_STATIC_CAPS ( GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS ) ); static void gst_mixmatrix_class_init (GstMixMatrixClass *klass); @@ -118,11 +112,10 @@ static void gst_mixmatrix_set_property (GObject *object, guint prop_id, const GV static void gst_mixmatrix_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); static GstPad * gst_mixmatrix_request_new_pad (GstElement *element, GstPadTemplate *temp, const gchar *name); -static GstPadLinkReturn gst_mixmatrix_connect (GstPad *pad, GstCaps *caps); +static GstPadLinkReturn gst_mixmatrix_connect (GstPad *pad, const GstCaps *caps); static void gst_mixmatrix_loop (GstElement *element); -static GstPadTemplate *srctempl, *sinktempl; static guint gst_mixmatrix_signals[LAST_SIGNAL] = { 0 }; static GstElementClass *parent_class = NULL; @@ -152,8 +145,10 @@ gst_mixmatrix_base_init (GstMixMatrixClass *klass) { GstElementClass *element_class = GST_ELEMENT_CLASS (klass); - gst_element_class_add_pad_template (element_class, sinktempl); - gst_element_class_add_pad_template (element_class, srctempl); + gst_element_class_add_pad_template (element_class, + gst_static_pad_template_get (&mixmatrix_sink_template)); + gst_element_class_add_pad_template (element_class, + gst_static_pad_template_get (&mixmatrix_src_template)); gst_element_class_set_details (element_class, &mixmatrix_details); } @@ -324,24 +319,22 @@ gst_mixmatrix_set_all_caps (GstMixMatrix *mix) */ static GstPadLinkReturn -gst_mixmatrix_connect (GstPad *pad, GstCaps *caps) +gst_mixmatrix_connect (GstPad *pad, const GstCaps *caps) { GstMixMatrix *mix = GST_MIXMATRIX(GST_PAD_PARENT(pad)); gint i; - if (!GST_CAPS_IS_FIXED(caps) || GST_PAD_IS_SRC (pad)) { - return GST_PAD_LINK_DELAYED; - } - for (i=0;i<mix->srcpadalloc;i++) { if (mix->srcpads[i]) { - if (GST_PAD_CAPS(mix->srcpads[i]) == NULL) - if (gst_pad_try_set_caps(mix->srcpads[i], gst_caps_ref (caps)) <= 0) + if (GST_PAD_CAPS(mix->srcpads[i]) == NULL) { + if (gst_pad_try_set_caps(mix->srcpads[i], caps) <= 0) { return GST_PAD_LINK_REFUSED; + } + } } } - mix->caps = caps; + mix->caps = gst_caps_copy(caps); return GST_PAD_LINK_OK; } @@ -368,7 +361,8 @@ gst_mixmatrix_request_new_pad (GstElement *element, GstPadTemplate *templ, const if (padnum >= mix->sinkpadalloc) mixmatrix_resize(mix, ROUND_UP(padnum,mix->grpsize), mix->sinkpadalloc); - pad = gst_pad_new_from_template(sinktempl, name); + pad = gst_pad_new_from_template( + gst_static_pad_template_get (&mixmatrix_sink_template), name); GST_PAD_ELEMENT_PRIVATE(pad) = GINT_TO_POINTER(padnum); gst_element_add_pad(GST_ELEMENT(mix), pad); // g_signal_connect(G_OBJECT(pad), "unlink", G_CALLBACK(sink_unlinked), mix); @@ -391,7 +385,8 @@ gst_mixmatrix_request_new_pad (GstElement *element, GstPadTemplate *templ, const if (padnum >= mix->srcpadalloc) mixmatrix_resize(mix, ROUND_UP(padnum,mix->grpsize), mix->srcpadalloc); - pad = gst_pad_new_from_template(srctempl, name); + pad = gst_pad_new_from_template( + gst_static_pad_template_get (&mixmatrix_src_template), name); GST_PAD_ELEMENT_PRIVATE(pad) = GINT_TO_POINTER(padnum); gst_element_add_pad(GST_ELEMENT(mix), pad); // g_signal_connect(G_OBJECT(pad), "unlink", G_CALLBACK(sink_unlinked), mix); @@ -509,9 +504,6 @@ plugin_init (GstPlugin *plugin) if (!gst_library_load ("gstbytestream")) return FALSE; - sinktempl = mixmatrix_sink_factory (); - srctempl = mixmatrix_src_factory (); - return gst_element_register (plugin, "mixmatrix", GST_RANK_NONE, GST_TYPE_MIXMATRIX); } diff --git a/gst/modplug/gstmodplug.cc b/gst/modplug/gstmodplug.cc index 48f76368..ab603cd3 100644 --- a/gst/modplug/gstmodplug.cc +++ b/gst/modplug/gstmodplug.cc @@ -66,32 +66,24 @@ enum { ARG_SURROUND, ARG_SURROUND_DEPTH, ARG_SURROUND_DELAY, - ARG_OVERSAMP, - ARG_METADATA, - ARG_STREAMINFO + ARG_OVERSAMP }; -GST_PAD_TEMPLATE_FACTORY (modplug_src_template_factory, +static GstStaticPadTemplate modplug_src_template_factory = +GST_STATIC_PAD_TEMPLATE ( "src", GST_PAD_SRC, GST_PAD_ALWAYS, - gst_caps_new ( - "modplug_src", - "audio/x-raw-int", - GST_AUDIO_INT_PAD_TEMPLATE_PROPS - ) -) + GST_STATIC_CAPS (GST_AUDIO_INT_PAD_TEMPLATE_CAPS) +); -GST_PAD_TEMPLATE_FACTORY (modplug_sink_template_factory, +static GstStaticPadTemplate modplug_sink_template_factory = +GST_STATIC_PAD_TEMPLATE ( "sink", GST_PAD_SINK, GST_PAD_ALWAYS, - GST_CAPS_NEW ( - "modplug_sink", - "audio/x-mod", - NULL - ) -) + GST_STATIC_CAPS ("audio/x-mod") +); enum { MODPLUG_STATE_NEED_TUNE = 1, @@ -111,7 +103,7 @@ static void gst_modplug_get_property (GObject *object, GValue *value, GParamSpec *pspec ); static GstPadLinkReturn - gst_modplug_srclink (GstPad *pad, GstCaps *caps); + gst_modplug_srclink (GstPad *pad, const GstCaps *caps); static void gst_modplug_loop (GstElement *element); static void gst_modplug_setup (GstModPlug *modplug); static const GstFormat * @@ -156,9 +148,9 @@ gst_modplug_base_init (GstModPlugClass *klass) GstElementClass *element_class = GST_ELEMENT_CLASS (klass); gst_element_class_add_pad_template (element_class, - GST_PAD_TEMPLATE_GET (modplug_sink_template_factory)); + gst_static_pad_template_get (&modplug_sink_template_factory)); gst_element_class_add_pad_template (element_class, - GST_PAD_TEMPLATE_GET (modplug_src_template_factory)); + gst_static_pad_template_get (&modplug_src_template_factory)); gst_element_class_set_details (element_class, &modplug_details); } @@ -221,14 +213,6 @@ gst_modplug_class_init (GstModPlugClass *klass) g_param_spec_boolean("noise_reduction", "noise_reduction", "noise_reduction", TRUE, (GParamFlags)G_PARAM_READWRITE )); - g_object_class_install_property (gobject_class, ARG_METADATA, - g_param_spec_boxed ("metadata", "Metadata", "Metadata", - GST_TYPE_CAPS, G_PARAM_READABLE)); - - g_object_class_install_property (gobject_class, ARG_STREAMINFO, - g_param_spec_boxed ("streaminfo", "Streaminfo", "Streaminfo", - GST_TYPE_CAPS, G_PARAM_READABLE)); - gobject_class->set_property = gst_modplug_set_property; gobject_class->get_property = gst_modplug_get_property; @@ -238,10 +222,10 @@ gst_modplug_class_init (GstModPlugClass *klass) static void gst_modplug_init (GstModPlug *modplug) { - modplug->sinkpad = gst_pad_new_from_template (GST_PAD_TEMPLATE_GET (modplug_sink_template_factory), "sink"); + modplug->sinkpad = gst_pad_new_from_template (gst_static_pad_template_get (&modplug_sink_template_factory), "sink"); gst_element_add_pad (GST_ELEMENT(modplug), modplug->sinkpad); - modplug->srcpad = gst_pad_new_from_template (GST_PAD_TEMPLATE_GET (modplug_src_template_factory), "src"); + modplug->srcpad = gst_pad_new_from_template (gst_static_pad_template_get (&modplug_src_template_factory), "src"); gst_element_add_pad (GST_ELEMENT(modplug), modplug->srcpad); gst_pad_set_link_function (modplug->srcpad, gst_modplug_srclink); @@ -395,20 +379,18 @@ gst_modplug_src_event (GstPad *pad, GstEvent *event) return res; } +#if 0 static GstCaps* gst_modplug_get_streaminfo (GstModPlug *modplug) { GstCaps *caps; - GstProps *props; - GstPropsEntry *entry; props = gst_props_empty_new (); - entry = gst_props_entry_new ("Patterns", GST_PROPS_INT ((gint)modplug->mSoundFile->GetNumPatterns())); + entry = gst_props_entry_new ("Patterns", G_TYPE_INT ((gint)modplug->mSoundFile->GetNumPatterns())); gst_props_add_entry (props, (GstPropsEntry *) entry); - caps = gst_caps_new ("mad_streaminfo", "application/x-gst-streaminfo", - props); + caps = gst_caps_new_simple ("application/x-gst-streaminfo", NULL); return caps; } @@ -434,15 +416,15 @@ gst_modplug_update_metadata (GstModPlug *modplug) props = gst_props_empty_new (); title = modplug->mSoundFile->GetTitle(); - entry = gst_props_entry_new ("Title", GST_PROPS_STRING (title)); + entry = gst_props_entry_new ("Title", G_TYPE_STRING (title)); gst_props_add_entry (props, entry); - modplug->metadata = gst_caps_new ("modplug_metadata", - "application/x-gst-metadata", - props); + modplug->metadata = gst_caps_new_simple ("application/x-gst-metadata", + NULL); g_object_notify (G_OBJECT (modplug), "metadata"); } +#endif static GstPadLinkReturn @@ -464,17 +446,14 @@ modplug_negotiate (GstModPlug *modplug) } if ((ret = gst_pad_try_set_caps (modplug->srcpad, - GST_CAPS_NEW ( - "modplug_src", - "audio/x-raw-int", - "endianness", GST_PROPS_INT (G_BYTE_ORDER), - "signed", GST_PROPS_BOOLEAN (sign), - "width", GST_PROPS_INT (modplug->bitsPerSample), - "depth", GST_PROPS_INT (modplug->bitsPerSample), - "rate", GST_PROPS_INT (modplug->frequency), - "channels", GST_PROPS_INT (modplug->channel), - NULL) - )) <= 0) { + gst_caps_new_simple ("audio/x-raw-int", + "endianness", G_TYPE_INT, G_BYTE_ORDER, + "signed", G_TYPE_BOOLEAN, sign, + "width", G_TYPE_INT, modplug->bitsPerSample, + "depth", G_TYPE_INT, modplug->bitsPerSample, + "rate", G_TYPE_INT, modplug->frequency, + "channels", G_TYPE_INT, modplug->channel, + NULL))) <= 0) { return ret; } @@ -485,23 +464,20 @@ modplug_negotiate (GstModPlug *modplug) static GstPadLinkReturn -gst_modplug_srclink (GstPad *pad, GstCaps *caps) +gst_modplug_srclink (GstPad *pad, const GstCaps *caps) { GstModPlug *modplug; + GstStructure *structure; + gint depth; modplug = GST_MODPLUG (gst_pad_get_parent (pad)); - if (gst_caps_has_property_typed (caps, "depth", GST_PROPS_INT_TYPE)) { - gint depth; - gst_caps_get_int (caps, "depth", &depth); - modplug->_16bit = (depth == 16); - } - if (gst_caps_has_property_typed (caps, "channels", GST_PROPS_INT_TYPE)) { - gst_caps_get_int (caps, "channels", &modplug->channel); - } - if (gst_caps_has_property_typed (caps, "rate", GST_PROPS_INT_TYPE)) { - gst_caps_get_int (caps, "rate", &modplug->frequency); - } + structure = gst_caps_get_structure (caps, 0); + + gst_structure_get_int (structure, "depth", &depth); + modplug->_16bit = (depth == 16); + gst_structure_get_int (structure, "channels", &modplug->channel); + gst_structure_get_int (structure, "rate", &modplug->frequency); return modplug_negotiate(modplug); } @@ -611,8 +587,8 @@ gst_modplug_loop (GstElement *element) modplug->audiobuffer = (guchar *) g_malloc (modplug->length); - gst_modplug_update_metadata (modplug); - gst_modplug_update_info (modplug); + //gst_modplug_update_metadata (modplug); + //gst_modplug_update_info (modplug); modplug->state = MODPLUG_STATE_PLAY_TUNE; } @@ -691,8 +667,6 @@ gst_modplug_change_state (GstElement *element) modplug->bs = gst_bytestream_new (modplug->sinkpad); modplug->song_size = 0; modplug->state = MODPLUG_STATE_NEED_TUNE; - modplug->metadata = NULL; - modplug->streaminfo = NULL; break; case GST_STATE_PAUSED_TO_PLAYING: break; @@ -709,7 +683,6 @@ gst_modplug_change_state (GstElement *element) if (modplug->audiobuffer) g_free (modplug->audiobuffer); modplug->buffer_in = NULL; modplug->audiobuffer = NULL; - gst_caps_unref (modplug->streaminfo); modplug->state = MODPLUG_STATE_NEED_TUNE; break; case GST_STATE_READY_TO_NULL: @@ -810,12 +783,6 @@ gst_modplug_get_property (GObject *object, guint id, GValue *value, GParamSpec * case ARG_NOISE_REDUCTION: g_value_set_boolean (value, modplug->noise_reduction); break; - case ARG_METADATA: - g_value_set_boxed (value, modplug->metadata); - break; - case ARG_STREAMINFO: - g_value_set_boxed (value, modplug->streaminfo); - break; default: break; } diff --git a/gst/modplug/gstmodplug.h b/gst/modplug/gstmodplug.h index d6202e69..95a71443 100644 --- a/gst/modplug/gstmodplug.h +++ b/gst/modplug/gstmodplug.h @@ -44,8 +44,6 @@ struct _GstModPlug { GstElement element; GstPad *sinkpad, *srcpad; guint8 *buffer_in; - GstCaps *metadata; - GstCaps *streaminfo; GstByteStream *bs; const gchar *songname; diff --git a/gst/mpeg1sys/gstmpeg1systemencode.c b/gst/mpeg1sys/gstmpeg1systemencode.c index dfac9493..e3d38d9a 100644 --- a/gst/mpeg1sys/gstmpeg1systemencode.c +++ b/gst/mpeg1sys/gstmpeg1systemencode.c @@ -49,41 +49,34 @@ enum { /* FILL ME */ }; -GST_PAD_TEMPLATE_FACTORY (src_factory, +static GstStaticPadTemplate src_factory = +GST_STATIC_PAD_TEMPLATE ( "src", GST_PAD_SRC, GST_PAD_ALWAYS, - GST_CAPS_NEW ( - "src_video", - "video/mpeg", - "systemstream", GST_PROPS_BOOLEAN (TRUE) - ) -) -GST_PAD_TEMPLATE_FACTORY (video_sink_factory, + GST_STATIC_CAPS ("video/mpeg, " + "systemstream = (boolean) TRUE") +); +static GstStaticPadTemplate video_sink_factory = +GST_STATIC_PAD_TEMPLATE ( "video_%d", GST_PAD_SINK, GST_PAD_REQUEST, - GST_CAPS_NEW ( - "sink_video", - "video/mpeg", - "mpegversion", GST_PROPS_INT (1), - "systemstream", GST_PROPS_BOOLEAN (FALSE) - /* we don't care about width/height/framerate */ - ) -) + GST_STATIC_CAPS ("video/mpeg, " + "mpegversion = (int) 1, " + "systemstream = (boolean) FALSE") +); -GST_PAD_TEMPLATE_FACTORY (audio_sink_factory, +static GstStaticPadTemplate audio_sink_factory = +GST_STATIC_PAD_TEMPLATE ( "audio_%d", GST_PAD_SINK, GST_PAD_REQUEST, - GST_CAPS_NEW ( - "sink_audio", - "audio/mpeg", - "mpegversion", GST_PROPS_INT (1), - "layer", GST_PROPS_INT_RANGE (1, 2) - /* "don't care" about samplerate/channels */ + GST_STATIC_CAPS ("audio/mpeg, " + "mpegversion = (int) 1, " + "layer = (int) [ 1, 2 ] " ) -) +); static void gst_system_encode_class_init (GstMPEG1SystemEncodeClass *klass); static void gst_system_encode_base_init (GstMPEG1SystemEncodeClass *klass); @@ -130,11 +123,11 @@ gst_system_encode_base_init (GstMPEG1SystemEncodeClass *klass) GstElementClass *element_class = GST_ELEMENT_CLASS (klass); gst_element_class_add_pad_template (element_class, - GST_PAD_TEMPLATE_GET (src_factory)); + gst_static_pad_template_get (&src_factory)); gst_element_class_add_pad_template (element_class, - GST_PAD_TEMPLATE_GET (audio_sink_factory)); + gst_static_pad_template_get (&audio_sink_factory)); gst_element_class_add_pad_template (element_class, - GST_PAD_TEMPLATE_GET (video_sink_factory)); + gst_static_pad_template_get (&video_sink_factory)); gst_element_class_set_details (element_class, &system_encode_details); } @@ -159,7 +152,7 @@ static void gst_system_encode_init (GstMPEG1SystemEncode *system_encode) { system_encode->srcpad = gst_pad_new_from_template ( - GST_PAD_TEMPLATE_GET (src_factory), "src"); + gst_static_pad_template_get (&src_factory), "src"); gst_element_add_pad (GST_ELEMENT (system_encode), system_encode->srcpad); system_encode->video_buffer = mpeg1mux_buffer_new (BUFFER_TYPE_VIDEO, 0xE0); @@ -197,7 +190,7 @@ gst_system_encode_request_new_pad (GstElement *element, GstPadTemplate *templ, c } system_encode = GST_SYSTEM_ENCODE (element); - if (templ == GST_PAD_TEMPLATE_GET (audio_sink_factory)) { + if (templ == gst_static_pad_template_get (&audio_sink_factory)) { name = g_strdup_printf ("audio_%02d", system_encode->num_audio_pads); g_print ("%s\n", name); newpad = gst_pad_new_from_template (templ, name); @@ -207,7 +200,7 @@ gst_system_encode_request_new_pad (GstElement *element, GstPadTemplate *templ, c system_encode->num_audio_pads++; system_encode->which_streams |= STREAMS_AUDIO; } - else if (templ == GST_PAD_TEMPLATE_GET (video_sink_factory)) { + else if (templ == gst_static_pad_template_get (&video_sink_factory)) { name = g_strdup_printf ("video_%02d", system_encode->num_video_pads); g_print ("%s\n", name); newpad = gst_pad_new_from_template (templ, name); diff --git a/gst/mpeg1videoparse/gstmp1videoparse.c b/gst/mpeg1videoparse/gstmp1videoparse.c index 3ca8500a..1cdefbb1 100644 --- a/gst/mpeg1videoparse/gstmp1videoparse.c +++ b/gst/mpeg1videoparse/gstmp1videoparse.c @@ -43,32 +43,30 @@ static GstElementDetails mpeg1videoparse_details = GST_ELEMENT_DETAILS ( "Wim Taymans <wim.taymans@chello.be>" ); -GST_PAD_TEMPLATE_FACTORY (src_factory, +static GstStaticPadTemplate src_factory = +GST_STATIC_PAD_TEMPLATE ( "src", GST_PAD_SRC, GST_PAD_ALWAYS, - GST_CAPS_NEW ( - "mp1videoparse_src", - "video/mpeg", - "mpegversion", GST_PROPS_INT (1), - "systemstream", GST_PROPS_BOOLEAN (FALSE), - "width", GST_PROPS_INT_RANGE (16, 4096), - "height", GST_PROPS_INT_RANGE (16, 4096), - "pixel_width", GST_PROPS_INT_RANGE (1, 255), - "pixel_height", GST_PROPS_INT_RANGE (1, 255), - "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT) + GST_STATIC_CAPS ("video/mpeg, " + "mpegversion = (int) 1, " + "systemstream = (boolean) false, " + "width = (int) [ 16, 4096 ], " + "height = (int) [ 16, 4096 ], " + "pixel_width = (int) [ 1, 255 ], " + "pixel_height = (int) [ 1, 255 ], " + "framerate = (double) [ 0, MAX ]" ) ); -GST_PAD_TEMPLATE_FACTORY (sink_factory, +static GstStaticPadTemplate sink_factory = +GST_STATIC_PAD_TEMPLATE ( "sink", GST_PAD_SINK, GST_PAD_ALWAYS, - GST_CAPS_NEW ( - "mp1videoparse_sink", - "video/mpeg", - "mpegversion", GST_PROPS_INT (1), - "systemstream", GST_PROPS_BOOLEAN (FALSE) + GST_STATIC_CAPS ("video/mpeg, " + "mpegversion = (int) 1, " + "systemstream = (boolean) false" ) ); @@ -124,9 +122,9 @@ gst_mp1videoparse_base_init (Mp1VideoParseClass *klass) GstElementClass *element_class = GST_ELEMENT_CLASS (klass); gst_element_class_add_pad_template (element_class, - GST_PAD_TEMPLATE_GET (src_factory)); + gst_static_pad_template_get (&src_factory)); gst_element_class_add_pad_template (element_class, - GST_PAD_TEMPLATE_GET (sink_factory)); + gst_static_pad_template_get (&sink_factory)); gst_element_class_set_details (element_class, &mpeg1videoparse_details); } @@ -146,12 +144,12 @@ static void gst_mp1videoparse_init (Mp1VideoParse *mp1videoparse) { mp1videoparse->sinkpad = gst_pad_new_from_template ( - GST_PAD_TEMPLATE_GET (sink_factory), "sink"); + gst_static_pad_template_get (&sink_factory), "sink"); gst_element_add_pad(GST_ELEMENT(mp1videoparse),mp1videoparse->sinkpad); gst_pad_set_chain_function(mp1videoparse->sinkpad,gst_mp1videoparse_chain); mp1videoparse->srcpad = gst_pad_new_from_template ( - GST_PAD_TEMPLATE_GET (src_factory), "src"); + gst_static_pad_template_get (&src_factory), "src"); gst_element_add_pad(GST_ELEMENT(mp1videoparse),mp1videoparse->srcpad); mp1videoparse->partialbuf = NULL; @@ -200,17 +198,16 @@ mp1videoparse_parse_seq (Mp1VideoParse *mp1videoparse, GstBuffer *buf) p_w = (asr_table[asr_idx] < 1.0) ? (100 / asr_table[asr_idx]) : 1; p_h = (asr_table[asr_idx] > 1.0) ? (100 * asr_table[asr_idx]) : 1; - caps = GST_CAPS_NEW ("mp1videoparse_src", - "video/mpeg", - "systemstream", GST_PROPS_BOOLEAN (FALSE), - "mpegversion", GST_PROPS_INT (1), - "width", GST_PROPS_INT (width), - "height", GST_PROPS_INT (height), - "framerate", GST_PROPS_FLOAT (fps_table[fps_idx]), - "pixel_width", GST_PROPS_INT (p_w), - "pixel_height", GST_PROPS_INT (p_h)); - - gst_caps_debug (caps, "New mpeg1videoparse caps"); + caps = gst_caps_new_simple ("video/mpeg", + "systemstream", G_TYPE_BOOLEAN, FALSE, + "mpegversion", G_TYPE_INT, 1, + "width", G_TYPE_INT, width, + "height", G_TYPE_INT, height, + "framerate", G_TYPE_DOUBLE, fps_table[fps_idx], + "pixel_width", G_TYPE_INT, p_w, + "pixel_height", G_TYPE_INT, p_h, NULL); + + GST_DEBUG_CAPS ("New mpeg1videoparse caps", caps); if (gst_pad_try_set_caps (mp1videoparse->srcpad, caps) <= 0) { gst_element_error (GST_ELEMENT (mp1videoparse), diff --git a/gst/mpegaudioparse/gstmpegaudioparse.c b/gst/mpegaudioparse/gstmpegaudioparse.c index 6c7e614f..9b13019d 100644 --- a/gst/mpegaudioparse/gstmpegaudioparse.c +++ b/gst/mpegaudioparse/gstmpegaudioparse.c @@ -32,42 +32,27 @@ static GstElementDetails mp3parse_details = { "Erik Walthinsen <omega@cse.ogi.edu>" }; -static GstPadTemplate* -mp3_src_factory (void) -{ - return - gst_pad_template_new ( - "src", - GST_PAD_SRC, - GST_PAD_ALWAYS, - gst_caps_new ( - "mp3parse_src", - "audio/mpeg", - gst_props_new ( - "mpegversion", GST_PROPS_INT (1), - "layer", GST_PROPS_INT_RANGE (1, 3), - "rate", GST_PROPS_INT_RANGE (8000, 48000), - "channels", GST_PROPS_INT_RANGE (1, 2), - NULL)), - NULL); -} - -static GstPadTemplate* -mp3_sink_factory (void) -{ - return - gst_pad_template_new ( - "sink", - GST_PAD_SINK, - GST_PAD_ALWAYS, - GST_CAPS_NEW ( - "mp3parse_sink", - "audio/mpeg", - "mpegversion", GST_PROPS_INT (1) - ), - NULL - ); -}; +static GstStaticPadTemplate mp3_src_template = +GST_STATIC_PAD_TEMPLATE ( + "src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ("audio/mpeg, " + "mpegversion = (int) 1, " + "layer = (int) [ 1, 3 ], " + "rate = (int) [ 8000, 48000], " + "channels = (int) [ 1, 2 ]") +); + +static GstStaticPadTemplate mp3_sink_template = +GST_STATIC_PAD_TEMPLATE ( + "sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ("audio/mpeg, " + "mpegversion = (int) 1" + ) +); /* GstMPEGAudioParse signals and args */ enum { @@ -82,7 +67,6 @@ enum { /* FILL ME */ }; -static GstPadTemplate *sink_temp, *src_temp; static void gst_mp3parse_class_init (GstMPEGAudioParseClass *klass); static void gst_mp3parse_base_init (GstMPEGAudioParseClass *klass); @@ -248,13 +232,11 @@ mp3_caps_create (guint layer, guint channels, g_assert (bitrate); g_assert (channels); - new = GST_CAPS_NEW ("mp3_type_find", - "audio/mpeg", - "mpegversion", GST_PROPS_INT (1), - "layer", GST_PROPS_INT (layer), - /*"bitrate", GST_PROPS_INT (bitrate),*/ - "rate", GST_PROPS_INT (samplerate), - "channels", GST_PROPS_INT (channels)); + new = gst_caps_new_simple ("audio/mpeg", + "mpegversion", G_TYPE_INT, 1, + "layer", G_TYPE_INT, layer, + "rate", G_TYPE_INT, samplerate, + "channels", G_TYPE_INT, channels, NULL); return new; } @@ -264,8 +246,10 @@ gst_mp3parse_base_init (GstMPEGAudioParseClass *klass) { GstElementClass *element_class = GST_ELEMENT_CLASS (klass); - gst_element_class_add_pad_template (element_class, sink_temp); - gst_element_class_add_pad_template (element_class, src_temp); + gst_element_class_add_pad_template (element_class, + gst_static_pad_template_get (&mp3_sink_template)); + gst_element_class_add_pad_template (element_class, + gst_static_pad_template_get (&mp3_src_template)); gst_element_class_set_details (element_class, &mp3parse_details); } @@ -296,13 +280,15 @@ gst_mp3parse_class_init (GstMPEGAudioParseClass *klass) static void gst_mp3parse_init (GstMPEGAudioParse *mp3parse) { - mp3parse->sinkpad = gst_pad_new_from_template(sink_temp, "sink"); + mp3parse->sinkpad = gst_pad_new_from_template( + gst_static_pad_template_get (&mp3_sink_template), "sink"); gst_element_add_pad(GST_ELEMENT(mp3parse),mp3parse->sinkpad); gst_pad_set_chain_function(mp3parse->sinkpad,gst_mp3parse_chain); gst_element_set_loop_function (GST_ELEMENT(mp3parse),NULL); - mp3parse->srcpad = gst_pad_new_from_template(src_temp, "src"); + mp3parse->srcpad = gst_pad_new_from_template( + gst_static_pad_template_get (&mp3_src_template), "src"); gst_element_add_pad(GST_ELEMENT(mp3parse),mp3parse->srcpad); /*gst_pad_set_type_id(mp3parse->srcpad, mp3frametype); */ @@ -587,9 +573,6 @@ gst_mp3parse_change_state (GstElement *element) static gboolean plugin_init (GstPlugin *plugin) { - sink_temp = mp3_sink_factory (); - src_temp = mp3_src_factory (); - return gst_element_register (plugin, "mp3parse", GST_RANK_NONE, GST_TYPE_MP3PARSE); } diff --git a/gst/overlay/gstoverlay.c b/gst/overlay/gstoverlay.c index 676079d0..f2c01b3f 100644 --- a/gst/overlay/gstoverlay.c +++ b/gst/overlay/gstoverlay.c @@ -22,6 +22,7 @@ #include "config.h" #endif #include "gstoverlay.h" +#include <gst/video/video.h> /* elementfactory information */ static GstElementDetails overlay_details = { @@ -31,61 +32,37 @@ static GstElementDetails overlay_details = { "David Schleef <ds@schleef.org>" }; -GST_PAD_TEMPLATE_FACTORY (overlay_src_factory, +static GstStaticPadTemplate overlay_src_factory = +GST_STATIC_PAD_TEMPLATE ( "src", GST_PAD_SRC, GST_PAD_ALWAYS, - GST_CAPS_NEW ( - "overlay_src", - "video/x-raw-yuv", - "format", GST_PROPS_FOURCC (GST_MAKE_FOURCC ('I','4','2','0')), - "width", GST_PROPS_INT_RANGE (1, G_MAXINT), - "height", GST_PROPS_INT_RANGE (1, G_MAXINT), - "framerate",GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT) - ) -) + GST_STATIC_CAPS (GST_VIDEO_YUV_PAD_TEMPLATE_CAPS("I420")) +); -GST_PAD_TEMPLATE_FACTORY (overlay_sink1_factory, +static GstStaticPadTemplate overlay_sink1_factory = +GST_STATIC_PAD_TEMPLATE ( "sink1", GST_PAD_SINK, GST_PAD_ALWAYS, - GST_CAPS_NEW ( - "overlay_sink1", - "video/x-raw-yuv", - "format", GST_PROPS_FOURCC (GST_MAKE_FOURCC ('I','4','2','0')), - "width", GST_PROPS_INT_RANGE (1, G_MAXINT), - "height", GST_PROPS_INT_RANGE (1, G_MAXINT), - "framerate",GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT) - ) -) + GST_STATIC_CAPS (GST_VIDEO_YUV_PAD_TEMPLATE_CAPS("I420")) +); -GST_PAD_TEMPLATE_FACTORY (overlay_sink2_factory, +static GstStaticPadTemplate overlay_sink2_factory = +GST_STATIC_PAD_TEMPLATE ( "sink2", GST_PAD_SINK, GST_PAD_ALWAYS, - GST_CAPS_NEW ( - "overlay_sink2", - "video/x-raw-yuv", - "format", GST_PROPS_FOURCC (GST_MAKE_FOURCC ('I','4','2','0')), - "width", GST_PROPS_INT_RANGE (1, G_MAXINT), - "height", GST_PROPS_INT_RANGE (1, G_MAXINT), - "framerate",GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT) - ) -) + GST_STATIC_CAPS (GST_VIDEO_YUV_PAD_TEMPLATE_CAPS("I420")) +); -GST_PAD_TEMPLATE_FACTORY (overlay_sink3_factory, +static GstStaticPadTemplate overlay_sink3_factory = +GST_STATIC_PAD_TEMPLATE ( "sink3", GST_PAD_SINK, GST_PAD_ALWAYS, - GST_CAPS_NEW ( - "overlay_sink2", - "video/x-raw-yuv", - "format", GST_PROPS_FOURCC (GST_MAKE_FOURCC ('I','4','2','0')), - "width", GST_PROPS_INT_RANGE (1, G_MAXINT), - "height", GST_PROPS_INT_RANGE (1, G_MAXINT), - "framerate",GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT) - ) -) + GST_STATIC_CAPS (GST_VIDEO_YUV_PAD_TEMPLATE_CAPS("I420")) +); /* OVERLAY signals and args */ enum { @@ -140,13 +117,13 @@ gst_overlay_base_init (GstOverlayClass *klass) GstElementClass *element_class = GST_ELEMENT_CLASS (klass); gst_element_class_add_pad_template (element_class, - GST_PAD_TEMPLATE_GET (overlay_sink1_factory)); + gst_static_pad_template_get (&overlay_sink1_factory)); gst_element_class_add_pad_template (element_class, - GST_PAD_TEMPLATE_GET (overlay_sink2_factory)); + gst_static_pad_template_get (&overlay_sink2_factory)); gst_element_class_add_pad_template (element_class, - GST_PAD_TEMPLATE_GET (overlay_sink3_factory)); + gst_static_pad_template_get (&overlay_sink3_factory)); gst_element_class_add_pad_template (element_class, - GST_PAD_TEMPLATE_GET (overlay_src_factory)); + gst_static_pad_template_get (&overlay_src_factory)); gst_element_class_set_details (element_class, &overlay_details); } @@ -175,20 +152,20 @@ static GstCaps *gst_overlay_getcaps(GstPad *pad) overlay = GST_OVERLAY (gst_pad_get_parent (pad)); if(overlay->width && overlay->height){ - caps = GST_CAPS_NEW ( + caps = GST_STATIC_CAPS ( "overlay_sink2", "video/raw", - "format", GST_PROPS_FOURCC (GST_MAKE_FOURCC ('I','4','2','0')), - "width", GST_PROPS_INT (overlay->width), - "height", GST_PROPS_INT (overlay->height) + "format", GST_TYPE_FOURCC (GST_MAKE_FOURCC ('I','4','2','0')), + "width", G_TYPE_INT (overlay->width), + "height", G_TYPE_INT (overlay->height) ); }else{ - caps = GST_CAPS_NEW ( + caps = GST_STATIC_CAPS ( "overlay_sink2", "video/raw", - "format", GST_PROPS_FOURCC (GST_MAKE_FOURCC ('I','4','2','0')), - "width", GST_PROPS_INT_RANGE (0, 4096), - "height", GST_PROPS_INT_RANGE (0, 4096) + "format", GST_TYPE_FOURCC (GST_MAKE_FOURCC ('I','4','2','0')), + "width", G_TYPE_INT_RANGE (0, 4096), + "height", G_TYPE_INT_RANGE (0, 4096) ); } @@ -197,43 +174,43 @@ static GstCaps *gst_overlay_getcaps(GstPad *pad) #endif static gboolean -gst_overlay_sinkconnect (GstPad *pad, GstCaps *caps) +gst_overlay_sinkconnect (GstPad *pad, const GstCaps *caps) { GstOverlay *overlay; + GstStructure *structure; overlay = GST_OVERLAY (gst_pad_get_parent (pad)); - if (!GST_CAPS_IS_FIXED (caps)) - return GST_PAD_LINK_DELAYED; + structure = gst_caps_get_structure (caps, 0); - gst_caps_get_int (caps, "width", &overlay->width); - gst_caps_get_int (caps, "height", &overlay->height); - gst_caps_get_float (caps, "framerate", &overlay->framerate); + gst_structure_get_int (structure, "width", &overlay->width); + gst_structure_get_int (structure, "height", &overlay->height); + gst_structure_get_double (structure, "framerate", &overlay->framerate); /* forward to the next plugin */ - return gst_pad_try_set_caps(overlay->srcpad, gst_caps_copy_1(caps)); + return gst_pad_try_set_caps(overlay->srcpad, caps); } static void gst_overlay_init (GstOverlay *overlay) { overlay->sinkpad1 = gst_pad_new_from_template ( - GST_PAD_TEMPLATE_GET (overlay_sink1_factory), "sink1"); + gst_static_pad_template_get (&overlay_sink1_factory), "sink1"); gst_pad_set_link_function (overlay->sinkpad1, gst_overlay_sinkconnect); gst_element_add_pad (GST_ELEMENT (overlay), overlay->sinkpad1); overlay->sinkpad2 = gst_pad_new_from_template ( - GST_PAD_TEMPLATE_GET (overlay_sink2_factory), "sink2"); + gst_static_pad_template_get (&overlay_sink2_factory), "sink2"); gst_pad_set_link_function (overlay->sinkpad2, gst_overlay_sinkconnect); gst_element_add_pad (GST_ELEMENT (overlay), overlay->sinkpad2); overlay->sinkpad3 = gst_pad_new_from_template ( - GST_PAD_TEMPLATE_GET (overlay_sink3_factory), "sink3"); + gst_static_pad_template_get (&overlay_sink3_factory), "sink3"); gst_pad_set_link_function (overlay->sinkpad3, gst_overlay_sinkconnect); gst_element_add_pad (GST_ELEMENT (overlay), overlay->sinkpad3); overlay->srcpad = gst_pad_new_from_template ( - GST_PAD_TEMPLATE_GET (overlay_src_factory), "src"); + gst_static_pad_template_get (&overlay_src_factory), "src"); gst_element_add_pad (GST_ELEMENT (overlay), overlay->srcpad); gst_element_set_loop_function (GST_ELEMENT (overlay), gst_overlay_loop); @@ -318,22 +295,6 @@ gst_overlay_loop (GstElement *element) out = gst_buffer_new_and_alloc (size); - if (!GST_PAD_CAPS (overlay->srcpad)) { - if (!gst_pad_try_set_caps (overlay->srcpad, - GST_CAPS_NEW ( - "overlay_srccaps", - "video/x-raw-yuv", - "format", GST_PROPS_FOURCC (GST_MAKE_FOURCC ('I','4','2','0')), - "width", GST_PROPS_INT (overlay->width), - "height", GST_PROPS_INT (overlay->height), - "framerate",GST_PROPS_FLOAT (overlay->framerate) - ))) - { - gst_element_error (element, "cannot set caps"); - return; - } - } - gst_overlay_blend_i420 (GST_BUFFER_DATA (out), GST_BUFFER_DATA (in1), GST_BUFFER_DATA (in2), diff --git a/gst/overlay/gstoverlay.h b/gst/overlay/gstoverlay.h index 784c367b..523656e0 100644 --- a/gst/overlay/gstoverlay.h +++ b/gst/overlay/gstoverlay.h @@ -57,7 +57,7 @@ struct _GstOverlay { gint border; gint depth; - gfloat framerate; + gdouble framerate; }; struct _GstOverlayClass { diff --git a/gst/passthrough/gstpassthrough.c b/gst/passthrough/gstpassthrough.c index 8d58b2e2..5bf97f16 100644 --- a/gst/passthrough/gstpassthrough.c +++ b/gst/passthrough/gstpassthrough.c @@ -50,39 +50,27 @@ enum { ARG_SILENT }; -static GstPadTemplate* -passthrough_sink_factory (void) -{ - static GstPadTemplate *template = NULL; - - if (! template) { - template = gst_pad_template_new - ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, - gst_caps_append (gst_caps_new ("sink_int", "audio/x-raw-int", - GST_AUDIO_INT_PAD_TEMPLATE_PROPS), - gst_caps_new ("sink_float", "audio/x-raw-float", - GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_PROPS)), - NULL); - } - return template; -} - -static GstPadTemplate* -passthrough_src_factory (void) -{ - static GstPadTemplate *template = NULL; - - if (! template) - template = gst_pad_template_new - ("src", GST_PAD_SRC, GST_PAD_ALWAYS, - gst_caps_append (gst_caps_new ("src_float", "audio/x-raw-float", - GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_PROPS), - gst_caps_new ("src_int", "audio/x-raw-float", - GST_AUDIO_INT_PAD_TEMPLATE_PROPS)), - NULL); - - return template; -} +static GstStaticPadTemplate passthrough_sink_template = +GST_STATIC_PAD_TEMPLATE ( + "sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ( + GST_AUDIO_INT_PAD_TEMPLATE_CAPS "; " + GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS + ) +); + +static GstStaticPadTemplate passthrough_src_template = +GST_STATIC_PAD_TEMPLATE ( + "src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ( + GST_AUDIO_INT_PAD_TEMPLATE_CAPS "; " + GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS + ) +); static void passthrough_class_init (GstPassthroughClass *klass); static void passthrough_base_init (GstPassthroughClass *klass); @@ -91,7 +79,7 @@ static void passthrough_init (GstPassthrough *filter); static void passthrough_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); static void passthrough_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); -static GstPadLinkReturn passthrough_connect_sink (GstPad *pad, GstCaps *caps); +static GstPadLinkReturn passthrough_connect_sink (GstPad *pad, const GstCaps *caps); static void passthrough_chain (GstPad *pad, GstData *_data); static void inline passthrough_fast_float_chain (gfloat* data, guint numsamples); @@ -100,21 +88,12 @@ static void inline passthrough_fast_8bit_chain (gint8* data, guint numsamples); static GstElementClass *parent_class = NULL; -static GstBufferPool* -passthrough_get_bufferpool (GstPad *pad) -{ - GstPassthrough *filter; - - filter = GST_PASSTHROUGH (gst_pad_get_parent (pad)); - - return gst_pad_get_bufferpool (filter->srcpad); -} - static GstPadLinkReturn -passthrough_connect_sink (GstPad *pad, GstCaps *caps) +passthrough_connect_sink (GstPad *pad, const GstCaps *caps) { const gchar *mimetype; GstPassthrough *filter; + GstStructure *structure; g_return_val_if_fail (pad != NULL, GST_PAD_LINK_DELAYED); g_return_val_if_fail (caps != NULL, GST_PAD_LINK_DELAYED); @@ -123,18 +102,19 @@ passthrough_connect_sink (GstPad *pad, GstCaps *caps) g_return_val_if_fail (filter != NULL, GST_PAD_LINK_REFUSED); g_return_val_if_fail (GST_IS_PASSTHROUGH (filter), GST_PAD_LINK_REFUSED); - mimetype = gst_caps_get_mime(caps); + structure = gst_caps_get_structure (caps, 0); - gst_caps_get_int (caps, "rate", &filter->rate); - gst_caps_get_int (caps, "channels", &filter->channels); - gst_caps_get_int (caps, "width", &filter->width); - gst_caps_get_int (caps, "endianness", &filter->endianness); + mimetype = gst_structure_get_name (structure); + gst_structure_get_int (structure, "rate", &filter->rate); + gst_structure_get_int (structure, "channels", &filter->channels); + gst_structure_get_int (structure, "width", &filter->width); + gst_structure_get_int (structure, "endianness", &filter->endianness); if (strcmp (mimetype, "audio/x-raw-int") == 0) { filter->format = GST_PASSTHROUGH_FORMAT_INT; - gst_caps_get_int (caps, "depth", &filter->depth); - gst_caps_get_boolean (caps, "signed", &filter->is_signed); + gst_structure_get_int (structure, "depth", &filter->depth); + gst_structure_get_boolean (structure, "signed", &filter->is_signed); if (! filter->silent) { g_print ("Passthrough : channels %d, rate %d\n", filter->channels, filter->rate); @@ -150,9 +130,7 @@ passthrough_connect_sink (GstPad *pad, GstCaps *caps) } } - if (GST_CAPS_IS_FIXED (caps)) - return gst_pad_try_set_caps (filter->srcpad, caps); - return GST_PAD_LINK_DELAYED; + return gst_pad_try_set_caps (filter->srcpad, caps); } GType @@ -182,8 +160,10 @@ passthrough_base_init (GstPassthroughClass *klass) { GstElementClass *element_class = GST_ELEMENT_CLASS (klass); - gst_element_class_add_pad_template (element_class, passthrough_src_factory ()); - gst_element_class_add_pad_template (element_class, passthrough_sink_factory ()); + gst_element_class_add_pad_template (element_class, + gst_static_pad_template_get (&passthrough_src_template)); + gst_element_class_add_pad_template (element_class, + gst_static_pad_template_get (&passthrough_sink_template)); gst_element_class_set_details (element_class, &passthrough_details); } @@ -209,13 +189,14 @@ passthrough_class_init (GstPassthroughClass *klass) static void passthrough_init (GstPassthrough *filter) { - filter->srcpad = gst_pad_new_from_template (passthrough_src_factory (),"src"); + filter->srcpad = gst_pad_new_from_template ( + gst_static_pad_template_get (&passthrough_src_template), "src"); gst_element_add_pad (GST_ELEMENT (filter), filter->srcpad); - filter->sinkpad = gst_pad_new_from_template (passthrough_sink_factory (),"sink"); + filter->sinkpad = gst_pad_new_from_template ( + gst_static_pad_template_get (&passthrough_sink_template), "sink"); gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad); gst_pad_set_link_function (filter->sinkpad, passthrough_connect_sink); - gst_pad_set_bufferpool_function (filter->sinkpad, passthrough_get_bufferpool); gst_pad_set_chain_function (filter->sinkpad, passthrough_chain); filter->silent = FALSE; @@ -237,11 +218,6 @@ passthrough_chain (GstPad *pad, GstData *_data) g_return_if_fail (filter != NULL); g_return_if_fail (GST_IS_PASSTHROUGH (filter)); - filter->bufpool = gst_pad_get_bufferpool (filter->srcpad); - if (filter->bufpool == NULL) { - filter->bufpool = gst_buffer_pool_get_default (PASSTHRU_BUF_SIZE, PASSTHRU_NUM_BUFS); - } - switch (filter->format) { case GST_PASSTHROUGH_FORMAT_INT: int_data = (gint16 *) GST_BUFFER_DATA (buf); diff --git a/gst/passthrough/gstpassthrough.h b/gst/passthrough/gstpassthrough.h index 7d0119b2..0b6f9d58 100644 --- a/gst/passthrough/gstpassthrough.h +++ b/gst/passthrough/gstpassthrough.h @@ -50,7 +50,6 @@ struct _GstPassthrough { GstElement element; GstPad *sinkpad, *srcpad; - GstBufferPool *bufpool; gboolean silent; diff --git a/gst/playondemand/Makefile.am b/gst/playondemand/Makefile.am index a9894c4b..1cfbe766 100644 --- a/gst/playondemand/Makefile.am +++ b/gst/playondemand/Makefile.am @@ -15,5 +15,5 @@ endif demo_mp3_SOURCES = demo-mp3.c gstplayondemand.h ## putting GTK_CFLAGS first fixes a weird compilation error with GTK and XML demo_mp3_CFLAGS = $(GTK_CFLAGS) $(GST_CFLAGS) -demo_mp3_LDFLAGS = $(GST_LIBS) $(GTK_LIBS) libgstplayondemand.la +demo_mp3_LDFLAGS = $(GST_LIBS) $(GTK_LIBS) demo_mp3_DEPENDENCIES = libgstplayondemand.la diff --git a/gst/playondemand/filter.func b/gst/playondemand/filter.func index 3f2755a0..cded073e 100644 --- a/gst/playondemand/filter.func +++ b/gst/playondemand/filter.func @@ -46,7 +46,7 @@ do { out = GST_BUFFER (in); } else { - out = gst_buffer_new_from_pool(filter->bufpool, 0, 0); + out = gst_buffer_new_and_alloc (GST_POD_BUFPOOL_SIZE); } in = NULL; diff --git a/gst/playondemand/gstplayondemand.c b/gst/playondemand/gstplayondemand.c index 39225a79..3313599c 100644 --- a/gst/playondemand/gstplayondemand.c +++ b/gst/playondemand/gstplayondemand.c @@ -41,7 +41,6 @@ #define GST_POD_BUFPOOL_NUM 6 -/* element factory information */ static GstElementDetails play_on_demand_details = { "Play On Demand", "Filter/Editor/Audio", @@ -50,40 +49,27 @@ static GstElementDetails play_on_demand_details = { }; -static GstPadTemplate* -play_on_demand_sink_factory (void) -{ - static GstPadTemplate *template = NULL; - - if (!template) { - template = gst_pad_template_new - ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, - gst_caps_append(gst_caps_new ("sink_int", "audio/x-raw-int", - GST_AUDIO_INT_PAD_TEMPLATE_PROPS), - gst_caps_new ("sink_float", "audio/x-raw-float", - GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_PROPS)), - NULL); - } - return template; -} - - -static GstPadTemplate* -play_on_demand_src_factory (void) -{ - static GstPadTemplate *template = NULL; - - if (!template) - template = gst_pad_template_new - ("src", GST_PAD_SRC, GST_PAD_ALWAYS, - gst_caps_append (gst_caps_new ("src_float", "audio/x-raw-float", - GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_PROPS), - gst_caps_new ("src_int", "audio/x-raw-int", - GST_AUDIO_INT_PAD_TEMPLATE_PROPS)), - NULL); - - return template; -} +static GstStaticPadTemplate play_on_demand_sink_template = +GST_STATIC_PAD_TEMPLATE ( + "sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ( + GST_AUDIO_INT_PAD_TEMPLATE_CAPS "; " + GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS + ) +); + +static GstStaticPadTemplate play_on_demand_src_template = +GST_STATIC_PAD_TEMPLATE ( + "src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ( + GST_AUDIO_INT_PAD_TEMPLATE_CAPS "; " + GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS + ) +); /* GObject functionality */ @@ -95,8 +81,7 @@ static void play_on_demand_get_property (GObject *object, guint prop_id, GValue static void play_on_demand_dispose (GObject *object); /* GStreamer functionality */ -static GstBufferPool* play_on_demand_get_bufferpool (GstPad *pad); -static GstPadLinkReturn play_on_demand_pad_link (GstPad *pad, GstCaps *caps); +static GstPadLinkReturn play_on_demand_pad_link (GstPad *pad, const GstCaps *caps); static void play_on_demand_loop (GstElement *elem); static void play_on_demand_set_clock (GstElement *elem, GstClock *clock); @@ -164,8 +149,10 @@ play_on_demand_base_init (GstPlayOnDemandClass *klass) { GstElementClass *element_class = GST_ELEMENT_CLASS (klass); - gst_element_class_add_pad_template(element_class, play_on_demand_src_factory()); - gst_element_class_add_pad_template(element_class, play_on_demand_sink_factory()); + gst_element_class_add_pad_template(element_class, + gst_static_pad_template_get(&play_on_demand_src_template)); + gst_element_class_add_pad_template(element_class, + gst_static_pad_template_get(&play_on_demand_sink_template)); gst_element_class_set_details(element_class, &play_on_demand_details); } @@ -243,10 +230,11 @@ play_on_demand_class_init (GstPlayOnDemandClass *klass) static void play_on_demand_init (GstPlayOnDemand *filter) { - filter->srcpad = gst_pad_new_from_template(play_on_demand_src_factory(), "src"); - filter->sinkpad = gst_pad_new_from_template(play_on_demand_sink_factory(), "sink"); + filter->srcpad = gst_pad_new_from_template( + gst_static_pad_template_get(&play_on_demand_src_template), "src"); + filter->sinkpad = gst_pad_new_from_template( + gst_static_pad_template_get(&play_on_demand_sink_template), "sink"); - gst_pad_set_bufferpool_function(filter->sinkpad, play_on_demand_get_bufferpool); gst_pad_set_link_function(filter->sinkpad, play_on_demand_pad_link); gst_element_add_pad(GST_ELEMENT(filter), filter->sinkpad); @@ -376,41 +364,34 @@ play_on_demand_dispose (GObject *object) g_free (filter->buffer); } -static GstBufferPool* -play_on_demand_get_bufferpool (GstPad *pad) -{ - GstPlayOnDemand *filter; - filter = GST_PLAYONDEMAND(gst_pad_get_parent(pad)); - return gst_pad_get_bufferpool(filter->srcpad); -} - static GstPadLinkReturn -play_on_demand_pad_link (GstPad *pad, GstCaps *caps) +play_on_demand_pad_link (GstPad *pad, const GstCaps *caps) { const gchar *mimetype; GstPlayOnDemand *filter; + GstStructure *structure; g_return_val_if_fail(caps != NULL, GST_PAD_LINK_DELAYED); g_return_val_if_fail(pad != NULL, GST_PAD_LINK_DELAYED); filter = GST_PLAYONDEMAND(GST_PAD_PARENT(pad)); - mimetype = gst_caps_get_mime(caps); - gst_caps_get_int(caps, "rate", &filter->rate); - gst_caps_get_int(caps, "channels", &filter->channels); + structure = gst_caps_get_structure (caps, 0); + + mimetype = gst_structure_get_name (structure); + gst_structure_get_int (structure, "rate", &filter->rate); + gst_structure_get_int (structure, "channels", &filter->channels); if (strcmp(mimetype, "audio/x-raw-int") == 0) { filter->format = GST_PLAYONDEMAND_FORMAT_INT; - gst_caps_get_int (caps, "width", &filter->width); + gst_structure_get_int (structure, "width", &filter->width); } else if (strcmp(mimetype, "audio/x-raw-float") == 0) { filter->format = GST_PLAYONDEMAND_FORMAT_FLOAT; } play_on_demand_resize_buffer(filter); - if (GST_CAPS_IS_FIXED (caps)) - return gst_pad_try_set_caps (filter->srcpad, caps); - return GST_PAD_LINK_DELAYED; + return gst_pad_try_set_caps (filter->srcpad, caps); } inline static void @@ -442,12 +423,6 @@ play_on_demand_loop (GstElement *elem) g_return_if_fail(filter != NULL); g_return_if_fail(GST_IS_PLAYONDEMAND(filter)); - filter->bufpool = gst_pad_get_bufferpool(filter->srcpad); - - if (filter->bufpool == NULL) - filter->bufpool = gst_buffer_pool_get_default(GST_POD_BUFPOOL_SIZE, - GST_POD_BUFPOOL_NUM); - in = (in == NULL && ! filter->eos) ? gst_pad_pull(filter->sinkpad) : NULL; if (filter->format == GST_PLAYONDEMAND_FORMAT_INT) { diff --git a/gst/playondemand/gstplayondemand.h b/gst/playondemand/gstplayondemand.h index 8c7fa212..c99c8165 100644 --- a/gst/playondemand/gstplayondemand.h +++ b/gst/playondemand/gstplayondemand.h @@ -53,7 +53,6 @@ enum _GstPlayOnDemandFormat { struct _GstPlayOnDemand { GstElement element; - GstBufferPool *bufpool; GstPad *sinkpad, *srcpad; GstClock *clock; diff --git a/gst/qtdemux/qtdemux.c b/gst/qtdemux/qtdemux.c index 623f69b2..e1fc8712 100644 --- a/gst/qtdemux/qtdemux.c +++ b/gst/qtdemux/qtdemux.c @@ -111,23 +111,30 @@ enum { ARG_0 }; -GST_PAD_TEMPLATE_FACTORY (sink_templ, +static GstStaticPadTemplate gst_qtdemux_sink_template = +GST_STATIC_PAD_TEMPLATE ( "sink", GST_PAD_SINK, - GST_PAD_ALWAYS, - GST_CAPS_NEW ( - "qtdemux_sink", - "video/quicktime", - NULL - ), - GST_CAPS_NEW ( - "qtdemux_sink", - "audio/x-m4a", - NULL - ) -) + GST_PAD_SOMETIMES, + GST_STATIC_CAPS_ANY +); + +static GstStaticPadTemplate gst_qtdemux_videosrc_template = +GST_STATIC_PAD_TEMPLATE ( + "audio_%02d", + GST_PAD_SRC, + GST_PAD_SOMETIMES, + GST_STATIC_CAPS_ANY +); + +static GstStaticPadTemplate gst_qtdemux_audiosrc_template = +GST_STATIC_PAD_TEMPLATE ( + "video_%02d", + GST_PAD_SRC, + GST_PAD_SOMETIMES, + GST_STATIC_CAPS_ANY +); -static GstPadTemplate *videosrctempl, *audiosrctempl; static GstElementClass *parent_class = NULL; static void gst_qtdemux_class_init (GstQTDemuxClass *klass); @@ -167,10 +174,13 @@ static void gst_qtdemux_base_init (GstQTDemuxClass *klass) GstElementClass *element_class = GST_ELEMENT_CLASS (klass); gst_element_class_add_pad_template (element_class, - GST_PAD_TEMPLATE_GET (sink_templ)); - gst_element_class_add_pad_template (element_class, videosrctempl); - gst_element_class_add_pad_template (element_class, audiosrctempl); + gst_static_pad_template_get (&gst_qtdemux_sink_template)); + gst_element_class_add_pad_template (element_class, + gst_static_pad_template_get (&gst_qtdemux_videosrc_template)); + gst_element_class_add_pad_template (element_class, + gst_static_pad_template_get (&gst_qtdemux_audiosrc_template)); gst_element_class_set_details (element_class, &gst_qtdemux_details); + } static void gst_qtdemux_class_init (GstQTDemuxClass *klass) @@ -189,14 +199,17 @@ static void gst_qtdemux_class_init (GstQTDemuxClass *klass) static void gst_qtdemux_init (GstQTDemux *qtdemux) { - qtdemux->sinkpad = gst_pad_new_from_template (GST_PAD_TEMPLATE_GET (sink_templ), "sink"); - gst_element_set_loop_function (GST_ELEMENT (qtdemux), gst_qtdemux_loop_header); + qtdemux->sinkpad = gst_pad_new_from_template ( + gst_static_pad_template_get (&gst_qtdemux_sink_template), "sink"); + gst_element_set_loop_function (GST_ELEMENT (qtdemux), + gst_qtdemux_loop_header); gst_element_add_pad (GST_ELEMENT (qtdemux), qtdemux->sinkpad); } static gboolean plugin_init (GstPlugin *plugin) { +#if 0 GstCaps *audiocaps = NULL, *videocaps = NULL, *temp; const guint32 audio_fcc[] = { /* FILLME */ @@ -227,6 +240,7 @@ plugin_init (GstPlugin *plugin) GST_PAD_SRC, GST_PAD_SOMETIMES, videocaps, NULL); +#endif return gst_element_register (plugin, "qtdemux", GST_RANK_PRIMARY, GST_TYPE_QTDEMUX); @@ -484,9 +498,8 @@ static void gst_qtdemux_loop_header (GstElement *element) if(stream->subtype == GST_MAKE_FOURCC('v','i','d','e')){ float fps = 1. * GST_SECOND / stream->samples[stream->sample_index].duration; if (fps != stream->fps) { - gst_props_remove_entry_by_name(stream->caps->properties, "framerate"); - gst_props_add_entry(stream->caps->properties, - gst_props_entry_new("framerate", GST_PROPS_FLOAT(fps))); + gst_caps_set_simple (stream->caps, "framerate", G_TYPE_DOUBLE, fps, + NULL); stream->fps = fps; gst_pad_try_set_caps(stream->pad, stream->caps); } @@ -506,11 +519,10 @@ static void gst_qtdemux_loop_header (GstElement *element) } -static GstCaps *gst_qtdemux_src_getcaps(GstPad *pad, GstCaps *caps) +static GstCaps *gst_qtdemux_src_getcaps(GstPad *pad) { GstQTDemux *qtdemux; QtDemuxStream *stream; - int i; GST_DEBUG ("gst_qtdemux_src_getcaps"); @@ -518,20 +530,12 @@ static GstCaps *gst_qtdemux_src_getcaps(GstPad *pad, GstCaps *caps) g_return_val_if_fail(GST_IS_QTDEMUX(qtdemux), NULL); - GST_DEBUG ("looking for pad %p in qtdemux %p", pad, qtdemux); - GST_DEBUG ("n_streams is %d", qtdemux->n_streams); - for(i=0;i<qtdemux->n_streams;i++){ - stream = qtdemux->streams[i]; - if(stream->pad == pad){ - return stream->caps; - } - } - - GST_DEBUG ("Couldn't find stream cooresponding to pad\n"); - - return NULL; + stream = GST_PAD_ELEMENT_PRIVATE (pad); + return gst_caps_copy(stream->caps); } +#if 0 +/* This function doesn't do anything useful, but might be useful later */ static GstPadLinkReturn gst_qtdemux_src_link(GstPad *pad, GstCaps *caps) { @@ -559,42 +563,40 @@ gst_qtdemux_src_link(GstPad *pad, GstCaps *caps) return GST_PAD_LINK_REFUSED; } +#endif void gst_qtdemux_add_stream(GstQTDemux *qtdemux, QtDemuxStream *stream) { if(stream->subtype == GST_MAKE_FOURCC('v','i','d','e')){ - stream->pad = gst_pad_new_from_template (videosrctempl, + stream->pad = gst_pad_new_from_template ( + gst_static_pad_template_get(&gst_qtdemux_videosrc_template), g_strdup_printf ("video_%02d", qtdemux->n_video_streams)); stream->fps = 1. * GST_SECOND / stream->samples[0].duration; if(stream->caps){ - GstProps *properties = gst_props_intersect( - stream->caps->properties, - gst_props_new("width",GST_PROPS_INT(stream->width), - "height",GST_PROPS_INT(stream->height), - "framerate", GST_PROPS_FLOAT(stream->fps), NULL)); - if (stream->caps->properties != NULL) - gst_props_unref (stream->caps->properties); - stream->caps->properties = properties; + gst_caps_set_simple(stream->caps, + "width", G_TYPE_INT, stream->width, + "height", G_TYPE_INT, stream->height, + "framerate", G_TYPE_DOUBLE, stream->fps, NULL); } qtdemux->n_video_streams++; }else{ - stream->pad = gst_pad_new_from_template (audiosrctempl, + stream->pad = gst_pad_new_from_template ( + gst_static_pad_template_get(&gst_qtdemux_audiosrc_template), g_strdup_printf ("audio_%02d", qtdemux->n_audio_streams)); if(stream->caps){ - GstProps *properties = gst_props_intersect( - stream->caps->properties, - gst_props_new("rate",GST_PROPS_INT((int)stream->rate), - "channels",GST_PROPS_INT(stream->n_channels), NULL)); - if (stream->caps->properties != NULL) - gst_props_unref (stream->caps->properties); - stream->caps->properties = properties; + gst_caps_set_simple(stream->caps, + "rate", G_TYPE_INT, (int)stream->rate, + "channels", G_TYPE_INT, stream->n_channels, NULL); } qtdemux->n_audio_streams++; } gst_pad_set_getcaps_function(stream->pad, gst_qtdemux_src_getcaps); +#ifdef unused gst_pad_set_link_function(stream->pad, gst_qtdemux_src_link); +#endif + GST_PAD_ELEMENT_PRIVATE(stream->pad) = stream; qtdemux->streams[qtdemux->n_streams] = stream; qtdemux->n_streams++; GST_DEBUG ("n_streams is now %d", qtdemux->n_streams); @@ -604,7 +606,7 @@ void gst_qtdemux_add_stream(GstQTDemux *qtdemux, QtDemuxStream *stream) /* Note: we need to have everything set up before calling try_set_caps */ if(stream->caps){ - g_print("setting caps to %s\n",gst_caps_to_string(stream->caps)); + GST_DEBUG_CAPS ("setting caps",stream->caps); gst_pad_try_set_caps(stream->pad, stream->caps); } @@ -1358,11 +1360,6 @@ static void qtdemux_parse_trak(GstQTDemux *qtdemux, GNode *trak) return; } - if(stream->caps){ - gst_caps_ref(stream->caps); - gst_caps_sink(stream->caps); - } - /* sample to chunk */ stsc = qtdemux_tree_get_child_by_type(stbl, FOURCC_stsc); g_assert(stsc); @@ -1528,87 +1525,51 @@ static GstCaps *qtdemux_video_caps(GstQTDemux *qtdemux, guint32 fourcc) switch(fourcc){ case GST_MAKE_FOURCC('j','p','e','g'): /* JPEG */ - return GST_CAPS_NEW("jpeg_caps","image/jpeg", - "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT), - "width", GST_PROPS_INT_RANGE (16, 4096), - "height", GST_PROPS_INT_RANGE (16, 4096)); + return gst_caps_from_string ("image/jpeg"); case GST_MAKE_FOURCC('m','j','p','a'): /* Motion-JPEG (format A) */ - return GST_CAPS_NEW("mjpa_caps","image/jpeg", - "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT), - "width", GST_PROPS_INT_RANGE (16, 4096), - "height", GST_PROPS_INT_RANGE (16, 4096)); + return gst_caps_from_string ("image/jpeg"); case GST_MAKE_FOURCC('m','j','p','b'): /* Motion-JPEG (format B) */ - return GST_CAPS_NEW("mjpb_caps","image/jpeg", - "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT), - "width", GST_PROPS_INT_RANGE (16, 4096), - "height", GST_PROPS_INT_RANGE (16, 4096)); + return gst_caps_from_string ("image/jpeg"); case GST_MAKE_FOURCC('S','V','Q','3'): - return GST_CAPS_NEW("SVQ3_caps","video/x-svq", - "svqversion", GST_PROPS_INT(3), - "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT), - "width", GST_PROPS_INT_RANGE (16, 4096), - "height", GST_PROPS_INT_RANGE (16, 4096)); + return gst_caps_from_string ("video/x-svq, " + "svqversion = (int) 3"); case GST_MAKE_FOURCC('s','v','q','i'): case GST_MAKE_FOURCC('S','V','Q','1'): - return GST_CAPS_NEW("SVQ1_caps","video/x-svq", - "svqversion", GST_PROPS_INT(1), - "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT), - "width", GST_PROPS_INT_RANGE (16, 4096), - "height", GST_PROPS_INT_RANGE (16, 4096)); + return gst_caps_from_string ("video/x-svq, " + "svqversion = (int) 1"); case GST_MAKE_FOURCC('r','a','w',' '): /* uncompressed RGB */ - return GST_CAPS_NEW("raw__caps","video/x-raw-rgb", - "endianness",GST_PROPS_INT(G_BIG_ENDIAN), + return gst_caps_from_string ("video/x-raw-rgb, " + "endianness = (int) BIG_ENDIAN"); /*"bpp", GST_PROPS_INT(x), "depth", GST_PROPS_INT(x), "red_mask", GST_PROPS_INT(x), "green_mask", GST_PROPS_INT(x), "blue_mask", GST_PROPS_INT(x), FIXME! */ - "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT), - "width", GST_PROPS_INT_RANGE (16, 4096), - "height", GST_PROPS_INT_RANGE (16, 4096)); case GST_MAKE_FOURCC('Y','u','v','2'): /* uncompressed YUV2 */ - return GST_CAPS_NEW("Yuv2_caps","video/x-raw-yuv", - "format",GST_PROPS_FOURCC(GST_MAKE_FOURCC('Y','U','V','2')), - "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT), - "width", GST_PROPS_INT_RANGE (16, 4096), - "height", GST_PROPS_INT_RANGE (16, 4096)); + return gst_caps_from_string ("video/x-raw-yuv, " + "format = (fourcc) YUY2"); case GST_MAKE_FOURCC('m','p','e','g'): /* MPEG */ - return GST_CAPS_NEW("mpeg_caps","video/mpeg", - "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT), - "width", GST_PROPS_INT_RANGE (16, 4096), - "height", GST_PROPS_INT_RANGE (16, 4096), - "systemstream", GST_PROPS_BOOLEAN(FALSE), - "mpegversion", GST_PROPS_INT(1)); + return gst_caps_from_string ("video/mpeg, " + "systemstream = (boolean) false, " + "mpegversion = (int) 1"); case GST_MAKE_FOURCC('g','i','f',' '): - return GST_CAPS_NEW("gif__caps","image/gif", - "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT), - "width", GST_PROPS_INT_RANGE (16, 4096), - "height", GST_PROPS_INT_RANGE (16, 4096)); + return gst_caps_from_string ("image/gif"); case GST_MAKE_FOURCC('h','2','6','3'): /* H.263 */ /* ffmpeg uses the height/width props, don't know why */ - return GST_CAPS_NEW("h263_caps","video/x-h263", - "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT), - "width", GST_PROPS_INT_RANGE (16, 4096), - "height", GST_PROPS_INT_RANGE (16, 4096)); + return gst_caps_from_string ("video/x-h263"); case GST_MAKE_FOURCC('m','p','4','v'): /* MPEG-4 */ - return GST_CAPS_NEW("mp4v_caps", "video/mpeg", - "mpegversion",GST_PROPS_INT(4), - "systemstream", GST_PROPS_BOOLEAN(FALSE), - "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT), - "width", GST_PROPS_INT_RANGE (16, 4096), - "height", GST_PROPS_INT_RANGE (16, 4096)); + return gst_caps_from_string ("video/mpeg, " + "mpegversion = (int) 4, " + "systemstream = (boolean) false"); case GST_MAKE_FOURCC('3','I','V','1'): - return GST_CAPS_NEW("3IV1_caps", "video/x-3ivx", - "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT), - "width", GST_PROPS_INT_RANGE (16, 4096), - "height", GST_PROPS_INT_RANGE (16, 4096)); + return gst_caps_from_string ("video/x-3ivx"); case GST_MAKE_FOURCC('r','p','z','a'): case GST_MAKE_FOURCC('c','v','i','d'): /* Cinepak */ @@ -1617,7 +1578,7 @@ static GstCaps *qtdemux_video_caps(GstQTDemux *qtdemux, guint32 fourcc) case GST_MAKE_FOURCC('s','m','c',' '): case GST_MAKE_FOURCC('k','p','c','d'): default: - g_print("Don't know how to convert fourcc '" GST_FOURCC_FORMAT + g_critical ("Don't know how to convert fourcc '" GST_FOURCC_FORMAT "' to caps\n", GST_FOURCC_ARGS(fourcc)); return NULL; } @@ -1627,130 +1588,89 @@ static GstCaps *qtdemux_audio_caps(GstQTDemux *qtdemux, guint32 fourcc) { switch(fourcc){ case GST_MAKE_FOURCC('N','O','N','E'): - return NULL; /*GST_CAPS_NEW("NONE_caps","audio/raw",NULL);*/ + return NULL; /*gst_caps_from_string ("audio/raw");*/ case GST_MAKE_FOURCC('r','a','w',' '): /* FIXME */ - return GST_CAPS_NEW("raw__caps","audio/x-raw-int", - "width",GST_PROPS_INT(8), - "depth",GST_PROPS_INT(8), - "signed",GST_PROPS_BOOLEAN(FALSE), - "rate",GST_PROPS_INT_RANGE(1,G_MAXINT), - "channels",GST_PROPS_INT_RANGE(1,G_MAXINT)); + return gst_caps_from_string ("audio/x-raw-int, " + "width = (int) 8, " + "depth = (int) 8, " + "signed = (boolean) true"); case GST_MAKE_FOURCC('t','w','o','s'): /* FIXME */ - return GST_CAPS_NEW("twos_caps","audio/x-raw-int", - "width",GST_PROPS_INT(16), - "depth",GST_PROPS_INT(16), - "endianness",GST_PROPS_INT(G_BIG_ENDIAN), - "signed",GST_PROPS_BOOLEAN(TRUE), - "rate",GST_PROPS_INT_RANGE(1,G_MAXINT), - "channels",GST_PROPS_INT_RANGE(1,G_MAXINT)); + return gst_caps_from_string ("audio/x-raw-int, " + "width = (int) 16, " + "depth = (int) 16, " + "endianness = (int) G_BIG_ENDIAN, " + "signed = (boolean) true"); case GST_MAKE_FOURCC('s','o','w','t'): /* FIXME */ - return GST_CAPS_NEW("sowt_caps","audio/x-raw-int", - "width",GST_PROPS_INT(16), - "depth",GST_PROPS_INT(16), - "endianness",GST_PROPS_INT(G_LITTLE_ENDIAN), - "signed",GST_PROPS_BOOLEAN(TRUE), - "rate",GST_PROPS_INT_RANGE(1,G_MAXINT), - "channels",GST_PROPS_INT_RANGE(1,G_MAXINT)); + return gst_caps_from_string ("audio/x-raw-int, " + "width = (int) 16, " + "depth = (int) 16, " + "endianness = (int) G_LITTLE_ENDIAN, " + "signed = (boolean) true"); case GST_MAKE_FOURCC('f','l','6','4'): - return GST_CAPS_NEW("fl64_caps","audio/x-raw-float", - "width",GST_PROPS_INT (64), - "endianness",GST_PROPS_INT (G_BIG_ENDIAN), - "rate",GST_PROPS_INT_RANGE(1,G_MAXINT), - "channels",GST_PROPS_INT_RANGE(1,G_MAXINT)); + return gst_caps_from_string ("audio/x-raw-float, " + "width = (int) 64, " + "endianness = (int) G_BIG_ENDIAN"); case GST_MAKE_FOURCC('f','l','3','2'): - return GST_CAPS_NEW("fl32_caps","audio/x-raw-float", - "width",GST_PROPS_INT (32), - "endianness",GST_PROPS_INT (G_BIG_ENDIAN), - "rate",GST_PROPS_INT_RANGE(1,G_MAXINT), - "channels",GST_PROPS_INT_RANGE(1,G_MAXINT)); + return gst_caps_from_string ("audio/x-raw-float, " + "width = (int) 32, " + "endianness = (int) G_BIG_ENDIAN"); case GST_MAKE_FOURCC('i','n','2','4'): /* FIXME */ - return GST_CAPS_NEW("in24_caps","audio/x-raw-int", - "width",GST_PROPS_INT(24), - "depth",GST_PROPS_INT(32), - "endianness",GST_PROPS_INT(G_BIG_ENDIAN), - "signed",GST_PROPS_BOOLEAN(TRUE), - "rate",GST_PROPS_INT_RANGE(1,G_MAXINT), - "channels",GST_PROPS_INT_RANGE(1,G_MAXINT)); + return gst_caps_from_string ("audio/x-raw-int, " + "width = (int) 24, " + "depth = (int) 32, " + "endianness = (int) G_BIG_ENDIAN, " + "signed = (boolean) true"); case GST_MAKE_FOURCC('i','n','3','2'): /* FIXME */ - return GST_CAPS_NEW("in32_caps","audio/x-raw-int", - "width",GST_PROPS_INT(24), - "depth",GST_PROPS_INT(32), - "endianness",GST_PROPS_INT(G_BIG_ENDIAN), - "rate",GST_PROPS_INT_RANGE(1,G_MAXINT), - "channels",GST_PROPS_INT_RANGE(1,G_MAXINT)); + return gst_caps_from_string ("audio/x-raw-int, " + "width = (int) 32, " + "depth = (int) 32, " + "endianness = (int) G_BIG_ENDIAN, " + "signed = (boolean) true"); case GST_MAKE_FOURCC('u','l','a','w'): /* FIXME */ - return GST_CAPS_NEW("ulaw_caps","audio/x-mulaw", - "rate",GST_PROPS_INT_RANGE(1,G_MAXINT), - "channels",GST_PROPS_INT_RANGE(1,G_MAXINT)); + return gst_caps_from_string ("audio/x-mulaw"); case GST_MAKE_FOURCC('a','l','a','w'): /* FIXME */ - return GST_CAPS_NEW("alaw_caps","audio/x-alaw", - "rate",GST_PROPS_INT_RANGE(1,G_MAXINT), - "channels",GST_PROPS_INT_RANGE(1,G_MAXINT)); + return gst_caps_from_string ("audio/x-alaw"); case 0x6d730002: /* Microsoft ADPCM-ACM code 2 */ - return GST_CAPS_NEW("msxx_caps","audio/x-adpcm", - "layout", GST_PROPS_STRING("microsoft"), - "rate",GST_PROPS_INT_RANGE(1,G_MAXINT), - "channels",GST_PROPS_INT_RANGE(1,G_MAXINT), - NULL); + return gst_caps_from_string ("audio/x-adpcm, " + "layout = (string) microsoft"); case 0x6d730011: /* FIXME DVI/Intel IMA ADPCM/ACM code 17 */ - return GST_CAPS_NEW("msxx_caps","audio/x-adpcm", - "layout", GST_PROPS_STRING("quicktime"), - "rate",GST_PROPS_INT_RANGE(1,G_MAXINT), - "channels",GST_PROPS_INT_RANGE(1,G_MAXINT), - NULL); + return gst_caps_from_string ("audio/x-adpcm, " + "layout = (string) quicktime"); case 0x6d730055: /* MPEG layer 3, CBR only (pre QT4.1) */ case 0x5500736d: case GST_MAKE_FOURCC('.','m','p','3'): /* MPEG layer 3, CBR & VBR (QT4.1 and later) */ - return GST_CAPS_NEW("_mp3_caps","audio/mpeg", - "mpegversion", GST_PROPS_INT(1), - "layer", GST_PROPS_INT(3), - "rate",GST_PROPS_INT_RANGE(1,G_MAXINT), - "channels",GST_PROPS_INT_RANGE(1,G_MAXINT), - NULL); + return gst_caps_from_string ("audio/mpeg, " + "layer = (int) 3, " + "mpegversion = (int) 1"); case GST_MAKE_FOURCC('M','A','C','3'): /* MACE 3:1 */ - return GST_CAPS_NEW("MAC3_caps","audio/x-mace", - "maceversion",GST_PROPS_INT(3), - "rate",GST_PROPS_INT_RANGE(1,G_MAXINT), - "channels",GST_PROPS_INT_RANGE(1,G_MAXINT), - NULL); + return gst_caps_from_string ("audio/x-mace, " + "maceversion = (int) 3"); case GST_MAKE_FOURCC('M','A','C','6'): /* MACE 6:1 */ - return GST_CAPS_NEW("MAC3_caps","audio/x-mace", - "maceversion",GST_PROPS_INT(6), - "rate",GST_PROPS_INT_RANGE(1,G_MAXINT), - "channels",GST_PROPS_INT_RANGE(1,G_MAXINT), - NULL); + return gst_caps_from_string ("audio/x-mace, " + "maceversion = (int) 6"); case GST_MAKE_FOURCC('O','g','g','V'): /* Ogg Vorbis */ - return GST_CAPS_NEW("OggV_caps","application/ogg", - "rate",GST_PROPS_INT_RANGE(1,G_MAXINT), - "channels",GST_PROPS_INT_RANGE(1,G_MAXINT), - NULL); + return gst_caps_from_string ("application/ogg"); case GST_MAKE_FOURCC('d','v','c','a'): /* DV audio */ - return GST_CAPS_NEW("dvca_caps","audio/x-dv", - "rate",GST_PROPS_INT_RANGE(1,G_MAXINT), - "channels",GST_PROPS_INT_RANGE(1,G_MAXINT), - NULL); + return gst_caps_from_string ("audio/x-dv"); case GST_MAKE_FOURCC('m','p','4','a'): /* MPEG-4 AAC */ - return GST_CAPS_NEW("mp4a_caps", "audio/mpeg", - "mpegversion", GST_PROPS_INT(4), - "rate", GST_PROPS_INT_RANGE(1, G_MAXINT), - "channels", GST_PROPS_INT_RANGE(1, G_MAXINT), - "systemstream", GST_PROPS_BOOLEAN(FALSE), NULL); + return gst_caps_from_string ("audio/mpeg, " + "mpegversion = (int) 4"); case GST_MAKE_FOURCC('q','t','v','r'): /* ? */ case GST_MAKE_FOURCC('Q','D','M','2'): @@ -1764,7 +1684,7 @@ static GstCaps *qtdemux_audio_caps(GstQTDemux *qtdemux, guint32 fourcc) case GST_MAKE_FOURCC('a','g','s','m'): /* ? */ default: - g_print("Don't know how to convert fourcc '" GST_FOURCC_FORMAT + g_critical ("Don't know how to convert fourcc '" GST_FOURCC_FORMAT "' to caps\n", GST_FOURCC_ARGS(fourcc)); return NULL; } diff --git a/gst/smooth/gstsmooth.c b/gst/smooth/gstsmooth.c index b0f20938..6e38fe86 100644 --- a/gst/smooth/gstsmooth.c +++ b/gst/smooth/gstsmooth.c @@ -47,29 +47,25 @@ enum { ARG_LUM_ONLY }; -GST_PAD_TEMPLATE_FACTORY (smooth_src_factory, +static GstStaticPadTemplate gst_smooth_src_template = +GST_STATIC_PAD_TEMPLATE ( "src", GST_PAD_SRC, GST_PAD_ALWAYS, - gst_caps_new ( - "smooth_src", - "video/x-raw-yuv", - GST_VIDEO_YUV_PAD_TEMPLATE_PROPS( - GST_PROPS_FOURCC (GST_STR_FOURCC ("I420"))) + GST_STATIC_CAPS ( + GST_VIDEO_YUV_PAD_TEMPLATE_CAPS("I420") ) -) +); -GST_PAD_TEMPLATE_FACTORY (smooth_sink_factory, +static GstStaticPadTemplate gst_smooth_sink_template = +GST_STATIC_PAD_TEMPLATE ( "sink", GST_PAD_SINK, GST_PAD_ALWAYS, - gst_caps_new ( - "smooth_src", - "video/x-raw-yuv", - GST_VIDEO_YUV_PAD_TEMPLATE_PROPS( - GST_PROPS_FOURCC (GST_STR_FOURCC ("I420"))) + GST_STATIC_CAPS ( + GST_VIDEO_YUV_PAD_TEMPLATE_CAPS("I420") ) -) +); static void gst_smooth_class_init (GstSmoothClass *klass); static void gst_smooth_base_init (GstSmoothClass *klass); @@ -113,9 +109,9 @@ gst_smooth_base_init (GstSmoothClass *klass) GstElementClass *element_class = GST_ELEMENT_CLASS (klass); gst_element_class_add_pad_template (element_class, - GST_PAD_TEMPLATE_GET (smooth_sink_factory)); + gst_static_pad_template_get (&gst_smooth_sink_template)); gst_element_class_add_pad_template (element_class, - GST_PAD_TEMPLATE_GET (smooth_src_factory)); + gst_static_pad_template_get (&gst_smooth_src_template)); gst_element_class_set_details (element_class, &smooth_details); } @@ -146,17 +142,19 @@ gst_smooth_class_init (GstSmoothClass *klass) } static GstPadLinkReturn -gst_smooth_sinkconnect (GstPad *pad, GstCaps *caps) +gst_smooth_link (GstPad *pad, const GstCaps *caps) { GstSmooth *filter; + GstStructure *structure; + gboolean ret; filter = GST_SMOOTH (gst_pad_get_parent (pad)); - if (!GST_CAPS_IS_FIXED (caps)) - return GST_PAD_LINK_DELAYED; + structure = gst_caps_get_structure (caps, 0); + ret = gst_structure_get_int (structure, "width", &filter->width); + ret &= gst_structure_get_int (structure, "height", &filter->height); - gst_caps_get_int (caps, "width", &filter->width); - gst_caps_get_int (caps, "height", &filter->height); + if (!ret) return GST_PAD_LINK_REFUSED; return gst_pad_try_set_caps (filter->srcpad, caps); } @@ -165,13 +163,14 @@ static void gst_smooth_init (GstSmooth *smooth) { smooth->sinkpad = gst_pad_new_from_template ( - GST_PAD_TEMPLATE_GET (smooth_sink_factory), "sink"); - gst_pad_set_link_function (smooth->sinkpad, gst_smooth_sinkconnect); + gst_static_pad_template_get (&gst_smooth_sink_template), "sink"); + gst_pad_set_link_function (smooth->sinkpad, gst_smooth_link); gst_pad_set_chain_function (smooth->sinkpad, gst_smooth_chain); gst_element_add_pad (GST_ELEMENT (smooth), smooth->sinkpad); smooth->srcpad = gst_pad_new_from_template ( - GST_PAD_TEMPLATE_GET (smooth_src_factory), "src"); + gst_static_pad_template_get (&gst_smooth_sink_template), "src"); + gst_pad_set_link_function (smooth->srcpad, gst_smooth_link); gst_element_add_pad (GST_ELEMENT (smooth), smooth->srcpad); smooth->active = TRUE; diff --git a/gst/smpte/gstsmpte.c b/gst/smpte/gstsmpte.c index fb51667a..fffc4caa 100644 --- a/gst/smpte/gstsmpte.c +++ b/gst/smpte/gstsmpte.c @@ -33,41 +33,35 @@ static GstElementDetails smpte_details = { "Wim Taymans <wim.taymans@chello.be>" }; -GST_PAD_TEMPLATE_FACTORY (smpte_src_factory, +static GstStaticPadTemplate gst_smpte_src_template = +GST_STATIC_PAD_TEMPLATE ( "src", GST_PAD_SRC, GST_PAD_ALWAYS, - gst_caps_new ( - "smpte_src", - "video/x-raw-yuv", - GST_VIDEO_YUV_PAD_TEMPLATE_PROPS( - GST_PROPS_FOURCC (GST_STR_FOURCC ("I420"))) + GST_STATIC_CAPS ( + GST_VIDEO_YUV_PAD_TEMPLATE_CAPS("I420") ) -) +); -GST_PAD_TEMPLATE_FACTORY (smpte_sink1_factory, +static GstStaticPadTemplate gst_smpte_sink1_template = +GST_STATIC_PAD_TEMPLATE ( "sink1", GST_PAD_SINK, GST_PAD_ALWAYS, - gst_caps_new ( - "smpte_sink1", - "video/x-raw-yuv", - GST_VIDEO_YUV_PAD_TEMPLATE_PROPS( - GST_PROPS_FOURCC (GST_STR_FOURCC ("I420"))) + GST_STATIC_CAPS ( + GST_VIDEO_YUV_PAD_TEMPLATE_CAPS("I420") ) -) +); -GST_PAD_TEMPLATE_FACTORY (smpte_sink2_factory, +static GstStaticPadTemplate gst_smpte_sink2_template = +GST_STATIC_PAD_TEMPLATE ( "sink2", GST_PAD_SINK, GST_PAD_ALWAYS, - gst_caps_new ( - "smpte_sink2", - "video/x-raw-yuv", - GST_VIDEO_YUV_PAD_TEMPLATE_PROPS( - GST_PROPS_FOURCC (GST_STR_FOURCC ("I420"))) + GST_STATIC_CAPS ( + GST_VIDEO_YUV_PAD_TEMPLATE_CAPS("I420") ) -) +); /* SMPTE signals and args */ @@ -158,11 +152,11 @@ gst_smpte_base_init (GstSMPTEClass *klass) GstElementClass *element_class = GST_ELEMENT_CLASS (klass); gst_element_class_add_pad_template (element_class, - GST_PAD_TEMPLATE_GET (smpte_sink1_factory)); + gst_static_pad_template_get(&gst_smpte_sink1_template)); gst_element_class_add_pad_template (element_class, - GST_PAD_TEMPLATE_GET (smpte_sink2_factory)); + gst_static_pad_template_get(&gst_smpte_sink2_template)); gst_element_class_add_pad_template (element_class, - GST_PAD_TEMPLATE_GET (smpte_src_factory)); + gst_static_pad_template_get(&gst_smpte_src_template)); gst_element_class_set_details (element_class, &smpte_details); } @@ -236,40 +230,42 @@ gst_smpte_update_mask (GstSMPTE *smpte, gint type, gint depth, gint width, gint } static gboolean -gst_smpte_sinkconnect (GstPad *pad, GstCaps *caps) +gst_smpte_sinkconnect (GstPad *pad, const GstCaps *caps) { GstSMPTE *smpte; + GstStructure *structure; + gboolean ret; smpte = GST_SMPTE (gst_pad_get_parent (pad)); - if (!GST_CAPS_IS_FIXED (caps)) - return GST_PAD_LINK_DELAYED; + structure = gst_caps_get_structure (caps, 0); - gst_caps_get_int (caps, "width", &smpte->width); - gst_caps_get_int (caps, "height", &smpte->height); - gst_caps_get_float (caps, "framerate", &smpte->fps); + ret = gst_structure_get_int (structure, "width", &smpte->width); + ret &= gst_structure_get_int (structure, "height", &smpte->height); + ret &= gst_structure_get_double (structure, "framerate", &smpte->fps); + if (!ret) return GST_PAD_LINK_REFUSED; gst_smpte_update_mask (smpte, smpte->type, smpte->depth, smpte->width, smpte->height); /* forward to the next plugin */ - return gst_pad_try_set_caps(smpte->srcpad, gst_caps_copy_1(caps)); + return gst_pad_try_set_caps(smpte->srcpad, caps); } static void gst_smpte_init (GstSMPTE *smpte) { smpte->sinkpad1 = gst_pad_new_from_template ( - GST_PAD_TEMPLATE_GET (smpte_sink1_factory), "sink1"); + gst_static_pad_template_get(&gst_smpte_sink1_template), "sink1"); gst_pad_set_link_function (smpte->sinkpad1, gst_smpte_sinkconnect); gst_element_add_pad (GST_ELEMENT (smpte), smpte->sinkpad1); smpte->sinkpad2 = gst_pad_new_from_template ( - GST_PAD_TEMPLATE_GET (smpte_sink2_factory), "sink2"); + gst_static_pad_template_get(&gst_smpte_sink2_template), "sink2"); gst_pad_set_link_function (smpte->sinkpad2, gst_smpte_sinkconnect); gst_element_add_pad (GST_ELEMENT (smpte), smpte->sinkpad2); smpte->srcpad = gst_pad_new_from_template ( - GST_PAD_TEMPLATE_GET (smpte_src_factory), "src"); + gst_static_pad_template_get(&gst_smpte_src_template), "src"); gst_element_add_pad (GST_ELEMENT (smpte), smpte->srcpad); gst_element_set_loop_function (GST_ELEMENT (smpte), gst_smpte_loop); @@ -366,16 +362,15 @@ gst_smpte_loop (GstElement *element) outbuf = gst_buffer_new_and_alloc (smpte->width * smpte->height * 3); if (!GST_PAD_CAPS (smpte->srcpad)) { - if (!gst_pad_try_set_caps (smpte->srcpad, - GST_CAPS_NEW ( - "smpte_srccaps", - "video/raw", - "format", GST_PROPS_FOURCC (GST_MAKE_FOURCC ('I','4','2','0')), - "width", GST_PROPS_INT (smpte->width), - "height", GST_PROPS_INT (smpte->height), - "framerate", GST_PROPS_FLOAT (smpte->fps) - ))) - { + GstCaps *caps; + caps = gst_caps_copy (gst_static_caps_get ( + &gst_smpte_src_template.static_caps)); + gst_caps_set_simple (caps, + "width", G_TYPE_INT, smpte->width, + "height", G_TYPE_INT, smpte->height, + "framerate", G_TYPE_DOUBLE, smpte->fps, NULL); + + if (!gst_pad_try_set_caps (smpte->srcpad, caps)) { gst_element_error (element, "cannot set caps"); return; } diff --git a/gst/smpte/gstsmpte.h b/gst/smpte/gstsmpte.h index c51d4fbe..40844209 100644 --- a/gst/smpte/gstsmpte.h +++ b/gst/smpte/gstsmpte.h @@ -44,7 +44,7 @@ struct _GstSMPTE { gint format; gint width; gint height; - gfloat fps; + gdouble fps; gint duration; gint position; diff --git a/gst/speed/filter.func b/gst/speed/filter.func index 7bd5227c..6802b20c 100644 --- a/gst/speed/filter.func +++ b/gst/speed/filter.func @@ -13,15 +13,10 @@ do { speed = filter->speed; /* update this, it might have changed */ - if (filter->srcpool) { - out = gst_buffer_new_from_pool(filter->srcpool, 0, 0); - out_data = (_FORMAT*) GST_BUFFER_DATA(out); - } else { - out = gst_buffer_new(); - GST_BUFFER_DATA(out) = (gchar*) g_new(_FORMAT,SPEED_BUFSIZE/sizeof(_FORMAT)); - GST_BUFFER_SIZE(out) = SPEED_BUFSIZE; - out_data = (_FORMAT*) GST_BUFFER_DATA(out); - } + out = gst_buffer_new(); + GST_BUFFER_DATA(out) = (gchar*) g_new(_FORMAT,SPEED_BUFSIZE/sizeof(_FORMAT)); + GST_BUFFER_SIZE(out) = SPEED_BUFSIZE; + out_data = (_FORMAT*) GST_BUFFER_DATA(out); nout = GST_BUFFER_SIZE(out) / sizeof(_FORMAT); GST_BUFFER_TIMESTAMP (out) = timestamp; offset += nout; diff --git a/gst/speed/gstspeed.c b/gst/speed/gstspeed.c index 8c602881..ec094156 100644 --- a/gst/speed/gstspeed.c +++ b/gst/speed/gstspeed.c @@ -55,49 +55,27 @@ enum { ARG_SPEED }; -static GstPadTemplate* -speed_sink_factory (void) -{ - static GstPadTemplate *template = NULL; - - if (!template) { - template = gst_pad_template_new - ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, - gst_caps_append(gst_caps_new ("sink_int", "audio/x-raw-int", - GST_AUDIO_INT_PAD_TEMPLATE_PROPS), - gst_caps_new ("sink_float", "audio/x-raw-float", - GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_PROPS)), - NULL); - } - return template; -} - -static GstPadTemplate* -speed_src_factory (void) -{ - static GstPadTemplate *template = NULL; - - if (!template) - template = gst_pad_template_new - ("src", GST_PAD_SRC, GST_PAD_ALWAYS, - gst_caps_append (gst_caps_new ("src_float", "audio/x-raw-float", - GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_PROPS), - gst_caps_new ("src_int", "audio/x-raw-int", - GST_AUDIO_INT_PAD_TEMPLATE_PROPS)), - NULL); - - return template; -} - -static GstBufferPool* -speed_sink_get_bufferpool (GstPad *pad) -{ - GstSpeed *filter; - - filter = GST_SPEED (gst_pad_get_parent(pad)); +static GstStaticPadTemplate gst_speed_sink_template = +GST_STATIC_PAD_TEMPLATE ( + "sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ( + GST_AUDIO_INT_PAD_TEMPLATE_CAPS "; " + GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS + ) +); - return filter->sinkpool; -} +static GstStaticPadTemplate gst_speed_src_template = +GST_STATIC_PAD_TEMPLATE ( + "src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ( + GST_AUDIO_INT_PAD_TEMPLATE_CAPS "; " + GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS + ) +); static void speed_base_init (gpointer g_class); static void speed_class_init (GstSpeedClass *klass); @@ -106,7 +84,7 @@ static void speed_init (GstSpeed *filter); static void speed_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); static void speed_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); -static gboolean speed_parse_caps (GstSpeed *filter, GstCaps *caps); +static gboolean speed_parse_caps (GstSpeed *filter, const GstCaps *caps); static void speed_loop (GstElement *element); @@ -114,7 +92,7 @@ static GstElementClass *parent_class = NULL; /*static guint gst_filter_signals[LAST_SIGNAL] = { 0 }; */ static GstPadLinkReturn -speed_link (GstPad *pad, GstCaps *caps) +speed_link (GstPad *pad, const GstCaps *caps) { GstSpeed *filter; GstPad *otherpad; @@ -124,41 +102,41 @@ speed_link (GstPad *pad, GstCaps *caps) g_return_val_if_fail (GST_IS_SPEED (filter), GST_PAD_LINK_REFUSED); otherpad = (pad == filter->srcpad ? filter->sinkpad : filter->srcpad); - if (GST_CAPS_IS_FIXED (caps)) { - if (! speed_parse_caps (filter, caps)) return GST_PAD_LINK_REFUSED; + if (! speed_parse_caps (filter, caps)) return GST_PAD_LINK_REFUSED; - return gst_pad_try_set_caps(otherpad, caps); - } - - return GST_PAD_LINK_DELAYED; + return gst_pad_try_set_caps(otherpad, caps); } static gboolean -speed_parse_caps (GstSpeed *filter, GstCaps *caps) +speed_parse_caps (GstSpeed *filter, const GstCaps *caps) { const gchar *mimetype; + GstStructure *structure; + gboolean ret; g_return_val_if_fail(filter != NULL, FALSE); g_return_val_if_fail(caps != NULL, FALSE); - gst_caps_get_int (caps, "rate", &filter->rate); - gst_caps_get_int (caps, "channels", &filter->channels); - gst_caps_get_int (caps, "width", &filter->width); - gst_caps_get_int (caps, "endianness", &filter->endianness); - gst_caps_get_int (caps, "buffer-frames", &filter->buffer_frames); + structure = gst_caps_get_structure (caps, 0); + + ret = gst_structure_get_int (structure, "rate", &filter->rate); + ret &= gst_structure_get_int (structure, "channels", &filter->channels); + ret &= gst_structure_get_int (structure, "width", &filter->width); + ret &= gst_structure_get_int (structure, "endianness", &filter->endianness); + ret &= gst_structure_get_int (structure, "buffer-frames", &filter->buffer_frames); - mimetype = gst_caps_get_mime (caps); + mimetype = gst_structure_get_name (structure); - if (! strncmp(mimetype, "audio/x-raw-int", 15)) { + if (strcmp(mimetype, "audio/x-raw-int") == 0) { filter->format = GST_SPEED_FORMAT_INT; - gst_caps_get_int (caps, "depth", &filter->depth); - gst_caps_get_boolean (caps, "signed", &filter->is_signed); - } else if (! strncmp(mimetype, "audio/x-raw-float", 17)) { + ret &= gst_structure_get_int (structure, "depth", &filter->depth); + ret &= gst_structure_get_boolean (structure, "signed", &filter->is_signed); + } else if (strcmp(mimetype, "audio/x-raw-float") == 0) { filter->format = GST_SPEED_FORMAT_FLOAT; } else { return FALSE; } - return TRUE; + return ret; } @@ -190,8 +168,10 @@ speed_base_init (gpointer g_class) gst_element_class_set_details (element_class, &speed_details); - gst_element_class_add_pad_template (element_class, speed_src_factory ()); - gst_element_class_add_pad_template (element_class, speed_sink_factory ()); + gst_element_class_add_pad_template (element_class, + gst_static_pad_template_get (&gst_speed_src_template)); + gst_element_class_add_pad_template (element_class, + gst_static_pad_template_get (&gst_speed_sink_template)); } static void speed_class_init (GstSpeedClass *klass) @@ -211,18 +191,17 @@ speed_class_init (GstSpeedClass *klass) static void speed_init (GstSpeed *filter) { - filter->sinkpad = gst_pad_new_from_template(speed_sink_factory (), "sink"); + filter->sinkpad = gst_pad_new_from_template( + gst_static_pad_template_get (&gst_speed_sink_template), "sink"); gst_pad_set_link_function(filter->sinkpad, speed_link); gst_element_add_pad(GST_ELEMENT(filter),filter->sinkpad); - gst_pad_set_bufferpool_function (filter->sinkpad, speed_sink_get_bufferpool); - filter->srcpad = gst_pad_new_from_template(speed_src_factory (), "src"); + filter->srcpad = gst_pad_new_from_template( + gst_static_pad_template_get (&gst_speed_src_template), "src"); gst_pad_set_link_function(filter->srcpad, speed_link); gst_element_add_pad(GST_ELEMENT(filter),filter->srcpad); gst_element_set_loop_function(GST_ELEMENT(filter),speed_loop); - - filter->sinkpool = gst_buffer_pool_get_default(SPEED_BUFSIZE, SPEED_NUMBUF); } static void @@ -236,8 +215,6 @@ speed_loop (GstElement *element) g_return_if_fail(filter != NULL); g_return_if_fail(GST_IS_SPEED(filter)); - filter->srcpool = gst_pad_get_bufferpool(filter->srcpad); - i = j = 0; speed = filter->speed; diff --git a/gst/speed/gstspeed.h b/gst/speed/gstspeed.h index 103ecdb8..2bbb0e6c 100644 --- a/gst/speed/gstspeed.h +++ b/gst/speed/gstspeed.h @@ -50,7 +50,6 @@ struct _GstSpeed { GstElement element; GstPad *sinkpad, *srcpad; - GstBufferPool *sinkpool, *srcpool; gfloat speed; diff --git a/gst/switch/gstswitch.c b/gst/switch/gstswitch.c index 09da3cdb..625eba29 100644 --- a/gst/switch/gstswitch.c +++ b/gst/switch/gstswitch.c @@ -38,11 +38,12 @@ static GstElementDetails gst_switch_details = GST_ELEMENT_DETAILS ( "Julien Moutte <julien@moutte.net>" ); -GST_PAD_TEMPLATE_FACTORY (gst_switch_sink_factory, +static GstStaticPadTemplate gst_switch_sink_factory = +GST_STATIC_PAD_TEMPLATE ( "sink%d", GST_PAD_SINK, GST_PAD_REQUEST, - GST_CAPS_ANY + GST_STATIC_CAPS_ANY ); static GstElementClass *parent_class = NULL; @@ -249,7 +250,7 @@ gst_switch_base_init (gpointer g_class) gst_element_class_set_details (element_class, &gst_switch_details); gst_element_class_add_pad_template (element_class, - GST_PAD_TEMPLATE_GET (gst_switch_sink_factory)); + gst_static_pad_template_get (&gst_switch_sink_factory)); } static void diff --git a/gst/vbidec/gstvbidec.c b/gst/vbidec/gstvbidec.c index c0999dc8..1670142f 100644 --- a/gst/vbidec/gstvbidec.c +++ b/gst/vbidec/gstvbidec.c @@ -82,26 +82,20 @@ enum { ARG_DVD_INPUT }; -GST_PAD_TEMPLATE_FACTORY (sink_template_factory, +static GstStaticPadTemplate gst_vbidec_sink_template = +GST_STATIC_PAD_TEMPLATE ( "sink", GST_PAD_SINK, GST_PAD_ALWAYS, - GST_CAPS_NEW ( - "vbidec_sink", - "application/octet-stream", - NULL - ) + GST_STATIC_CAPS_ANY ); -GST_PAD_TEMPLATE_FACTORY (src_template_factory, +static GstStaticPadTemplate gst_vbidec_src_template = +GST_STATIC_PAD_TEMPLATE ( "src", GST_PAD_SRC, GST_PAD_ALWAYS, - GST_CAPS_NEW ( - "vbidec_src", - "text/plain", - NULL - ) + GST_STATIC_CAPS ( "text/plain" ) ); @@ -171,8 +165,10 @@ gst_vbidec_base_init (gpointer g_class) gst_element_class_set_details (element_class, &gst_vbidec_details); - gst_element_class_add_pad_template (element_class, GST_PAD_TEMPLATE_GET (src_template_factory)); - gst_element_class_add_pad_template (element_class, GST_PAD_TEMPLATE_GET (sink_template_factory)); + gst_element_class_add_pad_template (element_class, + gst_static_pad_template_get (&gst_vbidec_src_template)); + gst_element_class_add_pad_template (element_class, + gst_static_pad_template_get (&gst_vbidec_sink_template)); } static void gst_vbidec_class_init(GstVBIDecClass *klass) @@ -204,12 +200,12 @@ gst_vbidec_init (GstVBIDec *vbidec) { /* create the sink and src pads */ vbidec->sinkpad = gst_pad_new_from_template ( - GST_PAD_TEMPLATE_GET (sink_template_factory), "sink"); + gst_static_pad_template_get (&gst_vbidec_sink_template), "sink"); gst_element_add_pad (GST_ELEMENT (vbidec), vbidec->sinkpad); gst_pad_set_chain_function (vbidec->sinkpad, GST_DEBUG_FUNCPTR (gst_vbidec_chain)); vbidec->srcpad = gst_pad_new_from_template ( - GST_PAD_TEMPLATE_GET (src_template_factory), "src"); + gst_static_pad_template_get (&gst_vbidec_src_template), "src"); gst_element_add_pad (GST_ELEMENT (vbidec), vbidec->srcpad); vbidec->vbiscreen = vbiscreen_new(0, 0, 1.0, 0, (void *)vbidec); diff --git a/gst/videocrop/gstvideocrop.c b/gst/videocrop/gstvideocrop.c index fb3ea230..ab975a23 100644 --- a/gst/videocrop/gstvideocrop.c +++ b/gst/videocrop/gstvideocrop.c @@ -48,7 +48,7 @@ struct _GstVideoCrop { /* caps */ gint width, height; - gfloat fps; + gdouble fps; gint crop_left, crop_right, crop_top, crop_bottom; }; @@ -80,29 +80,21 @@ enum { /* FILL ME */ }; -GST_PAD_TEMPLATE_FACTORY (video_crop_src_template_factory, +static GstStaticPadTemplate gst_video_crop_src_template = +GST_STATIC_PAD_TEMPLATE ( "src", GST_PAD_SRC, GST_PAD_ALWAYS, - gst_caps_new ( - "video_crop_src", - "video/x-raw-yuv", - GST_VIDEO_YUV_PAD_TEMPLATE_PROPS( - GST_PROPS_FOURCC (GST_STR_FOURCC ("I420"))) - ) -) + GST_STATIC_CAPS (GST_VIDEO_YUV_PAD_TEMPLATE_CAPS ("I420")) +); -GST_PAD_TEMPLATE_FACTORY (video_crop_sink_template_factory, +static GstStaticPadTemplate gst_video_crop_sink_template = +GST_STATIC_PAD_TEMPLATE ( "sink", GST_PAD_SINK, GST_PAD_ALWAYS, - gst_caps_new ( - "video_crop_sink", - "video/x-raw-yuv", - GST_VIDEO_YUV_PAD_TEMPLATE_PROPS( - GST_PROPS_FOURCC (GST_STR_FOURCC ("I420"))) - ) -) + GST_STATIC_CAPS (GST_VIDEO_YUV_PAD_TEMPLATE_CAPS ("I420")) +); static void gst_video_crop_base_init (gpointer g_class); @@ -115,7 +107,7 @@ static void gst_video_crop_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); static GstPadLinkReturn - gst_video_crop_sink_connect (GstPad *pad, GstCaps *caps); + gst_video_crop_sink_link (GstPad *pad, const GstCaps *caps); static void gst_video_crop_chain (GstPad *pad, GstData *_data); static GstElementStateReturn @@ -155,9 +147,9 @@ gst_video_crop_base_init (gpointer g_class) gst_element_class_set_details (element_class, &gst_video_crop_details); gst_element_class_add_pad_template (element_class, - GST_PAD_TEMPLATE_GET (video_crop_sink_template_factory)); + gst_static_pad_template_get (&gst_video_crop_sink_template)); gst_element_class_add_pad_template (element_class, - GST_PAD_TEMPLATE_GET (video_crop_src_template_factory)); + gst_static_pad_template_get (&gst_video_crop_src_template)); } static void gst_video_crop_class_init (GstVideoCropClass *klass) @@ -194,13 +186,13 @@ gst_video_crop_init (GstVideoCrop *video_crop) { /* create the sink and src pads */ video_crop->sinkpad = gst_pad_new_from_template( - GST_PAD_TEMPLATE_GET (video_crop_sink_template_factory), "sink"); + gst_static_pad_template_get (&gst_video_crop_sink_template), "sink"); gst_element_add_pad (GST_ELEMENT (video_crop), video_crop->sinkpad); - gst_pad_set_chain_function (video_crop->sinkpad, GST_DEBUG_FUNCPTR (gst_video_crop_chain)); - gst_pad_set_link_function (video_crop->sinkpad, GST_DEBUG_FUNCPTR (gst_video_crop_sink_connect)); + gst_pad_set_chain_function (video_crop->sinkpad, gst_video_crop_chain); + gst_pad_set_link_function (video_crop->sinkpad, gst_video_crop_sink_link); video_crop->srcpad = gst_pad_new_from_template( - GST_PAD_TEMPLATE_GET (video_crop_src_template_factory), "src"); + gst_static_pad_template_get (&gst_video_crop_src_template), "src"); gst_element_add_pad (GST_ELEMENT (video_crop), video_crop->srcpad); video_crop->crop_right = 0; @@ -270,19 +262,18 @@ gst_video_crop_get_property (GObject *object, guint prop_id, GValue *value, GPar } static GstPadLinkReturn -gst_video_crop_sink_connect (GstPad *pad, GstCaps *caps) +gst_video_crop_sink_link (GstPad *pad, const GstCaps *caps) { GstVideoCrop *video_crop; - - /* we are not going to act on variable caps */ - if (!GST_CAPS_IS_FIXED (caps)) - return GST_PAD_LINK_DELAYED; + GstStructure *structure; + gboolean ret; video_crop = GST_VIDEO_CROP (gst_pad_get_parent (pad)); + structure = gst_caps_get_structure (caps, 0); - gst_caps_get_int (caps, "width", &video_crop->width); - gst_caps_get_int (caps, "height", &video_crop->height); - gst_caps_get_float (caps, "framerate", &video_crop->fps); + ret = gst_structure_get_int (structure, "width", &video_crop->width); + ret &= gst_structure_get_int (structure, "height", &video_crop->height); + ret &= gst_structure_get_double (structure, "framerate", &video_crop->fps); return GST_PAD_LINK_OK; } @@ -380,22 +371,6 @@ gst_video_crop_chain (GstPad *pad, GstData *_data) new_height = video_crop->height - (video_crop->crop_top + video_crop->crop_bottom); - if (GST_PAD_CAPS (video_crop->srcpad) == NULL) { - if (gst_pad_try_set_caps (video_crop->srcpad, - GST_CAPS_NEW ( - "video_crop_caps", - "video/x-raw-yuv", - "format", GST_PROPS_FOURCC (GST_STR_FOURCC ("I420")), - "width", GST_PROPS_INT (new_width), - "height", GST_PROPS_INT (new_height), - "framerate", GST_PROPS_FLOAT (video_crop->fps) - )) <= 0) - { - gst_element_error (GST_ELEMENT (video_crop), "could not negotiate pads"); - return; - } - } - outbuf = gst_buffer_new_and_alloc ((new_width * new_height * 3) / 2); GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buffer); diff --git a/gst/videodrop/gstvideodrop.c b/gst/videodrop/gstvideodrop.c index e3df20a2..05c23220 100644 --- a/gst/videodrop/gstvideodrop.c +++ b/gst/videodrop/gstvideodrop.c @@ -22,6 +22,7 @@ #endif #include <gstvideodrop.h> +#include <gst/video/video.h> /* elementfactory information */ static GstElementDetails videodrop_details = GST_ELEMENT_DETAILS ( @@ -43,45 +44,25 @@ enum { /* FILL ME */ }; -GST_PAD_TEMPLATE_FACTORY(src_template, +static GstStaticPadTemplate gst_videodrop_src_template = +GST_STATIC_PAD_TEMPLATE ( "src", GST_PAD_SRC, GST_PAD_ALWAYS, - GST_CAPS_NEW( - "framedropper_yuv", - "video/x-raw-yuv", - "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT), - "width", GST_PROPS_INT_RANGE (0, G_MAXINT), - "height", GST_PROPS_INT_RANGE (0, G_MAXINT), - "format", GST_PROPS_LIST ( - GST_PROPS_FOURCC (GST_MAKE_FOURCC ('Y','U','Y','2')), - GST_PROPS_FOURCC (GST_MAKE_FOURCC ('I','4','2','0')), - GST_PROPS_FOURCC (GST_MAKE_FOURCC ('Y','V','1','2')), - GST_PROPS_FOURCC (GST_MAKE_FOURCC ('Y','U','Y','V')), - GST_PROPS_FOURCC (GST_MAKE_FOURCC ('U','Y','V','Y')) - ) + GST_STATIC_CAPS( + GST_VIDEO_YUV_PAD_TEMPLATE_CAPS("{ YUY2, I420, YV12, YUYV, UYVY }") ) -) +); -GST_PAD_TEMPLATE_FACTORY(sink_template, +static GstStaticPadTemplate gst_videodrop_sink_template = +GST_STATIC_PAD_TEMPLATE ( "sink", GST_PAD_SINK, GST_PAD_ALWAYS, - GST_CAPS_NEW( - "framedropper_yuv", - "video/x-raw-yuv", - "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT), - "width", GST_PROPS_INT_RANGE (0, G_MAXINT), - "height", GST_PROPS_INT_RANGE (0, G_MAXINT), - "format", GST_PROPS_LIST ( - GST_PROPS_FOURCC (GST_MAKE_FOURCC ('Y','U','Y','2')), - GST_PROPS_FOURCC (GST_MAKE_FOURCC ('I','4','2','0')), - GST_PROPS_FOURCC (GST_MAKE_FOURCC ('Y','V','1','2')), - GST_PROPS_FOURCC (GST_MAKE_FOURCC ('Y','U','Y','V')), - GST_PROPS_FOURCC (GST_MAKE_FOURCC ('U','Y','V','Y')) - ) + GST_STATIC_CAPS( + GST_VIDEO_YUV_PAD_TEMPLATE_CAPS("{ YUY2, I420, YV12, YUYV, UYVY }") ) -) +); static void gst_videodrop_base_init (gpointer g_class); static void gst_videodrop_class_init (GstVideodropClass *klass); @@ -137,9 +118,9 @@ gst_videodrop_base_init (gpointer g_class) gst_element_class_set_details (element_class, &videodrop_details); gst_element_class_add_pad_template (element_class, - GST_PAD_TEMPLATE_GET (sink_template)); + gst_static_pad_template_get (&gst_videodrop_sink_template)); gst_element_class_add_pad_template (element_class, - GST_PAD_TEMPLATE_GET (src_template)); + gst_static_pad_template_get (&gst_videodrop_src_template)); } static void gst_videodrop_class_init (GstVideodropClass *klass) @@ -166,52 +147,27 @@ gst_videodrop_class_init (GstVideodropClass *klass) min, max) static GstPadLinkReturn -gst_videodrop_link (GstPad *pad, GstCaps *caps) +gst_videodrop_link (GstPad *pad, const GstCaps *caps) { GstVideodrop *videodrop; - GstPadLinkReturn ret; - GstCaps *peercaps; + GstStructure *structure; + gboolean ret; + double fps; videodrop = GST_VIDEODROP (gst_pad_get_parent (pad)); - videodrop->inited = FALSE; - - if (!GST_CAPS_IS_FIXED (caps)) { - return GST_PAD_LINK_DELAYED; - } + structure = gst_caps_get_structure (caps, 0); + ret = gst_structure_get_double (structure, "framerate", &fps); - gst_caps_get_float (caps, "framerate", &videodrop->from_fps); + if (!ret) return GST_PAD_LINK_REFUSED; - /* calc output fps */ - peercaps = gst_pad_get_allowed_caps (videodrop->srcpad); - if (gst_caps_has_fixed_property (peercaps, "framerate")) { - gst_caps_get_float (peercaps, "framerate", &videodrop->to_fps); + if (pad == videodrop->srcpad) { + videodrop->to_fps = fps; } else { - gfloat min, max; - gst_caps_get_float_range (peercaps, "framerate", &min, &max); - if (videodrop->from_fps >= min && - videodrop->from_fps <= max) { - videodrop->to_fps = videodrop->from_fps; - } else { - videodrop->to_fps = max; - } - } - gst_caps_unref (peercaps); - - GST_DEBUG ("%f -> %f fps", - videodrop->from_fps, videodrop->to_fps); - - peercaps = gst_caps_copy (caps); - - peercaps->properties = gst_caps_set (peercaps, "framerate", - GST_PROPS_FLOAT (videodrop->to_fps)); - - if ((ret = gst_pad_try_set_caps (videodrop->srcpad, peercaps)) > 0) { - videodrop->inited = TRUE; - videodrop->total = videodrop->pass = 0; + videodrop->from_fps = fps; } - return ret; + return GST_PAD_LINK_OK; } static void @@ -219,16 +175,15 @@ gst_videodrop_init (GstVideodrop *videodrop) { GST_DEBUG ("gst_videodrop_init"); videodrop->sinkpad = gst_pad_new_from_template ( - GST_PAD_TEMPLATE_GET (sink_template), - "sink"); + gst_static_pad_template_get (&gst_videodrop_sink_template), "sink"); gst_element_add_pad (GST_ELEMENT (videodrop), videodrop->sinkpad); gst_pad_set_chain_function (videodrop->sinkpad, gst_videodrop_chain); gst_pad_set_link_function (videodrop->sinkpad, gst_videodrop_link); videodrop->srcpad = gst_pad_new_from_template ( - GST_PAD_TEMPLATE_GET (src_template), - "src"); + gst_static_pad_template_get (&gst_videodrop_src_template), "src"); gst_element_add_pad (GST_ELEMENT(videodrop), videodrop->srcpad); + gst_pad_set_link_function (videodrop->srcpad, gst_videodrop_link); videodrop->inited = FALSE; videodrop->total = videodrop->pass = 0; diff --git a/gst/y4m/gsty4mencode.c b/gst/y4m/gsty4mencode.c index b2463932..f45cf109 100644 --- a/gst/y4m/gsty4mencode.c +++ b/gst/y4m/gsty4mencode.c @@ -44,28 +44,23 @@ enum { ARG_0 }; -GST_PAD_TEMPLATE_FACTORY (y4mencode_src_factory, +static GstStaticPadTemplate y4mencode_src_factory = +GST_STATIC_PAD_TEMPLATE ( "src", GST_PAD_SRC, GST_PAD_ALWAYS, - GST_CAPS_NEW ( - "test_src", - "application/x-yuv4mpeg", - "y4mversion", GST_PROPS_INT (1) + GST_STATIC_CAPS ("application/x-yuv4mpeg, " + "y4mversion = (int) 1" ) -) +); -GST_PAD_TEMPLATE_FACTORY (y4mencode_sink_factory, +static GstStaticPadTemplate y4mencode_sink_factory = +GST_STATIC_PAD_TEMPLATE ( "sink", GST_PAD_SINK, GST_PAD_ALWAYS, - gst_caps_new ( - "test_src", - "video/x-raw-yuv", - GST_VIDEO_YUV_PAD_TEMPLATE_PROPS ( - GST_PROPS_FOURCC (GST_STR_FOURCC ("I420"))) - ) -) + GST_STATIC_CAPS (GST_VIDEO_YUV_PAD_TEMPLATE_CAPS ("I420")) +); static void gst_y4mencode_base_init (gpointer g_class); static void gst_y4mencode_class_init (GstY4mEncodeClass *klass); @@ -119,9 +114,9 @@ gst_y4mencode_base_init (gpointer g_class) GstElementClass *element_class = GST_ELEMENT_CLASS (g_class); gst_element_class_add_pad_template (element_class, - GST_PAD_TEMPLATE_GET (y4mencode_src_factory)); + gst_static_pad_template_get (&y4mencode_src_factory)); gst_element_class_add_pad_template (element_class, - GST_PAD_TEMPLATE_GET (y4mencode_sink_factory)); + gst_static_pad_template_get (&y4mencode_sink_factory)); gst_element_class_set_details (element_class, &y4mencode_details); } static void @@ -142,12 +137,12 @@ gst_y4mencode_class_init (GstY4mEncodeClass *klass) } static GstPadLinkReturn -gst_y4mencode_sinkconnect (GstPad *pad, GstCaps *caps) +gst_y4mencode_sinkconnect (GstPad *pad, const GstCaps *caps) { GstY4mEncode *filter; gint idx = -1, i; - gfloat fps; - float framerates[] = { + gdouble fps; + gdouble framerates[] = { 00.000, 23.976, 24.000, /* 24fps movie */ 25.000, /* PAL */ @@ -155,22 +150,22 @@ gst_y4mencode_sinkconnect (GstPad *pad, GstCaps *caps) 50.000, 59.940, 60.000 }; + GstStructure *structure; filter = GST_Y4MENCODE (gst_pad_get_parent (pad)); - if (!GST_CAPS_IS_FIXED (caps)) - return GST_PAD_LINK_DELAYED; + structure = gst_caps_get_structure (caps, 0); - gst_caps_get_int (caps, "width", &filter->width); - gst_caps_get_int (caps, "height", &filter->height); - gst_caps_get_float (caps, "framerate", &fps); + gst_structure_get_int (structure, "width", &filter->width); + gst_structure_get_int (structure, "height", &filter->height); + gst_structure_get_double (structure, "framerate", &fps); /* find fps idx */ for (i = 1; i < 9; i++) { if (idx == -1) { idx = i; } else { - gfloat old_diff = fabs(framerates[idx] - fps), + gdouble old_diff = fabs(framerates[idx] - fps), new_diff = fabs(framerates[i] - fps); if (new_diff < old_diff) { @@ -187,13 +182,13 @@ static void gst_y4mencode_init (GstY4mEncode *filter) { filter->sinkpad = gst_pad_new_from_template( - GST_PAD_TEMPLATE_GET (y4mencode_sink_factory), "sink"); + gst_static_pad_template_get (&y4mencode_sink_factory), "sink"); gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad); gst_pad_set_chain_function (filter->sinkpad, gst_y4mencode_chain); gst_pad_set_link_function (filter->sinkpad, gst_y4mencode_sinkconnect); filter->srcpad = gst_pad_new_from_template( - GST_PAD_TEMPLATE_GET (y4mencode_src_factory), "src"); + gst_static_pad_template_get (&y4mencode_src_factory), "src"); gst_element_add_pad (GST_ELEMENT (filter), filter->srcpad); filter->init = TRUE; |