Updated the event system to use event,timestamp,data instead of a pointer.

Original commit message from CVS:
Updated the event system to use event,timestamp,data instead of a pointer.
Updated elements to use the event system correctly.
Changed "size" to "filesize" in disksrc.
This commit is contained in:
Erik Walthinsen 2001-08-22 21:45:25 +00:00
parent 7adfdaf6dc
commit 75312f3812
16 changed files with 73 additions and 67 deletions

View file

@ -52,7 +52,7 @@ enum {
ARG_LOCATION,
ARG_BYTESPERREAD,
ARG_OFFSET,
ARG_SIZE,
ARG_FILESIZE,
};
@ -117,8 +117,8 @@ gst_disksrc_class_init (GstDiskSrcClass *klass)
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_OFFSET,
g_param_spec_long("offset","offset","offset",
G_MINLONG,G_MAXLONG,0,G_PARAM_READWRITE)); // CHECKME
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_SIZE,
g_param_spec_long("size","size","size",
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_FILESIZE,
g_param_spec_long("filesize","filesize","filesize",
G_MINLONG,G_MAXLONG,0,G_PARAM_READABLE)); // CHECKME
gobject_class->set_property = gst_disksrc_set_property;
@ -211,7 +211,7 @@ gst_disksrc_get_property (GObject *object, guint prop_id, GValue *value, GParamS
case ARG_OFFSET:
g_value_set_long (value, src->curoffset);
break;
case ARG_SIZE:
case ARG_FILESIZE:
g_value_set_long (value, src->size);
break;
default:
@ -240,7 +240,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_event(pad, GST_EVENT_EOS, 0LL, 0);
buf = gst_buffer_new();
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_EOS);
return buf;
@ -263,7 +263,8 @@ gst_disksrc_get (GstPad *pad)
} else
GST_BUFFER_SIZE (buf) = src->bytes_per_read;
GST_DEBUG (0,"map %p, offset %ld, size %d\n", src->map, src->curoffset, GST_BUFFER_SIZE (buf));
GST_DEBUG (0,"map %p, offset %ld (%p), size %d\n", src->map, src->curoffset,
src->map + src->curoffset, GST_BUFFER_SIZE (buf));
//gst_util_dump_mem (GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
@ -303,7 +304,7 @@ gst_disksrc_get_region (GstPad *pad, GstRegionType type,guint64 offset,guint64 l
/* deal with EOF state */
if (offset >= src->size) {
gst_pad_event (pad, (void*)GST_EVENT_EOS);
gst_pad_event (pad, GST_EVENT_EOS, 0LL, 0);
GST_DEBUG (0,"map offset %lld >= size %ld --> eos\n", offset, src->size);
//FIXME
buf = gst_buffer_new();
@ -365,6 +366,7 @@ gst_disksrc_open_file (GstDiskSrc *src)
src->new_seek = TRUE;
}
return TRUE;
GST_DEBUG(0, "opened file %s\n",src->filename);
}
/* unmap and close the file */

View file

@ -66,7 +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 gboolean gst_fakesink_event (GstPad *pad, GstEventType event, guint64 timestamp, guint32 data);
static GstElementClass *parent_class = NULL;
static guint gst_fakesink_signals[LAST_SIGNAL] = { 0 };
@ -222,7 +222,7 @@ gst_fakesink_chain (GstPad *pad, GstBuffer *buf)
fakesink = GST_FAKESINK (gst_pad_get_parent (pad));
if (!fakesink->silent)
g_print("fakesink: chain ******* (%s:%s)< (%d bytes, %llu) \n",
g_print("fakesink: chain ******* (%s:%s)< (%d bytes, %lld) \n",
GST_DEBUG_PAD_NAME (pad), GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf));
g_signal_emit (G_OBJECT (fakesink), gst_fakesink_signals[SIGNAL_HANDOFF], 0,
@ -242,10 +242,10 @@ gst_fakesink_factory_init (GstElementFactory *factory)
static gboolean
gst_fakesink_event (GstPad *pad, void *event)
gst_fakesink_event (GstPad *pad, GstEventType event, guint64 timestamp, guint32 data)
{
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, "fakesink has event %d on pad %s:%s\n",event,GST_DEBUG_PAD_NAME(pad));
if (event == GST_EVENT_EOS) {
GST_DEBUG(GST_CAT_EVENT, "have EOS\n");
}
}

View file

@ -334,7 +334,7 @@ gst_fakesrc_get(GstPad *pad)
g_return_val_if_fail (GST_IS_FAKESRC (src), NULL);
if (src->num_buffers == 0) {
gst_pad_event (pad, (void*)GST_EVENT_EOS);
gst_pad_event (pad, GST_EVENT_EOS, 0LL, 0);
return NULL;
}
else {
@ -344,7 +344,7 @@ gst_fakesrc_get(GstPad *pad)
if (src->eos) {
GST_INFO (0, "fakesrc is setting eos on pad");
gst_pad_event (pad, (void*)GST_EVENT_EOS);
gst_pad_event (pad, GST_EVENT_EOS, 0LL, 0);
return NULL;
}
@ -387,7 +387,7 @@ gst_fakesrc_loop(GstElement *element)
GstBuffer *buf;
if (src->num_buffers == 0) {
gst_pad_event (pad, (void*)GST_EVENT_EOS);
gst_pad_event (pad, GST_EVENT_EOS, 0LL, 0);
return;
}
else {
@ -397,7 +397,7 @@ gst_fakesrc_loop(GstElement *element)
if (src->eos) {
GST_INFO (0, "fakesrc is setting eos on pad");
gst_pad_event (pad, (void*)GST_EVENT_EOS);
gst_pad_event (pad, GST_EVENT_EOS, 0LL, 0);
return;
}

View file

@ -203,7 +203,7 @@ gst_multidisksrc_get (GstPad *pad)
gst_multidisksrc_close_file(src);
if (!src->listptr) {
gst_pad_event (pad, (void*)GST_EVENT_EOS);
gst_pad_event (pad, GST_EVENT_EOS, 0LL, 0);
return FALSE;
}

View file

@ -203,7 +203,7 @@ gst_multidisksrc_get (GstPad *pad)
gst_multidisksrc_close_file(src);
if (!src->listptr) {
gst_pad_event (pad, (void*)GST_EVENT_EOS);
gst_pad_event (pad, GST_EVENT_EOS, 0LL, 0);
return FALSE;
}

View file

@ -180,7 +180,7 @@ gst_pipefilter_get (GstPad *pad)
}
/* if we didn't get as many bytes as we asked for, we're at EOF */
if (readbytes == 0) {
gst_pad_event (pad, (void*)GST_EVENT_EOS);
gst_pad_event (pad, GST_EVENT_EOS, 0LL, 0);
return NULL;
}

View file

@ -49,6 +49,7 @@
#include <gst/gstxml.h>
#include <gst/cothreads.h>
#include <gst/gstscheduler.h>
#include <gst/gsttimecache.h>
#include <gst/gstparse.h>
#include <gst/gstextratypes.h>

View file

@ -1914,8 +1914,24 @@ gst_ghost_pad_new (gchar *name,
}
/* pad is the receiving pad */
static void
gst_pad_event_default(GstPad *pad, GstEventType event, guint64 timestamp, guint32 data)
{
GST_DEBUG(GST_CAT_EVENT, "default event handler for pad %s:%s\n",GST_DEBUG_PAD_NAME(pad));
switch (event) {
case GST_EVENT_EOS:
if (GST_PAD_PARENT(pad)->numsinkpads == 1)
gst_element_signal_eos(GST_PAD_PARENT(pad));
else
GST_DEBUG(GST_CAT_EVENT, "WARNING: no default behavior for EOS with multiple sinkpads\n");
break;
}
}
gboolean
gst_pad_event (GstPad *pad, void *event)
gst_pad_event (GstPad *pad, GstEventType event, gint64 timestamp, guint32 data)
{
GstRealPad *peer;
gboolean handled = FALSE;
@ -1924,28 +1940,13 @@ gst_pad_event (GstPad *pad, void *event)
peer = GST_RPAD_PEER(pad);
if (GST_RPAD_EVENTFUNC(peer))
handled = GST_RPAD_EVENTFUNC(peer) (peer, event);
handled = GST_RPAD_EVENTFUNC(peer) (peer, event, timestamp, data);
else {
GST_DEBUG(GST_CAT_EVENT, "there's no event function for peer %s:%s\n",GST_DEBUG_PAD_NAME(peer));
}
if (!handled) {
GST_DEBUG(GST_CAT_EVENT, "would proceed with default behavior here\n");
gst_pad_event_default(peer,event);
}
}
/* 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;
gst_pad_event_default(peer,event, timestamp, data);
}
}

View file

@ -46,20 +46,20 @@ extern "C" {
#define GST_TYPE_PAD (gst_pad_get_type ())
#define GST_PAD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_PAD,GstPad))
#define GST_PAD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_PAD,GstPadClass))
#define GST_PAD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_PAD, GstPad))
#define GST_PAD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_PAD, GstPadClass))
#define GST_IS_PAD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_PAD))
#define GST_IS_PAD_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_PAD))
#define GST_TYPE_REAL_PAD (gst_real_pad_get_type ())
#define GST_REAL_PAD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_REAL_PAD,GstRealPad))
#define GST_REAL_PAD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_REAL_PAD,GstRealPadClass))
#define GST_REAL_PAD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_REAL_PAD, GstRealPad))
#define GST_REAL_PAD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_REAL_PAD, GstRealPadClass))
#define GST_IS_REAL_PAD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_REAL_PAD))
#define GST_IS_REAL_PAD_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_REAL_PAD))
#define GST_TYPE_GHOST_PAD (gst_ghost_pad_get_type ())
#define GST_GHOST_PAD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_GHOST_PAD,GstGhostPad))
#define GST_GHOST_PAD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_GHOST_PAD,GstGhostPadClass))
#define GST_GHOST_PAD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_GHOST_PAD, GstGhostPad))
#define GST_GHOST_PAD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_GHOST_PAD, GstGhostPadClass))
#define GST_IS_GHOST_PAD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_GHOST_PAD))
#define GST_IS_GHOST_PAD_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_GHOST_PAD))
@ -92,7 +92,7 @@ typedef enum {
* buf is the buffer being passed */
typedef void (*GstPadChainFunction) (GstPad *pad,GstBuffer *buf);
typedef GstBuffer* (*GstPadGetFunction) (GstPad *pad);
typedef gboolean (*GstPadEventFunction) (GstPad *pad, void *event);
typedef gboolean (*GstPadEventFunction) (GstPad *pad, GstEventType event, gint64 timestamp, guint32 data);
typedef GstBuffer* (*GstPadGetRegionFunction) (GstPad *pad, GstRegionType type, guint64 offset, guint64 len);
typedef GstBuffer* (*GstPadPullRegionFunction) (GstPad *pad, GstRegionType type, guint64 offset, guint64 len);
@ -365,11 +365,11 @@ NULL )
#endif
#if 1
gboolean gst_pad_event (GstPad *pad, void *event);
gboolean gst_pad_event (GstPad *pad, GstEventType event, gint64 timestamp, guint32 data);
#else
#define gst_pad_event(pad,event) G_STMT_START{ \
#define gst_pad_event(pad,event,timestamp,data) G_STMT_START{ \
( (((GstRealPad *)(pad))->peer->eventhandler) ? \
(((GstRealPad *)(pad))->peer->eventhandler)((GstPad *)(((GstRealPad *)(pad))->peer),(event)) : \
(((GstRealPad *)(pad))->peer->eventhandler)((GstPad *)(((GstRealPad *)(pad))->peer),(event),(timestamp),(data)) : \
FALSE )
}G_STMT_END
#endif

View file

@ -44,7 +44,7 @@ struct _GstTrace {
};
struct _GstTraceEntry {
guint64 timestamp;
gint64 timestamp;
guint32 sequence;
guint32 data;
gchar message[112];

View file

@ -52,7 +52,7 @@ enum {
ARG_LOCATION,
ARG_BYTESPERREAD,
ARG_OFFSET,
ARG_SIZE,
ARG_FILESIZE,
};
@ -117,8 +117,8 @@ gst_disksrc_class_init (GstDiskSrcClass *klass)
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_OFFSET,
g_param_spec_long("offset","offset","offset",
G_MINLONG,G_MAXLONG,0,G_PARAM_READWRITE)); // CHECKME
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_SIZE,
g_param_spec_long("size","size","size",
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_FILESIZE,
g_param_spec_long("filesize","filesize","filesize",
G_MINLONG,G_MAXLONG,0,G_PARAM_READABLE)); // CHECKME
gobject_class->set_property = gst_disksrc_set_property;
@ -211,7 +211,7 @@ gst_disksrc_get_property (GObject *object, guint prop_id, GValue *value, GParamS
case ARG_OFFSET:
g_value_set_long (value, src->curoffset);
break;
case ARG_SIZE:
case ARG_FILESIZE:
g_value_set_long (value, src->size);
break;
default:
@ -240,7 +240,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_event(pad, GST_EVENT_EOS, 0LL, 0);
buf = gst_buffer_new();
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_EOS);
return buf;
@ -263,7 +263,8 @@ gst_disksrc_get (GstPad *pad)
} else
GST_BUFFER_SIZE (buf) = src->bytes_per_read;
GST_DEBUG (0,"map %p, offset %ld, size %d\n", src->map, src->curoffset, GST_BUFFER_SIZE (buf));
GST_DEBUG (0,"map %p, offset %ld (%p), size %d\n", src->map, src->curoffset,
src->map + src->curoffset, GST_BUFFER_SIZE (buf));
//gst_util_dump_mem (GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
@ -303,7 +304,7 @@ gst_disksrc_get_region (GstPad *pad, GstRegionType type,guint64 offset,guint64 l
/* deal with EOF state */
if (offset >= src->size) {
gst_pad_event (pad, (void*)GST_EVENT_EOS);
gst_pad_event (pad, GST_EVENT_EOS, 0LL, 0);
GST_DEBUG (0,"map offset %lld >= size %ld --> eos\n", offset, src->size);
//FIXME
buf = gst_buffer_new();
@ -365,6 +366,7 @@ gst_disksrc_open_file (GstDiskSrc *src)
src->new_seek = TRUE;
}
return TRUE;
GST_DEBUG(0, "opened file %s\n",src->filename);
}
/* unmap and close the file */

View file

@ -66,7 +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 gboolean gst_fakesink_event (GstPad *pad, GstEventType event, guint64 timestamp, guint32 data);
static GstElementClass *parent_class = NULL;
static guint gst_fakesink_signals[LAST_SIGNAL] = { 0 };
@ -222,7 +222,7 @@ gst_fakesink_chain (GstPad *pad, GstBuffer *buf)
fakesink = GST_FAKESINK (gst_pad_get_parent (pad));
if (!fakesink->silent)
g_print("fakesink: chain ******* (%s:%s)< (%d bytes, %llu) \n",
g_print("fakesink: chain ******* (%s:%s)< (%d bytes, %lld) \n",
GST_DEBUG_PAD_NAME (pad), GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf));
g_signal_emit (G_OBJECT (fakesink), gst_fakesink_signals[SIGNAL_HANDOFF], 0,
@ -242,10 +242,10 @@ gst_fakesink_factory_init (GstElementFactory *factory)
static gboolean
gst_fakesink_event (GstPad *pad, void *event)
gst_fakesink_event (GstPad *pad, GstEventType event, guint64 timestamp, guint32 data)
{
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, "fakesink has event %d on pad %s:%s\n",event,GST_DEBUG_PAD_NAME(pad));
if (event == GST_EVENT_EOS) {
GST_DEBUG(GST_CAT_EVENT, "have EOS\n");
}
}

View file

@ -334,7 +334,7 @@ gst_fakesrc_get(GstPad *pad)
g_return_val_if_fail (GST_IS_FAKESRC (src), NULL);
if (src->num_buffers == 0) {
gst_pad_event (pad, (void*)GST_EVENT_EOS);
gst_pad_event (pad, GST_EVENT_EOS, 0LL, 0);
return NULL;
}
else {
@ -344,7 +344,7 @@ gst_fakesrc_get(GstPad *pad)
if (src->eos) {
GST_INFO (0, "fakesrc is setting eos on pad");
gst_pad_event (pad, (void*)GST_EVENT_EOS);
gst_pad_event (pad, GST_EVENT_EOS, 0LL, 0);
return NULL;
}
@ -387,7 +387,7 @@ gst_fakesrc_loop(GstElement *element)
GstBuffer *buf;
if (src->num_buffers == 0) {
gst_pad_event (pad, (void*)GST_EVENT_EOS);
gst_pad_event (pad, GST_EVENT_EOS, 0LL, 0);
return;
}
else {
@ -397,7 +397,7 @@ gst_fakesrc_loop(GstElement *element)
if (src->eos) {
GST_INFO (0, "fakesrc is setting eos on pad");
gst_pad_event (pad, (void*)GST_EVENT_EOS);
gst_pad_event (pad, GST_EVENT_EOS, 0LL, 0);
return;
}

View file

@ -203,7 +203,7 @@ gst_multidisksrc_get (GstPad *pad)
gst_multidisksrc_close_file(src);
if (!src->listptr) {
gst_pad_event (pad, (void*)GST_EVENT_EOS);
gst_pad_event (pad, GST_EVENT_EOS, 0LL, 0);
return FALSE;
}

View file

@ -203,7 +203,7 @@ gst_multidisksrc_get (GstPad *pad)
gst_multidisksrc_close_file(src);
if (!src->listptr) {
gst_pad_event (pad, (void*)GST_EVENT_EOS);
gst_pad_event (pad, GST_EVENT_EOS, 0LL, 0);
return FALSE;
}

View file

@ -180,7 +180,7 @@ gst_pipefilter_get (GstPad *pad)
}
/* if we didn't get as many bytes as we asked for, we're at EOF */
if (readbytes == 0) {
gst_pad_event (pad, (void*)GST_EVENT_EOS);
gst_pad_event (pad, GST_EVENT_EOS, 0LL, 0);
return NULL;
}