mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-31 03:29:50 +00:00
validate:tools: Implement Buffering support in the various tools
This commit is contained in:
parent
b3c71bba02
commit
8b8562ea85
3 changed files with 131 additions and 14 deletions
|
@ -47,6 +47,10 @@ static GstEncodingProfile *encoding_profile = NULL;
|
||||||
static gboolean eos_on_shutdown = FALSE;
|
static gboolean eos_on_shutdown = FALSE;
|
||||||
static gboolean force_reencoding = FALSE;
|
static gboolean force_reencoding = FALSE;
|
||||||
static GList *all_raw_caps = NULL;
|
static GList *all_raw_caps = NULL;
|
||||||
|
static guint print_pos_srcid = 0;
|
||||||
|
|
||||||
|
static gboolean buffering = FALSE;
|
||||||
|
static gboolean is_live = FALSE;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
@ -458,6 +462,9 @@ bus_callback (GstBus * bus, GstMessage * message, gpointer data)
|
||||||
gst_message_parse_state_changed (message, &old, &new, &pending);
|
gst_message_parse_state_changed (message, &old, &new, &pending);
|
||||||
|
|
||||||
if (new == GST_STATE_PLAYING) {
|
if (new == GST_STATE_PLAYING) {
|
||||||
|
if (print_pos_srcid == 0)
|
||||||
|
print_pos_srcid =
|
||||||
|
g_timeout_add (50, (GSourceFunc) print_position, NULL);
|
||||||
GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (pipeline),
|
GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (pipeline),
|
||||||
GST_DEBUG_GRAPH_SHOW_ALL, "gst-validate-transcode.playing");
|
GST_DEBUG_GRAPH_SHOW_ALL, "gst-validate-transcode.playing");
|
||||||
}
|
}
|
||||||
|
@ -489,6 +496,39 @@ bus_callback (GstBus * bus, GstMessage * message, gpointer data)
|
||||||
case GST_MESSAGE_EOS:
|
case GST_MESSAGE_EOS:
|
||||||
g_main_loop_quit (loop);
|
g_main_loop_quit (loop);
|
||||||
break;
|
break;
|
||||||
|
case GST_MESSAGE_BUFFERING:{
|
||||||
|
gint percent;
|
||||||
|
|
||||||
|
if (!buffering) {
|
||||||
|
g_print ("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
gst_message_parse_buffering (message, &percent);
|
||||||
|
g_print ("%s %d%% \r", "Buffering...", percent);
|
||||||
|
|
||||||
|
/* no state management needed for live pipelines */
|
||||||
|
if (is_live)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (percent == 100) {
|
||||||
|
/* a 100% message means buffering is done */
|
||||||
|
if (buffering) {
|
||||||
|
buffering = FALSE;
|
||||||
|
gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/* buffering... */
|
||||||
|
if (!buffering) {
|
||||||
|
gst_element_set_state (pipeline, GST_STATE_PAUSED);
|
||||||
|
if (print_pos_srcid) {
|
||||||
|
if (g_source_remove (print_pos_srcid))
|
||||||
|
print_pos_srcid = 0;
|
||||||
|
}
|
||||||
|
buffering = TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -704,6 +744,8 @@ main (int argc, gchar ** argv)
|
||||||
GstValidateMonitor *monitor;
|
GstValidateMonitor *monitor;
|
||||||
GOptionContext *ctx;
|
GOptionContext *ctx;
|
||||||
int rep_err;
|
int rep_err;
|
||||||
|
GstStateChangeReturn sret;
|
||||||
|
|
||||||
#ifdef G_OS_UNIX
|
#ifdef G_OS_UNIX
|
||||||
guint signal_watch_id;
|
guint signal_watch_id;
|
||||||
#endif
|
#endif
|
||||||
|
@ -833,13 +875,24 @@ main (int argc, gchar ** argv)
|
||||||
gst_object_unref (bus);
|
gst_object_unref (bus);
|
||||||
|
|
||||||
g_print ("Starting pipeline\n");
|
g_print ("Starting pipeline\n");
|
||||||
if (gst_element_set_state (pipeline,
|
sret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
||||||
GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE) {
|
switch (sret) {
|
||||||
g_print ("Pipeline failed to go to PLAYING state\n");
|
case GST_STATE_CHANGE_FAILURE:
|
||||||
ret = -1;
|
/* ignore, we should get an error message posted on the bus */
|
||||||
goto exit;
|
g_print ("Pipeline failed to go to PLAYING state\n");
|
||||||
|
ret = -1;
|
||||||
|
goto exit;
|
||||||
|
case GST_STATE_CHANGE_NO_PREROLL:
|
||||||
|
g_print ("Pipeline is live.\n");
|
||||||
|
is_live = TRUE;
|
||||||
|
break;
|
||||||
|
case GST_STATE_CHANGE_ASYNC:
|
||||||
|
g_print ("Prerolling...\r");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
g_timeout_add (50, (GSourceFunc) print_position, NULL);
|
|
||||||
g_main_loop_run (mainloop);
|
g_main_loop_run (mainloop);
|
||||||
|
|
||||||
rep_err = gst_validate_runner_printf (runner);
|
rep_err = gst_validate_runner_printf (runner);
|
||||||
|
|
|
@ -40,6 +40,10 @@ static gint ret = 0;
|
||||||
static GMainLoop *mainloop;
|
static GMainLoop *mainloop;
|
||||||
static GstElement *pipeline;
|
static GstElement *pipeline;
|
||||||
|
|
||||||
|
static gboolean buffering = FALSE;
|
||||||
|
static gboolean is_live = FALSE;
|
||||||
|
static guint print_pos_srcid = 0;
|
||||||
|
|
||||||
#ifdef G_OS_UNIX
|
#ifdef G_OS_UNIX
|
||||||
static gboolean
|
static gboolean
|
||||||
intr_handler (gpointer user_data)
|
intr_handler (gpointer user_data)
|
||||||
|
@ -111,9 +115,50 @@ bus_callback (GstBus * bus, GstMessage * message, gpointer data)
|
||||||
gst_element_state_get_name (oldstate),
|
gst_element_state_get_name (oldstate),
|
||||||
gst_element_state_get_name (newstate),
|
gst_element_state_get_name (newstate),
|
||||||
gst_element_state_get_name (pending));
|
gst_element_state_get_name (pending));
|
||||||
|
|
||||||
|
if (newstate == GST_STATE_PLAYING) {
|
||||||
|
if (print_pos_srcid == 0)
|
||||||
|
print_pos_srcid =
|
||||||
|
g_timeout_add (50, (GSourceFunc) print_position, NULL);
|
||||||
|
GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (pipeline),
|
||||||
|
GST_DEBUG_GRAPH_SHOW_ALL, "gst-validate.playing");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
case GST_MESSAGE_BUFFERING:{
|
||||||
|
gint percent;
|
||||||
|
|
||||||
|
if (!buffering) {
|
||||||
|
g_print ("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
gst_message_parse_buffering (message, &percent);
|
||||||
|
g_print ("%s %d%% \r", "Buffering...", percent);
|
||||||
|
|
||||||
|
/* no state management needed for live pipelines */
|
||||||
|
if (is_live)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (percent == 100) {
|
||||||
|
/* a 100% message means buffering is done */
|
||||||
|
if (buffering) {
|
||||||
|
buffering = FALSE;
|
||||||
|
gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/* buffering... */
|
||||||
|
if (!buffering) {
|
||||||
|
gst_element_set_state (pipeline, GST_STATE_PAUSED);
|
||||||
|
if (print_pos_srcid) {
|
||||||
|
if (g_source_remove (print_pos_srcid))
|
||||||
|
print_pos_srcid = 0;
|
||||||
|
}
|
||||||
|
buffering = TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -127,6 +172,8 @@ main (int argc, gchar ** argv)
|
||||||
GError *err = NULL;
|
GError *err = NULL;
|
||||||
const gchar *scenario = NULL, *configs = NULL;
|
const gchar *scenario = NULL, *configs = NULL;
|
||||||
gboolean list_scenarios = FALSE;
|
gboolean list_scenarios = FALSE;
|
||||||
|
GstStateChangeReturn sret;
|
||||||
|
|
||||||
#ifdef G_OS_UNIX
|
#ifdef G_OS_UNIX
|
||||||
guint signal_watch_id;
|
guint signal_watch_id;
|
||||||
#endif
|
#endif
|
||||||
|
@ -237,21 +284,32 @@ main (int argc, gchar ** argv)
|
||||||
gst_object_unref (bus);
|
gst_object_unref (bus);
|
||||||
|
|
||||||
g_print ("Starting pipeline\n");
|
g_print ("Starting pipeline\n");
|
||||||
if (gst_element_set_state (pipeline,
|
sret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
||||||
GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE) {
|
switch (sret) {
|
||||||
g_print ("Pipeline failed to go to PLAYING state\n");
|
case GST_STATE_CHANGE_FAILURE:
|
||||||
ret = -1;
|
/* ignore, we should get an error message posted on the bus */
|
||||||
goto exit;
|
g_print ("Pipeline failed to go to PLAYING state\n");
|
||||||
|
ret = -1;
|
||||||
|
goto exit;
|
||||||
|
case GST_STATE_CHANGE_NO_PREROLL:
|
||||||
|
g_print ("Pipeline is live.\n");
|
||||||
|
is_live = TRUE;
|
||||||
|
break;
|
||||||
|
case GST_STATE_CHANGE_ASYNC:
|
||||||
|
g_print ("Prerolling...\r");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_timeout_add (50, (GSourceFunc) print_position, NULL);
|
|
||||||
g_print ("Pipeline started\n");
|
g_print ("Pipeline started\n");
|
||||||
g_main_loop_run (mainloop);
|
g_main_loop_run (mainloop);
|
||||||
|
|
||||||
rep_err = gst_validate_runner_printf (runner);
|
rep_err = gst_validate_runner_printf (runner);
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
ret = rep_err;
|
ret = rep_err;
|
||||||
g_print ("Returning %d as error where found", rep_err);
|
if (rep_err != 0)
|
||||||
|
g_print ("Returning %d as error where found", rep_err);
|
||||||
}
|
}
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
|
|
|
@ -210,6 +210,10 @@ def _parse_position(p):
|
||||||
return parse_gsttimeargs(start_stop[0]), parse_gsttimeargs(start_stop[1])
|
return parse_gsttimeargs(start_stop[0]), parse_gsttimeargs(start_stop[1])
|
||||||
|
|
||||||
|
|
||||||
|
def _parse_buffering(b):
|
||||||
|
return b.split("buffering... ")[1].split("%")[0], 100
|
||||||
|
|
||||||
|
|
||||||
def _get_position(test):
|
def _get_position(test):
|
||||||
position = duration = -1
|
position = duration = -1
|
||||||
|
|
||||||
|
@ -217,7 +221,7 @@ def _get_position(test):
|
||||||
m = None
|
m = None
|
||||||
for l in reversed(test.reporter.out.readlines()):
|
for l in reversed(test.reporter.out.readlines()):
|
||||||
l = l.lower()
|
l = l.lower()
|
||||||
if "<position:" in l:
|
if "<position:" in l or "buffering" in l:
|
||||||
m = l
|
m = l
|
||||||
break
|
break
|
||||||
|
|
||||||
|
@ -228,6 +232,8 @@ def _get_position(test):
|
||||||
for j in m.split("\r"):
|
for j in m.split("\r"):
|
||||||
if j.startswith("<position:") and j.endswith("/>"):
|
if j.startswith("<position:") and j.endswith("/>"):
|
||||||
position, duration = _parse_position(j)
|
position, duration = _parse_position(j)
|
||||||
|
elif j.startswith("buffering") and j.endswith("%"):
|
||||||
|
position, duration = _parse_buffering(j)
|
||||||
|
|
||||||
return position, duration
|
return position, duration
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue