From: Thibault Saunier Date: Tue, 14 Jan 2020 13:26:54 +0000 (-0300) Subject: validate:ssim: Enhance printing position X-Git-Tag: 1.19.3~491^2~185 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4ae29ab7ed6a07efdcee7e492d55b3a95daf5903;p=platform%2Fupstream%2Fgstreamer.git validate:ssim: Enhance printing position Adding a new `gst_validate_print_position` method which also sends messages to the runner if required. --- diff --git a/validate/gst/validate/gst-validate-pipeline-monitor.c b/validate/gst/validate/gst-validate-pipeline-monitor.c index 8ea73fdb43..6aa590e791 100644 --- a/validate/gst/validate/gst-validate-pipeline-monitor.c +++ b/validate/gst/validate/gst-validate-pipeline-monitor.c @@ -35,8 +35,6 @@ #include #endif -static gboolean output_is_tty = TRUE; - enum { PROP_0, @@ -142,11 +140,6 @@ gst_validate_pipeline_monitor_class_init (GstValidatePipelineMonitorClass * object_class->get_property = gst_validate_pipeline_monitor_get_property; g_object_class_override_property (object_class, PROP_VERBOSITY, "verbosity"); - -#ifdef HAVE_UNISTD_H - output_is_tty = isatty (1); -#endif - } static void @@ -160,7 +153,6 @@ print_position (GstValidateMonitor * monitor) { GstQuery *query; gint64 position, duration; - JsonBuilder *jbuilder; GstElement *pipeline = GST_ELEMENT (gst_validate_monitor_get_pipeline (monitor)); @@ -196,25 +188,7 @@ print_position (GstValidateMonitor * monitor) gst_query_parse_segment (query, &rate, NULL, NULL, NULL); gst_query_unref (query); - jbuilder = json_builder_new (); - json_builder_begin_object (jbuilder); - json_builder_set_member_name (jbuilder, "type"); - json_builder_add_string_value (jbuilder, "position"); - json_builder_set_member_name (jbuilder, "position"); - json_builder_add_int_value (jbuilder, position); - json_builder_set_member_name (jbuilder, "duration"); - json_builder_add_int_value (jbuilder, duration); - json_builder_set_member_name (jbuilder, "speed"); - json_builder_add_double_value (jbuilder, rate); - json_builder_end_object (jbuilder); - - gst_validate_send (json_builder_get_root (jbuilder)); - g_object_unref (jbuilder); - - gst_validate_printf (NULL, - "%c", GST_TIME_ARGS (position), GST_TIME_ARGS (duration), - rate, output_is_tty ? '\r' : '\n'); + gst_validate_print_position (position, duration, rate, NULL); done: gst_object_unref (pipeline); diff --git a/validate/gst/validate/gst-validate-report.c b/validate/gst/validate/gst-validate-report.c index 1b1e06d067..91141e2483 100644 --- a/validate/gst/validate/gst-validate-report.c +++ b/validate/gst/validate/gst-validate-report.c @@ -43,6 +43,7 @@ static GstClockTime _gst_validate_report_start_time = 0; static GstValidateDebugFlags _gst_validate_flags = 0; static GHashTable *_gst_validate_issues = NULL; static FILE **log_files = NULL; +static gboolean output_is_tty = TRUE; /* Tcp server for communications with gst-validate-launcher */ GSocketClient *socket_client = NULL; @@ -552,6 +553,9 @@ gst_validate_report_init (void) gst_validate_report_load_issues (); } +#ifdef HAVE_UNISTD_H + output_is_tty = isatty (1); +#endif server_env = g_getenv ("GST_VALIDATE_SERVER"); uuid = g_getenv ("GST_VALIDATE_UUID"); @@ -1235,3 +1239,36 @@ gst_validate_report_add_repeated_report (GstValidateReport * report, g_list_append (report->repeated_reports, gst_validate_report_ref (repeated_report)); } + + +void +gst_validate_print_position (GstClockTime position, GstClockTime duration, + gdouble rate, gchar * extra_info) +{ + JsonBuilder *jbuilder; + + gst_validate_printf (NULL, + "%c", GST_TIME_ARGS (position), GST_TIME_ARGS (duration), + rate, extra_info ? extra_info : "", output_is_tty ? '\r' : '\n'); + + if (!server_ostream) + return; + + jbuilder = json_builder_new (); + json_builder_begin_object (jbuilder); + json_builder_set_member_name (jbuilder, "type"); + json_builder_add_string_value (jbuilder, "position"); + json_builder_set_member_name (jbuilder, "position"); + json_builder_add_int_value (jbuilder, position); + json_builder_set_member_name (jbuilder, "duration"); + json_builder_add_int_value (jbuilder, duration); + json_builder_set_member_name (jbuilder, "speed"); + json_builder_add_double_value (jbuilder, rate); + json_builder_end_object (jbuilder); + + gst_validate_send (json_builder_get_root (jbuilder)); + g_object_unref (jbuilder); + + g_free (extra_info); +} diff --git a/validate/gst/validate/gst-validate-report.h b/validate/gst/validate/gst-validate-report.h index 04b307e68d..898e57c2a0 100644 --- a/validate/gst/validate/gst-validate-report.h +++ b/validate/gst/validate/gst-validate-report.h @@ -309,6 +309,8 @@ GST_VALIDATE_API void gst_validate_report_add_repeated_report (GstValidateReport *report, GstValidateReport *repeated_report); GST_VALIDATE_API GstValidateReportLevel gst_validate_report_level_from_name (const gchar *level_name); +GST_VALIDATE_API +void gst_validate_print_position(GstClockTime position, GstClockTime duration, gdouble rate, gchar* extra_info); G_END_DECLS diff --git a/validate/plugins/ssim/gstvalidatessim.c b/validate/plugins/ssim/gstvalidatessim.c index 53168cf09e..28d671bc6f 100644 --- a/validate/plugins/ssim/gstvalidatessim.c +++ b/validate/plugins/ssim/gstvalidatessim.c @@ -180,13 +180,10 @@ runner_stopping (GstValidateRunner * runner, ValidateSsimOverride * self) min_avg = MIN (min_avg, mssim); min_min = MIN (lowest, min_min); total_avg += mssim; - gst_validate_printf (NULL, - "\n", - GST_TIME_ARGS (frame->position), GST_TIME_ARGS (GST_CLOCK_TIME_NONE), - i + 1, nfiles, mssim, lowest, npassed, nfailures); - - g_free (bname); + gst_validate_print_position(frame->position, GST_CLOCK_TIME_NONE, 1.0, + g_strdup_printf(" %d / %d avg: %f min: %f (Passed: %d failed: %d)", + i + 1, nfiles, mssim, lowest, npassed, nfailures)); + g_free(bname); } gst_validate_printf (NULL,