diff options
Diffstat (limited to 'gst/playondemand')
-rw-r--r-- | gst/playondemand/Makefile.am | 2 | ||||
-rw-r--r-- | gst/playondemand/filter.func | 2 | ||||
-rw-r--r-- | gst/playondemand/gstplayondemand.c | 103 | ||||
-rw-r--r-- | gst/playondemand/gstplayondemand.h | 1 |
4 files changed, 41 insertions, 67 deletions
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; |