diff --git a/src/lib/clapper/clapper-harvest-private.h b/src/lib/clapper/clapper-harvest-private.h index 94477cb3..4ac376ea 100644 --- a/src/lib/clapper/clapper-harvest-private.h +++ b/src/lib/clapper/clapper-harvest-private.h @@ -29,6 +29,9 @@ G_BEGIN_DECLS G_GNUC_INTERNAL ClapperHarvest * clapper_harvest_new (void); +G_GNUC_INTERNAL +void clapper_harvest_set_enhancer_in_caps (ClapperHarvest *harvest, ClapperEnhancerProxy *proxy); + G_GNUC_INTERNAL gboolean clapper_harvest_unpack (ClapperHarvest *harvest, GstBuffer **buffer, gsize *buf_size, GstCaps **caps, GstTagList **tags, GstToc **toc, GstStructure **headers); diff --git a/src/lib/clapper/clapper-harvest.c b/src/lib/clapper/clapper-harvest.c index aec1dbd9..af196e70 100644 --- a/src/lib/clapper/clapper-harvest.c +++ b/src/lib/clapper/clapper-harvest.c @@ -94,6 +94,13 @@ clapper_harvest_new (void) return harvest; } +void +clapper_harvest_set_enhancer_in_caps (ClapperHarvest *self, ClapperEnhancerProxy *proxy) +{ + gst_caps_set_simple (self->caps, "enhancer", G_TYPE_STRING, + clapper_enhancer_proxy_get_module_name (proxy), NULL); +} + gboolean clapper_harvest_unpack (ClapperHarvest *self, GstBuffer **buffer, gsize *buf_size, GstCaps **caps, @@ -221,7 +228,6 @@ clapper_harvest_fill_from_cache (ClapperHarvest *self, ClapperEnhancerProxy *pro gchar *filename; const gchar *data, *read_str; const guint8 *buf_data; - guint8 *buf_copy; gsize buf_size; gint64 epoch_cached, epoch_now = 0; gdouble exp_seconds; @@ -281,10 +287,10 @@ clapper_harvest_fill_from_cache (ClapperHarvest *self, ClapperEnhancerProxy *pro goto finish; } - /* Read media type */ + /* Read caps */ read_str = clapper_cache_read_string (&data); if (G_UNLIKELY (read_str == NULL)) { - GST_ERROR_OBJECT (self, "Could not read media type from cache file"); + GST_ERROR_OBJECT (self, "Could not read caps from cache file"); goto finish; } @@ -296,9 +302,12 @@ clapper_harvest_fill_from_cache (ClapperHarvest *self, ClapperEnhancerProxy *pro } /* Fill harvest */ - buf_copy = g_memdup2 (buf_data, buf_size); - if (!clapper_harvest_fill (self, read_str, buf_copy, buf_size)) + if (!(self->caps = gst_caps_from_string (read_str))) { + GST_ERROR_OBJECT (self, "Could not construct caps from cache"); goto finish; + } + self->buffer = gst_buffer_new_memdup (buf_data, buf_size); + self->buf_size = buf_size; /* Read tags */ read_str = clapper_cache_read_string (&data); @@ -332,7 +341,6 @@ clapper_harvest_export_to_cache (ClapperHarvest *self, ClapperEnhancerProxy *pro const GstStructure *config, GUri *uri) { GByteArray *bytes; - const GstStructure *caps_structure; gchar *filename, *temp_str = NULL; gboolean data_ok = TRUE; @@ -366,12 +374,13 @@ clapper_harvest_export_to_cache (ClapperHarvest *self, ClapperEnhancerProxy *pro clapper_cache_store_string (bytes, temp_str); // NULL when no config g_clear_pointer (&temp_str, g_free); - /* Store media type */ - caps_structure = gst_caps_get_structure (self->caps, 0); - if (G_LIKELY (caps_structure != NULL)) { - clapper_cache_store_string (bytes, gst_structure_get_name (caps_structure)); + /* Store caps */ + temp_str = gst_caps_to_string (self->caps); + if (G_LIKELY (temp_str != NULL)) { + clapper_cache_store_string (bytes, temp_str); + g_clear_pointer (&temp_str, g_free); } else { - GST_ERROR_OBJECT (self, "Cannot cache empty caps"); + GST_ERROR_OBJECT (self, "Cannot cache caps"); data_ok = FALSE; } diff --git a/src/lib/clapper/gst/clapper-enhancer-director.c b/src/lib/clapper/gst/clapper-enhancer-director.c index 17211bb0..9d1e075d 100644 --- a/src/lib/clapper/gst/clapper-enhancer-director.c +++ b/src/lib/clapper/gst/clapper-enhancer-director.c @@ -106,9 +106,10 @@ clapper_enhancer_director_extract_in_thread (ClapperEnhancerDirectorData *data) /* We are done with extractable, but keep harvest and try to cache it */ if (success) { - if (!g_cancellable_is_cancelled (data->cancellable)) + if (!g_cancellable_is_cancelled (data->cancellable)) { + clapper_harvest_set_enhancer_in_caps (harvest, proxy); clapper_harvest_export_to_cache (harvest, proxy, config, data->uri); - + } gst_clear_structure (&config); break; }