diff --git a/doc/reference/clapper/extractable-enhancers.md b/doc/reference/clapper/extractable-enhancers.md index 5344a3149..f1f8f2642 100644 --- a/doc/reference/clapper/extractable-enhancers.md +++ b/doc/reference/clapper/extractable-enhancers.md @@ -16,8 +16,10 @@ For the basics about writing enhancers see [Clapper Enhancers](clapper-enhancers ### Requirements -Additional fields for `.plugin` info file: `X-Schemes` and `X-Hosts`. The former one should -hold the `;` separated list of supported URI schemes, while the latter is for hostnames. +Additional fields for `.plugin` info file: `X-Schemes`, `X-Hosts`, `X-Use-Cache`. +The former one is required and should hold the `;` separated list of supported URI schemes, +while the second is for hostnames and the last one is also optional (set to `false` in order +skip trying to restore harvested data from cache if enhancer never caches any data). Example: diff --git a/src/bin/clapper-app/ui/clapper-app-headerbar.ui b/src/bin/clapper-app/ui/clapper-app-headerbar.ui index 5c15f04e2..c4186d3f5 100644 --- a/src/bin/clapper-app/ui/clapper-app-headerbar.ui +++ b/src/bin/clapper-app/ui/clapper-app-headerbar.ui @@ -86,6 +86,7 @@ true diff --git a/src/bin/clapper-app/ui/clapper-app-queue-list-item.ui b/src/bin/clapper-app/ui/clapper-app-queue-list-item.ui index cc1d8c7e5..298516e69 100644 --- a/src/bin/clapper-app/ui/clapper-app-queue-list-item.ui +++ b/src/bin/clapper-app/ui/clapper-app-queue-list-item.ui @@ -30,6 +30,7 @@ diff --git a/src/lib/clapper-gtk/ui/clapper-gtk-title-header.ui b/src/lib/clapper-gtk/ui/clapper-gtk-title-header.ui index fae5d27b4..402759ec4 100644 --- a/src/lib/clapper-gtk/ui/clapper-gtk-title-header.ui +++ b/src/lib/clapper-gtk/ui/clapper-gtk-title-header.ui @@ -15,6 +15,7 @@ center diff --git a/src/lib/clapper/gst/clapper-enhancer-director.c b/src/lib/clapper/gst/clapper-enhancer-director.c index 1f71cd316..4665c34cf 100644 --- a/src/lib/clapper/gst/clapper-enhancer-director.c +++ b/src/lib/clapper/gst/clapper-enhancer-director.c @@ -76,7 +76,7 @@ clapper_enhancer_director_extract_in_thread (ClapperEnhancerDirectorData *data) /* Cancelled during thread switching */ if (g_cancellable_is_cancelled (data->cancellable)) - return NULL; + goto finish; uri_str = g_uri_to_string (data->uri); job_id = g_str_hash (uri_str); @@ -89,25 +89,39 @@ clapper_enhancer_director_extract_in_thread (ClapperEnhancerDirectorData *data) ClapperEnhancerProxy *proxy = CLAPPER_ENHANCER_PROXY_CAST (el->data); ClapperExtractable *extractable = NULL; GstStructure *config; - - /* Ensures that we do not start extraction of the same URI concurrently. - * If given job is already running, blocks here until finished. - * Afterwards we try to read extracted data from cache. */ - clapper_enhancer_proxy_await_job_start (proxy, job_id); - - /* Cancelled during waiting for usage access */ - if (g_cancellable_is_cancelled (data->cancellable)) { - clapper_enhancer_proxy_remove_job (proxy, job_id); - break; + const gchar *extra_data; + gboolean cache_disabled; + + /* Skip cache IO if extractable explicitly says + * it is not supported in it (enabled by default) */ + extra_data = clapper_enhancer_proxy_get_extra_data (proxy, "X-Use-Cache"); + cache_disabled = (extra_data && g_ascii_strcasecmp (extra_data, "false") == 0); + + if (!cache_disabled) { + /* Ensures that we do not start extraction of the same URI concurrently. + * If given job is already running, blocks here until finished. + * Afterwards we try to read extracted data from cache. */ + clapper_enhancer_proxy_await_job_start (proxy, job_id); + + /* Cancelled during waiting for usage access */ + if (g_cancellable_is_cancelled (data->cancellable)) { + clapper_enhancer_proxy_remove_job (proxy, job_id); + break; + } } harvest = clapper_harvest_new (); // fresh harvest for each iteration config = clapper_enhancer_proxy_make_current_config (proxy); - if ((success = clapper_harvest_fill_from_cache (harvest, proxy, config, data->uri)) - || g_cancellable_is_cancelled (data->cancellable)) { // Check before extract + success = (!cache_disabled + && clapper_harvest_fill_from_cache (harvest, proxy, config, data->uri)); + + /* Skip extraction if restored from cache or cancelled */ + if (success || g_cancellable_is_cancelled (data->cancellable)) { gst_clear_structure (&config); - clapper_enhancer_proxy_remove_job (proxy, job_id); + if (!cache_disabled) + clapper_enhancer_proxy_remove_job (proxy, job_id); + break; } @@ -131,12 +145,15 @@ clapper_enhancer_director_extract_in_thread (ClapperEnhancerDirectorData *data) clapper_harvest_export_to_cache (harvest, proxy, config, data->uri); } gst_clear_structure (&config); - clapper_enhancer_proxy_remove_job (proxy, job_id); + if (!cache_disabled) + clapper_enhancer_proxy_remove_job (proxy, job_id); + break; } } - clapper_enhancer_proxy_remove_job (proxy, job_id); + if (!cache_disabled) + clapper_enhancer_proxy_remove_job (proxy, job_id); /* Cleanup to try again with next enhancer */ g_clear_object (&harvest); @@ -147,6 +164,7 @@ clapper_enhancer_director_extract_in_thread (ClapperEnhancerDirectorData *data) if (g_cancellable_is_cancelled (data->cancellable)) success = FALSE; +finish: if (!success) { gst_clear_object (&harvest); @@ -180,7 +198,7 @@ clapper_enhancer_director_parse_in_thread (ClapperEnhancerDirectorData *data) /* Cancelled during thread switching */ if (g_cancellable_is_cancelled (data->cancellable)) - return NULL; + goto finish; GST_DEBUG_OBJECT (self, "Enhancer proxies for buffer: %u", g_list_length (data->filtered_proxies)); @@ -242,6 +260,7 @@ clapper_enhancer_director_parse_in_thread (ClapperEnhancerDirectorData *data) if (g_cancellable_is_cancelled (data->cancellable)) success = FALSE; +finish: if (!success) { g_clear_object (&playlist); diff --git a/src/lib/clapper/gst/clapper-uri-base-demux.c b/src/lib/clapper/gst/clapper-uri-base-demux.c index b6baf2f18..dfd50b52b 100644 --- a/src/lib/clapper/gst/clapper-uri-base-demux.c +++ b/src/lib/clapper/gst/clapper-uri-base-demux.c @@ -183,9 +183,6 @@ _make_handler_for_uri (ClapperUriBaseDemux *self, const gchar *uri, const gchar gst_plugin_feature_list_free (factories); - GST_DEBUG_OBJECT (self, "Created URI handler: %s", - GST_OBJECT_NAME (element)); - return element; } @@ -238,9 +235,11 @@ clapper_uri_base_demux_set_uri (ClapperUriBaseDemux *self, const gchar *uri, con priv->uri_handler = _make_handler_for_uri (self, uri, blacklisted_el); - if (G_UNLIKELY (!priv->uri_handler)) { + if (G_LIKELY (priv->uri_handler != NULL)) { + GST_DEBUG_OBJECT (self, "Created URI handler: %s", + GST_OBJECT_NAME (priv->uri_handler)); + } else { GST_ERROR_OBJECT (self, "Could not create URI handler element"); - GST_ELEMENT_ERROR (self, CORE, MISSING_PLUGIN, ("Missing plugin to handle URI: %s", uri), (NULL));