project: Use asset ID as URI if possible
authorThibault Saunier <tsaunier@igalia.com>
Tue, 9 Jul 2019 04:05:21 +0000 (00:05 -0400)
committerThibault Saunier <tsaunier@igalia.com>
Fri, 26 Jul 2019 17:48:51 +0000 (13:48 -0400)
It was making no sense to consider it an empty timeline when the user
had passed the project URI when requesting the asset. Usually user
use `ges_project_new` with the URI but it is also valid to use
`ges_asset_request` with the uri as ID so let's handle that properly.

ges/ges-project.c

index ba9c568..8ff82a2 100644 (file)
@@ -209,18 +209,24 @@ _load_project (GESProject * project, GESTimeline * timeline, GError ** error)
 
   g_signal_emit (project, _signals[LOADING_SIGNAL], 0, timeline);
   if (priv->uri == NULL) {
-    EmitLoadedInIdle *data = g_slice_new (EmitLoadedInIdle);
 
-    GST_LOG_OBJECT (project, "%s, Loading an empty timeline %s"
-        " as no URI set yet", GST_OBJECT_NAME (timeline),
-        ges_asset_get_id (GES_ASSET (project)));
+    if (gst_uri_is_valid (ges_asset_get_id (GES_ASSET (project)))) {
+      ges_project_set_uri (project, ges_asset_get_id (GES_ASSET (project)));
+      GST_INFO_OBJECT (project, "Using asset ID %s as URI.", priv->uri);
+    } else {
+      EmitLoadedInIdle *data = g_slice_new (EmitLoadedInIdle);
 
-    data->timeline = gst_object_ref (timeline);
-    data->project = gst_object_ref (project);
+      GST_INFO_OBJECT (project, "%s, Loading an empty timeline %s"
+          " as no URI set yet", GST_OBJECT_NAME (timeline),
+          ges_asset_get_id (GES_ASSET (project)));
 
-    /* Make sure the signal is emitted after the functions ends */
-    g_idle_add ((GSourceFunc) _emit_loaded_in_idle, data);
-    return TRUE;
+      data->timeline = gst_object_ref (timeline);
+      data->project = gst_object_ref (project);
+
+      /* Make sure the signal is emitted after the functions ends */
+      g_idle_add ((GSourceFunc) _emit_loaded_in_idle, data);
+      return TRUE;
+    }
   }
 
   if (priv->formatter_asset == NULL)