From da03fde0547b8df1061f11a555728364aeecaba5 Mon Sep 17 00:00:00 2001 From: Erik Walthinsen Date: Sat, 16 Dec 2000 10:18:09 +0000 Subject: [PATCH] WARNING: Don't grab this updated unless you're really, REALLY sure. Original commit message from CVS: WARNING: Don't grab this updated unless you're really, REALLY sure. WARNING: Wait for the next one. Whole lotta changes here, including a few random bits: examples/*/Makefile: updated to use `libtool gcc`, not just `gcc` gst/ gstbuffer.h: updated to new flag style gst.c, gstdebug.h: added new debugging for function ptrs gstpipeline.c: set type of parent_class to the class, not the object gstthread.c: ditto plugins/ cdparanoia/cdparanoia.c: added an argument type, updated some defaults cobin/spindentity.c: updated to new do/while loopfunction style mp3encode/lame/gstlame.c: argument types, whole lotta lame options tests/: various changes Now, for the big changes: Once again, the scheduling system has changed. And once again, it broke a whole bunch of things. The gist of the change is that there is now a function pointer for gst_pad_push and gst_pad_pull, instead of a hard-wired function. Well, currently they are functions, but that's for debugging purposes only, they just call the function pointer after spewing lots of DEBUG(). This changed the GstPad structure a bit, and the GstPad API as well. Where elements used to provide chain() and pull() functions, they provide chain() and get() functions. gst_pad_set_pull[region]_function has been changed to get_pad_set_get[region]_function. This means all the elements out there that used to have pull functions need to be updated. The calls to that function have been changed in the normal elements, but the names of the functions passed is still _pull[region](), which is an aesthetic issue more than anything. As for what doesn't work yet, just about anything dealing with Connections is hosed, meaning threaded stuff won't work. This will be fixed about 12 hours from now, after I've slept, etc. The simplefake.c test works in both cothreaded and chained cases, but not much else will work due to the Connection problem. Needless to say, don't grab this unless you *need* these features *now*, else wait to update this stuff until tomorrow. I'm going to sleep now. --- docs/random/sources | 8 +- examples/autoplug/Makefile | 2 +- examples/helloworld/Makefile | 2 +- examples/queue4/Makefile | 6 +- examples/xml/Makefile | 2 +- gst/elements/gstasyncdisksrc.c | 17 +- gst/elements/gstaudiosrc.c | 6 +- gst/elements/gstdisksrc.c | 21 ++- gst/elements/gstfakesink.c | 4 +- gst/elements/gstfakesrc.c | 14 +- gst/elements/gstfdsrc.c | 6 +- gst/elements/gsthttpsrc.c | 6 +- gst/elements/gstidentity.c | 4 +- gst/elements/gstqueue.c | 6 +- gst/elements/gstsinesrc.c | 6 +- gst/gst.c | 2 + gst/gstbin.c | 231 +++++++++++++++---------- gst/gstbuffer.h | 12 +- gst/gstdebug.h | 31 ++++ gst/gstpad.c | 156 ++++++++++++----- gst/gstpad.h | 37 +++- gst/gstpipeline.c | 2 +- gst/gstthread.c | 2 +- plugins/elements/gstasyncdisksrc.c | 17 +- plugins/elements/gstaudiosrc.c | 6 +- plugins/elements/gstdisksrc.c | 21 ++- plugins/elements/gstfakesink.c | 4 +- plugins/elements/gstfakesrc.c | 14 +- plugins/elements/gstfdsrc.c | 6 +- plugins/elements/gsthttpsrc.c | 6 +- plugins/elements/gstidentity.c | 4 +- plugins/elements/gstqueue.c | 6 +- plugins/elements/gstsinesrc.c | 6 +- tests/Makefile.am | 2 +- tests/mp3encode.c | 85 +++++++++ tests/old/examples/autoplug/Makefile | 2 +- tests/old/examples/helloworld/Makefile | 2 +- tests/old/examples/queue4/Makefile | 6 +- tests/old/examples/xml/Makefile | 2 +- tests/pad-active.c | 24 +++ tests/paranoia.c | 25 ++- tests/queue.c | 14 +- tests/rip.c | 15 +- tests/simplefake.c | 35 +++- tests/states.c | 34 +++- 45 files changed, 619 insertions(+), 300 deletions(-) create mode 100644 tests/mp3encode.c create mode 100644 tests/pad-active.c diff --git a/docs/random/sources b/docs/random/sources index a3ee74f795..2876c58267 100644 --- a/docs/random/sources +++ b/docs/random/sources @@ -34,7 +34,7 @@ Chained (current implementation): !------------------------------->! ! ! : : - (more chaining) + (more chaining) : : !<-------------------------------! !<----------------! @@ -182,7 +182,7 @@ The stack will grow and unwind as many times as buffers are pushed out. !------------------------------->! ! ! : : - (more chaining) + (more chaining) : : !<-------------------------------! !<----------------! @@ -195,7 +195,7 @@ The stack will grow and unwind as many times as buffers are pushed out. !------------------------------->! ! ! : : - (more chaining) + (more chaining) : : !<-------------------------------! !<----------------! @@ -256,7 +256,7 @@ Chained: !------------------------------------------------------------------->! ! : - (more chaining) + (more chaining) : !<-------------------------------------------------------------------! ! diff --git a/examples/autoplug/Makefile b/examples/autoplug/Makefile index c8feaad2cb..470a9aac6e 100644 --- a/examples/autoplug/Makefile +++ b/examples/autoplug/Makefile @@ -1,5 +1,5 @@ -CC = gcc +CC = libtool gcc autoplug: autoplug.c $(CC) -Wall `gstreamer-config --cflags --libs` `gnome-config --cflags --libs gnomeui` autoplug.c -o autoplug diff --git a/examples/helloworld/Makefile b/examples/helloworld/Makefile index ab164c83f5..39fb9a5386 100644 --- a/examples/helloworld/Makefile +++ b/examples/helloworld/Makefile @@ -1,5 +1,5 @@ -CC = gcc +CC = libtool gcc helloworld: helloworld.c $(CC) -Wall `gstreamer-config --cflags --libs` helloworld.c -o helloworld diff --git a/examples/queue4/Makefile b/examples/queue4/Makefile index f195a19ab7..fba4ebabcd 100644 --- a/examples/queue4/Makefile +++ b/examples/queue4/Makefile @@ -1,8 +1,8 @@ -CC = gcc +CC = libtool gcc -queue4: queue4.c - $(CC) -Wall `gstreamer-config --cflags --libs` queue4.c -o queue4 +queue4: queue4.c + $(CC) -Wall `gstreamer-config --cflags --libs` queue4.c -o queue4 clean: rm -f *.o queue4 diff --git a/examples/xml/Makefile b/examples/xml/Makefile index 5f74b38f7d..e15dfc9092 100644 --- a/examples/xml/Makefile +++ b/examples/xml/Makefile @@ -1,5 +1,5 @@ -CC = gcc +CC = libtool gcc all: createxml runxml diff --git a/gst/elements/gstasyncdisksrc.c b/gst/elements/gstasyncdisksrc.c index a12d008cb2..dd3f60d865 100644 --- a/gst/elements/gstasyncdisksrc.c +++ b/gst/elements/gstasyncdisksrc.c @@ -57,8 +57,8 @@ static void gst_asyncdisksrc_init (GstAsyncDiskSrc *asyncdisksrc); static void gst_asyncdisksrc_set_arg (GtkObject *object, GtkArg *arg, guint id); static void gst_asyncdisksrc_get_arg (GtkObject *object, GtkArg *arg, guint id); -static void gst_asyncdisksrc_pull (GstPad *pad); -static void gst_asyncdisksrc_pull_region (GstPad *pad, gulong offset, gulong size); +static void gst_asyncdisksrc_get (GstPad *pad); +static void gst_asyncdisksrc_get_region (GstPad *pad, gulong offset, gulong size); static GstElementStateReturn gst_asyncdisksrc_change_state (GstElement *element); @@ -122,9 +122,8 @@ gst_asyncdisksrc_init (GstAsyncDiskSrc *asyncdisksrc) g_print("init\n"); asyncdisksrc->srcpad = gst_pad_new ("src", GST_PAD_SRC); - gst_pad_set_pull_function (asyncdisksrc->srcpad,gst_asyncdisksrc_pull); - gst_pad_set_pullregion_function (asyncdisksrc->srcpad,gst_asyncdisksrc_pull_region); - // FIXME must set pullregion + gst_pad_set_get_function (asyncdisksrc->srcpad,gst_asyncdisksrc_get); + gst_pad_set_getregion_function (asyncdisksrc->srcpad,gst_asyncdisksrc_get_region); gst_element_add_pad (GST_ELEMENT (asyncdisksrc), asyncdisksrc->srcpad); asyncdisksrc->filename = NULL; @@ -205,13 +204,13 @@ gst_asyncdisksrc_get_arg (GtkObject *object, GtkArg *arg, guint id) } /** - * gst_asyncdisksrc_pull: + * gst_asyncdisksrc_get: * @pad: #GstPad to push a buffer from * * Push a new buffer from the asyncdisksrc at the current offset. */ static void -gst_asyncdisksrc_pull (GstPad *pad) +gst_asyncdisksrc_get (GstPad *pad) { GstAsyncDiskSrc *src; GstBuffer *buf; @@ -256,7 +255,7 @@ gst_asyncdisksrc_pull (GstPad *pad) } /** - * gst_asyncdisksrc_pull_region: + * gst_asyncdisksrc_get_region: * @src: #GstSrc to push a buffer from * @offset: offset in file * @size: number of bytes @@ -264,7 +263,7 @@ gst_asyncdisksrc_pull (GstPad *pad) * Push a new buffer from the asyncdisksrc of given size at given offset. */ static void -gst_asyncdisksrc_pull_region (GstPad *pad, gulong offset, gulong size) +gst_asyncdisksrc_get_region (GstPad *pad, gulong offset, gulong size) { GstAsyncDiskSrc *src; GstBuffer *buf; diff --git a/gst/elements/gstaudiosrc.c b/gst/elements/gstaudiosrc.c index 6e89a77b73..91a3a2bf18 100644 --- a/gst/elements/gstaudiosrc.c +++ b/gst/elements/gstaudiosrc.c @@ -64,7 +64,7 @@ static void gst_audiosrc_close_audio (GstAudioSrc *src); static gboolean gst_audiosrc_open_audio (GstAudioSrc *src); static void gst_audiosrc_sync_parms (GstAudioSrc *audiosrc); -static void gst_audiosrc_pull (GstPad *pad); +static void gst_audiosrc_get (GstPad *pad); static GstSrcClass *parent_class = NULL; //static guint gst_audiosrc_signals[LAST_SIGNAL] = { 0 }; @@ -124,7 +124,7 @@ static void gst_audiosrc_init (GstAudioSrc *audiosrc) { audiosrc->srcpad = gst_pad_new ("src", GST_PAD_SRC); - gst_pad_set_pull_function(audiosrc->srcpad,gst_audiosrc_pull); + gst_pad_set_get_function(audiosrc->srcpad,gst_audiosrc_get); gst_element_add_pad (GST_ELEMENT (audiosrc), audiosrc->srcpad); audiosrc->fd = -1; @@ -140,7 +140,7 @@ gst_audiosrc_init (GstAudioSrc *audiosrc) audiosrc->seq = 0; } -void gst_audiosrc_pull(GstPad *pad) { +void gst_audiosrc_get(GstPad *pad) { GstAudioSrc *src; GstBuffer *buf; glong readbytes; diff --git a/gst/elements/gstdisksrc.c b/gst/elements/gstdisksrc.c index e985df3aec..ea49fd769d 100644 --- a/gst/elements/gstdisksrc.c +++ b/gst/elements/gstdisksrc.c @@ -22,8 +22,6 @@ #include #include -//#define DEBUG_ENABLED - #include @@ -60,7 +58,7 @@ static void gst_disksrc_get_arg (GtkObject *object, GtkArg *arg, guint id); static void gst_disksrc_close_file (GstDiskSrc *src); -static void gst_disksrc_pull (GstPad *pad); +static void gst_disksrc_get (GstPad *pad); static GstElementStateReturn gst_disksrc_change_state (GstElement *element); @@ -120,7 +118,7 @@ static void gst_disksrc_init (GstDiskSrc *disksrc) { disksrc->srcpad = gst_pad_new ("src", GST_PAD_SRC); - gst_pad_set_pull_function(disksrc->srcpad,gst_disksrc_pull); + gst_pad_set_get_function(disksrc->srcpad,gst_disksrc_get); gst_element_add_pad (GST_ELEMENT (disksrc), disksrc->srcpad); disksrc->filename = NULL; @@ -202,7 +200,7 @@ gst_disksrc_get_arg (GtkObject *object, GtkArg *arg, guint id) } static void -gst_disksrc_pull (GstPad *pad) +gst_disksrc_get (GstPad *pad) { GstDiskSrc *src; GstBuffer *buf; @@ -228,18 +226,19 @@ gst_disksrc_pull (GstPad *pad) perror ("read()"); gst_buffer_unref (buf); return; - } - else if (readbytes == 0) { + } else if (readbytes == 0) { gst_src_signal_eos (GST_SRC (src)); gst_buffer_unref (buf); return; } /* if we didn't get as many bytes as we asked for, we're at EOF */ - if (readbytes < src->bytes_per_read) + if (readbytes < src->bytes_per_read) { GST_BUFFER_FLAG_SET (buf, GST_BUFFER_EOS); + DEBUG("setting GST_BUFFER_EOS\n"); + } - /* if we have a new buffer froma seek, mark it */ + /* if we have a new buffer from a seek, mark it */ if (src->new_seek) { GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLUSH); src->new_seek = FALSE; @@ -249,10 +248,10 @@ gst_disksrc_pull (GstPad *pad) GST_BUFFER_SIZE (buf) = readbytes; src->curoffset += readbytes; - DEBUG("pushing with offset %d\n", GST_BUFFER_OFFSET (buf)); + DEBUG("pushing %d bytes with offset %d\n", GST_BUFFER_SIZE(buf), GST_BUFFER_OFFSET (buf)); /* we're done, push the buffer off now */ gst_pad_push (pad, buf); - DEBUG("pushing with offset %d done\n", GST_BUFFER_OFFSET (buf)); + DEBUG("pushing %d bytes with offset %d done\n", GST_BUFFER_SIZE(buf), GST_BUFFER_OFFSET (buf)); } diff --git a/gst/elements/gstfakesink.c b/gst/elements/gstfakesink.c index f629294f88..be8af67bf7 100644 --- a/gst/elements/gstfakesink.c +++ b/gst/elements/gstfakesink.c @@ -111,9 +111,7 @@ gst_fakesink_chain (GstPad *pad, GstBuffer *buf) g_return_if_fail (buf != NULL); fakesink = GST_FAKESINK (pad->parent); -// g_print("gst_fakesink_chain: got buffer in '%s'\n", -// gst_element_get_name(GST_ELEMENT(fakesink))); - g_print("<"); + g_print("(%s:%s)< ",GST_DEBUG_PAD_NAME(pad)); gst_buffer_unref (buf); } diff --git a/gst/elements/gstfakesrc.c b/gst/elements/gstfakesrc.c index 47688a3505..306460f34e 100644 --- a/gst/elements/gstfakesrc.c +++ b/gst/elements/gstfakesrc.c @@ -46,7 +46,7 @@ enum { static void gst_fakesrc_class_init (GstFakeSrcClass *klass); static void gst_fakesrc_init (GstFakeSrc *fakesrc); -static void gst_fakesrc_pull (GstPad *pad); +static void gst_fakesrc_get (GstPad *pad); static GstSrcClass *parent_class = NULL; //static guint gst_fakesrc_signals[LAST_SIGNAL] = { 0 }; @@ -85,7 +85,7 @@ gst_fakesrc_class_init (GstFakeSrcClass *klass) static void gst_fakesrc_init(GstFakeSrc *fakesrc) { // create our output pad fakesrc->srcpad = gst_pad_new("src",GST_PAD_SRC); - gst_pad_set_pull_function(fakesrc->srcpad,gst_fakesrc_pull); + gst_pad_set_get_function(fakesrc->srcpad,gst_fakesrc_get); gst_element_add_pad(GST_ELEMENT(fakesrc),fakesrc->srcpad); // we're ready right away, since we don't have any args... @@ -107,12 +107,12 @@ GstElement *gst_fakesrc_new(gchar *name) { } /** - * gst_fakesrc_pull: - * @src: the faksesrc to pull + * gst_fakesrc_get: + * @src: the faksesrc to get * * generate an empty buffer and push it to the next element. */ -void gst_fakesrc_pull(GstPad *pad) { +void gst_fakesrc_get(GstPad *pad) { GstFakeSrc *src; GstBuffer *buf; @@ -120,9 +120,7 @@ void gst_fakesrc_pull(GstPad *pad) { src = GST_FAKESRC(gst_pad_get_parent(pad)); g_return_if_fail(GST_IS_FAKESRC(src)); -// g_print("gst_fakesrc_push(): pushing fake buffer from '%s'\n", -// gst_element_get_name(GST_ELEMENT(src))); - g_print(">"); + g_print("(%s:%s)> ",GST_DEBUG_PAD_NAME(pad)); buf = gst_buffer_new(); gst_pad_push(pad,buf); } diff --git a/gst/elements/gstfdsrc.c b/gst/elements/gstfdsrc.c index 5d33755f44..dfb2447997 100644 --- a/gst/elements/gstfdsrc.c +++ b/gst/elements/gstfdsrc.c @@ -57,7 +57,7 @@ static void gst_fdsrc_init (GstFdSrc *fdsrc); static void gst_fdsrc_set_arg (GtkObject *object, GtkArg *arg, guint id); static void gst_fdsrc_get_arg (GtkObject *object, GtkArg *arg, guint id); -static void gst_fdsrc_pull (GstPad *pad); +static void gst_fdsrc_get (GstPad *pad); static GstSrcClass *parent_class = NULL; @@ -108,7 +108,7 @@ gst_fdsrc_class_init (GstFdSrcClass *klass) static void gst_fdsrc_init(GstFdSrc *fdsrc) { fdsrc->srcpad = gst_pad_new("src",GST_PAD_SRC); - gst_pad_set_pull_function(fdsrc->srcpad,gst_fdsrc_pull); + gst_pad_set_get_function(fdsrc->srcpad,gst_fdsrc_get); gst_element_add_pad(GST_ELEMENT(fdsrc),fdsrc->srcpad); fdsrc->fd = 0; @@ -175,7 +175,7 @@ gst_fdsrc_get_arg (GtkObject *object, GtkArg *arg, guint id) } } -void gst_fdsrc_pull(GstPad *pad) { +void gst_fdsrc_get(GstPad *pad) { GstFdSrc *src; GstBuffer *buf; glong readbytes; diff --git a/gst/elements/gsthttpsrc.c b/gst/elements/gsthttpsrc.c index 578da6c4fb..15eb2a9efc 100644 --- a/gst/elements/gsthttpsrc.c +++ b/gst/elements/gsthttpsrc.c @@ -55,7 +55,7 @@ static void gst_httpsrc_set_arg (GtkObject *object, GtkArg *arg, guint id); static void gst_httpsrc_get_arg (GtkObject *object, GtkArg *arg, guint id); static GstElementStateReturn gst_httpsrc_change_state (GstElement *element); -static void gst_httpsrc_pull (GstPad *pad); +static void gst_httpsrc_get (GstPad *pad); static gboolean gst_httpsrc_open_url (GstHttpSrc *src); static void gst_httpsrc_close_url (GstHttpSrc *src); @@ -112,7 +112,7 @@ gst_httpsrc_class_init (GstHttpSrcClass *klass) static void gst_httpsrc_init(GstHttpSrc *httpsrc) { httpsrc->srcpad = gst_pad_new("src",GST_PAD_SRC); - gst_pad_set_pull_function(httpsrc->srcpad,gst_httpsrc_pull); + gst_pad_set_get_function(httpsrc->srcpad,gst_httpsrc_get); gst_element_add_pad(GST_ELEMENT(httpsrc),httpsrc->srcpad); httpsrc->url = NULL; @@ -122,7 +122,7 @@ static void gst_httpsrc_init(GstHttpSrc *httpsrc) { httpsrc->bytes_per_read = 4096; } -static void gst_httpsrc_pull(GstPad *pad) { +static void gst_httpsrc_get(GstPad *pad) { GstHttpSrc *src; GstBuffer *buf; glong readbytes; diff --git a/gst/elements/gstidentity.c b/gst/elements/gstidentity.c index 332be4df4d..f5546b0cdf 100644 --- a/gst/elements/gstidentity.c +++ b/gst/elements/gstidentity.c @@ -116,9 +116,7 @@ gst_identity_chain (GstPad *pad, GstBuffer *buf) g_return_if_fail (buf != NULL); identity = GST_IDENTITY (pad->parent); -// g_print("gst_identity_chain: got buffer in '%s'\n", -// gst_element_get_name(GST_ELEMENT(identity))); - g_print("i"); + g_print("(%s:%s)i ",GST_DEBUG_PAD_NAME(pad)); gst_pad_push (identity->srcpad, buf); } diff --git a/gst/elements/gstqueue.c b/gst/elements/gstqueue.c index 825e0eb5ca..2f29e4b90c 100644 --- a/gst/elements/gstqueue.c +++ b/gst/elements/gstqueue.c @@ -58,7 +58,7 @@ static void gst_queue_init (GstQueue *queue); static void gst_queue_set_arg (GtkObject *object, GtkArg *arg, guint id); static void gst_queue_get_arg (GtkObject *object, GtkArg *arg, guint id); -static void gst_queue_pull (GstPad *pad); +static void gst_queue_get (GstPad *pad); static void gst_queue_chain (GstPad *pad, GstBuffer *buf); static void gst_queue_flush (GstQueue *queue); @@ -121,7 +121,7 @@ gst_queue_init (GstQueue *queue) gst_element_add_pad (GST_ELEMENT (queue), queue->sinkpad); queue->srcpad = gst_pad_new ("src", GST_PAD_SRC); - gst_pad_set_pull_function (queue->srcpad, gst_queue_pull); + gst_pad_set_get_function (queue->srcpad, gst_queue_get); gst_element_add_pad (GST_ELEMENT (queue), queue->srcpad); queue->queue = NULL; @@ -218,7 +218,7 @@ gst_queue_chain (GstPad *pad, GstBuffer *buf) } static void -gst_queue_pull (GstPad *pad) +gst_queue_get (GstPad *pad) { GstQueue *queue = GST_QUEUE (gst_pad_get_parent(pad)); GstBuffer *buf = NULL; diff --git a/gst/elements/gstsinesrc.c b/gst/elements/gstsinesrc.c index 271e0b30cd..e15c6c2bee 100644 --- a/gst/elements/gstsinesrc.c +++ b/gst/elements/gstsinesrc.c @@ -62,7 +62,7 @@ static void gst_sinesrc_get_arg(GtkObject *object,GtkArg *arg,guint id); //static gboolean gst_sinesrc_open_audio(GstSineSrc *src); void gst_sinesrc_sync_parms(GstSineSrc *sinesrc); -void gst_sinesrc_pull(GstPad *pad); +void gst_sinesrc_get(GstPad *pad); static GstSrcClass *parent_class = NULL; //static guint gst_sinesrc_signals[LAST_SIGNAL] = { 0 }; @@ -116,7 +116,7 @@ gst_sinesrc_class_init(GstSineSrcClass *klass) { static void gst_sinesrc_init(GstSineSrc *sinesrc) { sinesrc->srcpad = gst_pad_new("src",GST_PAD_SRC); - gst_pad_set_pull_function(sinesrc->srcpad,gst_sinesrc_pull); + gst_pad_set_get_function(sinesrc->srcpad,gst_sinesrc_get); gst_element_add_pad(GST_ELEMENT(sinesrc),sinesrc->srcpad); sinesrc->volume = 1.0; @@ -142,7 +142,7 @@ GstElement *gst_sinesrc_new_with_fd(gchar *name,gchar *filename) { return sinesrc; } -void gst_sinesrc_pull(GstPad *pad) { +void gst_sinesrc_get(GstPad *pad) { GstSineSrc *src; GstBuffer *buf; gint16 *samples; diff --git a/gst/gst.c b/gst/gst.c index 2da659d804..879a004e06 100644 --- a/gst/gst.c +++ b/gst/gst.c @@ -28,6 +28,8 @@ extern gint _gst_trace_on; +GHashTable *__gst_function_pointers = NULL; + /** * gst_init: * @argc: pointer to application's argc diff --git a/gst/gstbin.c b/gst/gstbin.c index 2a058f2898..0f25a6507e 100644 --- a/gst/gstbin.c +++ b/gst/gstbin.c @@ -570,17 +570,17 @@ gst_bin_src_wrapper (int argc,char *argv[]) while (pads) { pad = GST_PAD (pads->data); if (pad->direction == GST_PAD_SRC) { - region_struct *region = cothread_get_data (pad->threadstate, "region"); + region_struct *region = cothread_get_data (element->threadstate, "region"); + DEBUG("calling _getfunc for %s:%s\n",GST_DEBUG_PAD_NAME(pad)); if (region) { //gst_src_push_region (GST_SRC (element), region->offset, region->size); - if (pad->pullregionfunc == NULL) - fprintf(stderr,"error, no pullregionfunc in \"%s\"\n", name); - (pad->pullregionfunc)(pad, region->offset, region->size); - } - else { - if (pad->pullfunc == NULL) - fprintf(stderr,"error, no pullfunc in \"%s\"\n", name); - (pad->pullfunc)(pad); + if (pad->getregionfunc == NULL) + fprintf(stderr,"error, no getregionfunc in \"%s\"\n", name); + (pad->getregionfunc)(pad, region->offset, region->size); + } else { + if (pad->getfunc == NULL) + fprintf(stderr,"error, no getfunc in \"%s\"\n", name); + (pad->getfunc)(pad); } } pads = g_list_next(pads); @@ -596,8 +596,9 @@ static void gst_bin_pullfunc_proxy (GstPad *pad) { DEBUG_ENTER("(%s:%s)",GST_DEBUG_PAD_NAME(pad)); - cothread_switch (pad->threadstate); + cothread_switch (GST_ELEMENT(pad->parent)->threadstate); } +*/ static void gst_bin_pullregionfunc_proxy (GstPad *pad, @@ -605,32 +606,56 @@ gst_bin_pullregionfunc_proxy (GstPad *pad, gulong size) { region_struct region; + cothread_state *threadstate; DEBUG_ENTER("%s:%s,%ld,%ld",GST_DEBUG_PAD_NAME(pad),offset,size); region.offset = offset; region.size = size; - cothread_set_data (pad->threadstate, "region", ®ion); - cothread_switch (pad->threadstate); - cothread_set_data (pad->threadstate, "region", NULL); + threadstate = GST_ELEMENT(pad->parent)->threadstate; + cothread_set_data (threadstate, "region", ®ion); + cothread_switch (threadstate); + cothread_set_data (threadstate, "region", NULL); } static void -gst_bin_pushfunc_proxy (GstPad *pad) +gst_bin_pushfunc_proxy (GstPad *pad, GstBuffer *buf) { + cothread_state *threadstate = GST_ELEMENT(pad->parent)->threadstate; DEBUG_ENTER("(%s:%s)",GST_DEBUG_PAD_NAME(pad)); - cothread_switch (pad->threadstate); + DEBUG("putting buffer in peer's pen\n"); + pad->peer->bufpen = buf; + DEBUG("switching to %p (@%p)\n",threadstate,&(GST_ELEMENT(pad->parent)->threadstate)); + cothread_switch (threadstate); + DEBUG("done switching\n"); +} + +static GstBuffer* +gst_bin_pullfunc_proxy (GstPad *pad) +{ + GstBuffer *buf; + + cothread_state *threadstate = GST_ELEMENT(pad->parent)->threadstate; + DEBUG_ENTER("(%s:%s)",GST_DEBUG_PAD_NAME(pad)); + if (pad->bufpen == NULL) { + DEBUG("switching to %p (@%p)\n",threadstate,&(GST_ELEMENT(pad->parent)->threadstate)); + cothread_switch (threadstate); + } + DEBUG("done switching\n"); + buf = pad->bufpen; + pad->bufpen = NULL; + return buf; } static void -gst_bin_pushfunc_fake_proxy (GstPad *pad) { +gst_bin_pushfunc_fake_proxy (GstPad *pad) +{ } static void gst_bin_create_plan_func (GstBin *bin) { - const gchar *binname = gst_element_get_name(GST_ELEMENT(bin)); GList *elements; GstElement *element; int sink_pads; @@ -661,6 +686,7 @@ gst_bin_create_plan_func (GstBin *bin) DEBUG("NEED COTHREADS, it's \"%s\"'s fault\n",gst_element_get_name(element)); break; } + // if it's a complex element, use cothreads else if (GST_ELEMENT_IS_MULTI_IN (element)) { DEBUG("complex element \"%s\" in bin \"%s\"\n", @@ -671,6 +697,7 @@ gst_bin_create_plan_func (GstBin *bin) DEBUG("NEED COTHREADS, it's \"%s\"'s fault\n",gst_element_get_name(element)); break; } + // if it has more than one input pad, use cothreads sink_pads = 0; pads = gst_element_get_pad_list (element); @@ -689,6 +716,7 @@ gst_bin_create_plan_func (GstBin *bin) DEBUG("NEED COTHREADS, it's \"%s\"'s fault\n",gst_element_get_name(element)); break; } + elements = g_list_next (elements); } @@ -719,8 +747,8 @@ gst_bin_create_plan_func (GstBin *bin) element->threadstate = cothread_create (bin->threadcontext); cothread_setfunc (element->threadstate, gst_bin_loopfunc_wrapper, 0, (char **)element); - DEBUG("created element threadstate %p for \"%s\"\n",element->threadstate, - gst_element_get_name(element)); + DEBUG("created cothread %p (@%p) for \"%s\"\n",element->threadstate, + &element->threadstate,gst_element_get_name(element)); } if (GST_IS_BIN (element)) { @@ -737,42 +765,18 @@ gst_bin_create_plan_func (GstBin *bin) while (pads) { pad = GST_PAD(pads->data); - // ***** check for possible connections outside - // get the pad's peer - peer = gst_pad_get_peer (pad); - // FIXME this should be an error condition, if not disabled - if (!peer) break; - // get the parent of the peer of the pad - outside = GST_ELEMENT (gst_pad_get_parent (peer)); - // FIXME this should *really* be an error condition - if (!outside) break; - // if it's a source or connection and it's not ours... - if ((GST_IS_SRC (outside) || GST_IS_CONNECTION (outside)) && - (gst_object_get_parent (GST_OBJECT (outside)) != GST_OBJECT (bin))) { - if (gst_pad_get_direction (pad) == GST_PAD_SINK) { - DEBUG("PUNT: copying pullfunc ptr from %s:%s to %s:%s (@ %p)\n", -GST_DEBUG_PAD_NAME(pad->peer),GST_DEBUG_PAD_NAME(pad),&pad->pullfunc); - pad->pullfunc = pad->peer->pullfunc; - DEBUG("PUNT: setting pushfunc proxy to fake proxy on %s:%s\n",GST_DEBUG_PAD_NAME(pad->peer)); - pad->peer->pushfunc = gst_bin_pushfunc_fake_proxy; - } - } else { - if (gst_pad_get_direction (pad) == GST_PAD_SRC) { - DEBUG("checking/setting push proxy for srcpad %s:%s\n", - GST_DEBUG_PAD_NAME(pad)); - // set the proxy functions - if (!pad->pushfunc) - pad->pushfunc = gst_bin_pushfunc_proxy; - - } else if (gst_pad_get_direction (pad) == GST_PAD_SINK) { - DEBUG("checking/setting pull proxies for sinkpad %s:%s\n",GST_DEBUG_PAD_NAME(pad)); - // set the proxy functions - if (!pad->pullfunc) - pad->pullfunc = gst_bin_pullfunc_proxy; - if (!pad->pullregionfunc) - pad->pullregionfunc = gst_bin_pullregionfunc_proxy; - } - //pad->threadstate = element->threadstate; + if (gst_pad_get_direction (pad) == GST_PAD_SINK) { + DEBUG("setting push proxy for sinkpad %s:%s\n",GST_DEBUG_PAD_NAME(pad)); + // set the proxy functions + pad->pushfunc = GST_DEBUG_FUNCPTR(gst_bin_pushfunc_proxy); + DEBUG("pushfunc %p = gst_bin_pushfunc_proxy %p\n",&pad->pushfunc,gst_bin_pushfunc_proxy); + } else if (gst_pad_get_direction (pad) == GST_PAD_SRC) { + DEBUG("setting pull proxies for srcpad %s:%s\n",GST_DEBUG_PAD_NAME(pad)); + // set the proxy functions + pad->pullfunc = GST_DEBUG_FUNCPTR(gst_bin_pullfunc_proxy); + DEBUG("pad->pullfunc(@%p) = gst_bin_pullfunc_proxy(@%p)\n", + &pad->pullfunc,gst_bin_pullfunc_proxy); + pad->pullregionfunc = GST_DEBUG_FUNCPTR(gst_bin_pullregionfunc_proxy); } pads = g_list_next (pads); } @@ -783,52 +787,60 @@ GST_DEBUG_PAD_NAME(pad->peer),GST_DEBUG_PAD_NAME(pad),&pad->pullfunc); bin->entries = g_list_prepend (bin->entries, GST_ELEMENT(bin->children->data)); } } else { - g_print("gstbin: don't need cothreads, looking for entry points\n"); + DEBUG("don't need cothreads, looking for entry points\n"); // we have to find which elements will drive an iteration elements = bin->children; while (elements) { element = GST_ELEMENT (elements->data); - g_print("gstbin: found element \"%s\"\n", gst_element_get_name (element)); + DEBUG("found element \"%s\"\n", gst_element_get_name (element)); if (GST_IS_BIN (element)) { - gst_bin_create_plan (GST_BIN (element)); + gst_bin_create_plan (GST_BIN (element)); } if (GST_IS_SRC (element)) { - g_print("adding '%s' as entry point, because it's a source\n",gst_element_get_name (element)); + DEBUG("adding '%s' as entry point, because it's a source\n",gst_element_get_name (element)); bin->entries = g_list_prepend (bin->entries, element); bin->numentries++; - } else { - /* go through the list of pads to see if there's a Connection */ - pads = gst_element_get_pad_list (element); - while (pads) { - pad = GST_PAD (pads->data); - /* we only worry about sink pads */ - if (gst_pad_get_direction (pad) == GST_PAD_SINK) { - g_print("gstbin '%s': found SINK pad %s:%s\n", binname, GST_DEBUG_PAD_NAME(pad)); - /* get the pad's peer */ - peer = gst_pad_get_peer (pad); - if (!peer) { - g_print("gstbin: found SINK pad %s has no peer\n", gst_pad_get_name (pad)); - break; - } - /* get the parent of the peer of the pad */ - outside = GST_ELEMENT (gst_pad_get_parent (peer)); - if (!outside) break; - /* if it's a connection and it's not ours... */ - if (GST_IS_CONNECTION (outside) && - (gst_object_get_parent (GST_OBJECT (outside)) != GST_OBJECT (bin))) { - gst_info("gstbin: element \"%s\" is the external source Connection " + } + + // go through all the pads, set pointers, and check for connections + pads = gst_element_get_pad_list (element); + while (pads) { + pad = GST_PAD (pads->data); + + if (gst_pad_get_direction (pad) == GST_PAD_SINK) { + DEBUG("found SINK pad %s:%s\n", GST_DEBUG_PAD_NAME(pad)); + + // copy the peer's chain function, easy enough + DEBUG("copying peer's chainfunc to %s:%s's pushfunc\n",GST_DEBUG_PAD_NAME(pad)); + pad->pushfunc = pad->peer->chainfunc; + + // need to walk through and check for outside connections +//FIXME need to do this for all pads + /* get the pad's peer */ + peer = gst_pad_get_peer (pad); + if (!peer) { + DEBUG("found SINK pad %s has no peer\n", gst_pad_get_name (pad)); + break; + } + /* get the parent of the peer of the pad */ + outside = GST_ELEMENT (gst_pad_get_parent (peer)); + if (!outside) break; + /* if it's a connection and it's not ours... */ + if (GST_IS_CONNECTION (outside) && + (gst_object_get_parent (GST_OBJECT (outside)) != GST_OBJECT (bin))) { + gst_info("gstbin: element \"%s\" is the external source Connection " "for internal element \"%s\"\n", - gst_element_get_name (GST_ELEMENT (outside)), - gst_element_get_name (GST_ELEMENT (element))); - bin->entries = g_list_prepend (bin->entries, outside); - bin->numentries++; - } + gst_element_get_name (GST_ELEMENT (outside)), + gst_element_get_name (GST_ELEMENT (element))); + bin->entries = g_list_prepend (bin->entries, outside); + bin->numentries++; } - else { - g_print("gstbin: found pad %s\n", gst_pad_get_name (pad)); - } - pads = g_list_next (pads); } + else { + DEBUG("found pad %s\n", gst_pad_get_name (pad)); + } + pads = g_list_next (pads); + } elements = g_list_next (elements); } @@ -856,22 +868,25 @@ gst_bin_iterate_func (GstBin *bin) if (bin->need_cothreads) { // all we really have to do is switch to the first child // FIXME this should be lots more intelligent about where to start + DEBUG("starting iteration via cothreads\n"); if (GST_IS_ELEMENT(bin->entries->data)) { entry = GST_ELEMENT (bin->entries->data); GST_FLAG_SET (entry, GST_ELEMENT_COTHREAD_STOPPING); - DEBUG("set COTHREAD_STOPPING flag on \"%s\"(%p)\n", + DEBUG("set COTHREAD_STOPPING flag on \"%s\"(@%p)\n", gst_element_get_name(entry),entry); cothread_switch (entry->threadstate); } else { sched = (_GstBinOutsideSchedule *) (bin->entries->data); sched->flags |= GST_ELEMENT_COTHREAD_STOPPING; - DEBUG("set COTHREAD STOPPING flag on sched for \"%s\"(%p)\n", + DEBUG("set COTHREAD STOPPING flag on sched for \"%s\"(@%p)\n", gst_element_get_name(sched->element),sched->element); cothread_switch (sched->threadstate); } } else { + DEBUG("starting iteration via chain-functions\n"); + if (bin->numentries <= 0) { //printf("gstbin: no entries in bin \"%s\" trying children...\n", gst_element_get_name(GST_ELEMENT(bin))); // we will try loop over the elements then... @@ -890,10 +905,11 @@ gst_bin_iterate_func (GstBin *bin) while (pads) { pad = GST_PAD (pads->data); if (pad->direction == GST_PAD_SRC) { - if (pad->pullfunc == NULL) - fprintf(stderr, "error, no pullfunc in \"%s\"\n", gst_element_get_name (entry)); + DEBUG("calling getfunc of %s:%s\n",GST_DEBUG_PAD_NAME(pad)); + if (pad->getfunc == NULL) + fprintf(stderr, "error, no getfunc in \"%s\"\n", gst_element_get_name (entry)); else - (pad->pullfunc)(pad); + (pad->getfunc)(pad); } pads = g_list_next (pads); } @@ -911,3 +927,30 @@ gst_bin_iterate_func (GstBin *bin) DEBUG_LEAVE("(%s)", gst_element_get_name (GST_ELEMENT (bin))); } + + + +/* + // ***** check for possible connections outside + // get the pad's peer + peer = gst_pad_get_peer (pad); + // FIXME this should be an error condition, if not disabled + if (!peer) break; + // get the parent of the peer of the pad + outside = GST_ELEMENT (gst_pad_get_parent (peer)); + // FIXME this should *really* be an error condition + if (!outside) break; + // if it's a source or connection and it's not ours... + if ((GST_IS_SRC (outside) || GST_IS_CONNECTION (outside)) && + (gst_object_get_parent (GST_OBJECT (outside)) != GST_OBJECT (bin))) { + if (gst_pad_get_direction (pad) == GST_PAD_SINK) { + DEBUG("dealing with outside source element %s\n",gst_element_get_name(outside)); +// DEBUG("PUNT: copying pullfunc ptr from %s:%s to %s:%s (@ %p)\n", +//GST_DEBUG_PAD_NAME(pad->peer),GST_DEBUG_PAD_NAME(pad),&pad->pullfunc); +// pad->pullfunc = pad->peer->pullfunc; +// DEBUG("PUNT: setting pushfunc proxy to fake proxy on %s:%s\n",GST_DEBUG_PAD_NAME(pad->peer)); +// pad->peer->pushfunc = GST_DEBUG_FUNCPTR(gst_bin_pushfunc_fake_proxy); + pad->pullfunc = GST_DEBUG_FUNCPTR(gst_bin_pullfunc_proxy); + } + } else { +*/ diff --git a/gst/gstbuffer.h b/gst/gstbuffer.h index 563f86bbb4..5b0b2a9e8e 100644 --- a/gst/gstbuffer.h +++ b/gst/gstbuffer.h @@ -63,11 +63,13 @@ extern "C" { typedef enum { - GST_BUFFER_READONLY = (1 << 0), - GST_BUFFER_EOS = (1 << 1), - GST_BUFFER_ORIGINAL = (1 << 2), - GST_BUFFER_DONTFREE = (1 << 3), - GST_BUFFER_FLUSH = (1 << 4), + GST_BUFFER_READONLY = GST_OBJECT_FLAG_LAST, + GST_BUFFER_ORIGINAL, + GST_BUFFER_DONTFREE, + GST_BUFFER_FLUSH, + GST_BUFFER_EOS, + + GST_BUFFER_FLAG_LAST = GST_OBJECT_FLAG_LAST + 8, } GstBufferFlags; diff --git a/gst/gstdebug.h b/gst/gstdebug.h index 5059089960..82d261b657 100644 --- a/gst/gstdebug.h +++ b/gst/gstdebug.h @@ -120,4 +120,35 @@ G_GNUC_UNUSED static GModule *_debug_self_module = NULL; #define GST_DEBUG_PAD_NAME(pad) \ ((pad)->parent != NULL) ? gst_element_get_name(GST_ELEMENT((pad)->parent)) : "''", gst_pad_get_name(pad) + + +/********** function pointer stuff **********/ +extern GHashTable *__gst_function_pointers; + +#ifdef GST_DEBUG_ENABLED +#define GST_DEBUG_FUNCPTR(ptr) _gst_debug_register_funcptr((void *)(ptr), #ptr) +#define GST_DEBUG_FUNCPTR_NAME(ptr) _gst_debug_nameof_funcptr((void *)ptr) +#else +#define GST_DEBUG_FUNCPTR(ptr) (ptr) +#define GST_DEBUG_FUNCPTR_NAME(ptr) "" +#endif + +static inline void * +_gst_debug_register_funcptr (void *ptr, gchar *ptrname) +{ + if (!__gst_function_pointers) __gst_function_pointers = g_hash_table_new(g_direct_hash,g_direct_equal); + if (!g_hash_table_lookup(__gst_function_pointers,ptr)) + g_hash_table_insert(__gst_function_pointers,ptr,ptrname); + return ptr; +} + +static inline gchar * +_gst_debug_nameof_funcptr (void *ptr) +{ + gchar *ptrname = __gst_function_pointers ? g_hash_table_lookup(__gst_function_pointers,ptr) : NULL; +// FIXME this must go away, it's a major leak + if (!ptrname) return g_strdup_printf("%p",ptr); + else return ptrname; +} + #endif /* __GST_H__ */ diff --git a/gst/gstpad.c b/gst/gstpad.c index 27bb19846e..b7d478d61e 100644 --- a/gst/gstpad.c +++ b/gst/gstpad.c @@ -47,6 +47,8 @@ static void gst_pad_get_arg(GtkObject *object,GtkArg *arg,guint id); static void gst_pad_real_destroy(GtkObject *object); +static void gst_pad_push_func(GstPad *pad, GstBuffer *buf); + static GstObject *parent_class = NULL; static guint gst_pad_signals[LAST_SIGNAL] = { 0 }; @@ -104,11 +106,16 @@ gst_pad_init (GstPad *pad) { pad->direction = GST_PAD_UNKNOWN; pad->peer = NULL; + pad->chainfunc = NULL; + pad->getfunc = NULL; + pad->getregionfunc = NULL; + pad->qosfunc = NULL; + + pad->pushfunc = NULL; //GST_DEBUG_FUNCPTR(gst_pad_push_func); pad->pullfunc = NULL; pad->pullregionfunc = NULL; - pad->pushfunc = NULL; - pad->qosfunc = NULL; + pad->parent = NULL; pad->ghostparents = NULL; pad->caps = NULL; @@ -256,46 +263,6 @@ gst_pad_get_name (GstPad *pad) return pad->name; } -/** - * gst_pad_set_pull_function: - * @pad: the pad to set the pull function for - * @pull: the pull function - * - * Set the given pull function for the pad - */ -void -gst_pad_set_pull_function (GstPad *pad, - GstPadPullFunction pull) -{ - g_return_if_fail (pad != NULL); - g_return_if_fail (GST_IS_PAD (pad)); - - // the if and such should optimize out when DEBUG is off - DEBUG("setting pull function for %s:%s\n",GST_DEBUG_PAD_NAME(pad)); - - pad->pullfunc = pull; - DEBUG("pullfunc for %s:%s(%p) at %p is set to %p\n",GST_DEBUG_PAD_NAME(pad),pad,&pad->pullfunc,pull); -} - -/** - * gst_pad_set_pullregion_function: - * @pad: the pad to set the pull function for - * @pull: the pull function - * - * Set the given pull function for the pad - */ -void -gst_pad_set_pullregion_function (GstPad *pad, - GstPadPullRegionFunction pull) -{ - g_return_if_fail (pad != NULL); - g_return_if_fail (GST_IS_PAD (pad)); - - g_print("gstpad: pad setting pullregion function\n"); - - pad->pullregionfunc = pull; -} - /** * gst_pad_set_chain_function: * @pad: the pad to set the chain function for @@ -312,6 +279,46 @@ void gst_pad_set_chain_function (GstPad *pad, pad->chainfunc = chain; } +/** + * gst_pad_set_pull_function: + * @pad: the pad to set the get function for + * @get: the get function + * + * Set the given get function for the pad + */ +void +gst_pad_set_get_function (GstPad *pad, + GstPadGetFunction get) +{ + g_return_if_fail (pad != NULL); + g_return_if_fail (GST_IS_PAD (pad)); + + // the if and such should optimize out when DEBUG is off + DEBUG("setting get function for %s:%s\n",GST_DEBUG_PAD_NAME(pad)); + + pad->getfunc = get; + DEBUG("getfunc for %s:%s(@%p) at %p is set to %p\n",GST_DEBUG_PAD_NAME(pad),pad,&pad->getfunc,get); +} + +/** + * gst_pad_set_getregion_function: + * @pad: the pad to set the getregion function for + * @getregion: the getregion function + * + * Set the given getregion function for the pad + */ +void +gst_pad_set_getregion_function (GstPad *pad, + GstPadGetRegionFunction getregion) +{ + g_return_if_fail (pad != NULL); + g_return_if_fail (GST_IS_PAD (pad)); + + g_print("gstpad: pad setting getregion function\n"); + + pad->getregionfunc = getregion; +} + /** * gst_pad_set_qos_function: * @pad: the pad to set the qos function for @@ -329,6 +336,17 @@ gst_pad_set_qos_function (GstPad *pad, pad->qosfunc = qos; } +static void +gst_pad_push_func(GstPad *pad, GstBuffer *buf) +{ + if (pad->peer->chainfunc != NULL) { + DEBUG("calling chain function\n"); + (pad->peer->chainfunc)(pad,buf); + } else { + DEBUG("got a problem here: default pad_push handler in place, no chain function\n"); + } +} + /** * gst_pad_push: * @pad: the pad to push @@ -336,20 +354,21 @@ gst_pad_set_qos_function (GstPad *pad, * * pushes a buffer along a src pad */ +/* void gst_pad_push (GstPad *pad, GstBuffer *buffer) { GstPad *peer; - DEBUG_ENTER("(pad:'%s'(%p),buffer:%p)",gst_pad_get_name(pad),pad,buffer); + DEBUG_ENTER("(pad:'%s'(@%p),buffer:%p)",gst_pad_get_name(pad),pad,buffer); g_return_if_fail(pad != NULL); g_return_if_fail(GST_IS_PAD(pad)); g_return_if_fail(GST_PAD_CONNECTED(pad)); g_return_if_fail(buffer != NULL); - /* if the pad has been disabled, unreference the pad and let it drop */ + // if the pad has been disabled, unreference the pad and let it drop if (GST_FLAG_IS_SET(pad,GST_PAD_DISABLED)) { g_print("gst_pad_push: pad disabled, dropping buffer\n"); gst_buffer_unref(buffer); @@ -378,6 +397,7 @@ gst_pad_push (GstPad *pad, g_print("-- gst_pad_push(): houston, we have a problem, no way of talking to peer\n"); } } +*/ /** * gst_pad_pull: @@ -387,6 +407,7 @@ gst_pad_push (GstPad *pad, * * Returns: the buffer that was pulled */ +/* GstBuffer* gst_pad_pull (GstPad *pad) { @@ -397,8 +418,8 @@ gst_pad_pull (GstPad *pad) g_return_val_if_fail(pad != NULL, NULL); g_return_val_if_fail(GST_IS_PAD(pad), NULL); - /* check to see if the peer pad is disabled. return NULL if it is */ - /* FIXME: this may be the wrong way to go about it */ + // check to see if the peer pad is disabled. return NULL if it is + // FIXME: this may be the wrong way to go about it if (GST_FLAG_IS_SET(pad->peer,GST_PAD_DISABLED)) { DEBUG("pad disabled, returning NULL\n"); return NULL; @@ -429,6 +450,7 @@ gst_pad_pull (GstPad *pad) return NULL; } +*/ /** * gst_pad_pull_region: @@ -440,6 +462,7 @@ gst_pad_pull (GstPad *pad) * * Returns: the buffer that was pulled */ +/* GstBuffer* gst_pad_pull_region (GstPad *pad, gulong offset, @@ -478,6 +501,7 @@ gst_pad_pull_region (GstPad *pad, return NULL; } +*/ /** * gst_pad_chain: @@ -981,3 +1005,43 @@ gst_padtemplate_load_thyself (xmlNodePtr parent) +#ifndef gst_pad_push +void gst_pad_push(GstPad *pad,GstBuffer *buf) { + DEBUG_ENTER("(%s:%s)",GST_DEBUG_PAD_NAME(pad)); + if (pad->peer->pushfunc) { + DEBUG("calling pushfunc &%s of peer pad %s:%s\n", + GST_DEBUG_FUNCPTR_NAME(pad->peer->pushfunc),GST_DEBUG_PAD_NAME(pad->peer)); + (pad->peer->pushfunc)(pad->peer,buf); + } else + DEBUG("no pushfunc\n"); +} +#endif + +#ifndef gst_pad_pull +GstBuffer *gst_pad_pull(GstPad *pad) { + GstPad *peer = pad->peer; + DEBUG_ENTER("(%s:%s)",GST_DEBUG_PAD_NAME(pad)); + if (peer->pullfunc) { + DEBUG("calling pullfunc &%s (@%p) of peer pad %s:%s\n", + GST_DEBUG_FUNCPTR_NAME(peer->pullfunc),&peer->pullfunc,GST_DEBUG_PAD_NAME(peer)); + return (peer->pullfunc)(peer); + } else { + DEBUG("no pullfunc for peer pad %s:%s at %p\n",GST_DEBUG_PAD_NAME(peer),&peer->pullfunc); + return NULL; + } +} +#endif + +#ifndef gst_pad_pullregion +GstBuffer *gst_pad_pullregion(GstPad *pad,gulong offset,gulong size) { + DEBUG_ENTER("(%s:%s,%ld,%ld)",GST_DEBUG_PAD_NAME(pad),offset,size); + if (pad->peer->pullregionfunc) { + DEBUG("calling pullregionfunc &%s of peer pad %s:%s\n", + GST_DEBUG_FUNCPTR_NAME(pad->peer->pullregionfunc),GST_DEBUG_PAD_NAME(pad->peer)); + return (pad->peer->pullregionfunc)(pad->peer,offset,size); + } else { + DEBUG("no pullregionfunc\n"); + return NULL; + } +} +#endif diff --git a/gst/gstpad.h b/gst/gstpad.h index 0d975d8ab0..0db874dfe2 100644 --- a/gst/gstpad.h +++ b/gst/gstpad.h @@ -44,6 +44,7 @@ extern "C" { #define GST_PAD_CONNECTED(pad) ((pad) && (pad)->peer != NULL) #define GST_PAD_CAN_PULL(pad) ((pad) && (pad)->pullfunc != NULL) + typedef struct _GstPad GstPad; typedef struct _GstPadClass GstPadClass; @@ -51,11 +52,14 @@ typedef struct _GstPadClass GstPadClass; * pad is the sink pad (so the same chain function can be used for N pads) * buf is the buffer being passed */ typedef void (*GstPadChainFunction) (GstPad *pad,GstBuffer *buf); -typedef void (*GstPadPullFunction) (GstPad *pad); -typedef void (*GstPadPullRegionFunction) (GstPad *pad, gulong offset, gulong size); -typedef void (*GstPadPushFunction) (GstPad *pad); +typedef void (*GstPadGetFunction) (GstPad *pad); +typedef void (*GstPadGetRegionFunction) (GstPad *pad, gulong offset, gulong size); typedef void (*GstPadQoSFunction) (GstPad *pad, glong qos_message); +typedef void (*GstPadPushFunction) (GstPad *pad, GstBuffer *buf); +typedef GstBuffer *(*GstPadPullFunction) (GstPad *pad); +typedef GstBuffer *(*GstPadPullRegionFunction) (GstPad *pad, gulong offset, gulong size); + typedef enum { GST_PAD_UNKNOWN, GST_PAD_SRC, @@ -64,8 +68,9 @@ typedef enum { typedef enum { GST_PAD_DISABLED = GST_OBJECT_FLAG_LAST, + GST_PAD_EOS, - GST_PAD_FLAG_LAST = GST_OBJECT_FLAG_LAST+2, + GST_PAD_FLAG_LAST = GST_OBJECT_FLAG_LAST + 4, } GstPadFlags; struct _GstPad { @@ -83,10 +88,13 @@ struct _GstPad { GstBuffer *bufpen; GstPadChainFunction chainfunc; + GstPadGetFunction getfunc; + GstPadGetRegionFunction getregionfunc; + GstPadQoSFunction qosfunc; + GstPadPushFunction pushfunc; GstPadPullFunction pullfunc; GstPadPullRegionFunction pullregionfunc; - GstPadQoSFunction qosfunc; GstObject *parent; GList *ghostparents; @@ -98,6 +106,7 @@ struct _GstPadClass { /* signal callbacks */ void (*set_active) (GstPad *pad, gboolean active); void (*caps_changed) (GstPad *pad, GstCaps *newcaps); + void (*eos) (GstPad *pad); }; typedef enum { @@ -133,8 +142,8 @@ GstPad* gst_pad_new_from_template (GstPadTemplate *temp, gchar *name); GstPadDirection gst_pad_get_direction (GstPad *pad); void gst_pad_set_chain_function (GstPad *pad, GstPadChainFunction chain); -void gst_pad_set_pull_function (GstPad *pad, GstPadPullFunction pull); -void gst_pad_set_pullregion_function (GstPad *pad, GstPadPullRegionFunction pullregion); +void gst_pad_set_get_function (GstPad *pad, GstPadGetFunction get); +void gst_pad_set_getregion_function (GstPad *pad, GstPadGetRegionFunction getregion); void gst_pad_set_qos_function (GstPad *pad, GstPadQoSFunction qos); void gst_pad_set_caps (GstPad *pad, GstCaps *caps); @@ -154,9 +163,23 @@ GstPad* gst_pad_get_peer (GstPad *pad); void gst_pad_connect (GstPad *srcpad, GstPad *sinkpad); void gst_pad_disconnect (GstPad *srcpad, GstPad *sinkpad); +#if 1 void gst_pad_push (GstPad *pad, GstBuffer *buffer); +#else +#define gst_pad_push(pad,buf) G_STMT_START{ \ + if ((pad)->peer->pushfunc) ((pad)->peer->pushfunc)((pad)->peer,(buf)); \ +}G_STMT_END +#endif +#if 1 GstBuffer* gst_pad_pull (GstPad *pad); GstBuffer* gst_pad_pull_region (GstPad *pad, gulong offset, gulong size); +#else +#define gst_pad_pull(pad) \ + (((pad)->peer->pullfunc) ? ((pad)->peer->pullfunc)((pad)->peer) : NULL) +#define gst_pad_pullregion(pad,offset,size) \ + (((pad)->peer->pullregionfunc) ? ((pad)->peer->pullregionfunc)((pad)->peer,(offset),(size)) : NULL) +#endif + void gst_pad_handle_qos (GstPad *pad, glong qos_message); xmlNodePtr gst_pad_save_thyself (GstPad *pad, xmlNodePtr parent); diff --git a/gst/gstpipeline.c b/gst/gstpipeline.c index 5b7cd965c1..72b356c1ec 100644 --- a/gst/gstpipeline.c +++ b/gst/gstpipeline.c @@ -55,7 +55,7 @@ static void gst_pipeline_prepare (GstPipeline *pipeline); static void gst_pipeline_have_type (GstSink *sink, GstSink *sink2, gpointer data); static void gst_pipeline_pads_autoplug (GstElement *src, GstElement *sink); -static GstBin *parent_class = NULL; +static GstBinClass *parent_class = NULL; //static guint gst_pipeline_signals[LAST_SIGNAL] = { 0 }; GtkType diff --git a/gst/gstthread.c b/gst/gstthread.c index edf1a2db80..df29b8c175 100644 --- a/gst/gstthread.c +++ b/gst/gstthread.c @@ -61,7 +61,7 @@ static void gst_thread_create_plan_dummy (GstBin *bin); static void* gst_thread_main_loop (void *arg); -static GstBin *parent_class = NULL; +static GstBinClass *parent_class = NULL; //static guint gst_thread_signals[LAST_SIGNAL] = { 0 }; GtkType diff --git a/plugins/elements/gstasyncdisksrc.c b/plugins/elements/gstasyncdisksrc.c index a12d008cb2..dd3f60d865 100644 --- a/plugins/elements/gstasyncdisksrc.c +++ b/plugins/elements/gstasyncdisksrc.c @@ -57,8 +57,8 @@ static void gst_asyncdisksrc_init (GstAsyncDiskSrc *asyncdisksrc); static void gst_asyncdisksrc_set_arg (GtkObject *object, GtkArg *arg, guint id); static void gst_asyncdisksrc_get_arg (GtkObject *object, GtkArg *arg, guint id); -static void gst_asyncdisksrc_pull (GstPad *pad); -static void gst_asyncdisksrc_pull_region (GstPad *pad, gulong offset, gulong size); +static void gst_asyncdisksrc_get (GstPad *pad); +static void gst_asyncdisksrc_get_region (GstPad *pad, gulong offset, gulong size); static GstElementStateReturn gst_asyncdisksrc_change_state (GstElement *element); @@ -122,9 +122,8 @@ gst_asyncdisksrc_init (GstAsyncDiskSrc *asyncdisksrc) g_print("init\n"); asyncdisksrc->srcpad = gst_pad_new ("src", GST_PAD_SRC); - gst_pad_set_pull_function (asyncdisksrc->srcpad,gst_asyncdisksrc_pull); - gst_pad_set_pullregion_function (asyncdisksrc->srcpad,gst_asyncdisksrc_pull_region); - // FIXME must set pullregion + gst_pad_set_get_function (asyncdisksrc->srcpad,gst_asyncdisksrc_get); + gst_pad_set_getregion_function (asyncdisksrc->srcpad,gst_asyncdisksrc_get_region); gst_element_add_pad (GST_ELEMENT (asyncdisksrc), asyncdisksrc->srcpad); asyncdisksrc->filename = NULL; @@ -205,13 +204,13 @@ gst_asyncdisksrc_get_arg (GtkObject *object, GtkArg *arg, guint id) } /** - * gst_asyncdisksrc_pull: + * gst_asyncdisksrc_get: * @pad: #GstPad to push a buffer from * * Push a new buffer from the asyncdisksrc at the current offset. */ static void -gst_asyncdisksrc_pull (GstPad *pad) +gst_asyncdisksrc_get (GstPad *pad) { GstAsyncDiskSrc *src; GstBuffer *buf; @@ -256,7 +255,7 @@ gst_asyncdisksrc_pull (GstPad *pad) } /** - * gst_asyncdisksrc_pull_region: + * gst_asyncdisksrc_get_region: * @src: #GstSrc to push a buffer from * @offset: offset in file * @size: number of bytes @@ -264,7 +263,7 @@ gst_asyncdisksrc_pull (GstPad *pad) * Push a new buffer from the asyncdisksrc of given size at given offset. */ static void -gst_asyncdisksrc_pull_region (GstPad *pad, gulong offset, gulong size) +gst_asyncdisksrc_get_region (GstPad *pad, gulong offset, gulong size) { GstAsyncDiskSrc *src; GstBuffer *buf; diff --git a/plugins/elements/gstaudiosrc.c b/plugins/elements/gstaudiosrc.c index 6e89a77b73..91a3a2bf18 100644 --- a/plugins/elements/gstaudiosrc.c +++ b/plugins/elements/gstaudiosrc.c @@ -64,7 +64,7 @@ static void gst_audiosrc_close_audio (GstAudioSrc *src); static gboolean gst_audiosrc_open_audio (GstAudioSrc *src); static void gst_audiosrc_sync_parms (GstAudioSrc *audiosrc); -static void gst_audiosrc_pull (GstPad *pad); +static void gst_audiosrc_get (GstPad *pad); static GstSrcClass *parent_class = NULL; //static guint gst_audiosrc_signals[LAST_SIGNAL] = { 0 }; @@ -124,7 +124,7 @@ static void gst_audiosrc_init (GstAudioSrc *audiosrc) { audiosrc->srcpad = gst_pad_new ("src", GST_PAD_SRC); - gst_pad_set_pull_function(audiosrc->srcpad,gst_audiosrc_pull); + gst_pad_set_get_function(audiosrc->srcpad,gst_audiosrc_get); gst_element_add_pad (GST_ELEMENT (audiosrc), audiosrc->srcpad); audiosrc->fd = -1; @@ -140,7 +140,7 @@ gst_audiosrc_init (GstAudioSrc *audiosrc) audiosrc->seq = 0; } -void gst_audiosrc_pull(GstPad *pad) { +void gst_audiosrc_get(GstPad *pad) { GstAudioSrc *src; GstBuffer *buf; glong readbytes; diff --git a/plugins/elements/gstdisksrc.c b/plugins/elements/gstdisksrc.c index e985df3aec..ea49fd769d 100644 --- a/plugins/elements/gstdisksrc.c +++ b/plugins/elements/gstdisksrc.c @@ -22,8 +22,6 @@ #include #include -//#define DEBUG_ENABLED - #include @@ -60,7 +58,7 @@ static void gst_disksrc_get_arg (GtkObject *object, GtkArg *arg, guint id); static void gst_disksrc_close_file (GstDiskSrc *src); -static void gst_disksrc_pull (GstPad *pad); +static void gst_disksrc_get (GstPad *pad); static GstElementStateReturn gst_disksrc_change_state (GstElement *element); @@ -120,7 +118,7 @@ static void gst_disksrc_init (GstDiskSrc *disksrc) { disksrc->srcpad = gst_pad_new ("src", GST_PAD_SRC); - gst_pad_set_pull_function(disksrc->srcpad,gst_disksrc_pull); + gst_pad_set_get_function(disksrc->srcpad,gst_disksrc_get); gst_element_add_pad (GST_ELEMENT (disksrc), disksrc->srcpad); disksrc->filename = NULL; @@ -202,7 +200,7 @@ gst_disksrc_get_arg (GtkObject *object, GtkArg *arg, guint id) } static void -gst_disksrc_pull (GstPad *pad) +gst_disksrc_get (GstPad *pad) { GstDiskSrc *src; GstBuffer *buf; @@ -228,18 +226,19 @@ gst_disksrc_pull (GstPad *pad) perror ("read()"); gst_buffer_unref (buf); return; - } - else if (readbytes == 0) { + } else if (readbytes == 0) { gst_src_signal_eos (GST_SRC (src)); gst_buffer_unref (buf); return; } /* if we didn't get as many bytes as we asked for, we're at EOF */ - if (readbytes < src->bytes_per_read) + if (readbytes < src->bytes_per_read) { GST_BUFFER_FLAG_SET (buf, GST_BUFFER_EOS); + DEBUG("setting GST_BUFFER_EOS\n"); + } - /* if we have a new buffer froma seek, mark it */ + /* if we have a new buffer from a seek, mark it */ if (src->new_seek) { GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLUSH); src->new_seek = FALSE; @@ -249,10 +248,10 @@ gst_disksrc_pull (GstPad *pad) GST_BUFFER_SIZE (buf) = readbytes; src->curoffset += readbytes; - DEBUG("pushing with offset %d\n", GST_BUFFER_OFFSET (buf)); + DEBUG("pushing %d bytes with offset %d\n", GST_BUFFER_SIZE(buf), GST_BUFFER_OFFSET (buf)); /* we're done, push the buffer off now */ gst_pad_push (pad, buf); - DEBUG("pushing with offset %d done\n", GST_BUFFER_OFFSET (buf)); + DEBUG("pushing %d bytes with offset %d done\n", GST_BUFFER_SIZE(buf), GST_BUFFER_OFFSET (buf)); } diff --git a/plugins/elements/gstfakesink.c b/plugins/elements/gstfakesink.c index f629294f88..be8af67bf7 100644 --- a/plugins/elements/gstfakesink.c +++ b/plugins/elements/gstfakesink.c @@ -111,9 +111,7 @@ gst_fakesink_chain (GstPad *pad, GstBuffer *buf) g_return_if_fail (buf != NULL); fakesink = GST_FAKESINK (pad->parent); -// g_print("gst_fakesink_chain: got buffer in '%s'\n", -// gst_element_get_name(GST_ELEMENT(fakesink))); - g_print("<"); + g_print("(%s:%s)< ",GST_DEBUG_PAD_NAME(pad)); gst_buffer_unref (buf); } diff --git a/plugins/elements/gstfakesrc.c b/plugins/elements/gstfakesrc.c index 47688a3505..306460f34e 100644 --- a/plugins/elements/gstfakesrc.c +++ b/plugins/elements/gstfakesrc.c @@ -46,7 +46,7 @@ enum { static void gst_fakesrc_class_init (GstFakeSrcClass *klass); static void gst_fakesrc_init (GstFakeSrc *fakesrc); -static void gst_fakesrc_pull (GstPad *pad); +static void gst_fakesrc_get (GstPad *pad); static GstSrcClass *parent_class = NULL; //static guint gst_fakesrc_signals[LAST_SIGNAL] = { 0 }; @@ -85,7 +85,7 @@ gst_fakesrc_class_init (GstFakeSrcClass *klass) static void gst_fakesrc_init(GstFakeSrc *fakesrc) { // create our output pad fakesrc->srcpad = gst_pad_new("src",GST_PAD_SRC); - gst_pad_set_pull_function(fakesrc->srcpad,gst_fakesrc_pull); + gst_pad_set_get_function(fakesrc->srcpad,gst_fakesrc_get); gst_element_add_pad(GST_ELEMENT(fakesrc),fakesrc->srcpad); // we're ready right away, since we don't have any args... @@ -107,12 +107,12 @@ GstElement *gst_fakesrc_new(gchar *name) { } /** - * gst_fakesrc_pull: - * @src: the faksesrc to pull + * gst_fakesrc_get: + * @src: the faksesrc to get * * generate an empty buffer and push it to the next element. */ -void gst_fakesrc_pull(GstPad *pad) { +void gst_fakesrc_get(GstPad *pad) { GstFakeSrc *src; GstBuffer *buf; @@ -120,9 +120,7 @@ void gst_fakesrc_pull(GstPad *pad) { src = GST_FAKESRC(gst_pad_get_parent(pad)); g_return_if_fail(GST_IS_FAKESRC(src)); -// g_print("gst_fakesrc_push(): pushing fake buffer from '%s'\n", -// gst_element_get_name(GST_ELEMENT(src))); - g_print(">"); + g_print("(%s:%s)> ",GST_DEBUG_PAD_NAME(pad)); buf = gst_buffer_new(); gst_pad_push(pad,buf); } diff --git a/plugins/elements/gstfdsrc.c b/plugins/elements/gstfdsrc.c index 5d33755f44..dfb2447997 100644 --- a/plugins/elements/gstfdsrc.c +++ b/plugins/elements/gstfdsrc.c @@ -57,7 +57,7 @@ static void gst_fdsrc_init (GstFdSrc *fdsrc); static void gst_fdsrc_set_arg (GtkObject *object, GtkArg *arg, guint id); static void gst_fdsrc_get_arg (GtkObject *object, GtkArg *arg, guint id); -static void gst_fdsrc_pull (GstPad *pad); +static void gst_fdsrc_get (GstPad *pad); static GstSrcClass *parent_class = NULL; @@ -108,7 +108,7 @@ gst_fdsrc_class_init (GstFdSrcClass *klass) static void gst_fdsrc_init(GstFdSrc *fdsrc) { fdsrc->srcpad = gst_pad_new("src",GST_PAD_SRC); - gst_pad_set_pull_function(fdsrc->srcpad,gst_fdsrc_pull); + gst_pad_set_get_function(fdsrc->srcpad,gst_fdsrc_get); gst_element_add_pad(GST_ELEMENT(fdsrc),fdsrc->srcpad); fdsrc->fd = 0; @@ -175,7 +175,7 @@ gst_fdsrc_get_arg (GtkObject *object, GtkArg *arg, guint id) } } -void gst_fdsrc_pull(GstPad *pad) { +void gst_fdsrc_get(GstPad *pad) { GstFdSrc *src; GstBuffer *buf; glong readbytes; diff --git a/plugins/elements/gsthttpsrc.c b/plugins/elements/gsthttpsrc.c index 578da6c4fb..15eb2a9efc 100644 --- a/plugins/elements/gsthttpsrc.c +++ b/plugins/elements/gsthttpsrc.c @@ -55,7 +55,7 @@ static void gst_httpsrc_set_arg (GtkObject *object, GtkArg *arg, guint id); static void gst_httpsrc_get_arg (GtkObject *object, GtkArg *arg, guint id); static GstElementStateReturn gst_httpsrc_change_state (GstElement *element); -static void gst_httpsrc_pull (GstPad *pad); +static void gst_httpsrc_get (GstPad *pad); static gboolean gst_httpsrc_open_url (GstHttpSrc *src); static void gst_httpsrc_close_url (GstHttpSrc *src); @@ -112,7 +112,7 @@ gst_httpsrc_class_init (GstHttpSrcClass *klass) static void gst_httpsrc_init(GstHttpSrc *httpsrc) { httpsrc->srcpad = gst_pad_new("src",GST_PAD_SRC); - gst_pad_set_pull_function(httpsrc->srcpad,gst_httpsrc_pull); + gst_pad_set_get_function(httpsrc->srcpad,gst_httpsrc_get); gst_element_add_pad(GST_ELEMENT(httpsrc),httpsrc->srcpad); httpsrc->url = NULL; @@ -122,7 +122,7 @@ static void gst_httpsrc_init(GstHttpSrc *httpsrc) { httpsrc->bytes_per_read = 4096; } -static void gst_httpsrc_pull(GstPad *pad) { +static void gst_httpsrc_get(GstPad *pad) { GstHttpSrc *src; GstBuffer *buf; glong readbytes; diff --git a/plugins/elements/gstidentity.c b/plugins/elements/gstidentity.c index 332be4df4d..f5546b0cdf 100644 --- a/plugins/elements/gstidentity.c +++ b/plugins/elements/gstidentity.c @@ -116,9 +116,7 @@ gst_identity_chain (GstPad *pad, GstBuffer *buf) g_return_if_fail (buf != NULL); identity = GST_IDENTITY (pad->parent); -// g_print("gst_identity_chain: got buffer in '%s'\n", -// gst_element_get_name(GST_ELEMENT(identity))); - g_print("i"); + g_print("(%s:%s)i ",GST_DEBUG_PAD_NAME(pad)); gst_pad_push (identity->srcpad, buf); } diff --git a/plugins/elements/gstqueue.c b/plugins/elements/gstqueue.c index 825e0eb5ca..2f29e4b90c 100644 --- a/plugins/elements/gstqueue.c +++ b/plugins/elements/gstqueue.c @@ -58,7 +58,7 @@ static void gst_queue_init (GstQueue *queue); static void gst_queue_set_arg (GtkObject *object, GtkArg *arg, guint id); static void gst_queue_get_arg (GtkObject *object, GtkArg *arg, guint id); -static void gst_queue_pull (GstPad *pad); +static void gst_queue_get (GstPad *pad); static void gst_queue_chain (GstPad *pad, GstBuffer *buf); static void gst_queue_flush (GstQueue *queue); @@ -121,7 +121,7 @@ gst_queue_init (GstQueue *queue) gst_element_add_pad (GST_ELEMENT (queue), queue->sinkpad); queue->srcpad = gst_pad_new ("src", GST_PAD_SRC); - gst_pad_set_pull_function (queue->srcpad, gst_queue_pull); + gst_pad_set_get_function (queue->srcpad, gst_queue_get); gst_element_add_pad (GST_ELEMENT (queue), queue->srcpad); queue->queue = NULL; @@ -218,7 +218,7 @@ gst_queue_chain (GstPad *pad, GstBuffer *buf) } static void -gst_queue_pull (GstPad *pad) +gst_queue_get (GstPad *pad) { GstQueue *queue = GST_QUEUE (gst_pad_get_parent(pad)); GstBuffer *buf = NULL; diff --git a/plugins/elements/gstsinesrc.c b/plugins/elements/gstsinesrc.c index 271e0b30cd..e15c6c2bee 100644 --- a/plugins/elements/gstsinesrc.c +++ b/plugins/elements/gstsinesrc.c @@ -62,7 +62,7 @@ static void gst_sinesrc_get_arg(GtkObject *object,GtkArg *arg,guint id); //static gboolean gst_sinesrc_open_audio(GstSineSrc *src); void gst_sinesrc_sync_parms(GstSineSrc *sinesrc); -void gst_sinesrc_pull(GstPad *pad); +void gst_sinesrc_get(GstPad *pad); static GstSrcClass *parent_class = NULL; //static guint gst_sinesrc_signals[LAST_SIGNAL] = { 0 }; @@ -116,7 +116,7 @@ gst_sinesrc_class_init(GstSineSrcClass *klass) { static void gst_sinesrc_init(GstSineSrc *sinesrc) { sinesrc->srcpad = gst_pad_new("src",GST_PAD_SRC); - gst_pad_set_pull_function(sinesrc->srcpad,gst_sinesrc_pull); + gst_pad_set_get_function(sinesrc->srcpad,gst_sinesrc_get); gst_element_add_pad(GST_ELEMENT(sinesrc),sinesrc->srcpad); sinesrc->volume = 1.0; @@ -142,7 +142,7 @@ GstElement *gst_sinesrc_new_with_fd(gchar *name,gchar *filename) { return sinesrc; } -void gst_sinesrc_pull(GstPad *pad) { +void gst_sinesrc_get(GstPad *pad) { GstSineSrc *src; GstBuffer *buf; gint16 *samples; diff --git a/tests/Makefile.am b/tests/Makefile.am index 34b5b9bd0e..7c944f0101 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,4 +1,4 @@ -noinst_PROGRAMS = init loadall simplefake states caps queue registry paranoia rip +noinst_PROGRAMS = init loadall simplefake states caps queue registry paranoia rip mp3encode LDADD = $(GLIB_LIBS) $(GTK_LIBS) $(top_builddir)/gst/libgst.la CFLAGS = -Wall diff --git a/tests/mp3encode.c b/tests/mp3encode.c new file mode 100644 index 0000000000..266a9c6f21 --- /dev/null +++ b/tests/mp3encode.c @@ -0,0 +1,85 @@ +#include +#include +#include +#include +#include +#include + +int main(int argc,char *argv[]) { + GstPipeline *pipeline; + GstElement *src,*lame,*sink; + int bitrate; + int fdin = -1; + int fdout = -1; + int i; + + gst_init(&argc,&argv); + + for (i=1;i + +int main(int argc,char *argv[]) { + GstPipeline *pipeline; + GstElement *src,*sink; + + gst_init(&argc,&argv); + + pipeline = gst_pipeline_new("fakepipeline"); + src = gst_elementfactory_make("fakesrc","fakesrc"); + g_return_val_if_fail(1,src != NULL); + sink = gst_elementfactory_make("fakesink","fakesink"); + g_return_val_if_fail(1,sink != NULL); + + gst_bin_add(GST_BIN(pipeline),src); + gst_bin_add(GST_BIN(pipeline),sink); + + gst_element_connect(src,"src",sink,"sink"); + + gtk_object_set(GTK_OBJECT(gst_element_get_pad(src,"src")),"active",FALSE,NULL); + gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_PLAYING); + + gst_bin_iterate(GST_BIN(pipeline)); +} diff --git a/tests/paranoia.c b/tests/paranoia.c index 44bbcd5ad3..ca15c7805c 100644 --- a/tests/paranoia.c +++ b/tests/paranoia.c @@ -1,28 +1,36 @@ #include +void paranoia_eos(GstPad *pad) { + gst_element_set_state(GST_ELEMENT(gst_pad_get_parent(pad)),GST_STATE_READY); + fprintf(stderr,"PARANOIA: have eos signal\n"); +} + int main(int argc,char *argv[]) { GstPipeline *pipeline; GstElement *paranoia,*queue,*audio_thread,*audiosink; int i; + int track = (argc == 2) ? atoi(argv[1]) : 1; DEBUG_ENTER("(%d)",argc); gst_init(&argc,&argv); pipeline = GST_PIPELINE(gst_pipeline_new("paranoia")); - g_return_if_fail(pipeline != NULL); + g_return_val_if_fail(pipeline != NULL,1); audio_thread = gst_thread_new("audio_thread"); - g_return_if_fail(audio_thread != NULL); + g_return_val_if_fail(audio_thread != NULL,2); paranoia = gst_elementfactory_make("cdparanoia","paranoia"); - g_return_val_if_fail(1,paranoia != NULL); -// gtk_object_set(GTK_OBJECT(paranoia),"extra_paranoia",FALSE,"cdda2wav_paranoia",FALSE,NULL); + g_return_val_if_fail(paranoia != NULL,3); + gtk_object_set(GTK_OBJECT(paranoia),"paranoia_mode",0,NULL); +// gtk_object_set(GTK_OBJECT(paranoia),"start_sector",0,"end_sector",75,NULL); queue = gst_elementfactory_make("queue","queue"); - g_return_val_if_fail(2,queue != NULL); + gtk_object_set(GTK_OBJECT(queue),"max_level",750,NULL); + g_return_val_if_fail(queue != NULL,4); - audiosink = gst_elementfactory_make("audiosink","audiosink"); - g_return_val_if_fail(2,audiosink != NULL); + audiosink = gst_elementfactory_make("fakesink","audiosink"); + g_return_val_if_fail(audiosink != NULL,4); gst_bin_add(GST_BIN(pipeline),paranoia); gst_bin_add(GST_BIN(pipeline),queue); @@ -33,6 +41,9 @@ int main(int argc,char *argv[]) { gst_element_connect(paranoia,"src",queue,"sink"); gst_element_connect(queue,"src",audio_thread,"sink"); + gtk_signal_connect(GTK_OBJECT(gst_element_get_pad(paranoia,"src")),"eos", + GTK_SIGNAL_FUNC(paranoia_eos),NULL); + gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_PLAYING); if (GST_STATE(paranoia) != GST_STATE_PLAYING) fprintf(stderr,"error: state not set\n"); diff --git a/tests/queue.c b/tests/queue.c index e11dec9328..7cda7dc365 100644 --- a/tests/queue.c +++ b/tests/queue.c @@ -34,7 +34,7 @@ fprintf(stderr,"QUEUE: fakesink\n"); gst_bin_add(thr2,sink); fprintf(stderr,"QUEUE: added sink to thr2\n"); gst_element_add_ghost_pad(GST_ELEMENT(thr2),gst_element_get_pad(sink,"sink")); - gst_bin_use_cothreads(thr2,TRUE); +// gst_bin_use_cothreads(thr2,TRUE); fprintf(stderr,"QUEUE: filled in threads\n"); gst_bin_add(pipeline,GST_ELEMENT(thr1)); @@ -53,10 +53,10 @@ fprintf(stderr,"QUEUE: fakesink\n"); sleep(1); fprintf(stderr,"\n\n"); -// for (i=0;i<1000;i++) -// gst_bin_iterate(thr1); - fprintf(stderr,"\n\n"); - fflush(stdout); - fflush(stderr); - gst_bin_iterate(thr2); + for (i=0;i<1000;i++) + gst_bin_iterate(thr2); +// fprintf(stderr,"\n\n"); +// fflush(stdout); +// fflush(stderr); +// gst_bin_iterate(thr2); } diff --git a/tests/rip.c b/tests/rip.c index 050a76abc3..7a61cc9cc4 100644 --- a/tests/rip.c +++ b/tests/rip.c @@ -15,6 +15,7 @@ int main(int argc,char *argv[]) { gst_init(&argc,&argv); + if (argc != 2) argv[1] = "output.mp3"; unlink(argv[1]); outfile = open(argv[1],O_CREAT | O_RDWR | O_TRUNC); if (!outfile) { @@ -24,13 +25,19 @@ int main(int argc,char *argv[]) { fprintf(stderr,"outfile is fd %d\n",outfile); pipeline = gst_pipeline_new("ripper"); + g_return_val_if_fail(pipeline != NULL,1); + gst_bin_use_cothreads(GST_BIN(pipeline),TRUE); + paranoia = gst_elementfactory_make("cdparanoia","paranoia"); - g_return_val_if_fail(1,paranoia != NULL); + g_return_val_if_fail(paranoia != NULL,2); + gtk_object_set(GTK_OBJECT(paranoia),"paranoia_mode",0,NULL); +// gtk_object_set(GTK_OBJECT(paranoia),"start_sector",0,"end_sector",75,NULL); + lame = gst_elementfactory_make("lame","lame"); - g_return_val_if_fail(2,lame != NULL); - gtk_object_set(GTK_OBJECT(lame),"bitrate",320,NULL); + g_return_val_if_fail(lame != NULL,3); + gtk_object_set(GTK_OBJECT(lame),"bitrate",128,NULL); sink = gst_elementfactory_make("fdsink","fdsink"); - g_return_val_if_fail(3,sink != NULL); + g_return_val_if_fail(sink != NULL,4); gtk_object_set(GTK_OBJECT(sink),"fd",outfile,NULL); fprintf(stderr,"paranoia is %p, lame is %p, sink is %p\n",paranoia,lame,sink); diff --git a/tests/simplefake.c b/tests/simplefake.c index 079f533136..ff86d3fdb2 100644 --- a/tests/simplefake.c +++ b/tests/simplefake.c @@ -1,17 +1,42 @@ #include +#include int main(int argc,char *argv[]) { GstPipeline *pipeline; - GstElement *src,*sink; + GstElement *src,*identity,*sink; + int i; + + DEBUG_ENTER("(%d)",argc); gst_init(&argc,&argv); pipeline = gst_pipeline_new("fakepipeline"); - src = gst_elementfactory_make("fakesrc","fakesrc"); - g_return_val_if_fail(1,src != NULL); - sink = gst_elementfactory_make("fakesink","fakesink"); - g_return_val_if_fail(1,sink != NULL); + src = gst_elementfactory_make("fakesrc","src"); +/* g_return_val_if_fail(src != NULL,1); + if (argc == 2) + gtk_object_set(GTK_OBJECT(src),"location",argv[1],NULL); + else + gtk_object_set(GTK_OBJECT(src),"location","simplefake.c",NULL);*/ + identity = gst_elementfactory_make("identity","identity"); + g_return_val_if_fail(identity != NULL,2); + sink = gst_elementfactory_make("fakesink","sink"); + g_return_val_if_fail(sink != NULL,3); + fprintf(stderr,"src %p identity %p sink %p\n",src,identity,sink); gst_bin_add(GST_BIN(pipeline),src); + gst_bin_add(GST_BIN(pipeline),identity); gst_bin_add(GST_BIN(pipeline),sink); + + gst_element_connect(src,"src",identity,"sink"); + gst_element_connect(identity,"src",sink,"sink"); + +// gst_bin_use_cothreads(GST_BIN(pipeline),TRUE); + + gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_PLAYING); + if (GST_STATE(src) != GST_STATE_PLAYING) fprintf(stderr,"error: state not set\n"); + + for (i=0;i<2;i++) { + fprintf(stderr,"\n"); + gst_bin_iterate(GST_BIN(pipeline)); + } } diff --git a/tests/states.c b/tests/states.c index 6401f37ce3..e5139af9bd 100644 --- a/tests/states.c +++ b/tests/states.c @@ -1,19 +1,23 @@ #include gboolean state_change(GstElement *element,GstElementState state) { - g_print("state_change: element '%s' state set to %d(%s)\n", + g_print(">STATES: element '%s' state set to %d(%s)\n", gst_element_get_name(element),state,_gst_print_statename(state)); - g_print("state_change: element state is actually %d\n",GST_STATE(element)); + g_print(">STATES: element state is actually %d\n",GST_STATE(element)); } int main(int argc,char *argv[]) { - GstElement *bin; - GstElement *src,*sink; + GstElement *bin,*subbin; + GstElement *src,*sink,*filter; gst_init(&argc,&argv); src = gst_elementfactory_make("fakesrc","src"); g_return_val_if_fail(1,src != NULL); + subbin = gst_bin_new("subbin"); + g_return_val_if_fail(1,subbin != NULL); + filter = gst_elementfactory_make("identity","filter"); + g_return_val_if_fail(1,filter != NULL); sink = gst_elementfactory_make("fakesink","sink"); g_return_val_if_fail(1,sink != NULL); bin = gst_bin_new("bin"); @@ -21,25 +25,39 @@ int main(int argc,char *argv[]) { gtk_signal_connect(GTK_OBJECT(src),"state_change", GTK_SIGNAL_FUNC(state_change),NULL); + gtk_signal_connect(GTK_OBJECT(subbin),"state_change", + GTK_SIGNAL_FUNC(state_change),NULL); + gtk_signal_connect(GTK_OBJECT(filter),"state_change", + GTK_SIGNAL_FUNC(state_change),NULL); gtk_signal_connect(GTK_OBJECT(sink),"state_change", GTK_SIGNAL_FUNC(state_change),NULL); gtk_signal_connect(GTK_OBJECT(bin),"state_change", GTK_SIGNAL_FUNC(state_change),NULL); - g_print("element '%s' starts at state %d(%s)\n",gst_element_get_name(src), + g_print("STATES: element '%s' starts at state %d(%s)\n",gst_element_get_name(src), GST_STATE(src),_gst_print_statename(GST_STATE(src))); - g_print("element '%s' starts at state %d(%s)\n",gst_element_get_name(sink), + g_print("STATES: element '%s' starts at state %d(%s)\n",gst_element_get_name(subbin), + GST_STATE(subbin),_gst_print_statename(GST_STATE(subbin))); + g_print("STATES: element '%s' starts at state %d(%s)\n",gst_element_get_name(filter), + GST_STATE(filter),_gst_print_statename(GST_STATE(filter))); + g_print("STATES: element '%s' starts at state %d(%s)\n",gst_element_get_name(sink), GST_STATE(sink),_gst_print_statename(GST_STATE(sink))); - g_print("element '%s' starts at state %d(%s)\n",gst_element_get_name(bin), + g_print("STATES: element '%s' starts at state %d(%s)\n",gst_element_get_name(bin), GST_STATE(bin),_gst_print_statename(GST_STATE(bin))); + gst_bin_add(GST_BIN(subbin),filter); + gst_element_add_ghost_pad(GST_ELEMENT(bin),gst_element_get_pad(filter,"sink")); + gst_element_add_ghost_pad(GST_ELEMENT(bin),gst_element_get_pad(filter,"src")); + gst_bin_add(GST_BIN(bin),src); + gst_bin_add(GST_BIN(bin),subbin); gst_bin_add(GST_BIN(bin),sink); gst_pad_connect(gst_element_get_pad(src,"src"), + gst_element_get_pad(subbin,"sink")); + gst_pad_connect(gst_element_get_pad(subbin,"src"), gst_element_get_pad(sink,"sink")); - gst_bin_create_plan (GST_BIN (bin)); gst_element_set_state (bin, GST_STATE_PLAYING); gst_bin_iterate (GST_BIN (bin));