diff --git a/girs/GES-1.0.gir b/girs/GES-1.0.gir
index f39d227f51..1aef02d442 100644
--- a/girs/GES-1.0.gir
+++ b/girs/GES-1.0.gir
@@ -3126,6 +3126,124 @@ if no track elements are created or an error occurred.
+
+
+
+
+
+ The default #GESDiscovererManager
+
+
+
+
+
+
+ The timeout to use for the discoverer
+
+
+
+
+ The #GESDiscovererManager
+
+
+
+
+
+
+
+ Whether to use the cache or not
+
+
+
+
+ The #GESDiscovererManager
+
+
+
+
+
+ Sets the timeout to use for the discoverer
+
+
+
+
+
+
+ The #GESDiscovererManager
+
+
+
+ The timeout to set
+
+
+
+
+
+ Sets whether to use the cache or not
+
+
+
+
+
+
+ The #GESDiscovererManager
+
+
+
+ Whether to use the cache
+
+
+
+
+
+ The timeout (in milliseconds) for the #GstDiscoverer operations
+
+
+
+
+
+
+
+
+
+
+
+
+ The #GstDiscovererInfo representing the discovered URI
+
+
+
+ The #GError that occurred, or %NULL
+
+
+
+
+
+ Retrieves information about a URI from and external source of information,
+like a cache file. This is used by the discoverer to speed up the
+discovery.
+
+ The #GstDiscovererInfo representing
+@uri, or %NULL if no information
+
+
+
+
+ The URI to load the serialized info for
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -14965,7 +15083,7 @@ ges_uri_clip_asset_new (uri, (GAsyncReadyCallback) filesource_asset_loaded_cb, u
- Creates a #GESUriClipAsset for @uri syncronously. You should avoid
+ Creates a #GESUriClipAsset for @uri synchonously. You should avoid
to use it in application, and rather create #GESUriClipAsset asynchronously
@@ -15115,8 +15233,9 @@ are different as those can be extended 'infinitely'.
-
+
Sets the timeout of #GESUriClipAsset loading
+ ges_discoverer_manager_set_timeout() should be used instead
diff --git a/girs/GstPbutils-1.0.gir b/girs/GstPbutils-1.0.gir
index d415a50b01..15d2e20cd8 100644
--- a/girs/GstPbutils-1.0.gir
+++ b/girs/GstPbutils-1.0.gir
@@ -369,6 +369,24 @@ free it when no longer needed using g_error_free().
+
+ Loads the serialized info from the given uri.
+
+
+ the #GstDiscovererInfo or %NULL if it could not be loaded
+
+
+
+
+ the #GstDiscoverer
+
+
+
+ the uri to load the info from
+
+
+
+
@@ -521,6 +539,22 @@ depending on the circumstances of the error.
+
+ Retrieves information about a URI from and external source of information,
+like a cache file. This is used by the discoverer to speed up the
+discovery.
+
+ The #GstDiscovererInfo representing
+@uri, or %NULL if no information
+
+
+
+
+ THe URI to load the serialized info for
+
+
+
+
This signal is emitted after the source element has been created for, so
the URI being discovered, so it can be configured by setting additional
@@ -708,8 +742,27 @@ information.
+
+
+
+
+ the #GstDiscovererInfo or %NULL if it could not be loaded
+
+
+
+
+ the #GstDiscoverer
+
+
+
+ the uri to load the info from
+
+
+
+
+
-
+
diff --git a/subprojects/gst-editing-services/ges/ges-discoverer-manager.c b/subprojects/gst-editing-services/ges/ges-discoverer-manager.c
new file mode 100644
index 0000000000..fd2dcd18fd
--- /dev/null
+++ b/subprojects/gst-editing-services/ges/ges-discoverer-manager.c
@@ -0,0 +1,353 @@
+#include "ges-internal.h"
+#include "ges-discoverer-manager.h"
+
+/**
+ * GESDiscovererManager:
+ *
+ * Since: 1.24
+ */
+
+struct _GESDiscovererManager
+{
+ GObject parent;
+
+ GHashTable *discoverers;
+ GMutex lock;
+ GstClockTime timeout;
+
+ gboolean use_cache;
+};
+
+G_DEFINE_TYPE (GESDiscovererManager, ges_discoverer_manager, G_TYPE_OBJECT);
+
+enum
+{
+ PROP_0,
+ PROP_TIMEOUT,
+ PROP_USE_CACHE,
+ N_PROPERTIES
+};
+
+enum
+{
+ LOAD_SERIALIZED_INFO_SIGNAL,
+ DISCOVERER_SIGNAL,
+ N_SIGNALS
+};
+
+#define DEFAULT_USE_CACHE FALSE
+#define DEFAULT_TIMEOUT (60 * GST_SECOND)
+static GParamSpec *properties[N_PROPERTIES] = { NULL, };
+static guint signals[N_SIGNALS] = { 0, };
+
+G_LOCK_DEFINE_STATIC (singleton_lock);
+static GESDiscovererManager *self = NULL;
+
+static void
+ges_discoverer_manager_get_property (GObject * object,
+ guint property_id, GValue * value, GParamSpec * pspec)
+{
+ GESDiscovererManager *self = GES_DISCOVERER_MANAGER (object);
+
+ switch (property_id) {
+ case PROP_TIMEOUT:
+ g_value_set_uint64 (value, ges_discoverer_manager_get_timeout (self));
+ break;
+ case PROP_USE_CACHE:
+ g_value_set_boolean (value, ges_discoverer_manager_get_use_cache (self));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+ges_discoverer_manager_set_property (GObject * object,
+ guint property_id, const GValue * value, GParamSpec * pspec)
+{
+ GESDiscovererManager *self = GES_DISCOVERER_MANAGER (object);
+
+ switch (property_id) {
+ case PROP_TIMEOUT:
+ ges_discoverer_manager_set_timeout (self, g_value_get_uint64 (value));
+ break;
+ case PROP_USE_CACHE:
+ ges_discoverer_manager_set_use_cache (self, g_value_get_boolean (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+ges_discoverer_manager_finalize (GObject * object)
+{
+ GESDiscovererManager *self = GES_DISCOVERER_MANAGER (object);
+
+ g_hash_table_unref (self->discoverers);
+
+ G_OBJECT_CLASS (ges_discoverer_manager_parent_class)->finalize (object);
+}
+
+static void
+ges_discoverer_manager_class_init (GESDiscovererManagerClass * klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = ges_discoverer_manager_finalize;
+ object_class->set_property = ges_discoverer_manager_set_property;
+ object_class->get_property = ges_discoverer_manager_get_property;
+
+ /**
+ * GESDiscovererManager:timeout:
+ *
+ * The timeout (in milliseconds) for the #GstDiscoverer operations
+ *
+ * Since: 1.24
+ */
+ properties[PROP_TIMEOUT] =
+ g_param_spec_uint64 ("timeout", "Timeout",
+ "The timeout for the discoverer", 0, GST_CLOCK_TIME_NONE, DEFAULT_TIMEOUT,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
+
+ /**
+ * GESDiscovererManager::use-cache:
+ *
+ * Whether to use a serialized version of the discoverer info from our own
+ * cache if accessible. This allows the discovery to be much faster as when
+ * using this option, we do not need to create a #GstPipeline and run it, but
+ * instead, just reload the #GstDiscovererInfo in its serialized form.
+ *
+ * The cache files are saved in `$XDG_CACHE_DIR/gstreamer-1.0/discoverer/`.
+ *
+ * For more granularity or to use your own cache, using the
+ * #GESDiscovererManager::load-serialized-info signal is recommended.
+ *
+ * Since: 1.24
+ */
+ properties[PROP_USE_CACHE] =
+ g_param_spec_boolean ("use-cache", "Use cache",
+ "Whether to use a serialized version of the discoverer info from our own cache if accessible",
+ DEFAULT_USE_CACHE,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
+
+ g_object_class_install_properties (object_class, N_PROPERTIES, properties);
+
+ /**
+ * GESDiscovererManager::load-serialized-info:
+ * @manager: the #GESDiscovererManager
+ * @uri: The URI to load the serialized info for
+ *
+ * Retrieves information about a URI from and external source of information,
+ * like a cache file. This is used by the discoverer to speed up the
+ * discovery.
+ *
+ * Returns: (nullable) (transfer full): The #GstDiscovererInfo representing
+ * @uri, or %NULL if no information
+ *
+ * Since: 1.24
+ */
+ signals[LOAD_SERIALIZED_INFO_SIGNAL] =
+ g_signal_new ("load-serialized-info", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ 0, NULL, NULL, NULL, GST_TYPE_DISCOVERER_INFO, 1, G_TYPE_STRING);
+
+ /**
+ * GESDiscovererManager::discovered: (attributes doc.skip=true)
+ * @manager: the #GESDiscovererManager
+ * @info: The #GstDiscovererInfo representing the discovered URI
+ * @error: The #GError that occurred, or %NULL
+ *
+ * Since: 1.24
+ */
+ signals[DISCOVERER_SIGNAL] =
+ g_signal_new ("discovered", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ 0, NULL, NULL, NULL, G_TYPE_NONE, 2, GST_TYPE_DISCOVERER_INFO,
+ G_TYPE_ERROR);
+}
+
+void
+ges_discoverer_manager_init (GESDiscovererManager * self)
+{
+ self->discoverers = g_hash_table_new_full (g_direct_hash, g_str_equal,
+ NULL, g_object_unref);
+}
+
+
+/**
+ * ges_discoverer_manager_get_default:
+ *
+ * Returns: (transfer full): The default #GESDiscovererManager
+ *
+ * Since: 1.24
+ */
+GESDiscovererManager *
+ges_discoverer_manager_get_default (void)
+{
+ G_LOCK (singleton_lock);
+ if (G_UNLIKELY (self == NULL)) {
+ self = g_object_new (GES_TYPE_DISCOVERER_MANAGER, NULL);
+ }
+ G_UNLOCK (singleton_lock);
+
+ return g_object_ref (self);
+}
+
+/**
+ * ges_discoverer_manager_get_use_cache:
+ * @self: The #GESDiscovererManager
+ *
+ * Returns: Whether to use the cache or not
+ *
+ * Since: 1.24
+ */
+gboolean
+ges_discoverer_manager_get_use_cache (GESDiscovererManager * self)
+{
+ g_return_val_if_fail (GES_IS_DISCOVERER_MANAGER (self), FALSE);
+
+ return self->use_cache;
+
+}
+
+/**
+ * ges_discoverer_manager_set_use_cache:
+ * @self: The #GESDiscovererManager
+ * @use_cache: Whether to use the cache
+ *
+ * Sets whether to use the cache or not
+ *
+ * Since: 1.24
+ */
+void
+ges_discoverer_manager_set_use_cache (GESDiscovererManager * self,
+ gboolean use_cache)
+{
+ g_return_if_fail (GES_IS_DISCOVERER_MANAGER (self));
+
+ self->use_cache = use_cache;
+
+}
+
+/**
+ * ges_discoverer_manager_get_timeout:
+ * @self: The #GESDiscovererManager
+ *
+ * Returns: The timeout to use for the discoverer
+ *
+ * Since: 1.24
+ */
+GstClockTime
+ges_discoverer_manager_get_timeout (GESDiscovererManager * self)
+{
+ g_return_val_if_fail (GES_IS_DISCOVERER_MANAGER (self), 0);
+
+ return self->timeout;
+}
+
+/**
+ * ges_discoverer_manager_set_timeout:
+ * @self: The #GESDiscovererManager
+ * @timeout: The timeout to set
+ *
+ * Sets the timeout to use for the discoverer
+ *
+ * Since: 1.24
+ */
+void
+ges_discoverer_manager_set_timeout (GESDiscovererManager * self,
+ GstClockTime timeout)
+{
+ GHashTableIter iter;
+ GstDiscoverer *discoverer;
+
+ g_return_if_fail (GES_IS_DISCOVERER_MANAGER (self));
+
+ self->timeout = timeout;
+
+ g_mutex_lock (&self->lock);
+ g_hash_table_iter_init (&iter, self->discoverers);
+ while (g_hash_table_iter_next (&iter, NULL, (gpointer *) & discoverer))
+ g_object_set (discoverer, "timeout", timeout, NULL);
+ g_mutex_unlock (&self->lock);
+}
+
+static GstDiscovererInfo *
+proxy_load_serialized_info_cb (GESDiscovererManager * self, const gchar * uri)
+{
+ GstDiscovererInfo *info;
+
+ g_signal_emit (self, signals[LOAD_SERIALIZED_INFO_SIGNAL], 0, uri, &info);
+
+ return info;
+}
+
+static void
+proxy_discovered_cb (GESDiscovererManager * self,
+ GstDiscovererInfo * info, GError * err, gpointer user_data)
+{
+ g_signal_emit (self, signals[DISCOVERER_SIGNAL], 0, info, err);
+}
+
+
+static GstDiscoverer *
+create_discoverer (GESDiscovererManager * self)
+{
+ GstDiscoverer *discoverer;
+
+ discoverer = gst_discoverer_new (self->timeout, NULL);
+ g_signal_connect_swapped (discoverer, "load-serialized-info",
+ G_CALLBACK (proxy_load_serialized_info_cb), self);
+ g_signal_connect_swapped (discoverer, "discovered",
+ G_CALLBACK (proxy_discovered_cb), self);
+ g_object_set (discoverer, "use-cache", self->use_cache, NULL);
+
+ gst_discoverer_start (discoverer);
+
+ return discoverer;
+}
+
+static GstDiscoverer *
+ges_discoverer_manager_get_discoverer (GESDiscovererManager * self)
+{
+ GstDiscoverer *ret;
+
+ g_return_val_if_fail (GES_IS_DISCOVERER_MANAGER (self), NULL);
+
+ g_mutex_lock (&self->lock);
+ ret = g_hash_table_lookup (self->discoverers, g_thread_self ());
+ if (!ret) {
+ ret = create_discoverer (self);
+ g_hash_table_insert (self->discoverers, g_thread_self (), ret);
+ }
+ g_mutex_unlock (&self->lock);
+
+ return gst_object_ref (ret);
+}
+
+gboolean
+ges_discoverer_manager_start_discovery (GESDiscovererManager * self,
+ const gchar * uri)
+{
+ GstDiscoverer *discoverer;
+
+ g_return_val_if_fail (uri != NULL, FALSE);
+
+ discoverer = ges_discoverer_manager_get_discoverer (self);
+
+ gboolean res = gst_discoverer_discover_uri_async (discoverer, uri);
+ gst_object_unref (discoverer);
+
+ return res;
+}
+
+void
+ges_discoverer_manager_cleanup (void)
+{
+ G_LOCK (singleton_lock);
+ gst_clear_object (&self);
+ G_UNLOCK (singleton_lock);
+}
diff --git a/subprojects/gst-editing-services/ges/ges-discoverer-manager.h b/subprojects/gst-editing-services/ges/ges-discoverer-manager.h
new file mode 100644
index 0000000000..51b3798c02
--- /dev/null
+++ b/subprojects/gst-editing-services/ges/ges-discoverer-manager.h
@@ -0,0 +1,32 @@
+#pragma once
+
+#include
+#include
+#include
+#include
+
+G_BEGIN_DECLS
+
+/**
+ * GES_TYPE_DISCOVERER_MANAGER:
+ *
+ * Since: 1.24
+ */
+#define GES_TYPE_DISCOVERER_MANAGER ges_discoverer_manager_get_type ()
+
+struct _GESDiscovererManagerClass
+{
+ GObjectClass parent_class;
+};
+
+GES_DECLARE_TYPE(DiscovererManager, discoverer_manager, DISCOVERER_MANAGER);
+
+GES_API GstClockTime ges_discoverer_manager_get_timeout (GESDiscovererManager * self);
+GES_API void ges_discoverer_manager_set_timeout (GESDiscovererManager * self,
+ GstClockTime timeout);
+GES_API GESDiscovererManager * ges_discoverer_manager_get_default (void);
+GES_API void ges_discoverer_manager_set_use_cache (GESDiscovererManager *self,
+ gboolean use_cache);
+GES_API gboolean ges_discoverer_manager_get_use_cache (GESDiscovererManager *self);
+
+G_END_DECLS
diff --git a/subprojects/gst-editing-services/ges/ges-internal.h b/subprojects/gst-editing-services/ges/ges-internal.h
index 445ca82ecf..6f4277ec5b 100644
--- a/subprojects/gst-editing-services/ges/ges-internal.h
+++ b/subprojects/gst-editing-services/ges/ges-internal.h
@@ -594,6 +594,14 @@ G_GNUC_INTERNAL GESMarker * ges_marker_list_get_closest (GESMarkerList *list, Gs
G_GNUC_INTERNAL gchar * ges_marker_list_serialize (const GValue * v);
G_GNUC_INTERNAL gboolean ges_marker_list_deserialize (GValue *dest, const gchar *s);
+/*******************************
+ * GESDiscovererManager *
+ *******************************/
+G_GNUC_INTERNAL void ges_discoverer_manager_cleanup (void);
+G_GNUC_INTERNAL gboolean ges_discoverer_manager_start_discovery (GESDiscovererManager *self,
+ const gchar *uri);
+G_GNUC_INTERNAL void ges_discoverer_manager_recreate_discoverer (GESDiscovererManager *self);
+
/********************
* Gnonlin helpers *
********************/
diff --git a/subprojects/gst-editing-services/ges/ges-types.h b/subprojects/gst-editing-services/ges/ges-types.h
index 7b26af6b12..744035f3e5 100644
--- a/subprojects/gst-editing-services/ges/ges-types.h
+++ b/subprojects/gst-editing-services/ges/ges-types.h
@@ -233,6 +233,9 @@ typedef struct _GESEffectAsset GESEffectAsset;
typedef struct _GESXmlFormatterClass GESXmlFormatterClass;
typedef struct _GESXmlFormatter GESXmlFormatter;
+typedef struct _GESDiscovererManager GESDiscovererManager;
+typedef struct _GESDiscovererManagerClass GESDiscovererManagerClass;
+
/**
* GES_DECLARE_TYPE: (attributes doc.skip=true)
*/
diff --git a/subprojects/gst-editing-services/ges/ges-uri-asset.c b/subprojects/gst-editing-services/ges/ges-uri-asset.c
index fcb901598b..fc57a77e15 100644
--- a/subprojects/gst-editing-services/ges/ges-uri-asset.c
+++ b/subprojects/gst-editing-services/ges/ges-uri-asset.c
@@ -28,6 +28,7 @@
* let you get information about the medias. Also, the tags found in the media file are
* set as Metadata of the Asset.
*/
+#include "ges-discoverer-manager.h"
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -42,44 +43,9 @@
static GHashTable *parent_newparent_table = NULL;
-G_LOCK_DEFINE_STATIC (discoverers_lock);
-static GstClockTime discovering_timeout = DEFAULT_DISCOVERY_TIMEOUT;
-static GHashTable *discoverers = NULL; /* Thread ID -> GstDiscoverer */
static void discoverer_discovered_cb (GstDiscoverer * discoverer,
GstDiscovererInfo * info, GError * err, gpointer user_data);
-/* WITH discoverers_lock */
-static GstDiscoverer *
-create_discoverer (void)
-{
- GstDiscoverer *disco = gst_discoverer_new (discovering_timeout, NULL);
-
- g_signal_connect (disco, "discovered", G_CALLBACK (discoverer_discovered_cb),
- NULL);
- GST_INFO_OBJECT (disco, "Creating new discoverer");
- g_hash_table_insert (discoverers, g_thread_self (), disco);
- gst_discoverer_start (disco);
-
- return disco;
-}
-
-static GstDiscoverer *
-get_discoverer (void)
-{
- GstDiscoverer *disco;
-
- G_LOCK (discoverers_lock);
- g_assert (discoverers);
- disco = g_hash_table_lookup (discoverers, g_thread_self ());
- if (!disco) {
- disco = create_discoverer ();
- }
- disco = gst_object_ref (disco);
- G_UNLOCK (discoverers_lock);
-
- return disco;
-}
-
static void
initable_iface_init (GInitableIface * initable_iface)
{
@@ -167,13 +133,13 @@ _start_loading (GESAsset * asset, GError ** error)
{
gboolean ret;
const gchar *uri;
- GstDiscoverer *discoverer = get_discoverer ();
+ GESDiscovererManager *manager = ges_discoverer_manager_get_default ();
uri = ges_asset_get_id (asset);
- GST_DEBUG_OBJECT (discoverer, "Started loading %s", uri);
+ GST_DEBUG_OBJECT (manager, "Started loading %s", uri);
- ret = gst_discoverer_discover_uri_async (discoverer, uri);
- gst_object_unref (discoverer);
+ ret = ges_discoverer_manager_start_discovery (manager, uri);
+ gst_object_unref (manager);
if (ret)
return GES_ASSET_LOADING_ASYNC;
@@ -314,7 +280,6 @@ ges_uri_clip_asset_class_init (GESUriClipAssetClass * klass)
klass->discovered = discoverer_discovered_cb;
-
/**
* GESUriClipAsset:duration:
*
@@ -491,7 +456,7 @@ _set_meta_foreach (const GstTagList * tags, const gchar * tag,
}
static void
-discoverer_discovered_cb (GstDiscoverer * discoverer,
+discoverer_discovered_cb (GstDiscoverer * _object,
GstDiscovererInfo * info, GError * err, gpointer user_data)
{
GError *error = NULL;
@@ -697,7 +662,7 @@ ges_uri_clip_asset_finish (GAsyncResult * res, GError ** error)
* You can also use multi file uris for #GESMultiFileSource.
* @error: An error to be set in case something wrong happens or %NULL
*
- * Creates a #GESUriClipAsset for @uri syncronously. You should avoid
+ * Creates a #GESUriClipAsset for @uri synchonously. You should avoid
* to use it in application, and rather create #GESUriClipAsset asynchronously
*
* Returns: (transfer full): A reference to the requested asset or %NULL if
@@ -709,7 +674,6 @@ ges_uri_clip_asset_request_sync (const gchar * uri, GError ** error)
GError *lerror = NULL;
GESUriClipAsset *asset;
RequestSyncData data = { 0, };
- GstDiscoverer *previous_discoverer;
asset = GES_URI_CLIP_ASSET (ges_asset_request (GES_TYPE_URI_CLIP, uri,
&lerror));
@@ -718,18 +682,12 @@ ges_uri_clip_asset_request_sync (const gchar * uri, GError ** error)
return asset;
data.ml = g_main_loop_new (NULL, TRUE);
- previous_discoverer = get_discoverer ();
- create_discoverer ();
ges_asset_request_async (GES_TYPE_URI_CLIP, uri, NULL,
(GAsyncReadyCallback) asset_ready_cb, &data);
g_main_loop_run (data.ml);
g_main_loop_unref (data.ml);
- G_LOCK (discoverers_lock);
- g_hash_table_insert (discoverers, g_thread_self (), previous_discoverer);
- G_UNLOCK (discoverers_lock);
-
if (data.error) {
GST_ERROR ("Got an error requesting asset: %s", data.error->message);
if (error != NULL)
@@ -747,23 +705,17 @@ ges_uri_clip_asset_request_sync (const gchar * uri, GError ** error)
* @timeout: The timeout to set
*
* Sets the timeout of #GESUriClipAsset loading
+ *
+ * Deprecated: 1.24: ges_discoverer_manager_set_timeout() should be used instead
*/
void
ges_uri_clip_asset_class_set_timeout (GESUriClipAssetClass * klass,
GstClockTime timeout)
{
- GHashTableIter iter;
- gpointer value;
-
g_return_if_fail (GES_IS_URI_CLIP_ASSET_CLASS (klass));
- discovering_timeout = timeout;
-
- G_LOCK (discoverers_lock);
- g_hash_table_iter_init (&iter, discoverers);
- while (g_hash_table_iter_next (&iter, NULL, &value))
- g_object_set (value, "timeout", timeout, NULL);
- G_UNLOCK (discoverers_lock);
+ ges_discoverer_manager_set_timeout (ges_discoverer_manager_get_default (),
+ timeout);
}
/**
@@ -931,14 +883,9 @@ _ges_uri_asset_cleanup (void)
parent_newparent_table = NULL;
}
- G_LOCK (discoverers_lock);
- if (discoverers) {
- g_hash_table_destroy (discoverers);
- discoverers = NULL;
- }
gst_clear_object (&GES_URI_CLIP_ASSET_CLASS (g_type_class_peek
(GES_TYPE_URI_CLIP_ASSET))->discoverer);
- G_UNLOCK (discoverers_lock);
+ ges_discoverer_manager_cleanup ();
}
gboolean
@@ -965,18 +912,23 @@ _ges_uri_asset_ensure_setup (gpointer uriasset_class)
if (errno)
timeout = DEFAULT_DISCOVERY_TIMEOUT;
+ /* The class structure keeps weak pointers on the discoverers so they
+ * can be properly cleaned up in _ges_uri_asset_cleanup(). */
if (!klass->discoverer) {
+ GESDiscovererManager *manager = ges_discoverer_manager_get_default ();
+
+ ges_discoverer_manager_set_timeout (manager, timeout);
+ g_signal_connect (manager, "discovered",
+ G_CALLBACK (discoverer_discovered_cb), NULL);
+
discoverer = gst_discoverer_new (timeout, &err);
if (!discoverer) {
GST_ERROR ("Could not create discoverer: %s", err->message);
g_error_free (err);
return FALSE;
}
- }
- /* The class structure keeps weak pointers on the discoverers so they
- * can be properly cleaned up in _ges_uri_asset_cleanup(). */
- if (!klass->discoverer) {
+ /* Keep legacy handling of discoverer, even if not used */
klass->discoverer = klass->sync_discoverer = discoverer;
g_object_add_weak_pointer (G_OBJECT (discoverer),
(gpointer *) & klass->discoverer);
@@ -988,13 +940,6 @@ _ges_uri_asset_ensure_setup (gpointer uriasset_class)
gst_discoverer_start (klass->discoverer);
}
- G_LOCK (discoverers_lock);
- if (discoverers == NULL) {
- discoverers = g_hash_table_new_full (g_direct_hash,
- (GEqualFunc) g_direct_equal, NULL, g_object_unref);
- }
- G_UNLOCK (discoverers_lock);
-
/* We just start the discoverer and let it live */
if (parent_newparent_table == NULL) {
parent_newparent_table = g_hash_table_new_full (g_file_hash,
diff --git a/subprojects/gst-editing-services/ges/ges-uri-asset.h b/subprojects/gst-editing-services/ges/ges-uri-asset.h
index 53fa5446dd..4ec259037d 100644
--- a/subprojects/gst-editing-services/ges/ges-uri-asset.h
+++ b/subprojects/gst-editing-services/ges/ges-uri-asset.h
@@ -118,5 +118,4 @@ GES_API
const GESUriClipAsset *ges_uri_source_asset_get_filesource_asset (GESUriSourceAsset *asset);
GES_API
gboolean ges_uri_source_asset_is_image (GESUriSourceAsset *asset);
-
-G_END_DECLS
\ No newline at end of file
+G_END_DECLS
diff --git a/subprojects/gst-editing-services/ges/ges-uri-clip.c b/subprojects/gst-editing-services/ges/ges-uri-clip.c
index 64082cdbe0..a4e8cca953 100644
--- a/subprojects/gst-editing-services/ges/ges-uri-clip.c
+++ b/subprojects/gst-editing-services/ges/ges-uri-clip.c
@@ -445,7 +445,6 @@ ges_extractable_interface_init (GESExtractableInterface * iface)
iface->check_id = (GESExtractableCheckId) extractable_check_id;
iface->get_parameters_from_id = extractable_get_parameters_from_id;
iface->get_id = extractable_get_id;
- iface->get_id = extractable_get_id;
iface->can_update_asset = TRUE;
iface->set_asset_full = extractable_set_asset;
}
diff --git a/subprojects/gst-editing-services/ges/meson.build b/subprojects/gst-editing-services/ges/meson.build
index 03f1a126d0..014ce76234 100644
--- a/subprojects/gst-editing-services/ges/meson.build
+++ b/subprojects/gst-editing-services/ges/meson.build
@@ -65,6 +65,7 @@ ges_sources = files([
'ges-structured-interface.c',
'ges-structure-parser.c',
'ges-marker-list.c',
+ 'ges-discoverer-manager.c',
'gstframepositioner.c'
])
@@ -129,7 +130,8 @@ ges_headers = files([
'ges-effect-asset.h',
'ges-utils.h',
'ges-group.h',
- 'ges-marker-list.h'
+ 'ges-marker-list.h',
+ 'ges-discoverer-manager.h',
])
if libxml_dep.found()