mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 10:11:08 +00:00
tests: add interactive test for gapless playback using SEGMENT seeks
Not working too well yet, there are glitches even with WAV or FLAC. https://bugzilla.gnome.org/show_bug.cgi?id=692368
This commit is contained in:
parent
6348de195d
commit
7b64b3e109
3 changed files with 137 additions and 0 deletions
1
tests/icles/.gitignore
vendored
1
tests/icles/.gitignore
vendored
|
@ -1,6 +1,7 @@
|
|||
equalizer-test
|
||||
gdkpixbufsink-test
|
||||
test-accurate-seek
|
||||
test-segment-seeks
|
||||
test-oss4
|
||||
ximagesrc-test
|
||||
v4l2src-test
|
||||
|
|
|
@ -45,6 +45,10 @@ test_accurate_seek_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) \
|
|||
test_accurate_seek_LDADD = $(GST_PLUGINS_BASE_LIBS) -lgstapp-$(GST_API_VERSION) \
|
||||
$(GST_BASE_LIBS) $(GST_LIBS)
|
||||
|
||||
test_segment_seeks_SOURCES = test-segment-seeks.c
|
||||
test_segment_seeks_CFLAGS = $(GST_CFLAGS)
|
||||
test_segment_seeks_LDADD = $(GST_LIBS)
|
||||
|
||||
videocrop_test_SOURCES = videocrop-test.c
|
||||
videocrop_test_CFLAGS = $(GST_CFLAGS)
|
||||
videocrop_test_LDADD = $(GST_LIBS)
|
||||
|
@ -60,6 +64,7 @@ videocrop2_test_LDADD = $(GST_LIBS)
|
|||
noinst_PROGRAMS = $(GTK_TESTS) $(OSS4_TESTS) $(V4L2_TESTS) $(X_TESTS) \
|
||||
equalizer-test \
|
||||
test-accurate-seek \
|
||||
test-segment-seeks \
|
||||
videocrop-test \
|
||||
videobox-test \
|
||||
videocrop2-test
|
||||
|
|
131
tests/icles/test-segment-seeks.c
Normal file
131
tests/icles/test-segment-seeks.c
Normal file
|
@ -0,0 +1,131 @@
|
|||
/* GStreamer interactive test for accurate segment seeking
|
||||
* Copyright (C) 2014 Tim-Philipp Müller <tim centricular com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
/* Plays the provided file one second at a time using segment seeks.
|
||||
* Theoretically this should be just as smooth as if we played the
|
||||
* file from start to stop in one go, certainly without hickups.
|
||||
*/
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include <gst/gst.h>
|
||||
|
||||
#define SEGMENT_DURATION (1 * GST_SECOND)
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
GstElement *playbin;
|
||||
GstMessage *msg;
|
||||
gchar *uri;
|
||||
gint64 dur, start, stop;
|
||||
|
||||
if (argc < 2) {
|
||||
g_printerr ("Usage: %s FILENAME\n", argv[0]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
gst_init (&argc, &argv);
|
||||
|
||||
if (gst_uri_is_valid (argv[1]))
|
||||
uri = g_strdup (argv[1]);
|
||||
else
|
||||
uri = gst_filename_to_uri (argv[1], NULL);
|
||||
|
||||
g_print ("uri: %s\n", uri);
|
||||
|
||||
playbin = gst_element_factory_make ("playbin", NULL);
|
||||
g_object_set (playbin, "uri", uri, NULL);
|
||||
|
||||
#if 0
|
||||
{
|
||||
GstElement *src;
|
||||
|
||||
playbin = gst_parse_launch ("uridecodebin name=d ! queue ! "
|
||||
"filesink location=/tmp/raw1.data", NULL);
|
||||
src = gst_bin_get_by_name (GST_BIN (playbin), "d");
|
||||
g_object_set (src, "uri", uri, NULL);
|
||||
gst_object_unref (src);
|
||||
}
|
||||
#endif
|
||||
|
||||
gst_element_set_state (playbin, GST_STATE_PAUSED);
|
||||
|
||||
/* wait for preroll */
|
||||
msg = gst_bus_timed_pop_filtered (GST_ELEMENT_BUS (playbin),
|
||||
GST_CLOCK_TIME_NONE, GST_MESSAGE_ASYNC_DONE | GST_MESSAGE_ERROR);
|
||||
|
||||
g_assert (GST_MESSAGE_TYPE (msg) != GST_MESSAGE_ERROR);
|
||||
|
||||
gst_message_unref (msg);
|
||||
|
||||
if (!gst_element_query_duration (playbin, GST_FORMAT_TIME, &dur))
|
||||
g_error ("Failed to query duration!\n");
|
||||
|
||||
g_print ("Duration: %" GST_TIME_FORMAT "\n", GST_TIME_ARGS (dur));
|
||||
|
||||
start = 0;
|
||||
do {
|
||||
GstSeekFlags seek_flags;
|
||||
gboolean ret;
|
||||
|
||||
seek_flags = GST_SEEK_FLAG_ACCURATE | GST_SEEK_FLAG_SEGMENT;
|
||||
|
||||
if (start == 0)
|
||||
seek_flags |= GST_SEEK_FLAG_FLUSH;
|
||||
|
||||
stop = start + SEGMENT_DURATION;
|
||||
|
||||
g_print ("Segment: %" GST_TIME_FORMAT "-%" GST_TIME_FORMAT "\n",
|
||||
GST_TIME_ARGS (start), GST_TIME_ARGS (stop));
|
||||
|
||||
ret = gst_element_seek (playbin, 1.0, GST_FORMAT_TIME, seek_flags,
|
||||
GST_SEEK_TYPE_SET, start, GST_SEEK_TYPE_SET, stop);
|
||||
|
||||
g_assert (ret);
|
||||
|
||||
if (start == 0) {
|
||||
/* wait for preroll again */
|
||||
msg = gst_bus_timed_pop_filtered (GST_ELEMENT_BUS (playbin),
|
||||
GST_CLOCK_TIME_NONE, GST_MESSAGE_ASYNC_DONE | GST_MESSAGE_ERROR);
|
||||
|
||||
g_assert (GST_MESSAGE_TYPE (msg) != GST_MESSAGE_ERROR);
|
||||
gst_message_unref (msg);
|
||||
|
||||
gst_element_set_state (playbin, GST_STATE_PLAYING);
|
||||
}
|
||||
|
||||
/* wait for end of segment */
|
||||
msg = gst_bus_timed_pop_filtered (GST_ELEMENT_BUS (playbin),
|
||||
GST_CLOCK_TIME_NONE, GST_MESSAGE_SEGMENT_DONE | GST_MESSAGE_ERROR);
|
||||
|
||||
g_assert (GST_MESSAGE_TYPE (msg) != GST_MESSAGE_ERROR);
|
||||
|
||||
gst_message_unref (msg);
|
||||
|
||||
start = stop;
|
||||
}
|
||||
while (start < dur);
|
||||
|
||||
gst_element_set_state (playbin, GST_STATE_NULL);
|
||||
gst_object_unref (playbin);
|
||||
return 0;
|
||||
}
|
Loading…
Reference in a new issue