Patch from vishnu:
authorWim Taymans <wim.taymans@gmail.com>
Mon, 22 Oct 2001 19:00:52 +0000 (19:00 +0000)
committerWim Taymans <wim.taymans@gmail.com>
Mon, 22 Oct 2001 19:00:52 +0000 (19:00 +0000)
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
libs/bytestream/gstbytestream.h

index 3df4681..b39b077 100644 (file)
@@ -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)
 {
@@ -398,6 +408,21 @@ gst_bytestream_read (GstByteStream * bs, guint32 len)
 }
 
 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)
 {
   GSList *walk;
index dbff9a3..7061e93 100644 (file)
@@ -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);