!------------------------------->!
! !
: :
- (more chaining)
+ (more chaining)
: :
!<-------------------------------!
!<----------------!
!------------------------------->!
! !
: :
- (more chaining)
+ (more chaining)
: :
!<-------------------------------!
!<----------------!
!------------------------------->!
! !
: :
- (more chaining)
+ (more chaining)
: :
!<-------------------------------!
!<----------------!
!------------------------------------------------------------------->!
!
:
- (more chaining)
+ (more chaining)
:
!<-------------------------------------------------------------------!
!
-CC = gcc
+CC = libtool gcc
autoplug: autoplug.c
$(CC) -Wall `gstreamer-config --cflags --libs` `gnome-config --cflags --libs gnomeui` autoplug.c -o autoplug
-CC = gcc
+CC = libtool gcc
helloworld: helloworld.c
$(CC) -Wall `gstreamer-config --cflags --libs` helloworld.c -o helloworld
-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
-CC = gcc
+CC = libtool gcc
all: createxml runxml
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);
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;
}
/**
- * 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;
}
/**
- * gst_asyncdisksrc_pull_region:
+ * gst_asyncdisksrc_get_region:
* @src: #GstSrc to push a buffer from
* @offset: offset in file
* @size: number of bytes
* 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;
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 };
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;
audiosrc->seq = 0;
}
-void gst_audiosrc_pull(GstPad *pad) {
+void gst_audiosrc_get(GstPad *pad) {
GstAudioSrc *src;
GstBuffer *buf;
glong readbytes;
#include <fcntl.h>
#include <unistd.h>
-//#define DEBUG_ENABLED
-
#include <gstdisksrc.h>
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);
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;
}
static void
-gst_disksrc_pull (GstPad *pad)
+gst_disksrc_get (GstPad *pad)
{
GstDiskSrc *src;
GstBuffer *buf;
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;
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));
}
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);
}
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 };
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...
}
/**
- * 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;
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);
}
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;
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;
}
}
-void gst_fdsrc_pull(GstPad *pad) {
+void gst_fdsrc_get(GstPad *pad) {
GstFdSrc *src;
GstBuffer *buf;
glong readbytes;
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);
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;
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;
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);
}
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);
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;
}
static void
-gst_queue_pull (GstPad *pad)
+gst_queue_get (GstPad *pad)
{
GstQueue *queue = GST_QUEUE (gst_pad_get_parent(pad));
GstBuffer *buf = NULL;
//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 };
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;
return sinesrc;
}
-void gst_sinesrc_pull(GstPad *pad) {
+void gst_sinesrc_get(GstPad *pad) {
GstSineSrc *src;
GstBuffer *buf;
gint16 *samples;
extern gint _gst_trace_on;
+GHashTable *__gst_function_pointers = NULL;
+
/**
* gst_init:
* @argc: pointer to application's argc
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);
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,
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;
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",
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);
DEBUG("NEED COTHREADS, it's \"%s\"'s fault\n",gst_element_get_name(element));
break;
}
+
elements = g_list_next (elements);
}
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)) {
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);
}
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 "
- "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++;
- }
+ }
+
+ // 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;
}
- else {
- g_print("gstbin: found pad %s\n", gst_pad_get_name (pad));
+ /* 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++;
}
- 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);
}
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...
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);
}
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 {
+*/
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;
#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__ */
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 };
{
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;
}
/**
- * gst_pad_set_pull_function:
- * @pad: the pad to set the pull function for
- * @pull: the pull function
+ * gst_pad_set_chain_function:
+ * @pad: the pad to set the chain function for
+ * @chain: the chain function
*
- * Set the given pull function for the pad
+ * Set the given chain function for the pad
*/
-void
-gst_pad_set_pull_function (GstPad *pad,
- GstPadPullFunction pull)
+void gst_pad_set_chain_function (GstPad *pad,
+ GstPadChainFunction chain)
{
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);
+
+ pad->chainfunc = chain;
}
/**
- * gst_pad_set_pullregion_function:
- * @pad: the pad to set the pull function for
- * @pull: the pull function
+ * gst_pad_set_pull_function:
+ * @pad: the pad to set the get function for
+ * @get: the get function
*
- * Set the given pull function for the pad
+ * Set the given get function for the pad
*/
void
-gst_pad_set_pullregion_function (GstPad *pad,
- GstPadPullRegionFunction pull)
+gst_pad_set_get_function (GstPad *pad,
+ GstPadGetFunction get)
{
g_return_if_fail (pad != NULL);
g_return_if_fail (GST_IS_PAD (pad));
- g_print("gstpad: pad setting pullregion function\n");
+ // 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->pullregionfunc = pull;
+ 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_chain_function:
- * @pad: the pad to set the chain function for
- * @chain: the chain function
+ * gst_pad_set_getregion_function:
+ * @pad: the pad to set the getregion function for
+ * @getregion: the getregion function
*
- * Set the given chain function for the pad
+ * Set the given getregion function for the pad
*/
-void gst_pad_set_chain_function (GstPad *pad,
- GstPadChainFunction chain)
+void
+gst_pad_set_getregion_function (GstPad *pad,
+ GstPadGetRegionFunction getregion)
{
g_return_if_fail (pad != NULL);
g_return_if_fail (GST_IS_PAD (pad));
-
- pad->chainfunc = chain;
+
+ g_print("gstpad: pad setting getregion function\n");
+
+ pad->getregionfunc = getregion;
}
/**
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
*
* 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);
g_print("-- gst_pad_push(): houston, we have a problem, no way of talking to peer\n");
}
}
+*/
/**
* gst_pad_pull:
*
* Returns: the buffer that was pulled
*/
+/*
GstBuffer*
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;
return NULL;
}
+*/
/**
* gst_pad_pull_region:
*
* Returns: the buffer that was pulled
*/
+/*
GstBuffer*
gst_pad_pull_region (GstPad *pad,
gulong offset,
return NULL;
}
+*/
/**
* gst_pad_chain:
+#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
#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;
* 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,
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 {
GstBuffer *bufpen;
GstPadChainFunction chainfunc;
+ GstPadGetFunction getfunc;
+ GstPadGetRegionFunction getregionfunc;
+ GstPadQoSFunction qosfunc;
+
GstPadPushFunction pushfunc;
GstPadPullFunction pullfunc;
GstPadPullRegionFunction pullregionfunc;
- GstPadQoSFunction qosfunc;
GstObject *parent;
GList *ghostparents;
/* signal callbacks */
void (*set_active) (GstPad *pad, gboolean active);
void (*caps_changed) (GstPad *pad, GstCaps *newcaps);
+ void (*eos) (GstPad *pad);
};
typedef enum {
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);
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);
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
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
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);
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;
}
/**
- * 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;
}
/**
- * gst_asyncdisksrc_pull_region:
+ * gst_asyncdisksrc_get_region:
* @src: #GstSrc to push a buffer from
* @offset: offset in file
* @size: number of bytes
* 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;
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 };
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;
audiosrc->seq = 0;
}
-void gst_audiosrc_pull(GstPad *pad) {
+void gst_audiosrc_get(GstPad *pad) {
GstAudioSrc *src;
GstBuffer *buf;
glong readbytes;
#include <fcntl.h>
#include <unistd.h>
-//#define DEBUG_ENABLED
-
#include <gstdisksrc.h>
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);
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;
}
static void
-gst_disksrc_pull (GstPad *pad)
+gst_disksrc_get (GstPad *pad)
{
GstDiskSrc *src;
GstBuffer *buf;
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;
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));
}
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);
}
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 };
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...
}
/**
- * 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;
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);
}
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;
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;
}
}
-void gst_fdsrc_pull(GstPad *pad) {
+void gst_fdsrc_get(GstPad *pad) {
GstFdSrc *src;
GstBuffer *buf;
glong readbytes;
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);
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;
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;
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);
}
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);
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;
}
static void
-gst_queue_pull (GstPad *pad)
+gst_queue_get (GstPad *pad)
{
GstQueue *queue = GST_QUEUE (gst_pad_get_parent(pad));
GstBuffer *buf = NULL;
//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 };
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;
return sinesrc;
}
-void gst_sinesrc_pull(GstPad *pad) {
+void gst_sinesrc_get(GstPad *pad) {
GstSineSrc *src;
GstBuffer *buf;
gint16 *samples;
-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
--- /dev/null
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <gst/gst.h>
+
+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<argc;i++) {
+ fprintf(stderr,"arg is %s\n",argv[i]);
+ if (argv[i][0] == '-') {
+ fprintf(stderr," starts with -\n");
+ switch (argv[i][1]) {
+ case 'b': bitrate = atoi(argv[++i]);break;
+ case 0: {
+ if (fdin == -1) fdin = stdin;
+ else if (fdout == -1) fdout = stdout;
+ else fprintf(stderr,"unknown argument\n");exit(1);
+ break;
+ }
+ default: fprintf(stderr,"unknown argument\n");exit(1);
+ }
+ } else {
+ fprintf(stderr," probably a filename\n");
+ if (fdin == -1) {
+ fdin = open(argv[i],O_RDONLY);
+ if (fdin <= 0) {
+ fprintf(stderr,"can't open file '%s' for read\n",argv[i]);
+ exit(1);
+ }
+ fprintf(stderr," openned file %s for read, fd %d\n",argv[i],fdin);
+ } else if (fdout == -1) {
+ unlink(argv[i]);
+ fdout = open(argv[i],O_CREAT|O_RDWR|O_TRUNC);
+ if (fdout <= 0) {
+ fprintf(stderr,"can't open file '%s' for write\n",argv[i]);
+ exit(1);
+ }
+ fprintf(stderr," openned file %s for write, fd %d\n",argv[i],fdout);
+ } else {
+ fprintf(stderr,"unknown argument\n");exit(1);
+ }
+ }
+ }
+
+ pipeline = gst_pipeline_new("mp3encode");
+
+ src = gst_elementfactory_make("fdsrc","src");
+ g_return_val_if_fail(src != NULL,1);
+ gtk_object_set(GTK_OBJECT(src),"location",fdin,NULL);
+
+ lame = gst_elementfactory_make("lame","encoder");
+ g_return_val_if_fail(lame != NULL,2);
+ gtk_object_set(GTK_OBJECT(lame),"bitrate",bitrate,NULL);
+
+ sink = gst_elementfactory_make("fdsink","sink");
+ g_return_val_if_fail(sink != NULL,3);
+ gtk_object_set(GTK_OBJECT(src),"fd",fdout,NULL);
+
+ gst_bin_add(GST_BIN(pipeline),src);
+ gst_bin_add(GST_BIN(pipeline),lame);
+ gst_bin_add(GST_BIN(pipeline),sink);
+
+ gst_element_connect(src,"src",lame,"sink");
+ gst_element_connect(lame,"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<100;i++) {
+ fprintf(stderr,"\n");
+ gst_bin_iterate(GST_BIN(pipeline));
+ }
+}
-CC = gcc
+CC = libtool gcc
autoplug: autoplug.c
$(CC) -Wall `gstreamer-config --cflags --libs` `gnome-config --cflags --libs gnomeui` autoplug.c -o autoplug
-CC = gcc
+CC = libtool gcc
helloworld: helloworld.c
$(CC) -Wall `gstreamer-config --cflags --libs` helloworld.c -o helloworld
-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
-CC = gcc
+CC = libtool gcc
all: createxml runxml
--- /dev/null
+#include <gst/gst.h>
+
+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));
+}
#include <gst/gst.h>
+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);
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");
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));
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);
}
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) {
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);
#include <gst/gst.h>
+#include <assert.h>
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));
+ }
}
#include <gst/gst.h>
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");
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));