Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions doc/reference/clapper/extractable-enhancers.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
1 change: 1 addition & 0 deletions src/bin/clapper-app/ui/clapper-app-headerbar.ui
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
<property name="fallback-to-uri">true</property>
<style>
<class name="heading"/>
<class name="numeric"/>
<class name="titlelabel"/>
</style>
</object>
Expand Down
1 change: 1 addition & 0 deletions src/bin/clapper-app/ui/clapper-app-queue-list-item.ui
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
</binding>
<style>
<class name="heading"/>
<class name="numeric"/>
</style>
</object>
</child>
Expand Down
1 change: 1 addition & 0 deletions src/lib/clapper-gtk/ui/clapper-gtk-title-header.ui
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<property name="valign">center</property>
<style>
<class name="heading"/>
<class name="numeric"/>
</style>
</object>
</child>
Expand Down
53 changes: 36 additions & 17 deletions src/lib/clapper/gst/clapper-enhancer-director.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
}

Expand All @@ -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);
Expand All @@ -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);

Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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);

Expand Down
9 changes: 4 additions & 5 deletions src/lib/clapper/gst/clapper-uri-base-demux.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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));

Expand Down
Loading