From da1fe1e0ddc95b14d132f063c4ddedf4b669f009 Mon Sep 17 00:00:00 2001 From: David Schleef Date: Tue, 14 Dec 2010 19:03:09 -0800 Subject: [PATCH] element-maker: improve generation of several classes Better creation of pads, test and fix many other classes. Most classes work now, although might not create functional elements. --- tools/Makefile.am | 6 +- tools/element-maker | 78 ++++++--- tools/gstaudiofilter.c | 2 + tools/gstaudiosink.c | 46 ++++-- tools/gstaudiosrc.c | 46 ++++-- tools/gstbaseaudiosink.c | 8 +- tools/gstbaseaudiosrc.c | 7 +- tools/gstbasertpdepayload.c | 2 + tools/gstbasertppayload.c | 2 + tools/gstbasesink.c | 2 + tools/gstbasesrc.c | 2 + tools/gstbasetransform.c | 4 + tools/gstcddabasesrc.c | 2 + tools/gstelement.c | 68 ++++---- tools/gstpushsrc.c | 7 +- tools/gsttagdemux.c | 2 + tools/gstvideosink.c | 2 + tools/sinkpad-simple.c | 23 +++ tools/sinkpad.c | 311 ++++++++++++++++++++++++++++++++++++ tools/srcpad-simple.c | 23 +++ tools/srcpad.c | 274 +++++++++++++++++++++++++++++++ 21 files changed, 816 insertions(+), 101 deletions(-) create mode 100644 tools/sinkpad-simple.c create mode 100644 tools/sinkpad.c create mode 100644 tools/srcpad-simple.c create mode 100644 tools/srcpad.c diff --git a/tools/Makefile.am b/tools/Makefile.am index 54cdae13ec..f501ef3530 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -17,4 +17,8 @@ EXTRA_DIST = \ gstelement.c \ gstpushsrc.c \ gsttagdemux.c \ - gstvideosink.c + gstvideosink.c \ + sinkpad.c \ + sinkpad-simple.c \ + srcpad.c \ + srcpad-simple.c diff --git a/tools/element-maker b/tools/element-maker index 02127a97af..60dc35d3be 100755 --- a/tools/element-maker +++ b/tools/element-maker @@ -73,6 +73,7 @@ source=gst$class.c pkg=`grep -A 10000 '^% pkg-config' $source | tail -n +2|grep -m 1 -B 10000 '^%'|head -n -1` GST_TYPE_BASE_REPLACE=`grep -A 10000 '^% TYPE_CLASS_NAME' $source | tail -n +2|grep -m 1 -B 10000 '^%'|head -n -1` GstBaseReplace=`grep -A 10000 '^% ClassName' $source | tail -n +2|grep -m 1 -B 10000 '^%'|head -n -1` +pads=`grep -A 10000 '^% pads' $source | tail -n +2|grep -m 1 -B 10000 '^%'|head -n -1` generate () { @@ -102,12 +103,12 @@ cat <<-EOF /** * SECTION:element-$gstreplace * - * The $gstreplace element does FIXME stuff. + * The $replace element does FIXME stuff. * * * Example launch line * |[ - * gst-launch -v fakesrc ! $gstreplace ! FIXME ! fakesink + * gst-launch -v fakesrc ! $replace ! FIXME ! fakesink * ]| * FIXME Describe what the pipeline does. * @@ -138,6 +139,10 @@ EOF grep -A 10000 '^% prototypes' base.c | tail -n +2|grep -m 1 -B 10000 '^%'|head -n -1 grep -A 10000 '^% prototypes' gobject.c | tail -n +2|grep -m 1 -B 10000 '^%'|head -n -1 grep -A 10000 '^% prototypes' $source | tail -n +2|grep -m 1 -B 10000 '^%'|head -n -1 +for each in $pads +do + grep -A 10000 '^% prototypes' $each.c | tail -n +2|grep -m 1 -B 10000 '^%'|head -n -1 +done cat <"); +for each in $pads +do + grep -A 10000 '^% base-init' $each.c | tail -n +2|grep -m 1 -B 10000 '^%'|head -n -1 +done + +cat <"); } static void @@ -202,7 +206,15 @@ cat < % prototypes -static gboolean gst_replace_open (GstAudioSrc * src); +static gboolean gst_replace_open (GstAudioSink * sink); static gboolean -gst_replace_prepare (GstAudioSrc * src, GstRingBufferSpec * spec); -static gboolean gst_replace_unprepare (GstAudioSrc * src); -static gboolean gst_replace_close (GstAudioSrc * src); -static guint gst_replace_read (GstAudioSrc * src, gpointer data, guint length); -static guint gst_replace_delay (GstAudioSrc * src); -static void gst_replace_reset (GstAudioSrc * src); +gst_replace_prepare (GstAudioSink * sink, GstRingBufferSpec * spec); +static gboolean gst_replace_unprepare (GstAudioSink * sink); +static gboolean gst_replace_close (GstAudioSink * sink); +static guint gst_replace_write (GstAudioSink * sink, gpointer data, guint length); +static guint gst_replace_delay (GstAudioSink * sink); +static void gst_replace_reset (GstAudioSink * sink); % declare-class - GstAudioSink *audio_sink_class = GST_AUDIO_SINK (klass); + GstAudioSinkClass *audio_sink_class = GST_AUDIO_SINK_CLASS (klass); % set-methods - audio_sink_class-> = GST_DEBUG_FUNCPTR (gst_replace_); + audio_sink_class->open = GST_DEBUG_FUNCPTR (gst_replace_open); + audio_sink_class->prepare = GST_DEBUG_FUNCPTR (gst_replace_prepare); + audio_sink_class->unprepare = GST_DEBUG_FUNCPTR (gst_replace_unprepare); + audio_sink_class->close = GST_DEBUG_FUNCPTR (gst_replace_close); + audio_sink_class->write = GST_DEBUG_FUNCPTR (gst_replace_write); + audio_sink_class->delay = GST_DEBUG_FUNCPTR (gst_replace_delay); + audio_sink_class->reset = GST_DEBUG_FUNCPTR (gst_replace_reset); % methods static gboolean -gst_replace_open (GstAudioSrc * src) +gst_replace_open (GstAudioSink * sink) { + return FALSE; } static gboolean -gst_replace_prepare (GstAudioSrc * src, GstRingBufferSpec * spec) +gst_replace_prepare (GstAudioSink * sink, GstRingBufferSpec * spec) { + return FALSE; } static gboolean -gst_replace_unprepare (GstAudioSrc * src) +gst_replace_unprepare (GstAudioSink * sink) { + return FALSE; } static gboolean -gst_replace_close (GstAudioSrc * src) +gst_replace_close (GstAudioSink * sink) { + return FALSE; } static guint -gst_replace_read (GstAudioSrc * src, gpointer data, guint length) +gst_replace_write (GstAudioSink * sink, gpointer data, guint length) { + return 0; } static guint -gst_replace_delay (GstAudioSrc * src) +gst_replace_delay (GstAudioSink * sink) { + return 0; } static void -gst_replace_reset (GstAudioSrc * src) +gst_replace_reset (GstAudioSink * sink) { } % end diff --git a/tools/gstaudiosrc.c b/tools/gstaudiosrc.c index 95f20e7523..051211e563 100644 --- a/tools/gstaudiosrc.c +++ b/tools/gstaudiosrc.c @@ -2,58 +2,72 @@ GstAudioSrc % TYPE_CLASS_NAME GST_TYPE_AUDIO_SRC +% pads +srcpad-simple % pkg-config gstreamer-audio-0.10 % includes #include % prototypes -static gboolean gst_replace_open (GstAudioSink * sink); +static gboolean gst_replace_open (GstAudioSrc * src); static gboolean -gst_replace_prepare (GstAudioSink * sink, GstRingBufferSpec * spec); -static gboolean gst_replace_unprepare (GstAudioSink * sink); -static gboolean gst_replace_close (GstAudioSink * sink); +gst_replace_prepare (GstAudioSrc * src, GstRingBufferSpec * spec); +static gboolean gst_replace_unprepare (GstAudioSrc * src); +static gboolean gst_replace_close (GstAudioSrc * src); static guint -gst_replace_write (GstAudioSink * sink, gpointer data, guint length); -static guint gst_replace_delay (GstAudioSink * sink); -static void gst_replace_reset (GstAudioSink * sink); +gst_replace_read (GstAudioSrc * src, gpointer data, guint length); +static guint gst_replace_delay (GstAudioSrc * src); +static void gst_replace_reset (GstAudioSrc * src); % declare-class - GstAudioSrc *audio_src_class = GST_AUDIO_SRC (klass); + GstAudioSrcClass *audio_src_class = GST_AUDIO_SRC_CLASS (klass); % set-methods - audio_src_class-> = GST_DEBUG_FUNCPTR (gst_replace_); + audio_src_class->open = GST_DEBUG_FUNCPTR (gst_replace_open); + audio_src_class->prepare = GST_DEBUG_FUNCPTR (gst_replace_prepare); + audio_src_class->unprepare = GST_DEBUG_FUNCPTR (gst_replace_unprepare); + audio_src_class->close = GST_DEBUG_FUNCPTR (gst_replace_close); + audio_src_class->read = GST_DEBUG_FUNCPTR (gst_replace_read); + audio_src_class->delay = GST_DEBUG_FUNCPTR (gst_replace_delay); + audio_src_class->reset = GST_DEBUG_FUNCPTR (gst_replace_reset); % methods static gboolean -gst_replace_open (GstAudioSink * sink) +gst_replace_open (GstAudioSrc * src) { + return FALSE; } static gboolean -gst_replace_prepare (GstAudioSink * sink, GstRingBufferSpec * spec) +gst_replace_prepare (GstAudioSrc * src, GstRingBufferSpec * spec) { + return FALSE; } static gboolean -gst_replace_unprepare (GstAudioSink * sink) +gst_replace_unprepare (GstAudioSrc * src) { + return FALSE; } static gboolean -gst_replace_close (GstAudioSink * sink) +gst_replace_close (GstAudioSrc * src) { + return FALSE; } static guint -gst_replace_write (GstAudioSink * sink, gpointer data, guint length) +gst_replace_read (GstAudioSrc * src, gpointer data, guint length) { + return 0; } static guint -gst_replace_delay (GstAudioSink * sink) +gst_replace_delay (GstAudioSrc * src) { + return 0; } static void -gst_replace_reset (GstAudioSink * sink) +gst_replace_reset (GstAudioSrc * src) { } % end diff --git a/tools/gstbaseaudiosink.c b/tools/gstbaseaudiosink.c index 2f36e84c97..695b685fb0 100644 --- a/tools/gstbaseaudiosink.c +++ b/tools/gstbaseaudiosink.c @@ -2,6 +2,8 @@ GstBaseAudioSink % TYPE_CLASS_NAME GST_TYPE_BASE_AUDIO_SINK +% pads +sinkpad-simple % pkg-config gstreamer-audio-0.10 % includes @@ -9,14 +11,14 @@ gstreamer-audio-0.10 % prototypes static GstRingBuffer *gst_replace_create_ringbuffer (GstBaseAudioSink * sink); % declare-class - GstBaseAudioSink *base_audio_sink_class = GST_BASE_AUDIO_SINK (klass); + GstBaseAudioSinkClass *base_audio_sink_class = GST_BASE_AUDIO_SINK_CLASS (klass); % set-methods - base_audio_sink_class-> = GST_DEBUG_FUNCPTR (gst_replace_); + base_audio_sink_class->create_ringbuffer = GST_DEBUG_FUNCPTR (gst_replace_create_ringbuffer); % methods static GstRingBuffer * gst_replace_create_ringbuffer (GstBaseAudioSink * sink) { - + return NULL; } % end diff --git a/tools/gstbaseaudiosrc.c b/tools/gstbaseaudiosrc.c index c87bb32c02..6ef302b0ef 100644 --- a/tools/gstbaseaudiosrc.c +++ b/tools/gstbaseaudiosrc.c @@ -2,6 +2,8 @@ GstBaseAudioSrc % TYPE_CLASS_NAME GST_TYPE_BASE_AUDIO_SRC +% pads +srcpad-simple % pkg-config gstreamer-audio-0.10 % includes @@ -9,14 +11,15 @@ gstreamer-audio-0.10 % prototypes static GstRingBuffer *gst_replace_create_ringbuffer (GstBaseAudioSrc * src); % declare-class - GstBaseAudioSrc *base_audio_src_class = GST_BASE_AUDIO_SRC (klass); + GstBaseAudioSrcClass *base_audio_src_class = GST_BASE_AUDIO_SRC_CLASS (klass); % set-methods - base_audio_src_class-> = GST_DEBUG_FUNCPTR (gst_replace_); + base_audio_src_class->create_ringbuffer = GST_DEBUG_FUNCPTR (gst_replace_create_ringbuffer); % methods static GstRingBuffer * gst_replace_create_ringbuffer (GstBaseAudioSrc * src) { + return NULL; } % end diff --git a/tools/gstbasertpdepayload.c b/tools/gstbasertpdepayload.c index b0810be259..8257a32719 100644 --- a/tools/gstbasertpdepayload.c +++ b/tools/gstbasertpdepayload.c @@ -2,6 +2,8 @@ GstBaseRTPDepayload % TYPE_CLASS_NAME GST_TYPE_BASE_RTP_DEPAYLOAD +% pads +sinkpad-simple srcpad-simple % pkg-config gstreamer-rtp-0.10 % includes diff --git a/tools/gstbasertppayload.c b/tools/gstbasertppayload.c index a871e901c2..65d216f64c 100644 --- a/tools/gstbasertppayload.c +++ b/tools/gstbasertppayload.c @@ -2,6 +2,8 @@ GstBaseRTPPayload % TYPE_CLASS_NAME GST_TYPE_BASE_RTP_PAYLOAD +% pads +sinkpad-simple srcpad-simple % pkg-config gstreamer-rtp-0.10 % includes diff --git a/tools/gstbasesink.c b/tools/gstbasesink.c index 6646dd9f9e..26ad3f9218 100644 --- a/tools/gstbasesink.c +++ b/tools/gstbasesink.c @@ -2,6 +2,8 @@ GstBaseSink % TYPE_CLASS_NAME GST_TYPE_BASE_SINK +% pads +sinkpad-simple % pkg-config gstreamer-base-0.10 % includes diff --git a/tools/gstbasesrc.c b/tools/gstbasesrc.c index 240a16d258..048e274dd1 100644 --- a/tools/gstbasesrc.c +++ b/tools/gstbasesrc.c @@ -2,6 +2,8 @@ GstBaseSrc % TYPE_CLASS_NAME GST_TYPE_BASE_SRC +% pads +srcpad-simple % pkg-config gstreamer-base-0.10 % includes diff --git a/tools/gstbasetransform.c b/tools/gstbasetransform.c index 47d42d39fe..7dcbc8588a 100644 --- a/tools/gstbasetransform.c +++ b/tools/gstbasetransform.c @@ -2,8 +2,12 @@ GstBaseTransform % TYPE_CLASS_NAME GST_TYPE_BASE_TRANSFORM +% pads +sinkpad-simple srcpad-simple % pkg-config gstreamer-base-0.10 +% pads +sinkpad-simple srcpad-simple % includes #include % prototypes diff --git a/tools/gstcddabasesrc.c b/tools/gstcddabasesrc.c index d0e0a804f3..201a843c96 100644 --- a/tools/gstcddabasesrc.c +++ b/tools/gstcddabasesrc.c @@ -2,6 +2,8 @@ GstCddaBaseSrc % TYPE_CLASS_NAME GST_TYPE_CDDA_BASE_SRC +% pads +srcpad-simple % pkg-config gstreamer-cdda-0.10 % includes diff --git a/tools/gstelement.c b/tools/gstelement.c index 293341cdd9..c9e05c66c0 100644 --- a/tools/gstelement.c +++ b/tools/gstelement.c @@ -2,6 +2,8 @@ GstElement % TYPE_CLASS_NAME GST_TYPE_ELEMENT +% pads +sinkpad srcpad % pkg-config gstreamer-0.10 % includes @@ -11,35 +13,24 @@ static GstPad *gst_replace_request_new_pad (GstElement * element, GstPadTemplate * templ, const gchar * name); static void gst_replace_release_pad (GstElement * element, GstPad * pad); static GstStateChangeReturn -gst_replace_get_state (GstElement * element, GstState * state, - GstState * pending, GstClockTime timeout); -static GstStateChangeReturn -gst_replace_set_state (GstElement * element, GstState state); -static GstStateChangeReturn gst_replace_change_state (GstElement * element, GstStateChange transition); -static void gst_replace_set_bus (GstElement * element, GstBus * bus); static GstClock *gst_replace_provide_clock (GstElement * element); static gboolean gst_replace_set_clock (GstElement * element, GstClock * clock); static GstIndex *gst_replace_get_index (GstElement * element); static void gst_replace_set_index (GstElement * element, GstIndex * index); static gboolean gst_replace_send_event (GstElement * element, GstEvent * event); -static const GstQueryType *gst_replace_get_query_types (GstElement * element); static gboolean gst_replace_query (GstElement * element, GstQuery * query); % declare-class GstElementClass *element_class = GST_ELEMENT_CLASS (klass); % set-methods element_class->request_new_pad = GST_DEBUG_FUNCPTR (gst_replace_request_new_pad); element_class->release_pad = GST_DEBUG_FUNCPTR (gst_replace_release_pad); - element_class->get_state = GST_DEBUG_FUNCPTR (gst_replace_get_state); - element_class->set_state = GST_DEBUG_FUNCPTR (gst_replace_set_state); element_class->change_state = GST_DEBUG_FUNCPTR (gst_replace_change_state); - element_class->set_bus = GST_DEBUG_FUNCPTR (gst_replace_set_bus); element_class->provide_clock = GST_DEBUG_FUNCPTR (gst_replace_provide_clock); element_class->set_clock = GST_DEBUG_FUNCPTR (gst_replace_set_clock); element_class->get_index = GST_DEBUG_FUNCPTR (gst_replace_get_index); element_class->set_index = GST_DEBUG_FUNCPTR (gst_replace_set_index); element_class->send_event = GST_DEBUG_FUNCPTR (gst_replace_send_event); - element_class->get_query_types = GST_DEBUG_FUNCPTR (gst_replace_get_query_types); element_class->query = GST_DEBUG_FUNCPTR (gst_replace_query); % methods @@ -58,32 +49,40 @@ gst_replace_release_pad (GstElement * element, GstPad * pad) } -static GstStateChangeReturn -gst_replace_get_state (GstElement * element, GstState * state, - GstState * pending, GstClockTime timeout) -{ - - return GST_STATE_CHANGE_SUCCESS; -} - -static GstStateChangeReturn -gst_replace_set_state (GstElement * element, GstState state) -{ - - return GST_STATE_CHANGE_SUCCESS; -} - static GstStateChangeReturn gst_replace_change_state (GstElement * element, GstStateChange transition) { + GstReplace *replace; + GstStateChangeReturn ret; - return GST_STATE_CHANGE_SUCCESS; -} + g_return_val_if_fail (GST_IS_REPLACE (element), GST_STATE_CHANGE_FAILURE); + replace = GST_REPLACE (element); -static void -gst_replace_set_bus (GstElement * element, GstBus * bus) -{ + switch (transition) { + case GST_STATE_CHANGE_NULL_TO_READY: + break; + case GST_STATE_CHANGE_READY_TO_PAUSED: + break; + case GST_STATE_CHANGE_PAUSED_TO_PLAYING: + break; + default: + break; + } + ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition); + + switch (transition) { + case GST_STATE_CHANGE_PLAYING_TO_PAUSED: + break; + case GST_STATE_CHANGE_PAUSED_TO_READY: + break; + case GST_STATE_CHANGE_READY_TO_NULL: + break; + default: + break; + } + + return ret; } static GstClock * @@ -120,13 +119,6 @@ gst_replace_send_event (GstElement * element, GstEvent * event) return TRUE; } -static const GstQueryType * -gst_replace_get_query_types (GstElement * element) -{ - - return NULL; -} - static gboolean gst_replace_query (GstElement * element, GstQuery * query) { diff --git a/tools/gstpushsrc.c b/tools/gstpushsrc.c index 5db8e76302..a35595085b 100644 --- a/tools/gstpushsrc.c +++ b/tools/gstpushsrc.c @@ -2,6 +2,8 @@ GstPushSrc % TYPE_CLASS_NAME GST_TYPE_PUSH_SRC +% pads +srcpad-simple % pkg-config gstreamer-base-0.10 % includes @@ -9,14 +11,15 @@ gstreamer-base-0.10 % prototypes static GstFlowReturn gst_replace_create (GstPushSrc * src, GstBuffer ** buf); % declare-class - GstPushSrc *pushsrc_class = GST_PUSHSRC (klass); + GstPushSrcClass *pushsrc_class = GST_PUSH_SRC_CLASS (klass); % set-methods - pushsrc_class-> = GST_DEBUG_FUNCPTR (gst_replace_); + pushsrc_class->create = GST_DEBUG_FUNCPTR (gst_replace_create); % methods static GstFlowReturn gst_replace_create (GstPushSrc * src, GstBuffer ** buf) { + return GST_FLOW_OK; } % end diff --git a/tools/gsttagdemux.c b/tools/gsttagdemux.c index 7ddec9d870..6cdfb58d8e 100644 --- a/tools/gsttagdemux.c +++ b/tools/gsttagdemux.c @@ -2,6 +2,8 @@ GstTagDemux % TYPE_CLASS_NAME GST_TYPE_TAG_DEMUX +% pads +sinkpad-simple srcpad-simple % pkg-config gstreamer-tag-0.10 % includes diff --git a/tools/gstvideosink.c b/tools/gstvideosink.c index ce12a07f3e..72a9e88789 100644 --- a/tools/gstvideosink.c +++ b/tools/gstvideosink.c @@ -2,6 +2,8 @@ GstVideoSink % TYPE_CLASS_NAME GST_TYPE_VIDEO_SINK +% pads +sinkpad-simple % pkg-config gstreamer-video-0.10 % includes diff --git a/tools/sinkpad-simple.c b/tools/sinkpad-simple.c new file mode 100644 index 0000000000..9a031fc150 --- /dev/null +++ b/tools/sinkpad-simple.c @@ -0,0 +1,23 @@ + +% instance-members + GstPad *sinkpad; +% prototypes +% pad-template +static GstStaticPadTemplate gst_replace_sink_template = +GST_STATIC_PAD_TEMPLATE ("sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ("application/unknown") + ); + +% base-init + gst_element_class_add_pad_template (element_class, + gst_static_pad_template_get (&gst_replace_sink_template)); +% instance-init + + replace->sinkpad = gst_pad_new_from_static_template (&gst_replace_sink_template + , + "sink"); +% methods +% end + diff --git a/tools/sinkpad.c b/tools/sinkpad.c new file mode 100644 index 0000000000..87babbc7f9 --- /dev/null +++ b/tools/sinkpad.c @@ -0,0 +1,311 @@ + +% instance-members + GstPad *sinkpad; +% prototypes + +static GstCaps* gst_replace_sink_getcaps (GstPad *pad); +static gboolean gst_replace_sink_setcaps (GstPad *pad, GstCaps *caps); +static gboolean gst_replace_sink_acceptcaps (GstPad *pad, GstCaps *caps); +static void gst_replace_sink_fixatecaps (GstPad *pad, GstCaps *caps); +static gboolean gst_replace_sink_activate (GstPad *pad); +static gboolean gst_replace_sink_activatepush (GstPad *pad, gboolean active); +static gboolean gst_replace_sink_activatepull (GstPad *pad, gboolean active); +static GstPadLinkReturn gst_replace_sink_link (GstPad *pad, GstPad *peer); +static void gst_replace_sink_unlink (GstPad *pad); +static GstFlowReturn gst_replace_sink_chain (GstPad *pad, GstBuffer *buffer); +static GstFlowReturn gst_replace_sink_chainlist (GstPad *pad, GstBufferList *bufferlist); +static gboolean gst_replace_sink_event (GstPad *pad, GstEvent *event); +static gboolean gst_replace_sink_query (GstPad *pad, GstQuery *query); +static GstFlowReturn gst_replace_sink_bufferalloc (GstPad *pad, guint64 offset, guint size, + GstCaps *caps, GstBuffer **buf); +static GstIterator * gst_replace_sink_iterintlink (GstPad *pad); + +% pad-template +static GstStaticPadTemplate gst_replace_sink_template = +GST_STATIC_PAD_TEMPLATE ("sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ("application/unknown") + ); + +% base-init + gst_element_class_add_pad_template (element_class, + gst_static_pad_template_get (&gst_replace_sink_template)); +% instance-init + + replace->sinkpad = gst_pad_new_from_static_template (&gst_replace_sink_template + , + "sink"); + gst_pad_set_getcaps_function (replace->sinkpad, + GST_DEBUG_FUNCPTR(gst_replace_sink_getcaps)); + gst_pad_set_setcaps_function (replace->sinkpad, + GST_DEBUG_FUNCPTR(gst_replace_sink_setcaps)); + gst_pad_set_acceptcaps_function (replace->sinkpad, + GST_DEBUG_FUNCPTR(gst_replace_sink_acceptcaps)); + gst_pad_set_fixatecaps_function (replace->sinkpad, + GST_DEBUG_FUNCPTR(gst_replace_sink_fixatecaps)); + gst_pad_set_activate_function (replace->sinkpad, + GST_DEBUG_FUNCPTR(gst_replace_sink_activate)); + gst_pad_set_activatepush_function (replace->sinkpad, + GST_DEBUG_FUNCPTR(gst_replace_sink_activatepush)); + gst_pad_set_activatepull_function (replace->sinkpad, + GST_DEBUG_FUNCPTR(gst_replace_sink_activatepull)); + gst_pad_set_link_function (replace->sinkpad, + GST_DEBUG_FUNCPTR(gst_replace_sink_link)); + gst_pad_set_unlink_function (replace->sinkpad, + GST_DEBUG_FUNCPTR(gst_replace_sink_unlink)); + gst_pad_set_chain_function (replace->sinkpad, + GST_DEBUG_FUNCPTR(gst_replace_sink_chain)); + gst_pad_set_chain_list_function (replace->sinkpad, + GST_DEBUG_FUNCPTR(gst_replace_sink_chainlist)); + gst_pad_set_event_function (replace->sinkpad, + GST_DEBUG_FUNCPTR(gst_replace_sink_event)); + gst_pad_set_query_function (replace->sinkpad, + GST_DEBUG_FUNCPTR(gst_replace_sink_query)); + gst_pad_set_bufferalloc_function (replace->sinkpad, + GST_DEBUG_FUNCPTR(gst_replace_sink_bufferalloc)); + gst_pad_set_iterate_internal_links_function (replace->sinkpad, + GST_DEBUG_FUNCPTR(gst_replace_sink_iterintlink)); + gst_element_add_pad (GST_ELEMENT(replace), replace->sinkpad); + + +% methods + +static GstCaps* +gst_replace_sink_getcaps (GstPad *pad) +{ + GstReplace *replace; + GstCaps *caps; + + replace = GST_REPLACE (gst_pad_get_parent (pad)); + + GST_DEBUG_OBJECT(replace, "getcaps"); + + caps = gst_caps_copy (gst_pad_get_pad_template_caps (pad)); + + gst_object_unref (replace); + return caps; +} + +static gboolean +gst_replace_sink_setcaps (GstPad *pad, GstCaps *caps) +{ + GstReplace *replace; + + replace = GST_REPLACE (gst_pad_get_parent (pad)); + + GST_DEBUG_OBJECT(replace, "setcaps"); + + + gst_object_unref (replace); + return TRUE; +} + +static gboolean +gst_replace_sink_acceptcaps (GstPad *pad, GstCaps *caps) +{ + GstReplace *replace; + + replace = GST_REPLACE (gst_pad_get_parent (pad)); + + GST_DEBUG_OBJECT(replace, "acceptcaps"); + + + gst_object_unref (replace); + return TRUE; +} + +static void +gst_replace_sink_fixatecaps (GstPad *pad, GstCaps *caps) +{ + GstReplace *replace; + + replace = GST_REPLACE (gst_pad_get_parent (pad)); + + GST_DEBUG_OBJECT(replace, "fixatecaps"); + + + gst_object_unref (replace); +} + +static gboolean +gst_replace_sink_activate (GstPad *pad) +{ + GstReplace *replace; + gboolean ret; + + replace = GST_REPLACE (gst_pad_get_parent (pad)); + + GST_DEBUG_OBJECT(replace, "activate"); + + if (gst_pad_check_pull_range (pad)) { + GST_DEBUG_OBJECT (pad, "activating pull"); + ret = gst_pad_activate_pull (pad, TRUE); + } else { + GST_DEBUG_OBJECT (pad, "activating push"); + ret = gst_pad_activate_push (pad, TRUE); + } + + gst_object_unref (replace); + return ret; +} + +static gboolean +gst_replace_sink_activatepush (GstPad *pad, gboolean active) +{ + GstReplace *replace; + + replace = GST_REPLACE (gst_pad_get_parent (pad)); + + GST_DEBUG_OBJECT(replace, "activatepush"); + + + gst_object_unref (replace); + return TRUE; +} + +static gboolean +gst_replace_sink_activatepull (GstPad *pad, gboolean active) +{ + GstReplace *replace; + + replace = GST_REPLACE (gst_pad_get_parent (pad)); + + GST_DEBUG_OBJECT(replace, "activatepull"); + + + gst_object_unref (replace); + return TRUE; +} + +static GstPadLinkReturn +gst_replace_sink_link (GstPad *pad, GstPad *peer) +{ + GstReplace *replace; + + replace = GST_REPLACE (gst_pad_get_parent (pad)); + + GST_DEBUG_OBJECT(replace, "link"); + + + gst_object_unref (replace); + return GST_PAD_LINK_OK; +} + +static void +gst_replace_sink_unlink (GstPad *pad) +{ + GstReplace *replace; + + replace = GST_REPLACE (gst_pad_get_parent (pad)); + + GST_DEBUG_OBJECT(replace, "unlink"); + + + gst_object_unref (replace); +} + +static GstFlowReturn +gst_replace_sink_chain (GstPad *pad, GstBuffer *buffer) +{ + GstReplace *replace; + + replace = GST_REPLACE (gst_pad_get_parent (pad)); + + GST_DEBUG_OBJECT(replace, "chain"); + + + gst_object_unref (replace); + return GST_FLOW_OK; +} + +static GstFlowReturn +gst_replace_sink_chainlist (GstPad *pad, GstBufferList *bufferlist) +{ + GstReplace *replace; + + replace = GST_REPLACE (gst_pad_get_parent (pad)); + + GST_DEBUG_OBJECT(replace, "chainlist"); + + + gst_object_unref (replace); + return GST_FLOW_OK; +} + +static gboolean +gst_replace_sink_event (GstPad *pad, GstEvent *event) +{ + gboolean res; + GstReplace *replace; + + replace = GST_REPLACE (gst_pad_get_parent (pad)); + + GST_DEBUG_OBJECT(replace, "event"); + + switch (GST_EVENT_TYPE (event)) { + default: + res = gst_pad_event_default (pad, event); + break; + } + + gst_object_unref (replace); + return res; +} + +static gboolean +gst_replace_sink_query (GstPad *pad, GstQuery *query) +{ + gboolean res; + GstReplace *replace; + + replace = GST_REPLACE (gst_pad_get_parent (pad)); + + GST_DEBUG_OBJECT(replace, "query"); + + switch (GST_QUERY_TYPE(query)) { + default: + res = gst_pad_query_default (pad, query); + break; + } + + gst_object_unref (replace); + return res; +} + +static GstFlowReturn +gst_replace_sink_bufferalloc (GstPad *pad, guint64 offset, guint size, + GstCaps *caps, GstBuffer **buf) +{ + GstReplace *replace; + + replace = GST_REPLACE (gst_pad_get_parent (pad)); + + GST_DEBUG_OBJECT(replace, "bufferalloc"); + + + *buf = gst_buffer_new_and_alloc (size); + gst_buffer_set_caps (*buf, caps); + + gst_object_unref (replace); + return GST_FLOW_OK; +} + +static GstIterator * +gst_replace_sink_iterintlink (GstPad *pad) +{ + GstReplace *replace; + GstIterator *iter; + + replace = GST_REPLACE (gst_pad_get_parent (pad)); + + GST_DEBUG_OBJECT(replace, "iterintlink"); + + iter = gst_pad_iterate_internal_links_default (pad); + + gst_object_unref (replace); + return iter; +} + +% end + diff --git a/tools/srcpad-simple.c b/tools/srcpad-simple.c new file mode 100644 index 0000000000..42db8d385b --- /dev/null +++ b/tools/srcpad-simple.c @@ -0,0 +1,23 @@ + +% instance-members + GstPad *srcpad; +% prototypes +% pad-template +static GstStaticPadTemplate gst_replace_src_template = +GST_STATIC_PAD_TEMPLATE ("src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ("application/unknown") + ); + +% base-init + gst_element_class_add_pad_template (element_class, + gst_static_pad_template_get (&gst_replace_src_template)); +% instance-init + + replace->srcpad = gst_pad_new_from_static_template (&gst_replace_src_template + , + "src"); +% methods +% end + diff --git a/tools/srcpad.c b/tools/srcpad.c new file mode 100644 index 0000000000..61cbd21326 --- /dev/null +++ b/tools/srcpad.c @@ -0,0 +1,274 @@ + +% instance-members + GstPad *srcpad; +% prototypes + +static GstCaps* gst_replace_src_getcaps (GstPad *pad); +static gboolean gst_replace_src_setcaps (GstPad *pad, GstCaps *caps); +static gboolean gst_replace_src_acceptcaps (GstPad *pad, GstCaps *caps); +static void gst_replace_src_fixatecaps (GstPad *pad, GstCaps *caps); +static gboolean gst_replace_src_activate (GstPad *pad); +static gboolean gst_replace_src_activatepush (GstPad *pad, gboolean active); +static gboolean gst_replace_src_activatepull (GstPad *pad, gboolean active); +static GstPadLinkReturn gst_replace_src_link (GstPad *pad, GstPad *peer); +static void gst_replace_src_unlink (GstPad *pad); +static GstFlowReturn gst_replace_src_getrange (GstPad *pad, guint64 offset, guint length, + GstBuffer **buffer); +static gboolean gst_replace_src_event (GstPad *pad, GstEvent *event); +static gboolean gst_replace_src_query (GstPad *pad, GstQuery *query); +static GstIterator * gst_replace_src_iterintlink (GstPad *pad); + +% pad-template +static GstStaticPadTemplate gst_replace_src_template = +GST_STATIC_PAD_TEMPLATE ("src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ("application/unknown") + ); + +% base-init + gst_element_class_add_pad_template (element_class, + gst_static_pad_template_get (&gst_replace_src_template)); +% instance-init + + replace->srcpad = gst_pad_new_from_static_template (&gst_replace_src_template + , + "src"); + gst_pad_set_getcaps_function (replace->srcpad, + GST_DEBUG_FUNCPTR(gst_replace_src_getcaps)); + gst_pad_set_setcaps_function (replace->srcpad, + GST_DEBUG_FUNCPTR(gst_replace_src_setcaps)); + gst_pad_set_acceptcaps_function (replace->srcpad, + GST_DEBUG_FUNCPTR(gst_replace_src_acceptcaps)); + gst_pad_set_fixatecaps_function (replace->srcpad, + GST_DEBUG_FUNCPTR(gst_replace_src_fixatecaps)); + gst_pad_set_activate_function (replace->srcpad, + GST_DEBUG_FUNCPTR(gst_replace_src_activate)); + gst_pad_set_activatepush_function (replace->srcpad, + GST_DEBUG_FUNCPTR(gst_replace_src_activatepush)); + gst_pad_set_activatepull_function (replace->srcpad, + GST_DEBUG_FUNCPTR(gst_replace_src_activatepull)); + gst_pad_set_link_function (replace->srcpad, + GST_DEBUG_FUNCPTR(gst_replace_src_link)); + gst_pad_set_unlink_function (replace->srcpad, + GST_DEBUG_FUNCPTR(gst_replace_src_unlink)); + gst_pad_set_getrange_function (replace->srcpad, + GST_DEBUG_FUNCPTR(gst_replace_src_getrange)); + gst_pad_set_event_function (replace->srcpad, + GST_DEBUG_FUNCPTR(gst_replace_src_event)); + gst_pad_set_query_function (replace->srcpad, + GST_DEBUG_FUNCPTR(gst_replace_src_query)); + gst_pad_set_iterate_internal_links_function (replace->srcpad, + GST_DEBUG_FUNCPTR(gst_replace_src_iterintlink)); + gst_element_add_pad (GST_ELEMENT(replace), replace->srcpad); + + +% methods + +static GstCaps* +gst_replace_src_getcaps (GstPad *pad) +{ + GstReplace *replace; + GstCaps *caps; + + replace = GST_REPLACE (gst_pad_get_parent (pad)); + + GST_DEBUG_OBJECT(replace, "getcaps"); + + caps = gst_caps_copy (gst_pad_get_pad_template_caps (pad)); + + gst_object_unref (replace); + return caps; +} + +static gboolean +gst_replace_src_setcaps (GstPad *pad, GstCaps *caps) +{ + GstReplace *replace; + + replace = GST_REPLACE (gst_pad_get_parent (pad)); + + GST_DEBUG_OBJECT(replace, "setcaps"); + + + gst_object_unref (replace); + return TRUE; +} + +static gboolean +gst_replace_src_acceptcaps (GstPad *pad, GstCaps *caps) +{ + GstReplace *replace; + + replace = GST_REPLACE (gst_pad_get_parent (pad)); + + GST_DEBUG_OBJECT(replace, "acceptcaps"); + + + gst_object_unref (replace); + return TRUE; +} + +static void +gst_replace_src_fixatecaps (GstPad *pad, GstCaps *caps) +{ + GstReplace *replace; + + replace = GST_REPLACE (gst_pad_get_parent (pad)); + + GST_DEBUG_OBJECT(replace, "fixatecaps"); + + + gst_object_unref (replace); +} + +static gboolean +gst_replace_src_activate (GstPad *pad) +{ + GstReplace *replace; + gboolean ret; + + replace = GST_REPLACE (gst_pad_get_parent (pad)); + + GST_DEBUG_OBJECT(replace, "activate"); + + if (gst_pad_check_pull_range (pad)) { + GST_DEBUG_OBJECT (pad, "activating pull"); + ret = gst_pad_activate_pull (pad, TRUE); + } else { + GST_DEBUG_OBJECT (pad, "activating push"); + ret = gst_pad_activate_push (pad, TRUE); + } + + gst_object_unref (replace); + return ret; +} + +static gboolean +gst_replace_src_activatepush (GstPad *pad, gboolean active) +{ + GstReplace *replace; + + replace = GST_REPLACE (gst_pad_get_parent (pad)); + + GST_DEBUG_OBJECT(replace, "activatepush"); + + + gst_object_unref (replace); + return TRUE; +} + +static gboolean +gst_replace_src_activatepull (GstPad *pad, gboolean active) +{ + GstReplace *replace; + + replace = GST_REPLACE (gst_pad_get_parent (pad)); + + GST_DEBUG_OBJECT(replace, "activatepull"); + + + gst_object_unref (replace); + return TRUE; +} + +static GstPadLinkReturn +gst_replace_src_link (GstPad *pad, GstPad *peer) +{ + GstReplace *replace; + + replace = GST_REPLACE (gst_pad_get_parent (pad)); + + GST_DEBUG_OBJECT(replace, "link"); + + + gst_object_unref (replace); + return GST_PAD_LINK_OK; +} + +static void +gst_replace_src_unlink (GstPad *pad) +{ + GstReplace *replace; + + replace = GST_REPLACE (gst_pad_get_parent (pad)); + + GST_DEBUG_OBJECT(replace, "unlink"); + + + gst_object_unref (replace); +} + +static GstFlowReturn +gst_replace_src_getrange (GstPad *pad, guint64 offset, guint length, + GstBuffer **buffer) +{ + GstReplace *replace; + + replace = GST_REPLACE (gst_pad_get_parent (pad)); + + GST_DEBUG_OBJECT(replace, "getrange"); + + + gst_object_unref (replace); + return GST_FLOW_OK; +} + +static gboolean +gst_replace_src_event (GstPad *pad, GstEvent *event) +{ + gboolean res; + GstReplace *replace; + + replace = GST_REPLACE (gst_pad_get_parent (pad)); + + GST_DEBUG_OBJECT(replace, "event"); + + switch (GST_EVENT_TYPE (event)) { + default: + res = gst_pad_event_default (pad, event); + break; + } + + gst_object_unref (replace); + return res; +} + +static gboolean +gst_replace_src_query (GstPad *pad, GstQuery *query) +{ + gboolean res; + GstReplace *replace; + + replace = GST_REPLACE (gst_pad_get_parent (pad)); + + GST_DEBUG_OBJECT(replace, "query"); + + switch (GST_QUERY_TYPE(query)) { + default: + res = gst_pad_query_default (pad, query); + break; + } + + gst_object_unref (replace); + return res; +} + +static GstIterator * +gst_replace_src_iterintlink (GstPad *pad) +{ + GstReplace *replace; + GstIterator *iter; + + replace = GST_REPLACE (gst_pad_get_parent (pad)); + + GST_DEBUG_OBJECT(replace, "iterintlink"); + + iter = gst_pad_iterate_internal_links_default (pad); + + gst_object_unref (replace); + return iter; +} + +% end +