mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-28 20:51:13 +00:00
file-check: add reverse-playback test
Adds a test that checks if reverse playback works without errors
This commit is contained in:
parent
737a2664f2
commit
4f11a05baf
3 changed files with 66 additions and 9 deletions
|
@ -151,7 +151,7 @@ main (int argc, gchar ** argv)
|
||||||
GError *err = NULL;
|
GError *err = NULL;
|
||||||
guint count = -1;
|
guint count = -1;
|
||||||
|
|
||||||
gboolean playback = FALSE, seekable = FALSE;
|
gboolean playback = FALSE, seekable = FALSE, reverse_playback = FALSE;
|
||||||
gint64 filesize = 0, filesize_tolerance = 0, duration_arg =
|
gint64 filesize = 0, filesize_tolerance = 0, duration_arg =
|
||||||
0, duration_tolerance = 0;
|
0, duration_tolerance = 0;
|
||||||
GstClockTime duration = GST_CLOCK_TIME_NONE;
|
GstClockTime duration = GST_CLOCK_TIME_NONE;
|
||||||
|
@ -173,6 +173,10 @@ main (int argc, gchar ** argv)
|
||||||
{"playback", 'p', 0, G_OPTION_ARG_NONE,
|
{"playback", 'p', 0, G_OPTION_ARG_NONE,
|
||||||
&playback, "If the file should be tested for playback",
|
&playback, "If the file should be tested for playback",
|
||||||
NULL},
|
NULL},
|
||||||
|
{"reverse-playback", '\0', 0, G_OPTION_ARG_NONE,
|
||||||
|
&reverse_playback,
|
||||||
|
"If the file should be tested for reverse playback",
|
||||||
|
NULL},
|
||||||
{"file-size", '\0', 0, G_OPTION_ARG_INT64, &filesize,
|
{"file-size", '\0', 0, G_OPTION_ARG_INT64, &filesize,
|
||||||
"The expected file size in bytes", NULL},
|
"The expected file size in bytes", NULL},
|
||||||
{"file-size-tolerance", '\0', 0, G_OPTION_ARG_INT64, &filesize_tolerance,
|
{"file-size-tolerance", '\0', 0, G_OPTION_ARG_INT64, &filesize_tolerance,
|
||||||
|
@ -212,6 +216,7 @@ main (int argc, gchar ** argv)
|
||||||
fc = g_object_new (GST_TYPE_QA_FILE_CHECKER, "uri",
|
fc = g_object_new (GST_TYPE_QA_FILE_CHECKER, "uri",
|
||||||
argv[1], "profile", encoding_profile, "qa-runner", runner,
|
argv[1], "profile", encoding_profile, "qa-runner", runner,
|
||||||
"is-seekable", seekable, "test-playback", playback,
|
"is-seekable", seekable, "test-playback", playback,
|
||||||
|
"test-reverse-playback", reverse_playback,
|
||||||
"file-size", (guint64) filesize, "file-size-tolerance", (guint64)
|
"file-size", (guint64) filesize, "file-size-tolerance", (guint64)
|
||||||
filesize_tolerance, "duration", (guint64) duration,
|
filesize_tolerance, "duration", (guint64) duration,
|
||||||
"duration-tolerance", (guint64) duration_tolerance, NULL);
|
"duration-tolerance", (guint64) duration_tolerance, NULL);
|
||||||
|
|
|
@ -42,6 +42,7 @@ enum
|
||||||
PROP_FILE_SIZE_TOLERANCE,
|
PROP_FILE_SIZE_TOLERANCE,
|
||||||
PROP_SEEKABLE,
|
PROP_SEEKABLE,
|
||||||
PROP_TEST_PLAYBACK,
|
PROP_TEST_PLAYBACK,
|
||||||
|
PROP_TEST_REVERSE_PLAYBACK,
|
||||||
PROP_LAST
|
PROP_LAST
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -51,6 +52,7 @@ enum
|
||||||
#define DEFAULT_FILE_SIZE_TOLERANCE 0
|
#define DEFAULT_FILE_SIZE_TOLERANCE 0
|
||||||
#define DEFAULT_SEEKABLE FALSE
|
#define DEFAULT_SEEKABLE FALSE
|
||||||
#define DEFAULT_PLAYBACK FALSE
|
#define DEFAULT_PLAYBACK FALSE
|
||||||
|
#define DEFAULT_REVERSE_PLAYBACK FALSE
|
||||||
|
|
||||||
GST_DEBUG_CATEGORY_STATIC (gst_qa_file_checker_debug);
|
GST_DEBUG_CATEGORY_STATIC (gst_qa_file_checker_debug);
|
||||||
#define GST_CAT_DEFAULT gst_qa_file_checker_debug
|
#define GST_CAT_DEFAULT gst_qa_file_checker_debug
|
||||||
|
@ -153,6 +155,11 @@ gst_qa_file_checker_class_init (GstQaFileCheckerClass * klass)
|
||||||
g_param_spec_boolean ("test-playback", "test playback",
|
g_param_spec_boolean ("test-playback", "test playback",
|
||||||
"If the file should be tested for playback", DEFAULT_PLAYBACK,
|
"If the file should be tested for playback", DEFAULT_PLAYBACK,
|
||||||
G_PARAM_READWRITE | G_PARAM_STATIC_NAME));
|
G_PARAM_READWRITE | G_PARAM_STATIC_NAME));
|
||||||
|
|
||||||
|
g_object_class_install_property (gobject_class, PROP_TEST_REVERSE_PLAYBACK,
|
||||||
|
g_param_spec_boolean ("test-reverse-playback", "test reverse playback",
|
||||||
|
"If the file should be tested for reverse playback",
|
||||||
|
DEFAULT_REVERSE_PLAYBACK, G_PARAM_READWRITE | G_PARAM_STATIC_NAME));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -166,6 +173,7 @@ gst_qa_file_checker_init (GstQaFileChecker * fc)
|
||||||
fc->file_size_tolerance = DEFAULT_FILE_SIZE_TOLERANCE;
|
fc->file_size_tolerance = DEFAULT_FILE_SIZE_TOLERANCE;
|
||||||
fc->seekable = DEFAULT_SEEKABLE;
|
fc->seekable = DEFAULT_SEEKABLE;
|
||||||
fc->test_playback = DEFAULT_PLAYBACK;
|
fc->test_playback = DEFAULT_PLAYBACK;
|
||||||
|
fc->test_reverse_playback = DEFAULT_REVERSE_PLAYBACK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -208,6 +216,9 @@ gst_qa_file_checker_set_property (GObject * object, guint prop_id,
|
||||||
case PROP_TEST_PLAYBACK:
|
case PROP_TEST_PLAYBACK:
|
||||||
fc->test_playback = g_value_get_boolean (value);
|
fc->test_playback = g_value_get_boolean (value);
|
||||||
break;
|
break;
|
||||||
|
case PROP_TEST_REVERSE_PLAYBACK:
|
||||||
|
fc->test_reverse_playback = g_value_get_boolean (value);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
|
@ -251,6 +262,9 @@ gst_qa_file_checker_get_property (GObject * object, guint prop_id,
|
||||||
case PROP_TEST_PLAYBACK:
|
case PROP_TEST_PLAYBACK:
|
||||||
g_value_set_boolean (value, fc->test_playback);
|
g_value_set_boolean (value, fc->test_playback);
|
||||||
break;
|
break;
|
||||||
|
case PROP_TEST_REVERSE_PLAYBACK:
|
||||||
|
g_value_set_boolean (value, fc->test_reverse_playback);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
|
@ -583,8 +597,10 @@ check_encoding_profile (GstQaFileChecker * fc, GstDiscovererInfo * info)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef gboolean (*GstElementConfigureFunc) (GstQaFileChecker *, GstElement *);
|
||||||
static gboolean
|
static gboolean
|
||||||
check_playback (GstQaFileChecker * fc)
|
check_playback_scenario (GstQaFileChecker * fc,
|
||||||
|
GstElementConfigureFunc configure_function, const gchar * messages_prefix)
|
||||||
{
|
{
|
||||||
GstElement *playbin;
|
GstElement *playbin;
|
||||||
GstElement *videosink, *audiosink;
|
GstElement *videosink, *audiosink;
|
||||||
|
@ -592,9 +608,6 @@ check_playback (GstQaFileChecker * fc)
|
||||||
GstMessage *msg;
|
GstMessage *msg;
|
||||||
gboolean ret = TRUE;
|
gboolean ret = TRUE;
|
||||||
|
|
||||||
if (!fc->test_playback)
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
playbin = gst_element_factory_make ("playbin2", "fc-playbin");
|
playbin = gst_element_factory_make ("playbin2", "fc-playbin");
|
||||||
videosink = gst_element_factory_make ("fakesink", "fc-videosink");
|
videosink = gst_element_factory_make ("fakesink", "fc-videosink");
|
||||||
audiosink = gst_element_factory_make ("fakesink", "fc-audiosink");
|
audiosink = gst_element_factory_make ("fakesink", "fc-audiosink");
|
||||||
|
@ -615,6 +628,11 @@ check_playback (GstQaFileChecker * fc)
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (configure_function) {
|
||||||
|
if (!configure_function (fc, playbin))
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
bus = gst_pipeline_get_bus (GST_PIPELINE (playbin));
|
bus = gst_pipeline_get_bus (GST_PIPELINE (playbin));
|
||||||
msg =
|
msg =
|
||||||
gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE,
|
gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE,
|
||||||
|
@ -627,8 +645,9 @@ check_playback (GstQaFileChecker * fc)
|
||||||
gchar *debug = NULL;
|
gchar *debug = NULL;
|
||||||
|
|
||||||
gst_message_parse_error (msg, &error, &debug);
|
gst_message_parse_error (msg, &error, &debug);
|
||||||
GST_QA_REPORT (fc, GST_QA_ISSUE_ID_FILE_PLAYBACK_ERROR, "File %s failed "
|
GST_QA_REPORT (fc, GST_QA_ISSUE_ID_FILE_PLAYBACK_ERROR,
|
||||||
"during playback. Error: %s : %s", fc->uri, error->message, debug);
|
"%s - File %s failed " "during playback. Error: %s : %s",
|
||||||
|
messages_prefix, fc->uri, error->message, debug);
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
g_free (debug);
|
g_free (debug);
|
||||||
|
|
||||||
|
@ -638,8 +657,8 @@ check_playback (GstQaFileChecker * fc)
|
||||||
}
|
}
|
||||||
gst_message_unref (msg);
|
gst_message_unref (msg);
|
||||||
} else {
|
} else {
|
||||||
GST_QA_REPORT (fc, GST_QA_ISSUE_ID_FILE_PLAYBACK_ERROR, "File playback "
|
GST_QA_REPORT (fc, GST_QA_ISSUE_ID_FILE_PLAYBACK_ERROR, "%s - "
|
||||||
"finished unexpectedly");
|
"File playback finished unexpectedly", messages_prefix);
|
||||||
}
|
}
|
||||||
gst_object_unref (bus);
|
gst_object_unref (bus);
|
||||||
|
|
||||||
|
@ -650,6 +669,37 @@ end:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
check_playback (GstQaFileChecker * fc)
|
||||||
|
{
|
||||||
|
if (!fc->test_playback)
|
||||||
|
return TRUE;
|
||||||
|
return check_playback_scenario (fc, NULL, "Playback");
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
send_reverse_seek (GstQaFileChecker * fc, GstElement * pipeline)
|
||||||
|
{
|
||||||
|
gboolean ret;
|
||||||
|
|
||||||
|
ret = gst_element_seek (pipeline, -1.0, GST_FORMAT_TIME,
|
||||||
|
GST_SEEK_FLAG_FLUSH, GST_SEEK_TYPE_SET, 0, GST_SEEK_TYPE_SET, -1);
|
||||||
|
|
||||||
|
if (!ret) {
|
||||||
|
GST_QA_REPORT (fc, GST_QA_ISSUE_ID_FILE_PLAYBACK_ERROR,
|
||||||
|
"Reverse playback seek failed");
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
check_reverse_playback (GstQaFileChecker * fc)
|
||||||
|
{
|
||||||
|
if (!fc->test_reverse_playback)
|
||||||
|
return TRUE;
|
||||||
|
return check_playback_scenario (fc, send_reverse_seek, "Reverse playback");
|
||||||
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
gst_qa_file_checker_run (GstQaFileChecker * fc)
|
gst_qa_file_checker_run (GstQaFileChecker * fc)
|
||||||
{
|
{
|
||||||
|
@ -680,6 +730,7 @@ gst_qa_file_checker_run (GstQaFileChecker * fc)
|
||||||
ret = check_seekable (fc, info) & ret;
|
ret = check_seekable (fc, info) & ret;
|
||||||
ret = check_encoding_profile (fc, info) & ret;
|
ret = check_encoding_profile (fc, info) & ret;
|
||||||
ret = check_playback (fc) & ret;
|
ret = check_playback (fc) & ret;
|
||||||
|
ret = check_reverse_playback (fc) & ret;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,6 +64,7 @@ struct _GstQaFileChecker {
|
||||||
gboolean seekable; /* TODO should we care about disabling this check? */
|
gboolean seekable; /* TODO should we care about disabling this check? */
|
||||||
|
|
||||||
gboolean test_playback;
|
gboolean test_playback;
|
||||||
|
gboolean test_reverse_playback;
|
||||||
|
|
||||||
gchar *uri;
|
gchar *uri;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue