[gst-cvs] CVS: gstreamer/libs/bytestream gstbytestream.c,1.3,1.4 gstbytestream.h,1.3,1.4

Wim Taymans wtay at users.sourceforge.net
Mon Oct 22 12:01:53 PDT 2001


Update of /cvsroot/gstreamer/gstreamer/libs/bytestream
In directory usw-pr-cvs1:/tmp/cvs-serv8038

Modified Files:
	gstbytestream.c gstbytestream.h 
Log Message:
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.



Index: gstbytestream.c
===================================================================
RCS file: /cvsroot/gstreamer/gstreamer/libs/bytestream/gstbytestream.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- gstbytestream.c	2001/10/21 19:14:48	1.3
+++ gstbytestream.c	2001/10/22 19:00:52	1.4
@@ -52,7 +52,7 @@
   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 @@
 {
   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 @@
   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 @@
   return TRUE;
 }
 
-
 static gboolean
 gst_bytestream_fill_bytes (GstByteStream * bs, guint32 len)
 {
@@ -395,6 +405,21 @@
   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
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- gstbytestream.h	2001/10/21 19:14:48	1.3
+++ gstbytestream.h	2001/10/22 19:00:52	1.4
@@ -31,6 +31,8 @@
 struct _GstByteStream {
   GstPad *pad;
 
+  GstEvent *    event;
+
   GSList 	*buflist;
   guint32 	headbufavail;
   guint32 	listavail;
@@ -48,6 +50,7 @@
 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-commits mailing list