libs/gst/bytestream/filepad.*: add 2 new functions

Original commit message from CVS:
* libs/gst/bytestream/filepad.c: (gst_file_pad_available),
(gst_file_pad_get_length):
* libs/gst/bytestream/filepad.h:
add 2 new functions
This commit is contained in:
Benjamin Otte 2004-06-24 02:18:59 +00:00
parent 6b5554c50f
commit 5e2e65c734
3 changed files with 57 additions and 1 deletions

View file

@ -1,3 +1,10 @@
2004-06-24 Benjamin Otte <in7y118@public.uni-hamburg.de>
* libs/gst/bytestream/filepad.c: (gst_file_pad_available),
(gst_file_pad_get_length):
* libs/gst/bytestream/filepad.h:
add 2 new functions
2004-06-22 Zaheer Abbas Merali <zaheerabbas at merali.org>
* docs/gst/gstreamer-sections.txt:

View file

@ -412,7 +412,7 @@ gst_file_pad_error (GstFilePad * pad)
/**
* gst_file_pad_eof:
* @pad: ia #GstFilePad
* @pad: a #GstFilePad
*
* Checks if the EOS has been reached. This function is modeled after the
* function feof() from libc.
@ -433,3 +433,50 @@ gst_file_pad_eof (GstFilePad * pad)
return 1;
}
/**
* gst_file_pad_available:
* @pad: a #GstFilePad
*
* Use this function to figure out the maximum number of bytes that can be read
* via gst_file_pad_read() without that function returning -EAGAIN.
*
* Returns: the number of bytes available in the file pad.
*/
guint
gst_file_pad_available (GstFilePad * pad)
{
g_return_val_if_fail (GST_IS_FILE_PAD (pad), 0);
return gst_adapter_available (pad->adapter);
}
/**
* gst_file_pad_get_length:
* @pad: a #GstFilePad
*
* Gets the length in bytes of the @pad.
*
* Returns: length in bytes or -1 if not available
*/
gint64
gst_file_pad_get_length (GstFilePad * pad)
{
GstFormat format = GST_FORMAT_BYTES;
gint64 length;
GstPad *peer;
g_return_val_if_fail (GST_IS_FILE_PAD (pad), -1);
/* we query the length every time to avoid issues with changing lengths */
peer = GST_PAD_PEER (pad);
if (!peer)
return -1;
if (gst_pad_query (peer, GST_QUERY_TOTAL, &format, &length))
return length;
format = GST_FORMAT_DEFAULT;
if (gst_pad_query (peer, GST_QUERY_TOTAL, &format, &length))
return length;
return -1;
}

View file

@ -74,6 +74,8 @@ void gst_file_pad_set_event_function (GstFilePad *file_pad,
void gst_file_pad_set_iterate_function (GstFilePad *file_pad,
GstFilePadIterateFunction iterate);
guint gst_file_pad_available (GstFilePad *pad);
gint64 gst_file_pad_get_length (GstFilePad *pad);
/* this is a file like interface */
/* FIXME: is gint64 the correct type? (it must be signed to get error return vals */
gint64 gst_file_pad_read (GstFilePad *pad,