From 14de4f27daa8132a1f8dddecaa7bf0c8929d59ea Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 22 Oct 2001 19:00:52 +0000 Subject: [PATCH] Patch from vishnu: Original commit message from CVS: Patch from vishnu: The attached patch adds event support to bytestream. Here's how it works: When bytestream encounters an event, the event is saved and it returns NULL. Then you must call a new API to retrieve the event and handle it: void gst_bytestream_get_status (GstByteStream *bs, guint32 *avail_out, GstEvent **event_out); Whatever is necessary to handle the event is left up to the plugin. Once the event is retrieved then the bytestream continues as usual. --- libs/bytestream/gstbytestream.c | 29 +++++++++++++++++++++++++++-- libs/bytestream/gstbytestream.h | 3 +++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/libs/bytestream/gstbytestream.c b/libs/bytestream/gstbytestream.c index 3df468104b..b39b077049 100644 --- a/libs/bytestream/gstbytestream.c +++ b/libs/bytestream/gstbytestream.c @@ -52,7 +52,7 @@ gst_bytestream_new (GstPad * pad) GstByteStream *bs = g_new (GstByteStream, 1); bs->pad = pad; - + bs->event = NULL; bs->buflist = NULL; bs->headbufavail = 0; bs->listavail = 0; @@ -66,6 +66,9 @@ gst_bytestream_destroy (GstByteStream * bs) { GSList *walk; + if (bs->event) + gst_event_free (bs->event); + walk = bs->buflist; while (walk) { gst_buffer_unref (GST_BUFFER (walk->data)); @@ -116,9 +119,17 @@ gst_bytestream_get_next_buf (GstByteStream * bs) GstBuffer *nextbuf, *lastbuf; GSList *end; + g_assert (!bs->event); + bs_print ("get_next_buf: pulling buffer\n"); nextbuf = gst_pad_pull (bs->pad); + if (GST_IS_EVENT (nextbuf)) + { + bs->event = GST_EVENT (nextbuf); + return FALSE; + } + if (!nextbuf) return FALSE; @@ -172,7 +183,6 @@ gst_bytestream_get_next_buf (GstByteStream * bs) return TRUE; } - static gboolean gst_bytestream_fill_bytes (GstByteStream * bs, guint32 len) { @@ -397,6 +407,21 @@ gst_bytestream_read (GstByteStream * bs, guint32 len) return buf; } +void +gst_bytestream_get_status (GstByteStream *bs, + guint32 *avail_out, + GstEvent **event_out) +{ + if (avail_out) + *avail_out = bs->listavail; + + if (event_out) + { + *event_out = bs->event; + bs->event = NULL; + } +} + void gst_bytestream_print_status (GstByteStream * bs) { diff --git a/libs/bytestream/gstbytestream.h b/libs/bytestream/gstbytestream.h index dbff9a32e3..7061e93e08 100644 --- a/libs/bytestream/gstbytestream.h +++ b/libs/bytestream/gstbytestream.h @@ -31,6 +31,8 @@ typedef struct _GstByteStream GstByteStream; struct _GstByteStream { GstPad *pad; + GstEvent * event; + GSList *buflist; guint32 headbufavail; guint32 listavail; @@ -48,6 +50,7 @@ GstBuffer* gst_bytestream_peek (GstByteStream *bs, guint32 len); guint8* gst_bytestream_peek_bytes (GstByteStream *bs, guint32 len); gboolean gst_bytestream_flush (GstByteStream *bs, guint32 len); void gst_bytestream_flush_fast (GstByteStream * bs, guint32 len); +void gst_bytestream_get_status (GstByteStream *bs, guint32 *avail_out, GstEvent **event_out); void gst_bytestream_print_status (GstByteStream *bs);