validate: Allow scenarios to set track types
authorThibault Saunier <tsaunier@igalia.com>
Fri, 28 Jun 2019 21:35:40 +0000 (17:35 -0400)
committerThibault Saunier <tsaunier@igalia.com>
Fri, 5 Jul 2019 22:30:41 +0000 (18:30 -0400)
tools/ges-launcher.c
tools/ges-validate.c
tools/ges-validate.h

index 4f7875f..90451c6 100644 (file)
@@ -206,15 +206,16 @@ _project_loaded_cb (GESProject * project, GESTimeline * timeline,
   }
 
   project_uri = ges_project_get_uri (project);
-  _timeline_set_user_options (self, timeline, project_uri);
 
   if (self->priv->parsed_options.load_path && project_uri
       && ges_validate_activate (GST_PIPELINE (self->priv->pipeline),
-          opts->scenario, &opts->needs_set_state) == FALSE) {
+          &opts->track_types, opts->scenario,
+          &opts->needs_set_state) == FALSE) {
     g_error ("Could not activate scenario %s", opts->scenario);
     self->priv->seenerrors = TRUE;
     g_application_quit (G_APPLICATION (self));
   }
+  _timeline_set_user_options (self, timeline, project_uri);
 
   g_free (project_uri);
 
@@ -414,7 +415,8 @@ _run_pipeline (GESLauncher * self)
 
   if (!opts->load_path) {
     if (ges_validate_activate (GST_PIPELINE (self->priv->pipeline),
-            opts->scenario, &opts->needs_set_state) == FALSE) {
+            &opts->track_types, opts->scenario,
+            &opts->needs_set_state) == FALSE) {
       g_error ("Could not activate scenario %s", opts->scenario);
       return FALSE;
     }
index d6c97a0..4423d33 100644 (file)
 #include "config.h"
 #endif
 
+#include "utils.h"
 #include "ges-validate.h"
 
 #include <string.h>
-#include <ges/ges.h>
 
 #ifdef HAVE_GST_VALIDATE
 #include <gst/validate/gst-validate-scenario.h>
 #include <gst/validate/validate.h>
 #include <gst/validate/gst-validate-utils.h>
 #include <gst/validate/gst-validate-element-monitor.h>
+#include <gst/validate/gst-validate-bin-monitor.h>
 
 #define MONITOR_ON_PIPELINE "validate-monitor"
 #define RUNNER_ON_PIPELINE "runner-monitor"
@@ -99,10 +100,9 @@ ges_validate_register_issues (void)
           " in a Video track).", GST_VALIDATE_REPORT_LEVEL_CRITICAL));
 }
 
-
 gboolean
-ges_validate_activate (GstPipeline * pipeline, const gchar * scenario,
-    gboolean * needs_setting_state)
+ges_validate_activate (GstPipeline * pipeline, GESTrackType * track_types,
+    const gchar * scenario, gboolean * needs_setting_state)
 {
   GstValidateRunner *runner = NULL;
   GstValidateMonitor *monitor = NULL;
@@ -126,6 +126,24 @@ ges_validate_activate (GstPipeline * pipeline, const gchar * scenario,
   monitor =
       gst_validate_monitor_factory_create (GST_OBJECT_CAST (pipeline), runner,
       NULL);
+  if (GST_VALIDATE_BIN_MONITOR (monitor)->scenario) {
+    GstStructure *metas =
+        GST_VALIDATE_BIN_MONITOR (monitor)->scenario->description;
+
+    if (metas) {
+      const gchar *track_types_str;
+
+      if ((track_types_str =
+              gst_structure_get_string (metas, "ges-track-types"))) {
+        if (!get_flags_from_string (GES_TYPE_TRACK_TYPE, track_types_str,
+                track_types)) {
+          GST_ERROR_OBJECT (pipeline, "Scenario track types: %s no valid",
+              track_types_str);
+          return FALSE;
+        }
+      }
+    }
+  }
 
   gst_validate_reporter_set_handle_g_logs (GST_VALIDATE_REPORTER (monitor));
 
@@ -208,8 +226,8 @@ _print_position (GstElement * pipeline)
 }
 
 gboolean
-ges_validate_activate (GstPipeline * pipeline, const gchar * scenario,
-    gboolean * needs_setting_state)
+ges_validate_activate (GstPipeline * pipeline, GESTrackType * track_types,
+    const gchar * scenario, gboolean * needs_setting_state)
 {
   if (scenario) {
     GST_WARNING ("Trying to run scenario %s, but gst-validate not supported",
index 4363e89..8f76e78 100644 (file)
 #include <glib.h>
 #include <gio/gio.h>
 #include <gst/gst.h>
+#include <ges/ges.h>
 
 G_BEGIN_DECLS
 
 gboolean
-ges_validate_activate (GstPipeline *pipeline, const gchar *scenario, gboolean *needs_set_state);
+ges_validate_activate (GstPipeline *pipeline, GESTrackType *track_types,
+                       const gchar *scenario, gboolean *needs_set_state);
 void ges_launch_validate_uri (const gchar *nid);
 
 gint