From 2a01bdbe56ab3d4dfccf10c1b8823ea1afcd5936 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 13 Jun 2002 22:29:32 +0000 Subject: [PATCH] Implement size_hint on bytestream so that plugins can give a hint about the number of bytes they are going to read. 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 | 22 ++++++++++++++++++++++ libs/gst/bytestream/bytestream.h | 1 + 2 files changed, 23 insertions(+) diff --git a/libs/gst/bytestream/bytestream.c b/libs/gst/bytestream/bytestream.c index 00ba66f..e9e7b73 100644 --- a/libs/gst/bytestream/bytestream.c +++ b/libs/gst/bytestream/bytestream.c @@ -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 diff --git a/libs/gst/bytestream/bytestream.h b/libs/gst/bytestream/bytestream.h index 380c188..0738f70 100644 --- a/libs/gst/bytestream/bytestream.h +++ b/libs/gst/bytestream/bytestream.h @@ -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); -- 2.7.4