1 /* GStreamer Editing Services
3 * Copyright (C) 2012 Thibault Saunier <thibault.saunier@collabora.com>
4 * Copyright (C) 2012 Volodymyr Rudyi <vladimir.rudoy@gmail.com>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
22 * SECTION: gesuriclipasset
23 * @title: GESUriClipAsset
24 * @short_description: A GESAsset subclass specialized in GESUriClip extraction
26 * The #GESUriClipAsset is a special #GESAsset that lets you handle
27 * the media file to use inside the GStreamer Editing Services. It has APIs that
28 * let you get information about the medias. Also, the tags found in the media file are
29 * set as Metadata of the Asset.
36 #include <gst/pbutils/pbutils.h>
38 #include "ges-internal.h"
39 #include "ges-track-element-asset.h"
41 #define DEFAULT_DISCOVERY_TIMEOUT (60 * GST_SECOND)
43 static GHashTable *parent_newparent_table = NULL;
45 static GstDiscoverer *discoverer = NULL;
48 initable_iface_init (GInitableIface * initable_iface)
50 /* We can not iniate synchronously */
51 initable_iface->init = NULL;
54 /* TODO: We should monitor files here, and add some way of reporting changes
63 static GParamSpec *properties[PROP_LAST];
65 static void discoverer_discovered_cb (GstDiscoverer * discoverer,
66 GstDiscovererInfo * info, GError * err, gpointer user_data);
68 struct _GESUriClipAssetPrivate
70 GstDiscovererInfo *info;
71 GstClockTime duration;
74 GList *asset_trackfilesources;
84 struct _GESUriSourceAssetPrivate
86 GstDiscovererStreamInfo *sinfo;
87 GESUriClipAsset *parent_asset;
92 G_DEFINE_TYPE_WITH_CODE (GESUriClipAsset, ges_uri_clip_asset,
93 GES_TYPE_CLIP_ASSET, G_ADD_PRIVATE (GESUriClipAsset)
94 G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE, initable_iface_init));
97 ges_uri_clip_asset_get_property (GObject * object, guint property_id,
98 GValue * value, GParamSpec * pspec)
100 GESUriClipAssetPrivate *priv = GES_URI_CLIP_ASSET (object)->priv;
102 switch (property_id) {
104 g_value_set_uint64 (value, priv->duration);
107 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
112 ges_uri_clip_asset_set_property (GObject * object, guint property_id,
113 const GValue * value, GParamSpec * pspec)
115 GESUriClipAssetPrivate *priv = GES_URI_CLIP_ASSET (object)->priv;
117 switch (property_id) {
119 priv->duration = g_value_get_uint64 (value);
122 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
126 static GESAssetLoadingReturn
127 _start_loading (GESAsset * asset, GError ** error)
131 GESUriClipAssetClass *class = GES_URI_CLIP_ASSET_GET_CLASS (asset);
133 GST_DEBUG ("Started loading %p", asset);
135 uri = ges_asset_get_id (asset);
137 ret = gst_discoverer_discover_uri_async (class->discoverer, uri);
139 return GES_ASSET_LOADING_ASYNC;
141 return GES_ASSET_LOADING_ERROR;
145 _request_id_update (GESAsset * self, gchar ** proposed_new_id, GError * error)
147 if (error->domain == GST_RESOURCE_ERROR &&
148 (error->code == GST_RESOURCE_ERROR_NOT_FOUND ||
149 error->code == GST_RESOURCE_ERROR_OPEN_READ)) {
150 const gchar *uri = ges_asset_get_id (self);
151 GFile *parent, *file = g_file_new_for_uri (uri);
153 /* Check if we have the new parent in cache */
154 parent = g_file_get_parent (file);
156 GFile *new_parent = g_hash_table_lookup (parent_newparent_table, parent);
159 gchar *basename = g_file_get_basename (file);
160 GFile *new_file = g_file_get_child (new_parent, basename);
162 /* FIXME Handle the GCancellable */
163 if (g_file_query_exists (new_file, NULL)) {
164 *proposed_new_id = g_file_get_uri (new_file);
165 GST_DEBUG_OBJECT (self, "Proposing path: %s as proxy",
169 gst_object_unref (new_file);
172 gst_object_unref (parent);
175 gst_object_unref (file);
184 _asset_proxied (GESAsset * self, const gchar * new_uri)
186 const gchar *uri = ges_asset_get_id (self);
187 GFile *parent, *new_parent, *new_file = g_file_new_for_uri (new_uri),
188 *file = g_file_new_for_uri (uri);
190 parent = g_file_get_parent (file);
191 new_parent = g_file_get_parent (new_file);
192 g_hash_table_insert (parent_newparent_table, parent, new_parent);
193 gst_object_unref (file);
194 gst_object_unref (new_file);
198 ges_uri_clip_asset_dispose (GObject * object)
200 GESUriClipAsset *self = GES_URI_CLIP_ASSET (object);
201 GESUriClipAssetPrivate *prif = self->priv;
203 if (prif->asset_trackfilesources) {
204 g_list_free_full (prif->asset_trackfilesources,
205 (GDestroyNotify) gst_object_unref);
206 prif->asset_trackfilesources = NULL;
209 gst_clear_object (&prif->info);
211 G_OBJECT_CLASS (ges_uri_clip_asset_parent_class)->dispose (object);
215 ges_uri_clip_asset_class_init (GESUriClipAssetClass * klass)
217 GObjectClass *object_class = G_OBJECT_CLASS (klass);
219 object_class->get_property = ges_uri_clip_asset_get_property;
220 object_class->set_property = ges_uri_clip_asset_set_property;
221 object_class->dispose = ges_uri_clip_asset_dispose;
223 GES_ASSET_CLASS (klass)->start_loading = _start_loading;
224 GES_ASSET_CLASS (klass)->request_id_update = _request_id_update;
225 GES_ASSET_CLASS (klass)->inform_proxy = _asset_proxied;
227 klass->discovered = discoverer_discovered_cb;
231 * GESUriClipAsset:duration:
233 * The duration (in nanoseconds) of the media file
235 properties[PROP_DURATION] =
236 g_param_spec_uint64 ("duration", "Duration", "The duration to use", 0,
237 G_MAXUINT64, GST_CLOCK_TIME_NONE, G_PARAM_READWRITE);
238 g_object_class_install_property (object_class, PROP_DURATION,
239 properties[PROP_DURATION]);
241 _ges_uri_asset_ensure_setup (klass);
245 ges_uri_clip_asset_init (GESUriClipAsset * self)
247 GESUriClipAssetPrivate *priv;
249 priv = self->priv = ges_uri_clip_asset_get_instance_private (self);
252 priv->duration = GST_CLOCK_TIME_NONE;
253 priv->is_image = FALSE;
257 _create_uri_source_asset (GESUriClipAsset * asset,
258 GstDiscovererStreamInfo * sinfo, GESTrackType type)
260 GESAsset *tck_filesource_asset;
261 GESUriSourceAssetPrivate *priv_tckasset;
262 GESUriClipAssetPrivate *priv = asset->priv;
264 g_strdup (gst_discoverer_stream_info_get_stream_id (sinfo));
266 if (stream_id == NULL) {
267 GST_WARNING ("No stream ID found, using the pointer instead");
269 stream_id = g_strdup_printf ("%i", GPOINTER_TO_INT (sinfo));
272 if (type == GES_TRACK_TYPE_VIDEO)
273 tck_filesource_asset = ges_asset_request (GES_TYPE_VIDEO_URI_SOURCE,
276 tck_filesource_asset = ges_asset_request (GES_TYPE_AUDIO_URI_SOURCE,
280 priv_tckasset = GES_URI_SOURCE_ASSET (tck_filesource_asset)->priv;
281 priv_tckasset->uri = ges_asset_get_id (GES_ASSET (asset));
282 priv_tckasset->sinfo = gst_object_ref (sinfo);
283 priv_tckasset->parent_asset = asset;
284 ges_track_element_asset_set_track_type (GES_TRACK_ELEMENT_ASSET
285 (tck_filesource_asset), type);
287 priv->asset_trackfilesources = g_list_append (priv->asset_trackfilesources,
288 tck_filesource_asset);
292 ges_uri_clip_asset_set_info (GESUriClipAsset * self, GstDiscovererInfo * info)
294 GList *tmp, *stream_list;
296 GESTrackType supportedformats = GES_TRACK_TYPE_UNKNOWN;
297 GESUriClipAssetPrivate *priv = GES_URI_CLIP_ASSET (self)->priv;
299 /* Extract infos from the GstDiscovererInfo */
300 stream_list = gst_discoverer_info_get_stream_list (info);
301 for (tmp = stream_list; tmp; tmp = tmp->next) {
302 GESTrackType type = GES_TRACK_TYPE_UNKNOWN;
303 GstDiscovererStreamInfo *sinf = (GstDiscovererStreamInfo *) tmp->data;
305 if (GST_IS_DISCOVERER_AUDIO_INFO (sinf)) {
306 if (supportedformats == GES_TRACK_TYPE_UNKNOWN)
307 supportedformats = GES_TRACK_TYPE_AUDIO;
309 supportedformats |= GES_TRACK_TYPE_AUDIO;
311 type = GES_TRACK_TYPE_AUDIO;
312 } else if (GST_IS_DISCOVERER_VIDEO_INFO (sinf)) {
313 if (supportedformats == GES_TRACK_TYPE_UNKNOWN)
314 supportedformats = GES_TRACK_TYPE_VIDEO;
316 supportedformats |= GES_TRACK_TYPE_VIDEO;
317 if (gst_discoverer_video_info_is_image ((GstDiscovererVideoInfo *)
319 priv->is_image = TRUE;
320 type = GES_TRACK_TYPE_VIDEO;
323 GST_DEBUG_OBJECT (self, "Creating GESUriSourceAsset for stream: %s",
324 gst_discoverer_stream_info_get_stream_id (sinf));
325 _create_uri_source_asset (self, sinf, type);
327 ges_clip_asset_set_supported_formats (GES_CLIP_ASSET
328 (self), supportedformats);
331 gst_discoverer_stream_info_list_free (stream_list);
333 if (priv->is_image == FALSE)
334 priv->duration = gst_discoverer_info_get_duration (info);
335 /* else we keep #GST_CLOCK_TIME_NONE */
337 priv->info = gst_object_ref (info);
341 _set_meta_file_size (const gchar * uri, GESUriClipAsset * asset)
343 GError *error = NULL;
344 GFileInfo *file_info = NULL;
348 GESMetaContainer *container = GES_META_CONTAINER (asset);
350 gfile = g_file_new_for_uri (uri);
351 file_info = g_file_query_info (gfile, "standard::size",
352 G_FILE_QUERY_INFO_NONE, NULL, &error);
354 file_size = g_file_info_get_attribute_uint64 (file_info, "standard::size");
355 ges_meta_container_register_meta_uint64 (container, GES_META_READ_WRITE,
356 "file-size", file_size);
358 g_error_free (error);
361 g_object_unref (gfile);
363 g_object_unref (file_info);
367 _set_meta_foreach (const GstTagList * tags, const gchar * tag,
368 GESMetaContainer * container)
370 GValue value = { 0 };
372 if (gst_tag_list_copy_value (&value, tags, tag)) {
373 ges_meta_container_set_meta (container, tag, &value);
374 g_value_unset (&value);
376 GST_INFO ("Could not set metadata: %s", tag);
381 discoverer_discovered_cb (GstDiscoverer * discoverer,
382 GstDiscovererInfo * info, GError * err, gpointer user_data)
384 GError *error = NULL;
385 const GstTagList *tags;
387 const gchar *uri = gst_discoverer_info_get_uri (info);
388 GESUriClipAsset *mfs =
389 GES_URI_CLIP_ASSET (ges_asset_cache_lookup (GES_TYPE_URI_CLIP, uri));
391 tags = gst_discoverer_info_get_tags (info);
393 gst_tag_list_foreach (tags, (GstTagForeachFunc) _set_meta_foreach, mfs);
395 _set_meta_file_size (uri, mfs);
397 if (gst_discoverer_info_get_result (info) == GST_DISCOVERER_OK) {
398 ges_uri_clip_asset_set_info (mfs, info);
401 error = g_error_copy (err);
403 error = g_error_new (GST_RESOURCE_ERROR, GST_RESOURCE_ERROR_FAILED,
404 "Stream %s discovering failed (error code: %d)",
405 uri, gst_discoverer_info_get_result (info));
409 ges_asset_cache_set_loaded (GES_TYPE_URI_CLIP, uri, error);
412 g_error_free (error);
416 asset_ready_cb (GESAsset * source, GAsyncResult * res, RequestSyncData * data)
418 data->asset = ges_asset_request_finish (res, &data->error);
421 gchar *possible_uri = ges_uri_asset_try_update_id (data->error, source);
424 g_clear_error (&data->error);
425 ges_asset_request_async (GES_TYPE_URI_CLIP, possible_uri, NULL,
426 (GAsyncReadyCallback) asset_ready_cb, data);
427 g_free (possible_uri);
432 g_main_loop_quit (data->ml);
435 /* API implementation */
437 * ges_uri_clip_asset_get_info:
438 * @self: Target asset
440 * Gets #GstDiscovererInfo about the file
442 * Returns: (transfer none): #GstDiscovererInfo of specified asset
445 ges_uri_clip_asset_get_info (const GESUriClipAsset * self)
447 g_return_val_if_fail (GES_IS_URI_CLIP_ASSET (self), NULL);
449 return self->priv->info;
453 * ges_uri_clip_asset_get_duration:
454 * @self: a #GESUriClipAsset
456 * Gets duration of the file represented by @self
458 * Returns: The duration of @self
461 ges_uri_clip_asset_get_duration (GESUriClipAsset * self)
463 g_return_val_if_fail (GES_IS_URI_CLIP_ASSET (self), GST_CLOCK_TIME_NONE);
465 return self->priv->duration;
469 * ges_uri_clip_asset_is_image:
470 * @self: a #indent: Standard input:311: Error:Unexpected end of file
473 * Gets Whether the file represented by @self is an image or not
475 * Returns: Whether the file represented by @self is an image or not
478 ges_uri_clip_asset_is_image (GESUriClipAsset * self)
480 g_return_val_if_fail (GES_IS_URI_CLIP_ASSET (self), FALSE);
482 return self->priv->is_image;
486 * ges_uri_clip_asset_new:
487 * @uri: The URI of the file for which to create a #GESUriClipAsset
488 * @cancellable: optional %GCancellable object, %NULL to ignore.
489 * @callback: (scope async): a #GAsyncReadyCallback to call when the initialization is finished
490 * @user_data: The user data to pass when @callback is called
492 * Creates a #GESUriClipAsset for @uri
494 * Example of request of a GESUriClipAsset:
496 * // The request callback
498 * filesource_asset_loaded_cb (GESAsset * source, GAsyncResult * res, gpointer user_data)
500 * GError *error = NULL;
501 * GESUriClipAsset *filesource_asset;
503 * filesource_asset = ges_uri_clip_asset_finish (res, &error);
504 * if (filesource_asset) {
505 * g_print ("The file: %s is usable as a FileSource, it is%s an image and lasts %" GST_TIME_FORMAT,
506 * ges_asset_get_id (GES_ASSET (filesource_asset))
507 * ges_uri_clip_asset_is_image (filesource_asset) ? "" : " not",
508 * GST_TIME_ARGS (ges_uri_clip_asset_get_duration (filesource_asset));
510 * g_print ("The file: %s is *not* usable as a FileSource because: %s",
511 * ges_asset_get_id (source), error->message);
514 * gst_object_unref (mfs);
518 * ges_uri_clip_asset_new (uri, (GAsyncReadyCallback) filesource_asset_loaded_cb, user_data);
522 ges_uri_clip_asset_new (const gchar * uri, GCancellable * cancellable,
523 GAsyncReadyCallback callback, gpointer user_data)
525 ges_asset_request_async (GES_TYPE_URI_CLIP, uri, cancellable,
526 callback, user_data);
530 * ges_uri_clip_asset_finish:
531 * @res: The #GAsyncResult from which to get the newly created #GESUriClipAsset
532 * @error: An error to be set in case something wrong happens or %NULL
534 * Finalize the request of an async #GESUriClipAsset
536 * Returns: (transfer full): The #GESUriClipAsset previously requested
541 ges_uri_clip_asset_finish (GAsyncResult * res, GError ** error)
545 g_return_val_if_fail (G_IS_ASYNC_RESULT (res), NULL);
547 asset = ges_asset_request_finish (res, error);
549 return GES_URI_CLIP_ASSET (asset);
556 * ges_uri_clip_asset_request_sync:
557 * @uri: The URI of the file for which to create a #GESUriClipAsset.
558 * You can also use multi file uris for #GESMultiFileSource.
559 * @error: An error to be set in case something wrong happens or %NULL
561 * Creates a #GESUriClipAsset for @uri syncronously. You should avoid
562 * to use it in application, and rather create #GESUriClipAsset asynchronously
564 * Returns: (transfer full): A reference to the requested asset or %NULL if
568 ges_uri_clip_asset_request_sync (const gchar * uri, GError ** error)
570 GError *lerror = NULL;
571 GESUriClipAsset *asset;
572 RequestSyncData data = { 0, };
573 GESUriClipAssetClass *klass = g_type_class_peek (GES_TYPE_URI_CLIP_ASSET);
574 GstClockTime timeout;
575 GstDiscoverer *previous_discoverer = klass->discoverer;
577 asset = GES_URI_CLIP_ASSET (ges_asset_request (GES_TYPE_URI_CLIP, uri,
583 data.ml = g_main_loop_new (NULL, TRUE);
584 g_object_get (previous_discoverer, "timeout", &timeout, NULL);
585 klass->discoverer = gst_discoverer_new (timeout, error);
586 if (!klass->discoverer) {
587 klass->discoverer = previous_discoverer;
592 g_signal_connect (klass->discoverer, "discovered",
593 G_CALLBACK (klass->discovered), NULL);
594 gst_discoverer_start (klass->discoverer);
595 ges_asset_request_async (GES_TYPE_URI_CLIP, uri, NULL,
596 (GAsyncReadyCallback) asset_ready_cb, &data);
597 g_main_loop_run (data.ml);
598 g_main_loop_unref (data.ml);
600 gst_object_unref (klass->discoverer);
601 klass->discoverer = previous_discoverer;
604 GST_ERROR ("Got an error requesting asset: %s", data.error->message);
606 g_propagate_error (error, data.error);
611 return GES_URI_CLIP_ASSET (data.asset);
615 * ges_uri_clip_asset_class_set_timeout:
616 * @klass: The #GESUriClipAssetClass on which to set the discoverer timeout
617 * @timeout: The timeout to set
619 * Sets the timeout of #GESUriClipAsset loading
622 ges_uri_clip_asset_class_set_timeout (GESUriClipAssetClass * klass,
623 GstClockTime timeout)
625 g_return_if_fail (GES_IS_URI_CLIP_ASSET_CLASS (klass));
627 g_object_set (klass->discoverer, "timeout", timeout, NULL);
631 * ges_uri_clip_asset_get_stream_assets:
632 * @self: A #GESUriClipAsset
634 * Get the GESUriSourceAsset @self containes
636 * Returns: (transfer none) (element-type GESUriSourceAsset): a
637 * #GList of #GESUriSourceAsset
640 ges_uri_clip_asset_get_stream_assets (GESUriClipAsset * self)
642 g_return_val_if_fail (GES_IS_URI_CLIP_ASSET (self), FALSE);
644 return self->priv->asset_trackfilesources;
647 /*****************************************************************
648 * GESUriSourceAsset implementation *
649 *****************************************************************/
651 * SECTION: gesurisourceasset
652 * @title: GESUriClipAsset
653 * @short_description: A GESAsset subclass specialized in GESUriSource extraction
655 * NOTE: You should never request such a #GESAsset as they will be created automatically
656 * by #GESUriClipAsset-s.
659 G_DEFINE_TYPE_WITH_PRIVATE (GESUriSourceAsset, ges_uri_source_asset,
660 GES_TYPE_TRACK_ELEMENT_ASSET);
662 static GESExtractable *
663 _extract (GESAsset * asset, GError ** error)
666 GESTrackElement *trackelement;
667 GESUriSourceAssetPrivate *priv = GES_URI_SOURCE_ASSET (asset)->priv;
669 if (GST_IS_DISCOVERER_STREAM_INFO (priv->sinfo) == FALSE) {
670 GST_WARNING_OBJECT (asset, "Can not extract as no strean info set");
675 if (priv->uri == NULL) {
676 GST_WARNING_OBJECT (asset, "Can not extract as no uri set");
681 uri = g_strdup (priv->uri);
683 if (g_str_has_prefix (priv->uri, GES_MULTI_FILE_URI_PREFIX)) {
684 trackelement = GES_TRACK_ELEMENT (ges_multi_file_source_new (uri));
685 } else if (GST_IS_DISCOVERER_VIDEO_INFO (priv->sinfo)
686 && gst_discoverer_video_info_is_image ((GstDiscovererVideoInfo *)
688 trackelement = GES_TRACK_ELEMENT (ges_image_source_new (uri));
689 else if (GST_IS_DISCOVERER_VIDEO_INFO (priv->sinfo))
690 trackelement = GES_TRACK_ELEMENT (ges_video_uri_source_new (uri));
692 trackelement = GES_TRACK_ELEMENT (ges_audio_uri_source_new (uri));
694 ges_track_element_set_track_type (trackelement,
695 ges_track_element_asset_get_track_type (GES_TRACK_ELEMENT_ASSET (asset)));
699 return GES_EXTRACTABLE (trackelement);
703 ges_uri_source_asset_dispose (GObject * object)
705 GESUriSourceAsset *self = GES_URI_SOURCE_ASSET (object);
706 GESUriSourceAssetPrivate *priv = self->priv;
708 gst_clear_object (&priv->sinfo);
710 G_OBJECT_CLASS (ges_uri_source_asset_parent_class)->dispose (object);
714 ges_uri_source_asset_class_init (GESUriSourceAssetClass * klass)
716 GObjectClass *object_class = G_OBJECT_CLASS (klass);
718 object_class->dispose = ges_uri_source_asset_dispose;
720 GES_ASSET_CLASS (klass)->extract = _extract;
724 ges_uri_source_asset_init (GESUriSourceAsset * self)
726 GESUriSourceAssetPrivate *priv;
728 priv = self->priv = ges_uri_source_asset_get_instance_private (self);
731 priv->parent_asset = NULL;
736 * ges_uri_source_asset_get_stream_info:
737 * @asset: A #GESUriClipAsset
739 * Get the #GstDiscovererStreamInfo user by @asset
741 * Returns: (transfer none): a #GESUriClipAsset
743 GstDiscovererStreamInfo *
744 ges_uri_source_asset_get_stream_info (GESUriSourceAsset * asset)
746 g_return_val_if_fail (GES_IS_URI_SOURCE_ASSET (asset), NULL);
748 return asset->priv->sinfo;
752 ges_uri_source_asset_get_stream_uri (GESUriSourceAsset * asset)
754 g_return_val_if_fail (GES_IS_URI_SOURCE_ASSET (asset), NULL);
756 return asset->priv->uri;
760 * ges_uri_source_asset_get_filesource_asset:
761 * @asset: A #GESUriClipAsset
763 * Get the #GESUriClipAsset @self is contained in
765 * Returns: a #GESUriClipAsset
767 const GESUriClipAsset *
768 ges_uri_source_asset_get_filesource_asset (GESUriSourceAsset * asset)
770 g_return_val_if_fail (GES_IS_URI_SOURCE_ASSET (asset), NULL);
772 return asset->priv->parent_asset;
776 _ges_uri_asset_cleanup (void)
779 gst_discoverer_stop (discoverer);
780 g_clear_object (&discoverer);
781 if (parent_newparent_table) {
782 g_hash_table_destroy (parent_newparent_table);
783 parent_newparent_table = NULL;
788 _ges_uri_asset_ensure_setup (gpointer uriasset_class)
790 GESUriClipAssetClass *klass;
792 GstClockTime timeout;
793 const gchar *timeout_str;
795 g_return_val_if_fail (GES_IS_URI_CLIP_ASSET_CLASS (uriasset_class), FALSE);
797 klass = GES_URI_CLIP_ASSET_CLASS (uriasset_class);
799 timeout = DEFAULT_DISCOVERY_TIMEOUT;
801 timeout_str = g_getenv ("GES_DISCOVERY_TIMEOUT");
803 timeout = g_ascii_strtod (timeout_str, NULL) * GST_SECOND;
808 timeout = DEFAULT_DISCOVERY_TIMEOUT;
811 discoverer = gst_discoverer_new (timeout, &err);
813 GST_ERROR ("Could not create discoverer: %s", err->message);
819 /* The class structure keeps weak pointers on the discoverers so they
820 * can be properly cleaned up in _ges_uri_asset_cleanup(). */
821 if (!klass->discoverer) {
822 klass->discoverer = klass->sync_discoverer = discoverer;
823 g_object_add_weak_pointer (G_OBJECT (discoverer),
824 (gpointer *) & klass->discoverer);
825 g_object_add_weak_pointer (G_OBJECT (discoverer),
826 (gpointer *) & klass->sync_discoverer);
828 g_signal_connect (klass->discoverer, "discovered",
829 G_CALLBACK (klass->discovered), NULL);
832 /* We just start the discoverer and let it live */
833 gst_discoverer_start (klass->discoverer);
834 if (parent_newparent_table == NULL) {
835 parent_newparent_table = g_hash_table_new_full (g_file_hash,
836 (GEqualFunc) g_file_equal, g_object_unref, g_object_unref);