From cccc097ca5b1a3214f0ed3af6268ee6a3d8ea017 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Sun, 21 Oct 2001 18:00:31 +0000 Subject: [PATCH] API docs. revived _buffer_ref_by_count fast types for scheduler and bin. Original commit message from CVS: API docs. revived _buffer_ref_by_count fast types for scheduler and bin. error checking on plugin features; removed some prototypes that were not implemented (gst_pipeline_iterate comes to mind) remove gst_pad_event until we know what it's supposed to do. remove sinesrc, it wasn't compiles anymore, so... updates to various elements that used the old event API. --- gst/cothreads.c | 16 +- gst/elements/Makefile.am | 3 +- gst/elements/gstdisksrc.c | 5 +- gst/elements/gstmultidisksrc.c | 3 +- gst/elements/gstmultifilesrc.c | 3 +- gst/elements/gstpipefilter.c | 8 +- gst/elements/gstsinesrc.c | 452 ------------------------------------- gst/elements/gstsinesrc.h | 96 -------- gst/gst.c | 3 + gst/gstautoplug.c | 8 +- gst/gstbin.c | 9 +- gst/gstbin.h | 27 ++- gst/gstbuffer.c | 36 ++- gst/gstbuffer.h | 8 +- gst/gstbufferpool.c | 11 +- gst/gstbufferpool.h | 5 +- gst/gstclock.c | 47 ++++ gst/gstelement.c | 43 ++-- gst/gstelement.h | 4 +- gst/gstelementfactory.c | 8 +- gst/gstevent.c | 26 ++- gst/gstinfo.c | 8 + gst/gstobject.c | 14 +- gst/gstpad.c | 32 +-- gst/gstpad.h | 10 - gst/gstpipeline.h | 2 - gst/gstplugin.c | 15 +- gst/gstplugin.h | 2 - gst/gstpluginfeature.c | 21 +- gst/gstpluginfeature.h | 2 +- gst/gstscheduler.c | 89 +++++++- gst/gstscheduler.h | 26 ++- gst/gsttimecache.c | 88 +++++++- gst/gsttimecache.h | 10 +- gst/gsttype.c | 20 +- gst/gstutils.c | 373 ++++++++++++++++-------------- gst/gstutils.h | 4 +- plugins/elements/Makefile.am | 3 +- plugins/elements/gstdisksrc.c | 5 +- plugins/elements/gstmultidisksrc.c | 3 +- plugins/elements/gstmultifilesrc.c | 3 +- plugins/elements/gstpipefilter.c | 8 +- plugins/elements/gstsinesrc.c | 452 ------------------------------------- plugins/elements/gstsinesrc.h | 96 -------- 44 files changed, 660 insertions(+), 1447 deletions(-) delete mode 100644 gst/elements/gstsinesrc.c delete mode 100644 gst/elements/gstsinesrc.h delete mode 100644 plugins/elements/gstsinesrc.c delete mode 100644 plugins/elements/gstsinesrc.h diff --git a/gst/cothreads.c b/gst/cothreads.c index 6a89425..b189c3b 100644 --- a/gst/cothreads.c +++ b/gst/cothreads.c @@ -192,10 +192,12 @@ cothread_setfunc (cothread_state *thread, * cothread_main: * @ctx: cothread context to find main thread of * + * Get the main thread. + * * Returns: the #cothread_state of the main (0th) thread */ cothread_state* -cothread_main(cothread_context *ctx) +cothread_main (cothread_context *ctx) { GST_DEBUG (0,"returning %p, the 0th cothread\n",ctx->threads[0]); return ctx->threads[0]; @@ -204,10 +206,12 @@ cothread_main(cothread_context *ctx) /** * cothread_current_main: * + * Get the main thread in the current pthread. + * * Returns: the #cothread_state of the main (0th) thread in the current pthread */ cothread_state* -cothread_current_main(void) +cothread_current_main (void) { cothread_context *ctx = pthread_getspecific(_cothread_key); return ctx->threads[0]; @@ -242,10 +246,14 @@ cothread_stub (void) /** * cothread_getcurrent: * + * Get the current cothread id + * * Returns: the current cothread id */ -int cothread_getcurrent(void) __attribute__ ((no_instrument_function)); -int cothread_getcurrent(void) { +int cothread_getcurrent (void) __attribute__ ((no_instrument_function)); +int +cothread_getcurrent (void) +{ cothread_context *ctx = pthread_getspecific(_cothread_key); if (!ctx) return -1; return ctx->current; diff --git a/gst/elements/Makefile.am b/gst/elements/Makefile.am index f50e4f7..1e165b8 100644 --- a/gst/elements/Makefile.am +++ b/gst/elements/Makefile.am @@ -39,8 +39,7 @@ noinst_HEADERS = \ gstfdsink.h \ gstpipefilter.h \ gsttee.h \ - gstaggregator.h \ - gstsinesrc.h + gstaggregator.h CFLAGS += -O2 -Wall LDFLAGS += -lm diff --git a/gst/elements/gstdisksrc.c b/gst/elements/gstdisksrc.c index ffe1b35..11e2cba 100644 --- a/gst/elements/gstdisksrc.c +++ b/gst/elements/gstdisksrc.c @@ -290,10 +290,7 @@ gst_disksrc_get (GstPad *pad) /* deal with EOF state */ if (src->curoffset >= src->size) { GST_DEBUG (0,"map offset %ld >= size %ld --> eos\n", src->curoffset, src->size); - gst_pad_event(pad, GST_EVENT_EOS, 0LL, 0); - buf = gst_buffer_new(); - GST_BUFFER_FLAG_SET (buf, GST_BUFFER_EOS); - return buf; + return GST_BUFFER(gst_event_new (GST_EVENT_EOS)); } // FIXME use a bufferpool diff --git a/gst/elements/gstmultidisksrc.c b/gst/elements/gstmultidisksrc.c index 9a8b28f..a09adcf 100644 --- a/gst/elements/gstmultidisksrc.c +++ b/gst/elements/gstmultidisksrc.c @@ -203,8 +203,7 @@ gst_multidisksrc_get (GstPad *pad) gst_multidisksrc_close_file(src); if (!src->listptr) { - gst_pad_event (pad, GST_EVENT_EOS, 0LL, 0); - return FALSE; + return GST_BUFFER(gst_event_new (GST_EVENT_EOS)); } list = src->listptr; diff --git a/gst/elements/gstmultifilesrc.c b/gst/elements/gstmultifilesrc.c index 9a8b28f..a09adcf 100644 --- a/gst/elements/gstmultifilesrc.c +++ b/gst/elements/gstmultifilesrc.c @@ -203,8 +203,7 @@ gst_multidisksrc_get (GstPad *pad) gst_multidisksrc_close_file(src); if (!src->listptr) { - gst_pad_event (pad, GST_EVENT_EOS, 0LL, 0); - return FALSE; + return GST_BUFFER(gst_event_new (GST_EVENT_EOS)); } list = src->listptr; diff --git a/gst/elements/gstpipefilter.c b/gst/elements/gstpipefilter.c index 86e5ac0..74ec480 100644 --- a/gst/elements/gstpipefilter.c +++ b/gst/elements/gstpipefilter.c @@ -64,7 +64,7 @@ static void gst_pipefilter_get_property (GObject *object, guint prop_id, GVal static GstBuffer* gst_pipefilter_get (GstPad *pad); static void gst_pipefilter_chain (GstPad *pad, GstBuffer *buf); -static gboolean gst_pipefilter_handle_event (GstPad *pad, void *event); +static gboolean gst_pipefilter_handle_event (GstPad *pad, GstEvent *event); static GstElementStateReturn gst_pipefilter_change_state (GstElement *element); @@ -134,7 +134,7 @@ gst_pipefilter_init (GstPipefilter *pipefilter) } static gboolean -gst_pipefilter_handle_event (GstPad *pad, void *event) +gst_pipefilter_handle_event (GstPad *pad, GstEvent *event) { GstPipefilter *pipefilter; @@ -180,8 +180,8 @@ gst_pipefilter_get (GstPad *pad) } /* if we didn't get as many bytes as we asked for, we're at EOF */ if (readbytes == 0) { - gst_pad_event (pad, GST_EVENT_EOS, 0LL, 0); - return NULL; + return GST_BUFFER(gst_event_new (GST_EVENT_EOS)); + } GST_BUFFER_OFFSET(newbuf) = pipefilter->curoffset; diff --git a/gst/elements/gstsinesrc.c b/gst/elements/gstsinesrc.c deleted file mode 100644 index 75ca6ba..0000000 --- a/gst/elements/gstsinesrc.c +++ /dev/null @@ -1,452 +0,0 @@ -/* GStreamer - * Copyright (C) 1999,2000 Erik Walthinsen - * 2000 Wim Taymans - * 2001 Steve Baker - * - * gstsinesrc.c: - * - * 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. - */ - -#include -#include -#include - -#include - - -GstElementDetails gst_sinesrc_details = { - "Sine-wave src", - "Source/Audio", - "Create a sine wave of a given frequency and volume", - VERSION, - "Erik Walthinsen ", - "(C) 1999", -}; - - -/* SineSrc signals and args */ -enum { - /* FILL ME */ - LAST_SIGNAL -}; - -enum { - ARG_0, - ARG_VOLUME, - ARG_FORMAT, - ARG_SAMPLERATE, - ARG_FREQ, - ARG_TABLESIZE, - ARG_BUFFER_SIZE, -}; - -// FIXME: this is not core business... -GST_PADTEMPLATE_FACTORY (sinesrc_src_factory, - "src", - GST_PAD_SRC, - GST_PAD_ALWAYS, - GST_CAPS_NEW ( - "sinesrc_src", - "audio/raw", - "format", GST_PROPS_STRING ("int"), - "law", GST_PROPS_INT (0), - "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, 48000), - "channels", GST_PROPS_INT (1) - ) -); - -static void gst_sinesrc_class_init (GstSineSrcClass *klass); -static void gst_sinesrc_init (GstSineSrc *src); -static GstPadNegotiateReturn gst_sinesrc_negotiate (GstPad *pad, GstCaps **caps, gpointer *data); -static void gst_sinesrc_set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec); -static void gst_sinesrc_get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec); -//static gboolean gst_sinesrc_change_state(GstElement *element, -// GstElementState state); -//static void gst_sinesrc_close_audio(GstSineSrc *src); -//static gboolean gst_sinesrc_open_audio(GstSineSrc *src); - -static void gst_sinesrc_update_volume(GValue *value, gpointer data); -static void gst_sinesrc_update_freq(GValue *value, gpointer data); -static void gst_sinesrc_populate_sinetable (GstSineSrc *src); -static inline void gst_sinesrc_update_table_inc (GstSineSrc *src); -static inline void gst_sinesrc_update_vol_scale (GstSineSrc *src); -static void gst_sinesrc_force_caps (GstSineSrc *src); - -static GstBuffer* gst_sinesrc_get (GstPad *pad); - -static GstElementClass *parent_class = NULL; -//static guint gst_sinesrc_signals[LAST_SIGNAL] = { 0 }; - -GType -gst_sinesrc_get_type (void) -{ - static GType sinesrc_type = 0; - - if (!sinesrc_type) { - static const GTypeInfo sinesrc_info = { - sizeof(GstSineSrcClass), - NULL, - NULL, - (GClassInitFunc)gst_sinesrc_class_init, - NULL, - NULL, - sizeof(GstSineSrc), - 0, - (GInstanceInitFunc)gst_sinesrc_init, - }; - sinesrc_type = g_type_register_static (GST_TYPE_ELEMENT, "GstSineSrc", &sinesrc_info, 0); - } - return sinesrc_type; -} - -static void -gst_sinesrc_class_init (GstSineSrcClass *klass) -{ - GObjectClass *gobject_class; - GstElementClass *gstelement_class; - - gobject_class = (GObjectClass*)klass; - gstelement_class = (GstElementClass*)klass; - - parent_class = g_type_class_ref(GST_TYPE_ELEMENT); - - g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_VOLUME, - g_param_spec_double("volume","volume","volume", - 0.0, 1.0, 0.0,G_PARAM_READWRITE)); // CHECKME - g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_FORMAT, - g_param_spec_int("format","format","format", - G_MININT,G_MAXINT,0,G_PARAM_READWRITE)); // CHECKME - g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_SAMPLERATE, - g_param_spec_int("samplerate","samplerate","samplerate", - G_MININT,G_MAXINT,0,G_PARAM_READWRITE)); // CHECKME - g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_TABLESIZE, - g_param_spec_int("tablesize","tablesize","tablesize", - G_MININT,G_MAXINT,0,G_PARAM_READWRITE)); // CHECKME - g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_FREQ, - g_param_spec_double("freq","freq","freq", - 0.0,G_MAXDOUBLE, 440.0,G_PARAM_READWRITE)); // CHECKME - g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_BUFFER_SIZE, - g_param_spec_int("buffersize","buffersize","buffersize", - 0, G_MAXINT, 1024, G_PARAM_READWRITE)); - - gobject_class->set_property = gst_sinesrc_set_property; - gobject_class->get_property = gst_sinesrc_get_property; - -// gstelement_class->change_state = gst_sinesrc_change_state; -} - -static void -gst_sinesrc_init (GstSineSrc *src) -{ - GstElement *element = GST_ELEMENT(src); - GstDParamManager *dpman; - - src->srcpad = gst_pad_new_from_template ( - GST_PADTEMPLATE_GET (sinesrc_src_factory), "src"); - gst_element_add_pad(GST_ELEMENT(src), src->srcpad); - gst_pad_set_negotiate_function (src->srcpad, gst_sinesrc_negotiate); - - gst_pad_set_get_function(src->srcpad, gst_sinesrc_get); - - src->format = 16; - src->samplerate = 44100; - - src->newcaps = TRUE; - - src->table_pos = 0.0; - src->table_size = 1024; - src->buffer_size=1024; - - src->seq = 0; - - dpman = gst_dpman_new ("sinesrc_dpman", GST_ELEMENT(src)); - gst_dpman_add_required_dparam (dpman, "volume", G_TYPE_FLOAT, gst_sinesrc_update_volume, src); - gst_dpman_add_required_dparam (dpman, "freq", G_TYPE_FLOAT, gst_sinesrc_update_freq, src); - - gst_dpman_set_rate_change_pad(dpman, src->srcpad); - - GST_ELEMENT_DPARAM_MANAGER(element) = dpman; - - gst_sinesrc_update_vol_scale(src); - - gst_sinesrc_populate_sinetable(src); - gst_sinesrc_update_table_inc(src); - -} - -static GstPadNegotiateReturn -gst_sinesrc_negotiate (GstPad *pad, GstCaps **caps, gpointer *data) -{ - GstSineSrc *src; - - if (*caps) { - g_return_val_if_fail (pad != NULL, GST_PAD_NEGOTIATE_FAIL); - src = GST_SINESRC(gst_pad_get_parent (pad)); - src->samplerate = gst_caps_get_int (*caps, "rate"); - gst_sinesrc_update_table_inc(src); - return GST_PAD_NEGOTIATE_AGREE; - } - - return GST_PAD_NEGOTIATE_FAIL; -} - -static GstBuffer * -gst_sinesrc_get(GstPad *pad) -{ - GstSineSrc *src; - GstBuffer *buf; - GstDParamManager *dpman; - - gint16 *samples; - gint i=0, frame_countdown; - - g_return_val_if_fail (pad != NULL, NULL); - src = GST_SINESRC(gst_pad_get_parent (pad)); - - buf = gst_buffer_new(); - g_return_val_if_fail (buf, NULL); - samples = g_new(gint16, src->buffer_size); - GST_BUFFER_DATA(buf) = (gpointer) samples; - GST_BUFFER_SIZE(buf) = 2 * src->buffer_size; - - dpman = GST_ELEMENT_DPARAM_MANAGER(GST_ELEMENT(src)); - frame_countdown = GST_DPMAN_FIRST_COUNTDOWN(dpman, src->buffer_size, 0LL); - - while(GST_DPMAN_COUNTDOWN(dpman, frame_countdown, i)) { - src->table_lookup = (gint)(src->table_pos); - src->table_lookup_next = src->table_lookup + 1; - src->table_interp = src->table_pos - src->table_lookup; - - // wrap the array lookups if we're out of bounds - if (src->table_lookup_next >= src->table_size){ - src->table_lookup_next -= src->table_size; - if (src->table_lookup >= src->table_size){ - src->table_lookup -= src->table_size; - src->table_pos -= src->table_size; - } - } - - src->table_pos += src->table_inc; - - //no interpolation - //samples[i] = src->table_data[src->table_lookup] - // * src->vol_scale; - - //linear interpolation - samples[i++] = ((src->table_interp - *(src->table_data[src->table_lookup_next] - -src->table_data[src->table_lookup] - ) - )+src->table_data[src->table_lookup] - )* src->vol_scale; - } - - if (src->newcaps) { - gst_sinesrc_force_caps(src); - } - - return buf; -} - -static void -gst_sinesrc_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) -{ - GstSineSrc *src; - - /* it's not null if we got it, but it might not be ours */ - g_return_if_fail(GST_IS_SINESRC(object)); - src = GST_SINESRC(object); - - switch (prop_id) { - case ARG_VOLUME: - src->volume = (gfloat)g_value_get_double (value); - gst_sinesrc_update_vol_scale(src); - break; - case ARG_FORMAT: - src->format = g_value_get_int (value); - src->newcaps=TRUE; - break; - case ARG_SAMPLERATE: - src->samplerate = g_value_get_int (value); - src->newcaps=TRUE; - gst_sinesrc_update_table_inc(src); - break; - case ARG_FREQ: { - if (g_value_get_double (value) <= 0.0 || g_value_get_double (value) > src->samplerate/2) - break; - src->freq = (gfloat)g_value_get_double (value); - gst_sinesrc_update_table_inc(src); - break; - case ARG_TABLESIZE: - src->table_size = g_value_get_int (value); - gst_sinesrc_populate_sinetable(src); - gst_sinesrc_update_table_inc(src); - break; - case ARG_BUFFER_SIZE: - src->buffer_size = g_value_get_int (value); - break; - } - default: - break; - } -} - -static void -gst_sinesrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) -{ - GstSineSrc *src; - - /* it's not null if we got it, but it might not be ours */ - g_return_if_fail(GST_IS_SINESRC(object)); - src = GST_SINESRC(object); - - switch (prop_id) { - case ARG_VOLUME: - g_value_set_double (value, (gdouble)(src->volume)); - break; - case ARG_FORMAT: - g_value_set_int (value, src->format); - break; - case ARG_SAMPLERATE: - g_value_set_int (value, src->samplerate); - break; - case ARG_FREQ: - g_value_set_double (value, (gdouble)(src->freq)); - break; - case ARG_TABLESIZE: - g_value_set_int (value, src->table_size); - break; - case ARG_BUFFER_SIZE: - g_value_set_int (value, src->buffer_size); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -/* -static gboolean gst_sinesrc_change_state(GstElement *element, - GstElementState state) { - g_return_if_fail(GST_IS_SINESRC(element)); - - switch (state) { - case GST_STATE_RUNNING: - if (!gst_sinesrc_open_audio(GST_SINESRC(element))) - return FALSE; - break; - case ~GST_STATE_RUNNING: - gst_sinesrc_close_audio(GST_SINESRC(element)); - break; - default: - break; - } - - if (GST_ELEMENT_CLASS(parent_class)->change_state) - return GST_ELEMENT_CLASS(parent_class)->change_state(element,state); - return TRUE; -} -*/ - -static void -gst_sinesrc_populate_sinetable (GstSineSrc *src) -{ - gint i; - gdouble pi2scaled = M_PI * 2 / src->table_size; - gfloat *table = g_new(gfloat, src->table_size); - - for(i=0 ; i < src->table_size ; i++){ - table[i] = (gfloat)sin(i * pi2scaled); - } - - g_free(src->table_data); - src->table_data = table; -} - -static void -gst_sinesrc_update_volume(GValue *value, gpointer data) -{ - GstSineSrc *src = (GstSineSrc*)data; - g_return_if_fail(GST_IS_SINESRC(src)); - - src->volume = g_value_get_float(value); - src->vol_scale = 32767.0 * src->volume; -} - -static void -gst_sinesrc_update_freq(GValue *value, gpointer data) -{ - GstSineSrc *src = (GstSineSrc*)data; - g_return_if_fail(GST_IS_SINESRC(src)); - - src->freq = g_value_get_float(value); - src->table_inc = src->table_size * src->freq / src->samplerate; -} - -static inline void -gst_sinesrc_update_table_inc (GstSineSrc *src) -{ - src->table_inc = src->table_size * src->freq / src->samplerate; -} - -static inline void -gst_sinesrc_update_vol_scale (GstSineSrc *src) -{ - src->vol_scale = 32767.0 * src->volume; -} - -static void -gst_sinesrc_force_caps(GstSineSrc *src) { - GstCaps *caps; - - if (!src->newcaps) - return; - - src->newcaps=FALSE; - - caps = gst_caps_new ( - "sinesrc_src_caps", - "audio/raw", - gst_props_new ( - "format", GST_PROPS_STRING ("int"), - "law", GST_PROPS_INT (0), - "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 (src->samplerate), - "channels", GST_PROPS_INT (1), - NULL - ) - ); - - gst_pad_set_caps (src->srcpad, caps); -} - -gboolean -gst_sinesrc_factory_init (GstElementFactory *factory) -{ - gst_elementfactory_add_padtemplate (factory, GST_PADTEMPLATE_GET (sinesrc_src_factory)); - - return TRUE; -} diff --git a/gst/elements/gstsinesrc.h b/gst/elements/gstsinesrc.h deleted file mode 100644 index 58e03fd..0000000 --- a/gst/elements/gstsinesrc.h +++ /dev/null @@ -1,96 +0,0 @@ -/* GStreamer - * Copyright (C) 1999,2000 Erik Walthinsen - * 2000 Wim Taymans - * - * gstsinesrc.h: - * - * 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_SINESRC_H__ -#define __GST_SINESRC_H__ - - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - - -GstElementDetails gst_sinesrc_details; - - -#define GST_TYPE_SINESRC \ - (gst_sinesrc_get_type()) -#define GST_SINESRC(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_SINESRC,GstSineSrc)) -#define GST_SINESRC_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_SINESRC,GstSineSrcClass)) -#define GST_IS_SINESRC(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_SINESRC)) -#define GST_IS_SINESRC_CLASS(obj) \ - (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_SINESRC)) - -typedef struct _GstSineSrc GstSineSrc; -typedef struct _GstSineSrcClass GstSineSrcClass; - -struct _GstSineSrc { - GstElement element; - - /* pads */ - GstPad *srcpad; - - /* parameters */ - gfloat volume; - gfloat freq; - gfloat vol_scale; - - /* lookup table data */ - gfloat *table_data; - gdouble table_pos; - gdouble table_inc; - gint table_size; - gdouble table_interp; - gint table_lookup; - gint table_lookup_next; - - /* audio parameters */ - gint format; - gint samplerate; - - gint buffer_size; - gulong seq; - - gboolean newcaps; - -}; - -struct _GstSineSrcClass { - GstElementClass parent_class; -}; - -GType gst_sinesrc_get_type(void); -gboolean gst_sinesrc_factory_init (GstElementFactory *factory); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* __GST_SINESRC_H__ */ diff --git a/gst/gst.c b/gst/gst.c index 8ecacba..c6afbb12 100644 --- a/gst/gst.c +++ b/gst/gst.c @@ -34,6 +34,7 @@ #include "gstthread.h" #include "gstqueue.h" #include "gstautoplug.h" +#include "gstscheduler.h" #ifndef GST_DISABLE_TYPEFIND #include "gsttypefind.h" #endif @@ -117,6 +118,8 @@ gst_init (int *argc, char **argv[]) gst_elementfactory_get_type (); gst_element_get_type (); gst_typefactory_get_type (); + gst_schedule_get_type (); + gst_bin_get_type (); #ifndef GST_DISABLE_AUTOPLUG gst_autoplugfactory_get_type (); #endif diff --git a/gst/gstautoplug.c b/gst/gstautoplug.c index 612cd4b..c1c813e 100644 --- a/gst/gstautoplug.c +++ b/gst/gstautoplug.c @@ -335,11 +335,11 @@ gst_autoplugfactory_create (GstAutoplugFactory *factory) g_return_val_if_fail (factory != NULL, NULL); - gst_plugin_feature_ensure_loaded (GST_PLUGIN_FEATURE (factory)); + if (gst_plugin_feature_ensure_loaded (GST_PLUGIN_FEATURE (factory))) { + g_return_val_if_fail (factory->type != 0, NULL); - g_return_val_if_fail (factory->type != 0, NULL); - - new = GST_AUTOPLUG (g_object_new(factory->type,NULL)); + new = GST_AUTOPLUG (g_object_new(factory->type,NULL)); + } return new; } diff --git a/gst/gstbin.c b/gst/gstbin.c index 4396fe3..1821aba 100644 --- a/gst/gstbin.c +++ b/gst/gstbin.c @@ -36,6 +36,7 @@ GstElementDetails gst_bin_details = { "(C) 1999", }; +GType _gst_bin_type = 0; static void gst_bin_dispose (GObject *object); @@ -74,9 +75,7 @@ static guint gst_bin_signals[LAST_SIGNAL] = { 0 }; GType gst_bin_get_type (void) { - static GType bin_type = 0; - - if (!bin_type) { + if (!_gst_bin_type) { static const GTypeInfo bin_info = { sizeof(GstBinClass), NULL, @@ -89,9 +88,9 @@ gst_bin_get_type (void) (GInstanceInitFunc)gst_bin_init, NULL }; - bin_type = g_type_register_static (GST_TYPE_ELEMENT, "GstBin", &bin_info, 0); + _gst_bin_type = g_type_register_static (GST_TYPE_ELEMENT, "GstBin", &bin_info, 0); } - return bin_type; + return _gst_bin_type; } static void diff --git a/gst/gstbin.h b/gst/gstbin.h index cee2a69..f8e2c6d 100644 --- a/gst/gstbin.h +++ b/gst/gstbin.h @@ -32,17 +32,22 @@ extern "C" { #endif /* __cplusplus */ extern GstElementDetails gst_bin_details; - -#define GST_TYPE_BIN \ - (gst_bin_get_type()) -#define GST_BIN(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_BIN,GstBin)) -#define GST_BIN_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_BIN,GstBinClass)) -#define GST_IS_BIN(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_BIN)) -#define GST_IS_BIN_CLASS(obj) \ - (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_BIN)) +extern GType _gst_bin_type; + +#define GST_TYPE_BIN (_gst_bin_type) +# define GST_IS_BIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_BIN)) +# define GST_IS_BIN_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_BIN)) + +#define GST_BIN_FAST(obj) ((GstBin*)(obj)) +#define GST_BIN_CLASS_FAST(klass) ((GstBinClass*)(klass)) + +#ifdef GST_TYPE_PARANOID +# define GST_BIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_BIN, GstBin)) +# define GST_BIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_BIN, GstBinClass)) +#else +# define GST_BIN GST_BIN_FAST +# define GST_BIN_CLASS GST_BIN_CLASS_FAST +#endif typedef enum { /* this bin is a manager of child elements, i.e. a pipeline or thread */ diff --git a/gst/gstbuffer.c b/gst/gstbuffer.c index c330b2e..de223f3 100644 --- a/gst/gstbuffer.c +++ b/gst/gstbuffer.c @@ -102,8 +102,10 @@ gst_buffer_new (void) /** * gst_buffer_new_from_pool: * @pool: the buffer pool to use + * @offset: the offset of the new buffer + * @size: the size of the new buffer * - * Create a new buffer using the specified bufferpool. + * Create a new buffer using the specified bufferpool, offset and size. * * Returns: new buffer */ @@ -315,6 +317,30 @@ gst_buffer_ref (GstBuffer *buffer) } /** + * gst_buffer_ref_by_count: + * @buffer: the GstBuffer to reference + * @count: a number + * + * Increment the refcount of this buffer by the given number. + */ +void +gst_buffer_ref_by_count (GstBuffer *buffer, gint count) +{ + g_return_if_fail (buffer != NULL); + g_return_if_fail (count > 0); + +#ifdef HAVE_ATOMIC_H + g_return_if_fail (atomic_read (&(buffer->refcount)) > 0); + atomic_add (count, &(buffer->refcount)); +#else + g_return_if_fail (buffer->refcount > 0); + GST_BUFFER_LOCK (buffer); + buffer->refcount += count; + GST_BUFFER_UNLOCK (buffer); +#endif +} + +/** * gst_buffer_unref: * @buffer: the GstBuffer to unref * @@ -388,8 +414,8 @@ gst_buffer_copy (GstBuffer *buffer) return newbuf; } -/* - * gst_buffer_is_span_fast +/** + * gst_buffer_is_span_fast: * @buf1: first source buffer * @buf2: second source buffer * @@ -439,7 +465,7 @@ gst_buffer_span (GstBuffer *buf1, guint32 offset, GstBuffer *buf2, guint32 len) // make sure buf1 has a lower address than buf2 if (buf1->data > buf2->data) { GstBuffer *tmp = buf1; - g_print ("swapping buffers\n"); + //g_print ("swapping buffers\n"); buf1 = buf2; buf2 = tmp; } @@ -450,7 +476,7 @@ gst_buffer_span (GstBuffer *buf1, guint32 offset, GstBuffer *buf2, guint32 len) newbuf = gst_buffer_create_sub (buf1->parent, buf1->data - (buf1->parent->data) + offset, len); } else { - g_print ("slow path taken in buffer_span\n"); + //g_print ("slow path taken in buffer_span\n"); // otherwise we simply have to brute-force copy the buffers newbuf = gst_buffer_new (); diff --git a/gst/gstbuffer.h b/gst/gstbuffer.h index 9eef49c..77ff766 100644 --- a/gst/gstbuffer.h +++ b/gst/gstbuffer.h @@ -36,7 +36,6 @@ // #include -#include #ifdef HAVE_CONFIG_H #include "config.h" @@ -137,8 +136,8 @@ struct _GstBuffer { gpointer pool_private; /* utility function pointers */ - GstBufferFreeFunc free; // free the data associated with the buffer - GstBufferCopyFunc copy; // copy the data from one buffer to another + GstBufferFreeFunc free; /* free the data associated with the buffer */ + GstBufferCopyFunc copy; /* copy the data from one buffer to another */ }; /* initialisation */ @@ -152,6 +151,7 @@ GstBuffer* gst_buffer_create_sub (GstBuffer *parent, guint32 offset, guint32 si /* refcounting */ void gst_buffer_ref (GstBuffer *buffer); +void gst_buffer_ref_by_count (GstBuffer *buffer, gint count); void gst_buffer_unref (GstBuffer *buffer); /* destroying the buffer */ @@ -163,7 +163,7 @@ GstBuffer* gst_buffer_copy (GstBuffer *buffer); /* merge, span, or append two buffers, intelligently */ GstBuffer* gst_buffer_merge (GstBuffer *buf1, GstBuffer *buf2); GstBuffer* gst_buffer_span (GstBuffer *buf1,guint32 offset,GstBuffer *buf2,guint32 len); -GstBuffer* gst_buffer_append (GstBuffer *buf, GstBuffer *buf2); +GstBuffer* gst_buffer_append (GstBuffer *buffer, GstBuffer *append); gboolean gst_buffer_is_span_fast (GstBuffer *buf1, GstBuffer *buf2); diff --git a/gst/gstbufferpool.c b/gst/gstbufferpool.c index d04c8a2..2a9c520 100644 --- a/gst/gstbufferpool.c +++ b/gst/gstbufferpool.c @@ -191,7 +191,7 @@ gst_buffer_pool_set_buffer_free_function (GstBufferPool *pool, /** * gst_buffer_pool_set_buffer_copy_function: * @pool: the pool to set the buffer copy function for - * @destroy: the copy function + * @copy: the copy function * * Sets the function that will be called when a buffer is copied. * @@ -207,7 +207,7 @@ gst_buffer_pool_set_buffer_copy_function (GstBufferPool *pool, } /** - * gst_buffer_pool_set_pool_destroy_hook: + * gst_buffer_pool_set_destroy_hook: * @pool: the pool to set the destroy hook for * @destroy: the destroy function * @@ -243,14 +243,13 @@ gst_buffer_pool_set_user_data (GstBufferPool *pool, /** * gst_buffer_pool_get_user_data: * @pool: the pool to get the user data from - * @user_data: any user data to be passed to the create/destroy buffer functions - * and the destroy hook * * gets user data + * + * Returns: The user data of this bufferpool */ gpointer -gst_buffer_pool_get_user_data (GstBufferPool *pool, - gpointer user_data) +gst_buffer_pool_get_user_data (GstBufferPool *pool) { g_return_val_if_fail (pool != NULL, NULL); diff --git a/gst/gstbufferpool.h b/gst/gstbufferpool.h index 507f77e..4ac0283 100644 --- a/gst/gstbufferpool.h +++ b/gst/gstbufferpool.h @@ -70,7 +70,7 @@ GstBufferPool* gst_buffer_pool_new (void); /* refcounting */ void gst_buffer_pool_ref (GstBufferPool *pool); void gst_buffer_pool_ref_by_count (GstBufferPool *pool, int count); -void gst_buffer_pool_unref (GstBufferPool *buffer); +void gst_buffer_pool_unref (GstBufferPool *pool); /* setting create and destroy functions */ void gst_buffer_pool_set_buffer_new_function (GstBufferPool *pool, @@ -83,8 +83,7 @@ void gst_buffer_pool_set_destroy_hook (GstBufferPool *pool, GstBufferPoolDestroyHook destroy); void gst_buffer_pool_set_user_data (GstBufferPool *pool, gpointer user_data); -gpointer gst_buffer_pool_get_user_data (GstBufferPool *pool, - gpointer user_data); +gpointer gst_buffer_pool_get_user_data (GstBufferPool *pool); /* destroying the buffer pool */ void gst_buffer_pool_destroy (GstBufferPool *pool); diff --git a/gst/gstclock.c b/gst/gstclock.c index 0c3caad..52bf735 100644 --- a/gst/gstclock.c +++ b/gst/gstclock.c @@ -57,6 +57,13 @@ gst_clock_new (gchar *name) return clock; } +/** + * gst_clock_get_system: + * + * Get the global system clock + * + * Returns: the global clock + */ GstClock* gst_clock_get_system(void) { @@ -67,6 +74,14 @@ gst_clock_get_system(void) return the_system_clock; } +/** + * gst_clock_register: + * @clock: the name of the clock to register to + * @obj: the object registering to the clock + * + * State that an object is interested in listening to the + * given clock + */ void gst_clock_register (GstClock *clock, GstObject *obj) { @@ -77,6 +92,13 @@ gst_clock_register (GstClock *clock, GstObject *obj) } } +/** + * gst_clock_set: + * @clock: The clock to set + * @time: the time to set + * + * Set the time of the given clock to time. + */ void gst_clock_set (GstClock *clock, GstClockTime time) { @@ -92,6 +114,16 @@ gst_clock_set (GstClock *clock, GstClockTime time) time, now, clock->start_time); } +/** + * gst_clock_current_diff: + * @clock: the clock to calculate the diff against + * @time: the time + * + * Calculate the difference between the given clock and the + * given time + * + * Returns: the clock difference + */ GstClockTimeDiff gst_clock_current_diff (GstClock *clock, GstClockTime time) { @@ -106,6 +138,13 @@ gst_clock_current_diff (GstClock *clock, GstClockTime time) return GST_CLOCK_DIFF (time, now); } +/** + * gst_clock_reset: + * @clock: the clock to reset + * + * Reset the given clock. The of the clock will be adjusted back + * to 0. + */ void gst_clock_reset (GstClock *clock) { @@ -120,6 +159,14 @@ gst_clock_reset (GstClock *clock) g_mutex_unlock (clock->lock); } +/** + * gst_clock_wait: + * @clock: the clock to wait on + * @time: the time to wait for + * @obj: the object performing the wait + * + * Wait for a specific clock tick on the given clock. + */ void gst_clock_wait (GstClock *clock, GstClockTime time, GstObject *obj) { diff --git a/gst/gstelement.c b/gst/gstelement.c index 332c91b..d1f3139 100644 --- a/gst/gstelement.c +++ b/gst/gstelement.c @@ -794,12 +794,20 @@ gst_element_error (GstElement *element, const gchar *error) } +/** + * gst_element_get_state: + * @element: element to get state of + * + * Gets the state of the element. + * + * Returns: The element state + */ GstElementState -gst_element_get_state (GstElement *elem) +gst_element_get_state (GstElement *element) { - g_return_val_if_fail (GST_IS_ELEMENT (elem), GST_STATE_VOID_PENDING); + g_return_val_if_fail (GST_IS_ELEMENT (element), GST_STATE_VOID_PENDING); - return GST_STATE (elem); + return GST_STATE (element); } /** @@ -969,23 +977,6 @@ gst_element_dispose (GObject *object) G_OBJECT_CLASS (parent_class)->dispose (object); } -/* -static gchar *_gst_element_type_names[] = { - "invalid", - "none", - "char", - "uchar", - "bool", - "int", - "uint", - "long", - "ulong", - "float", - "double", - "string", -}; -*/ - #ifndef GST_DISABLE_LOADSAVE /** * gst_element_save_thyself: @@ -1260,7 +1251,17 @@ gst_element_signal_eos (GstElement *element) } -const gchar *gst_element_statename(GstElementState state) { +/** + * gst_element_statename: + * @state: The state to get the name of + * + * Gets a string representing the given state. + * + * Returns: a string with the statename. + */ +const gchar* +gst_element_statename (GstElementState state) +{ switch (state) { #ifdef GST_DEBUG_COLOR case GST_STATE_VOID_PENDING: return "NONE_PENDING";break; diff --git a/gst/gstelement.h b/gst/gstelement.h index 1d05451..4f0b11e 100644 --- a/gst/gstelement.h +++ b/gst/gstelement.h @@ -177,7 +177,7 @@ struct _GstElementClass { GstPad* (*request_new_pad) (GstElement *element, GstPadTemplate *templ, const gchar* name); }; -void gst_element_class_add_padtemplate (GstElementClass *element, GstPadTemplate *templ); +void gst_element_class_add_padtemplate (GstElementClass *klass, GstPadTemplate *templ); GType gst_element_get_type (void); #define gst_element_destroy(element) gst_object_destroy (GST_OBJECT (element)) @@ -214,7 +214,7 @@ void gst_element_disconnect (GstElement *src, const gchar *srcpadname, void gst_element_signal_eos (GstElement *element); -GstElementState gst_element_get_state (GstElement *elem); +GstElementState gst_element_get_state (GstElement *element); /* called by the app to set the state of the element */ gint gst_element_set_state (GstElement *element, GstElementState state); const gchar * gst_element_statename (GstElementState state); diff --git a/gst/gstelementfactory.c b/gst/gstelementfactory.c index 0f4dde3..b2079f9 100644 --- a/gst/gstelementfactory.c +++ b/gst/gstelementfactory.c @@ -229,17 +229,17 @@ gst_elementfactory_create (GstElementFactory *factory, GST_DEBUG (GST_CAT_ELEMENTFACTORY,"creating element from factory \"%s\" with name \"%s\" and type %d\n", GST_OBJECT_NAME (factory), name, factory->type); - gst_plugin_feature_ensure_loaded (GST_PLUGIN_FEATURE (factory)); + if (!gst_plugin_feature_ensure_loaded (GST_PLUGIN_FEATURE (factory))) + return NULL; - if (factory->type == 0) - { + if (factory->type == 0) { /* FIXME: g_critical is glib-2.0, not glib-1.2 g_critical ("Factory for `%s' has no type", */ g_warning ("Factory for `%s' has no type", gst_object_get_name (GST_OBJECT (factory))); return NULL; - } + } // create an instance of the element element = GST_ELEMENT(g_object_new(factory->type,NULL)); diff --git a/gst/gstevent.c b/gst/gstevent.c index 10aa9c3..e06ed50 100644 --- a/gst/gstevent.c +++ b/gst/gstevent.c @@ -50,13 +50,20 @@ _gst_event_initialize (void) _gst_event_chunk = g_mem_chunk_new ("GstEvent", eventsize, eventsize * 32, G_ALLOC_AND_FREE); - _gst_event_chunk_lock = g_mutex_new (); // register the type _gst_event_type = g_type_register_static (G_TYPE_INT, "GstEvent", &event_info, 0); } +/** + * gst_event_new: + * @type: The type of the new event + * + * Allocate a new event of the given type. + * + * Returns: A new event. + */ GstEvent* gst_event_new (GstEventType type) { @@ -73,6 +80,12 @@ gst_event_new (GstEventType type) return event; } +/** + * gst_event_free: + * @event: The event to free + * + * Free the given element. + */ void gst_event_free (GstEvent* event) { @@ -81,7 +94,16 @@ gst_event_free (GstEvent* event) g_mutex_unlock (_gst_event_chunk_lock); } -/* seek stuff */ +/** + * gst_event_new_seek: + * @type: The type of the seek event + * @offset: The offset of the seek + * @flush: A boolean indicating a flush has to be performed as well + * + * Allocate a new seek event with the given parameters. + * + * Returns: A new seek event. + */ GstEvent* gst_event_new_seek (GstSeekType type, guint64 offset, gboolean flush) { diff --git a/gst/gstinfo.c b/gst/gstinfo.c index 41244b4..1652b08 100644 --- a/gst/gstinfo.c +++ b/gst/gstinfo.c @@ -66,6 +66,8 @@ static gchar *_gst_info_category_strings[] = { * gst_get_category_name: * @category: the category to return the name of * + * Return a string containing the name of the category + * * Returns: string containing the name of the category */ const gchar * @@ -214,6 +216,8 @@ gst_debug_set_categories (guint32 categories) { /** * gst_debug_get_categories: * + * Return the current bitmask of enabled DEBUG categories + * * Returns: the current bitmask of enabled DEBUG categories * The bit for any given category is (1 << GST_CAT_...). */ @@ -339,6 +343,9 @@ gst_info_set_categories (guint32 categories) { /** * gst_info_get_categories: * + * Return the current bitmask of enabled INFO categories + * The bit for any given category is (1 << GST_CAT_...). + * * Returns: the current bitmask of enabled INFO categories * The bit for any given category is (1 << GST_CAT_...). */ @@ -528,6 +535,7 @@ gst_debug_print_stack_trace (void) void gst_debug_print_stack_trace (void) { + //nothing because it's compiled out } #endif /* GST_ENABLE_FUNC_INTSTRUMENTATION */ diff --git a/gst/gstobject.c b/gst/gstobject.c index 70d8122..899ee6c 100644 --- a/gst/gstobject.c +++ b/gst/gstobject.c @@ -186,6 +186,12 @@ gst_object_sink (GstObject *object) } } +/** + * gst_object_destroy: + * @object: GstObject to destroy + * + * Destroy the object. + */ void gst_object_destroy (GstObject *object) { @@ -475,13 +481,11 @@ gst_object_save_thyself (GstObject *object, xmlNodePtr parent) } /** - * gst_object_load_thyself: + * gst_object_restore_thyself: * @object: GstObject to load into - * @parent: The parent XML node to save the object into + * @parent: The parent XML node to load the object from * - * Saves the given object into the parent XML node. - * - * Returns: the new xmlNodePtr with the saved object + * Restores the given object with the data from the parent XML node. */ void gst_object_restore_thyself (GstObject *object, xmlNodePtr parent) diff --git a/gst/gstpad.c b/gst/gstpad.c index c5c985d..d76c650 100644 --- a/gst/gstpad.c +++ b/gst/gstpad.c @@ -1970,32 +1970,20 @@ gst_pad_event_default(GstPad *pad, GstEventType event, guint64 timestamp, guint3 gst_element_signal_eos(GST_PAD_PARENT(pad)); else GST_DEBUG(GST_CAT_EVENT, "WARNING: no default behavior for EOS with multiple sinkpads\n"); + default: break; } } -gboolean -gst_pad_event (GstPad *pad, GstEventType event, gint64 timestamp, guint32 data) -{ - GstRealPad *peer; - gboolean handled = FALSE; - - GST_DEBUG(GST_CAT_EVENT, "have event %d on pad %s:%s\n",(gint)event,GST_DEBUG_PAD_NAME(pad)); - - peer = GST_RPAD_PEER(pad); - if (GST_RPAD_EVENTFUNC(peer)) { - //handled = GST_RPAD_EVENTFUNC(peer) (peer, event, timestamp, data); - } - else { - GST_DEBUG(GST_CAT_EVENT, "there's no event function for peer %s:%s\n",GST_DEBUG_PAD_NAME(peer)); - } - - if (!handled) { - GST_DEBUG(GST_CAT_EVENT, "would proceed with default behavior here\n"); - //gst_pad_event_default(peer,event, timestamp, data); - } -} - +/** + * gst_pad_send_event: + * @pad: the pad to send the event to + * @event: the event to send to the pad. + * + * Send the event to the pad. + * + * Returns: TRUe if the event was handled. + */ gboolean gst_pad_send_event (GstPad *pad, GstEvent *event) { diff --git a/gst/gstpad.h b/gst/gstpad.h index 70f0a39..bfeddb6 100644 --- a/gst/gstpad.h +++ b/gst/gstpad.h @@ -403,16 +403,6 @@ NULL ) NULL ) #endif -#if 1 -gboolean gst_pad_event (GstPad *pad, GstEventType event, gint64 timestamp, guint32 data); -#else -#define gst_pad_event(pad,event,timestamp,data) G_STMT_START{ \ - ( (((GstRealPad *)(pad))->peer->eventhandler) ? \ - (((GstRealPad *)(pad))->peer->eventhandler)((GstPad *)(((GstRealPad *)(pad))->peer),(event),(timestamp),(data)) : \ -FALSE ) -}G_STMT_END -#endif - gboolean gst_pad_send_event (GstPad *pad, GstEvent *event); GstBuffer* gst_pad_peek (GstPad *pad); diff --git a/gst/gstpipeline.h b/gst/gstpipeline.h index 435a1f2..04a4170 100644 --- a/gst/gstpipeline.h +++ b/gst/gstpipeline.h @@ -60,8 +60,6 @@ GType gst_pipeline_get_type (void); GstElement* gst_pipeline_new (const gchar *name); #define gst_pipeline_destroy(pipeline) gst_object_destroy(GST_OBJECT(pipeline)) -void gst_pipeline_iterate (GstPipeline *pipeline); - #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/gst/gstplugin.c b/gst/gstplugin.c index 9f1f140..753c666 100644 --- a/gst/gstplugin.c +++ b/gst/gstplugin.c @@ -274,6 +274,11 @@ gst_plugin_load_all (void) GST_INFO (GST_CAT_PLUGIN_LOADING,"loaded %d plugins", _gst_plugins_seqno); } +/** + * gst_plugin_unload_all: + * + * Unload all plugins in memory. + */ void gst_plugin_unload_all (void) { @@ -391,11 +396,11 @@ gst_plugin_load (const gchar *name) } /** - * gst_plugin_load: + * gst_plugin_load_absolute: * @name: name of plugin to load * * Load the named plugin. Name should be given as - * "libplugin.so". + * "/path/to/plugin/libplugin.so". * * Returns: whether the plugin was loaded or not */ @@ -464,8 +469,10 @@ gst_plugin_register_func (GstPluginDesc *desc, GstPlugin *plugin, GModule *modul } /** - * gst_plugin_load_absolute: - * @name: name of plugin to load + * gst_plugin_load_plugin: + * @plugin: The plugin to load + * + * Load the given plugin. * * Returns: whether or not the plugin loaded */ diff --git a/gst/gstplugin.h b/gst/gstplugin.h index 58eb018..a6bdad7 100644 --- a/gst/gstplugin.h +++ b/gst/gstplugin.h @@ -85,8 +85,6 @@ _gst_plugin_static_init__ ##init (void) \ void _gst_plugin_initialize (void); void _gst_plugin_register_static (GstPluginDesc *desc); -GstPlugin* gst_plugin_new (const gchar *name, gint major, gint minor); - void gst_plugin_add_path (const gchar *path); const gchar* gst_plugin_get_name (GstPlugin *plugin); diff --git a/gst/gstpluginfeature.c b/gst/gstpluginfeature.c index 11021ef..f2f2179 100644 --- a/gst/gstpluginfeature.c +++ b/gst/gstpluginfeature.c @@ -110,7 +110,16 @@ gst_plugin_feature_restore_thyself (GstObject *object, xmlNodePtr parent) } #endif /* GST_DISABLE_REGISTRY */ -void +/** + * gst_plugin_feature_ensure_loaded: + * @feature: the plugin feature to check + * + * Check if the plugin containing the feature is loaded, + * if not, the plugin will be loaded. + * + * Returns: a boolean indicating the feature is loaded. + */ +gboolean gst_plugin_feature_ensure_loaded (GstPluginFeature *feature) { GstPlugin *plugin = (GstPlugin *) (feature->manager); @@ -118,10 +127,18 @@ gst_plugin_feature_ensure_loaded (GstPluginFeature *feature) if (plugin && !gst_plugin_is_loaded (plugin)) { GST_DEBUG (GST_CAT_PLUGIN_LOADING, "loading plugin %s for feature\n", plugin->name); - gst_plugin_load_plugin (plugin); + return gst_plugin_load_plugin (plugin); } + return TRUE; } +/** + * gst_plugin_feature_unload_thyself: + * @feature: the plugin feature to check + * + * Unload the given feature. This will decrease the refcount + * in the plugin and will eventually unload the plugin + */ void gst_plugin_feature_unload_thyself (GstPluginFeature *feature) { diff --git a/gst/gstpluginfeature.h b/gst/gstpluginfeature.h index 6fd92f1..8e3b8b9 100644 --- a/gst/gstpluginfeature.h +++ b/gst/gstpluginfeature.h @@ -60,7 +60,7 @@ struct _GstPluginFeatureClass { /* normal GObject stuff */ GType gst_plugin_feature_get_type (void); -void gst_plugin_feature_ensure_loaded (GstPluginFeature *feature); +gboolean gst_plugin_feature_ensure_loaded (GstPluginFeature *feature); void gst_plugin_feature_unload_thyself (GstPluginFeature *feature); #ifdef __cplusplus diff --git a/gst/gstscheduler.c b/gst/gstscheduler.c index fc4abe0..1c10f13 100644 --- a/gst/gstscheduler.c +++ b/gst/gstscheduler.c @@ -25,6 +25,7 @@ #include "gstscheduler.h" +GType _gst_schedule_type = 0; static int gst_schedule_loopfunc_wrapper (int argc,char *argv[]) @@ -828,10 +829,10 @@ static void gst_schedule_init (GstSchedule *schedule); static GstObjectClass *parent_class = NULL; -GType gst_schedule_get_type(void) { - static GType schedule_type = 0; - - if (!schedule_type) { +GType +gst_schedule_get_type (void) +{ + if (!_gst_schedule_type) { static const GTypeInfo schedule_info = { sizeof(GstScheduleClass), NULL, @@ -844,9 +845,9 @@ GType gst_schedule_get_type(void) { (GInstanceInitFunc)gst_schedule_init, NULL }; - schedule_type = g_type_register_static(GST_TYPE_OBJECT, "GstSchedule", &schedule_info, 0); + _gst_schedule_type = g_type_register_static(GST_TYPE_OBJECT, "GstSchedule", &schedule_info, 0); } - return schedule_type; + return _gst_schedule_type; } static void @@ -870,6 +871,14 @@ gst_schedule_init (GstSchedule *schedule) schedule->iterate = GST_DEBUG_FUNCPTR(gst_schedule_iterate); } +/** + * gst_schedule_new: + * @parent: the parent of the new scheduler + * + * Create a new scheduler for the given parent. + * + * Returns: the new scheduler. + */ GstSchedule* gst_schedule_new(GstElement *parent) { @@ -1083,6 +1092,14 @@ gst_schedule_chain_elements (GstSchedule *sched, GstElement *element1, GstElemen } } +/** + * gst_schedule_pad_connect: + * @sched: the scheduler + * @srcpad: the srcpad to connect + * @sinkpad: the sinkpad to connect to + * + * Connect the srcpad to the given sinkpad. + */ void gst_schedule_pad_connect (GstSchedule *sched, GstPad *srcpad, GstPad *sinkpad) { @@ -1159,6 +1176,14 @@ gst_schedule_chain_recursive_add (GstScheduleChain *chain, GstElement *element) } } +/** + * gst_schedule_pad_disconnect: + * @sched: the scheduler + * @srcpad: the srcpad to disconnect + * @sinkpad: the sinkpad to disconnect from + * + * Disconnect the srcpad to the given sinkpad. + */ void gst_schedule_pad_disconnect (GstSchedule *sched, GstPad *srcpad, GstPad *sinkpad) { @@ -1195,6 +1220,15 @@ gst_schedule_pad_disconnect (GstSchedule *sched, GstPad *srcpad, GstPad *sinkpad } } +/** + * gst_schedule_pad_select: + * @sched: the scheduler + * @padlist: the padlist to select on + * + * register the given padlist for a select operation. + * + * Returns: the pad which received a buffer. + */ GstPad* gst_schedule_pad_select (GstSchedule *sched, GList *padlist) { @@ -1235,6 +1269,13 @@ gst_schedule_pad_select (GstSchedule *sched, GList *padlist) return pad; } +/** + * gst_schedule_add_element: + * @sched: the scheduler + * @element: the element to add to the scheduler + * + * Add an element to the scheduler. + */ void gst_schedule_add_element (GstSchedule *sched, GstElement *element) { @@ -1296,6 +1337,13 @@ gst_schedule_add_element (GstSchedule *sched, GstElement *element) } } +/** + * gst_schedule_enable_element: + * @sched: the scheduler + * @element: the element to enable + * + * Enable an element for scheduling. + */ void gst_schedule_enable_element (GstSchedule *sched, GstElement *element) { @@ -1310,6 +1358,13 @@ gst_schedule_enable_element (GstSchedule *sched, GstElement *element) GST_INFO (GST_CAT_SCHEDULING, "element not found in any chain, not enabling"); } +/** + * gst_schedule_disable_element: + * @sched: the scheduler + * @element: the element to disable + * + * Disable an element for scheduling. + */ void gst_schedule_disable_element (GstSchedule *sched, GstElement *element) { @@ -1324,6 +1379,13 @@ gst_schedule_disable_element (GstSchedule *sched, GstElement *element) } } +/** + * gst_schedule_remove_element: + * @sched: the scheduler + * @element: the element to remove + * + * Remove an element from the scheduler. + */ void gst_schedule_remove_element (GstSchedule *sched, GstElement *element) { @@ -1351,6 +1413,14 @@ gst_schedule_remove_element (GstSchedule *sched, GstElement *element) } } +/** + * gst_schedule_iterate: + * @sched: the scheduler + * + * Perform one iteration on the scheduler. + * + * Returns: a boolean indicating something usefull has happened. + */ gboolean gst_schedule_iterate (GstSchedule *sched) { @@ -1486,7 +1556,12 @@ GST_DEBUG(GST_CAT_SCHEDULING,"there are %d elements in this chain\n",chain->num_ } - +/** + * gst_schedule_show: + * @sched: the scheduler + * + * Dump the state of the scheduler + */ void gst_schedule_show (GstSchedule *sched) { diff --git a/gst/gstscheduler.h b/gst/gstscheduler.h index 641fe22..b65c5ed 100644 --- a/gst/gstscheduler.h +++ b/gst/gstscheduler.h @@ -33,16 +33,22 @@ extern "C" { #endif /* __cplusplus */ -#define GST_TYPE_SCHEDULE \ - (gst_schedule_get_type()) -#define GST_SCHEDULE(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_SCHEDULE,GstSchedule)) -#define GST_SCHEDULE_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_SCHEDULE,GstScheduleClass)) -#define GST_IS_SCHEDULE(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_SCHEDULE)) -#define GST_IS_SCHEDULE_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_SCHEDULE)) +extern GType _gst_schedule_type; + +#define GST_TYPE_SCHEDULE (_gst_schedule_type) +# define GST_IS_SCHEDULE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_SCHEDULE)) +# define GST_IS_SCHEDULE_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_SCHEDULE)) + +#define GST_SCHEDULE_FAST(obj) ((GstSchedule*)(obj)) +#define GST_SCHEDULE_CLASS_FAST(klass) ((GstScheduleClass*)(klass)) + +#ifdef GST_TYPE_PARANOID +# define GST_SCHEDULE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_SCHEDULE, GstSchedule)) +# define GST_SCHEDULE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_SCHEDULE, GstScheduleClass)) +#else +# define GST_SCHEDULE GST_SCHEDULE_FAST +# define GST_SCHEDULE_CLASS GST_SCHEDULE_CLASS_FAST +#endif #define GST_SCHED_PARENT(sched) ((sched)->parent) diff --git a/gst/gsttimecache.c b/gst/gsttimecache.c index 6c804fa..56d3c53 100644 --- a/gst/gsttimecache.c +++ b/gst/gsttimecache.c @@ -85,6 +85,13 @@ gst_timecache_init (GstTimeCache *tc) GST_DEBUG(0, "created new timecache\n"); } +/** + * gst_timecache_new: + * + * Create a new tilecache object + * + * Returns: a new timecache object + */ GstTimeCache * gst_timecache_new() { @@ -95,12 +102,29 @@ gst_timecache_new() return tc; } +/** + * gst_timecache_get_group: + * @tc: the timecache to get the current group from + * + * Get the id of the current group. + * + * Returns: the id of the current group. + */ gint gst_timecache_get_group(GstTimeCache *tc) { return tc->curgroup->groupnum; } +/** + * gst_timecache_new_group: + * @tc: the timecache to create the new group in + * + * Create a new group for the given timecache. It will be + * set as the current group. + * + * Returns: the id of the newly created group. + */ gint gst_timecache_new_group(GstTimeCache *tc) { @@ -110,6 +134,16 @@ gst_timecache_new_group(GstTimeCache *tc) return tc->maxgroup; } +/** + * gst_timecache_set_group: + * @tc: the timecache to set the new group in + * @groupnum: the groupnumber to set + * + * Set the current groupnumber to the given argument. + * + * Returns: TRUE if the operation succeeded, FALSE if the group + * did not exist. + */ gboolean gst_timecache_set_group(GstTimeCache *tc, gint groupnum) { @@ -137,18 +171,42 @@ gst_timecache_set_group(GstTimeCache *tc, gint groupnum) return FALSE; } +/** + * gst_timecache_set_certainty: + * @tc: the timecache to set the certainty on + * @certainty: the certainty to set + * + * Set the certainty of the given timecache. + */ void gst_timecache_set_certainty(GstTimeCache *tc, GstTimeCacheCertainty certainty) { tc->curgroup->certainty = certainty; } +/** + * gst_timecache_get_certainty: + * @tc: the timecache to get the certainty of + * + * Get the certainty of the given timecache. + * + * Returns: the certainty of the timecache. + */ GstTimeCacheCertainty gst_timecache_get_certainty(GstTimeCache *tc) { return tc->curgroup->certainty; } +/** + * gst_timecache_add_entry: + * @tc: the timecache to add the entry to + * @location: the location + * @timestamp: the timestamp + * + * Associate the given timestamp with the given location in the + * timecache. + */ void gst_timecache_add_entry (GstTimeCache *tc, guint64 location, gint64 timestamp) { @@ -169,12 +227,25 @@ gst_timecache_add_entry (GstTimeCache *tc, guint64 location, gint64 timestamp) GST_DEBUG(0, "added entry to timecache group %d\n",tc->curgroup->groupnum); } -gint _gst_timecache_find_location (const GstTimeCacheEntry *entry, const guint64 *location) { +static gint +_gst_timecache_find_location (const GstTimeCacheEntry *entry, const guint64 *location) +{ if (*location < entry->location) return -1; else if (*location > entry->location) return 1; else return 0; } +/** + * gst_timecache_find_location: + * @tc: the timecache to find the timestamp in + * @location: the location + * @timestamp: the timestamp + * + * Look up the associated timestamp for the given location in the + * timecache. + * + * Returns: TRUE if the location was found in the timecache. + */ gboolean gst_timecache_find_location (GstTimeCache *tc, guint64 location, gint64 *timestamp) { @@ -196,12 +267,25 @@ gst_timecache_find_location (GstTimeCache *tc, guint64 location, gint64 *timesta return FALSE; } -gint _gst_timecache_find_timestamp (const GstTimeCacheEntry *entry, const gint64 *timestamp) { +static gint +_gst_timecache_find_timestamp (const GstTimeCacheEntry *entry, const gint64 *timestamp) +{ if (*timestamp < entry->timestamp) return -1; else if (*timestamp > entry->timestamp) return 1; else return 0; } +/** + * gst_timecache_find_timestamp: + * @tc: the timecache to find the location in + * @location: the location + * @timestamp: the timestamp + * + * Look up the associated location for the given timestamp in the + * timecache. + * + * Returns: TRUE if the timestamp was found in the timecache. + */ gboolean gst_timecache_find_timestamp (GstTimeCache *tc, gint64 timestamp, guint64 *location) { diff --git a/gst/gsttimecache.h b/gst/gsttimecache.h index f4fa72c..d79818e 100644 --- a/gst/gsttimecache.h +++ b/gst/gsttimecache.h @@ -56,19 +56,19 @@ struct _GstTimeCacheEntry { }; struct _GstTimeCacheGroup { - // unique ID of group in cache + /* unique ID of group in cache */ gint groupnum; - // list of entries + /* list of entries */ GList *entries; - // the certainty level of the group + /* the certainty level of the group */ GstTimeCacheCertainty certainty; - // peer group that contains more certain entries + /* peer group that contains more certain entries */ gint peergroup; - // range variables + /* range variables */ gint64 mintimestamp,maxtimestamp; guint64 minlocation,maxlocation; }; diff --git a/gst/gsttype.c b/gst/gsttype.c index feeac26..b6bd195 100644 --- a/gst/gsttype.c +++ b/gst/gsttype.c @@ -109,6 +109,14 @@ gst_typefactory_init (GstTypeFactory *factory) _gst_typefactories = g_list_prepend (_gst_typefactories, factory); } +/** + * gst_typefactory_new: + * @definition: the definition to use + * + * Creata a new typefactory from the given definition. + * + * Returns: the new typefactory + */ GstTypeFactory* gst_typefactory_new (GstTypeDefinition *definition) { @@ -326,12 +334,12 @@ gst_type_typefind_dummy (GstBuffer *buffer, gpointer priv) GST_DEBUG (GST_CAT_TYPES,"gsttype: need to load typefind function for %s\n", factory->mime); - gst_plugin_feature_ensure_loaded (GST_PLUGIN_FEATURE (factory)); - - if (factory->typefindfunc) { - GstCaps *res = factory->typefindfunc (buffer, factory); - if (res) - return res; + if (gst_plugin_feature_ensure_loaded (GST_PLUGIN_FEATURE (factory))) { + if (factory->typefindfunc) { + GstCaps *res = factory->typefindfunc (buffer, factory); + if (res) + return res; + } } return NULL; diff --git a/gst/gstutils.c b/gst/gstutils.c index 0b66685..b119a86 100644 --- a/gst/gstutils.c +++ b/gst/gstutils.c @@ -40,15 +40,15 @@ * Returns: the property of the object */ gint -gst_util_get_int_arg (GObject *object, const gchar *argname) +gst_util_get_int_arg (GObject * object, const gchar * argname) { GValue value; ZERO (value); g_value_init (&value, G_TYPE_INT); - g_object_get_property(G_OBJECT(object),argname,&value); + g_object_get_property (G_OBJECT (object), argname, &value); - return g_value_get_int(&value); + return g_value_get_int (&value); } /** @@ -61,15 +61,15 @@ gst_util_get_int_arg (GObject *object, const gchar *argname) * Returns: the property of the object */ gint -gst_util_get_bool_arg (GObject *object, const gchar *argname) +gst_util_get_bool_arg (GObject * object, const gchar * argname) { GValue value; ZERO (value); g_value_init (&value, G_TYPE_BOOLEAN); - g_object_get_property(G_OBJECT(object),argname,&value); + g_object_get_property (G_OBJECT (object), argname, &value); - return g_value_get_boolean(&value); + return g_value_get_boolean (&value); } /** @@ -82,15 +82,15 @@ gst_util_get_bool_arg (GObject *object, const gchar *argname) * Returns: the property of the object */ glong -gst_util_get_long_arg (GObject *object, const gchar *argname) +gst_util_get_long_arg (GObject * object, const gchar * argname) { GValue value; ZERO (value); g_value_init (&value, G_TYPE_LONG); - g_object_get_property(G_OBJECT(object),argname,&value); + g_object_get_property (G_OBJECT (object), argname, &value); - return g_value_get_long(&value); + return g_value_get_long (&value); } /** @@ -103,15 +103,15 @@ gst_util_get_long_arg (GObject *object, const gchar *argname) * Returns: the property of the object */ gfloat -gst_util_get_float_arg (GObject *object, const gchar *argname) +gst_util_get_float_arg (GObject * object, const gchar * argname) { GValue value; ZERO (value); g_value_init (&value, G_TYPE_FLOAT); - g_object_get_property(G_OBJECT(object),argname,&value); + g_object_get_property (G_OBJECT (object), argname, &value); - return g_value_get_float(&value); + return g_value_get_float (&value); } /** @@ -123,16 +123,16 @@ gst_util_get_float_arg (GObject *object, const gchar *argname) * * Returns: the property of the object */ -gdouble -gst_util_get_double_arg (GObject *object, const gchar *argname) +gdouble +gst_util_get_double_arg (GObject * object, const gchar * argname) { GValue value; ZERO (value); g_value_init (&value, G_TYPE_DOUBLE); - g_object_get_property(G_OBJECT(object),argname,&value); + g_object_get_property (G_OBJECT (object), argname, &value); - return g_value_get_double(&value); + return g_value_get_double (&value); } /** @@ -144,16 +144,16 @@ gst_util_get_double_arg (GObject *object, const gchar *argname) * * Returns: the property of the object */ - const gchar* -gst_util_get_string_arg (GObject *object, const gchar *argname) +const gchar * +gst_util_get_string_arg (GObject * object, const gchar * argname) { GValue value; ZERO (value); g_value_init (&value, G_TYPE_STRING); - g_object_get_property(G_OBJECT(object),argname,&value); + g_object_get_property (G_OBJECT (object), argname, &value); - return g_value_get_string(&value); // memleak? + return g_value_get_string (&value); // memleak? } /** @@ -166,15 +166,15 @@ gst_util_get_string_arg (GObject *object, const gchar *argname) * Returns: the property of the object */ gpointer -gst_util_get_pointer_arg (GObject *object, const gchar *argname) +gst_util_get_pointer_arg (GObject * object, const gchar * argname) { GValue value; ZERO (value); g_value_init (&value, G_TYPE_POINTER); - g_object_get_property(G_OBJECT(object),argname,&value); + g_object_get_property (G_OBJECT (object), argname, &value); - return g_value_get_pointer(&value); + return g_value_get_pointer (&value); } /** @@ -206,24 +206,24 @@ gst_util_get_widget_property (GObject *object, const gchar *argname) * * Dumps the memory block into a hex representation. Useful for debugging. */ -void -gst_util_dump_mem (guchar *mem, guint size) +void +gst_util_dump_mem (guchar * mem, guint size) { guint i, j; - i = j =0; - while (iflags is %d, paramspec->value_type is %d\n", - paramspec->flags,paramspec->value_type); + GST_DEBUG (0, "paramspec->flags is %d, paramspec->value_type is %d\n", + paramspec->flags, paramspec->value_type); if (paramspec->flags & G_PARAM_WRITABLE) { switch (paramspec->value_type) { - case G_TYPE_STRING: - g_object_set (G_OBJECT (object), name, value, NULL); - break; - case G_TYPE_ENUM: - case G_TYPE_INT: { - gint i; - sscanf (value, "%d", &i); - g_object_set (G_OBJECT (object), name, i, NULL); + case G_TYPE_STRING: + g_object_set (G_OBJECT (object), name, value, NULL); + break; + case G_TYPE_ENUM: + case G_TYPE_INT:{ + gint i; + + sscanf (value, "%d", &i); + g_object_set (G_OBJECT (object), name, i, NULL); break; } - case G_TYPE_UINT: { - guint i; - sscanf (value, "%u", &i); - g_object_set (G_OBJECT (object), name, i, NULL); + case G_TYPE_UINT:{ + guint i; + + sscanf (value, "%u", &i); + g_object_set (G_OBJECT (object), name, i, NULL); break; } - case G_TYPE_LONG: { + case G_TYPE_LONG:{ glong i; + sscanf (value, "%ld", &i); - g_object_set (G_OBJECT (object), name, i, NULL); + g_object_set (G_OBJECT (object), name, i, NULL); break; } - case G_TYPE_ULONG: { + case G_TYPE_ULONG:{ gulong i; + sscanf (value, "%lu", &i); - g_object_set (G_OBJECT (object), name, i, NULL); + g_object_set (G_OBJECT (object), name, i, NULL); break; } - case G_TYPE_BOOLEAN: { + case G_TYPE_BOOLEAN:{ gboolean i = FALSE; - if (!strncmp ("true", value, 4)) i = TRUE; - g_object_set (G_OBJECT (object), name, i, NULL); + + if (!strncmp ("true", value, 4)) + i = TRUE; + g_object_set (G_OBJECT (object), name, i, NULL); break; } - case G_TYPE_CHAR: { + case G_TYPE_CHAR:{ gchar i; + sscanf (value, "%c", &i); - g_object_set (G_OBJECT (object), name, i, NULL); + g_object_set (G_OBJECT (object), name, i, NULL); break; } - case G_TYPE_UCHAR: { + case G_TYPE_UCHAR:{ guchar i; + sscanf (value, "%c", &i); - g_object_set (G_OBJECT (object), name, i, NULL); + g_object_set (G_OBJECT (object), name, i, NULL); break; } - case G_TYPE_FLOAT: { + case G_TYPE_FLOAT:{ gfloat i; + sscanf (value, "%f", &i); - g_object_set (G_OBJECT (object), name, i, NULL); + g_object_set (G_OBJECT (object), name, i, NULL); break; } - case G_TYPE_DOUBLE: { + case G_TYPE_DOUBLE:{ gfloat i; + sscanf (value, "%g", &i); - g_object_set (G_OBJECT (object), name, (gdouble)i, NULL); + g_object_set (G_OBJECT (object), name, (gdouble) i, NULL); break; } - default: - if (G_IS_PARAM_SPEC_ENUM(paramspec)) { - gint i; - sscanf (value, "%d", &i); - g_object_set (G_OBJECT (object), name, i, NULL); + default: + if (G_IS_PARAM_SPEC_ENUM (paramspec)) { + gint i; + + sscanf (value, "%d", &i); + g_object_set (G_OBJECT (object), name, i, NULL); } else if (paramspec->value_type == GST_TYPE_FILENAME) { - g_object_set (G_OBJECT (object), name, value, NULL); + g_object_set (G_OBJECT (object), name, value, NULL); } break; } @@ -336,140 +347,150 @@ gst_util_set_object_arg (GObject *object, const gchar *name, const gchar *valu #include "gstprops.h" #include "gstpropsprivate.h" -static void string_append_indent (GString *str, gint count) +static void +string_append_indent (GString * str, gint count) { gint xx; - for (xx=0; xx < count; xx++) + + for (xx = 0; xx < count; xx++) g_string_append_c (str, ' '); } -static void -gst_print_props (GString *buf, gint indent, - GList *props, gboolean showname) +static void +gst_print_props (GString * buf, gint indent, GList * props, gboolean showname) { GList *elem; guint width = 0; - + if (showname) - for (elem = props; elem; elem = g_list_next (elem)) - { - GstPropsEntry *prop = elem->data; - const gchar *name = g_quark_to_string (prop->propid); + for (elem = props; elem; elem = g_list_next (elem)) { + GstPropsEntry *prop = elem->data; + const gchar *name = g_quark_to_string (prop->propid); - if (width < strlen (name)) - width = strlen (name); - } + if (width < strlen (name)) + width = strlen (name); + } - for (elem = props; elem; elem = g_list_next (elem)) - { - GstPropsEntry *prop = elem->data; + for (elem = props; elem; elem = g_list_next (elem)) { + GstPropsEntry *prop = elem->data; - string_append_indent (buf, indent); - if (showname) - { - const gchar *name = g_quark_to_string (prop->propid); - - g_string_append (buf, name); - string_append_indent (buf, 2 + width - strlen (name)); - } + string_append_indent (buf, indent); + if (showname) { + const gchar *name = g_quark_to_string (prop->propid); + + g_string_append (buf, name); + string_append_indent (buf, 2 + width - strlen (name)); + } - switch (prop->propstype) { + switch (prop->propstype) { case GST_PROPS_INT_ID: g_string_append_printf (buf, "%d (int)\n", prop->data.int_data); break; case GST_PROPS_INT_RANGE_ID: g_string_append_printf (buf, "%d - %d (int)\n", - prop->data.int_range_data.min, - prop->data.int_range_data.max); + prop->data.int_range_data.min, prop->data.int_range_data.max); break; case GST_PROPS_FLOAT_ID: g_string_append_printf (buf, "%f (float)\n", prop->data.float_data); - break; + break; case GST_PROPS_FLOAT_RANGE_ID: g_string_append_printf (buf, "%f - %f (float)\n", - prop->data.float_range_data.min, - prop->data.float_range_data.max); + prop->data.float_range_data.min, prop->data.float_range_data.max); break; case GST_PROPS_BOOL_ID: - g_string_append_printf (buf, "%s\n", - prop->data.bool_data ? "TRUE" : "FALSE"); + g_string_append_printf (buf, "%s\n", prop->data.bool_data ? "TRUE" : "FALSE"); break; case GST_PROPS_STRING_ID: g_string_append_printf (buf, "\"%s\"\n", prop->data.string_data.string); break; case GST_PROPS_FOURCC_ID: g_string_append_printf (buf, "'%c%c%c%c' (fourcc)\n", - prop->data.fourcc_data & 0xff, - prop->data.fourcc_data>>8 & 0xff, - prop->data.fourcc_data>>16 & 0xff, - prop->data.fourcc_data>>24 & 0xff); + prop->data.fourcc_data & 0xff, + prop->data.fourcc_data >> 8 & 0xff, + prop->data.fourcc_data >> 16 & 0xff, + prop->data.fourcc_data >> 24 & 0xff); break; case GST_PROPS_LIST_ID: - gst_print_props (buf, indent+2, prop->data.list_data.entries, FALSE); + gst_print_props (buf, indent + 2, prop->data.list_data.entries, FALSE); break; default: g_string_append_printf (buf, "unknown proptype %d\n", prop->propstype); break; - } + } } } -void gst_print_pad_caps (GString *buf, gint indent, GstPad *pad) +/** + * gst_print_pad_caps: + * @buf: the buffer to print the caps in + * @indent: initial indentation + * @pad: the pad to print the caps from + * + * Write the pad capabilities in a human readable format into + * the given GString. + */ +void +gst_print_pad_caps (GString * buf, gint indent, GstPad * pad) { GstRealPad *realpad; GstCaps *caps; - realpad = GST_PAD_REALIZE(pad); + realpad = GST_PAD_REALIZE (pad); caps = realpad->caps; - if (!caps) - { - string_append_indent (buf, indent); - g_string_printf (buf, "%s:%s has no capabilities", - GST_DEBUG_PAD_NAME (pad)); - } - else - { - gint capx = 0; + if (!caps) { + string_append_indent (buf, indent); + g_string_printf (buf, "%s:%s has no capabilities", GST_DEBUG_PAD_NAME (pad)); + } + else { + gint capx = 0; - while (caps) { - GstType *type; + while (caps) { + GstType *type; - string_append_indent (buf, indent); - g_string_append_printf (buf, "Cap[%d]: %s\n", capx++, caps->name); + string_append_indent (buf, indent); + g_string_append_printf (buf, "Cap[%d]: %s\n", capx++, caps->name); - type = gst_type_find_by_id (caps->id); - string_append_indent (buf, indent+2); - g_string_append_printf (buf, "MIME type: %s\n", - type->mime? type->mime : "unknown/unknown"); + type = gst_type_find_by_id (caps->id); + string_append_indent (buf, indent + 2); + g_string_append_printf (buf, "MIME type: %s\n", type->mime ? type->mime : "unknown/unknown"); - if (caps->properties) - gst_print_props (buf, indent + 4, - caps->properties->properties, TRUE); + if (caps->properties) + gst_print_props (buf, indent + 4, caps->properties->properties, TRUE); - caps = caps->next; - } + caps = caps->next; } + } } -void gst_print_element_args (GString *buf, gint indent, GstElement *element) +/** + * gst_print_element_args: + * @buf: the buffer to print the args in + * @indent: initial indentation + * @element: the element to print the args of + * + * Print the element argument in a human readable format in the given + * GString. + */ +void +gst_print_element_args (GString * buf, gint indent, GstElement * element) { gint num_properties; gint px; guint width; - GParamSpec **property_specs = - g_object_class_list_properties (G_OBJECT_GET_CLASS (element), - &num_properties); - - width=0; - for (px=0; px < num_properties; px++) { + GParamSpec **property_specs = g_object_class_list_properties (G_OBJECT_GET_CLASS (element), + &num_properties); + + width = 0; + for (px = 0; px < num_properties; px++) { GParamSpec *param = property_specs[px]; + if (width < strlen (param->name)) width = strlen (param->name); } - for (px=0; px < num_properties; px++) { + for (px = 0; px < num_properties; px++) { GParamSpec *param = property_specs[px]; GValue value; @@ -492,49 +513,57 @@ void gst_print_element_args (GString *buf, gint indent, GstElement *element) #endif g_string_append_printf (buf, "%s (%s)", - values [g_value_get_enum (&value)].value_nick, - g_type_name (G_VALUE_TYPE (&value))); + values[g_value_get_enum (&value)].value_nick, + g_type_name (G_VALUE_TYPE (&value))); } - else + else { switch (G_VALUE_TYPE (&value)) { - case G_TYPE_STRING: - g_string_append_printf (buf, "\"%s\"", g_value_get_string (&value)); - break; - case G_TYPE_BOOLEAN: - g_string_append (buf, g_value_get_boolean (&value)? "TRUE":"FALSE"); - break; - case G_TYPE_ULONG:{ - gulong val = g_value_get_ulong (&value); - g_string_append_printf (buf, "%lu (0x%lx)", val, val); - break;} - case G_TYPE_LONG:{ - glong val = g_value_get_long (&value); - g_string_append_printf (buf, "%ld (0x%lx)", val, val); - break;} - case G_TYPE_UINT:{ - guint val = g_value_get_uint (&value); - g_string_append_printf (buf, "%u (0x%x)", val, val); - break;} - case G_TYPE_INT:{ - gint val = g_value_get_int (&value); - g_string_append_printf (buf, "%d (0x%x)", val, val); - break;} - case G_TYPE_FLOAT: - g_string_append_printf (buf, "%f", g_value_get_float (&value)); - break; - case G_TYPE_DOUBLE: - g_string_append_printf (buf, "%f", g_value_get_double (&value)); - break; - default: - g_string_append_printf (buf, "unknown value_type %d", G_VALUE_TYPE (&value)); - break; + case G_TYPE_STRING: + g_string_append_printf (buf, "\"%s\"", g_value_get_string (&value)); + break; + case G_TYPE_BOOLEAN: + g_string_append (buf, g_value_get_boolean (&value) ? "TRUE" : "FALSE"); + break; + case G_TYPE_ULONG:{ + gulong val = g_value_get_ulong (&value); + + g_string_append_printf (buf, "%lu (0x%lx)", val, val); + break; + } + case G_TYPE_LONG:{ + glong val = g_value_get_long (&value); + + g_string_append_printf (buf, "%ld (0x%lx)", val, val); + break; + } + case G_TYPE_UINT:{ + guint val = g_value_get_uint (&value); + + g_string_append_printf (buf, "%u (0x%x)", val, val); + break; + } + case G_TYPE_INT:{ + gint val = g_value_get_int (&value); + + g_string_append_printf (buf, "%d (0x%x)", val, val); + break; + } + case G_TYPE_FLOAT: + g_string_append_printf (buf, "%f", g_value_get_float (&value)); + break; + case G_TYPE_DOUBLE: + g_string_append_printf (buf, "%f", g_value_get_double (&value)); + break; + default: + g_string_append_printf (buf, "unknown value_type %d", G_VALUE_TYPE (&value)); + break; } + } g_string_append_c (buf, '\n'); if (G_VALUE_TYPE (&value)) g_value_unset (&value); } - g_free (property_specs); } diff --git a/gst/gstutils.h b/gst/gstutils.h index e7e1fa5..6a71367 100644 --- a/gst/gstutils.h +++ b/gst/gstutils.h @@ -45,8 +45,8 @@ void gst_util_set_object_arg (GObject *object, const gchar *name, const gchar void gst_util_dump_mem (guchar *mem, guint size); -void gst_print_pad_caps (GString *buf, gint indent, GstPad *pad); -void gst_print_element_args (GString *buf, gint indent, GstElement *element); +void gst_print_pad_caps (GString *buf, gint indent, GstPad *pad); +void gst_print_element_args (GString *buf, gint indent, GstElement *element); #ifdef __cplusplus } diff --git a/plugins/elements/Makefile.am b/plugins/elements/Makefile.am index f50e4f7..1e165b8 100644 --- a/plugins/elements/Makefile.am +++ b/plugins/elements/Makefile.am @@ -39,8 +39,7 @@ noinst_HEADERS = \ gstfdsink.h \ gstpipefilter.h \ gsttee.h \ - gstaggregator.h \ - gstsinesrc.h + gstaggregator.h CFLAGS += -O2 -Wall LDFLAGS += -lm diff --git a/plugins/elements/gstdisksrc.c b/plugins/elements/gstdisksrc.c index ffe1b35..11e2cba 100644 --- a/plugins/elements/gstdisksrc.c +++ b/plugins/elements/gstdisksrc.c @@ -290,10 +290,7 @@ gst_disksrc_get (GstPad *pad) /* deal with EOF state */ if (src->curoffset >= src->size) { GST_DEBUG (0,"map offset %ld >= size %ld --> eos\n", src->curoffset, src->size); - gst_pad_event(pad, GST_EVENT_EOS, 0LL, 0); - buf = gst_buffer_new(); - GST_BUFFER_FLAG_SET (buf, GST_BUFFER_EOS); - return buf; + return GST_BUFFER(gst_event_new (GST_EVENT_EOS)); } // FIXME use a bufferpool diff --git a/plugins/elements/gstmultidisksrc.c b/plugins/elements/gstmultidisksrc.c index 9a8b28f..a09adcf 100644 --- a/plugins/elements/gstmultidisksrc.c +++ b/plugins/elements/gstmultidisksrc.c @@ -203,8 +203,7 @@ gst_multidisksrc_get (GstPad *pad) gst_multidisksrc_close_file(src); if (!src->listptr) { - gst_pad_event (pad, GST_EVENT_EOS, 0LL, 0); - return FALSE; + return GST_BUFFER(gst_event_new (GST_EVENT_EOS)); } list = src->listptr; diff --git a/plugins/elements/gstmultifilesrc.c b/plugins/elements/gstmultifilesrc.c index 9a8b28f..a09adcf 100644 --- a/plugins/elements/gstmultifilesrc.c +++ b/plugins/elements/gstmultifilesrc.c @@ -203,8 +203,7 @@ gst_multidisksrc_get (GstPad *pad) gst_multidisksrc_close_file(src); if (!src->listptr) { - gst_pad_event (pad, GST_EVENT_EOS, 0LL, 0); - return FALSE; + return GST_BUFFER(gst_event_new (GST_EVENT_EOS)); } list = src->listptr; diff --git a/plugins/elements/gstpipefilter.c b/plugins/elements/gstpipefilter.c index 86e5ac0..74ec480 100644 --- a/plugins/elements/gstpipefilter.c +++ b/plugins/elements/gstpipefilter.c @@ -64,7 +64,7 @@ static void gst_pipefilter_get_property (GObject *object, guint prop_id, GVal static GstBuffer* gst_pipefilter_get (GstPad *pad); static void gst_pipefilter_chain (GstPad *pad, GstBuffer *buf); -static gboolean gst_pipefilter_handle_event (GstPad *pad, void *event); +static gboolean gst_pipefilter_handle_event (GstPad *pad, GstEvent *event); static GstElementStateReturn gst_pipefilter_change_state (GstElement *element); @@ -134,7 +134,7 @@ gst_pipefilter_init (GstPipefilter *pipefilter) } static gboolean -gst_pipefilter_handle_event (GstPad *pad, void *event) +gst_pipefilter_handle_event (GstPad *pad, GstEvent *event) { GstPipefilter *pipefilter; @@ -180,8 +180,8 @@ gst_pipefilter_get (GstPad *pad) } /* if we didn't get as many bytes as we asked for, we're at EOF */ if (readbytes == 0) { - gst_pad_event (pad, GST_EVENT_EOS, 0LL, 0); - return NULL; + return GST_BUFFER(gst_event_new (GST_EVENT_EOS)); + } GST_BUFFER_OFFSET(newbuf) = pipefilter->curoffset; diff --git a/plugins/elements/gstsinesrc.c b/plugins/elements/gstsinesrc.c deleted file mode 100644 index 75ca6ba..0000000 --- a/plugins/elements/gstsinesrc.c +++ /dev/null @@ -1,452 +0,0 @@ -/* GStreamer - * Copyright (C) 1999,2000 Erik Walthinsen - * 2000 Wim Taymans - * 2001 Steve Baker - * - * gstsinesrc.c: - * - * 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. - */ - -#include -#include -#include - -#include - - -GstElementDetails gst_sinesrc_details = { - "Sine-wave src", - "Source/Audio", - "Create a sine wave of a given frequency and volume", - VERSION, - "Erik Walthinsen ", - "(C) 1999", -}; - - -/* SineSrc signals and args */ -enum { - /* FILL ME */ - LAST_SIGNAL -}; - -enum { - ARG_0, - ARG_VOLUME, - ARG_FORMAT, - ARG_SAMPLERATE, - ARG_FREQ, - ARG_TABLESIZE, - ARG_BUFFER_SIZE, -}; - -// FIXME: this is not core business... -GST_PADTEMPLATE_FACTORY (sinesrc_src_factory, - "src", - GST_PAD_SRC, - GST_PAD_ALWAYS, - GST_CAPS_NEW ( - "sinesrc_src", - "audio/raw", - "format", GST_PROPS_STRING ("int"), - "law", GST_PROPS_INT (0), - "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, 48000), - "channels", GST_PROPS_INT (1) - ) -); - -static void gst_sinesrc_class_init (GstSineSrcClass *klass); -static void gst_sinesrc_init (GstSineSrc *src); -static GstPadNegotiateReturn gst_sinesrc_negotiate (GstPad *pad, GstCaps **caps, gpointer *data); -static void gst_sinesrc_set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec); -static void gst_sinesrc_get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec); -//static gboolean gst_sinesrc_change_state(GstElement *element, -// GstElementState state); -//static void gst_sinesrc_close_audio(GstSineSrc *src); -//static gboolean gst_sinesrc_open_audio(GstSineSrc *src); - -static void gst_sinesrc_update_volume(GValue *value, gpointer data); -static void gst_sinesrc_update_freq(GValue *value, gpointer data); -static void gst_sinesrc_populate_sinetable (GstSineSrc *src); -static inline void gst_sinesrc_update_table_inc (GstSineSrc *src); -static inline void gst_sinesrc_update_vol_scale (GstSineSrc *src); -static void gst_sinesrc_force_caps (GstSineSrc *src); - -static GstBuffer* gst_sinesrc_get (GstPad *pad); - -static GstElementClass *parent_class = NULL; -//static guint gst_sinesrc_signals[LAST_SIGNAL] = { 0 }; - -GType -gst_sinesrc_get_type (void) -{ - static GType sinesrc_type = 0; - - if (!sinesrc_type) { - static const GTypeInfo sinesrc_info = { - sizeof(GstSineSrcClass), - NULL, - NULL, - (GClassInitFunc)gst_sinesrc_class_init, - NULL, - NULL, - sizeof(GstSineSrc), - 0, - (GInstanceInitFunc)gst_sinesrc_init, - }; - sinesrc_type = g_type_register_static (GST_TYPE_ELEMENT, "GstSineSrc", &sinesrc_info, 0); - } - return sinesrc_type; -} - -static void -gst_sinesrc_class_init (GstSineSrcClass *klass) -{ - GObjectClass *gobject_class; - GstElementClass *gstelement_class; - - gobject_class = (GObjectClass*)klass; - gstelement_class = (GstElementClass*)klass; - - parent_class = g_type_class_ref(GST_TYPE_ELEMENT); - - g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_VOLUME, - g_param_spec_double("volume","volume","volume", - 0.0, 1.0, 0.0,G_PARAM_READWRITE)); // CHECKME - g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_FORMAT, - g_param_spec_int("format","format","format", - G_MININT,G_MAXINT,0,G_PARAM_READWRITE)); // CHECKME - g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_SAMPLERATE, - g_param_spec_int("samplerate","samplerate","samplerate", - G_MININT,G_MAXINT,0,G_PARAM_READWRITE)); // CHECKME - g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_TABLESIZE, - g_param_spec_int("tablesize","tablesize","tablesize", - G_MININT,G_MAXINT,0,G_PARAM_READWRITE)); // CHECKME - g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_FREQ, - g_param_spec_double("freq","freq","freq", - 0.0,G_MAXDOUBLE, 440.0,G_PARAM_READWRITE)); // CHECKME - g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_BUFFER_SIZE, - g_param_spec_int("buffersize","buffersize","buffersize", - 0, G_MAXINT, 1024, G_PARAM_READWRITE)); - - gobject_class->set_property = gst_sinesrc_set_property; - gobject_class->get_property = gst_sinesrc_get_property; - -// gstelement_class->change_state = gst_sinesrc_change_state; -} - -static void -gst_sinesrc_init (GstSineSrc *src) -{ - GstElement *element = GST_ELEMENT(src); - GstDParamManager *dpman; - - src->srcpad = gst_pad_new_from_template ( - GST_PADTEMPLATE_GET (sinesrc_src_factory), "src"); - gst_element_add_pad(GST_ELEMENT(src), src->srcpad); - gst_pad_set_negotiate_function (src->srcpad, gst_sinesrc_negotiate); - - gst_pad_set_get_function(src->srcpad, gst_sinesrc_get); - - src->format = 16; - src->samplerate = 44100; - - src->newcaps = TRUE; - - src->table_pos = 0.0; - src->table_size = 1024; - src->buffer_size=1024; - - src->seq = 0; - - dpman = gst_dpman_new ("sinesrc_dpman", GST_ELEMENT(src)); - gst_dpman_add_required_dparam (dpman, "volume", G_TYPE_FLOAT, gst_sinesrc_update_volume, src); - gst_dpman_add_required_dparam (dpman, "freq", G_TYPE_FLOAT, gst_sinesrc_update_freq, src); - - gst_dpman_set_rate_change_pad(dpman, src->srcpad); - - GST_ELEMENT_DPARAM_MANAGER(element) = dpman; - - gst_sinesrc_update_vol_scale(src); - - gst_sinesrc_populate_sinetable(src); - gst_sinesrc_update_table_inc(src); - -} - -static GstPadNegotiateReturn -gst_sinesrc_negotiate (GstPad *pad, GstCaps **caps, gpointer *data) -{ - GstSineSrc *src; - - if (*caps) { - g_return_val_if_fail (pad != NULL, GST_PAD_NEGOTIATE_FAIL); - src = GST_SINESRC(gst_pad_get_parent (pad)); - src->samplerate = gst_caps_get_int (*caps, "rate"); - gst_sinesrc_update_table_inc(src); - return GST_PAD_NEGOTIATE_AGREE; - } - - return GST_PAD_NEGOTIATE_FAIL; -} - -static GstBuffer * -gst_sinesrc_get(GstPad *pad) -{ - GstSineSrc *src; - GstBuffer *buf; - GstDParamManager *dpman; - - gint16 *samples; - gint i=0, frame_countdown; - - g_return_val_if_fail (pad != NULL, NULL); - src = GST_SINESRC(gst_pad_get_parent (pad)); - - buf = gst_buffer_new(); - g_return_val_if_fail (buf, NULL); - samples = g_new(gint16, src->buffer_size); - GST_BUFFER_DATA(buf) = (gpointer) samples; - GST_BUFFER_SIZE(buf) = 2 * src->buffer_size; - - dpman = GST_ELEMENT_DPARAM_MANAGER(GST_ELEMENT(src)); - frame_countdown = GST_DPMAN_FIRST_COUNTDOWN(dpman, src->buffer_size, 0LL); - - while(GST_DPMAN_COUNTDOWN(dpman, frame_countdown, i)) { - src->table_lookup = (gint)(src->table_pos); - src->table_lookup_next = src->table_lookup + 1; - src->table_interp = src->table_pos - src->table_lookup; - - // wrap the array lookups if we're out of bounds - if (src->table_lookup_next >= src->table_size){ - src->table_lookup_next -= src->table_size; - if (src->table_lookup >= src->table_size){ - src->table_lookup -= src->table_size; - src->table_pos -= src->table_size; - } - } - - src->table_pos += src->table_inc; - - //no interpolation - //samples[i] = src->table_data[src->table_lookup] - // * src->vol_scale; - - //linear interpolation - samples[i++] = ((src->table_interp - *(src->table_data[src->table_lookup_next] - -src->table_data[src->table_lookup] - ) - )+src->table_data[src->table_lookup] - )* src->vol_scale; - } - - if (src->newcaps) { - gst_sinesrc_force_caps(src); - } - - return buf; -} - -static void -gst_sinesrc_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) -{ - GstSineSrc *src; - - /* it's not null if we got it, but it might not be ours */ - g_return_if_fail(GST_IS_SINESRC(object)); - src = GST_SINESRC(object); - - switch (prop_id) { - case ARG_VOLUME: - src->volume = (gfloat)g_value_get_double (value); - gst_sinesrc_update_vol_scale(src); - break; - case ARG_FORMAT: - src->format = g_value_get_int (value); - src->newcaps=TRUE; - break; - case ARG_SAMPLERATE: - src->samplerate = g_value_get_int (value); - src->newcaps=TRUE; - gst_sinesrc_update_table_inc(src); - break; - case ARG_FREQ: { - if (g_value_get_double (value) <= 0.0 || g_value_get_double (value) > src->samplerate/2) - break; - src->freq = (gfloat)g_value_get_double (value); - gst_sinesrc_update_table_inc(src); - break; - case ARG_TABLESIZE: - src->table_size = g_value_get_int (value); - gst_sinesrc_populate_sinetable(src); - gst_sinesrc_update_table_inc(src); - break; - case ARG_BUFFER_SIZE: - src->buffer_size = g_value_get_int (value); - break; - } - default: - break; - } -} - -static void -gst_sinesrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) -{ - GstSineSrc *src; - - /* it's not null if we got it, but it might not be ours */ - g_return_if_fail(GST_IS_SINESRC(object)); - src = GST_SINESRC(object); - - switch (prop_id) { - case ARG_VOLUME: - g_value_set_double (value, (gdouble)(src->volume)); - break; - case ARG_FORMAT: - g_value_set_int (value, src->format); - break; - case ARG_SAMPLERATE: - g_value_set_int (value, src->samplerate); - break; - case ARG_FREQ: - g_value_set_double (value, (gdouble)(src->freq)); - break; - case ARG_TABLESIZE: - g_value_set_int (value, src->table_size); - break; - case ARG_BUFFER_SIZE: - g_value_set_int (value, src->buffer_size); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -/* -static gboolean gst_sinesrc_change_state(GstElement *element, - GstElementState state) { - g_return_if_fail(GST_IS_SINESRC(element)); - - switch (state) { - case GST_STATE_RUNNING: - if (!gst_sinesrc_open_audio(GST_SINESRC(element))) - return FALSE; - break; - case ~GST_STATE_RUNNING: - gst_sinesrc_close_audio(GST_SINESRC(element)); - break; - default: - break; - } - - if (GST_ELEMENT_CLASS(parent_class)->change_state) - return GST_ELEMENT_CLASS(parent_class)->change_state(element,state); - return TRUE; -} -*/ - -static void -gst_sinesrc_populate_sinetable (GstSineSrc *src) -{ - gint i; - gdouble pi2scaled = M_PI * 2 / src->table_size; - gfloat *table = g_new(gfloat, src->table_size); - - for(i=0 ; i < src->table_size ; i++){ - table[i] = (gfloat)sin(i * pi2scaled); - } - - g_free(src->table_data); - src->table_data = table; -} - -static void -gst_sinesrc_update_volume(GValue *value, gpointer data) -{ - GstSineSrc *src = (GstSineSrc*)data; - g_return_if_fail(GST_IS_SINESRC(src)); - - src->volume = g_value_get_float(value); - src->vol_scale = 32767.0 * src->volume; -} - -static void -gst_sinesrc_update_freq(GValue *value, gpointer data) -{ - GstSineSrc *src = (GstSineSrc*)data; - g_return_if_fail(GST_IS_SINESRC(src)); - - src->freq = g_value_get_float(value); - src->table_inc = src->table_size * src->freq / src->samplerate; -} - -static inline void -gst_sinesrc_update_table_inc (GstSineSrc *src) -{ - src->table_inc = src->table_size * src->freq / src->samplerate; -} - -static inline void -gst_sinesrc_update_vol_scale (GstSineSrc *src) -{ - src->vol_scale = 32767.0 * src->volume; -} - -static void -gst_sinesrc_force_caps(GstSineSrc *src) { - GstCaps *caps; - - if (!src->newcaps) - return; - - src->newcaps=FALSE; - - caps = gst_caps_new ( - "sinesrc_src_caps", - "audio/raw", - gst_props_new ( - "format", GST_PROPS_STRING ("int"), - "law", GST_PROPS_INT (0), - "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 (src->samplerate), - "channels", GST_PROPS_INT (1), - NULL - ) - ); - - gst_pad_set_caps (src->srcpad, caps); -} - -gboolean -gst_sinesrc_factory_init (GstElementFactory *factory) -{ - gst_elementfactory_add_padtemplate (factory, GST_PADTEMPLATE_GET (sinesrc_src_factory)); - - return TRUE; -} diff --git a/plugins/elements/gstsinesrc.h b/plugins/elements/gstsinesrc.h deleted file mode 100644 index 58e03fd..0000000 --- a/plugins/elements/gstsinesrc.h +++ /dev/null @@ -1,96 +0,0 @@ -/* GStreamer - * Copyright (C) 1999,2000 Erik Walthinsen - * 2000 Wim Taymans - * - * gstsinesrc.h: - * - * 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_SINESRC_H__ -#define __GST_SINESRC_H__ - - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - - -GstElementDetails gst_sinesrc_details; - - -#define GST_TYPE_SINESRC \ - (gst_sinesrc_get_type()) -#define GST_SINESRC(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_SINESRC,GstSineSrc)) -#define GST_SINESRC_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_SINESRC,GstSineSrcClass)) -#define GST_IS_SINESRC(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_SINESRC)) -#define GST_IS_SINESRC_CLASS(obj) \ - (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_SINESRC)) - -typedef struct _GstSineSrc GstSineSrc; -typedef struct _GstSineSrcClass GstSineSrcClass; - -struct _GstSineSrc { - GstElement element; - - /* pads */ - GstPad *srcpad; - - /* parameters */ - gfloat volume; - gfloat freq; - gfloat vol_scale; - - /* lookup table data */ - gfloat *table_data; - gdouble table_pos; - gdouble table_inc; - gint table_size; - gdouble table_interp; - gint table_lookup; - gint table_lookup_next; - - /* audio parameters */ - gint format; - gint samplerate; - - gint buffer_size; - gulong seq; - - gboolean newcaps; - -}; - -struct _GstSineSrcClass { - GstElementClass parent_class; -}; - -GType gst_sinesrc_get_type(void); -gboolean gst_sinesrc_factory_init (GstElementFactory *factory); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* __GST_SINESRC_H__ */ -- 2.7.4