diff options
84 files changed, 2656 insertions, 3279 deletions
diff --git a/examples/seeking/vorbisfile.c b/examples/seeking/vorbisfile.c index 29fc18cf..acaa60c9 100644 --- a/examples/seeking/vorbisfile.c +++ b/examples/seeking/vorbisfile.c @@ -12,78 +12,27 @@ struct probe_context { gint total_ls; - GstCaps *metadata; - GstCaps *streaminfo; - GstCaps *caps; + GstCaps *metadata; + GstCaps *streaminfo; + GstCaps *caps; }; static void print_caps (GstCaps *caps) { - if (caps == NULL) return; - if (!strcmp (gst_caps_get_mime (caps), "application/x-gst-metadata") || - !strcmp (gst_caps_get_mime (caps), "application/x-gst-streaminfo")) - { - GstProps *props = caps->properties; - GList *walk; - /* ugly hack, but ok for now. If needed, fix by individual strcmp */ - g_print (" %s:\n", gst_caps_get_mime (caps) + 18); - if (props == NULL) { - g_print (" none\n"); - return; - } - walk = props->properties; - - while (walk) { - GstPropsEntry *entry = (GstPropsEntry *) walk->data; - const gchar *name; - const gchar *str_val; - gint int_val; - GstPropsType type; - - name = gst_props_entry_get_name (entry); - type = gst_props_entry_get_props_type (entry); - switch (type) { - case GST_PROPS_STRING_TYPE: - gst_props_entry_get_string (entry, &str_val); - g_print (" %s='%s'\n", name, str_val); - break; - case GST_PROPS_INT_TYPE: - gst_props_entry_get_int (entry, &int_val); - g_print (" %s=%d\n", name, int_val); - break; - default: - break; - } - walk = g_list_next (walk); - } - } - else { - g_print (" unkown caps type\n"); - } + char *s; + s = gst_caps_to_string (caps); + g_print(" %s\n", s); + g_free (s); } static void print_format (GstCaps *caps) { - g_print (" format:\n"); - if (!caps || caps->properties == NULL) { - g_print (" unkown\n"); - return; - } - if (!strcmp (gst_caps_get_mime (caps), "audio/raw")) { - gint channels; - gint rate; - - gst_caps_get_int (caps, "channels", &channels); - gst_caps_get_int (caps, "rate", &rate); - - g_print (" channels: %d\n", channels); - g_print (" rate: %d\n", rate); - } - else { - g_print (" unkown format\n"); - } + char *s; + s = gst_caps_to_string (caps); + g_print(" format: %s\n", s); + g_free (s); } static void diff --git a/ext/arts/gst_arts.c b/ext/arts/gst_arts.c index f726e260..196bd7c1 100644 --- a/ext/arts/gst_arts.c +++ b/ext/arts/gst_arts.c @@ -38,36 +38,34 @@ static GstElementDetails gst_arts_details = { }; -GST_PAD_TEMPLATE_FACTORY ( sink_temp, +static GstStaticPadTemplate sink_temp = +GST_STATIC_PAD_TEMPLATE ( "sink", GST_PAD_SINK, GST_PAD_ALWAYS, - GST_CAPS_NEW ( - "arts_sample", - "audio/x-raw-int", - "depth", GST_PROPS_INT (16), - "width", GST_PROPS_INT (16), - "signed", GST_PROPS_BOOLEAN (TRUE), - "channels", GST_PROPS_INT (2), - "endianness", GST_PROPS_INT (G_BYTE_ORDER) + GST_STATIC_CAPS ( "audio/x-raw-int, " + "depth = (int) 16, " + "width = (int) 16, " + "signed = (boolean) true, " + "channels = (int) 2, " + "endianness = (int) byte_order" ) -) +); -GST_PAD_TEMPLATE_FACTORY ( src_temp, +static GstStaticPadTemplate src_temp = +GST_STATIC_PAD_TEMPLATE ( "src", GST_PAD_SRC, GST_PAD_ALWAYS, - GST_CAPS_NEW ( - "arts_sample", - "audio/x-raw-int", - "depth", GST_PROPS_INT (16), - "width", GST_PROPS_INT (16), - "signed", GST_PROPS_BOOLEAN (TRUE), - "channels", GST_PROPS_INT (2), - "rate", GST_PROPS_INT (44100), - "endianness", GST_PROPS_INT (G_BYTE_ORDER) + GST_STATIC_CAPS ("audio/x-raw-int, " + "depth = (int) 16, " + "width = (int) 16, " + "signed = (boolean) true, " + "channels = (int) 2, " + "rate = (int) 44100, " + "endianness = (int) byte_order" ) -) +); enum { ARG_0, @@ -112,9 +110,9 @@ gst_arts_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 (sink_temp)); + gst_static_pad_template_get (&sink_temp)); gst_element_class_add_pad_template (element_class, - GST_PAD_TEMPLATE_GET (src_temp)); + gst_static_pad_template_get (&src_temp)); gst_element_class_set_details (element_class, &gst_arts_details); } @@ -133,10 +131,12 @@ gst_arts_class_init (GstARTSClass *klass) static void gst_arts_init (GstARTS *arts) { - arts->sinkpad = gst_pad_new_from_template(GST_PAD_TEMPLATE_GET(sink_temp),"sink"); + arts->sinkpad = gst_pad_new_from_template( + gst_element_get_pad_template (GST_ELEMENT (arts), "sink"), "sink"); gst_element_add_pad(GST_ELEMENT(arts),arts->sinkpad); - arts->srcpad = gst_pad_new_from_template(GST_PAD_TEMPLATE_GET(src_temp),"src"); + arts->srcpad = gst_pad_new_from_template( + gst_element_get_pad_template (GST_ELEMENT (arts), "src"), "src"); gst_element_add_pad(GST_ELEMENT(arts),arts->srcpad); gst_element_set_loop_function (GST_ELEMENT (arts), gst_arts_loop); diff --git a/ext/artsd/gstartsdsink.c b/ext/artsd/gstartsdsink.c index 2c223df1..25ff80c4 100644 --- a/ext/artsd/gstartsdsink.c +++ b/ext/artsd/gstartsdsink.c @@ -24,6 +24,7 @@ #include "config.h" #endif #include "gstartsdsink.h" +#include <gst/audio/audio.h> /* elementfactory information */ static GstElementDetails artsdsink_details = { @@ -45,31 +46,12 @@ enum { ARG_NAME, }; -GST_PAD_TEMPLATE_FACTORY (sink_factory, - "sink", /* the name of the pads */ - GST_PAD_SINK, /* type of the pad */ - GST_PAD_ALWAYS, /* ALWAYS/SOMETIMES */ - GST_CAPS_NEW ( - "artsdsink_sink", /* the name of the caps */ - "audio/x-raw-int", /* the mime type of the caps */ - "format", GST_PROPS_STRING ("int"), - "law", GST_PROPS_INT (0), - "endianness", GST_PROPS_INT (G_BYTE_ORDER), - "signed", GST_PROPS_BOOLEAN (FALSE), - "width", GST_PROPS_LIST ( - GST_PROPS_INT (8), - GST_PROPS_INT (16) - ), - "depth", GST_PROPS_LIST ( - GST_PROPS_INT (8), - GST_PROPS_INT (16) - ), - "rate", GST_PROPS_INT_RANGE (8000, 96000), - "channels", GST_PROPS_LIST ( - GST_PROPS_INT (1), - GST_PROPS_INT (2) - ) - ) +static GstStaticPadTemplate sink_factory = +GST_STATIC_PAD_TEMPLATE ( + "sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + GST_STATIC_CAPS (GST_AUDIO_INT_PAD_TEMPLATE_CAPS) ); static void gst_artsdsink_base_init (gpointer g_class); @@ -80,7 +62,7 @@ static gboolean gst_artsdsink_open_audio (GstArtsdsink *sink); static void gst_artsdsink_close_audio (GstArtsdsink *sink); static GstElementStateReturn gst_artsdsink_change_state (GstElement *element); static gboolean gst_artsdsink_sync_parms (GstArtsdsink *artsdsink); -static GstPadLinkReturn gst_artsdsink_link (GstPad *pad, GstCaps *caps); +static GstPadLinkReturn gst_artsdsink_link (GstPad *pad, const GstCaps *caps); static void gst_artsdsink_chain (GstPad *pad, GstData *_data); static void gst_artsdsink_set_property (GObject *object, guint prop_id, @@ -118,7 +100,8 @@ gst_artsdsink_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 (sink_factory)); + gst_element_class_add_pad_template (element_class, + gst_static_pad_template_get (&sink_factory)); gst_element_class_set_details (element_class, &artsdsink_details); } @@ -151,7 +134,7 @@ static void gst_artsdsink_init(GstArtsdsink *artsdsink) { artsdsink->sinkpad = gst_pad_new_from_template ( - GST_PAD_TEMPLATE_GET (sink_factory), "sink"); + gst_element_get_pad_template (GST_ELEMENT (artsdsink), "sink"), "sink"); gst_element_add_pad(GST_ELEMENT(artsdsink), artsdsink->sinkpad); gst_pad_set_chain_function(artsdsink->sinkpad, gst_artsdsink_chain); gst_pad_set_link_function(artsdsink->sinkpad, gst_artsdsink_link); @@ -175,19 +158,16 @@ gst_artsdsink_sync_parms (GstArtsdsink *artsdsink) } static GstPadLinkReturn -gst_artsdsink_link (GstPad *pad, GstCaps *caps) +gst_artsdsink_link (GstPad *pad, const GstCaps *caps) { GstArtsdsink *artsdsink = GST_ARTSDSINK (gst_pad_get_parent (pad)); + GstStructure *structure; - if (!GST_CAPS_IS_FIXED (caps)) - return GST_PAD_LINK_DELAYED; - - gst_caps_get (caps, - "rate", &artsdsink->frequency, - "depth", &artsdsink->depth, - "signed", &artsdsink->signd, - "channels", &artsdsink->channels, - NULL); + structure = gst_caps_get_structure (caps, 0); + gst_structure_get_int (structure, "rate", &artsdsink->frequency); + gst_structure_get_int (structure, "depth", &artsdsink->depth); + gst_structure_get_int (structure, "signed", &artsdsink->signd); + gst_structure_get_int (structure, "channels", &artsdsink->channels); if (gst_artsdsink_sync_parms (artsdsink)) return GST_PAD_LINK_OK; diff --git a/ext/audiofile/gstafparse.c b/ext/audiofile/gstafparse.c index 6df1ca2e..f61d64f4 100644 --- a/ext/audiofile/gstafparse.c +++ b/ext/audiofile/gstafparse.c @@ -50,42 +50,34 @@ enum { }; /* added a src factory function to force audio/raw MIME type */ -GST_PAD_TEMPLATE_FACTORY (afparse_src_factory, +static GstStaticPadTemplate afparse_src_factory = +GST_STATIC_PAD_TEMPLATE ( "src", GST_PAD_SRC, GST_PAD_ALWAYS, - GST_CAPS_NEW ( - "audiofile_src", - "audio/x-raw-int", - "endianness", GST_PROPS_INT (G_BYTE_ORDER), - "signed", GST_PROPS_LIST (GST_PROPS_BOOLEAN (TRUE), GST_PROPS_BOOLEAN (FALSE)), - "width", GST_PROPS_INT_RANGE (8, 16), - "depth", GST_PROPS_INT_RANGE (8, 16), - "rate", GST_PROPS_INT_RANGE (1, G_MAXINT), - "channels", GST_PROPS_INT_RANGE (1, 2) + GST_STATIC_CAPS ( + "audio/x-raw-int, " + "rate = (int) [ 1, MAX ], " + "channels = (int) [ 1, MAX ], " + "endianness = (int) BYTE_ORDER, " + "width = (int) { 8, 16 }, " + "depth = (int) { 8, 16 }, " + "signed = (boolean) { true, false }, " + "buffer-frames = (int) [ 1, MAX ]" ) -) +); -GST_PAD_TEMPLATE_FACTORY (afparse_sink_factory, +static GstStaticPadTemplate afparse_sink_factory = +GST_STATIC_PAD_TEMPLATE ( "sink", GST_PAD_SINK, GST_PAD_ALWAYS, - GST_CAPS_NEW ( - "afparse_sink_aiff", - "audio/x-aiff", - NULL - ), - GST_CAPS_NEW ( - "afparse_sink_wav", - "audio/x-wav", - NULL - ), - GST_CAPS_NEW ( - "afparse_sink_snd", - "audio/x-au", - NULL + GST_STATIC_CAPS ( + "audio/x-aiff; " + "audio/x-wav; " + "audio/x-au" ) -) +); static void gst_afparse_base_init (gpointer g_class); static void gst_afparse_class_init(GstAFParseClass *klass); @@ -131,8 +123,10 @@ gst_afparse_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 (afparse_src_factory)); - gst_element_class_add_pad_template (element_class, GST_PAD_TEMPLATE_GET (afparse_sink_factory)); + gst_element_class_add_pad_template (element_class, + gst_static_pad_template_get (&afparse_src_factory)); + gst_element_class_add_pad_template (element_class, + gst_static_pad_template_get (&afparse_sink_factory)); gst_element_class_set_details (element_class, &afparse_details); } @@ -154,10 +148,12 @@ gst_afparse_class_init (GstAFParseClass *klass) static void gst_afparse_init (GstAFParse *afparse) { - afparse->srcpad = gst_pad_new_from_template (afparse_src_factory (), "src"); + afparse->srcpad = gst_pad_new_from_template ( + gst_element_get_pad_template (GST_ELEMENT (afparse), "src"), "src"); gst_element_add_pad (GST_ELEMENT (afparse), afparse->srcpad); - afparse->sinkpad = gst_pad_new_from_template (afparse_sink_factory (), "sink"); + afparse->sinkpad = gst_pad_new_from_template ( + gst_element_get_pad_template (GST_ELEMENT (afparse), "sink"), "sink"); gst_element_add_pad (GST_ELEMENT (afparse), afparse->sinkpad); gst_element_set_loop_function (GST_ELEMENT (afparse), gst_afparse_loop); @@ -191,7 +187,6 @@ gst_afparse_loop(GstElement *element) { GstAFParse *afparse; GstBuffer *buf; - GstBufferPool *bufpool; gint numframes = 0, frames_to_bytes, frames_per_read, bytes_per_read; guint8 *data; gboolean bypass_afread = TRUE; @@ -230,7 +225,6 @@ gst_afparse_loop(GstElement *element) frames_per_read = afparse->frames_per_read; bytes_per_read = frames_per_read * frames_to_bytes; - bufpool = gst_buffer_pool_get_default (bytes_per_read, 8); afSeekFrame(afparse->file, AF_DEFAULT_TRACK, 0); if (bypass_afread){ @@ -269,7 +263,7 @@ gst_afparse_loop(GstElement *element) } else { do { - buf = gst_buffer_new_from_pool (bufpool, 0, 0); + buf = gst_buffer_new_and_alloc (bytes_per_read); GST_BUFFER_TIMESTAMP(buf) = afparse->timestamp; data = GST_BUFFER_DATA(buf); numframes = afReadFrames (afparse->file, AF_DEFAULT_TRACK, data, frames_per_read); @@ -290,7 +284,6 @@ gst_afparse_loop(GstElement *element) while (TRUE); } gst_afparse_close_file (afparse); - gst_buffer_pool_unref(bufpool); gst_bytestream_destroy ((GstByteStream*) afparse->vfile->closure); @@ -389,17 +382,15 @@ gst_afparse_open_file (GstAFParse *afparse) /* set caps on src */ /*FIXME: add all the possible formats, especially float ! */ gst_pad_try_set_caps (afparse->srcpad, - GST_CAPS_NEW ( - "af_src", - "audio/x-raw-int", - "endianness", GST_PROPS_INT (G_BYTE_ORDER), /*FIXME */ - "signed", GST_PROPS_BOOLEAN (afparse->is_signed), - "width", GST_PROPS_INT (afparse->width), - "depth", GST_PROPS_INT (afparse->width), - "rate", GST_PROPS_INT (afparse->rate), - "channels", GST_PROPS_INT (afparse->channels) - ) - ); + gst_caps_new_simple ( + "audio/x-raw-int", + "endianness", G_TYPE_INT, G_BYTE_ORDER, + "signed", G_TYPE_BOOLEAN, afparse->is_signed, + "width", G_TYPE_INT, afparse->width, + "depth", G_TYPE_INT, afparse->width, + "rate", G_TYPE_INT, afparse->rate, + "channels", G_TYPE_INT, afparse->channels, + NULL)); GST_FLAG_SET (afparse, GST_AFPARSE_OPEN); diff --git a/ext/audiofile/gstafsink.c b/ext/audiofile/gstafsink.c index efe242d4..5b6b702e 100644 --- a/ext/audiofile/gstafsink.c +++ b/ext/audiofile/gstafsink.c @@ -52,22 +52,19 @@ enum { /* added a sink factory function to force audio/raw MIME type */ /* I think the caps can be broader, we need to change that somehow */ -GST_PAD_TEMPLATE_FACTORY (afsink_sink_factory, +static GstStaticPadTemplate afsink_sink_factory = +GST_STATIC_PAD_TEMPLATE ( "sink", GST_PAD_SINK, GST_PAD_ALWAYS, - GST_CAPS_NEW ( - "audiofile_sink", - "audio/x-raw-int", - "endianness", GST_PROPS_INT (G_BYTE_ORDER), - "signed", GST_PROPS_LIST ( - GST_PROPS_BOOLEAN (TRUE), - GST_PROPS_BOOLEAN (FALSE) - ), - "width", GST_PROPS_INT_RANGE (8, 16), - "depth", GST_PROPS_INT_RANGE (8, 16), - "rate", GST_PROPS_INT_RANGE (4000, 48000), /*FIXME*/ - "channels", GST_PROPS_INT_RANGE (1, 2) + GST_STATIC_CAPS ("audio/x-raw-int, " + "rate = (int) [ 1, MAX ], " + "channels = (int) [ 1, 2 ], " + "endianness = (int) BYTE_ORDER, " + "width = (int) { 8, 16 }, " + "depth = (int) { 8, 16 }, " + "signed = (boolean) { true, false }, " + "buffer-frames = (int) [ 1, MAX ]" ) ); @@ -143,7 +140,8 @@ gst_afsink_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 (afsink_sink_factory)); + gst_element_class_add_pad_template (element_class, + gst_static_pad_template_get (&afsink_sink_factory)); gst_element_class_set_details (element_class, &afsink_details); } @@ -188,7 +186,7 @@ gst_afsink_init (GstAFSink *afsink) /* GstPad *pad; this is now done in the struct */ afsink->sinkpad = gst_pad_new_from_template ( - GST_PAD_TEMPLATE_GET (afsink_sink_factory), "sink"); + gst_element_get_pad_template (GST_ELEMENT (afsink), "sink"), "sink"); gst_element_add_pad (GST_ELEMENT (afsink), afsink->sinkpad); gst_pad_set_chain_function (afsink->sinkpad, gst_afsink_chain); @@ -284,7 +282,8 @@ static gboolean gst_afsink_open_file (GstAFSink *sink) { AFfilesetup outfilesetup; - GstCaps *caps; + const GstCaps *caps; + GstStructure *structure; int sample_format; /* audiofile's sample format, look in audiofile.h */ int byte_order = 0; /* audiofile's byte order defines */ @@ -301,22 +300,18 @@ gst_afsink_open_file (GstAFSink *sink) */ /* get the audio parameters */ - caps = NULL; g_return_val_if_fail (GST_IS_PAD (sink->sinkpad), FALSE); caps = GST_PAD_CAPS (sink->sinkpad); - if (caps == NULL) - { - /* FIXME : Please change this to a better warning method ! */ - printf ("WARNING: gstafsink chain : Could not get caps of pad !\n"); - } - else - { - gst_caps_get_int (caps, "channels", &sink->channels); - gst_caps_get_int (caps, "width", &sink->width); - gst_caps_get_int (caps, "rate", &sink->rate); - gst_caps_get_boolean (caps, "signed", &sink->is_signed); - gst_caps_get_int (caps, "endianness", &sink->endianness_data); + if (caps == NULL) { + g_critical ("gstafsink chain : Could not get caps of pad !\n"); + } else { + structure = gst_caps_get_structure (caps, 0); + gst_structure_get_int (structure, "channels", &sink->channels); + gst_structure_get_int (structure, "width", &sink->width); + gst_structure_get_int (structure, "rate", &sink->rate); + gst_structure_get_boolean (structure, "signed", &sink->is_signed); + gst_structure_get_int (structure, "endianness", &sink->endianness_data); } GST_DEBUG ("channels %d, width %d, rate %d, signed %s", sink->channels, sink->width, sink->rate, diff --git a/ext/audiofile/gstafsrc.c b/ext/audiofile/gstafsrc.c index 13e228fc..0520463d 100644 --- a/ext/audiofile/gstafsrc.c +++ b/ext/audiofile/gstafsrc.c @@ -51,22 +51,19 @@ enum { /* added a src factory function to force audio/raw MIME type */ /* I think the caps can be broader, we need to change that somehow */ -GST_PAD_TEMPLATE_FACTORY (afsrc_src_factory, +static GstStaticPadTemplate afsrc_src_factory = +GST_STATIC_PAD_TEMPLATE ( "src", GST_PAD_SRC, GST_PAD_ALWAYS, - GST_CAPS_NEW ( - "audiofile_src", - "audio/x-raw-int", - "endianness", GST_PROPS_INT (G_BYTE_ORDER), - "signed", GST_PROPS_LIST ( - GST_PROPS_BOOLEAN (TRUE), - GST_PROPS_BOOLEAN (FALSE) - ), - "width", GST_PROPS_INT_RANGE (8, 16), - "depth", GST_PROPS_INT_RANGE (8, 16), - "rate", GST_PROPS_INT_RANGE (4000, 48000), /*FIXME*/ - "channels", GST_PROPS_INT_RANGE (1, 2) + GST_STATIC_CAPS ("audio/x-raw-int, " + "rate = (int) [ 1, MAX ], " + "channels = (int) [ 1, MAX ], " + "endianness = (int) BYTE_ORDER, " + "width = (int) { 8, 16 }, " + "depth = (int) { 8, 16 }, " + "signed = (boolean) { true, false }, " + "buffer-frames = (int) [ 1, MAX ]" ) ); @@ -142,7 +139,8 @@ gst_afsrc_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 (afsrc_src_factory)); + gst_element_class_add_pad_template (element_class, + gst_static_pad_template_get (&afsrc_src_factory)); gst_element_class_set_details (element_class, &afsrc_details); } @@ -178,7 +176,8 @@ static void gst_afsrc_init (GstAFSrc *afsrc) { /* no need for a template, caps are set based on file, right ? */ - afsrc->srcpad = gst_pad_new_from_template (afsrc_src_factory (), "src"); + afsrc->srcpad = gst_pad_new_from_template ( + gst_element_get_pad_template (GST_ELEMENT (afsrc), "src"), "src"); gst_element_add_pad (GST_ELEMENT (afsrc), afsrc->srcpad); gst_pad_set_get_function (afsrc->srcpad, gst_afsrc_get); @@ -342,17 +341,14 @@ gst_afsrc_open_file (GstAFSrc *src) /* set caps on src */ /*FIXME: add all the possible formats, especially float ! */ gst_pad_try_set_caps (src->srcpad, - GST_CAPS_NEW ( - "af_src", - "audio/x-raw-int", - "endianness", GST_PROPS_INT (G_BYTE_ORDER), /*FIXME */ - "signed", GST_PROPS_BOOLEAN (src->is_signed), - "width", GST_PROPS_INT (src->width), - "depth", GST_PROPS_INT (src->width), - "rate", GST_PROPS_INT (src->rate), - "channels", GST_PROPS_INT (src->channels) - ) - ); + gst_caps_new_simple ("audio/x-raw-int", + "endianness", G_TYPE_INT, G_BYTE_ORDER, + "signed", G_TYPE_BOOLEAN, src->is_signed, + "width", G_TYPE_INT, src->width, + "depth", G_TYPE_INT, src->width, + "rate", G_TYPE_INT, src->rate, + "channels", G_TYPE_INT, src->channels, + NULL)); GST_FLAG_SET (src, GST_AFSRC_OPEN); diff --git a/ext/gsm/gstgsmdec.c b/ext/gsm/gstgsmdec.c index 095140c1..1359ce97 100644 --- a/ext/gsm/gstgsmdec.c +++ b/ext/gsm/gstgsmdec.c @@ -25,8 +25,6 @@ #include "gstgsmdec.h" -static GstPadTemplate *gsmdec_src_template, *gsmdec_sink_template; - /* elementfactory information */ GstElementDetails gst_gsmdec_details = { "GSM audio decoder", @@ -51,7 +49,7 @@ static void gst_gsmdec_class_init (GstGSMDec *klass); static void gst_gsmdec_init (GstGSMDec *gsmdec); static void gst_gsmdec_chain (GstPad *pad, GstData *_data); -static GstPadLinkReturn gst_gsmdec_sinkconnect (GstPad *pad, GstCaps *caps); +static GstPadLinkReturn gst_gsmdec_sinkconnect (GstPad *pad, const GstCaps *caps); static GstElementClass *parent_class = NULL; /*static guint gst_gsmdec_signals[LAST_SIGNAL] = { 0 }; */ @@ -77,39 +75,43 @@ gst_gsmdec_get_type(void) { return gsmdec_type; } -GST_CAPS_FACTORY (gsm_caps_factory, - GST_CAPS_NEW ( - "gsm_gsm", - "audio/x-gsm", - "rate", GST_PROPS_INT_RANGE (1000, 48000), - "channels", GST_PROPS_INT (1) - ) -) - -GST_CAPS_FACTORY (raw_caps_factory, - GST_CAPS_NEW ( - "gsm_raw", - "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 (1000, 48000), - "channels", GST_PROPS_INT (1) +static GstStaticPadTemplate gsmdec_sink_template = +GST_STATIC_PAD_TEMPLATE ( + "sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ( + "audio/x-gsm, " + "rate = (int) [ 1000, 48000 ], " + "channels = (int) 1" + ) +); + +static GstStaticPadTemplate gsmdec_src_template = +GST_STATIC_PAD_TEMPLATE ( + "src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ( + "audio/x-raw-int, " + "endianness = (int) BYTE_ORDER, " + "signed = (boolean) true, " + "width = (int) 16, " + "depth = (int) 16, " + "rate = (int) [ 1000, 48000 ], " + "channels = (int) 1" ) -) +); static void gst_gsmdec_base_init (gpointer g_class) { GstElementClass *element_class = GST_ELEMENT_CLASS (g_class); - gsmdec_sink_template = gst_pad_template_new ("sink", GST_PAD_SINK, - GST_PAD_ALWAYS, gsm_caps_factory(), NULL); - gsmdec_src_template = gst_pad_template_new ("src", GST_PAD_SRC, - GST_PAD_ALWAYS, raw_caps_factory(), NULL); - gst_element_class_add_pad_template (element_class, gsmdec_sink_template); - gst_element_class_add_pad_template (element_class, gsmdec_src_template); + gst_element_class_add_pad_template (element_class, + gst_static_pad_template_get (&gsmdec_sink_template)); + gst_element_class_add_pad_template (element_class, + gst_static_pad_template_get (&gsmdec_src_template)); gst_element_class_set_details (element_class, &gst_gsmdec_details); } @@ -129,12 +131,14 @@ gst_gsmdec_init (GstGSMDec *gsmdec) GST_DEBUG ("gst_gsmdec_init: initializing"); /* create the sink and src pads */ - gsmdec->sinkpad = gst_pad_new_from_template (gsmdec_sink_template, "sink"); + gsmdec->sinkpad = gst_pad_new_from_template ( + gst_static_pad_template_get (&gsmdec_sink_template), "sink"); gst_element_add_pad (GST_ELEMENT (gsmdec), gsmdec->sinkpad); gst_pad_set_chain_function (gsmdec->sinkpad, gst_gsmdec_chain); gst_pad_set_link_function (gsmdec->sinkpad, gst_gsmdec_sinkconnect); - gsmdec->srcpad = gst_pad_new_from_template (gsmdec_src_template, "src"); + gsmdec->srcpad = gst_pad_new_from_template ( + gst_static_pad_template_get (&gsmdec_src_template), "src"); gst_element_add_pad (GST_ELEMENT (gsmdec), gsmdec->srcpad); gsmdec->state = gsm_create (); @@ -142,29 +146,26 @@ gst_gsmdec_init (GstGSMDec *gsmdec) } static GstPadLinkReturn -gst_gsmdec_sinkconnect (GstPad *pad, GstCaps *caps) +gst_gsmdec_sinkconnect (GstPad *pad, const GstCaps *caps) { GstGSMDec *gsmdec; gint rate; + GstStructure *structure; gsmdec = GST_GSMDEC (gst_pad_get_parent (pad)); - if (!GST_CAPS_IS_FIXED (caps)) - return GST_PAD_LINK_DELAYED; - - gst_caps_get_int (caps, "rate", &rate); + structure = gst_caps_get_structure (caps, 0); + gst_structure_get_int (structure, "rate", &rate); if (gst_pad_try_set_caps (gsmdec->srcpad, - GST_CAPS_NEW ( - "gsm_raw", - "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 (rate), - "channels", GST_PROPS_INT (1) - )) > 0) + gst_caps_new_simple ("audio/x-raw-int", + "endianness", G_TYPE_INT, G_BYTE_ORDER, + "signed", G_TYPE_BOOLEAN, TRUE, + "width", G_TYPE_INT, 16, + "depth", G_TYPE_INT, 16, + "rate", G_TYPE_INT, rate, + "channels", G_TYPE_INT, 1, + NULL)) > 0) { return GST_PAD_LINK_OK; } diff --git a/ext/gsm/gstgsmenc.c b/ext/gsm/gstgsmenc.c index d8949b54..a608fea0 100644 --- a/ext/gsm/gstgsmenc.c +++ b/ext/gsm/gstgsmenc.c @@ -25,8 +25,6 @@ #include "gstgsmenc.h" -static GstPadTemplate *gsmenc_src_template, *gsmenc_sink_template; - /* elementfactory information */ GstElementDetails gst_gsmenc_details = { "GSM audio encoder", @@ -52,7 +50,7 @@ static void gst_gsmenc_class_init (GstGSMEnc *klass); static void gst_gsmenc_init (GstGSMEnc *gsmenc); static void gst_gsmenc_chain (GstPad *pad,GstData *_data); -static GstPadLinkReturn gst_gsmenc_sinkconnect (GstPad *pad, GstCaps *caps); +static GstPadLinkReturn gst_gsmenc_sinkconnect (GstPad *pad, const GstCaps *caps); static GstElementClass *parent_class = NULL; static guint gst_gsmenc_signals[LAST_SIGNAL] = { 0 }; @@ -79,45 +77,43 @@ gst_gsmenc_get_type (void) return gsmenc_type; } -GST_CAPS_FACTORY (gsm_caps_factory, - GST_CAPS_NEW ( - "gsm_gsm", - "audio/x-gsm", - "rate", GST_PROPS_INT_RANGE (1000, 48000), - "channels", GST_PROPS_INT (1) +static GstStaticPadTemplate gsmenc_src_template = +GST_STATIC_PAD_TEMPLATE ( + "src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ( + "audio/x-gsm, " + "rate = (int) [ 1000, 48000 ], " + "channels = (int) 1" ) -) - -GST_CAPS_FACTORY (raw_caps_factory, - GST_CAPS_NEW ( - "gsm_raw", - "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 (1000, 48000), - "channels", GST_PROPS_INT (1) +); + +static GstStaticPadTemplate gsmenc_sink_template = +GST_STATIC_PAD_TEMPLATE ( + "sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ( + "audio/x-raw-int, " + "endianness = (int) BYTE_ORDER, " + "signed = (boolean) true, " + "width = (int) 16, " + "depth = (int) 16, " + "rate = (int) [ 1000, 48000 ], " + "channels = (int) 1" ) -) +); static void gst_gsmenc_base_init (gpointer g_class) { GstElementClass *element_class = GST_ELEMENT_CLASS (g_class); - GstCaps *raw_caps, *gsm_caps; - raw_caps = GST_CAPS_GET (raw_caps_factory); - gsm_caps = GST_CAPS_GET (gsm_caps_factory); - - gsmenc_sink_template = gst_pad_template_new ("sink", GST_PAD_SINK, - GST_PAD_ALWAYS, - raw_caps, NULL); - gsmenc_src_template = gst_pad_template_new ("src", GST_PAD_SRC, - GST_PAD_ALWAYS, - gsm_caps, NULL); - gst_element_class_add_pad_template (element_class, gsmenc_sink_template); - gst_element_class_add_pad_template (element_class, gsmenc_src_template); + gst_element_class_add_pad_template (element_class, + gst_static_pad_template_get (&gsmenc_sink_template)); + gst_element_class_add_pad_template (element_class, + gst_static_pad_template_get (&gsmenc_src_template)); gst_element_class_set_details (element_class, &gst_gsmenc_details); } @@ -143,12 +139,14 @@ static void gst_gsmenc_init (GstGSMEnc *gsmenc) { /* create the sink and src pads */ - gsmenc->sinkpad = gst_pad_new_from_template (gsmenc_sink_template, "sink"); + gsmenc->sinkpad = gst_pad_new_from_template ( + gst_static_pad_template_get (&gsmenc_sink_template), "sink"); gst_element_add_pad (GST_ELEMENT (gsmenc), gsmenc->sinkpad); gst_pad_set_chain_function (gsmenc->sinkpad, gst_gsmenc_chain); gst_pad_set_link_function (gsmenc->sinkpad, gst_gsmenc_sinkconnect); - gsmenc->srcpad = gst_pad_new_from_template (gsmenc_src_template, "src"); + gsmenc->srcpad = gst_pad_new_from_template ( + gst_static_pad_template_get (&gsmenc_src_template), "src"); gst_element_add_pad (GST_ELEMENT (gsmenc), gsmenc->srcpad); gsmenc->state = gsm_create (); @@ -158,22 +156,20 @@ gst_gsmenc_init (GstGSMEnc *gsmenc) } static GstPadLinkReturn -gst_gsmenc_sinkconnect (GstPad *pad, GstCaps *caps) +gst_gsmenc_sinkconnect (GstPad *pad, const GstCaps *caps) { GstGSMEnc *gsmenc; + GstStructure *structure; gsmenc = GST_GSMENC (gst_pad_get_parent (pad)); - if (!GST_CAPS_IS_FIXED (caps)) - return GST_PAD_LINK_DELAYED; - - gst_caps_get_int (caps, "rate", &gsmenc->rate); - if (gst_pad_try_set_caps (gsmenc->srcpad, GST_CAPS_NEW ( - "gsm_gsm", - "audio/x-gsm", - "rate", GST_PROPS_INT (gsmenc->rate), - "channels", GST_PROPS_INT (1) - )) > 0) + structure = gst_caps_get_structure (caps, 0); + gst_structure_get_int (structure, "rate", &gsmenc->rate); + if (gst_pad_try_set_caps (gsmenc->srcpad, + gst_caps_new_simple("audio/x-gsm", + "rate", G_TYPE_INT, gsmenc->rate, + "channels", G_TYPE_INT, 1, + NULL)) > 0) { return GST_PAD_LINK_OK; } @@ -195,16 +191,6 @@ gst_gsmenc_chain (GstPad *pad, GstData *_data) gsmenc = GST_GSMENC (GST_OBJECT_PARENT (pad)); - if (!GST_PAD_CAPS (gsmenc->srcpad)) { - gst_pad_try_set_caps (gsmenc->srcpad, - GST_CAPS_NEW ( - "gsm_enc", - "audio/x-gsm", - "rate", GST_PROPS_INT (gsmenc->rate), - "channels", GST_PROPS_INT (1) - )); - } - data = (gsm_signal*) GST_BUFFER_DATA (buf); size = GST_BUFFER_SIZE (buf) / sizeof (gsm_signal); diff --git a/ext/hermes/gstcolorspace.c b/ext/hermes/gstcolorspace.c index 837c24e4..7a42e905 100644 --- a/ext/hermes/gstcolorspace.c +++ b/ext/hermes/gstcolorspace.c @@ -58,11 +58,7 @@ static void gst_colorspace_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); static GstPadLinkReturn - gst_colorspace_sinkconnect (GstPad *pad, GstCaps *caps); -static GstPadLinkReturn - gst_colorspace_srcconnect (GstPad *pad, GstCaps *caps); -static GstPadLinkReturn - gst_colorspace_srcconnect_func (GstPad *pad, GstCaps *caps, gboolean newcaps); + gst_colorspace_link (GstPad *pad, const GstCaps *caps); static void gst_colorspace_chain (GstPad *pad, GstData *_data); static GstElementStateReturn gst_colorspace_change_state (GstElement *element); @@ -77,36 +73,24 @@ static GstPadTemplate *srctempl, *sinktempl; static GstElementClass *parent_class = NULL; /*static guint gst_colorspace_signals[LAST_SIGNAL] = { 0 }; */ -static GstBufferPool* -colorspace_get_bufferpool (GstPad *pad) -{ - GstColorspace *space; - - space = GST_COLORSPACE (gst_pad_get_parent (pad)); - - if (space->type == GST_COLORSPACE_NONE && !space->disabled) - return gst_pad_get_bufferpool (space->srcpad); - else - return NULL; -} - static gboolean colorspace_setup_converter (GstColorspace *space, GstCaps *from_caps, GstCaps *to_caps) { guint32 from_space, to_space; + GstStructure *from_struct; + GstStructure *to_struct; g_return_val_if_fail (to_caps != NULL, FALSE); g_return_val_if_fail (from_caps != NULL, FALSE); - if (gst_caps_has_property (from_caps, "format")) - gst_caps_get_fourcc_int (from_caps, "format", &from_space); - else - from_space = GST_MAKE_FOURCC ('R','G','B',' '); + from_struct = gst_caps_get_structure (from_caps, 0); + to_struct = gst_caps_get_structure (to_caps, 0); - if (gst_caps_has_property (to_caps, "format")) - gst_caps_get_fourcc_int (to_caps, "format", &to_space); - else - to_space = GST_MAKE_FOURCC ('R','G','B',' '); + from_space = GST_MAKE_FOURCC ('R','G','B',' '); + gst_structure_get_fourcc (from_struct, "format", &from_space); + + to_space = GST_MAKE_FOURCC ('R','G','B',' '); + gst_structure_get_fourcc (to_struct, "format", &to_space); GST_INFO ("set up converter for " GST_FOURCC_FORMAT " (%08x) to " GST_FOURCC_FORMAT " (%08x)", @@ -118,7 +102,7 @@ colorspace_setup_converter (GstColorspace *space, GstCaps *from_caps, GstCaps *t { gint from_bpp; - gst_caps_get_int (from_caps, "bpp", &from_bpp); + gst_structure_get_int (from_struct, "bpp", &from_bpp); switch (to_space) { case GST_MAKE_FOURCC ('R','G','B',' '): @@ -126,11 +110,11 @@ colorspace_setup_converter (GstColorspace *space, GstCaps *from_caps, GstCaps *t { gint to_bpp; - gst_caps_get_int (to_caps, "bpp", &to_bpp); + gst_structure_get_int (to_struct, "bpp", &to_bpp); - gst_caps_get_int (from_caps, "red_mask", &space->source.r); - gst_caps_get_int (from_caps, "green_mask", &space->source.g); - gst_caps_get_int (from_caps, "blue_mask", &space->source.b); + gst_structure_get_int (from_struct, "red_mask", &space->source.r); + gst_structure_get_int (from_struct, "green_mask", &space->source.g); + gst_structure_get_int (from_struct, "blue_mask", &space->source.b); space->source.a = 0; space->srcbpp = space->source.bits = from_bpp; space->source.indexed = 0; @@ -141,9 +125,9 @@ colorspace_setup_converter (GstColorspace *space, GstCaps *from_caps, GstCaps *t GST_INFO ( "source blue mask %08x", space->source.b); GST_INFO ( "source bpp %08x", space->srcbpp); - gst_caps_get_int (to_caps, "red_mask", &space->dest.r); - gst_caps_get_int (to_caps, "green_mask", &space->dest.g); - gst_caps_get_int (to_caps, "blue_mask", &space->dest.b); + gst_structure_get_int (to_struct, "red_mask", &space->dest.r); + gst_structure_get_int (to_struct, "green_mask", &space->dest.g); + gst_structure_get_int (to_struct, "blue_mask", &space->dest.b); space->dest.a = 0; space->destbpp = space->dest.bits = to_bpp; space->dest.indexed = 0; @@ -189,7 +173,7 @@ colorspace_setup_converter (GstColorspace *space, GstCaps *from_caps, GstCaps *t case GST_MAKE_FOURCC ('R','G','B',' '): GST_INFO ( "colorspace: YUV to RGB"); - gst_caps_get_int (to_caps, "bpp", &space->destbpp); + gst_structure_get_int (to_struct, "bpp", &space->destbpp); space->converter = gst_colorspace_yuv2rgb_get_converter (from_caps, to_caps); space->type = GST_COLORSPACE_YUV_RGB; return TRUE; @@ -224,7 +208,7 @@ colorspace_setup_converter (GstColorspace *space, GstCaps *from_caps, GstCaps *t case GST_MAKE_FOURCC ('R','G','B',' '): GST_INFO ( "colorspace: YV12 to RGB"); - gst_caps_get_int (to_caps, "bpp", &space->destbpp); + gst_structure_get_int (to_struct, "bpp", &space->destbpp); space->converter = gst_colorspace_yuv2rgb_get_converter (from_caps, to_caps); space->type = GST_COLORSPACE_YUV_RGB; return TRUE; @@ -243,163 +227,68 @@ colorspace_setup_converter (GstColorspace *space, GstCaps *from_caps, GstCaps *t } static GstCaps* -gst_colorspace_getcaps (GstPad *pad, GstCaps *caps) +gst_colorspace_getcaps (GstPad *pad) { GstColorspace *space; - GstCaps *result; GstCaps *peercaps; - GstCaps *ourcaps, *temp; + GstCaps *ourcaps; space = GST_COLORSPACE (gst_pad_get_parent (pad)); /* we can do everything our peer can... */ - temp = gst_pad_get_allowed_caps (space->srcpad); - peercaps = gst_caps_copy (temp); - gst_caps_unref (temp); + peercaps = gst_pad_get_allowed_caps (space->srcpad); /* and our own template of course */ - temp = gst_pad_get_pad_template_caps (pad); - ourcaps = gst_caps_copy (temp); - gst_caps_unref (temp); + ourcaps = gst_caps_copy (gst_pad_get_pad_template_caps (pad)); /* merge them together, we prefer the peercaps first */ - result = gst_caps_prepend (ourcaps, peercaps); + gst_caps_append (peercaps, ourcaps); - return result; + return peercaps; } static GstPadLinkReturn -gst_colorspace_sinkconnect (GstPad *pad, GstCaps *caps) +gst_colorspace_link (GstPad *pad, const GstCaps *caps) { GstColorspace *space; - GstPad *peer; + GstPad *otherpad; + GstStructure *structure; space = GST_COLORSPACE (gst_pad_get_parent (pad)); + otherpad = (pad == space->sinkpad) ? space->srcpad : space->sinkpad; - if (!GST_CAPS_IS_FIXED (caps)) { - return GST_PAD_LINK_DELAYED; - } + structure = gst_caps_get_structure (caps, 0); - gst_caps_get_int (caps, "width", &space->width); - gst_caps_get_int (caps, "height", &space->height); - gst_caps_get_float (caps, "framerate", &space->fps); + gst_structure_get_int (structure, "width", &space->width); + gst_structure_get_int (structure, "height", &space->height); + gst_structure_get_double (structure, "framerate", &space->fps); GST_INFO ( "size: %dx%d", space->width, space->height); - gst_caps_replace_sink (&space->sinkcaps, caps); - - peer = gst_pad_get_peer (pad); - if (peer) { - GstCaps *allowed = gst_pad_get_allowed_caps (space->srcpad); - if (gst_colorspace_srcconnect_func (pad, allowed, FALSE) < 1) { - space->sinkcaps = NULL; - gst_caps_unref (allowed); - return GST_PAD_LINK_REFUSED; - } - gst_caps_unref (allowed); + if (pad == space->sinkpad) { + gst_caps_replace (&space->sinkcaps, gst_caps_copy(caps)); + } else { + gst_caps_replace (&space->srccaps, gst_caps_copy(caps)); } - return GST_PAD_LINK_OK; -} - -static GstPadLinkReturn -gst_colorspace_srcconnect (GstPad *pad, GstCaps *caps) -{ - return gst_colorspace_srcconnect_func (pad, caps, TRUE); -} - -static GstPadLinkReturn -gst_colorspace_srcconnect_func (GstPad *pad, GstCaps *caps, gboolean newcaps) -{ - GstColorspace *space; - GstCaps *peercaps; - GstCaps *ourcaps, *to_intersect, *try_peercaps; - GstPadLinkReturn res = GST_PAD_LINK_REFUSED; - - space = GST_COLORSPACE (gst_pad_get_parent (pad)); - - /* we cannot operate if we didn't get src caps */ - ourcaps = space->sinkcaps; - if (!ourcaps) { - if (newcaps) - gst_pad_recalc_allowed_caps (space->sinkpad); - +#if 0 + peer = gst_pad_get_peer (otherpad); + if (!peer) { return GST_PAD_LINK_DELAYED; } +#endif - /* first see if we can do the format natively by filtering the peer caps - * with our incomming caps */ - peercaps = gst_caps_intersect (caps, ourcaps); - if (peercaps) { - GstCaps *trycaps; - - trycaps = peercaps; - while(trycaps){ - GstCaps *caps1 = gst_caps_copy_1(trycaps); - - /* see if the peer likes it too, it should as the caps say so.. */ - if (gst_pad_try_set_caps (space->srcpad, caps1) > 0) { - space->type = GST_COLORSPACE_NONE; - space->disabled = FALSE; - gst_caps_unref (peercaps); - peercaps = caps1; - res = GST_PAD_LINK_DONE; - goto success; - } - trycaps = trycaps->next; - } - gst_caps_unref (peercaps); - } + if (gst_pad_try_set_caps (otherpad, caps) >= 0) { + space->passthru = TRUE; - to_intersect = gst_caps_append ( - GST_CAPS_NEW ( - "colorspace_filter", - "video/x-raw-yuv", - "width", GST_PROPS_INT (space->width), - "height", GST_PROPS_INT (space->height), - "framerate", GST_PROPS_FLOAT (space->fps) - ), GST_CAPS_NEW ( - "colorspace_filter", - "video/x-raw-rgb", - "width", GST_PROPS_INT (space->width), - "height", GST_PROPS_INT (space->height), - "framerate", GST_PROPS_FLOAT (space->fps) - )); - - /* then see what the peer has that matches the size */ - peercaps = gst_caps_intersect (caps, to_intersect); - gst_caps_unref (to_intersect); - - /* we are looping over the caps, so we have to get rid of the lists */ - try_peercaps = gst_caps_normalize (peercaps); - gst_caps_unref (peercaps); - peercaps = try_peercaps; - - /* loop over all possibilities and select the first one we can convert and - * is accepted by the peer */ - while (peercaps) { - GstCaps *peer1 = gst_caps_copy_1(peercaps); - - if (colorspace_setup_converter (space, ourcaps, peer1)) { - if (gst_pad_try_set_caps (space->srcpad, peer1) > 0) { - space->disabled = FALSE; - gst_caps_unref (try_peercaps); - res = GST_PAD_LINK_DONE; - goto success; - } - } - peercaps = peercaps->next; + return GST_PAD_LINK_OK; } - gst_caps_unref (try_peercaps); - - /* we disable ourself here */ - space->disabled = TRUE; - goto done; -success: -done: + if (colorspace_setup_converter (space, space->sinkcaps, space->srccaps)) { + return GST_PAD_LINK_OK; + } - return res; + return GST_PAD_LINK_REFUSED; } GType @@ -431,40 +320,22 @@ gst_colorspace_base_init (gpointer g_class) GstCaps *caps; /* create caps for templates */ - caps = gst_caps_new ("csp_templ_yuv", - "video/x-raw-yuv", - GST_VIDEO_YUV_PAD_TEMPLATE_PROPS ( - GST_PROPS_LIST ( - GST_PROPS_FOURCC (GST_STR_FOURCC ("I420")), - GST_PROPS_FOURCC (GST_STR_FOURCC ("YV12")), - GST_PROPS_FOURCC (GST_STR_FOURCC ("YUY2"))))); - caps = gst_caps_append (caps, - gst_caps_new ("csp_templ_rgb24_32", - "video/x-raw-rgb", - GST_VIDEO_RGB_PAD_TEMPLATE_PROPS_24_32_REVERSE)); - caps = gst_caps_append (caps, - gst_caps_new ("csp_templ_rgb24_32", - "video/x-raw-rgb", - GST_VIDEO_RGB_PAD_TEMPLATE_PROPS_24_32)); - caps = gst_caps_append (caps, - gst_caps_new ("csp_templ_rgb15", - "video/x-raw-rgb", - GST_VIDEO_RGB_PAD_TEMPLATE_PROPS_15)); - caps = gst_caps_append (caps, - gst_caps_new ("csp_templ_rgb16", - "video/x-raw-rgb", - GST_VIDEO_RGB_PAD_TEMPLATE_PROPS_16)); + caps = gst_caps_from_string ( + GST_VIDEO_YUV_PAD_TEMPLATE_CAPS ("{ I420, YV12, YUY2 }") "; " + GST_VIDEO_RGB_PAD_TEMPLATE_CAPS_24_32_REVERSE "; " + GST_VIDEO_RGB_PAD_TEMPLATE_CAPS_24_32 "; " + GST_VIDEO_RGB_PAD_TEMPLATE_CAPS_15 "; " + GST_VIDEO_RGB_PAD_TEMPLATE_CAPS_16); /* build templates */ srctempl = gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, - caps, NULL); - gst_caps_ref (caps); + caps); sinktempl = gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, - caps, NULL); + caps); gst_element_class_add_pad_template (element_class, srctempl); gst_element_class_add_pad_template (element_class, sinktempl); gst_element_class_set_details (element_class, &colorspace_details); @@ -491,22 +362,20 @@ static void gst_colorspace_init (GstColorspace *space) { space->sinkpad = gst_pad_new_from_template (sinktempl, "sink"); - gst_pad_set_link_function (space->sinkpad, gst_colorspace_sinkconnect); + gst_pad_set_link_function (space->sinkpad, gst_colorspace_link); gst_pad_set_getcaps_function (space->sinkpad, gst_colorspace_getcaps); - gst_pad_set_bufferpool_function (space->sinkpad, colorspace_get_bufferpool); gst_pad_set_chain_function(space->sinkpad,gst_colorspace_chain); gst_element_add_pad(GST_ELEMENT(space),space->sinkpad); space->srcpad = gst_pad_new_from_template (srctempl, "src"); gst_element_add_pad(GST_ELEMENT(space),space->srcpad); - gst_pad_set_link_function (space->srcpad, gst_colorspace_srcconnect); + gst_pad_set_link_function (space->srcpad, gst_colorspace_link); #ifdef HAVE_HERMES space->h_handle = Hermes_ConverterInstance (0); #endif - space->pool = NULL; space->converter = NULL; - space->disabled = TRUE; + space->passthru = FALSE; } static void @@ -516,6 +385,7 @@ gst_colorspace_chain (GstPad *pad,GstData *_data) GstColorspace *space; gint size; GstBuffer *outbuf = NULL; + gint dest_bytes, src_bytes; g_return_if_fail (pad != NULL); g_return_if_fail (GST_IS_PAD (pad)); @@ -526,74 +396,55 @@ gst_colorspace_chain (GstPad *pad,GstData *_data) g_return_if_fail (space != NULL); g_return_if_fail (GST_IS_COLORSPACE (space)); - if (space->disabled) { - gst_buffer_unref (buf); + if (space->passthru) { + gst_pad_push (space->srcpad, _data); return; } - if (space->type == GST_COLORSPACE_NONE) { - outbuf = buf; - } - else { - gint dest_bytes, src_bytes; - - size = space->width * space->height; - dest_bytes = ((space->destbpp+7)/8); - src_bytes = ((space->srcbpp+7)/8); - - if (!space->pool) - space->pool = gst_pad_get_bufferpool (space->srcpad); - - if (space->pool) { - outbuf = gst_buffer_new_from_pool (space->pool, 0, 0); - } - - if (!outbuf) { - outbuf = gst_buffer_new (); + size = space->width * space->height; + dest_bytes = ((space->destbpp+7)/8); + src_bytes = ((space->srcbpp+7)/8); - GST_BUFFER_SIZE (outbuf) = (size * space->destbpp)/8; - GST_BUFFER_DATA (outbuf) = g_malloc (GST_BUFFER_SIZE (outbuf)); - } + outbuf = gst_buffer_new_and_alloc ((size * space->destbpp)/8); - if (space->type == GST_COLORSPACE_YUV_RGB) { - gst_colorspace_convert (space->converter, GST_BUFFER_DATA (buf), GST_BUFFER_DATA (outbuf)); - } + if (space->type == GST_COLORSPACE_YUV_RGB) { + gst_colorspace_convert (space->converter, GST_BUFFER_DATA (buf), GST_BUFFER_DATA (outbuf)); + } #ifdef HAVE_HERMES - else if (space->type == GST_COLORSPACE_HERMES) { - Hermes_ConverterCopy (space->h_handle, - GST_BUFFER_DATA (buf), 0, 0, space->width, space->height, space->width * src_bytes, - GST_BUFFER_DATA (outbuf), 0, 0, space->width, space->height, space->width * dest_bytes); - } + else if (space->type == GST_COLORSPACE_HERMES) { + Hermes_ConverterCopy (space->h_handle, + GST_BUFFER_DATA (buf), 0, 0, space->width, space->height, space->width * src_bytes, + GST_BUFFER_DATA (outbuf), 0, 0, space->width, space->height, space->width * dest_bytes); + } #endif - else if (space->type == GST_COLORSPACE_YUY2_I420) { - gst_colorspace_yuy2_to_i420 (GST_BUFFER_DATA (buf), - GST_BUFFER_DATA (outbuf), - space->width, - space->height); - } - else if (space->type == GST_COLORSPACE_420_SWAP) { - gst_colorspace_i420_to_yv12 (GST_BUFFER_DATA (buf), - GST_BUFFER_DATA (outbuf), - space->width, - space->height); - } - else if (space->type == GST_COLORSPACE_RGB32_I420) { - gst_colorspace_rgb32_to_i420 (GST_BUFFER_DATA (buf), - GST_BUFFER_DATA (outbuf), - space->width, - space->height); - } - else if (space->type == GST_COLORSPACE_RGB32_YV12) { - gst_colorspace_rgb32_to_yv12 (GST_BUFFER_DATA (buf), - GST_BUFFER_DATA (outbuf), - space->width, - space->height); - } + else if (space->type == GST_COLORSPACE_YUY2_I420) { + gst_colorspace_yuy2_to_i420 (GST_BUFFER_DATA (buf), + GST_BUFFER_DATA (outbuf), + space->width, + space->height); + } + else if (space->type == GST_COLORSPACE_420_SWAP) { + gst_colorspace_i420_to_yv12 (GST_BUFFER_DATA (buf), + GST_BUFFER_DATA (outbuf), + space->width, + space->height); + } + else if (space->type == GST_COLORSPACE_RGB32_I420) { + gst_colorspace_rgb32_to_i420 (GST_BUFFER_DATA (buf), + GST_BUFFER_DATA (outbuf), + space->width, + space->height); + } + else if (space->type == GST_COLORSPACE_RGB32_YV12) { + gst_colorspace_rgb32_to_yv12 (GST_BUFFER_DATA (buf), + GST_BUFFER_DATA (outbuf), + space->width, + space->height); + } - GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buf); + GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buf); - gst_buffer_unref (buf); - } + gst_buffer_unref (buf); gst_pad_push (space->srcpad, GST_DATA (outbuf)); } @@ -608,14 +459,10 @@ gst_colorspace_change_state (GstElement *element) case GST_STATE_PAUSED_TO_PLAYING: break; case GST_STATE_PLAYING_TO_PAUSED: - if (space->pool) - gst_buffer_pool_unref (space->pool); - space->pool = NULL; break; case GST_STATE_PAUSED_TO_READY: gst_colorspace_converter_destroy (space->converter); space->converter = NULL; - space->disabled = TRUE; space->type = GST_COLORSPACE_NONE; gst_caps_replace (&space->sinkcaps, NULL); break; diff --git a/ext/hermes/gstcolorspace.h b/ext/hermes/gstcolorspace.h index ef8a8bfe..0cf6f2d7 100644 --- a/ext/hermes/gstcolorspace.h +++ b/ext/hermes/gstcolorspace.h @@ -75,13 +75,12 @@ struct _GstColorspace { GstColorSpaceConverterType type; gint width, height; - gfloat fps; + gdouble fps; gint srcbpp, destbpp; - gboolean disabled; + gboolean passthru; GstCaps *sinkcaps; - - GstBufferPool *pool; + GstCaps *srccaps; }; struct _GstColorspaceClass { diff --git a/ext/hermes/yuv2rgb.c b/ext/hermes/yuv2rgb.c index a1669b25..b3b1b494 100644 --- a/ext/hermes/yuv2rgb.c +++ b/ext/hermes/yuv2rgb.c @@ -105,22 +105,26 @@ static GstColorSpaceYUVTables * gst_colorspace_init_yuv(long depth, long red_mask, long green_mask, long blue_mask); GstColorSpaceConverter* -gst_colorspace_yuv2rgb_get_converter (GstCaps *from, GstCaps *to) +gst_colorspace_yuv2rgb_get_converter (const GstCaps *from, const GstCaps *to) { guint32 from_space; GstColorSpaceConverter *new; gint to_bpp; + GstStructure *struct_from, *struct_to; GST_DEBUG ("gst_colorspace_yuv2rgb_get_converter"); new = g_malloc (sizeof (GstColorSpaceConverter)); - gst_caps_get_int (from, "width", &new->width); - gst_caps_get_int (from, "height", &new->height); + struct_from = gst_caps_get_structure (from, 0); + struct_to = gst_caps_get_structure (to, 0); + + gst_structure_get_int (struct_from, "width", &new->width); + gst_structure_get_int (struct_from, "height", &new->height); new->color_tables = NULL; - gst_caps_get_fourcc_int (from, "format", &from_space); - gst_caps_get_int (to, "bpp", &to_bpp); + gst_structure_get_fourcc (struct_from, "format", &from_space); + gst_structure_get_int (struct_to, "bpp", &to_bpp); /* FIXME we leak new here. */ @@ -132,9 +136,9 @@ gst_colorspace_yuv2rgb_get_converter (GstCaps *from, GstCaps *to) gint green_mask; gint blue_mask; - gst_caps_get_int (to, "red_mask", &red_mask); - gst_caps_get_int (to, "green_mask", &green_mask); - gst_caps_get_int (to, "blue_mask", &blue_mask); + gst_structure_get_int (struct_to, "red_mask", &red_mask); + gst_structure_get_int (struct_to, "green_mask", &green_mask); + gst_structure_get_int (struct_to, "blue_mask", &blue_mask); GST_INFO ( "red_mask %08x", red_mask); GST_INFO ( "green_mask %08x", green_mask); diff --git a/ext/hermes/yuv2rgb.h b/ext/hermes/yuv2rgb.h index 699234a3..7edfa377 100644 --- a/ext/hermes/yuv2rgb.h +++ b/ext/hermes/yuv2rgb.h @@ -59,7 +59,7 @@ struct _GstColorSpaceConverter { }; -GstColorSpaceConverter* gst_colorspace_yuv2rgb_get_converter (GstCaps *from, GstCaps *to); +GstColorSpaceConverter* gst_colorspace_yuv2rgb_get_converter (const GstCaps *from, const GstCaps *to); #define gst_colorspace_convert(converter, src, dest) \ (converter)->convert((converter), (src), (dest)) void gst_colorspace_converter_destroy (GstColorSpaceConverter *space); diff --git a/ext/jack/gstjack.c b/ext/jack/gstjack.c index 85d57658..4a987ae1 100644 --- a/ext/jack/gstjack.c +++ b/ext/jack/gstjack.c @@ -77,7 +77,7 @@ static GstPadTemplate* gst_jack_sink_request_pad_factory(); static GstPad* gst_jack_request_new_pad (GstElement *element, GstPadTemplate *templ, const gchar *name); static GstElementStateReturn gst_jack_change_state (GstElement *element); -static GstPadLinkReturn gst_jack_link (GstPad *pad, GstCaps *caps); +static GstPadLinkReturn gst_jack_link (GstPad *pad, const GstCaps *caps); static void gst_jack_loop (GstElement *element); @@ -264,11 +264,9 @@ gst_jack_src_request_pad_factory (void) if (!template) { GstCaps *caps; - caps = gst_caps_new ("src", - "audio/x-raw-float", - GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_PROPS); + caps = gst_caps_from_string (GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS); template = gst_pad_template_new ("%s", GST_PAD_SRC, - GST_PAD_REQUEST, caps, NULL); + GST_PAD_REQUEST, caps); } return template; @@ -281,11 +279,9 @@ gst_jack_sink_request_pad_factory (void) if (!template) { GstCaps *caps; - caps = gst_caps_new ("sink", - "audio/x-raw-float", - GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_PROPS); + caps = gst_caps_from_string (GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS); template = gst_pad_template_new ("%s", GST_PAD_SINK, - GST_PAD_REQUEST, caps, NULL); + GST_PAD_REQUEST, caps); } return template; @@ -397,10 +393,10 @@ gst_jack_change_state (GstElement *element) while (l) { pad = GST_JACK_PAD (l); caps = gst_pad_get_caps (pad->pad); - gst_caps_set (caps, "rate", GST_PROPS_INT_TYPE, - (gint)this->bin->rate, NULL); - gst_caps_set (caps, "buffer-frames", GST_PROPS_INT_TYPE, - (gint)this->bin->nframes, NULL); + gst_caps_set_simple (caps, + "rate", G_TYPE_INT, (int)this->bin->rate, + "buffer-frames", G_TYPE_INT, (gint)this->bin->nframes, + NULL); if (gst_pad_try_set_caps (pad->pad, caps) <= 0) return GST_STATE_FAILURE; l = g_list_next (l); @@ -421,24 +417,22 @@ gst_jack_change_state (GstElement *element) } static GstPadLinkReturn -gst_jack_link (GstPad *pad, GstCaps *caps) +gst_jack_link (GstPad *pad, const GstCaps *caps) { GstJack *this; gint rate, buffer_frames; + GstStructure *structure; this = GST_JACK (GST_OBJECT_PARENT (pad)); - if (GST_CAPS_IS_FIXED (caps)) { - gst_caps_get_int (caps, "rate", &rate); - gst_caps_get_int (caps, "buffer-frames", &buffer_frames); - if (this->bin && (rate != this->bin->rate || - buffer_frames != this->bin->nframes)) - return GST_PAD_LINK_REFUSED; - - return GST_PAD_LINK_OK; - } + structure = gst_caps_get_structure (caps, 0); + gst_structure_get_int (structure, "rate", &rate); + gst_structure_get_int (structure, "buffer-frames", &buffer_frames); + if (this->bin && (rate != this->bin->rate || + buffer_frames != this->bin->nframes)) + return GST_PAD_LINK_REFUSED; - return GST_PAD_LINK_DELAYED; + return GST_PAD_LINK_OK; } static void diff --git a/ext/ladspa/gstladspa.c b/ext/ladspa/gstladspa.c index 6ecb3ce1..ff2711fc 100644 --- a/ext/ladspa/gstladspa.c +++ b/ext/ladspa/gstladspa.c @@ -37,45 +37,15 @@ #define LADSPA_VERSION "1.0" #endif -/* takes ownership of the name */ -static GstPadTemplate* -ladspa_sink_factory (gchar *name) -{ - return GST_PAD_TEMPLATE_NEW ( - name, - GST_PAD_SINK, - GST_PAD_ALWAYS, - gst_caps_new ( - "ladspa_sink", - "audio/x-raw-float", - GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_PROPS - ) - ); -} - -/* takes ownership of the name */ -static GstPadTemplate* -ladspa_src_factory (gchar *name) -{ - return GST_PAD_TEMPLATE_NEW ( - name, - GST_PAD_SRC, - GST_PAD_ALWAYS, - gst_caps_new ( - "ladspa_src", - "audio/x-raw-float", - GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_PROPS - ) - ); -} +static GstStaticCaps ladspa_pad_caps = +GST_STATIC_CAPS (GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS); static void gst_ladspa_class_init (GstLADSPAClass *klass); static void gst_ladspa_base_init (GstLADSPAClass *klass); static void gst_ladspa_init (GstLADSPA *ladspa); static void gst_ladspa_update_int (const GValue *value, gpointer data); -static GstPadLinkReturn gst_ladspa_link (GstPad *pad, GstCaps *caps); -static void gst_ladspa_force_src_caps (GstLADSPA *ladspa, GstPad *pad); +static GstPadLinkReturn gst_ladspa_link (GstPad *pad, const GstCaps *caps); static void gst_ladspa_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); static void gst_ladspa_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); @@ -141,10 +111,12 @@ gst_ladspa_base_init (GstLADSPAClass *klass) /* the factories take ownership of the name */ if (LADSPA_IS_PORT_INPUT(desc->PortDescriptors[j])) { - templ = ladspa_sink_factory (name); + templ = gst_pad_template_new (name, GST_PAD_SINK, GST_PAD_ALWAYS, + gst_caps_copy (gst_static_caps_get (&ladspa_pad_caps))); klass->numsinkpads++; } else { - templ = ladspa_src_factory (name); + templ = gst_pad_template_new (name, GST_PAD_SRC, GST_PAD_ALWAYS, + gst_caps_copy (gst_static_caps_get (&ladspa_pad_caps))); klass->numsrcpads++; } @@ -456,7 +428,6 @@ gst_ladspa_init (GstLADSPA *ladspa) ladspa->buffer_frames = 0; /* should be set with caps */ ladspa->activated = FALSE; - ladspa->bufpool = NULL; ladspa->inplace_broken = LADSPA_IS_INPLACE_BROKEN(ladspa->descriptor->Properties); if (sinkcount==0 && srccount == 1) { @@ -492,52 +463,43 @@ gst_ladspa_update_int(const GValue *value, gpointer data) } static GstPadLinkReturn -gst_ladspa_link (GstPad *pad, GstCaps *caps) +gst_ladspa_link (GstPad *pad, const GstCaps *caps) { GstElement *element = (GstElement*)GST_PAD_PARENT (pad); GstLADSPA *ladspa = (GstLADSPA*)element; const GList *l = NULL; gint rate; + GstStructure *structure; - if (GST_CAPS_IS_FIXED (caps)) { - /* if this fails in some other plugin, the graph is left in an inconsistent - state */ - for (l=gst_element_get_pad_list (element); l; l=l->next) - if (pad != (GstPad*)l->data) - if (gst_pad_try_set_caps ((GstPad*)l->data, caps) <= 0) - return GST_PAD_LINK_REFUSED; - - /* we assume that the ladspa plugin can handle any sample rate, so this - check gets put last */ - gst_caps_get_int (caps, "rate", &rate); - /* have to instantiate ladspa plugin when samplerate changes (groan) */ - if (ladspa->samplerate != rate) { - ladspa->samplerate = rate; - if (! gst_ladspa_instantiate(ladspa)) + /* if this fails in some other plugin, the graph is left in an inconsistent + state */ + for (l=gst_element_get_pad_list (element); l; l=l->next) + if (pad != (GstPad*)l->data) + if (gst_pad_try_set_caps ((GstPad*)l->data, caps) <= 0) return GST_PAD_LINK_REFUSED; - } - - gst_caps_get_int (caps, "buffer-frames", &ladspa->buffer_frames); - - if (ladspa->bufpool) - gst_buffer_pool_unref (ladspa->bufpool); - ladspa->bufpool = gst_buffer_pool_get_default (ladspa->buffer_frames * sizeof(gfloat), - 3); - - return GST_PAD_LINK_OK; + + /* we assume that the ladspa plugin can handle any sample rate, so this + check gets put last */ + structure = gst_caps_get_structure (caps, 0); + gst_structure_get_int (structure, "rate", &rate); + /* have to instantiate ladspa plugin when samplerate changes (groan) */ + if (ladspa->samplerate != rate) { + ladspa->samplerate = rate; + if (! gst_ladspa_instantiate(ladspa)) + return GST_PAD_LINK_REFUSED; } - return GST_PAD_LINK_DELAYED; + gst_structure_get_int (structure, "buffer-frames", &ladspa->buffer_frames); + + return GST_PAD_LINK_OK; } +#if 0 static void gst_ladspa_force_src_caps(GstLADSPA *ladspa, GstPad *pad) { if (!ladspa->buffer_frames) { ladspa->buffer_frames = 256; /* 5 ms at 44100 kHz (just a default...) */ - g_return_if_fail (ladspa->bufpool == NULL); - ladspa->bufpool = - gst_buffer_pool_get_default (ladspa->buffer_frames * sizeof(gfloat), 3); } DEBUG_OBJ (ladspa, "forcing caps with rate=%d, buffer-frames=%d", @@ -548,13 +510,14 @@ gst_ladspa_force_src_caps(GstLADSPA *ladspa, GstPad *pad) "ladspa_src_caps", "audio/x-raw-float", gst_props_new ( - "width", GST_PROPS_INT (32), - "endianness", GST_PROPS_INT (G_BYTE_ORDER), - "rate", GST_PROPS_INT (ladspa->samplerate), - "buffer-frames", GST_PROPS_INT (ladspa->buffer_frames), - "channels", GST_PROPS_INT (1), + "width", G_TYPE_INT (32), + "endianness", G_TYPE_INT (G_BYTE_ORDER), + "rate", G_TYPE_INT (ladspa->samplerate), + "buffer-frames", G_TYPE_INT (ladspa->buffer_frames), + "channels", G_TYPE_INT (1), NULL))); } +#endif static void gst_ladspa_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) @@ -759,11 +722,6 @@ gst_ladspa_loop (GstElement *element) GST_BUFFER_TIMESTAMP(buffers_in[i]) = ladspa->timestamp; } - if (!ladspa->bufpool) { - gst_element_error (element, "Caps were never set, bailing..."); - return; - } - i=0; if (!ladspa->inplace_broken) { for (; i<numsrcpads && i<numsinkpads; i++) { @@ -773,8 +731,7 @@ gst_ladspa_loop (GstElement *element) } } for (; i<numsrcpads; i++) { - /* we have to make new buffers -- at least we're taking them from a pool */ - buffers_out[i] = gst_buffer_new_from_pool (ladspa->bufpool, 0, 0); + buffers_out[i] = gst_buffer_new_and_alloc (ladspa->buffer_frames * sizeof(gfloat)); GST_BUFFER_TIMESTAMP (buffers_out[i]) = ladspa->timestamp; data_out[i] = (LADSPA_Data*)GST_BUFFER_DATA (buffers_out[i]); } @@ -850,11 +807,6 @@ gst_ladspa_chain (GstPad *pad, GstData *_data) /* we shouldn't get events here... */ g_return_if_fail (GST_IS_BUFFER (buffer_in)); - if (!ladspa->bufpool) { - gst_element_error ((GstElement*)ladspa, "Caps were never set, bailing..."); - return; - } - /* FIXME: this function shouldn't need to malloc() anything */ if (numsrcpads > 0) { buffers_out = g_new(GstBuffer*, numsrcpads); @@ -870,11 +822,7 @@ gst_ladspa_chain (GstPad *pad, GstData *_data) i++; } for (; i<numsrcpads; i++) { - /* we have to make new buffers -- at least we're taking them from a pool */ - buffers_out[i] = gst_buffer_new_from_pool (ladspa->bufpool, 0, 0); - /* the size of the buffer returned from the pool is the maximum size; this - chained buffer might be smaller */ - GST_BUFFER_SIZE (buffers_out[i]) = GST_BUFFER_SIZE (buffer_in); + buffers_out[i] = gst_buffer_new_and_alloc (GST_BUFFER_SIZE(buffer_in)); DEBUG ("new %d", GST_BUFFER_SIZE (buffer_in)); GST_BUFFER_TIMESTAMP (buffers_out[i]) = ladspa->timestamp; data_out[i] = (LADSPA_Data*)GST_BUFFER_DATA (buffers_out[i]); @@ -932,12 +880,8 @@ gst_ladspa_get(GstPad *pad) oclass = (GstLADSPAClass*)(G_OBJECT_GET_CLASS(ladspa)); desc = ladspa->descriptor; - if (!ladspa->bufpool) { - /* capsnego hasn't happened... */ - gst_ladspa_force_src_caps(ladspa, ladspa->srcpads[0]); - } - - buf = gst_buffer_new_from_pool (ladspa->bufpool, 0, 0); + /* 4096 is arbitrary */ + buf = gst_buffer_new_and_alloc (4096); GST_BUFFER_TIMESTAMP(buf) = ladspa->timestamp; data = (LADSPA_Data *) GST_BUFFER_DATA(buf); diff --git a/ext/ladspa/gstladspa.h b/ext/ladspa/gstladspa.h index b588ffa4..f3556f74 100644 --- a/ext/ladspa/gstladspa.h +++ b/ext/ladspa/gstladspa.h @@ -59,8 +59,6 @@ struct _GstLADSPA { GstPad **sinkpads, **srcpads; - GstBufferPool *bufpool; - gboolean activated; gint samplerate, buffer_frames; diff --git a/ext/libfame/gstlibfame.c b/ext/libfame/gstlibfame.c index be2404d5..c68ff36b 100644 --- a/ext/libfame/gstlibfame.c +++ b/ext/libfame/gstlibfame.c @@ -60,54 +60,34 @@ enum { /* FILL ME */ }; -GST_PAD_TEMPLATE_FACTORY (sink_template_factory, +static GstStaticPadTemplate sink_template = +GST_STATIC_PAD_TEMPLATE ( "sink", GST_PAD_SINK, GST_PAD_ALWAYS, - GST_CAPS_NEW ( - "fameenc_sink_caps", - "video/x-raw-yuv", - "format", - GST_PROPS_FOURCC (GST_MAKE_FOURCC ('I','4','2','0')), - "width", GST_PROPS_INT_RANGE (16, 4096), - "height", GST_PROPS_INT_RANGE (16, 4096), - "framerate", GST_PROPS_LIST ( - GST_PROPS_FLOAT (24/1.001), - GST_PROPS_FLOAT (24.), - GST_PROPS_FLOAT (25.), - GST_PROPS_FLOAT (30/1.001), - GST_PROPS_FLOAT (30.), - GST_PROPS_FLOAT (50.), - GST_PROPS_FLOAT (60/1.001), - GST_PROPS_FLOAT (60.) - ) + GST_STATIC_CAPS ( + "video/x-raw-yuv, " + "format = (fourcc) I420, " + "width = (int) [ 16, 4096 ], " + "height = (int) [ 16, 4096 ], " + "framerate = (double) { 23.976024, 24.0, 25.0, 29.970030, 30.0, " + " 50.0, 59.940060, 60.0 }" ) -) +); -GST_PAD_TEMPLATE_FACTORY (src_template_factory, +static GstStaticPadTemplate src_template = +GST_STATIC_PAD_TEMPLATE ( "src", GST_PAD_SRC, GST_PAD_ALWAYS, - GST_CAPS_NEW ( - "fameenc_src_caps", - "video/mpeg", - "mpegversion", GST_PROPS_LIST ( - GST_PROPS_INT (1), - GST_PROPS_INT (4) - ), - "systemstream", GST_PROPS_BOOLEAN (FALSE), - "width", GST_PROPS_INT_RANGE (16, 4096), - "height", GST_PROPS_INT_RANGE (16, 4096), - "framerate", GST_PROPS_LIST ( - GST_PROPS_FLOAT (24/1.001), - GST_PROPS_FLOAT (24.), - GST_PROPS_FLOAT (25.), - GST_PROPS_FLOAT (30/1.001), - GST_PROPS_FLOAT (30.), - GST_PROPS_FLOAT (50.), - GST_PROPS_FLOAT (60/1.001), - GST_PROPS_FLOAT (60.) - ) + GST_STATIC_CAPS ( + "video/mpeg, " + "mpegversion = (int) { 1, 4 }, " + "systemstream = (boolean) FALSE, " + "width = (int) [ 16, 4096 ], " + "height = (int) [ 16, 4096 ], " + "framerate = (double) { 23.976024, 24.0, 25.0, 29.970030, 30.0, " + " 50.0, 59.940060, 60.0 }" ) ); @@ -205,9 +185,9 @@ gst_fameenc_base_init (GstFameEncClass *klass) GstElementClass *element_class = GST_ELEMENT_CLASS (klass); gst_element_class_add_pad_template (element_class, - GST_PAD_TEMPLATE_GET (sink_template_factory)); + gst_static_pad_template_get (&sink_template)); gst_element_class_add_pad_template (element_class, - GST_PAD_TEMPLATE_GET (src_template_factory)); + gst_static_pad_template_get (&src_template)); gst_element_class_set_details (element_class, &gst_fameenc_details); } @@ -318,25 +298,24 @@ gst_fameenc_class_init (GstFameEncClass *klass) } static GstPadLinkReturn -gst_fameenc_sinkconnect (GstPad *pad, GstCaps *caps) +gst_fameenc_sink_link (GstPad *pad, const GstCaps *caps) { gint width, height, fps_idx; - gfloat fps; + gdouble fps; GstFameEnc *fameenc; + GstStructure *structure; fameenc = GST_FAMEENC (gst_pad_get_parent (pad)); - if (!GST_CAPS_IS_FIXED (caps)) - return GST_PAD_LINK_DELAYED; - if (fameenc->initialized) { GST_DEBUG ("error: fameenc encoder already initialized !"); return GST_PAD_LINK_REFUSED; } - gst_caps_get_int (caps, "width", &width); - gst_caps_get_int (caps, "height", &height); - gst_caps_get_float (caps, "framerate", &fps); + structure = gst_caps_get_structure (caps, 0); + gst_structure_get_int (structure, "width", &width); + gst_structure_get_int (structure, "height", &height); + gst_structure_get_double (structure, "framerate", &fps); /* fameenc requires width and height to be multiples of 16 */ if (width % 16 != 0 || height % 16 != 0) @@ -380,13 +359,13 @@ gst_fameenc_init (GstFameEnc *fameenc) /* create the sink and src pads */ fameenc->sinkpad = gst_pad_new_from_template ( - GST_PAD_TEMPLATE_GET (sink_template_factory), "sink"); + gst_static_pad_template_get (&sink_template), "sink"); gst_element_add_pad (GST_ELEMENT (fameenc), fameenc->sinkpad); gst_pad_set_chain_function (fameenc->sinkpad, gst_fameenc_chain); - gst_pad_set_link_function (fameenc->sinkpad, gst_fameenc_sinkconnect); + gst_pad_set_link_function (fameenc->sinkpad, gst_fameenc_sink_link); fameenc->srcpad = gst_pad_new_from_template ( - GST_PAD_TEMPLATE_GET (src_template_factory), "src"); + gst_static_pad_template_get (&src_template), "src"); gst_element_add_pad (GST_ELEMENT (fameenc), fameenc->srcpad); /* FIXME: set some more handler functions here */ diff --git a/ext/mas/massink.c b/ext/mas/massink.c index 2b52a45a..01eed9e6 100644 --- a/ext/mas/massink.c +++ b/ext/mas/massink.c @@ -49,15 +49,12 @@ enum { ARG_HOST, }; -GST_PAD_TEMPLATE_FACTORY (sink_factory, - "sink", /* the name of the pads */ - GST_PAD_SINK, /* type of the pad */ - GST_PAD_ALWAYS, /* ALWAYS/SOMETIMES */ - GST_CAPS_NEW ( - "massink_sink8", /* the name of the caps */ - "audio/x-raw-int", - NULL - ) +static GstStaticPadTemplate sink_factory = +GST_STATIC_PAD_TEMPLATE ( + "sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ("audio/x-raw-int") ); static void gst_massink_base_init (gpointer g_class); @@ -68,7 +65,7 @@ static gboolean gst_massink_open_audio (GstMassink *sink); //static void gst_massink_close_audio (GstMassink *sink); static GstElementStateReturn gst_massink_change_state (GstElement *element); static gboolean gst_massink_sync_parms (GstMassink *massink); -static GstPadLinkReturn gst_massink_sinkconnect (GstPad *pad, GstCaps *caps); +static GstPadLinkReturn gst_massink_sinkconnect (GstPad *pad, const GstCaps *caps); static void gst_massink_chain (GstPad *pad, GstData *_data); @@ -130,7 +127,7 @@ gst_massink_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 (sink_factory)); + gst_static_pad_template_get (&sink_factory)); gst_element_class_set_details (element_class, &massink_details); } @@ -179,7 +176,7 @@ static void gst_massink_init(GstMassink *massink) { massink->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(massink), massink->sinkpad); gst_pad_set_chain_function(massink->sinkpad, GST_DEBUG_FUNCPTR(gst_massink_chain)); gst_pad_set_link_function(massink->sinkpad, gst_massink_sinkconnect); @@ -204,15 +201,12 @@ gst_massink_sync_parms (GstMassink *massink) } static GstPadLinkReturn -gst_massink_sinkconnect (GstPad *pad, GstCaps *caps) +gst_massink_sinkconnect (GstPad *pad, const GstCaps *caps) { GstMassink *massink; massink = GST_MASSINK (gst_pad_get_parent (pad)); - if (!GST_CAPS_IS_FIXED (caps)) - return GST_PAD_LINK_DELAYED; - if (gst_massink_sync_parms (massink)) return GST_PAD_LINK_OK; diff --git a/ext/mplex/gstmplex.cc b/ext/mplex/gstmplex.cc index c63d1801..7de9ab56 100644 --- a/ext/mplex/gstmplex.cc +++ b/ext/mplex/gstmplex.cc @@ -56,63 +56,54 @@ 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", - "mpegversion", GST_PROPS_INT_RANGE (1, 2), - "systemstream", GST_PROPS_BOOLEAN (TRUE) + GST_STATIC_CAPS ("video/mpeg, " + "mpegversion = (int) [ 1, 2 ], " + "systemstream = (boolean) true" ) -) +); -GST_PAD_TEMPLATE_FACTORY (video_sink_factory, +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_RANGE (1, 2), - "systemstream", GST_PROPS_BOOLEAN (FALSE) + GST_STATIC_CAPS ("video/mpeg, " + "mpegversion = (int) [ 1, 2 ], " + "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, 3) + GST_STATIC_CAPS ("audio/mpeg, " + "mpegversion = (int) 1, " + "layer = (int) [ 1, 3 ]" ) -) +); -GST_PAD_TEMPLATE_FACTORY (private_1_sink_factory, +static GstStaticPadTemplate private_1_sink_factory = +GST_STATIC_PAD_TEMPLATE ( "private_stream_1_%d", GST_PAD_SINK, GST_PAD_REQUEST, - GST_CAPS_NEW ( - "sink_private1", - "audio/x-ac3", - NULL - ) -) + GST_STATIC_CAPS ("audio/x-ac3") +); -GST_PAD_TEMPLATE_FACTORY (private_2_sink_factory, +static GstStaticPadTemplate private_2_sink_factory = +GST_STATIC_PAD_TEMPLATE ( "private_stream_2", GST_PAD_SINK, GST_PAD_REQUEST, - GST_CAPS_NEW ( - "sink_private2", - "unknown/unknown", - NULL - ) -) + GST_STATIC_CAPS_ANY +); #define GST_TYPE_MPLEX_MUX_FORMAT (gst_mplex_mux_format_get_type()) static GType @@ -189,11 +180,11 @@ gst_mplex_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 (audio_sink_factory)); - gst_element_class_add_pad_template (element_class, GST_PAD_TEMPLATE_GET (video_sink_factory)); - gst_element_class_add_pad_template (element_class, GST_PAD_TEMPLATE_GET (private_1_sink_factory)); - gst_element_class_add_pad_template (element_class, GST_PAD_TEMPLATE_GET (private_2_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 (&audio_sink_factory)); + gst_element_class_add_pad_template (element_class, gst_static_pad_template_get (&video_sink_factory)); + gst_element_class_add_pad_template (element_class, gst_static_pad_template_get (&private_1_sink_factory)); + gst_element_class_add_pad_template (element_class, gst_static_pad_template_get (&private_2_sink_factory)); gst_element_class_set_details (element_class, &gst_mplex_details); } @@ -247,7 +238,7 @@ static void gst_mplex_init (GstMPlex *mplex) { mplex->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 (mplex), mplex->srcpad); gst_element_set_loop_function (GST_ELEMENT (mplex), gst_mplex_loop); @@ -263,20 +254,20 @@ gst_mplex_init (GstMPlex *mplex) } static GstPadLinkReturn -gst_mplex_video_link (GstPad *pad, GstCaps *caps) +gst_mplex_video_link (GstPad *pad, const GstCaps *caps) { GstMPlex *mplex; gint version; GstMPlexStream *stream; + GstStructure *structure; mplex = GST_MPLEX (gst_pad_get_parent (pad)); - if (!GST_CAPS_IS_FIXED (caps)) - return GST_PAD_LINK_DELAYED; - stream = (GstMPlexStream *) gst_pad_get_element_private (pad); + + structure = gst_caps_get_structure (caps, 0); - if (!gst_caps_get_int (caps, "mpegversion", &version)){ + if (!gst_structure_get_int (structure, "mpegversion", &version)){ return GST_PAD_LINK_REFUSED; } diff --git a/ext/sdl/sdlvideosink.c b/ext/sdl/sdlvideosink.c index f75ee233..887b37f8 100644 --- a/ext/sdl/sdlvideosink.c +++ b/ext/sdl/sdlvideosink.c @@ -64,7 +64,7 @@ static void gst_sdlvideosink_destroy (GstSDLVideoSink *sdl); static GstPadLinkReturn gst_sdlvideosink_sinkconnect (GstPad *pad, - GstCaps *caps); + const GstCaps *caps); static void gst_sdlvideosink_chain (GstPad *pad, GstData *data); @@ -80,7 +80,6 @@ static GstElementStateReturn gst_sdlvideosink_change_state (GstElement *element); -static GstCaps *capslist = NULL; static GstPadTemplate *sink_template; static GstElementClass *parent_class = NULL; @@ -129,7 +128,7 @@ static void gst_sdlvideosink_base_init (gpointer g_class) { GstElementClass *element_class = GST_ELEMENT_CLASS (g_class); - GstCaps *caps; + GstCaps *capslist; gint i; gulong format[6] = { GST_MAKE_FOURCC('I','4','2','0'), GST_MAKE_FOURCC('Y','V','1','2'), @@ -139,23 +138,21 @@ gst_sdlvideosink_base_init (gpointer g_class) }; /* make a list of all available caps */ + capslist = gst_caps_new_empty(); for (i = 0; i < 5; i++) { - caps = gst_caps_new ("sdlvideosink_caps", - "video/x-raw-yuv", - gst_props_new ( - "format", GST_PROPS_FOURCC(format[i]), - "width", GST_PROPS_INT_RANGE (0, G_MAXINT), - "height", GST_PROPS_INT_RANGE (0, G_MAXINT), - "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT), - NULL ) - ); - capslist = gst_caps_append(capslist, caps); + gst_caps_append_structure (capslist, + gst_structure_new ("video/x-raw-yuv", + "format", GST_TYPE_FOURCC, format[i], + "width", GST_TYPE_INT_RANGE, 1, G_MAXINT, + "height", GST_TYPE_INT_RANGE, 1, G_MAXINT, + "framerate", GST_TYPE_DOUBLE_RANGE, 0.0, G_MAXDOUBLE, + NULL)); } sink_template = gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, - capslist, NULL); + capslist); gst_element_class_add_pad_template (element_class, sink_template); gst_element_class_set_details (element_class, &gst_sdlvideosink_details); @@ -194,6 +191,8 @@ gst_sdlvideosink_class_init (GstSDLVideoSinkClass *klass) gstvs_class->set_geometry = gst_sdlvideosink_set_geometry;*/ } +#if 0 +/* FIXME */ static GstBuffer * gst_sdlvideosink_buffer_new (GstBufferPool *pool, gint64 location, @@ -253,14 +252,13 @@ gst_sdlvideosink_get_bufferpool (GstPad *pad) return NULL; } +#endif static void gst_sdlvideosink_init (GstSDLVideoSink *sdlvideosink) { GST_VIDEOSINK_PAD (sdlvideosink) = gst_pad_new_from_template (sink_template, "sink"); - gst_pad_set_bufferpool_function (GST_VIDEOSINK_PAD (sdlvideosink), - gst_sdlvideosink_get_bufferpool); gst_element_add_pad (GST_ELEMENT (sdlvideosink), GST_VIDEOSINK_PAD (sdlvideosink)); @@ -277,12 +275,13 @@ gst_sdlvideosink_init (GstSDLVideoSink *sdlvideosink) sdlvideosink->xwindow_id = 0; - sdlvideosink->capslist = capslist; + //sdlvideosink->capslist = capslist; sdlvideosink->init = FALSE; sdlvideosink->lock = g_mutex_new (); +#if 0 sdlvideosink->bufferpool = gst_buffer_pool_new ( NULL, /* free */ NULL, /* copy */ @@ -290,6 +289,7 @@ gst_sdlvideosink_init (GstSDLVideoSink *sdlvideosink) NULL, /* buffer copy, the default is fine */ (GstBufferPoolBufferFreeFunction) gst_sdlvideosink_buffer_free, sdlvideosink); +#endif GST_FLAG_SET(sdlvideosink, GST_ELEMENT_THREAD_SUGGESTED); GST_FLAG_SET(sdlvideosink, GST_ELEMENT_EVENT_AWARE); @@ -509,37 +509,25 @@ gst_sdlvideosink_create (GstSDLVideoSink *sdlvideosink) static GstPadLinkReturn gst_sdlvideosink_sinkconnect (GstPad *pad, - GstCaps *vscapslist) + const GstCaps *vscapslist) { GstSDLVideoSink *sdlvideosink; - GstCaps *caps; + guint32 format; + GstStructure *structure; sdlvideosink = GST_SDLVIDEOSINK (gst_pad_get_parent (pad)); - /* we are not going to act on variable caps */ - if (!GST_CAPS_IS_FIXED (vscapslist)) - return GST_PAD_LINK_DELAYED; - - for (caps = vscapslist; caps != NULL; caps = vscapslist = vscapslist->next) - { - guint32 format; + structure = gst_caps_get_structure (vscapslist, 0); + gst_structure_get_fourcc (structure, "format", &format); + sdlvideosink->format = + gst_sdlvideosink_get_sdl_from_fourcc (sdlvideosink, format); + gst_structure_get_int (structure, "width", &sdlvideosink->width); + gst_structure_get_int (structure, "height", &sdlvideosink->height); - gst_caps_get_fourcc_int(caps, "format", &format); - sdlvideosink->format = - gst_sdlvideosink_get_sdl_from_fourcc (sdlvideosink, format); - gst_caps_get_int(caps, "width", &sdlvideosink->width); - gst_caps_get_int(caps, "height", &sdlvideosink->height); - - /* try it out */ - if (!sdlvideosink->format || - !gst_sdlvideosink_create(sdlvideosink)) - continue; - - return GST_PAD_LINK_OK; - } + if (!sdlvideosink->format || !gst_sdlvideosink_create(sdlvideosink)) + return GST_PAD_LINK_REFUSED; - /* if we got here - it's not good */ - return GST_PAD_LINK_REFUSED; + return GST_PAD_LINK_OK; } diff --git a/ext/sdl/sdlvideosink.h b/ext/sdl/sdlvideosink.h index 96b2aecb..e4e0df0c 100644 --- a/ext/sdl/sdlvideosink.h +++ b/ext/sdl/sdlvideosink.h @@ -55,14 +55,11 @@ struct _GstSDLVideoSink { gboolean init; - GstCaps *capslist; - SDL_Surface *screen; SDL_Overlay *overlay; SDL_Rect rect; GMutex *lock; - GstBufferPool *bufferpool; }; struct _GstSDLVideoSinkClass { diff --git a/ext/snapshot/gstsnapshot.c b/ext/snapshot/gstsnapshot.c index 36d5e815..eff6567a 100644 --- a/ext/snapshot/gstsnapshot.c +++ b/ext/snapshot/gstsnapshot.c @@ -36,36 +36,21 @@ static GstElementDetails snapshot_details = { "Jeremy SIMON <jsimon13@yahoo.fr>", }; -GST_PAD_TEMPLATE_FACTORY (snapshot_src_factory, +static GstStaticPadTemplate snapshot_src_factory = +GST_STATIC_PAD_TEMPLATE ( "src", GST_PAD_SRC, GST_PAD_ALWAYS, - gst_caps_new ( - "snapshot_src", - "video/x-raw-yuv", - GST_VIDEO_YUV_PAD_TEMPLATE_PROPS ( - GST_PROPS_LIST ( - GST_PROPS_FOURCC (GST_STR_FOURCC ("I420")), - GST_PROPS_FOURCC (GST_STR_FOURCC ("YUY2")) - )) - ) -) - -GST_PAD_TEMPLATE_FACTORY (snapshot_sink_factory, + GST_STATIC_CAPS (GST_VIDEO_YUV_PAD_TEMPLATE_CAPS ("{ I420, YUY2 }")) +); + +static GstStaticPadTemplate snapshot_sink_factory = +GST_STATIC_PAD_TEMPLATE ( "sink", GST_PAD_SINK, GST_PAD_ALWAYS, - gst_caps_new ( - "snapshot_src", - "video/x-raw-yuv", - GST_VIDEO_YUV_PAD_TEMPLATE_PROPS ( - GST_PROPS_LIST ( - GST_PROPS_FOURCC (GST_STR_FOURCC ("I420")), - GST_PROPS_FOURCC (GST_STR_FOURCC ("YUY2")) - )) - ) -) - + GST_STATIC_CAPS (GST_VIDEO_YUV_PAD_TEMPLATE_CAPS ("{ I420, YUY2 }")) +); /* Snapshot signals and args */ enum { @@ -133,8 +118,8 @@ gst_snapshot_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 (snapshot_sink_factory)); - gst_element_class_add_pad_template (element_class, GST_PAD_TEMPLATE_GET (snapshot_src_factory)); + gst_element_class_add_pad_template (element_class, gst_static_pad_template_get (&snapshot_sink_factory)); + gst_element_class_add_pad_template (element_class, gst_static_pad_template_get (&snapshot_src_factory)); gst_element_class_set_details (element_class, &snapshot_details); } @@ -179,48 +164,43 @@ snapshot_handler(GstElement *element) static gboolean -gst_snapshot_sinkconnect (GstPad *pad, GstCaps *caps) +gst_snapshot_sinkconnect (GstPad *pad, const GstCaps *caps) { GstSnapshot *filter; GstCaps *from_caps, *to_caps; - gfloat fps; + gdouble fps; + GstStructure *structure; filter = GST_SNAPSHOT (gst_pad_get_parent (pad)); - if (!GST_CAPS_IS_FIXED (caps)) - return GST_PAD_LINK_DELAYED; - - gst_caps_get_int (caps, "width", &filter->width); - gst_caps_get_int (caps, "height", &filter->height); - gst_caps_get_float (caps, "framerate", &fps); - gst_caps_get_fourcc_int (caps, "format", &filter->format); + structure = gst_caps_get_structure (caps, 0); + gst_structure_get_int (structure, "width", &filter->width); + gst_structure_get_int (structure, "height", &filter->height); + gst_structure_get_double (structure, "framerate", &fps); + gst_structure_get_fourcc (structure, "format", &filter->format); filter->to_bpp = 24; - to_caps = GST_CAPS_NEW ( - "snapshot_conversion", - "video/x-raw-rgb", - "width", GST_PROPS_INT( filter->width ), - "height", GST_PROPS_INT( filter->height ), - "red_mask", GST_PROPS_INT (0x0000FF), - "green_mask", GST_PROPS_INT (0x00FF00), - "blue_mask", GST_PROPS_INT (0xFF0000), - "bpp", GST_PROPS_INT( 24 ), - "framerate", GST_PROPS_FLOAT (fps) - ); + to_caps = gst_caps_new_simple ("video/x-raw-rgb", + "width", G_TYPE_INT, filter->width, + "height", G_TYPE_INT, filter->height, + "red_mask", G_TYPE_INT, 0x0000FF, + "green_mask", G_TYPE_INT, 0x00FF00, + "blue_mask", G_TYPE_INT, 0xFF0000, + "bpp", G_TYPE_INT, 24, + "framerate", G_TYPE_DOUBLE, fps, + NULL); switch ( filter->format ) { case GST_MAKE_FOURCC('Y','U','Y','2'): case GST_MAKE_FOURCC('I','4','2','0'): - from_caps = GST_CAPS_NEW ( - "snapshot_from", - "video/x-raw-yuv", - "format", GST_PROPS_FOURCC (GST_STR_FOURCC ("I420")), - "width", GST_PROPS_INT( filter->width ), - "height", GST_PROPS_INT( filter->height ), - "framerate", GST_PROPS_FLOAT (fps) - ); + from_caps = gst_caps_new_simple ("video/x-raw-yuv", + "format", GST_TYPE_FOURCC, GST_STR_FOURCC ("I420"), + "width", G_TYPE_INT, filter->width, + "height", G_TYPE_INT, filter->height, + "framerate", G_TYPE_DOUBLE, fps, + NULL); filter->converter = gst_colorspace_yuv2rgb_get_converter ( from_caps, to_caps ); break; @@ -246,12 +226,12 @@ gst_snapshot_sinkconnect (GstPad *pad, GstCaps *caps) static void gst_snapshot_init (GstSnapshot *snapshot) { - snapshot->sinkpad = gst_pad_new_from_template (GST_PAD_TEMPLATE_GET (snapshot_sink_factory), "sink"); + snapshot->sinkpad = gst_pad_new_from_template (gst_static_pad_template_get (&snapshot_sink_factory), "sink"); gst_pad_set_link_function (snapshot->sinkpad, gst_snapshot_sinkconnect); gst_pad_set_chain_function (snapshot->sinkpad, gst_snapshot_chain); gst_element_add_pad (GST_ELEMENT (snapshot), snapshot->sinkpad); - snapshot->srcpad = gst_pad_new_from_template (GST_PAD_TEMPLATE_GET (snapshot_src_factory), "src"); + snapshot->srcpad = gst_pad_new_from_template (gst_static_pad_template_get (&snapshot_src_factory), "src"); gst_element_add_pad (GST_ELEMENT (snapshot), snapshot->srcpad); snapshot->cur_frame = 0; diff --git a/ext/sndfile/gstsf.c b/ext/sndfile/gstsf.c index 34a8b60f..b9c630c9 100644 --- a/ext/sndfile/gstsf.c +++ b/ext/sndfile/gstsf.c @@ -53,26 +53,20 @@ enum { ARG_CREATE_PADS }; -GST_PAD_TEMPLATE_FACTORY (sf_src_factory, +static GstStaticPadTemplate sf_src_factory = +GST_STATIC_PAD_TEMPLATE ( "src%d", GST_PAD_SRC, GST_PAD_REQUEST, - gst_caps_new ( - "sf_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 (sf_sink_factory, +static GstStaticPadTemplate sf_sink_factory = +GST_STATIC_PAD_TEMPLATE ( "sink%d", GST_PAD_SINK, GST_PAD_REQUEST, - gst_caps_new ( - "sf_sink", - "audio/x-raw-float", - GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_PROPS - ) + GST_STATIC_CAPS (GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS) ); #define GST_TYPE_SF_MAJOR_TYPES (gst_sf_major_types_get_type()) @@ -162,7 +156,7 @@ static GstPad* gst_sf_request_new_pad (GstElement *element, GstPadTemplate *tem static void gst_sf_release_request_pad (GstElement *element, GstPad *pad); static GstElementStateReturn gst_sf_change_state (GstElement *element); -static GstPadLinkReturn gst_sf_link (GstPad *pad, GstCaps *caps); +static GstPadLinkReturn gst_sf_link (GstPad *pad, const GstCaps *caps); static void gst_sf_loop (GstElement *element); @@ -249,7 +243,7 @@ gst_sfsrc_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 (sf_src_factory)); + gst_element_class_add_pad_template (element_class, gst_static_pad_template_get (&sf_src_factory)); gst_element_class_set_details (element_class, &sfsrc_details); } @@ -258,7 +252,7 @@ gst_sfsink_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 (sf_sink_factory)); + gst_element_class_add_pad_template (element_class, gst_static_pad_template_get (&sf_sink_factory)); gst_element_class_set_details (element_class, &sfsink_details); } @@ -530,28 +524,27 @@ gst_sf_release_request_pad (GstElement *element, GstPad *pad) } static GstPadLinkReturn -gst_sf_link (GstPad *pad, GstCaps *caps) +gst_sf_link (GstPad *pad, const GstCaps *caps) { GstSF *this = (GstSF*)GST_OBJECT_PARENT (pad); + GstStructure *structure; + + structure = gst_caps_get_structure (caps, 0); - if (GST_CAPS_IS_FIXED (caps)) { - gst_caps_get_int (caps, "rate", &this->rate); - gst_caps_get_int (caps, "buffer-frames", &this->buffer_frames); - - INFO_OBJ (this, "linked pad %s:%s with fixed caps, frames=%d, rate=%d", - GST_DEBUG_PAD_NAME (pad), this->rate, this->buffer_frames); - - if (this->numchannels) { - /* we can go ahead and allocate our buffer */ - if (this->buffer) - g_free (this->buffer); - this->buffer = g_malloc (this->numchannels * this->buffer_frames * sizeof (float)); - memset (this->buffer, 0, this->numchannels * this->buffer_frames * sizeof (float)); - } - return GST_PAD_LINK_OK; + gst_structure_get_int (structure, "rate", &this->rate); + gst_structure_get_int (structure, "buffer-frames", &this->buffer_frames); + + INFO_OBJ (this, "linked pad %s:%s with fixed caps, frames=%d, rate=%d", + GST_DEBUG_PAD_NAME (pad), this->rate, this->buffer_frames); + + if (this->numchannels) { + /* we can go ahead and allocate our buffer */ + if (this->buffer) + g_free (this->buffer); + this->buffer = g_malloc (this->numchannels * this->buffer_frames * sizeof (float)); + memset (this->buffer, 0, this->numchannels * this->buffer_frames * sizeof (float)); } - - return GST_PAD_LINK_DELAYED; + return GST_PAD_LINK_OK; } static gboolean @@ -706,8 +699,10 @@ gst_sf_loop (GstElement *element) if (!caps) caps = gst_caps_copy (GST_PAD_TEMPLATE_CAPS (GST_PAD_PAD_TEMPLATE (GST_SF_CHANNEL (l)->pad))); - gst_caps_set (caps, "rate", GST_PROPS_INT (this->rate), NULL); - gst_caps_set (caps, "buffer-frames", GST_PROPS_INT (this->buffer_frames), NULL); + gst_caps_set_simple (caps, + "rate", G_TYPE_INT, this->rate, + "buffer-frames", G_TYPE_INT, this->buffer_frames, + NULL); if (!gst_pad_try_set_caps (GST_SF_CHANNEL (l)->pad, caps)) { gst_element_error (GST_ELEMENT (this), g_strdup_printf ("Opened file with sample rate %d, but could not set caps", diff --git a/ext/swfdec/gstswfdec.c b/ext/swfdec/gstswfdec.c index 9e97ad1e..6e42c4fa 100644 --- a/ext/swfdec/gstswfdec.c +++ b/ext/swfdec/gstswfdec.c @@ -23,6 +23,7 @@ #endif #include "gstswfdec.h" #include <string.h> +#include <gst/video/video.h> /* elementfactory information */ static GstElementDetails gst_swfdec_details = GST_ELEMENT_DETAILS ( @@ -43,50 +44,35 @@ enum { /* FILL ME */ }; -GST_PAD_TEMPLATE_FACTORY (video_template_factory, +static GstStaticPadTemplate video_template_factory = +GST_STATIC_PAD_TEMPLATE ( "video_00", GST_PAD_SRC, GST_PAD_ALWAYS, - GST_CAPS_NEW ( - "swfdec_videosrc", - "video/x-raw-rgb", - "width", GST_PROPS_INT_RANGE (16, 4096), - "height", GST_PROPS_INT_RANGE (16, 4096), - "bpp", GST_PROPS_INT (24), - "depth", GST_PROPS_INT (24), - "endianness", GST_PROPS_INT (G_BIG_ENDIAN), - "red_mask", GST_PROPS_INT (0xff0000), - "green_mask", GST_PROPS_INT (0x00ff00), - "blue_mask", GST_PROPS_INT (0x0000ff), - "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT) - ) + GST_STATIC_CAPS (GST_VIDEO_RGB_PAD_TEMPLATE_CAPS_24) ); -GST_PAD_TEMPLATE_FACTORY (audio_template_factory, +static GstStaticPadTemplate audio_template_factory = +GST_STATIC_PAD_TEMPLATE ( "audio_00", GST_PAD_SRC, GST_PAD_ALWAYS, - GST_CAPS_NEW ( - "swfdec_audiosrc", - "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(44100), - "channels", GST_PROPS_INT(2) - ) + GST_STATIC_CAPS ("audio/x-raw-int, " + "rate = (int) 44100, " + "channels = (int) 2, " + "endianness = (int) BYTE_ORDER, " + "width = (int) 16, " + "depth = (int) 16, " + "signed = (boolean) true, " + "buffer-frames = (int) [ 1, MAX ]") ); -GST_PAD_TEMPLATE_FACTORY (sink_template_factory, +static GstStaticPadTemplate sink_template_factory = +GST_STATIC_PAD_TEMPLATE ( "sink", GST_PAD_SINK, GST_PAD_ALWAYS, - GST_CAPS_NEW ( - "swfdec_sink", - "application/x-shockwave-flash", - NULL - ) + GST_STATIC_CAPS ( "application/x-shockwave-flash") ); static void gst_swfdec_base_init (gpointer g_class); @@ -148,11 +134,11 @@ gst_swfdec_base_init(gpointer g_class) gst_element_class_set_details (element_class, &gst_swfdec_details); gst_element_class_add_pad_template (element_class, - GST_PAD_TEMPLATE_GET (video_template_factory)); + gst_static_pad_template_get (&video_template_factory)); gst_element_class_add_pad_template (element_class, - GST_PAD_TEMPLATE_GET (audio_template_factory)); + gst_static_pad_template_get (&audio_template_factory)); gst_element_class_add_pad_template (element_class, - GST_PAD_TEMPLATE_GET (sink_template_factory)); + gst_static_pad_template_get (&sink_template_factory)); } static void gst_swfdec_class_init(GstSwfdecClass *klass) @@ -172,33 +158,25 @@ gst_swfdec_class_init(GstSwfdecClass *klass) gstelement_class->change_state = gst_swfdec_change_state; } -static GstCaps *gst_swfdec_videosrc_getcaps(GstPad *pad, GstCaps *caps) +static GstCaps *gst_swfdec_videosrc_getcaps(GstPad *pad) { GstSwfdec *swfdec; - GstCaps *c; + GstCaps *caps; swfdec = GST_SWFDEC (gst_pad_get_parent (pad)); - c = GST_CAPS_NEW ( - "swfdec_videosrc", - "video/x-raw-rgb", - "width", GST_PROPS_INT_RANGE (16, 4096), - "height", GST_PROPS_INT_RANGE (16, 4096), - "bpp", GST_PROPS_INT (24), - "depth", GST_PROPS_INT (24), - "endianness", GST_PROPS_INT (G_BIG_ENDIAN), - "red_mask", GST_PROPS_INT (0xff0000), - "green_mask", GST_PROPS_INT (0x00ff00), - "blue_mask", GST_PROPS_INT (0x0000ff), - "framerate", GST_PROPS_FLOAT (swfdec->frame_rate) - ); - - if(swfdec->height){ - gst_caps_set(c,"height",GST_PROPS_INT(swfdec->height)); - gst_caps_set(c,"width",GST_PROPS_INT(swfdec->width)); + caps = gst_caps_copy (gst_pad_template_get_caps ( + gst_static_pad_template_get (&video_template_factory))); + + if (swfdec->height) { + gst_caps_set_simple (caps, + "framerate", G_TYPE_DOUBLE, swfdec->frame_rate, + "height",G_TYPE_INT,swfdec->height, + "width",G_TYPE_INT,swfdec->width, + NULL); } - return c; + return caps; } static void @@ -244,9 +222,9 @@ gst_swfdec_loop(GstElement *element) swfdec_decoder_get_rate(swfdec->state, &swfdec->rate); swfdec->interval = GST_SECOND / swfdec->rate; - gst_caps_debug(gst_swfdec_videosrc_getcaps(swfdec->videopad,NULL),"ack"); + GST_DEBUG_CAPS ("caps", gst_swfdec_videosrc_getcaps(swfdec->videopad)); gst_pad_try_set_caps(swfdec->videopad, - gst_swfdec_videosrc_getcaps(swfdec->videopad,NULL)); + gst_swfdec_videosrc_getcaps(swfdec->videopad)); return; } @@ -294,11 +272,11 @@ gst_swfdec_init (GstSwfdec *swfdec) { /* create the sink and src pads */ swfdec->sinkpad = gst_pad_new_from_template ( - GST_PAD_TEMPLATE_GET (sink_template_factory), "sink"); + gst_static_pad_template_get (&sink_template_factory), "sink"); gst_element_add_pad (GST_ELEMENT (swfdec), swfdec->sinkpad); swfdec->videopad = gst_pad_new_from_template( - GST_PAD_TEMPLATE_GET(video_template_factory), + gst_static_pad_template_get (&video_template_factory), "video_00"); gst_pad_set_query_function (swfdec->videopad, GST_DEBUG_FUNCPTR (gst_swfdec_src_query)); @@ -307,7 +285,7 @@ gst_swfdec_init (GstSwfdec *swfdec) gst_element_add_pad(GST_ELEMENT(swfdec), swfdec->videopad); swfdec->audiopad = gst_pad_new_from_template( - GST_PAD_TEMPLATE_GET(audio_template_factory), + gst_static_pad_template_get (&audio_template_factory), "audio_00"); gst_pad_set_query_function (swfdec->audiopad, GST_DEBUG_FUNCPTR (gst_swfdec_src_query)); @@ -563,7 +541,6 @@ gst_swfdec_change_state (GstElement *element) //swfdec->decoder->is_sequence_needed = 1; //swfdec->decoder->frame_rate_code = 0; swfdec->timestamp = 0; - swfdec->pool = NULL; swfdec->closed = FALSE; /* reset the initial video state */ @@ -574,19 +551,8 @@ gst_swfdec_change_state (GstElement *element) break; } case GST_STATE_PAUSED_TO_PLAYING: - /* try to get a bufferpool */ -#if 0 - swfdec->pool = gst_pad_get_bufferpool (swfdec->videopad); - if (swfdec->pool) - GST_INFO ( "got pool %p", swfdec->pool); -#endif break; case GST_STATE_PLAYING_TO_PAUSED: - /* need to clear things we get from other plugins, since we could be reconnected */ - if (swfdec->pool) { - gst_buffer_pool_unref (swfdec->pool); - swfdec->pool = NULL; - } break; case GST_STATE_PAUSED_TO_READY: /* if we are not closed by an EOS event do so now, this cen send a few frames but diff --git a/ext/swfdec/gstswfdec.h b/ext/swfdec/gstswfdec.h index 8aa3ce3a..5ee2a3b5 100644 --- a/ext/swfdec/gstswfdec.h +++ b/ext/swfdec/gstswfdec.h @@ -51,7 +51,6 @@ struct _GstSwfdec { GstPad *sinkpad; GstPad *videopad; GstPad *audiopad; - GstBufferPool *pool; SwfdecDecoder *state; gboolean closed; diff --git a/ext/xvid/gstxviddec.c b/ext/xvid/gstxviddec.c index 3cfdfaa7..84af838d 100644 --- a/ext/xvid/gstxviddec.c +++ b/ext/xvid/gstxviddec.c @@ -33,45 +33,30 @@ GstElementDetails gst_xviddec_details = { "Ronald Bultje <rbultje@ronald.bitfreak.net>", }; -GST_PAD_TEMPLATE_FACTORY(sink_template, +static GstStaticPadTemplate sink_template = +GST_STATIC_PAD_TEMPLATE ( "sink", GST_PAD_SINK, GST_PAD_ALWAYS, - GST_CAPS_NEW("xviddec_sink", - "video/x-xvid", - "width", GST_PROPS_INT_RANGE (0, G_MAXINT), - "height", GST_PROPS_INT_RANGE (0, G_MAXINT), - "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT)) -) - -GST_PAD_TEMPLATE_FACTORY(src_template, + GST_STATIC_CAPS ( + "video/x-xvid, " + "width = (int) [ 0, MAX ], " + "height = (int) [ 0, MAX ], " + "framerate = (double) [ 0, MAX ]" + ) +); + +static GstStaticPadTemplate src_template = +GST_STATIC_PAD_TEMPLATE ( "src", GST_PAD_SRC, GST_PAD_ALWAYS, - gst_caps_new( - "xviddec_sink", - "video/x-raw-yuv", - GST_VIDEO_YUV_PAD_TEMPLATE_PROPS ( - GST_PROPS_LIST( - GST_PROPS_FOURCC(GST_MAKE_FOURCC('I','4','2','0')), - GST_PROPS_FOURCC(GST_MAKE_FOURCC('Y','U','Y','2')), - GST_PROPS_FOURCC(GST_MAKE_FOURCC('Y','V','1','2')), - GST_PROPS_FOURCC(GST_MAKE_FOURCC('Y','V','Y','U')), - GST_PROPS_FOURCC(GST_MAKE_FOURCC('U','Y','V','Y')) - ) - ) - ), - gst_caps_new( - "xviddec_sink_rgb24_32", - "video/x-raw-rgb", - GST_VIDEO_RGB_PAD_TEMPLATE_PROPS_24_32 - ), - gst_caps_new( - "xviddec_sink_rgb15_16", - "video/x-raw-rgb", - GST_VIDEO_RGB_PAD_TEMPLATE_PROPS_15_16 + GST_STATIC_CAPS ( + GST_VIDEO_YUV_PAD_TEMPLATE_CAPS ("{ I420, YUY2, YV12, YVYU, UYVY }") "; " + GST_VIDEO_RGB_PAD_TEMPLATE_CAPS_24_32 "; " + GST_VIDEO_RGB_PAD_TEMPLATE_CAPS_15_16 ) -) +); /* XvidDec signals and args */ @@ -91,9 +76,9 @@ static void gst_xviddec_init (GstXvidDec *xviddec); static void gst_xviddec_dispose (GObject *object); static void gst_xviddec_chain (GstPad *pad, GstData *data); -static GstPadLinkReturn gst_xviddec_connect (GstPad *pad, - GstCaps *vscapslist); -static GstPadLinkReturn gst_xviddec_negotiate (GstXvidDec *xviddec); +static GstPadLinkReturn gst_xviddec_link (GstPad *pad, + const GstCaps *vscapslist); +static GstPadLinkReturn gst_xviddec_negotiate (GstXvidDec *xviddec); static GstElementClass *parent_class = NULL; /* static guint gst_xviddec_signals[LAST_SIGNAL] = { 0 }; */ @@ -129,8 +114,10 @@ gst_xviddec_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 (sink_template)); - gst_element_class_add_pad_template (element_class, GST_PAD_TEMPLATE_GET (src_template)); + gst_element_class_add_pad_template (element_class, + gst_static_pad_template_get (&sink_template)); + gst_element_class_add_pad_template (element_class, + gst_static_pad_template_get (&src_template)); gst_element_class_set_details (element_class, &gst_xviddec_details); } @@ -153,16 +140,16 @@ gst_xviddec_init (GstXvidDec *xviddec) { /* create the sink pad */ xviddec->sinkpad = gst_pad_new_from_template( - GST_PAD_TEMPLATE_GET(sink_template), + gst_static_pad_template_get (&sink_template), "sink"); gst_element_add_pad(GST_ELEMENT(xviddec), xviddec->sinkpad); gst_pad_set_chain_function(xviddec->sinkpad, gst_xviddec_chain); - gst_pad_set_link_function(xviddec->sinkpad, gst_xviddec_connect); + gst_pad_set_link_function(xviddec->sinkpad, gst_xviddec_link); /* create the src pad */ xviddec->srcpad = gst_pad_new_from_template( - GST_PAD_TEMPLATE_GET(src_template), + gst_static_pad_template_get (&src_template), "src"); gst_element_add_pad(GST_ELEMENT(xviddec), xviddec->srcpad); @@ -309,36 +296,36 @@ gst_xviddec_negotiate (GstXvidDec *xviddec) break; case 16: endianness = G_BYTE_ORDER; - r_mask = 0xf800; g_mask = 0x07e0; b_mask = 0x001f; + r_mask = R_MASK_16_INT; g_mask = G_MASK_16_INT; b_mask = B_MASK_16_INT; break; case 24: endianness = G_BIG_ENDIAN; - r_mask = R_MASK_24; g_mask = G_MASK_24; b_mask = B_MASK_24; + r_mask = R_MASK_24_INT; g_mask = G_MASK_24_INT; b_mask = B_MASK_24_INT; break; case 32: endianness = G_BIG_ENDIAN; - r_mask = R_MASK_32; g_mask = G_MASK_32; b_mask = B_MASK_32; + r_mask = R_MASK_32_INT; g_mask = G_MASK_32_INT; b_mask = B_MASK_32_INT; break; } - caps = GST_CAPS_NEW("xviddec_src_pad_rgb", + caps = gst_caps_new_simple ( "video/x-raw-rgb", - "width", GST_PROPS_INT(xviddec->width), - "height", GST_PROPS_INT(xviddec->height), - "depth", GST_PROPS_INT(fmt_list[i].depth), - "bpp", GST_PROPS_INT(fmt_list[i].bpp), - "endianness", GST_PROPS_INT(endianness), - "red_mask", GST_PROPS_INT(r_mask), - "green_mask", GST_PROPS_INT(g_mask), - "blue_mask", GST_PROPS_INT(b_mask), - "framerate", GST_PROPS_FLOAT(xviddec->fps), + "width", G_TYPE_INT, xviddec->width, + "height", G_TYPE_INT, xviddec->height, + "depth", G_TYPE_INT, fmt_list[i].depth, + "bpp", G_TYPE_INT, fmt_list[i].bpp, + "endianness", G_TYPE_INT, endianness, + "red_mask", G_TYPE_INT, r_mask, + "green_mask", G_TYPE_INT, g_mask, + "blue_mask", G_TYPE_INT, b_mask, + "framerate", G_TYPE_DOUBLE, xviddec->fps, NULL); } else { - caps = GST_CAPS_NEW("xviddec_src_pad_yuv", + caps = gst_caps_new_simple ( "video/x-raw-yuv", - "width", GST_PROPS_INT(xviddec->width), - "height", GST_PROPS_INT(xviddec->height), - "format", GST_PROPS_FOURCC(fmt_list[i].fourcc), - "framerate", GST_PROPS_FLOAT(xviddec->fps), + "width", G_TYPE_INT, xviddec->width, + "height", G_TYPE_INT, xviddec->height, + "format", GST_TYPE_FOURCC, fmt_list[i].fourcc, + "framerate", G_TYPE_DOUBLE, xviddec->fps, NULL); } @@ -358,10 +345,11 @@ gst_xviddec_negotiate (GstXvidDec *xviddec) static GstPadLinkReturn -gst_xviddec_connect (GstPad *pad, - GstCaps *vscaps) +gst_xviddec_link (GstPad *pad, + const GstCaps *vscaps) { GstXvidDec *xviddec; + GstStructure *structure; xviddec = GST_XVIDDEC(gst_pad_get_parent (pad)); @@ -370,15 +358,12 @@ gst_xviddec_connect (GstPad *pad, gst_xviddec_unset(xviddec); } - /* we are not going to act on variable caps */ - if (!GST_CAPS_IS_FIXED(vscaps)) - return GST_PAD_LINK_DELAYED; - /* if we get here, we know the input is xvid. we * only need to bother with the output colorspace */ - gst_caps_get_int(vscaps, "width", &xviddec->width); - gst_caps_get_int(vscaps, "height", &xviddec->height); - gst_caps_get_float(vscaps, "framerate", &xviddec->fps); + structure = gst_caps_get_structure (vscaps, 0); + gst_structure_get_int(structure, "width", &xviddec->width); + gst_structure_get_int(structure, "height", &xviddec->height); + gst_structure_get_double(structure, "framerate", &xviddec->fps); return gst_xviddec_negotiate(xviddec); } diff --git a/ext/xvid/gstxviddec.h b/ext/xvid/gstxviddec.h index 76fc6d89..a614bd81 100644 --- a/ext/xvid/gstxviddec.h +++ b/ext/xvid/gstxviddec.h @@ -53,9 +53,9 @@ struct _GstXvidDec { void *handle; /* video (output) settings */ - int csp, bpp; - int width, height; - float fps; + gint csp, bpp; + gint width, height; + double fps; }; struct _GstXvidDecClass { diff --git a/ext/xvid/gstxvidenc.c b/ext/xvid/gstxvidenc.c index f526df5a..ce2e71e9 100644 --- a/ext/xvid/gstxvidenc.c +++ b/ext/xvid/gstxvidenc.c @@ -34,45 +34,30 @@ GstElementDetails gst_xvidenc_details = { "Ronald Bultje <rbultje@ronald.bitfreak.net>", }; -GST_PAD_TEMPLATE_FACTORY(sink_template, +static GstStaticPadTemplate sink_template = +GST_STATIC_PAD_TEMPLATE ( "sink", GST_PAD_SINK, GST_PAD_ALWAYS, - gst_caps_new( - "xvidenc_sink", - "video/x-raw-yuv", - GST_VIDEO_YUV_PAD_TEMPLATE_PROPS ( - GST_PROPS_LIST( - GST_PROPS_FOURCC(GST_MAKE_FOURCC('I','4','2','0')), - GST_PROPS_FOURCC(GST_MAKE_FOURCC('Y','U','Y','2')), - GST_PROPS_FOURCC(GST_MAKE_FOURCC('Y','V','1','2')), - GST_PROPS_FOURCC(GST_MAKE_FOURCC('Y','V','Y','U')), - GST_PROPS_FOURCC(GST_MAKE_FOURCC('U','Y','V','Y')) - ) - ) - ), - gst_caps_new( - "xvidenc_sink_rgb24_32", - "video/x-raw-rgb", - GST_VIDEO_RGB_PAD_TEMPLATE_PROPS_24_32 - ), - gst_caps_new( - "xvidenc_sink_rgb15_16", - "video/x-raw-rgb", - GST_VIDEO_RGB_PAD_TEMPLATE_PROPS_15_16 + GST_STATIC_CAPS ( + GST_VIDEO_YUV_PAD_TEMPLATE_CAPS ("{ I420, YUY2, YV12, YVYU, UYVY }") "; " + GST_VIDEO_RGB_PAD_TEMPLATE_CAPS_24_32 "; " + GST_VIDEO_RGB_PAD_TEMPLATE_CAPS_15_16 ) -) +); -GST_PAD_TEMPLATE_FACTORY(src_template, +static GstStaticPadTemplate src_template = +GST_STATIC_PAD_TEMPLATE ( "src", GST_PAD_SRC, GST_PAD_ALWAYS, - GST_CAPS_NEW("xvidenc_src", - "video/x-xvid", - "width", GST_PROPS_INT_RANGE (0, G_MAXINT), - "height", GST_PROPS_INT_RANGE (0, G_MAXINT), - "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT)) -) + GST_STATIC_CAPS ( + "video/x-xvid, " + "width = (int) [ 0, MAX ], " + "height = (int) [ 0, MAX ], " + "framerate = (double) [ 0.0, MAX ]" + ) +); /* XvidEnc signals and args */ @@ -93,8 +78,8 @@ static void gst_xvidenc_class_init (GstXvidEncClass *klass); static void gst_xvidenc_init (GstXvidEnc *xvidenc); static void gst_xvidenc_chain (GstPad *pad, GstData *data); -static GstPadLinkReturn gst_xvidenc_connect (GstPad *pad, - GstCaps *vscapslist); +static GstPadLinkReturn gst_xvidenc_link (GstPad *pad, + const GstCaps *vscapslist); /* properties */ static void gst_xvidenc_set_property (GObject *object, @@ -140,8 +125,8 @@ gst_xvidenc_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 (sink_template)); - gst_element_class_add_pad_template (element_class, GST_PAD_TEMPLATE_GET (src_template)); + gst_element_class_add_pad_template (element_class, gst_static_pad_template_get (&sink_template)); + gst_element_class_add_pad_template (element_class, gst_static_pad_template_get (&src_template)); gst_element_class_set_details (element_class, &gst_xvidenc_details); } @@ -190,16 +175,16 @@ gst_xvidenc_init (GstXvidEnc *xvidenc) { /* create the sink pad */ xvidenc->sinkpad = gst_pad_new_from_template( - GST_PAD_TEMPLATE_GET(sink_template), + gst_static_pad_template_get (&sink_template), "sink"); gst_element_add_pad(GST_ELEMENT(xvidenc), xvidenc->sinkpad); gst_pad_set_chain_function(xvidenc->sinkpad, gst_xvidenc_chain); - gst_pad_set_link_function(xvidenc->sinkpad, gst_xvidenc_connect); + gst_pad_set_link_function(xvidenc->sinkpad, gst_xvidenc_link); /* create the src pad */ xvidenc->srcpad = gst_pad_new_from_template( - GST_PAD_TEMPLATE_GET(src_template), + gst_static_pad_template_get (&src_template), "src"); gst_element_add_pad(GST_ELEMENT(xvidenc), xvidenc->srcpad); @@ -312,11 +297,15 @@ gst_xvidenc_chain (GstPad *pad, static GstPadLinkReturn -gst_xvidenc_connect (GstPad *pad, - GstCaps *vscaps) +gst_xvidenc_link (GstPad *pad, + const GstCaps *vscaps) { GstXvidEnc *xvidenc; - GstCaps *caps; + GstStructure *structure; + gint w,h,d; + double fps; + guint32 fourcc; + gint xvid_cs = -1; xvidenc = GST_XVIDENC(gst_pad_get_parent (pad)); @@ -326,95 +315,81 @@ gst_xvidenc_connect (GstPad *pad, xvidenc->handle = NULL; } - /* we are not going to act on variable caps */ - if (!GST_CAPS_IS_FIXED(vscaps)) - return GST_PAD_LINK_DELAYED; + g_return_val_if_fail (gst_caps_get_size (vscaps) == 1, GST_PAD_LINK_REFUSED); + structure = gst_caps_get_structure (vscaps, 0); + + gst_structure_get_int (structure, "width", &w); + gst_structure_get_int (structure, "height", &h); + gst_structure_get_double (structure, "framerate", &fps); + if (gst_structure_has_field_typed (structure, "format", GST_TYPE_FOURCC)) + gst_structure_get_fourcc (structure, "format", &fourcc); + else + fourcc = GST_MAKE_FOURCC('R','G','B',' '); - for (caps = vscaps; caps != NULL; caps = caps->next) + switch (fourcc) { - int w,h,d; - float fps; - guint32 fourcc; - gint xvid_cs; - - gst_caps_get_int(caps, "width", &w); - gst_caps_get_int(caps, "height", &h); - gst_caps_get_float(caps, "framerate", &fps); - if (gst_caps_has_property(caps, "format")) - gst_caps_get_fourcc_int(caps, "format", &fourcc); - else - fourcc = GST_MAKE_FOURCC('R','G','B',' '); - - switch (fourcc) - { - case GST_MAKE_FOURCC('I','4','2','0'): - case GST_MAKE_FOURCC('I','Y','U','V'): - xvid_cs = XVID_CSP_I420; - break; - case GST_MAKE_FOURCC('Y','U','Y','2'): - xvid_cs = XVID_CSP_YUY2; - break; - case GST_MAKE_FOURCC('Y','V','1','2'): - xvid_cs = XVID_CSP_YV12; - break; - case GST_MAKE_FOURCC('U','Y','V','Y'): - xvid_cs = XVID_CSP_UYVY; - break; - case GST_MAKE_FOURCC('Y','V','Y','U'): - xvid_cs = XVID_CSP_YVYU; - break; - case GST_MAKE_FOURCC('R','G','B',' '): - gst_caps_get_int(caps, "depth", &d); - switch (d) { - case 15: - xvid_cs = XVID_CSP_RGB555; - break; - case 16: - xvid_cs = XVID_CSP_RGB565; - break; - case 24: - xvid_cs = XVID_CSP_RGB24; - break; - case 32: - xvid_cs = XVID_CSP_RGB32; - break; - default: - goto trynext; - } - break; - default: - goto trynext; - } + case GST_MAKE_FOURCC('I','4','2','0'): + case GST_MAKE_FOURCC('I','Y','U','V'): + xvid_cs = XVID_CSP_I420; + break; + case GST_MAKE_FOURCC('Y','U','Y','2'): + xvid_cs = XVID_CSP_YUY2; + break; + case GST_MAKE_FOURCC('Y','V','1','2'): + xvid_cs = XVID_CSP_YV12; + break; + case GST_MAKE_FOURCC('U','Y','V','Y'): + xvid_cs = XVID_CSP_UYVY; + break; + case GST_MAKE_FOURCC('Y','V','Y','U'): + xvid_cs = XVID_CSP_YVYU; + break; + case GST_MAKE_FOURCC('R','G','B',' '): + gst_structure_get_int(structure, "depth", &d); + switch (d) { + case 15: + xvid_cs = XVID_CSP_RGB555; + break; + case 16: + xvid_cs = XVID_CSP_RGB565; + break; + case 24: + xvid_cs = XVID_CSP_RGB24; + break; + case 32: + xvid_cs = XVID_CSP_RGB32; + break; + } + break; + } - xvidenc->csp = xvid_cs; - xvidenc->width = w; - xvidenc->height = h; - xvidenc->fps = fps; + g_return_val_if_fail (xvid_cs != -1, GST_PAD_LINK_REFUSED); - if (gst_xvidenc_setup(xvidenc)) { - GstPadLinkReturn ret; - GstCaps *new_caps; + xvidenc->csp = xvid_cs; + xvidenc->width = w; + xvidenc->height = h; + xvidenc->fps = fps; - new_caps = GST_CAPS_NEW("xvidenc_src_caps", - "video/x-xvid", - "width", GST_PROPS_INT(w), - "height", GST_PROPS_INT(h), - "framerate", GST_PROPS_FLOAT (fps)); + if (gst_xvidenc_setup(xvidenc)) { + GstPadLinkReturn ret; + GstCaps *new_caps; - ret = gst_pad_try_set_caps(xvidenc->srcpad, new_caps); + new_caps = gst_caps_new_simple( + "video/x-xvid", + "width", G_TYPE_INT, w, + "height", G_TYPE_INT, h, + "framerate", G_TYPE_DOUBLE, fps); - if (ret <= 0) { - if (xvidenc->handle) { - xvid_encore(xvidenc->handle, XVID_ENC_DESTROY, NULL, NULL); - xvidenc->handle = NULL; - } - } + ret = gst_pad_try_set_caps(xvidenc->srcpad, new_caps); - return ret; + if (ret <= 0) { + if (xvidenc->handle) { + xvid_encore(xvidenc->handle, XVID_ENC_DESTROY, NULL, NULL); + xvidenc->handle = NULL; + } } -trynext: - continue; + return ret; } /* if we got here - it's not good */ diff --git a/ext/xvid/gstxvidenc.h b/ext/xvid/gstxvidenc.h index 7597e196..12f4d2fd 100644 --- a/ext/xvid/gstxvidenc.h +++ b/ext/xvid/gstxvidenc.h @@ -59,9 +59,9 @@ struct _GstXvidEnc { /* xvid handle */ void *handle; - int csp; - int width, height; - float fps; + gint csp; + gint width, height; + double fps; }; struct _GstXvidEncClass { diff --git a/gst-libs/gst/audio/Makefile.am b/gst-libs/gst/audio/Makefile.am index 4f95f4ef..d99cbcc6 100644 --- a/gst-libs/gst/audio/Makefile.am +++ b/gst-libs/gst/audio/Makefile.am @@ -1,12 +1,21 @@ librarydir = $(libdir)/gstreamer-@GST_MAJORMINOR@ -library_LTLIBRARIES = libgstaudio.la +library_LTLIBRARIES = libgstaudio.la libgstaudiofilter.la libgstaudiofilterexample.la libgstaudio_la_SOURCES = audio.c audioclock.c libgstaudioincludedir = $(includedir)/gstreamer-@GST_MAJORMINOR@/gst/audio -libgstaudioinclude_HEADERS = audio.h audioclock.h +libgstaudioinclude_HEADERS = audio.h audioclock.h gstaudiofilter.h libgstaudio_la_LIBADD = libgstaudio_la_CFLAGS = $(GST_CFLAGS) libgstaudio_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) + +libgstaudiofilter_la_SOURCES = gstaudiofilter.c gstaudiofilter.h +libgstaudiofilter_la_CFLAGS = $(GST_CFLAGS) +libgstaudiofilter_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) + +libgstaudiofilterexample_la_SOURCES = gstaudiofilterexample.c +libgstaudiofilterexample_la_CFLAGS = $(GST_CFLAGS) +libgstaudiofilterexample_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) + diff --git a/gst-libs/gst/audio/audio.c b/gst-libs/gst/audio/audio.c index f5ddaf8b..bec298e9 100644 --- a/gst-libs/gst/audio/audio.c +++ b/gst-libs/gst/audio/audio.c @@ -35,22 +35,23 @@ gst_audio_frame_byte_size (GstPad* pad) int width = 0; int channels = 0; - - GstCaps *caps = NULL; + GstCaps *caps; + GstStructure *structure; /* get caps of pad */ caps = GST_PAD_CAPS (pad); - if (caps == NULL) - { + if (caps == NULL) { /* ERROR: could not get caps of pad */ g_warning ("gstaudio: could not get caps of pad %s:%s\n", GST_ELEMENT_NAME (gst_pad_get_parent (pad)), GST_PAD_NAME (pad)); return 0; } - gst_caps_get_int (caps, "width", &width); - gst_caps_get_int (caps, "channels", &channels); + structure = gst_caps_get_structure (caps, 0); + + gst_structure_get_int (structure, "width", &width); + gst_structure_get_int (structure, "channels", &channels); return (width / 8) * channels; } @@ -83,6 +84,7 @@ gst_audio_frame_rate (GstPad *pad) { GstCaps *caps = NULL; gint rate; + GstStructure *structure; /* get caps of pad */ caps = GST_PAD_CAPS (pad); @@ -94,7 +96,8 @@ gst_audio_frame_rate (GstPad *pad) return 0; } else { - gst_caps_get_int (caps, "rate", &rate); + structure = gst_caps_get_structure (caps, 0); + gst_structure_get_int (structure, "rate", &rate); return rate; } } @@ -115,6 +118,7 @@ gst_audio_length (GstPad* pad, GstBuffer* buf) double length; GstCaps *caps = NULL; + GstStructure *structure; g_assert (GST_IS_BUFFER (buf)); /* get caps of pad */ @@ -128,10 +132,11 @@ gst_audio_length (GstPad* pad, GstBuffer* buf) } else { + structure = gst_caps_get_structure (caps, 0); bytes = GST_BUFFER_SIZE (buf); - gst_caps_get_int (caps, "width", &width); - gst_caps_get_int (caps, "channels", &channels); - gst_caps_get_int (caps, "rate", &rate); + gst_structure_get_int (structure, "width", &width); + gst_structure_get_int (structure, "channels", &channels); + gst_structure_get_int (structure, "rate", &rate); g_assert (bytes != 0); g_assert (width != 0); @@ -152,6 +157,7 @@ gst_audio_highest_sample_value (GstPad* pad) gboolean is_signed = FALSE; gint width = 0; GstCaps *caps = NULL; + GstStructure *structure; caps = GST_PAD_CAPS (pad); if (caps == NULL) @@ -160,8 +166,9 @@ gst_audio_highest_sample_value (GstPad* pad) GST_ELEMENT_NAME (gst_pad_get_parent (pad)), GST_PAD_NAME (pad)); } - gst_caps_get_int (caps, "width", &width); - gst_caps_get_boolean (caps, "signed", &is_signed); + structure = gst_caps_get_structure (caps, 0); + gst_structure_get_int (structure, "width", &width); + gst_structure_get_boolean (structure, "signed", &is_signed); if (is_signed) --width; /* example : 16 bit, signed : samples between -32768 and 32767 */ diff --git a/gst-libs/gst/audio/audio.h b/gst-libs/gst/audio/audio.h index 0958f654..73a4043f 100644 --- a/gst-libs/gst/audio/audio.h +++ b/gst-libs/gst/audio/audio.h @@ -50,66 +50,43 @@ G_BEGIN_DECLS #define GST_AUDIO_DEF_RATE 44100 -#define GST_AUDIO_INT_PAD_TEMPLATE_PROPS \ - gst_props_new (\ - "rate", GST_PROPS_INT_RANGE (1, G_MAXINT),\ - "channels", GST_PROPS_INT_RANGE (1, G_MAXINT),\ - "endianness", GST_PROPS_LIST (\ - GST_PROPS_INT (G_LITTLE_ENDIAN),\ - GST_PROPS_INT (G_BIG_ENDIAN)\ - ),\ - "width", GST_PROPS_LIST (\ - GST_PROPS_INT (8),\ - GST_PROPS_INT (16),\ - GST_PROPS_INT (32)\ - ),\ - "depth", GST_PROPS_INT_RANGE (1, 32),\ - "signed", GST_PROPS_LIST (\ - GST_PROPS_BOOLEAN (TRUE),\ - GST_PROPS_BOOLEAN (FALSE)\ - ),\ - "buffer-frames", GST_PROPS_INT_RANGE (1, G_MAXINT),\ - NULL) +#define GST_AUDIO_INT_PAD_TEMPLATE_CAPS \ + "audio/x-raw-int, " \ + "rate = (int) [ 1, MAX ], " \ + "channels = (int) [ 1, MAX ], " \ + "endianness = (int) { LITTLE_ENDIAN, BIG_ENDIAN }, " \ + "width = (int) { 8, 16, 32 }, " \ + "depth = (int) [ 1, 32 ], " \ + "signed = (boolean) { true, false }, " \ + "buffer-frames = (int) [ 1, MAX ]" + /* "standard" int audio is native order, 16 bit stereo. */ -#define GST_AUDIO_INT_STANDARD_PAD_TEMPLATE_PROPS \ - gst_props_new (\ - "rate", GST_PROPS_INT_RANGE (1, G_MAXINT),\ - "channels", GST_PROPS_INT (2),\ - "endianness", GST_PROPS_INT (G_BYTE_ORDER),\ - "width", GST_PROPS_INT (16),\ - "depth", GST_PROPS_INT (16),\ - "signed", GST_PROPS_LIST (\ - GST_PROPS_BOOLEAN (TRUE),\ - GST_PROPS_BOOLEAN (FALSE)\ - ),\ - "buffer-frames", GST_PROPS_INT_RANGE (1, G_MAXINT),\ - NULL) - -#define GST_AUDIO_FLOAT_PAD_TEMPLATE_PROPS \ - gst_props_new (\ - "rate", GST_PROPS_INT_RANGE (1, G_MAXINT),\ - "channels", GST_PROPS_INT_RANGE (1, G_MAXINT),\ - "endianness", GST_PROPS_LIST (\ - GST_PROPS_INT (G_LITTLE_ENDIAN),\ - GST_PROPS_INT (G_BIG_ENDIAN)\ - ),\ - "width", GST_PROPS_LIST (\ - GST_PROPS_INT (32),\ - GST_PROPS_INT (64)\ - ),\ - "buffer-frames", GST_PROPS_INT_RANGE (1, G_MAXINT),\ - NULL) +#define GST_AUDIO_INT_STANDARD_PAD_TEMPLATE_CAPS \ + "audio/x-raw-int, " \ + "rate = (int) [ 1, MAX ], " \ + "channels = (int) 2, " \ + "endianness = (int) BYTE_ORDER, " \ + "width = (int) 16, " \ + "depth = (int) 16, " \ + "signed = (boolean) true, " \ + "buffer-frames = (int) [ 1, MAX]" + +#define GST_AUDIO_FLOAT_PAD_TEMPLATE_CAPS \ + "audio/x-raw-float, " \ + "rate = (int) [ 1, MAX ], " \ + "channels = (int) [ 1, MAX ], " \ + "endianness = (int) { LITTLE_ENDIAN , BIG_ENDIAN }, " \ + "width = (int) { 32, 64 }, " \ + "buffer-frames = (int) [ 1, MAX]" /* "standard" float audio is native order, 32 bit mono. */ -#define GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_PROPS \ - gst_props_new (\ - "rate", GST_PROPS_INT_RANGE (1, G_MAXINT),\ - "channels", GST_PROPS_INT (1),\ - "endianness", GST_PROPS_INT (G_BYTE_ORDER),\ - "width", GST_PROPS_INT (32),\ - "buffer-frames", GST_PROPS_INT_RANGE (1, G_MAXINT),\ - NULL) +#define GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS \ + "audio/x-raw-float, " \ + "rate = (int) [ 1, MAX ], " \ + "channels = (int) 1, " \ + "endianness = (int) BYTE_ORDER, " \ + "buffer-frames = (int) [ 1, MAX]" /* * this library defines and implements some helper functions for audio diff --git a/gst-libs/gst/audio/gstaudiofilter.c b/gst-libs/gst/audio/gstaudiofilter.c new file mode 100644 index 00000000..46e7c7de --- /dev/null +++ b/gst-libs/gst/audio/gstaudiofilter.c @@ -0,0 +1,322 @@ +/* GStreamer + * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu> + * Copyright (C) <2003> David Schleef <ds@schleef.org> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +/*#define DEBUG_ENABLED */ +#include <gstaudiofilter.h> + +#include <string.h> + + +/* GstAudiofilter signals and args */ +enum { + /* FILL ME */ + LAST_SIGNAL +}; + +enum { + ARG_0, + ARG_METHOD, + /* FILL ME */ +}; + +static void gst_audiofilter_base_init (gpointer g_class); +static void gst_audiofilter_class_init (gpointer g_class, gpointer class_data); +static void gst_audiofilter_init (GTypeInstance *instance, gpointer g_class); + +static void gst_audiofilter_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); +static void gst_audiofilter_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); + +static void gst_audiofilter_chain (GstPad *pad, GstData *_data); +GstCaps * gst_audiofilter_class_get_capslist(GstAudiofilterClass *klass); + +static GstElementClass *parent_class = NULL; + +GType +gst_audiofilter_get_type (void) +{ + static GType audiofilter_type = 0; + + if (!audiofilter_type) { + static const GTypeInfo audiofilter_info = { + sizeof(GstAudiofilterClass), + gst_audiofilter_base_init, + NULL, + gst_audiofilter_class_init, + NULL, + NULL, + sizeof(GstAudiofilter), + 0, + gst_audiofilter_init, + }; + audiofilter_type = g_type_register_static(GST_TYPE_ELEMENT, + "GstAudiofilter", &audiofilter_info, G_TYPE_FLAG_ABSTRACT); + } + return audiofilter_type; +} + +static void gst_audiofilter_base_init (gpointer g_class) +{ + static GstElementDetails audiofilter_details = { + "Audio filter base class", + "Filter/Effect/Audio", + "Filters audio", + "David Schleef <ds@schleef.org>" + }; + GstAudiofilterClass *klass = (GstAudiofilterClass *) g_class; + GstElementClass *element_class = GST_ELEMENT_CLASS (klass); + + gst_element_class_set_details (element_class, &audiofilter_details); +} + +static void gst_audiofilter_class_init (gpointer g_class, gpointer class_data) +{ + GObjectClass *gobject_class; + GstElementClass *gstelement_class; + GstAudiofilterClass *klass; + + klass = (GstAudiofilterClass *)g_class; + gobject_class = (GObjectClass*)klass; + gstelement_class = (GstElementClass*)klass; + + parent_class = g_type_class_ref(GST_TYPE_ELEMENT); + + gobject_class->set_property = gst_audiofilter_set_property; + gobject_class->get_property = gst_audiofilter_get_property; +} + +static GstCaps * +gst_audiofilter_getcaps (GstPad *pad) +{ + GstAudiofilter *audiofilter; + GstCaps *othercaps; + GstAudiofilterClass *audiofilter_class; + + GST_DEBUG("gst_audiofilter_sink_getcaps"); + audiofilter = GST_AUDIOFILTER (gst_pad_get_parent (pad)); + + audiofilter_class = GST_AUDIOFILTER_CLASS ( + G_OBJECT_GET_CLASS (audiofilter)); + + if (pad == audiofilter->srcpad) { + othercaps = gst_pad_get_allowed_caps (audiofilter->sinkpad); + } else { + othercaps = gst_pad_get_allowed_caps (audiofilter->srcpad); + } + + return gst_caps_intersect (othercaps, audiofilter_class->caps); +} + +static GstPadLinkReturn +gst_audiofilter_link (GstPad *pad, const GstCaps *caps) +{ + GstAudiofilter *audiofilter; + GstPadLinkReturn ret; + GstPadLinkReturn link_ret; + GstStructure *structure; + GstAudiofilterClass *audiofilter_class; + + GST_DEBUG("gst_audiofilter_link"); + audiofilter = GST_AUDIOFILTER (gst_pad_get_parent (pad)); + audiofilter_class = GST_AUDIOFILTER_CLASS ( + G_OBJECT_GET_CLASS (audiofilter)); + + + if (pad == audiofilter->srcpad) { + link_ret = gst_pad_try_set_caps (audiofilter->sinkpad, caps); + } else { + link_ret = gst_pad_try_set_caps (audiofilter->srcpad, caps); + } + + if (link_ret != GST_PAD_LINK_OK) return link_ret; + + structure = gst_caps_get_structure (caps, 0); + + if (strcmp (gst_structure_get_name (structure), "audio/x-raw-int") == 0) { + ret = gst_structure_get_int (structure, "depth", &audiofilter->depth); + ret &= gst_structure_get_int (structure, "width", &audiofilter->width); + ret &= gst_structure_get_int (structure, "channels", &audiofilter->channels); + } else if (strcmp (gst_structure_get_name (structure), "audio/x-raw-float") + == 0) { + + } else { + g_assert_not_reached(); + } + ret &= gst_structure_get_int (structure, "rate", &audiofilter->rate); + + if (audiofilter_class->setup) (audiofilter_class->setup) (audiofilter); + + return GST_PAD_LINK_OK; +} + +static void +gst_audiofilter_init (GTypeInstance *instance, gpointer g_class) +{ + GstAudiofilter *audiofilter = GST_AUDIOFILTER (instance); + GstPadTemplate *pad_template; + + GST_DEBUG("gst_audiofilter_init"); + + pad_template = gst_element_class_get_pad_template(GST_ELEMENT_CLASS(g_class), + "sink"); + g_return_if_fail(pad_template != NULL); + audiofilter->sinkpad = gst_pad_new_from_template(pad_template, "sink"); + gst_element_add_pad(GST_ELEMENT(audiofilter),audiofilter->sinkpad); + gst_pad_set_chain_function(audiofilter->sinkpad,gst_audiofilter_chain); + gst_pad_set_link_function(audiofilter->sinkpad,gst_audiofilter_link); + gst_pad_set_getcaps_function(audiofilter->sinkpad,gst_audiofilter_getcaps); + + pad_template = gst_element_class_get_pad_template(GST_ELEMENT_CLASS(g_class), + "src"); + g_return_if_fail(pad_template != NULL); + audiofilter->srcpad = gst_pad_new_from_template(pad_template, "src"); + gst_element_add_pad(GST_ELEMENT(audiofilter),audiofilter->srcpad); + gst_pad_set_link_function(audiofilter->srcpad,gst_audiofilter_link); + gst_pad_set_getcaps_function(audiofilter->srcpad,gst_audiofilter_getcaps); + + audiofilter->inited = FALSE; +} + +static void +gst_audiofilter_chain (GstPad *pad, GstData *data) +{ + GstBuffer *inbuf = GST_BUFFER (data); + GstAudiofilter *audiofilter; + GstBuffer *outbuf; + GstAudiofilterClass *audiofilter_class; + + GST_DEBUG ("gst_audiofilter_chain"); + + g_return_if_fail (pad != NULL); + g_return_if_fail (GST_IS_PAD (pad)); + g_return_if_fail (inbuf != NULL); + + audiofilter = GST_AUDIOFILTER (gst_pad_get_parent (pad)); + //g_return_if_fail (audiofilter->inited); + audiofilter_class = GST_AUDIOFILTER_CLASS ( + G_OBJECT_GET_CLASS (audiofilter)); + + GST_DEBUG ("gst_audiofilter_chain: got buffer of %d bytes in '%s'", + GST_BUFFER_SIZE(inbuf), GST_OBJECT_NAME (audiofilter)); + + if(audiofilter->passthru){ + gst_pad_push(audiofilter->srcpad, data); + return; + } + + if (gst_data_is_writable(data)) { + if (audiofilter_class->filter_inplace) { + (audiofilter_class->filter_inplace) (audiofilter, inbuf); + outbuf = inbuf; + } else { + outbuf = gst_buffer_new_and_alloc (GST_BUFFER_SIZE(inbuf)); + GST_BUFFER_DURATION(outbuf) = GST_BUFFER_DURATION(inbuf); + GST_BUFFER_TIMESTAMP(outbuf) = GST_BUFFER_TIMESTAMP(inbuf); + + (audiofilter_class->filter) (audiofilter, outbuf, inbuf); + gst_buffer_unref(inbuf); + } + } else { + outbuf = gst_buffer_new_and_alloc (GST_BUFFER_SIZE(inbuf)); + GST_BUFFER_DURATION(outbuf) = GST_BUFFER_DURATION(inbuf); + GST_BUFFER_TIMESTAMP(outbuf) = GST_BUFFER_TIMESTAMP(inbuf); + if (audiofilter_class->filter) { + (audiofilter_class->filter) (audiofilter, outbuf, inbuf); + } else { + memcpy(GST_BUFFER_DATA(outbuf), GST_BUFFER_DATA(inbuf), + GST_BUFFER_SIZE(inbuf)); + + (audiofilter_class->filter_inplace) (audiofilter, outbuf); + } + gst_buffer_unref(inbuf); + } + + gst_pad_push(audiofilter->srcpad, GST_DATA (outbuf)); +} + +static void +gst_audiofilter_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) +{ + GstAudiofilter *src; + + /* it's not null if we got it, but it might not be ours */ + g_return_if_fail(GST_IS_AUDIOFILTER(object)); + src = GST_AUDIOFILTER(object); + + GST_DEBUG("gst_audiofilter_set_property"); + switch (prop_id) { + default: + break; + } +} + +static void +gst_audiofilter_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) +{ + GstAudiofilter *src; + + /* it's not null if we got it, but it might not be ours */ + g_return_if_fail(GST_IS_AUDIOFILTER(object)); + src = GST_AUDIOFILTER(object); + + switch (prop_id) { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +void gst_audiofilter_class_add_pad_templates ( + GstAudiofilterClass *audiofilter_class, const GstCaps *caps) +{ + GstElementClass *element_class = GST_ELEMENT_CLASS (audiofilter_class); + + audiofilter_class->caps = gst_caps_copy(caps); + + gst_element_class_add_pad_template (element_class, + gst_pad_template_new("src", GST_PAD_SRC, GST_PAD_ALWAYS, + gst_caps_copy(caps))); + + gst_element_class_add_pad_template (element_class, + gst_pad_template_new("sink", GST_PAD_SINK, GST_PAD_ALWAYS, + gst_caps_copy(caps))); +} + +static gboolean +plugin_init (GstPlugin *plugin) +{ + return TRUE; +} + +GST_PLUGIN_DEFINE ( + GST_VERSION_MAJOR, + GST_VERSION_MINOR, + "gstaudiofilter", + "Audio filter parent class", + plugin_init, + VERSION, + "LGPL", + GST_PACKAGE, + GST_ORIGIN +) + diff --git a/gst-libs/gst/audio/gstaudiofilter.h b/gst-libs/gst/audio/gstaudiofilter.h new file mode 100644 index 00000000..4723c329 --- /dev/null +++ b/gst-libs/gst/audio/gstaudiofilter.h @@ -0,0 +1,84 @@ +/* GStreamer + * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + + +#ifndef __GST_AUDIOFILTER_H__ +#define __GST_AUDIOFILTER_H__ + + +#include <gst/gst.h> + + +G_BEGIN_DECLS + +typedef struct _GstAudiofilter GstAudiofilter; +typedef struct _GstAudiofilterClass GstAudiofilterClass; + +typedef void (*GstAudiofilterFilterFunc)(GstAudiofilter *filter, + GstBuffer *outbuf, GstBuffer *inbuf); +typedef void (*GstAudiofilterInplaceFilterFunc)(GstAudiofilter *filter, + GstBuffer *buffer); + +typedef void (*GstAudiofilterSetupFunc) (GstAudiofilter *filter); + + +#define GST_TYPE_AUDIOFILTER \ + (gst_audiofilter_get_type()) +#define GST_AUDIOFILTER(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_AUDIOFILTER,GstAudiofilter)) +#define GST_AUDIOFILTER_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_AUDIOFILTER,GstAudiofilterClass)) +#define GST_IS_AUDIOFILTER(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_AUDIOFILTER)) +#define GST_IS_AUDIOFILTER_CLASS(obj) \ + (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AUDIOFILTER)) + +struct _GstAudiofilter { + GstElement element; + + GstPad *sinkpad,*srcpad; + + /* audio state */ + gboolean inited; + + int rate; + int width; + int channels; + int depth; + gboolean passthru; + +}; + +struct _GstAudiofilterClass { + GstElementClass parent_class; + + GstCaps *caps; + GstAudiofilterSetupFunc setup; + GstAudiofilterInplaceFilterFunc filter_inplace; + GstAudiofilterFilterFunc filter; +}; + +GType gst_audiofilter_get_type(void); + +void gst_audiofilter_class_add_pad_templates (GstAudiofilterClass *audiofilterclass, const GstCaps *caps); + +G_END_DECLS + +#endif /* __GST_AUDIOFILTER_H__ */ + diff --git a/gst-libs/gst/audio/gstaudiofilterexample.c b/gst-libs/gst/audio/gstaudiofilterexample.c new file mode 100644 index 00000000..15e111af --- /dev/null +++ b/gst-libs/gst/audio/gstaudiofilterexample.c @@ -0,0 +1,170 @@ +/* GStreamer + * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu> + * Copyright (C) <2003> David Schleef <ds@schleef.org> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <gst/gst.h> +#include <gst/audio/gstaudiofilter.h> + +typedef struct _GstAudiofilterExample GstAudiofilterExample; +typedef struct _GstAudiofilterExampleClass GstAudiofilterExampleClass; + +#define GST_TYPE_AUDIOFILTER_EXAMPLE \ + (gst_audiofilter_example_get_type()) +#define GST_AUDIOFILTER_EXAMPLE(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_AUDIOFILTER_EXAMPLE,GstAudiofilterExample)) +#define GST_AUDIOFILTER_EXAMPLE_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_AUDIOFILTER_EXAMPLE,GstAudiofilterExampleClass)) +#define GST_IS_AUDIOFILTER_EXAMPLE(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_AUDIOFILTER_EXAMPLE)) +#define GST_IS_AUDIOFILTER_EXAMPLE_CLASS(obj) \ + (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AUDIOFILTER_EXAMPLE)) + +struct _GstAudiofilterExample { + GstAudiofilter audiofilter; + +}; + +struct _GstAudiofilterExampleClass { + GstAudiofilterClass parent_class; + +}; + + +/* GstAudiofilterExample signals and args */ +enum { + /* FILL ME */ + LAST_SIGNAL +}; + +enum { + ARG_0, + ARG_METHOD, + /* FILL ME */ +}; + +static void gst_audiofilter_example_base_init (gpointer g_class); +static void gst_audiofilter_example_class_init (gpointer g_class, gpointer class_data); + +static void gst_audiofilter_example_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); +static void gst_audiofilter_example_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); + +GType +gst_audiofilter_example_get_type (void) +{ + static GType audiofilter_example_type = 0; + + if (!audiofilter_example_type) { + static const GTypeInfo audiofilter_example_info = { + sizeof(GstAudiofilterExampleClass), + gst_audiofilter_example_base_init, + NULL, + gst_audiofilter_example_class_init, + NULL, + NULL, + sizeof(GstAudiofilterExample), + 0, + NULL, + }; + audiofilter_example_type = g_type_register_static(GST_TYPE_AUDIOFILTER, + "GstAudiofilterExample", &audiofilter_example_info, 0); + } + return audiofilter_example_type; +} + +static void gst_audiofilter_example_base_init (gpointer g_class) +{ + static GstElementDetails audiofilter_example_details = { + "Audio filter example", + "Filter/Effect/Audio", + "Filters audio", + "David Schleef <ds@schleef.org>" + }; + GstAudiofilterExampleClass *klass = (GstAudiofilterExampleClass *) g_class; + GstElementClass *element_class = GST_ELEMENT_CLASS (klass); + + gst_element_class_set_details (element_class, &audiofilter_example_details); +} + +static void gst_audiofilter_example_class_init (gpointer g_class, gpointer class_data) +{ + GObjectClass *gobject_class; + GstElementClass *gstelement_class; + GstAudiofilterExampleClass *klass; + + klass = (GstAudiofilterExampleClass *)g_class; + gobject_class = (GObjectClass*)klass; + gstelement_class = (GstElementClass*)klass; + + gobject_class->set_property = gst_audiofilter_example_set_property; + gobject_class->get_property = gst_audiofilter_example_get_property; +} + +static void +gst_audiofilter_example_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) +{ + GstAudiofilterExample *src; + + /* it's not null if we got it, but it might not be ours */ + g_return_if_fail(GST_IS_AUDIOFILTER_EXAMPLE(object)); + src = GST_AUDIOFILTER_EXAMPLE(object); + + GST_DEBUG("gst_audiofilter_example_set_property"); + switch (prop_id) { + default: + break; + } +} + +static void +gst_audiofilter_example_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) +{ + GstAudiofilterExample *src; + + /* it's not null if we got it, but it might not be ours */ + g_return_if_fail(GST_IS_AUDIOFILTER_EXAMPLE(object)); + src = GST_AUDIOFILTER_EXAMPLE(object); + + switch (prop_id) { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static gboolean +plugin_init (GstPlugin *plugin) +{ + return TRUE; +} + +GST_PLUGIN_DEFINE ( + GST_VERSION_MAJOR, + GST_VERSION_MINOR, + "gstaudiofilter_example", + "Audio filter example", + plugin_init, + VERSION, + "LGPL", + GST_PACKAGE, + GST_ORIGIN +) diff --git a/gst-libs/gst/media-info/media-info-priv.c b/gst-libs/gst/media-info/media-info-priv.c index 77981598..c7f470ea 100644 --- a/gst-libs/gst/media-info/media-info-priv.c +++ b/gst-libs/gst/media-info/media-info-priv.c @@ -136,13 +136,13 @@ gmi_reset (GstMediaInfo *info) if (priv->format) { GMI_DEBUG ("unreffing priv->format, error before this ?\n"); - gst_caps_unref (priv->format); + gst_caps_free (priv->format); priv->format = NULL; } if (priv->metadata) { GMI_DEBUG ("unreffing priv->metadata, error before this ?\n"); - gst_caps_unref (priv->metadata); + gst_caps_free (priv->metadata); priv->metadata = NULL; } if (priv->stream) @@ -193,12 +193,12 @@ gmi_seek_to_track (GstMediaInfo *info, long track) /* clear structs because of the seek */ if (priv->metadata) { - gst_caps_unref (priv->metadata); + gst_caps_free (priv->metadata); priv->metadata = NULL; } if (priv->streaminfo) { - gst_caps_unref (priv->streaminfo); + gst_caps_free (priv->streaminfo); priv->streaminfo = NULL; } return TRUE; @@ -304,7 +304,7 @@ gmip_find_type_pre (GstMediaInfoPriv *priv) if (priv->type) { /* we don't need to unref, this is done inside gsttypefind.c - gst_caps_unref (priv->type); + gst_caps_free (priv->type); */ priv->type = NULL; } @@ -573,14 +573,13 @@ gmip_find_track_streaminfo_post (GstMediaInfoPriv *priv) &format, &value_end); if (res) { - GstPropsEntry *length; /* substract to get the length */ GMI_DEBUG("DEBUG: start %lld, end %lld\n", value_start, value_end); value_end -= value_start; /* FIXME: check units; this is in seconds */ - length = gst_props_entry_new ("length", - GST_PROPS_INT ((int) (value_end / 1E6))); - gst_props_add_entry (gst_caps_get_props (priv->streaminfo), length); + + gst_caps_set_simple (priv->streaminfo, + "length", G_TYPE_INT, (int) (value_end / 1E6), NULL); } } } diff --git a/gst-libs/gst/media-info/media-info-test.c b/gst-libs/gst/media-info/media-info-test.c index 553e97c6..5a73c8bd 100644 --- a/gst-libs/gst/media-info/media-info-test.c +++ b/gst-libs/gst/media-info/media-info-test.c @@ -5,56 +5,6 @@ #include "media-info.h" static void -caps_print (GstCaps *caps) -{ - if (caps == NULL) return; - /* - if (!strcmp (gst_caps_get_mime (caps), "application/x-gst-metadata") || - !strcmp (gst_caps_get_mime (caps), "application/x-gst-streaminfo")) - */ - if (TRUE) - { - GstProps *props = caps->properties; - GList *walk; - - if (props == NULL) - { - g_print (" none\n"); - return; - } - walk = props->properties; - - while (walk) { - GstPropsEntry *entry = (GstPropsEntry *) walk->data; - const gchar *name; - const gchar *str_val; - gint int_val; - GstPropsType type; - - name = gst_props_entry_get_name (entry); - type = gst_props_entry_get_props_type (entry); - switch (type) { - case GST_PROPS_STRING_TYPE: - gst_props_entry_get_string (entry, &str_val); - g_print (" %s='%s'\n", name, str_val); - break; - case GST_PROPS_INT_TYPE: - gst_props_entry_get_int (entry, &int_val); - g_print (" %s=%d\n", name, int_val); - break; - default: - break; - } - - walk = g_list_next (walk); - } - } - else { - g_print (" unkown caps type\n"); - } -} - -static void info_print (GstMediaInfoStream *stream) { int i; @@ -77,11 +27,11 @@ info_print (GstMediaInfoStream *stream) g_print ("- track %d\n", i); track = (GstMediaInfoTrack *) p->data; g_print (" - metadata:\n"); - caps_print (track->metadata); + g_print ("%s\n", gst_caps_to_string (track->metadata)); g_print (" - streaminfo:\n"); - caps_print (track->streaminfo); + g_print ("%s\n", gst_caps_to_string (track->streaminfo)); g_print (" - format:\n"); - caps_print (track->format); + g_print ("%s\n", gst_caps_to_string (track->format)); p = p->next; } } diff --git a/gst-libs/gst/media-info/media-info.c b/gst-libs/gst/media-info/media-info.c index 92957e16..e214e8e1 100644 --- a/gst-libs/gst/media-info/media-info.c +++ b/gst-libs/gst/media-info/media-info.c @@ -294,7 +294,8 @@ gst_media_info_read_idler (GstMediaInfo *info, GstMediaInfoStream **streamp) GMI_DEBUG("doing find_type_post\n"); gmip_find_type_post (priv); GMI_DEBUG("finding out mime type\n"); - mime = g_strdup (gst_caps_get_mime (priv->type)); + mime = g_strdup (gst_structure_get_name ( + gst_caps_get_structure(priv->type, 0))); GMI_DEBUG("found out mime type: %s\n", mime); decoder = gmi_get_decoder (info, mime); if (decoder == NULL) @@ -443,7 +444,8 @@ gst_media_info_read (GstMediaInfo *info, const char *location, guint16 flags) if (!gmip_find_type (priv)) return NULL; - mime = g_strdup (gst_caps_get_mime (priv->type)); + mime = g_strdup (gst_structure_get_name ( + gst_caps_get_structure(priv->type, 0))); GMI_DEBUG("mime type: %s\n", mime); /* c) figure out decoder */ diff --git a/gst-libs/gst/play/gstplay.c b/gst-libs/gst/play/gstplay.c index 8e0c9754..d79e06f3 100644 --- a/gst-libs/gst/play/gstplay.c +++ b/gst-libs/gst/play/gstplay.c @@ -20,6 +20,7 @@ #ifdef HAVE_CONFIG_H #include "config.h" #endif +#include <string.h> #include "gstplay.h" @@ -919,40 +920,41 @@ gst_play_get_sink_element (GstPlay *play, } else { /* If not a src pad checking caps */ - GstCaps *caps; + const GstCaps *caps; + GstStructure *structure; + gboolean has_video_cap = FALSE; + gboolean has_audio_cap = FALSE; + caps = gst_pad_get_caps (GST_PAD (pads->data)); - while (caps) { - gboolean has_video_cap = FALSE, has_audio_cap = FALSE; - if (g_ascii_strcasecmp (gst_caps_get_mime (caps), - "audio/x-raw-int") == 0) { - has_audio_cap = TRUE; - } - - if ((g_ascii_strcasecmp (gst_caps_get_mime (caps), - "video/x-raw-yuv") == 0) || - (g_ascii_strcasecmp (gst_caps_get_mime (caps), - "video/x-raw-rgb") == 0)) { - has_video_cap = TRUE; - } - - switch (sink_type) { - case GST_PLAY_SINK_TYPE_AUDIO: - if (has_audio_cap) - has_correct_type = TRUE; - break;; - case GST_PLAY_SINK_TYPE_VIDEO: - if (has_video_cap) - has_correct_type = TRUE; - break;; - case GST_PLAY_SINK_TYPE_ANY: - if ((has_video_cap) || (has_audio_cap)) - has_correct_type = TRUE; - break;; - default: - has_correct_type = FALSE; - } - - caps = caps->next; + structure = gst_caps_get_structure (caps, 0); + + if (strcmp (gst_structure_get_name (structure), + "audio/x-raw-int") == 0) { + has_audio_cap = TRUE; + } + + if (strcmp (gst_structure_get_name (structure), + "video/x-raw-yuv") == 0 || + strcmp (gst_structure_get_name (structure), + "video/x-raw-rgb") == 0) { + has_video_cap = TRUE; + } + + switch (sink_type) { + case GST_PLAY_SINK_TYPE_AUDIO: + if (has_audio_cap) + has_correct_type = TRUE; + break;; + case GST_PLAY_SINK_TYPE_VIDEO: + if (has_video_cap) + has_correct_type = TRUE; + break;; + case GST_PLAY_SINK_TYPE_ANY: + if ((has_video_cap) || (has_audio_cap)) + has_correct_type = TRUE; + break;; + default: + has_correct_type = FALSE; } } diff --git a/gst-libs/gst/play/play.c b/gst-libs/gst/play/play.c index 8e0c9754..d79e06f3 100644 --- a/gst-libs/gst/play/play.c +++ b/gst-libs/gst/play/play.c @@ -20,6 +20,7 @@ #ifdef HAVE_CONFIG_H #include "config.h" #endif +#include <string.h> #include "gstplay.h" @@ -919,40 +920,41 @@ gst_play_get_sink_element (GstPlay *play, } else { /* If not a src pad checking caps */ - GstCaps *caps; + const GstCaps *caps; + GstStructure *structure; + gboolean has_video_cap = FALSE; + gboolean has_audio_cap = FALSE; + caps = gst_pad_get_caps (GST_PAD (pads->data)); - while (caps) { - gboolean has_video_cap = FALSE, has_audio_cap = FALSE; - if (g_ascii_strcasecmp (gst_caps_get_mime (caps), - "audio/x-raw-int") == 0) { - has_audio_cap = TRUE; - } - - if ((g_ascii_strcasecmp (gst_caps_get_mime (caps), - "video/x-raw-yuv") == 0) || - (g_ascii_strcasecmp (gst_caps_get_mime (caps), - "video/x-raw-rgb") == 0)) { - has_video_cap = TRUE; - } - - switch (sink_type) { - case GST_PLAY_SINK_TYPE_AUDIO: - if (has_audio_cap) - has_correct_type = TRUE; - break;; - case GST_PLAY_SINK_TYPE_VIDEO: - if (has_video_cap) - has_correct_type = TRUE; - break;; - case GST_PLAY_SINK_TYPE_ANY: - if ((has_video_cap) || (has_audio_cap)) - has_correct_type = TRUE; - break;; - default: - has_correct_type = FALSE; - } - - caps = caps->next; + structure = gst_caps_get_structure (caps, 0); + + if (strcmp (gst_structure_get_name (structure), + "audio/x-raw-int") == 0) { + has_audio_cap = TRUE; + } + + if (strcmp (gst_structure_get_name (structure), + "video/x-raw-yuv") == 0 || + strcmp (gst_structure_get_name (structure), + "video/x-raw-rgb") == 0) { + has_video_cap = TRUE; + } + + switch (sink_type) { + case GST_PLAY_SINK_TYPE_AUDIO: + if (has_audio_cap) + has_correct_type = TRUE; + break;; + case GST_PLAY_SINK_TYPE_VIDEO: + if (has_video_cap) + has_correct_type = TRUE; + break;; + case GST_PLAY_SINK_TYPE_ANY: + if ((has_video_cap) || (has_audio_cap)) + has_correct_type = TRUE; + break;; + default: + has_correct_type = FALSE; } } diff --git a/gst-libs/gst/play/play.old.c b/gst-libs/gst/play/play.old.c index 64963661..513a3e12 100644 --- a/gst-libs/gst/play/play.old.c +++ b/gst-libs/gst/play/play.old.c @@ -26,6 +26,7 @@ #include "config.h" #endif +#include <string.h> #include "play.h" enum @@ -906,43 +907,38 @@ gst_play_get_sink_element (GstPlay * play, else { /* If not a src pad checking caps */ - GstCaps *caps; - caps = gst_pad_get_caps (GST_PAD (pads->data)); - while (caps) + gboolean has_video_cap = FALSE, has_audio_cap = FALSE; + const char *media_type; + + media_type = gst_structure_get_name (gst_caps_get_structure ( + gst_pad_get_caps (GST_PAD (pads->data)), 0)); + if (strcmp (media_type, "audio/x-raw-int") == 0) + { + has_audio_cap = TRUE; + } + if ((strcmp (media_type, "video/x-raw-yuv") == 0) || + (strcmp (media_type, "video/x-raw-rgb") == 0)) + + { + has_video_cap = TRUE; + } + + switch (sink_type) { - gboolean has_video_cap = FALSE, has_audio_cap = FALSE; - if (g_ascii_strcasecmp (gst_caps_get_mime (caps), - "audio/x-raw-int") == 0) - { - has_audio_cap = TRUE; - } - if ((g_ascii_strcasecmp (gst_caps_get_mime (caps), - "video/x-raw-yuv") == 0) || - (g_ascii_strcasecmp (gst_caps_get_mime (caps), - "video/x-raw-rgb") == 0)) - - { - has_video_cap = TRUE; - } - - switch (sink_type) - { - case GST_PLAY_SINK_TYPE_AUDIO: - if (has_audio_cap) - has_correct_type = TRUE; - break;; - case GST_PLAY_SINK_TYPE_VIDEO: - if (has_video_cap) - has_correct_type = TRUE; - break;; - case GST_PLAY_SINK_TYPE_ANY: - if ((has_video_cap) || (has_audio_cap)) - has_correct_type = TRUE; - break;; - default: - has_correct_type = FALSE; - } - caps = caps->next; + case GST_PLAY_SINK_TYPE_AUDIO: + if (has_audio_cap) + has_correct_type = TRUE; + break;; + case GST_PLAY_SINK_TYPE_VIDEO: + if (has_video_cap) + has_correct_type = TRUE; + break;; + case GST_PLAY_SINK_TYPE_ANY: + if ((has_video_cap) || (has_audio_cap)) + has_correct_type = TRUE; + break;; + default: + has_correct_type = FALSE; } } pads = g_list_next (pads); diff --git a/gst-libs/gst/riff/riff-media.c b/gst-libs/gst/riff/riff-media.c index eeb6fd63..cbeb3492 100644 --- a/gst-libs/gst/riff/riff-media.c +++ b/gst-libs/gst/riff/riff-media.c @@ -36,40 +36,28 @@ gst_riff_create_video_caps (guint32 codec_fcc, switch (codec_fcc) { case GST_MAKE_FOURCC('I','4','2','0'): case GST_MAKE_FOURCC('Y','U','Y','2'): - caps = GST_CAPS_NEW ( - "riff_video_raw", - "video/x-raw-yuv", - "format", GST_PROPS_FOURCC (codec_fcc) - ); + caps = gst_caps_new_simple ("video/x-raw-yuv", + "format", GST_TYPE_FOURCC, codec_fcc, + NULL); break; case GST_MAKE_FOURCC('M','J','P','G'): /* YUY2 MJPEG */ case GST_MAKE_FOURCC('J','P','E','G'): /* generic (mostly RGB) MJPEG */ case GST_MAKE_FOURCC('P','I','X','L'): /* Miro/Pinnacle fourccs */ case GST_MAKE_FOURCC('V','I','X','L'): /* Miro/Pinnacle fourccs */ - caps = GST_CAPS_NEW ( - "riff_video_jpeg", - "video/x-jpeg", - NULL - ); + caps = gst_caps_new_simple ("video/x-jpeg", NULL); break; case GST_MAKE_FOURCC('H','F','Y','U'): - caps = GST_CAPS_NEW ( - "riff_video_hfyu", - "video/x-huffyuv", - NULL - ); + caps = gst_caps_new_simple ( "video/x-huffyuv", NULL); break; case GST_MAKE_FOURCC('M','P','E','G'): case GST_MAKE_FOURCC('M','P','G','I'): - caps = GST_CAPS_NEW ( - "riff_video_mpeg1", - "video/mpeg", - "systemstream", GST_PROPS_BOOLEAN (FALSE), - "mpegversion", GST_PROPS_BOOLEAN (1) - ); + caps = gst_caps_new_simple ("video/mpeg", + "systemstream", G_TYPE_BOOLEAN, FALSE, + "mpegversion", G_TYPE_BOOLEAN, 1, + NULL); break; case GST_MAKE_FOURCC('H','2','6','3'): @@ -79,138 +67,98 @@ gst_riff_create_video_caps (guint32 codec_fcc, case GST_MAKE_FOURCC('V','D','O','W'): case GST_MAKE_FOURCC('V','I','V','O'): case GST_MAKE_FOURCC('x','2','6','3'): - caps = GST_CAPS_NEW ( - "riff_video_h263", - "video/x-h263", - NULL - ); + caps = gst_caps_new_simple ("video/x-h263", NULL); break; case GST_MAKE_FOURCC('D','I','V','3'): case GST_MAKE_FOURCC('D','I','V','4'): case GST_MAKE_FOURCC('D','I','V','5'): - caps = GST_CAPS_NEW ( - "riff_video_divx3", - "video/x-divx", - "divxversion", GST_PROPS_INT(3) - ); + caps = gst_caps_new_simple ("video/x-divx", + "divxversion", G_TYPE_INT, 3, + NULL); break; case GST_MAKE_FOURCC('d','i','v','x'): case GST_MAKE_FOURCC('D','I','V','X'): case GST_MAKE_FOURCC('D','X','5','0'): - caps = GST_CAPS_NEW ( - "riff_video_divx45", - "video/x-divx", - "divxversion", GST_PROPS_INT(5) - ); + caps = gst_caps_new_simple ("video/x-divx", + "divxversion", G_TYPE_INT, 5, + NULL); break; case GST_MAKE_FOURCC('X','V','I','D'): case GST_MAKE_FOURCC('x','v','i','d'): - caps = GST_CAPS_NEW ( - "riff_video_xvid", - "video/x-xvid", - NULL - ); + caps = gst_caps_new_simple ("video/x-xvid", NULL); break; case GST_MAKE_FOURCC('M','P','G','4'): - caps = GST_CAPS_NEW ( - "riff_video_msmpeg41", - "video/x-msmpeg", - "msmpegversion", GST_PROPS_INT (41) - ); + caps = gst_caps_new_simple ("video/x-msmpeg", + "msmpegversion", G_TYPE_INT, 41, + NULL); break; case GST_MAKE_FOURCC('M','P','4','2'): - caps = GST_CAPS_NEW ( - "riff_video_msmpeg42", - "video/x-msmpeg", - "msmpegversion", GST_PROPS_INT (42) - ); + caps = gst_caps_new_simple ("video/x-msmpeg", + "msmpegversion", G_TYPE_INT, 42, + NULL); break; case GST_MAKE_FOURCC('M','P','4','3'): - caps = GST_CAPS_NEW ( - "riff_video_msmpeg43", - "video/x-msmpeg", - "msmpegversion", GST_PROPS_INT (43) - ); + caps = gst_caps_new_simple ("video/x-msmpeg", + "msmpegversion", G_TYPE_INT, 43, + NULL); break; case GST_MAKE_FOURCC('3','I','V','1'): case GST_MAKE_FOURCC('3','I','V','2'): - caps = GST_CAPS_NEW ( - "riff_video_3ivx", - "video/x-3ivx", - NULL - ); + caps = gst_caps_new_simple ( "video/x-3ivx", NULL); break; case GST_MAKE_FOURCC('D','V','S','D'): case GST_MAKE_FOURCC('d','v','s','d'): - caps = GST_CAPS_NEW ( - "riff_video_dv", - "video/x-dv", - "systemstream", GST_PROPS_BOOLEAN (FALSE) - ); + caps = gst_caps_new_simple ("video/x-dv", + "systemstream", G_TYPE_BOOLEAN, FALSE, + NULL); break; case GST_MAKE_FOURCC('W','M','V','1'): - caps = GST_CAPS_NEW ( - "riff_video_wmv1", - "video/x-wmv", - "wmvversion", GST_PROPS_INT (1) - ); + caps = gst_caps_new_simple ("video/x-wmv", + "wmvversion", G_TYPE_INT, 1, + NULL); break; case GST_MAKE_FOURCC('W','M','V','2'): - caps = GST_CAPS_NEW ( - "riff_video_wmv2", - "video/x-wmv", - "wmvversion", GST_PROPS_INT (2) - ); + caps = gst_caps_new_simple ("video/x-wmv", + "wmvversion", G_TYPE_INT, 2, + NULL); break; default: GST_WARNING ("Unkown video fourcc " GST_FOURCC_FORMAT, GST_FOURCC_ARGS (codec_fcc)); - break; + return NULL; } - /* add general properties */ - if (caps != NULL) { - GstPropsEntry *framerate, *width, *height; - - if (strh != NULL) { - gfloat fps = 1. * strh->rate / strh->scale; - - framerate = gst_props_entry_new ("framerate", - GST_PROPS_FLOAT (fps)); - } else { - framerate = gst_props_entry_new ("framerate", - GST_PROPS_FLOAT_RANGE (0., G_MAXFLOAT)); - } - - if (strf != NULL) { - width = gst_props_entry_new ("width", - GST_PROPS_INT (strf->width)); - height = gst_props_entry_new ("height", - GST_PROPS_INT (strf->height)); - } else { - width = gst_props_entry_new ("width", - GST_PROPS_INT_RANGE (16, 4096)); - height = gst_props_entry_new ("height", - GST_PROPS_INT_RANGE (16, 4096)); - } - - if (!caps->properties) - caps->properties = gst_props_empty_new (); - - gst_props_add_entry (caps->properties, width); - gst_props_add_entry (caps->properties, height); - gst_props_add_entry (caps->properties, framerate); + if (strh != NULL) { + gfloat fps = 1. * strh->rate / strh->scale; + + gst_caps_set_simple (caps, "framerate", G_TYPE_DOUBLE, fps, NULL); + } else { + gst_caps_set_simple (caps, + "framerate", GST_TYPE_DOUBLE_RANGE, 0., G_MAXDOUBLE, + NULL); + } + + if (strf != NULL) { + gst_caps_set_simple (caps, + "width", G_TYPE_INT, strf->width, + "height", G_TYPE_INT, strf->height, + NULL); + } else { + gst_caps_set_simple (caps, + "width", GST_TYPE_INT_RANGE, 16, 4096, + "height", GST_TYPE_INT_RANGE, 16, 4096, + NULL); } return caps; @@ -225,57 +173,38 @@ gst_riff_create_audio_caps (guint16 codec_id, switch (codec_id) { case GST_RIFF_WAVE_FORMAT_MPEGL3: /* mp3 */ - caps = GST_CAPS_NEW ("riff_audio_mp1l3", - "audio/mpeg", - "mpegversion", GST_PROPS_INT (1), - "layer", GST_PROPS_INT (3)); + caps = gst_caps_new_simple ("audio/mpeg", + "mpegversion", G_TYPE_INT, 1, + "layer", G_TYPE_INT, 3, + NULL); break; case GST_RIFF_WAVE_FORMAT_MPEGL12: /* mp1 or mp2 */ - caps = GST_CAPS_NEW ("riff_audio_mp1l12", - "audio/mpeg", - "mpegversion", GST_PROPS_INT (1), - "layer", GST_PROPS_INT (2)); + caps = gst_caps_new_simple ("audio/mpeg", + "mpegversion", G_TYPE_INT, 1, + "layer", G_TYPE_INT, 2, + NULL); break; - case GST_RIFF_WAVE_FORMAT_PCM: /* PCM/wav */ { - GstPropsEntry *width = NULL, *depth = NULL, *signedness = NULL; - + case GST_RIFF_WAVE_FORMAT_PCM: /* PCM/wav */ if (strf != NULL) { gint ba = GUINT16_FROM_LE (strf->blockalign); gint ch = GUINT16_FROM_LE (strf->channels); gint ws = GUINT16_FROM_LE (strf->size); - width = gst_props_entry_new ("width", - GST_PROPS_INT (ba * 8 / ch)); - depth = gst_props_entry_new ("depth", - GST_PROPS_INT (ws)); - signedness = gst_props_entry_new ("signed", - GST_PROPS_BOOLEAN (ws != 8)); + caps = gst_caps_new_simple ("audio/x-raw-int", + "endianness", G_TYPE_INT, G_LITTLE_ENDIAN, + "width", G_TYPE_INT, (int)(ba * 8 / ch), + "depth", G_TYPE_INT, ws, + "signed", G_TYPE_BOOLEAN, ws != 8, + NULL); } else { - signedness = gst_props_entry_new ("signed", - GST_PROPS_LIST ( - GST_PROPS_BOOLEAN (TRUE), - GST_PROPS_BOOLEAN (FALSE))); - width = gst_props_entry_new ("width", - GST_PROPS_LIST ( - GST_PROPS_INT (8), - GST_PROPS_INT (16))); - depth = gst_props_entry_new ("depth", - GST_PROPS_LIST ( - GST_PROPS_INT (8), - GST_PROPS_INT (16))); + caps = gst_caps_from_string ("audio/x-raw-int, " + "endianness = (int) LITTLE_ENDIAN, " + "signed = (boolean) { true, false }, " + "width = (int) { 8, 16 }, " + "height = (int) { 8, 16 }"); } - - caps = GST_CAPS_NEW ("riff_audio_pcm", - "audio/x-raw-int", - "endianness", - GST_PROPS_INT (G_LITTLE_ENDIAN)); - gst_props_add_entry (caps->properties, width); - gst_props_add_entry (caps->properties, depth); - gst_props_add_entry (caps->properties, signedness); - - } break; case GST_RIFF_WAVE_FORMAT_MULAW: @@ -283,9 +212,7 @@ gst_riff_create_audio_caps (guint16 codec_id, GST_WARNING ("invalid depth (%d) of mulaw audio, overwriting.", strf->size); } - caps = GST_CAPS_NEW ("riff_audio_mulaw", - "audio/x-mulaw", - NULL); + caps = gst_caps_new_simple ("audio/x-mulaw", NULL); break; case GST_RIFF_WAVE_FORMAT_ALAW: @@ -293,9 +220,7 @@ gst_riff_create_audio_caps (guint16 codec_id, GST_WARNING ("invalid depth (%d) of alaw audio, overwriting.", strf->size); } - caps = GST_CAPS_NEW ("riff_audio_alaw", - "audio/x-alaw", - NULL); + caps = gst_caps_new_simple ("audio/x-alaw", NULL); break; case GST_RIFF_WAVE_FORMAT_VORBIS1: /* ogg/vorbis mode 1 */ @@ -304,15 +229,11 @@ gst_riff_create_audio_caps (guint16 codec_id, case GST_RIFF_WAVE_FORMAT_VORBIS1PLUS: /* ogg/vorbis mode 1+ */ case GST_RIFF_WAVE_FORMAT_VORBIS2PLUS: /* ogg/vorbis mode 2+ */ case GST_RIFF_WAVE_FORMAT_VORBIS3PLUS: /* ogg/vorbis mode 3+ */ - caps = GST_CAPS_NEW ("riff_audio_vorbis", - "audio/x-vorbis", - NULL); + caps = gst_caps_new_simple ("audio/x-vorbis", NULL); break; case GST_RIFF_WAVE_FORMAT_A52: - caps = GST_CAPS_NEW ("riff_audio_ac3", - "audio/x-ac3", - NULL); + caps = gst_caps_new_simple ("audio/x-ac3", NULL); break; default: @@ -321,26 +242,16 @@ gst_riff_create_audio_caps (guint16 codec_id, break; } - if (caps != NULL) { - GstPropsEntry *samplerate, *channels; - - if (strf != NULL) { - samplerate = gst_props_entry_new ("rate", - GST_PROPS_INT (strf->rate)); - channels = gst_props_entry_new ("channels", - GST_PROPS_INT (strf->channels)); - } else { - samplerate = gst_props_entry_new ("rate", - GST_PROPS_INT_RANGE (8000, 96000)); - channels = gst_props_entry_new ("channels", - GST_PROPS_INT_RANGE (1, 2)); - } - - if (!caps->properties) - caps->properties = gst_props_empty_new (); - - gst_props_add_entry (caps->properties, samplerate); - gst_props_add_entry (caps->properties, channels); + if (strf != NULL) { + gst_caps_set_simple (caps, + "rate", G_TYPE_INT, strf->rate, + "channels", G_TYPE_INT, strf->channels, + NULL); + } else { + gst_caps_set_simple (caps, + "rate", GST_TYPE_INT_RANGE, 8000, 96000, + "channels", GST_TYPE_INT_RANGE, 1, 2, + NULL); } return caps; @@ -357,14 +268,13 @@ gst_riff_create_iavs_caps (guint32 codec_fcc, /* is this correct? */ case GST_MAKE_FOURCC ('D','V','S','D'): case GST_MAKE_FOURCC ('d','v','s','d'): - caps = GST_CAPS_NEW ("riff_iavs_dv", - "video/x-dv", - "systemstream", GST_PROPS_BOOLEAN (TRUE)); + caps = gst_caps_new_simple ("video/x-dv", + "systemstream", G_TYPE_BOOLEAN, TRUE, NULL); default: GST_WARNING ("Unkown IAVS fourcc " GST_FOURCC_FORMAT, GST_FOURCC_ARGS (codec_fcc)); - break; + return NULL; } return caps; @@ -398,12 +308,13 @@ gst_riff_create_video_template_caps (void) 0 }; guint i; - GstCaps *caps = NULL, *one; + GstCaps *caps, *one; + caps = gst_caps_new_empty (); for (i = 0; tags[i] != 0; i++) { one = gst_riff_create_video_caps (tags[i], NULL, NULL); if (one) - caps = gst_caps_append (caps, one); + gst_caps_append (caps, one); } return caps; @@ -424,12 +335,13 @@ gst_riff_create_audio_template_caps (void) 0 }; guint i; - GstCaps *caps = NULL, *one; + GstCaps *caps, *one; + caps = gst_caps_new_empty (); for (i = 0; tags[i] != 0; i++) { one = gst_riff_create_audio_caps (tags[i], NULL, NULL); if (one) - caps = gst_caps_append (caps, one); + gst_caps_append (caps, one); } return caps; @@ -444,13 +356,15 @@ gst_riff_create_iavs_template_caps (void) 0 }; guint i; - GstCaps *caps = NULL, *one; + GstCaps *caps, *one; + caps = gst_caps_new_empty (); for (i = 0; tags[i] != 0; i++) { one = gst_riff_create_iavs_caps (tags[i], NULL, NULL); if (one) - caps = gst_caps_append (caps, one); + gst_caps_append (caps, one); } return caps; } + diff --git a/gst-libs/gst/riff/riff-read.c b/gst-libs/gst/riff/riff-read.c index c264cced..815b3a7b 100644 --- a/gst-libs/gst/riff/riff-read.c +++ b/gst-libs/gst/riff/riff-read.c @@ -714,7 +714,7 @@ gst_riff_read_info (GstRiffRead *riff) GstRiffLevel *level; GList *last; gchar *name, *type; - GstProps *props; + GstCaps *caps; /* What we're doing here is ugly (oh no!); we look * at our LIST tag size and assure that we do not @@ -726,11 +726,10 @@ gst_riff_read_info (GstRiffRead *riff) end = level->start + level->length; g_free (level); - props = gst_props_empty_new (); + caps = gst_caps_new_simple ("application/x-gst-metadata", NULL); while (gst_bytestream_tell (riff->bs) < end) { if (!gst_riff_peek_head (riff, &tag, NULL, NULL)) { - gst_props_unref (props); return FALSE; } @@ -813,26 +812,18 @@ gst_riff_read_info (GstRiffRead *riff) } if (type) { - GstPropsEntry *entry; - if (!gst_riff_read_ascii (riff, &tag, &name)) { - gst_props_unref (props); return FALSE; } - entry = gst_props_entry_new (type, GST_PROPS_STRING (name)); - gst_props_add_entry (props, entry); + gst_caps_set_simple (caps, type, G_TYPE_STRING, name, NULL); } else { gst_riff_read_skip (riff); } } /* let the world know about this wonderful thing */ - gst_props_debug (props); - gst_caps_replace_sink (&riff->metadata, - gst_caps_new ("riff_metadata", - "application/x-gst-metadata", - props)); + gst_caps_replace (&riff->metadata, caps); g_object_notify (G_OBJECT (riff), "metadata"); return TRUE; diff --git a/gst-libs/gst/video/video.c b/gst-libs/gst/video/video.c index 706acc3b..6d804a4d 100644 --- a/gst-libs/gst/video/video.c +++ b/gst-libs/gst/video/video.c @@ -26,11 +26,12 @@ /* This is simply a convenience function, nothing more or less */ -gfloat +gdouble gst_video_frame_rate (GstPad *pad) { - gfloat fps = 0.; + gdouble fps = 0.; GstCaps *caps; + GstStructure *structure; /* get pad caps */ caps = GST_PAD_CAPS (pad); @@ -41,16 +42,14 @@ gst_video_frame_rate (GstPad *pad) return 0.; } - if (!gst_caps_has_property_typed (caps, "framerate", - GST_PROPS_FLOAT_TYPE)) { + structure = gst_caps_get_structure (caps, 0); + if (!gst_structure_get_double (structure, "framerate", &fps)){ g_warning ("gstvideo: failed to get framerate property of pad %s:%s", GST_ELEMENT_NAME (gst_pad_get_parent (pad)), GST_PAD_NAME (pad)); return 0.; } - gst_caps_get_float (caps, "framerate", &fps); - GST_DEBUG ("Framerate request on pad %s:%s: %f", GST_ELEMENT_NAME (gst_pad_get_parent (pad)), GST_PAD_NAME(pad), fps); @@ -64,8 +63,12 @@ gst_video_get_size (GstPad *pad, gint *height) { GstCaps *caps; + GstStructure *structure; + gboolean ret; g_return_val_if_fail (pad != NULL, FALSE); + g_return_val_if_fail (width != NULL, FALSE); + g_return_val_if_fail (height != NULL, FALSE); caps = GST_PAD_CAPS (pad); @@ -76,21 +79,17 @@ gst_video_get_size (GstPad *pad, return FALSE; } - if (!gst_caps_has_property_typed (caps, "width", - GST_PROPS_INT_TYPE) || - !gst_caps_has_property_typed (caps, "height", - GST_PROPS_FLOAT_TYPE)) { + structure = gst_caps_get_structure (caps, 0); + ret = gst_structure_get_int (structure, "width", width); + ret &= gst_structure_get_int (structure, "height", height); + + if (!ret) { g_warning ("gstvideo: failed to get size properties on pad %s:%s", GST_ELEMENT_NAME (gst_pad_get_parent (pad)), GST_PAD_NAME(pad)); return FALSE; } - if (width) - gst_caps_get_int (caps, "width", width); - if (height) - gst_caps_get_int (caps, "height", height); - GST_DEBUG ("size request on pad %s:%s: %dx%d", GST_ELEMENT_NAME (gst_pad_get_parent (pad)), GST_PAD_NAME (pad), diff --git a/gst-libs/gst/video/video.h b/gst-libs/gst/video/video.h index 3ce2a2e9..7f5a1fdf 100644 --- a/gst-libs/gst/video/video.h +++ b/gst-libs/gst/video/video.h @@ -23,203 +23,175 @@ #include <gst/gst.h> -#define R_MASK_32 0xff000000 -#define G_MASK_32 0x00ff0000 -#define B_MASK_32 0x0000ff00 +#define R_MASK_32 "0xff000000" +#define G_MASK_32 "0x00ff0000" +#define B_MASK_32 "0x0000ff00" -#define R_MASK_32_REVERSE 0x000000ff -#define G_MASK_32_REVERSE 0x0000ff00 -#define B_MASK_32_REVERSE 0x00ff0000 +#define R_MASK_32_REVERSE "0x000000ff" +#define G_MASK_32_REVERSE "0x0000ff00" +#define B_MASK_32_REVERSE "0x00ff0000" -#define R_MASK_24 0xff0000 -#define G_MASK_24 0x00ff00 -#define B_MASK_24 0x0000ff +#define R_MASK_24 "0xff0000" +#define G_MASK_24 "0x00ff00" +#define B_MASK_24 "0x0000ff" -#define R_MASK_24_REVERSE 0x0000ff -#define G_MASK_24_REVERSE 0x00ff00 -#define B_MASK_24_REVERSE 0xff0000 +#define R_MASK_24_REVERSE "0x0000ff" +#define G_MASK_24_REVERSE "0x00ff00" +#define B_MASK_24_REVERSE "0xff0000" -#define R_MASK_16 0xf800 -#define G_MASK_16 0x07e0 -#define B_MASK_16 0x001f +#define R_MASK_16 "0xf800" +#define G_MASK_16 "0x07e0" +#define B_MASK_16 "0x001f" -#define R_MASK_15 0x8c00 -#define G_MASK_15 0x03e0 -#define B_MASK_15 0x001f +#define R_MASK_15 "0x7c00" +#define G_MASK_15 "0x03e0" +#define B_MASK_15 "0x001f" -#define SIZE_RANGE GST_PROPS_INT_RANGE (16, 4096) -#define FPS_RANGE GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT) +#define R_MASK_32_INT 0xff000000 +#define G_MASK_32_INT 0x00ff0000 +#define B_MASK_32_INT 0x0000ff00 + +#define R_MASK_32_REVERSE_INT 0x000000ff +#define G_MASK_32_REVERSE_INT 0x0000ff00 +#define B_MASK_32_REVERSE_INT 0x00ff0000 + +#define R_MASK_24_INT 0xff0000 +#define G_MASK_24_INT 0x00ff00 +#define B_MASK_24_INT 0x0000ff + +#define R_MASK_24_REVERSE_INT 0x0000ff +#define G_MASK_24_REVERSE_INT 0x00ff00 +#define B_MASK_24_REVERSE_INT 0xff0000 + +#define R_MASK_16_INT 0xf800 +#define G_MASK_16_INT 0x07e0 +#define B_MASK_16_INT 0x001f + +#define R_MASK_15_INT 0x7c00 +#define G_MASK_15_INT 0x03e0 +#define B_MASK_15_INT 0x001f + +#define SIZE_RANGE "(int) [ 16, 4096 ]" +#define FPS_RANGE "(double) [ 0, max ]" /* properties for pad templates */ -#define GST_VIDEO_RGB_PAD_TEMPLATE_PROPS_24_32 \ - gst_props_new ( \ - "bpp", GST_PROPS_LIST ( \ - GST_PROPS_INT (24), \ - GST_PROPS_INT (32) \ - ), \ - "depth", GST_PROPS_LIST ( \ - GST_PROPS_INT (24), \ - GST_PROPS_INT (32) \ - ), \ - "endianness", GST_PROPS_INT (G_BIG_ENDIAN), \ - "red_mask", GST_PROPS_LIST ( \ - GST_PROPS_INT (R_MASK_32), \ - GST_PROPS_INT (R_MASK_24) \ - ), \ - "green_mask", GST_PROPS_LIST ( \ - GST_PROPS_INT (G_MASK_32), \ - GST_PROPS_INT (G_MASK_24) \ - ), \ - "blue_mask", GST_PROPS_LIST ( \ - GST_PROPS_INT (B_MASK_32), \ - GST_PROPS_INT (B_MASK_24) \ - ), \ - "width", SIZE_RANGE, \ - "height", SIZE_RANGE, \ - "framerate", FPS_RANGE, \ - NULL) - -#define GST_VIDEO_RGB_PAD_TEMPLATE_PROPS_24_32_REVERSE \ - gst_props_new ( \ - "bpp", GST_PROPS_LIST ( \ - GST_PROPS_INT (24), \ - GST_PROPS_INT (32) \ - ), \ - "depth", GST_PROPS_LIST ( \ - GST_PROPS_INT (24), \ - GST_PROPS_INT (32) \ - ), \ - "endianness", GST_PROPS_INT (G_BIG_ENDIAN), \ - "red_mask", GST_PROPS_LIST ( \ - GST_PROPS_INT (R_MASK_32_REVERSE), \ - GST_PROPS_INT (R_MASK_24_REVERSE) \ - ), \ - "green_mask", GST_PROPS_LIST ( \ - GST_PROPS_INT (G_MASK_32_REVERSE), \ - GST_PROPS_INT (G_MASK_24_REVERSE) \ - ), \ - "blue_mask", GST_PROPS_LIST ( \ - GST_PROPS_INT (B_MASK_32_REVERSE), \ - GST_PROPS_INT (B_MASK_24_REVERSE) \ - ), \ - "width", SIZE_RANGE, \ - "height", SIZE_RANGE, \ - "framerate", FPS_RANGE, \ - NULL) - -#define GST_VIDEO_RGB_PAD_TEMPLATE_PROPS_32 \ - gst_props_new ( \ - "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", SIZE_RANGE, \ - "height", SIZE_RANGE, \ - "framerate", FPS_RANGE, \ - NULL) - -#define GST_VIDEO_RGB_PAD_TEMPLATE_PROPS_24 \ - gst_props_new ( \ - "bpp", GST_PROPS_INT (24), \ - "depth", GST_PROPS_INT (24), \ - "endianness", GST_PROPS_INT (G_BIG_ENDIAN), \ - "red_mask", GST_PROPS_INT (R_MASK_24), \ - "green_mask", GST_PROPS_INT (G_MASK_24), \ - "blue_mask", GST_PROPS_INT (B_MASK_24), \ - "width", SIZE_RANGE, \ - "height", SIZE_RANGE, \ - "framerate", FPS_RANGE, \ - NULL) - -#define GST_VIDEO_RGB_PAD_TEMPLATE_PROPS_32_REVERSE \ - gst_props_new ( \ - "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_REVERSE), \ - "green_mask", GST_PROPS_INT (G_MASK_32_REVERSE), \ - "blue_mask", GST_PROPS_INT (B_MASK_32_REVERSE), \ - "width", SIZE_RANGE, \ - "height", SIZE_RANGE, \ - "framerate", FPS_RANGE, \ - NULL) - -#define GST_VIDEO_RGB_PAD_TEMPLATE_PROPS_24_REVERSE \ - gst_props_new ( \ - "bpp", GST_PROPS_INT (24), \ - "depth", GST_PROPS_INT (24), \ - "endianness", GST_PROPS_INT (G_BIG_ENDIAN), \ - "red_mask", GST_PROPS_INT (R_MASK_24_REVERSE), \ - "green_mask", GST_PROPS_INT (G_MASK_24_REVERSE), \ - "blue_mask", GST_PROPS_INT (B_MASK_24_REVERSE), \ - "width", SIZE_RANGE, \ - "height", SIZE_RANGE, \ - "framerate", FPS_RANGE, \ - NULL) - -#define GST_VIDEO_RGB_PAD_TEMPLATE_PROPS_15_16 \ - gst_props_new ( \ - "bpp", GST_PROPS_INT (16), \ - "depth", GST_PROPS_LIST ( \ - GST_PROPS_INT (15), \ - GST_PROPS_INT (16) \ - ), \ - "endianness", GST_PROPS_INT (G_BYTE_ORDER), \ - "red_mask", GST_PROPS_LIST ( \ - GST_PROPS_INT (R_MASK_15), \ - GST_PROPS_INT (R_MASK_16) \ - ), \ - "green_mask", GST_PROPS_LIST ( \ - GST_PROPS_INT (G_MASK_15), \ - GST_PROPS_INT (G_MASK_16) \ - ), \ - "blue_mask", GST_PROPS_LIST ( \ - GST_PROPS_INT (B_MASK_15), \ - GST_PROPS_INT (B_MASK_16) \ - ), \ - "width", SIZE_RANGE, \ - "height", SIZE_RANGE, \ - "framerate", FPS_RANGE, \ - NULL) - -#define GST_VIDEO_RGB_PAD_TEMPLATE_PROPS_16 \ - gst_props_new ( \ - "bpp", GST_PROPS_INT (16), \ - "depth", GST_PROPS_INT (16), \ - "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", SIZE_RANGE, \ - "height", SIZE_RANGE, \ - "framerate", FPS_RANGE, \ - NULL) - -#define GST_VIDEO_RGB_PAD_TEMPLATE_PROPS_15 \ - gst_props_new ( \ - "bpp", GST_PROPS_INT (15), \ - "depth", GST_PROPS_INT (15), \ - "endianness", GST_PROPS_INT (G_BYTE_ORDER), \ - "red_mask", GST_PROPS_INT (R_MASK_15), \ - "green_mask", GST_PROPS_INT (G_MASK_15), \ - "blue_mask", GST_PROPS_INT (B_MASK_15), \ - "width", SIZE_RANGE, \ - "height", SIZE_RANGE, \ - "framerate", FPS_RANGE, \ - NULL) - -#define GST_VIDEO_YUV_PAD_TEMPLATE_PROPS(fourcc) \ - gst_props_new (\ - "format", fourcc, \ - "width", SIZE_RANGE, \ - "height", SIZE_RANGE, \ - "framerate", FPS_RANGE, \ - NULL) +#define GST_VIDEO_RGB_PAD_TEMPLATE_CAPS_24_32 \ + "video/x-raw-rgb, " \ + "bpp = (int) { 24, 32 }, " \ + "depth = (int) { 24, 32 }, " \ + "endianness = (int) BIG_ENDIAN, " \ + "red_mask = (int) { " R_MASK_32 ", " R_MASK_24 " }, " \ + "green_mask = (int) { " G_MASK_32 ", " G_MASK_24 " }, " \ + "blue_mask = (int) { " B_MASK_32 ", " B_MASK_24 " }, " \ + "width = " SIZE_RANGE ", " \ + "height = " SIZE_RANGE ", " \ + "framerate = " FPS_RANGE + +#define GST_VIDEO_RGB_PAD_TEMPLATE_CAPS_24_32_REVERSE \ + "video/x-raw-rgb, " \ + "bpp = (int) { 24, 32 }, " \ + "depth = (int) { 24, 32 }, " \ + "endianness = (int) BIG_ENDIAN, " \ + "red_mask = (int) { " R_MASK_32_REVERSE ", " R_MASK_24_REVERSE "}, " \ + "green_mask = (int) { " G_MASK_32_REVERSE ", " G_MASK_24_REVERSE "}, " \ + "blue_mask = (int) { " B_MASK_32_REVERSE ", " B_MASK_24_REVERSE "}, " \ + "width = " SIZE_RANGE ", " \ + "height = " SIZE_RANGE ", " \ + "framerate = " FPS_RANGE + +#define GST_VIDEO_RGB_PAD_TEMPLATE_CAPS_32 \ + "video/x-raw-rgb, " \ + "bpp = (int) 32, " \ + "depth = (int) 32, " \ + "endianness = (int) BIG_ENDIAN, " \ + "red_mask = (int) " R_MASK_32 ", " \ + "green_mask = (int) " G_MASK_32 ", " \ + "blue_mask = (int) " B_MASK_32 ", " \ + "width = " SIZE_RANGE ", " \ + "height = " SIZE_RANGE ", " \ + "framerate = " FPS_RANGE + +#define GST_VIDEO_RGB_PAD_TEMPLATE_CAPS_24 \ + "video/x-raw-rgb, " \ + "bpp = (int) 24, " \ + "depth = (int) 24, " \ + "endianness = (int) BIG_ENDIAN, " \ + "red_mask = (int) " R_MASK_24 ", " \ + "green_mask = (int) " G_MASK_24 ", " \ + "blue_mask = (int) " B_MASK_24 ", " \ + "width = " SIZE_RANGE ", " \ + "height = " SIZE_RANGE ", " \ + "framerate = " FPS_RANGE + +#define GST_VIDEO_RGB_PAD_TEMPLATE_CAPS_32_REVERSE \ + "video/x-raw-rgb, " \ + "bpp = (int) 32, " \ + "depth = (int) 32, " \ + "endianness = (int) BIG_ENDIAN, " \ + "red_mask = (int) " R_MASK_32_REVERSE ", " \ + "green_mask = (int) " G_MASK_32_REVERSE ", " \ + "blue_mask = (int) " B_MASK_32_REVERSE ", " \ + "width = " SIZE_RANGE ", " \ + "height = " SIZE_RANGE ", " \ + "framerate = " FPS_RANGE + +#define GST_VIDEO_RGB_PAD_TEMPLATE_CAPS_24_REVERSE \ + "video/x-raw-rgb, " \ + "bpp = (int) 24, " \ + "depth = (int) 24, " \ + "endianness = (int) BIG_ENDIAN, " \ + "red_mask = (int) " R_MASK_24_REVERSE ", " \ + "green_mask = (int) " G_MASK_24_REVERSE ", " \ + "blue_mask = (int) " B_MASK_24_REVERSE ", " \ + "width = " SIZE_RANGE ", " \ + "height = " SIZE_RANGE ", " \ + "framerate = " FPS_RANGE + +#define GST_VIDEO_RGB_PAD_TEMPLATE_CAPS_15_16 \ + "video/x-raw-rgb, " \ + "bpp = (int) 16, " \ + "depth = (int) { 15, 16 }, " \ + "endianness = (int) BYTE_ORDER, " \ + "red_mask = (int) { " R_MASK_15 ", " R_MASK_16 " }, " \ + "green_mask = (int) { " G_MASK_15 ", " G_MASK_16 " }, " \ + "blue_mask = (int) { " B_MASK_15 ", " B_MASK_16 " }, " \ + "width = " SIZE_RANGE ", " \ + "height = " SIZE_RANGE ", " \ + "framerate = " FPS_RANGE + +#define GST_VIDEO_RGB_PAD_TEMPLATE_CAPS_16 \ + "video/x-raw-rgb, " \ + "bpp = (int) 16, " \ + "depth = (int) 16, " \ + "endianness = (int) BYTE_ORDER, " \ + "red_mask = (int) " R_MASK_16 ", " \ + "green_mask = (int) " G_MASK_16 ", " \ + "blue_mask = (int) " B_MASK_16 ", " \ + "width = " SIZE_RANGE ", " \ + "height = " SIZE_RANGE ", " \ + "framerate = " FPS_RANGE + +#define GST_VIDEO_RGB_PAD_TEMPLATE_CAPS_15 \ + "video/x-raw-rgb, " \ + "bpp = (int) 16, " \ + "depth = (int) 15, " \ + "endianness = (int) BYTE_ORDER, " \ + "red_mask = (int) " R_MASK_15 ", " \ + "green_mask = (int) " G_MASK_15 ", " \ + "blue_mask = (int) " B_MASK_15 ", " \ + "width = " SIZE_RANGE ", " \ + "height = " SIZE_RANGE ", " \ + "framerate = " FPS_RANGE + +#define GST_VIDEO_YUV_PAD_TEMPLATE_CAPS(fourcc) \ + "video/x-raw-yuv, " \ + "format = (fourcc) " fourcc ", " \ + "width = " SIZE_RANGE ", " \ + "height = " SIZE_RANGE ", " \ + "framerate = " FPS_RANGE /* functions */ -gfloat gst_video_frame_rate (GstPad *pad); +gdouble gst_video_frame_rate (GstPad *pad); gboolean gst_video_get_size (GstPad *pad, gint *width, gint *height); 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; diff --git a/sys/glsink/gstglsink.c b/sys/glsink/gstglsink.c index 15e8926e..3e1e56ce 100644 --- a/sys/glsink/gstglsink.c +++ b/sys/glsink/gstglsink.c @@ -107,8 +107,6 @@ struct _GstGLSink { GstClock *clock; - /* bufferpool stuff */ - GstBufferPool *bufferpool; GMutex *cache_lock; GList *cache; @@ -139,7 +137,6 @@ static void gst_glsink_set_clock (GstElement *element, GstClock *clock); static GstElementStateReturn gst_glsink_change_state (GstElement *element); static GstPadLinkReturn gst_glsink_sinkconnect (GstPad *pad, GstCaps *caps); static GstCaps * gst_glsink_getcaps (GstPad *pad, GstCaps *caps); -static GstBufferPool* gst_glsink_get_bufferpool (GstPad *pad); static void gst_glsink_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); @@ -149,13 +146,6 @@ static void gst_glsink_get_property (GObject *object, guint prop_id, static void gst_glsink_release_conn (GstGLSink *sink); static void gst_glsink_append_cache (GstGLSink *sink, GstImageData *image); static gboolean gst_glsink_set_caps (GstGLSink *sink, GstCaps *caps); -/* bufferpool stuff */ -static GstBuffer* gst_glsink_buffer_new (GstBufferPool *pool, - gint64 location, - guint size, gpointer user_data); -static void gst_glsink_buffer_free (GstBufferPool *pool, - GstBuffer *buffer, - gpointer user_data); /* prototypes from plugins */ extern GstImagePlugin* get_gl_rgbimage_plugin (void); @@ -278,13 +268,6 @@ gst_glsink_init (GstGLSink *sink) /* create bufferpool and image cache */ GST_DEBUG ("glsink: creating bufferpool"); - sink->bufferpool = gst_buffer_pool_new ( - NULL, - NULL, - (GstBufferPoolBufferNewFunction)gst_glsink_buffer_new, - NULL, - (GstBufferPoolBufferFreeFunction)gst_glsink_buffer_free, - sink); sink->cache_lock = g_mutex_new(); sink->cache = NULL; @@ -332,6 +315,7 @@ gst_glsink_append_cache (GstGLSink *sink, GstImageData *image) g_mutex_unlock (sink->cache_lock); } +#if 0 /* Create a new buffer to hand up the chain. This allows the plugins to make its own decoding buffers @@ -380,14 +364,7 @@ gst_glsink_buffer_free (GstBufferPool *pool, GstBuffer *buffer, gpointer user_da gst_buffer_default_free (buffer); } - -static GstBufferPool* -gst_glsink_get_bufferpool (GstPad *pad) -{ - GstGLSink *sink = GST_GLSINK (gst_pad_get_parent (pad)); - - return sink->bufferpool; -} +#endif /* Set the caps that the application desires. diff --git a/sys/qcam/gstqcamsrc.c b/sys/qcam/gstqcamsrc.c index 2cfc323f..1312bb43 100644 --- a/sys/qcam/gstqcamsrc.c +++ b/sys/qcam/gstqcamsrc.c @@ -55,17 +55,13 @@ static GstElementDetails gst_qcamsrc_details = GST_ELEMENT_DETAILS ( #define DEF_PORT 0x378 #define DEF_AUTOEXP AE_NONE -GST_PAD_TEMPLATE_FACTORY (gst_qcamsrc_src_factory, +static GstStaticPadTemplate gst_qcamsrc_src_factory = +GST_STATIC_PAD_TEMPLATE ( "src", GST_PAD_SRC, GST_PAD_ALWAYS, - gst_caps_new ( - "gstqcam_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")) +); #define GST_TYPE_AUTOEXP_MODE (gst_autoexp_mode_get_type()) static GType @@ -151,7 +147,7 @@ gst_qcamsrc_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 (gst_qcamsrc_src_factory)); + gst_element_class_add_pad_template (element_class, gst_static_pad_template_get (&gst_qcamsrc_src_factory)); gst_element_class_set_details (element_class, &gst_qcamsrc_details); } static void @@ -209,7 +205,7 @@ static void gst_qcamsrc_init (GstQCamSrc *qcamsrc) { qcamsrc->srcpad = gst_pad_new_from_template ( - GST_PAD_TEMPLATE_GET (gst_qcamsrc_src_factory), "src"); + gst_static_pad_template_get (&gst_qcamsrc_src_factory), "src"); gst_element_add_pad(GST_ELEMENT(qcamsrc),qcamsrc->srcpad); gst_pad_set_get_function (qcamsrc->srcpad,gst_qcamsrc_get); @@ -253,14 +249,11 @@ gst_qcamsrc_get (GstPad *pad) qc_set (qcamsrc->qcam); if (!GST_PAD_CAPS (pad)) { - gst_pad_try_set_caps (pad, GST_CAPS_NEW ( - "qcam_caps", - "video/x-raw-yuv", - "format", GST_PROPS_FOURCC (GST_STR_FOURCC ("I420")), - "width", GST_PROPS_INT (qcamsrc->qcam->width / scale), - "height", GST_PROPS_INT (qcamsrc->qcam->height / scale), - "framerate", GST_PROPS_FLOAT (10.) /* bla? */ - )); + gst_pad_try_set_caps (pad, gst_caps_new_simple("video/x-raw-yuv", + "format", GST_TYPE_FOURCC, "I420", + "width", G_TYPE_INT, qcamsrc->qcam->width / scale, + "height", G_TYPE_INT, qcamsrc->qcam->height / scale, + "framerate", G_TYPE_DOUBLE, 10., NULL)); } scan = qc_scan (qcamsrc->qcam); diff --git a/sys/v4l2/gstv4l2src.c b/sys/v4l2/gstv4l2src.c index cd98162f..b6e86b0a 100644 --- a/sys/v4l2/gstv4l2src.c +++ b/sys/v4l2/gstv4l2src.c @@ -62,29 +62,25 @@ static void gst_v4l2src_base_init (GstV4l2SrcClass *klass); static void gst_v4l2src_init (GstV4l2Src *v4l2src); /* signal functions */ -static void gst_v4l2src_open (GstElement *element, - const gchar *device); -static void gst_v4l2src_close (GstElement *element, - const gchar *device); - -/* pad/info functions */ -static gboolean gst_v4l2src_src_convert (GstPad *pad, - GstFormat src_format, - gint64 src_value, - GstFormat *dest_format, - gint64 *dest_value); -static gboolean gst_v4l2src_src_query (GstPad *pad, - GstQueryType type, - GstFormat *format, - gint64 *value); - -/* buffer functions */ -static GstPadLinkReturn - gst_v4l2src_srcconnect (GstPad *pad, - GstCaps *caps); -static GstCaps *gst_v4l2src_getcaps (GstPad *pad, - GstCaps *caps); -static GstData *gst_v4l2src_get (GstPad *pad); +static void gst_v4l2src_open (GstElement *element, + const gchar *device); +static void gst_v4l2src_close (GstElement *element, + const gchar *device); + +/* pad/buffer functions */ +static GstPadLinkReturn gst_v4l2src_srcconnect (GstPad *pad, + const GstCaps *caps); +static GstCaps * gst_v4l2src_getcaps (GstPad *pad); +static GstData * gst_v4l2src_get (GstPad *pad); +static gboolean gst_v4l2src_src_convert (GstPad *pad, + GstFormat src_format, + gint64 src_value, + GstFormat *dest_format, + gint64 *dest_value); +static gboolean gst_v4l2src_src_query (GstPad *pad, + GstQueryType type, + GstFormat *format, + gint64 *value); /* get/set params */ static void gst_v4l2src_set_property (GObject *object, @@ -104,16 +100,6 @@ static GstElementStateReturn static void gst_v4l2src_set_clock (GstElement *element, GstClock *clock); -/* bufferpool functions */ -static GstBuffer *gst_v4l2src_buffer_new (GstBufferPool *pool, - guint64 offset, - guint size, - gpointer user_data); -static void gst_v4l2src_buffer_free (GstBufferPool *pool, - GstBuffer *buf, - gpointer user_data); - - static GstPadTemplate *src_template; static GstElementClass *parent_class = NULL; @@ -240,12 +226,6 @@ gst_v4l2src_init (GstV4l2Src *v4l2src) gst_pad_set_query_type_function (v4l2src->srcpad, gst_v4l2src_get_query_types); - v4l2src->bufferpool = gst_buffer_pool_new(NULL, NULL, - gst_v4l2src_buffer_new, - NULL, - gst_v4l2src_buffer_free, - v4l2src); - v4l2src->breq.count = 0; v4l2src->formats = NULL; @@ -386,21 +366,16 @@ gst_v4l2src_src_query (GstPad *pad, } -static GstCaps * +static GstStructure * gst_v4l2src_v4l2fourcc_to_caps (guint32 fourcc, - GstPropsEntry *width, - GstPropsEntry *height, - GstPropsEntry *fps, gboolean compressed) { - GstCaps *caps = NULL; + GstStructure *structure; switch (fourcc) { case V4L2_PIX_FMT_MJPEG: /* Motion-JPEG */ case V4L2_PIX_FMT_JPEG: /* JFIF JPEG */ - caps = GST_CAPS_NEW("v4l2src_caps", - "video/x-jpeg", - NULL); + structure = gst_structure_new ("video/x-jpeg", NULL); break; case V4L2_PIX_FMT_RGB332: case V4L2_PIX_FMT_RGB555: @@ -488,15 +463,14 @@ gst_v4l2src_v4l2fourcc_to_caps (guint32 fourcc, break; } - caps = GST_CAPS_NEW("v4l2src_caps", - "video/x-raw-rgb", - "bpp", GST_PROPS_INT(bpp), - "depth", GST_PROPS_INT(depth), - "red_mask", GST_PROPS_INT(r_mask), - "green_mask", GST_PROPS_INT(g_mask), - "blue_mask", GST_PROPS_INT(b_mask), - "endianness", GST_PROPS_INT(endianness), - NULL); + structure = gst_structure_new ("video/x-raw-rgb", + "bpp", G_TYPE_INT, bpp, + "depth", G_TYPE_INT, depth, + "red_mask", G_TYPE_INT, r_mask, + "green_mask", G_TYPE_INT, g_mask, + "blue_mask", G_TYPE_INT, b_mask, + "endianness", G_TYPE_INT, endianness, + NULL); break; } case V4L2_PIX_FMT_YUV420: /* I420/IYUV */ @@ -527,10 +501,9 @@ gst_v4l2src_v4l2fourcc_to_caps (guint32 fourcc, break; } - caps = GST_CAPS_NEW("v4l2src_caps", - "video/x-raw-yuv", - "format", GST_PROPS_FOURCC(fcc), - NULL); + structure = gst_structure_new ("video/x-raw-yuv", + "format", GST_TYPE_FOURCC, fcc, + NULL); break; } default: @@ -550,26 +523,24 @@ gst_v4l2src_v4l2fourcc_to_caps (guint32 fourcc, } string_format = g_strdup_printf("video/%4.4s", print_format_str); - caps = GST_CAPS_NEW("v4l2src_caps", - string_format, - NULL); + structure = gst_structure_new (string_format, NULL); g_free(string_format); } else { - caps = GST_CAPS_NEW("v4l2src_caps", - "video/x-raw-yuv", - "format",GST_PROPS_FOURCC(fourcc), - NULL); + structure = gst_structure_new ("video/x-raw-yuv", + "format", GST_TYPE_FOURCC, fourcc, NULL); } break; } - if (!caps->properties) - caps->properties = gst_props_empty_new(); - gst_props_add_entry(caps->properties, width); - gst_props_add_entry(caps->properties, height); - gst_props_add_entry(caps->properties, fps); +#if 0 + gst_caps_set_simple (caps, + "width", G_TYPE_INT, width, + "height", G_TYPE_INT, height, + "framerate", G_TYPE_DOUBLE, fps, + NULL); +#endif - return caps; + return structure; } #define gst_v4l2src_v4l2fourcc_to_caps_fixed(f, width, height, fps, c) \ @@ -594,19 +565,19 @@ gst_v4l2src_v4l2fourcc_to_caps (guint32 fourcc, static struct v4l2_fmtdesc * gst_v4l2_caps_to_v4l2fourcc (GstV4l2Src *v4l2src, - GstCaps *caps) + GstStructure *structure) { gint i; guint32 fourcc = 0; struct v4l2_fmtdesc *end_fmt = NULL; - const gchar *format = gst_caps_get_mime(caps); + const gchar *format = gst_structure_get_name (structure); if (!strcmp(format, "video/x-raw-yuv") || !strcmp(format, "video/x-raw-rgb")) { if (!strcmp(format, "video/x-raw-rgb")) fourcc = GST_MAKE_FOURCC('R','G','B',' '); else - gst_caps_get_fourcc_int(caps, "format", &fourcc); + gst_structure_get_fourcc (structure, "format", &fourcc); switch (fourcc) { case GST_MAKE_FOURCC('I','4','2','0'): @@ -628,8 +599,8 @@ gst_v4l2_caps_to_v4l2fourcc (GstV4l2Src *v4l2src, case GST_MAKE_FOURCC('R','G','B',' '): { gint depth, endianness; - gst_caps_get_int(caps, "depth", &depth); - gst_caps_get_int(caps, "endianness", &endianness); + gst_structure_get_int (structure, "depth", &depth); + gst_structure_get_int (structure, "endianness", &endianness); switch (depth) { case 8: @@ -721,17 +692,19 @@ gst_v4l2_caps_to_v4l2fourcc (GstV4l2Src *v4l2src, static GstPadLinkReturn gst_v4l2src_srcconnect (GstPad *pad, - GstCaps *vscapslist) + const GstCaps *vscapslist) { GstV4l2Src *v4l2src; GstV4l2Element *v4l2element; - GstCaps *caps; struct v4l2_fmtdesc *format; int w, h; + GstStructure *structure; v4l2src = GST_V4L2SRC(gst_pad_get_parent (pad)); v4l2element = GST_V4L2ELEMENT(v4l2src); + structure = gst_caps_get_structure (vscapslist, 0); + /* clean up if we still haven't cleaned up our previous * capture session */ if (GST_V4L2_IS_ACTIVE(v4l2element)) { @@ -741,52 +714,18 @@ gst_v4l2src_srcconnect (GstPad *pad, return GST_PAD_LINK_DELAYED; } - for (caps = vscapslist; caps != NULL; caps = caps->next) { - /* we want our own v4l2 type of fourcc codes */ - if (!(format = gst_v4l2_caps_to_v4l2fourcc(v4l2src, caps))) { - continue; - } - if (gst_caps_has_property(caps, "width")) { - if (gst_caps_has_fixed_property(caps, "width")) { - gst_caps_get_int(caps, "width", &w); - } else { - int max; - gst_caps_get_int_range(caps, "width", &max, &w); - } - } - if (gst_caps_has_property(caps, "height")) { - if (gst_caps_has_fixed_property(caps, "height")) { - gst_caps_get_int(caps, "height", &h); - } else { - int max; - gst_caps_get_int_range(caps, "height", &max, &h); - } - } + /* we want our own v4l2 type of fourcc codes */ + if (!(format = gst_v4l2_caps_to_v4l2fourcc(v4l2src, structure))) { + return GST_PAD_LINK_REFUSED; + } - /* we found the pixelformat! - try it out */ - if (gst_v4l2src_set_capture(v4l2src, format, w, h)) { - /* it fits! Now, get the proper counterpart and retry - * it on the other side (again...) - if it works, we're - * done -> GST_PAD_LINK_OK */ - GstCaps *lastcaps; - GstPadLinkReturn ret_val; - - lastcaps = gst_v4l2src_v4l2fourcc_to_caps_fixed(format->pixelformat, - v4l2src->format.fmt.pix.width, - v4l2src->format.fmt.pix.height, - gst_v4l2src_get_fps(v4l2src), - format->flags & V4L2_FMT_FLAG_COMPRESSED); - - ret_val = gst_pad_try_set_caps(v4l2src->srcpad, - lastcaps); - - if (ret_val > 0) { - if (gst_v4l2src_capture_init(v4l2src)) { - return GST_PAD_LINK_DONE; - } - } else if (ret_val == GST_PAD_LINK_DELAYED) { - return GST_PAD_LINK_DELAYED; - } + gst_structure_get_int (structure, "width", &w); + gst_structure_get_int (structure, "height", &h); + + /* we found the pixelformat! - try it out */ + if (gst_v4l2src_set_capture(v4l2src, format, w, h)) { + if (gst_v4l2src_capture_init(v4l2src)) { + return GST_PAD_LINK_OK; } } @@ -795,11 +734,10 @@ gst_v4l2src_srcconnect (GstPad *pad, static GstCaps * -gst_v4l2src_getcaps (GstPad *pad, - GstCaps *caps) +gst_v4l2src_getcaps (GstPad *pad) { GstV4l2Src *v4l2src = GST_V4L2SRC(gst_pad_get_parent (pad)); - GstCaps *list = NULL; + GstCaps *caps; gint i; struct v4l2_fmtdesc *format; int min_w, max_w, min_h, max_h; @@ -809,7 +747,10 @@ gst_v4l2src_getcaps (GstPad *pad, } /* build our own capslist */ + caps = gst_caps_new_empty(); for (i=0;i<g_list_length(v4l2src->formats);i++) { + GstStructure *structure; + format = g_list_nth_data(v4l2src->formats, i); /* get size delimiters */ @@ -820,15 +761,19 @@ gst_v4l2src_getcaps (GstPad *pad, } /* add to list */ - caps = gst_v4l2src_v4l2fourcc_to_caps_range(format->pixelformat, - min_w, max_w, - min_h, max_h, - format->flags & V4L2_FMT_FLAG_COMPRESSED); + structure = gst_v4l2src_v4l2fourcc_to_caps (format->pixelformat, + format->flags & V4L2_FMT_FLAG_COMPRESSED); - list = gst_caps_append(list, caps); + gst_structure_set (structure, + "width", GST_TYPE_INT_RANGE, min_w, max_w, + "height", GST_TYPE_INT_RANGE, min_h, max_h, + "framerate", GST_TYPE_DOUBLE_RANGE, 0, G_MAXDOUBLE, + NULL); + + gst_caps_append_structure (caps, structure); } - return list; + return caps; } @@ -848,13 +793,6 @@ gst_v4l2src_get (GstPad *pad) (fps = gst_v4l2src_get_fps(v4l2src)) == 0) return NULL; - buf = gst_buffer_new_from_pool(v4l2src->bufferpool, 0, 0); - if (!buf) { - gst_element_error(GST_ELEMENT(v4l2src), - "Failed to create a new GstBuffer"); - return NULL; - } - if (v4l2src->need_writes > 0) { /* use last frame */ num = v4l2src->last_frame; @@ -929,8 +867,10 @@ gst_v4l2src_get (GstPad *pad) v4l2src->use_num_times[num] = 1; } + buf = gst_buffer_new (); GST_BUFFER_DATA(buf) = gst_v4l2src_get_buffer(v4l2src, num); GST_BUFFER_SIZE(buf) = v4l2src->bufsettings.bytesused; + GST_BUFFER_FLAG_SET(buf, GST_BUFFER_READONLY); if (v4l2src->use_fixed_fps) GST_BUFFER_TIMESTAMP(buf) = v4l2src->handled * GST_SECOND / fps; else /* calculate time based on our own clock */ @@ -1074,6 +1014,7 @@ gst_v4l2src_set_clock (GstElement *element, } +#if 0 static GstBuffer* gst_v4l2src_buffer_new (GstBufferPool *pool, guint64 offset, @@ -1097,8 +1038,9 @@ gst_v4l2src_buffer_new (GstBufferPool *pool, return buffer; } +#endif - +#if 0 static void gst_v4l2src_buffer_free (GstBufferPool *pool, GstBuffer *buf, @@ -1126,3 +1068,5 @@ gst_v4l2src_buffer_free (GstBufferPool *pool, /* free the buffer itself */ gst_buffer_default_free(buf); } +#endif + diff --git a/sys/v4l2/gstv4l2src.h b/sys/v4l2/gstv4l2src.h index 1b4ab095..bae60900 100644 --- a/sys/v4l2/gstv4l2src.h +++ b/sys/v4l2/gstv4l2src.h @@ -80,9 +80,6 @@ struct _GstV4l2Src { /* how are we going to push buffers? */ gboolean use_fixed_fps; - - /* bufferpool for the buffers we're gonna use */ - GstBufferPool *bufferpool; }; struct _GstV4l2SrcClass { |