mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-25 09:40:37 +00:00
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:
parent
38a7abe545
commit
ba9e0cc8d5
2 changed files with 59 additions and 9 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue