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.
This commit is contained in:
Sebastian Dröge 2008-01-06 16:36:32 +00:00
parent b37e08cb29
commit 815666e762
4 changed files with 70 additions and 10 deletions

View file

@ -1,3 +1,13 @@
2008-01-06 Sebastian Dröge <slomo@circular-chaos.org>
* 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.
2008-01-05 David Schleef <ds@schleef.org>
* sys/glsink/glimagesink.c:

View file

@ -584,7 +584,7 @@ AG_GST_CHECK_FEATURE(FAAD, [AAC decoder plug-in], faad, [
dnl *** libgio ***
translit(dnm, m, l) AM_CONDITIONAL(USE_GIO, true)
AG_GST_CHECK_FEATURE(GIO, [GIO library], gio, [
PKG_CHECK_MODULES(GIO, gio-2.0 >= 2.15.0, HAVE_GIO="yes", [
PKG_CHECK_MODULES(GIO, gio-2.0 >= 2.15.1, HAVE_GIO="yes", [
HAVE_GIO="no"
AC_MSG_RESULT(no)
])

View file

@ -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;
data_size =
g_memory_input_stream_get_data_size (G_MEMORY_INPUT_STREAM (src->
stream));
old = g_seekable_tell (seekable);
if (data_size != -1) {
*size = data_size;
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;
}
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 (stream_size >= 0) {
*size = stream_size;
return TRUE;
}
}

View file

@ -57,6 +57,12 @@ message_handler (GstBus * bus, GstMessage * msg, gpointer data)
return TRUE;
}
static void
free_input (gpointer data)
{
g_free (data);
}
GST_START_TEST (test_memory_stream)
{
GMainLoop *loop;
@ -70,6 +76,8 @@ GST_START_TEST (test_memory_stream)
guint8 *in_data;
GByteArray *out_data;
gint i;
GstFormat fmt = GST_FORMAT_BYTES;
gint64 duration;
got_eos = FALSE;
@ -78,8 +86,8 @@ GST_START_TEST (test_memory_stream)
in_data[i] = i % 256;
input =
G_MEMORY_INPUT_STREAM (g_memory_input_stream_from_data (in_data, 512));
g_memory_input_stream_set_free_data (input, TRUE);
G_MEMORY_INPUT_STREAM (g_memory_input_stream_new_from_data (in_data, 512,
free_input));
out_data = g_byte_array_new ();
output = G_MEMORY_OUTPUT_STREAM (g_memory_output_stream_new (out_data));
@ -105,6 +113,11 @@ GST_START_TEST (test_memory_stream)
gst_bus_add_watch (bus, message_handler, loop);
gst_object_unref (bus);
gst_element_set_state (bin, GST_STATE_PAUSED);
fail_unless (gst_element_query_duration (bin, &fmt, &duration));
fail_unless_equals_int (duration, 512);
gst_element_set_state (bin, GST_STATE_PLAYING);
g_main_loop_run (loop);