validate:scenario: Implement a way to execute an action on message
authorThibault Saunier <tsaunier@igalia.com>
Wed, 20 Mar 2019 21:26:19 +0000 (18:26 -0300)
committerThibault Saunier <tsaunier@gnome.org>
Wed, 3 Apr 2019 13:38:42 +0000 (13:38 +0000)
And use it for seek forward and fast forward scenarios

validate/data/scenarios/fast_forward.scenario
validate/data/scenarios/seek_forward.scenario
validate/gst/validate/gst-validate-report.c
validate/gst/validate/gst-validate-scenario.c

index 78645a7..89855a6 100644 (file)
@@ -5,5 +5,4 @@ seek, name=Fast-forward-seek, playback-time="min(10.0, $(duration) * 0.0625)", r
 seek, name=Fast-forward-seek, playback-time="min(20.0, $(duration) * 0.125)", rate=8.0,  start=0.0, flags="$(default_flags)"
 seek, name=Fast-forward-seek, playback-time="min(40.0, $(duration) * 0.25)", rate=16.0, start=0.0, flags="$(default_flags)"
 seek, name=Fast-forward-seek, playback-time="min(80.0, $(duration) * 0.50)", rate=32.0, start=0.0, flags="$(default_flags)"
-wait, message-type=eos
-stop
\ No newline at end of file
+stop, playback-time="min($(duration) - 0.3, 160.0)", on-message="eos"
index 7069b7f..5e8e889 100644 (file)
@@ -3,4 +3,4 @@ include,location=includes/default-seek-flags.scenario
 seek, name=First-forward-seek, playback-time="min(5.0, ($(duration)/8))", start="min(10, 2*($(duration)/8))", flags="$(default_flags)"
 seek, name=Second-forward-seek, playback-time="min(15.0, 3*($(duration)/8))", start="min(20, 4*($(duration)/8))", flags="$(default_flags)"
 seek, name=Third-forward-seek, playback-time="min(25, 5*($(duration)/8))", start="min(30.0, 6*($(duration)/8))", flags="$(default_flags)"
-stop, playback-time="min($(duration) - 1, 35)"
+stop, playback-time="min($(duration) - 1, 35)", on-eos=true
\ No newline at end of file
index b423480..522af71 100644 (file)
@@ -929,6 +929,19 @@ gst_validate_printf_valist (gpointer source, const gchar * format, va_list args)
         .def = "0.0"
       };
 
+      GstValidateActionParameter on_message_param = {
+        .name = "on-message",
+        .description =
+            "Specify on what message type the action will be executed.\n"
+            " If both 'playback-time' and 'on-message' is specified, the action will be executed\n"
+            " on whatever happens first.",
+        .mandatory = FALSE,
+        .types = "string",
+        .possible_variables = NULL,
+        .def = NULL
+      };
+
+
       GstValidateActionType *type = GST_VALIDATE_ACTION_TYPE (source);
 
       g_string_assign (string, "\nAction type:");
@@ -947,12 +960,16 @@ gst_validate_printf_valist (gpointer source, const gchar * format, va_list args)
       g_string_append_printf (string, "\n\n  Description: \n    %s", desc);
       g_free (desc);
 
-      if (!IS_CONFIG_ACTION_TYPE (type->flags))
+      if (!IS_CONFIG_ACTION_TYPE (type->flags)) {
+        g_string_append_printf (string, "\n\n  Parameters:");
         print_action_parameter (string, type, &playback_time_param);
+        print_action_parameter (string, type, &on_message_param);
+      }
 
       if (type->parameters) {
+        if (IS_CONFIG_ACTION_TYPE (type->flags))
+          g_string_append_printf (string, "\n\n  Parameters:");
         has_parameters = TRUE;
-        g_string_append_printf (string, "\n\n  Parameters:");
         for (i = 0; type->parameters[i].name; i++) {
           print_action_parameter (string, type, &type->parameters[i]);
         }
index 099b0ed..01c7e35 100644 (file)
@@ -1682,6 +1682,15 @@ _check_position (GstValidateScenario * scenario, GstValidateAction * act,
 }
 
 static gboolean
+_check_message_type (GstValidateScenario * scenario, GstValidateAction * act,
+    GstMessage * message)
+{
+  return act && message
+      && !g_strcmp0 (gst_structure_get_string (act->structure, "on-message"),
+      gst_message_type_get_name (GST_MESSAGE_TYPE (message)));
+}
+
+static gboolean
 _should_execute_action (GstValidateScenario * scenario, GstValidateAction * act,
     GstClockTime position, gdouble rate)
 {
@@ -2029,7 +2038,7 @@ done:
  * synchronously
  */
 static gboolean
-execute_next_action (GstValidateScenario * scenario)
+execute_next_action_full (GstValidateScenario * scenario, GstMessage * message)
 {
   GList *tmp;
   gdouble rate = 1.0;
@@ -2104,8 +2113,12 @@ execute_next_action (GstValidateScenario * scenario)
     }
   }
 
-  if (!_check_position (scenario, act, &position, &rate))
+  if (message) {
+    if (!_check_message_type (scenario, act, message))
+      return G_SOURCE_CONTINUE;
+  } else if (!_check_position (scenario, act, &position, &rate)) {
     return G_SOURCE_CONTINUE;
+  }
 
   if (!_should_execute_action (scenario, act, position, rate)) {
     _add_execute_actions_gsource (scenario);
@@ -2119,6 +2132,11 @@ execute_next_action (GstValidateScenario * scenario)
       " at %" GST_TIME_FORMAT, act->structure, GST_TIME_ARGS (position));
   priv->seeked_in_pause = FALSE;
 
+  if (message)
+    gst_structure_remove_field (act->structure, "playback-time");
+  else
+    gst_structure_remove_field (act->structure, "on-message");
+
   act->priv->state = gst_validate_execute_action (type, act);
   if (act->priv->state == GST_VALIDATE_EXECUTE_ACTION_ERROR) {
     gchar *str = gst_structure_to_string (act->structure);
@@ -2188,6 +2206,12 @@ execute_next_action (GstValidateScenario * scenario)
 }
 
 static gboolean
+execute_next_action (GstValidateScenario * scenario)
+{
+  return execute_next_action_full (scenario, NULL);
+}
+
+static gboolean
 stop_waiting (GstValidateAction * action)
 {
   GstValidateScenario *scenario = gst_validate_action_get_scenario (action);
@@ -3338,6 +3362,8 @@ done:
   if (priv->message_type)
     _check_waiting_for_message (scenario, message);
 
+  execute_next_action_full (scenario, message);
+
   return TRUE;
 }