Initial code for the event system.

Original commit message from CVS:
Initial code for the event system.
This commit is contained in:
Erik Walthinsen 2001-08-06 20:37:21 +00:00
parent 6650712126
commit ee9426a1a1
14 changed files with 211 additions and 58 deletions

View file

@ -239,6 +239,7 @@ gst_disksrc_get (GstPad *pad)
/* deal with EOF state */
if (src->curoffset >= src->size) {
GST_DEBUG (0,"map offset %ld >= size %ld --> eos\n", src->curoffset, src->size);
gst_pad_event(pad,(void *)GST_EVENT_EOS);
gst_pad_set_eos (pad);
buf = gst_buffer_new();
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_EOS);

View file

@ -66,6 +66,7 @@ static void gst_fakesink_get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec);
static void gst_fakesink_chain (GstPad *pad, GstBuffer *buf);
static gboolean gst_fakesink_event (GstPad *pad, void *event);
static GstElementClass *parent_class = NULL;
static guint gst_fakesink_signals[LAST_SIGNAL] = { 0 };
@ -128,6 +129,7 @@ gst_fakesink_init (GstFakeSink *fakesink)
pad = gst_pad_new ("sink", GST_PAD_SINK);
gst_element_add_pad (GST_ELEMENT (fakesink), pad);
gst_pad_set_chain_function (pad, GST_DEBUG_FUNCPTR (gst_fakesink_chain));
gst_pad_set_event_function (pad, GST_DEBUG_FUNCPTR (gst_fakesink_event));
fakesink->sinkpads = g_slist_prepend (NULL, pad);
fakesink->numsinkpads = 1;
@ -237,3 +239,13 @@ gst_fakesink_factory_init (GstElementFactory *factory)
return TRUE;
}
static gboolean
gst_fakesink_event (GstPad *pad, void *event)
{
GST_DEBUG (GST_CAT_EVENT, "fakesink has event %d on pad %s:%s\n",(gint)event,GST_DEBUG_PAD_NAME(pad));
if ((gint)event == GST_EVENT_EOS) {
GST_DEBUG(GST_CAT_EVENT, "have EOS\n");
}
}

View file

@ -840,6 +840,13 @@ gst_element_set_state (GstElement *element, GstElementState state)
GST_DEBUG_ELEMENT (GST_CAT_STATES,element,"have failed change_state return\n");
return return_val;
}
/* Last thing we do is verify that a successful state change really
* did change the state... */
if (GST_STATE(element) != curpending) {
GST_DEBUG_ELEMENT (GST_CAT_STATES, element, "element claimed state-change success, but state didn't change\n");
return GST_STATE_FAILURE;
}
}
/* this is redundant, really, it will always return SUCCESS */
@ -1248,6 +1255,7 @@ gst_element_signal_eos (GstElement *element)
g_return_if_fail (element != NULL);
g_return_if_fail (GST_IS_ELEMENT (element));
GST_DEBUG(GST_CAT_EVENT, "signaling EOS on element %s\n",GST_OBJECT_NAME(element));
g_signal_emit (G_OBJECT (element), gst_element_signals[EOS], 0);
GST_FLAG_SET(element,GST_ELEMENT_COTHREAD_STOPPING);
}

View file

