diff options
author | Sebastian Dröge <slomo@circular-chaos.org> | 2008-01-06 16:36:32 +0000 |
---|---|---|
committer | Sebastian Dröge <slomo@circular-chaos.org> | 2008-01-06 16:36:32 +0000 |
commit | 815666e762e6ff17aea1f505eee67c38193e6b86 (patch) | |
tree | 4a29297230964cd500f2b5671239c683611369b2 /ext/gio | |
parent | b37e08cb29ddca72161a8098690ba52e5594153d (diff) | |
download | gst-plugins-bad-815666e762e6ff17aea1f505eee67c38193e6b86.tar.gz gst-plugins-bad-815666e762e6ff17aea1f505eee67c38193e6b86.tar.bz2 gst-plugins-bad-815666e762e6ff17aea1f505eee67c38193e6b86.zip |
Update to GMemoryInputStream API changes in GLib SVN and require gio-2.0 >= 2.15.1 for this. Fixes bug #507584.
Original commit message from CVS:
* configure.ac:
* ext/gio/gstgiobasesrc.c: (gst_gio_base_src_get_size):
* tests/check/pipelines/gio.c: (free_input), (GST_START_TEST):
Update to GMemoryInputStream API changes in GLib SVN and require
gio-2.0 >= 2.15.1 for this. Fixes bug #507584.
We can also report the duration for every GSeekable, not only
GFileInputStream and GMemoryInputStream.
Diffstat (limited to 'ext/gio')
-rw-r--r-- | ext/gio/gstgiobasesrc.c | 51 |
1 files changed, 44 insertions, 7 deletions
diff --git a/ext/gio/gstgiobasesrc.c b/ext/gio/gstgiobasesrc.c index eaf6b954..019f8ee4 100644 --- a/ext/gio/gstgiobasesrc.c +++ b/ext/gio/gstgiobasesrc.c @@ -185,15 +185,52 @@ gst_gio_base_src_get_size (GstBaseSrc * base_src, guint64 * size) g_clear_error (&err); } - } else if (G_IS_MEMORY_INPUT_STREAM (src->stream)) { - gsize data_size; + } else if (GST_GIO_STREAM_IS_SEEKABLE (src->stream)) { + goffset old; + goffset stream_size; + gboolean ret; + GSeekable *seekable = G_SEEKABLE (src->stream); + GError *err = NULL; + + old = g_seekable_tell (seekable); + + ret = g_seekable_seek (seekable, 0, G_SEEK_END, src->cancel, &err); + if (!ret) { + if (!gst_gio_error (src, "g_seekable_seek", &err, NULL)) { + if (GST_GIO_ERROR_MATCHES (err, NOT_SUPPORTED)) + GST_DEBUG_OBJECT (src, + "Seeking to the end of stream is not supported"); + else + GST_WARNING_OBJECT (src, "Seeking to end of stream failed: %s", + err->message); + g_clear_error (&err); + } else { + GST_WARNING_OBJECT (src, "Seeking to end of stream failed"); + } + + return FALSE; + } - data_size = - g_memory_input_stream_get_data_size (G_MEMORY_INPUT_STREAM (src-> - stream)); + stream_size = g_seekable_tell (seekable); + + ret = g_seekable_seek (seekable, old, G_SEEK_SET, src->cancel, &err); + if (!ret) { + if (!gst_gio_error (src, "g_seekable_seek", &err, NULL)) { + if (GST_GIO_ERROR_MATCHES (err, NOT_SUPPORTED)) + GST_ERROR_OBJECT (src, "Seeking to the old position not supported"); + else + GST_ERROR_OBJECT (src, "Seeking to the old position failed: %s", + err->message); + g_clear_error (&err); + } else { + GST_ERROR_OBJECT (src, "Seeking to the old position faile"); + } + + return FALSE; + } - if (data_size != -1) { - *size = data_size; + if (stream_size >= 0) { + *size = stream_size; return TRUE; } } |