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.
This commit is contained in:
Wim Taymans 2002-06-13 22:29:32 +00:00
parent 9286f126e2
commit 2a01bdbe56
2 changed files with 23 additions and 0 deletions

View file

@ -497,6 +497,8 @@ 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)
return 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

View 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);