@ -56,6 +56,7 @@ static gchar *_gst_info_category_strings[] = {
"XML",
"NEGOTIATION",
"REFCOUNTING",
"EVENT",
};
/**
@ -108,6 +109,7 @@ const gchar *_gst_category_colors[32] = {
[GST_CAT_XML] = "01;37;41", // !!
[GST_CAT_NEGOTIATION] = "07;34",
[GST_CAT_REFCOUNTING] = "00;34:42",
[GST_CAT_EVENT] = "01;37;41", // !!
[31] = "",
};

View file

@ -88,6 +88,7 @@ enum {
GST_CAT_XML, // XML load/save of everything
GST_CAT_NEGOTIATION, // Caps Negotiation stuff
GST_CAT_REFCOUNTING, // Ref Counting stuff
GST_CAT_EVENT, // Event system
GST_CAT_MAX_CATEGORY = 31
};

View file

@ -196,8 +196,8 @@ gst_real_pad_init (GstRealPad *pad)
pad->qosfunc = NULL;
pad->eosfunc = GST_DEBUG_FUNCPTR(gst_pad_eos_func);
pad->pushfunc = GST_DEBUG_FUNCPTR(gst_pad_push_func);
pad->pullfunc = NULL;
pad->chainhandler = GST_DEBUG_FUNCPTR(gst_pad_push_func);
pad->gethandler = NULL;
pad->pullregionfunc = NULL;
pad->bufferpoolfunc = NULL;
@ -382,6 +382,25 @@ gst_pad_set_get_function (GstPad *pad,
GST_DEBUG_PAD_NAME(pad),GST_DEBUG_FUNCPTR_NAME(get));
}
/**
* gst_pad_set_event_function:
* @pad: the pad to set the event handler for
* @event: the event handler
*
* Set the given event handler for the pad.
*/
void
gst_pad_set_event_function (GstPad *pad,
GstPadEventFunction event)
{
g_return_if_fail (pad != NULL);
g_return_if_fail (GST_IS_REAL_PAD (pad));
GST_RPAD_EVENTFUNC(pad) = event;
GST_DEBUG (GST_CAT_PADS,"eventfunc for %s:%s set to %s\n",
GST_DEBUG_PAD_NAME(pad),GST_DEBUG_FUNCPTR_NAME(event));
}
/**
* gst_pad_set_getregion_function:
* @pad: the pad to set the getregion function for
@ -1477,12 +1496,12 @@ gst_pad_push (GstPad *pad, GstBuffer *buf)
g_return_if_fail (GST_PAD_DIRECTION (pad) == GST_PAD_SRC);
g_return_if_fail (peer != NULL);
if (peer->pushfunc) {
GST_DEBUG (GST_CAT_DATAFLOW, "calling pushfunc &%s of peer pad %s:%s\n",
GST_DEBUG_FUNCPTR_NAME (peer->pushfunc), GST_DEBUG_PAD_NAME (((GstPad*)peer)));
(peer->pushfunc) (((GstPad*)peer), buf);
if (peer->chainhandler) {
GST_DEBUG (GST_CAT_DATAFLOW, "calling chainhandler &%s of peer pad %s:%s\n",
GST_DEBUG_FUNCPTR_NAME (peer->chainhandler), GST_DEBUG_PAD_NAME (((GstPad*)peer)));
(peer->chainhandler) (((GstPad*)peer), buf);
} else
GST_DEBUG (GST_CAT_DATAFLOW, "no pushfunc\n");
GST_DEBUG (GST_CAT_DATAFLOW, "no chainhandler\n");
}
#endif
@ -1505,12 +1524,12 @@ gst_pad_pull (GstPad *pad)
g_return_val_if_fail (GST_PAD_DIRECTION (pad) == GST_PAD_SINK, NULL);
g_return_val_if_fail (peer != NULL, NULL);
if (peer->pullfunc) {
GST_DEBUG (GST_CAT_DATAFLOW,"calling pullfunc %s of peer pad %s:%s\n",
GST_DEBUG_FUNCPTR_NAME(peer->pullfunc),GST_DEBUG_PAD_NAME(peer));
return (peer->pullfunc)(((GstPad*)peer));
if (peer->gethandler) {
GST_DEBUG (GST_CAT_DATAFLOW,"calling gethandler %s of peer pad %s:%s\n",
GST_DEBUG_FUNCPTR_NAME(peer->gethandler),GST_DEBUG_PAD_NAME(peer));
return (peer->gethandler)(((GstPad*)peer));
} else {
GST_DEBUG (GST_CAT_DATAFLOW,"no pullfunc for peer pad %s:%s at %p\n",GST_DEBUG_PAD_NAME(((GstPad*)peer)),&peer->pullfunc);
GST_DEBUG (GST_CAT_DATAFLOW,"no gethandler for peer pad %s:%s at %p\n",GST_DEBUG_PAD_NAME(((GstPad*)peer)),&peer->gethandler);
return NULL;
}
}
@ -2035,3 +2054,40 @@ gst_ghost_pad_new (gchar *name,
return GST_PAD(ghostpad);
}
gboolean
gst_pad_event (GstPad *pad, void *event)
{
GstRealPad *peer;
gboolean handled = FALSE;
GST_DEBUG(GST_CAT_EVENT, "have event %d on pad %s:%s\n",(gint)event,GST_DEBUG_PAD_NAME(pad));
peer = GST_RPAD_PEER(pad);
if (GST_RPAD_EVENTFUNC(peer))
handled = GST_RPAD_EVENTFUNC(peer) (peer, event);
else {
GST_DEBUG(GST_CAT_EVENT, "there's no event function for peer %s:%s\n",GST_DEBUG_PAD_NAME(peer));
}
if (!handled) {
GST_DEBUG(GST_CAT_EVENT, "would proceed with default behavior here\n");
gst_pad_event_default(peer,event);
}
}
/* pad is the receiving pad */
static void
gst_pad_event_default(GstPad *pad, void *event)
{
switch((gint)event) {
case GST_EVENT_EOS:
if (GST_PAD_PARENT(pad)->numsrcpads == 1)
gst_element_signal_eos(GST_PAD_PARENT(pad));
else
GST_DEBUG(GST_CAT_EVENT, "WARNING: no default behavior for EOS with multiple srcpads\n");
break;
}
}

