mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-05 06:58:56 +00:00
validate: Handle position printing at the monitor level
Instead of replicating that code all around
This commit is contained in:
parent
810e432da2
commit
38eda37341
5 changed files with 41 additions and 74 deletions
|
@ -61,6 +61,11 @@ gst_validate_bin_monitor_dispose (GObject * object)
|
||||||
if (monitor->scenario)
|
if (monitor->scenario)
|
||||||
g_object_unref (monitor->scenario);
|
g_object_unref (monitor->scenario);
|
||||||
|
|
||||||
|
if (monitor->print_pos_srcid) {
|
||||||
|
if (g_source_remove (monitor->print_pos_srcid))
|
||||||
|
monitor->print_pos_srcid = 0;
|
||||||
|
}
|
||||||
|
|
||||||
g_list_free_full (monitor->element_monitors, g_object_unref);
|
g_list_free_full (monitor->element_monitors, g_object_unref);
|
||||||
|
|
||||||
G_OBJECT_CLASS (parent_class)->dispose (object);
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
||||||
|
@ -86,6 +91,34 @@ gst_validate_bin_monitor_init (GstValidateBinMonitor * bin_monitor)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
print_position (GstValidateMonitor *monitor)
|
||||||
|
{
|
||||||
|
GstQuery *query;
|
||||||
|
gint64 position, duration;
|
||||||
|
GstElement *pipeline = GST_ELEMENT (GST_VALIDATE_MONITOR_GET_OBJECT (monitor));
|
||||||
|
|
||||||
|
gdouble rate = 1.0;
|
||||||
|
GstFormat format = GST_FORMAT_TIME;
|
||||||
|
|
||||||
|
gst_element_query_position (pipeline, format, &position);
|
||||||
|
|
||||||
|
format = GST_FORMAT_TIME;
|
||||||
|
gst_element_query_duration (pipeline, format, &duration);
|
||||||
|
|
||||||
|
query = gst_query_new_segment (GST_FORMAT_DEFAULT);
|
||||||
|
if (gst_element_query (pipeline, query))
|
||||||
|
gst_query_parse_segment (query, &rate, NULL, NULL, NULL);
|
||||||
|
gst_query_unref (query);
|
||||||
|
|
||||||
|
gst_validate_printf (NULL,
|
||||||
|
"<position: %" GST_TIME_FORMAT " duration: %" GST_TIME_FORMAT
|
||||||
|
" speed: %f />\r", GST_TIME_ARGS (position), GST_TIME_ARGS (duration),
|
||||||
|
rate);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_validate_bin_monitor_create_scenarios (GstValidateBinMonitor * monitor)
|
gst_validate_bin_monitor_create_scenarios (GstValidateBinMonitor * monitor)
|
||||||
{
|
{
|
||||||
|
@ -93,6 +126,9 @@ gst_validate_bin_monitor_create_scenarios (GstValidateBinMonitor * monitor)
|
||||||
if (GST_IS_PIPELINE (GST_VALIDATE_MONITOR_GET_OBJECT (monitor))) {
|
if (GST_IS_PIPELINE (GST_VALIDATE_MONITOR_GET_OBJECT (monitor))) {
|
||||||
const gchar *scenario_name;
|
const gchar *scenario_name;
|
||||||
|
|
||||||
|
monitor->print_pos_srcid =
|
||||||
|
g_timeout_add (500, (GSourceFunc) print_position, monitor);
|
||||||
|
|
||||||
if ((scenario_name = g_getenv ("GST_VALIDATE_SCENARIO"))) {
|
if ((scenario_name = g_getenv ("GST_VALIDATE_SCENARIO"))) {
|
||||||
gchar **scenario_v = g_strsplit (scenario_name, "->", 2);
|
gchar **scenario_v = g_strsplit (scenario_name, "->", 2);
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,7 @@ struct _GstValidateBinMonitor {
|
||||||
|
|
||||||
/*< private >*/
|
/*< private >*/
|
||||||
gulong element_added_id;
|
gulong element_added_id;
|
||||||
|
guint print_pos_srcid;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -215,15 +215,13 @@ gst_validate_report_load_issues (void)
|
||||||
_("Query position reported a value outside of the current expected "
|
_("Query position reported a value outside of the current expected "
|
||||||
"segment"), NULL);
|
"segment"), NULL);
|
||||||
REGISTER_VALIDATE_ISSUE (CRITICAL, SCENARIO_NOT_ENDED,
|
REGISTER_VALIDATE_ISSUE (CRITICAL, SCENARIO_NOT_ENDED,
|
||||||
_("All the actions were not executed before the program stoped"),
|
_("All the actions were not executed before the program stoped"), NULL);
|
||||||
NULL);
|
|
||||||
REGISTER_VALIDATE_ISSUE (CRITICAL, SCENARIO_ACTION_EXECUTION_ERROR,
|
REGISTER_VALIDATE_ISSUE (CRITICAL, SCENARIO_ACTION_EXECUTION_ERROR,
|
||||||
_("The execution of an action did not properly happen"),
|
_("The execution of an action did not properly happen"), NULL);
|
||||||
NULL);
|
|
||||||
REGISTER_VALIDATE_ISSUE (WARNING, G_LOG_WARNING, _("We got a g_log warning"),
|
REGISTER_VALIDATE_ISSUE (WARNING, G_LOG_WARNING, _("We got a g_log warning"),
|
||||||
NULL);
|
NULL);
|
||||||
REGISTER_VALIDATE_ISSUE (WARNING, G_LOG_CRITICAL,
|
REGISTER_VALIDATE_ISSUE (WARNING, G_LOG_CRITICAL,
|
||||||
_("We got a g_log critical issue"), NULL);
|
_("We got a g_log critical issue"), NULL);
|
||||||
REGISTER_VALIDATE_ISSUE (ISSUE, G_LOG_ISSUE, _("We got a g_log issue"), NULL);
|
REGISTER_VALIDATE_ISSUE (ISSUE, G_LOG_ISSUE, _("We got a g_log issue"), NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,6 @@ 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 buffering = FALSE;
|
||||||
static gboolean is_live = FALSE;
|
static gboolean is_live = FALSE;
|
||||||
|
@ -422,32 +421,6 @@ _execute_set_restriction (GstValidateScenario * scenario,
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
|
||||||
print_position (void)
|
|
||||||
{
|
|
||||||
GstQuery *query;
|
|
||||||
gint64 position, duration;
|
|
||||||
|
|
||||||
gdouble rate = 1.0;
|
|
||||||
GstFormat format = GST_FORMAT_TIME;
|
|
||||||
|
|
||||||
gst_element_query_position (pipeline, format, &position);
|
|
||||||
|
|
||||||
format = GST_FORMAT_TIME;
|
|
||||||
gst_element_query_duration (pipeline, format, &duration);
|
|
||||||
|
|
||||||
query = gst_query_new_segment (GST_FORMAT_DEFAULT);
|
|
||||||
if (gst_element_query (pipeline, query))
|
|
||||||
gst_query_parse_segment (query, &rate, NULL, NULL, NULL);
|
|
||||||
gst_query_unref (query);
|
|
||||||
|
|
||||||
g_print ("<position: %" GST_TIME_FORMAT " duration: %" GST_TIME_FORMAT
|
|
||||||
" speed: %f />\r", GST_TIME_ARGS (position), GST_TIME_ARGS (duration),
|
|
||||||
rate);
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
bus_callback (GstBus * bus, GstMessage * message, gpointer data)
|
bus_callback (GstBus * bus, GstMessage * message, gpointer data)
|
||||||
{
|
{
|
||||||
|
@ -462,9 +435,6 @@ 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");
|
||||||
}
|
}
|
||||||
|
@ -520,10 +490,6 @@ bus_callback (GstBus * bus, GstMessage * message, gpointer data)
|
||||||
/* buffering... */
|
/* buffering... */
|
||||||
if (!buffering) {
|
if (!buffering) {
|
||||||
gst_element_set_state (pipeline, GST_STATE_PAUSED);
|
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;
|
buffering = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,6 @@ static GstElement *pipeline;
|
||||||
|
|
||||||
static gboolean buffering = FALSE;
|
static gboolean buffering = FALSE;
|
||||||
static gboolean is_live = FALSE;
|
static gboolean is_live = FALSE;
|
||||||
static guint print_pos_srcid = 0;
|
|
||||||
|
|
||||||
#ifdef G_OS_UNIX
|
#ifdef G_OS_UNIX
|
||||||
static gboolean
|
static gboolean
|
||||||
|
@ -57,32 +56,6 @@ intr_handler (gpointer user_data)
|
||||||
}
|
}
|
||||||
#endif /* G_OS_UNIX */
|
#endif /* G_OS_UNIX */
|
||||||
|
|
||||||
static gboolean
|
|
||||||
print_position (void)
|
|
||||||
{
|
|
||||||
GstQuery *query;
|
|
||||||
gint64 position, duration;
|
|
||||||
|
|
||||||
gdouble rate = 1.0;
|
|
||||||
GstFormat format = GST_FORMAT_TIME;
|
|
||||||
|
|
||||||
gst_element_query_position (pipeline, format, &position);
|
|
||||||
|
|
||||||
format = GST_FORMAT_TIME;
|
|
||||||
gst_element_query_duration (pipeline, format, &duration);
|
|
||||||
|
|
||||||
query = gst_query_new_segment (GST_FORMAT_DEFAULT);
|
|
||||||
if (gst_element_query (pipeline, query))
|
|
||||||
gst_query_parse_segment (query, &rate, NULL, NULL, NULL);
|
|
||||||
gst_query_unref (query);
|
|
||||||
|
|
||||||
g_print ("<position: %" GST_TIME_FORMAT " duration: %" GST_TIME_FORMAT
|
|
||||||
" speed: %f />\r", GST_TIME_ARGS (position), GST_TIME_ARGS (duration),
|
|
||||||
rate);
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
bus_callback (GstBus * bus, GstMessage * message, gpointer data)
|
bus_callback (GstBus * bus, GstMessage * message, gpointer data)
|
||||||
{
|
{
|
||||||
|
@ -105,9 +78,6 @@ bus_callback (GstBus * bus, GstMessage * message, gpointer data)
|
||||||
g_main_loop_quit (loop);
|
g_main_loop_quit (loop);
|
||||||
break;
|
break;
|
||||||
case GST_MESSAGE_ASYNC_DONE:
|
case GST_MESSAGE_ASYNC_DONE:
|
||||||
if (print_pos_srcid == 0)
|
|
||||||
print_pos_srcid =
|
|
||||||
g_timeout_add (50, (GSourceFunc) print_position, NULL);
|
|
||||||
break;
|
break;
|
||||||
case GST_MESSAGE_STATE_CHANGED:
|
case GST_MESSAGE_STATE_CHANGED:
|
||||||
if (GST_MESSAGE_SRC (message) == GST_OBJECT (pipeline)) {
|
if (GST_MESSAGE_SRC (message) == GST_OBJECT (pipeline)) {
|
||||||
|
@ -152,10 +122,6 @@ bus_callback (GstBus * bus, GstMessage * message, gpointer data)
|
||||||
/* buffering... */
|
/* buffering... */
|
||||||
if (!buffering) {
|
if (!buffering) {
|
||||||
gst_element_set_state (pipeline, GST_STATE_PAUSED);
|
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;
|
buffering = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue