Implement size_hint on bytestream so that plugins can give a hint about the number...
authorWim Taymans <wim.taymans@gmail.com>
Thu, 13 Jun 2002 22:29:32 +0000 (22:29 +0000)
committerWim Taymans <wim.taymans@gmail.com>
Thu, 13 Jun 2002 22:29:32 +0000 (22:29 +0000)
Original commit message from CVS:
Implement size_hint on bytestream so that plugins can give a hint about the
number of bytes they are going to read.

libs/gst/bytestream/bytestream.c
libs/gst/bytestream/bytestream.h

index 00ba66f..e9e7b73 100644 (file)
@@ -496,6 +496,8 @@ guint32
 gst_bytestream_read (GstByteStream * bs, GstBuffer** buf, guint32 len)
 {
   guint32 len_peeked;
+
+  g_return_val_if_fail (bs != NULL, -1);
   
   len_peeked = gst_bytestream_peek (bs, buf, len);
   if (len_peeked == 0)
@@ -506,6 +508,26 @@ gst_bytestream_read (GstByteStream * bs, GstBuffer** buf, guint32 len)
   return len_peeked;
 }
 
+/**
+ * gst_bytestream_size_hint
+ * @bs: a bytestream
+ * @size: the size to hint
+ *
+ * Give a hint that we are going to read chunks of the given size
+ *
+ * Returns: TRUE if the hint was accepted
+ */
+gboolean
+gst_bytestream_size_hint (GstByteStream *bs, guint32 size)
+{
+  GstEvent *event;
+
+  g_return_val_if_fail (bs != NULL, FALSE);
+
+  event = gst_event_new_size (GST_FORMAT_BYTES, size);
+
+  return gst_pad_send_event (GST_PAD_PEER (bs->pad), event);
+}
 
 /**
  * gst_bytestream_get_status
index 380c188..0738f70 100644 (file)
@@ -55,6 +55,7 @@ void                  gst_bytestream_destroy          (GstByteStream *bs);
 guint32                        gst_bytestream_read             (GstByteStream *bs, GstBuffer** buf, guint32 len);
 guint64                        gst_bytestream_tell             (GstByteStream *bs);
 guint64                        gst_bytestream_length           (GstByteStream *bs);
+gboolean               gst_bytestream_size_hint        (GstByteStream *bs, guint32 size);
 gboolean               gst_bytestream_seek             (GstByteStream *bs, gint64 offset, GstSeekType type);
 guint32                        gst_bytestream_peek             (GstByteStream *bs, GstBuffer** buf, guint32 len);
 guint32                        gst_bytestream_peek_bytes       (GstByteStream *bs, guint8** data, guint32 len);