View file

@ -37,6 +37,7 @@
#include <gst/gstbuffer.h>
#include <gst/cothreads.h>
#include <gst/gstcaps.h>
#include <gst/gstevent.h>
#ifdef __cplusplus
@ -91,12 +92,11 @@ typedef enum {
* buf is the buffer being passed */
typedef void (*GstPadChainFunction) (GstPad *pad,GstBuffer *buf);
typedef GstBuffer* (*GstPadGetFunction) (GstPad *pad);
typedef GstBuffer* (*GstPadGetRegionFunction) (GstPad *pad, GstRegionType type, guint64 offset, guint64 len);
typedef void (*GstPadQoSFunction) (GstPad *pad, glong qos_message);
typedef gboolean (*GstPadEventFunction) (GstPad *pad, void *event);
typedef void (*GstPadPushFunction) (GstPad *pad, GstBuffer *buf);
typedef GstBuffer* (*GstPadPullFunction) (GstPad *pad);
typedef GstBuffer* (*GstPadGetRegionFunction) (GstPad *pad, GstRegionType type, guint64 offset, guint64 len);
typedef GstBuffer* (*GstPadPullRegionFunction) (GstPad *pad, GstRegionType type, guint64 offset, guint64 len);
typedef void (*GstPadQoSFunction) (GstPad *pad, glong qos_message);
typedef gboolean (*GstPadEOSFunction) (GstPad *pad);
typedef GstPadNegotiateReturn (*GstPadNegotiateFunction) (GstPad *pad, GstCaps **caps, gpointer *data);
typedef void (*GstPadNewCapsFunction) (GstPad *pad, GstCaps *caps);
@ -145,15 +145,18 @@ struct _GstRealPad {
GstSchedule *sched;
GstPadChainFunction chainfunc;
GstPadChainFunction chainhandler;
GstPadGetFunction getfunc;
GstPadGetFunction gethandler;
GstPadEventFunction eventfunc;
GstPadEventFunction eventhandler;
GstPadGetRegionFunction getregionfunc;
GstPadPullRegionFunction pullregionfunc;
GstPadQoSFunction qosfunc;
GstPadEOSFunction eosfunc;
GstPadPushFunction pushfunc;
GstPadPullFunction pullfunc;
GstPadPullRegionFunction pullregionfunc;
GstPadNegotiateFunction negotiatefunc;
GstPadNewCapsFunction newcapsfunc;
GstPadBufferPoolFunction bufferpoolfunc;
@ -199,13 +202,17 @@ struct _GstGhostPadClass {
#define GST_RPAD_BUFPEN(pad) (((GstRealPad *)(pad))->bufpen)
#define GST_RPAD_SCHED(pad) (((GstRealPad *)(pad))->sched)
#define GST_RPAD_CHAINFUNC(pad) (((GstRealPad *)(pad))->chainfunc)
#define GST_RPAD_CHAINHANDLER(pad) (((GstRealPad *)(pad))->chainhandler)
#define GST_RPAD_GETFUNC(pad) (((GstRealPad *)(pad))->getfunc)
#define GST_RPAD_GETHANDLER(pad) (((GstRealPad *)(pad))->gethandler)
#define GST_RPAD_EVENTFUNC(pad) (((GstRealPad *)(pad))->eventfunc)
#define GST_RPAD_EVENTHANDLER(pad) (((GstRealPad *)(pad))->eventhandler)
#define GST_RPAD_GETREGIONFUNC(pad) (((GstRealPad *)(pad))->getregionfunc)
#define GST_RPAD_PUSHFUNC(pad) (((GstRealPad *)(pad))->pushfunc)
#define GST_RPAD_PULLFUNC(pad) (((GstRealPad *)(pad))->pullfunc)
#define GST_RPAD_PULLREGIONFUNC(pad) (((GstRealPad *)(pad))->pullregionfunc)
#define GST_RPAD_QOSFUNC(pad) (((GstRealPad *)(pad))->qosfunc)
#define GST_RPAD_EOSFUNC(pad) (((GstRealPad *)(pad))->eosfunc)
#define GST_RPAD_NEGOTIATEFUNC(pad) (((GstRealPad *)(pad))->negotiatefunc)
#define GST_RPAD_NEWCAPSFUNC(pad) (((GstRealPad *)(pad))->newcapsfunc)
#define GST_RPAD_BUFFERPOOLFUNC(pad) (((GstRealPad *)(pad))->bufferpoolfunc)
@ -225,7 +232,7 @@ struct _GstGhostPadClass {
/* Some check functions (unused?) */
#define GST_PAD_CONNECTED(pad) (GST_PAD_PEER(pad) != NULL)
#define GST_PAD_CAN_PULL(pad) (GST_IS_REAL_PAD(pad) && GST_REAL_PAD(pad)->pullfunc != NULL)
#define GST_PAD_CAN_PULL(pad) (GST_IS_REAL_PAD(pad) && GST_REAL_PAD(pad)->gethandler != NULL)
/***** PadTemplate *****/
@ -299,9 +306,12 @@ GstPadDirection gst_pad_get_direction (GstPad *pad);
void gst_pad_set_chain_function (GstPad *pad, GstPadChainFunction chain);
void gst_pad_set_get_function (GstPad *pad, GstPadGetFunction get);
void gst_pad_set_event_function (GstPad *pad, GstPadEventFunction event);
void gst_pad_set_getregion_function (GstPad *pad, GstPadGetRegionFunction getregion);
void gst_pad_set_qos_function (GstPad *pad, GstPadQoSFunction qos);
void gst_pad_set_eos_function (GstPad *pad, GstPadEOSFunction eos);
void gst_pad_set_negotiate_function (GstPad *pad, GstPadNegotiateFunction nego);
void gst_pad_set_newcaps_function (GstPad *pad, GstPadNewCapsFunction newcaps);
void gst_pad_set_bufferpool_function (GstPad *pad, GstPadBufferPoolFunction bufpool);
@ -344,8 +354,8 @@ GstPadNegotiateReturn gst_pad_negotiate_proxy (GstPad *srcpad, GstPad *destpad,
void gst_pad_push (GstPad *pad, GstBuffer *buf);
#else
#define gst_pad_push(pad,buf) G_STMT_START{ \
if (((GstRealPad *)(pad))->peer->pushfunc) \
(((GstRealPad *)(pad))->peer->pushfunc)((GstPad *)(((GstRealPad *)(pad))->peer),(buf)); \
if (((GstRealPad *)(pad))->peer->chainhandler) \
(((GstRealPad *)(pad))->peer->chainhandler)((GstPad *)(((GstRealPad *)(pad))->peer),(buf)); \
}G_STMT_END
#endif
#if 1
@ -353,14 +363,26 @@ GstBuffer* gst_pad_pull (GstPad *pad);
GstBuffer* gst_pad_pullregion (GstPad *pad, GstRegionType type, guint64 offset, guint64 len);
#else
#define gst_pad_pull(pad) \
( (((GstRealPad *)(pad))->peer->pullfunc) ? \
(((GstRealPad *)(pad))->peer->pullfunc)((GstPad *)(((GstRealPad *)(pad))->peer)) : \
( (((GstRealPad *)(pad))->peer->gethandler) ? \
(((GstRealPad *)(pad))->peer->gethandler)((GstPad *)(((GstRealPad *)(pad))->peer)) : \
NULL )
#define gst_pad_pullregion(pad,type,offset,len) \
( (((GstRealPad *)(pad))->peer->pullregionfunc) ? \
(((GstRealPad *)(pad))->peer->pullregionfunc)((GstPad *)(((GstRealPad *)(pad))->peer),(type),(offset),(len)) : \
NULL )
#endif
#if 1
gboolean gst_pad_event (GstPad *pad, void *event);
#else
#define gst_pad_event(pad,event) G_STMT_START{ \
( (((GstRealPad *)(pad))->peer->eventhandler) ? \
(((GstRealPad *)(pad))->peer->eventhandler)((GstPad *)(((GstRealPad *)(pad))->peer),(event)) : \
FALSE )
}G_STMT_END
#endif
GstBuffer* gst_pad_peek (GstPad *pad);
GstPad* gst_pad_select (GList *padlist);
GstPad* gst_pad_selectv (GstPad *pad, ...);

View file

@ -60,7 +60,10 @@ static time_t get_time(const char * path);
void
_gst_plugin_initialize (void)
{
#ifndef GST_DISABLE_REGISTRY
xmlDocPtr doc;
#endif
_gst_modules = NULL;
_gst_modules_seqno = 0;
_gst_plugins = NULL;
@ -89,6 +92,7 @@ _gst_plugin_initialize (void)
PLUGINS_BUILDDIR "/gst/autoplug");
#endif /* PLUGINS_USE_BUILDDIR */
#ifndef GST_DISABLE_REGISTRY
doc = xmlParseFile (GST_CONFIG_DIR"/reg.xml");
if (!doc ||
@ -104,6 +108,7 @@ _gst_plugin_initialize (void)
gst_plugin_load_thyself (doc->xmlRootNode);
xmlFreeDoc (doc);
#endif // GST_DISABLE_REGISTRY
}
/**
@ -841,6 +846,7 @@ gst_plugin_get_list (void)
return g_list_copy (_gst_plugins);
}
#ifndef GST_DISABLE_REGISTRY
/**
* gst_plugin_save_thyself:
* @parent: the parent node to save the plugin to
@ -974,6 +980,7 @@ gst_plugin_load_thyself (xmlNodePtr parent)
GST_INFO (GST_CAT_PLUGIN_LOADING, "added %d registered factories, %d autopluggers and %d types",
elementcount, autoplugcount, typecount);
}
#endif // GST_DISABLE_REGISTRY
/**

View file

@ -127,12 +127,12 @@ gst_schedule_src_wrapper (int argc,char *argv[])
}
static void
gst_schedule_pushfunc_proxy (GstPad *pad, GstBuffer *buf)
gst_schedule_chainhandler_proxy (GstPad *pad, GstBuffer *buf)
{
GstRealPad *peer = GST_RPAD_PEER(pad);
GST_DEBUG_ENTER("(%s:%s)",GST_DEBUG_PAD_NAME(pad));
GST_DEBUG (GST_CAT_DATAFLOW,"putting buffer %p in peer's pen\n",buf);
GST_DEBUG (GST_CAT_DATAFLOW,"putting buffer %p in peer \"%s:%s\"'s pen\n",buf,GST_DEBUG_PAD_NAME(peer));
// FIXME this should be bounded
// loop until the bufferpen is empty so we can fill it up again
@ -181,7 +181,7 @@ gst_schedule_select_proxy (GstPad *pad, GstBuffer *buf)
static GstBuffer*
gst_schedule_pullfunc_proxy (GstPad *pad)
gst_schedule_gethandler_proxy (GstPad *pad)
{
GstBuffer *buf;
GstRealPad *peer = GST_RPAD_PEER(pad);
@ -304,10 +304,10 @@ gst_schedule_cothreaded_chain (GstBin *bin, GstScheduleChain *chain) {
// set the chain proxies
if (GST_RPAD_DIRECTION(pad) == GST_PAD_SINK) {
GST_DEBUG (GST_CAT_SCHEDULING,"copying chain function into push proxy for %s:%s\n",GST_DEBUG_PAD_NAME(pad));
GST_RPAD_PUSHFUNC(pad) = GST_RPAD_CHAINFUNC(pad);
GST_RPAD_CHAINHANDLER(pad) = GST_RPAD_CHAINFUNC(pad);
} else {
GST_DEBUG (GST_CAT_SCHEDULING,"copying get function into pull proxy for %s:%s\n",GST_DEBUG_PAD_NAME(pad));
GST_RPAD_PULLFUNC(pad) = GST_RPAD_GETFUNC(pad);
GST_RPAD_GETHANDLER(pad) = GST_RPAD_GETFUNC(pad);
GST_RPAD_PULLREGIONFUNC(pad) = GST_RPAD_GETREGIONFUNC(pad);
}
@ -315,10 +315,10 @@ gst_schedule_cothreaded_chain (GstBin *bin, GstScheduleChain *chain) {
} else {
if (gst_pad_get_direction (pad) == GST_PAD_SINK) {
GST_DEBUG (GST_CAT_SCHEDULING,"setting cothreaded push proxy for sinkpad %s:%s\n",GST_DEBUG_PAD_NAME(pad));
GST_RPAD_PUSHFUNC(pad) = GST_DEBUG_FUNCPTR(gst_schedule_pushfunc_proxy);
GST_RPAD_CHAINHANDLER(pad) = GST_DEBUG_FUNCPTR(gst_schedule_chainhandler_proxy);
} else {
GST_DEBUG (GST_CAT_SCHEDULING,"setting cothreaded pull proxy for srcpad %s:%s\n",GST_DEBUG_PAD_NAME(pad));
GST_RPAD_PULLFUNC(pad) = GST_DEBUG_FUNCPTR(gst_schedule_pullfunc_proxy);
GST_RPAD_GETHANDLER(pad) = GST_DEBUG_FUNCPTR(gst_schedule_gethandler_proxy);
GST_RPAD_PULLREGIONFUNC(pad) = GST_DEBUG_FUNCPTR(gst_schedule_pullregionfunc_proxy);
}
}
@ -361,10 +361,10 @@ gst_schedule_chained_chain (GstBin *bin, _GstBinChain *chain) {
if (GST_RPAD_DIRECTION(pad) == GST_PAD_SINK) {
GST_DEBUG (GST_CAT_SCHEDULING,"copying chain function into push proxy for %s:%s\n",GST_DEBUG_PAD_NAME(pad));
GST_RPAD_PUSHFUNC(pad) = GST_RPAD_CHAINFUNC(pad);
GST_RPAD_CHAINHANDLER(pad) = GST_RPAD_CHAINFUNC(pad);
} else {
GST_DEBUG (GST_CAT_SCHEDULING,"copying get function into pull proxy for %s:%s\n",GST_DEBUG_PAD_NAME(pad));
GST_RPAD_PULLFUNC(pad) = GST_RPAD_GETFUNC(pad);
GST_RPAD_GETHANDLER(pad) = GST_RPAD_GETFUNC(pad);
GST_RPAD_PULLREGIONFUNC(pad) = GST_RPAD_GETREGIONFUNC(pad);
}
}
@ -564,12 +564,12 @@ void gst_bin_schedule_func(GstBin *bin) {
(gst_object_get_parent (GST_OBJECT (outside)) != GST_OBJECT (bin))) {
if (gst_pad_get_direction (pad) == GST_PAD_SINK) {
GST_DEBUG (0,"dealing with outside source element %s\n",GST_ELEMENT_NAME(outside));
// GST_DEBUG (0,"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;
// GST_DEBUG (0,"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);
GST_RPAD_PULLFUNC(pad) = GST_DEBUG_FUNCPTR(gst_bin_pullfunc_proxy);
// GST_DEBUG (0,"PUNT: copying gethandler ptr from %s:%s to %s:%s (@ %p)\n",
//GST_DEBUG_PAD_NAME(pad->peer),GST_DEBUG_PAD_NAME(pad),&pad->gethandler);
// pad->gethandler = pad->peer->gethandler;
// GST_DEBUG (0,"PUNT: setting chainhandler proxy to fake proxy on %s:%s\n",GST_DEBUG_PAD_NAME(pad->peer));
// pad->peer->chainhandler = GST_DEBUG_FUNCPTR(gst_bin_chainhandler_fake_proxy);
GST_RPAD_GETHANDLER(pad) = GST_DEBUG_FUNCPTR(gst_bin_gethandler_proxy);
GST_RPAD_PULLREGIONFUNC(pad) = GST_DEBUG_FUNCPTR(gst_bin_pullregionfunc_proxy);
}
} else {
@ -594,15 +594,15 @@ void gst_bin_schedule_func(GstBin *bin) {
if (gst_pad_get_direction (pad) == GST_PAD_SINK) {
GST_DEBUG (0,"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);
GST_DEBUG (0,"pushfunc %p = gst_bin_pushfunc_proxy %p\n",&pad->pushfunc,gst_bin_pushfunc_proxy);
pad->chainhandler = GST_DEBUG_FUNCPTR(gst_bin_chainhandler_proxy);
GST_DEBUG (0,"chainhandler %p = gst_bin_chainhandler_proxy %p\n",&pad->chainhandler,gst_bin_chainhandler_proxy);
} else if (gst_pad_get_direction (pad) == GST_PAD_SRC) {
GST_DEBUG (0,"setting pull proxies for srcpad %s:%s\n",GST_DEBUG_PAD_NAME(pad));
// set the proxy functions
GST_RPAD_PULLFUNC(pad) = GST_DEBUG_FUNCPTR(gst_bin_pullfunc_proxy);
GST_RPAD_GETHANDLER(pad) = GST_DEBUG_FUNCPTR(gst_bin_gethandler_proxy);
GST_RPAD_PULLREGIONFUNC(pad) = GST_DEBUG_FUNCPTR(gst_bin_pullregionfunc_proxy);
GST_DEBUG (0,"pad->pullfunc(@%p) = gst_bin_pullfunc_proxy(@%p)\n",
&pad->pullfunc,gst_bin_pullfunc_proxy);
GST_DEBUG (0,"pad->gethandler(@%p) = gst_bin_gethandler_proxy(@%p)\n",
&pad->gethandler,gst_bin_gethandler_proxy);
pad->pullregionfunc = GST_DEBUG_FUNCPTR(gst_bin_pullregionfunc_proxy);
}
pads = g_list_next (pads);
@ -638,8 +638,8 @@ void gst_bin_schedule_func(GstBin *bin) {
GST_DEBUG (0,"found SINK pad %s:%s\n", GST_DEBUG_PAD_NAME(pad));
// copy the peer's chain function, easy enough
GST_DEBUG (0,"copying peer's chainfunc to %s:%s's pushfunc\n",GST_DEBUG_PAD_NAME(pad));
GST_RPAD_PUSHFUNC(pad) = GST_DEBUG_FUNCPTR(GST_RPAD_CHAINFUNC(GST_RPAD_PEER(pad)));
GST_DEBUG (0,"copying peer's chainfunc to %s:%s's chainhandler\n",GST_DEBUG_PAD_NAME(pad));
GST_RPAD_CHAINHANDLER(pad) = GST_DEBUG_FUNCPTR(GST_RPAD_CHAINFUNC(GST_RPAD_PEER(pad)));
// need to walk through and check for outside connections
//FIXME need to do this for all pads
@ -650,7 +650,7 @@ void gst_bin_schedule_func(GstBin *bin) {
break;
}
// get the parent of the peer of the pad
outside = GST_ELEMENT (GST_RPAD_PARENT(peer));
outside = GST_ELEMENT (GST_PAD_PARENT(peer));
if (!outside) break;
// if it's a connection and it's not ours...
if (GST_IS_CONNECTION (outside) &&
@ -734,10 +734,10 @@ void gst_bin_schedule_func(GstBin *bin) {
// set up proxy functions
if (gst_pad_get_direction (pad) == GST_PAD_SINK) {
GST_DEBUG (0,"setting push proxy for sinkpad %s:%s\n",GST_DEBUG_PAD_NAME(pad));
pad->pushfunc = GST_DEBUG_FUNCPTR(gst_bin_pushfunc_proxy);
pad->chainhandler = GST_DEBUG_FUNCPTR(gst_bin_chainhandler_proxy);
} else if (gst_pad_get_direction (pad) == GST_PAD_SRC) {
GST_DEBUG (0,"setting pull proxy for srcpad %s:%s\n",GST_DEBUG_PAD_NAME(pad));
GST_RPAD_PULLFUNC(pad) = GST_DEBUG_FUNCPTR(gst_bin_pullfunc_proxy);
GST_RPAD_GETHANDLER(pad) = GST_DEBUG_FUNCPTR(gst_bin_gethandler_proxy);
GST_RPAD_PULLREGIONFUNC(pad) = GST_DEBUG_FUNCPTR(gst_bin_pullregionfunc_proxy);
}
} else {
@ -746,12 +746,12 @@ void gst_bin_schedule_func(GstBin *bin) {
// we can just copy the chain function, since it shares the prototype
GST_DEBUG (0,"copying chain function into push proxy for %s:%s\n",
GST_DEBUG_PAD_NAME(pad));
pad->pushfunc = pad->chainfunc;
pad->chainhandler = pad->chainfunc;
} else if (gst_pad_get_direction (pad) == GST_PAD_SRC) {
// we can just copy the get function, since it shares the prototype
GST_DEBUG (0,"copying get function into pull proxy for %s:%s\n",
GST_DEBUG_PAD_NAME(pad));
pad->pullfunc = pad->getfunc;
pad->gethandler = pad->getfunc;
}
}
}
@ -789,10 +789,10 @@ void gst_bin_schedule_func(GstBin *bin) {
if (gst_pad_get_direction (pad) == GST_PAD_SINK) {
GST_DEBUG (0,"copying chain function into push proxy for %s:%s\n",GST_DEBUG_PAD_NAME(pad));
pad->pushfunc = pad->chainfunc;
pad->chainhandler = pad->chainfunc;
} else {
GST_DEBUG (0,"copying get function into pull proxy for %s:%s\n",GST_DEBUG_PAD_NAME(pad));
pad->pullfunc = pad->getfunc;
pad->gethandler = pad->getfunc;
}
}
}
@ -1197,7 +1197,7 @@ gst_schedule_pad_select (GstSchedule *sched, GList *padlist)
while (padlist) {
pad = GST_PAD (padlist->data);
GST_RPAD_PUSHFUNC(pad) = GST_DEBUG_FUNCPTR(gst_schedule_select_proxy);
GST_RPAD_CHAINHANDLER(pad) = GST_DEBUG_FUNCPTR(gst_schedule_select_proxy);
padlist = g_list_next (padlist);
}

View file

@ -479,6 +479,7 @@ gst_thread_change_state (GstElement *element)
break;
default:
GST_DEBUG_ELEMENT(GST_CAT_THREAD, element, "UNHANDLED STATE CHANGE! %x\n",transition);
break;
}

View file

@ -239,6 +239,7 @@ gst_disksrc_get (GstPad *pad)
/* deal with EOF state */
if (src->curoffset >= src->size) {
GST_DEBUG (0,"map offset %ld >= size %ld --> eos\n", src->curoffset, src->size);
gst_pad_event(pad,(void *)GST_EVENT_EOS);
gst_pad_set_eos (pad);
buf = gst_buffer_new();
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_EOS);

View file

@ -66,6 +66,7 @@ static void gst_fakesink_get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec);
static void gst_fakesink_chain (GstPad *pad, GstBuffer *buf);
static gboolean gst_fakesink_event (GstPad *pad, void *event);
static GstElementClass *parent_class = NULL;
static guint gst_fakesink_signals[LAST_SIGNAL] = { 0 };
@ -128,6 +129,7 @@ gst_fakesink_init (GstFakeSink *fakesink)
pad = gst_pad_new ("sink", GST_PAD_SINK);
gst_element_add_pad (GST_ELEMENT (fakesink), pad);
gst_pad_set_chain_function (pad, GST_DEBUG_FUNCPTR (gst_fakesink_chain));
gst_pad_set_event_function (pad, GST_DEBUG_FUNCPTR (gst_fakesink_event));
fakesink->sinkpads = g_slist_prepend (NULL, pad);
fakesink->numsinkpads = 1;
@ -237,3 +239,13 @@ gst_fakesink_factory_init (GstElementFactory *factory)
return TRUE;
}
static gboolean
gst_fakesink_event (GstPad *pad, void *event)
{
GST_DEBUG (GST_CAT_EVENT, "fakesink has event %d on pad %s:%s\n",(gint)event,GST_DEBUG_PAD_NAME(pad));
if ((gint)event == GST_EVENT_EOS) {
GST_DEBUG(GST_CAT_EVENT, "have EOS\n");
}
}

View file

@ -2,7 +2,8 @@ SUBDIRS = sched eos nego muxing
noinst_PROGRAMS = init loadall simplefake states caps queue registry \
paranoia rip mp3encode autoplug props case4 markup load tee autoplug2 autoplug3 \
capsconnect padfactory autoplug4 incsched reaping threadlock mp1vid reconnect faketest
capsconnect padfactory autoplug4 incsched reaping threadlock mp1vid reconnect \
faketest events
# we have nothing but apps here, we can do this safely
LIBS += $(GST_LIBS)

29
tests/events.c Normal file
View file

@ -0,0 +1,29 @@
#include <gst/gst.h>
void eos_handler(GstElement *element) {
printf("got EOS signal\n");
}
int main (int argc,char *argv[]) {
GstElement *pipeline, *disksrc, *identity, *fakesink;
gst_init(&argc,&argv);
pipeline = gst_pipeline_new("pipeline");
disksrc = gst_elementfactory_make("disksrc","disksrc");
identity = gst_elementfactory_make("identity","identity");
fakesink = gst_elementfactory_make("fakesink","fakesink");
g_object_set(G_OBJECT(disksrc),"location","events.c",NULL);
g_signal_connectc(G_OBJECT(fakesink),"eos",eos_handler,NULL,FALSE);
gst_bin_add(GST_BIN(pipeline),disksrc);
gst_bin_add(GST_BIN(pipeline),fakesink);
gst_element_connect(disksrc,"src",fakesink,"sink");
gst_element_set_state(pipeline,GST_STATE_PLAYING);
gst_bin_iterate(GST_BIN(pipeline));
gst_bin_iterate(GST_BIN(pipeline));
}