[gst-devel] bytestream #2

vishnu at pobox.com vishnu at pobox.com
Sun Oct 21 19:24:01 CEST 2001


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.

-- 
Victory to the Divine Mother!!   ... after all,
  http://sahajayoga.org                http://why-compete.org
-------------- next part --------------
Index: gstbytestream.c
===================================================================
RCS file: /cvsroot/gstreamer/gstreamer/libs/bytestream/gstbytestream.c,v
retrieving revision 1.3
diff -u -p -r1.3 gstbytestream.c
--- gstbytestream.c	2001/10/21 19:14:48	1.3
+++ gstbytestream.c	2001/10/22 02:16:54
@@ -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 * 
 {
   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 (GstByteStre
   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 (GstByteStre
   return TRUE;
 }
 
-
 static gboolean
 gst_bytestream_fill_bytes (GstByteStream * bs, guint32 len)
 {
@@ -395,6 +405,21 @@ gst_bytestream_read (GstByteStream * bs,
   gst_bytestream_flush_fast (bs, 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
Index: gstbytestream.h
===================================================================
RCS file: /cvsroot/gstreamer/gstreamer/libs/bytestream/gstbytestream.h,v
retrieving revision 1.3
diff -u -p -r1.3 gstbytestream.h
--- gstbytestream.h	2001/10/21 19:14:48	1.3
+++ gstbytestream.h	2001/10/22 02:16:54
@@ -31,6 +31,8 @@ typedef struct _GstByteStream GstByteStr
 struct _GstByteStream {
   GstPad *pad;
 
+  GstEvent *    event;
+
   GSList 	*buflist;
   guint32 	headbufavail;
   guint32 	listavail;
@@ -48,6 +50,7 @@ GstBuffer*		gst_bytestream_peek		(GstByt
 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);
 


More information about the gstreamer-devel mailing list