[grilo-plugins] chromaprint: include chromaprint plugin



commit db1f2d5d5441529fc5f3dbb72a384fdc8ab23d6c
Author: Victor Toso <me victortoso com>
Date:   Mon Jul 7 23:07:14 2014 -0300

    chromaprint: include chromaprint plugin
    
    At this moment, this plugin get only information for audios but it can
    be extended to provide metadata from videos as well, using different
    types of plugins from gstreamer.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=732879

 Makefile.am                       |    1 +
 configure.ac                      |   84 +++++++
 src/Makefile.am                   |    7 +-
 src/chromaprint/Makefile.am       |   29 +++
 src/chromaprint/grl-chromaprint.c |  470 +++++++++++++++++++++++++++++++++++++
 src/chromaprint/grl-chromaprint.h |   66 +++++
 6 files changed, 655 insertions(+), 2 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index a1fbe27..261cff7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -23,6 +23,7 @@ MAINTAINERCLEANFILES = \
 # when creating tarball releases,
 # and make sure that we enable all plugins needed by the documentation.
 DISTCHECK_CONFIGURE_FLAGS = --enable-bookmarks \
+                            --enable-chromaprint \
                             --enable-dleyna \
                             --enable-dmap \
                             --enable-filesystem \
diff --git a/configure.ac b/configure.ac
index 224918b..a8c51c9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -147,6 +147,8 @@ PKG_CHECK_MODULES(LUA, lua >= 5.3.0,
 
 PKG_CHECK_MODULES(ARCHIVE, libarchive, HAVE_ARCHIVE=yes, HAVE_ARCHIVE=no)
 
+PKG_CHECK_MODULES(GSTREAMER, gstreamer-1.0, HAVE_GSTREAMER=yes, HAVE_GSTREAMER=no)
+
 PKG_CHECK_MODULES(GTHREAD, gthread-2.0, HAVE_GTHREAD=yes, HAVE_GTHREAD=no)
 
 PKG_CHECK_MODULES(OAUTH, oauth, HAVE_OAUTH=yes, HAVE_OAUTH=no)
@@ -1056,6 +1058,87 @@ DEPS_DMAP_LIBS="$DEPS_LIBS $DMAP_LIBS $XML_LIBS"
 AC_SUBST(DEPS_DMAP_LIBS)
 
 # ----------------------------------------------------------
+# BUILD CHROMAPRINT PLUGIN
+# ----------------------------------------------------------
+
+dnl Check for required plugins
+gst10_toolsdir=`$PKG_CONFIG --variable=toolsdir gstreamer-1.0`
+gst10_inspect="$gst10_toolsdir/gst-inspect-1.0"
+
+AC_ARG_ENABLE(gstreamer,
+        AC_HELP_STRING([--enable-chromaprint],
+                [enable chromaprint plugin (default: auto)]),
+        [
+                case "$enableval" in
+                     yes)
+                        if test "x$HAVE_GSTREAMER" = "xno"; then
+                            AC_MSG_ERROR([gstreamer-1.0 not found, install it or use --disable-chromaprint])
+                        fi
+
+                        dnl Give error and exit if we don't have the gst_inspect tool
+                        AC_MSG_CHECKING([GStreamer 1.0 inspection tool])
+                        if test -r "$gst10_inspect"; then
+                            AC_MSG_RESULT([yes])
+                        else
+                            AC_MSG_RESULT([no])
+                            AC_MSG_ERROR([
+                                Cannot find required GStreamer-1.0 tool 'gst-inspect-1.0'.
+                                It should be part of gstreamer-1_0-utils.
+                                Please install or use --disable-chromaprint
+                            ])
+                        fi
+
+                        dnl Check for elements from gst-plugins-bad
+                        dnl Set plugins which contain below elements
+                        set -- chromaprint
+                        for bad_element in chromaprint
+                        do
+                            AC_MSG_CHECKING([GStreamer 1.0 $bad_element element])
+                            if $gst10_inspect $bad_element >/dev/null 2>/dev/null; then
+                                AC_MSG_RESULT([yes])
+                            else
+                                AC_MSG_RESULT([no])
+                                AC_MSG_ERROR([
+                                    Cannot find required GStreamer-1.0 plugin '$1'.
+                                    It should be part of gst-plugins-bad.
+                                    Please install or use --disable-chromaprint
+                                ])
+                            fi
+                            shift;
+                        done
+                        ;;
+                esac
+        ],
+        [
+                if test "x$HAVE_GSTREAMER" = "xyes" -a -r "$gst10_inspect"; then
+                  if $gst10_inspect chromaprint >/dev/null 2>/dev/null; then
+                    enable_chromaprint=yes
+                  else
+                    enable_chromaprint=no
+                  fi
+                else
+                  enable_chromaprint=no
+                fi
+        ])
+
+AM_CONDITIONAL([CHROMAPRINT_PLUGIN], [test "x$enable_chromaprint" = "xyes"])
+GRL_PLUGINS_ALL="$GRL_PLUGINS_ALL chromaprint"
+if test "x$enable_chromaprint" = "xyes"
+then
+       GRL_PLUGINS_ENABLED="$GRL_PLUGINS_ENABLED chromaprint"
+fi
+
+CHROMAPRINT_PLUGIN_ID="grl-chromaprint"
+AC_SUBST(CHROMAPRINT_PLUGIN_ID)
+AC_DEFINE_UNQUOTED([CHROMAPRINT_PLUGIN_ID], ["$CHROMAPRINT_PLUGIN_ID"], [chromaprint plugin ID])
+
+DEPS_CHROMAPRINT_CFLAGS="$DEPS_CFLAGS $GSTREAMER_CFLAGS"
+AC_SUBST(DEPS_CHROMAPRINT_CFLAGS)
+DEPS_CHROMAPRINT_LIBS="$DEPS_LIBS $GSTREAMER_LIBS"
+AC_SUBST(DEPS_CHROMAPRINT_LIBS)
+
+
+# ----------------------------------------------------------
 # BUILD THETVDB PLUGIN
 # ----------------------------------------------------------
 
@@ -1260,6 +1343,7 @@ AC_CONFIG_FILES([
   po/Makefile.in
   po/Makefile
   src/Makefile
+  src/chromaprint/Makefile
   src/bookmarks/Makefile
   src/dleyna/Makefile
   src/dmap/Makefile
diff --git a/src/Makefile.am b/src/Makefile.am
index fbba58b..3749ccc 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -14,6 +14,10 @@ if BOOKMARKS_PLUGIN
 SUBDIRS += bookmarks
 endif
 
+if CHROMAPRINT_PLUGIN
+SUBDIRS += chromaprint
+endif
+
 if DLEYNA_PLUGIN
 SUBDIRS += dleyna
 endif
@@ -97,9 +101,8 @@ endif
 if OPENSUBTITLES_PLUGIN
 SUBDIRS += opensubtitles
 endif
-
 DIST_SUBDIRS = \
-   bookmarks dleyna dmap filesystem flickr freebox gravatar jamendo \
+   bookmarks chromaprint dleyna dmap filesystem flickr freebox gravatar jamendo \
    local-metadata lua-factory magnatune metadata-store opensubtitles \
    optical-media podcasts raitv shoutcast thetvdb tmdb tracker vimeo youtube
 
diff --git a/src/chromaprint/Makefile.am b/src/chromaprint/Makefile.am
new file mode 100644
index 0000000..18bd847
--- /dev/null
+++ b/src/chromaprint/Makefile.am
@@ -0,0 +1,29 @@
+#
+# Makefile.am
+#
+# Author: Victor Toso <me victortoso com>
+#
+# Copyright (C) 2016 Grilo Project
+
+include $(top_srcdir)/gtester.mk
+
+ext_LTLIBRARIES = libgrlchromaprint.la
+
+libgrlchromaprint_la_CFLAGS =  \
+       $(DEPS_CHROMAPRINT_CFLAGS)      \
+       -DG_LOG_DOMAIN=\"GrlChromaprint\" \
+       -DLOCALEDIR=\"$(localedir)\"
+
+libgrlchromaprint_la_LIBADD =  \
+       $(DEPS_CHROMAPRINT_LIBS)
+
+libgrlchromaprint_la_LDFLAGS = \
+       -no-undefined       \
+       -module             \
+       -avoid-version
+
+libgrlchromaprint_la_SOURCES = grl-chromaprint.c grl-chromaprint.h
+
+extdir                         = $(GRL_PLUGINS_DIR)
+
+-include $(top_srcdir)/git.mk
diff --git a/src/chromaprint/grl-chromaprint.c b/src/chromaprint/grl-chromaprint.c
new file mode 100644
index 0000000..3a22229
--- /dev/null
+++ b/src/chromaprint/grl-chromaprint.c
@@ -0,0 +1,470 @@
+/*
+ * Copyright (C) 2016 Grilo Project
+ *
+ * Contact: Victor Toso <me victortoso com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gst/gst.h>
+#include <glib/gi18n-lib.h>
+
+#include "grl-chromaprint.h"
+
+#define GRL_CHROMAPRINT_GET_PRIVATE(object)                  \
+  (G_TYPE_INSTANCE_GET_PRIVATE((object),                  \
+                               GRL_CHROMAPRINT_SOURCE_TYPE,  \
+                               GrlChromaprintPrivate))
+
+/* --------- Logging  -------- */
+
+#define GRL_LOG_DOMAIN_DEFAULT chromaprint_log_domain
+GRL_LOG_DOMAIN_STATIC (chromaprint_log_domain);
+
+/* --- Plugin information --- */
+
+#define SOURCE_ID     "grl-chromaprint"
+#define SOURCE_NAME   "Chromaprint"
+#define SOURCE_DESC   _("A plugin to get metadata using gstreamer framework")
+
+
+/* --- chromaprint keys  --- */
+
+static GrlKeyID GRL_CHROMAPRINT_METADATA_KEY_FINGERPRINT = GRL_METADATA_KEY_INVALID;
+
+/* GStreamer Elements */
+#define GST_BIN_AUDIO           "grl-gst-audiobin"
+#define GST_ELEMENT_CHROMAPRINT "grl-gst-chromaprint"
+
+struct _GrlChromaprintPrivate {
+  GList *supported_keys;
+};
+
+typedef struct _OperationSpec {
+  GrlSource  *source;
+  guint       operation_id;
+  GList      *keys;
+  GrlMedia   *media;
+  gpointer    user_data;
+  gint        duration;
+  gchar      *fingerprint;
+  GstElement *pipeline;
+  GrlSourceResolveCb callback;
+} OperationSpec;
+
+/* Copied from gst-plugins-base/gst/playback/gstplay-enum.h */
+typedef enum
+{
+  GST_PLAY_FLAG_VIDEO = (1 << 0),
+  GST_PLAY_FLAG_AUDIO = (1 << 1),
+  GST_PLAY_FLAG_TEXT = (1 << 2),
+  GST_PLAY_FLAG_VIS = (1 << 3),
+  GST_PLAY_FLAG_SOFT_VOLUME = (1 << 4),
+  GST_PLAY_FLAG_NATIVE_AUDIO = (1 << 5),
+  GST_PLAY_FLAG_NATIVE_VIDEO = (1 << 6),
+  GST_PLAY_FLAG_DOWNLOAD = (1 << 7),
+  GST_PLAY_FLAG_BUFFERING = (1 << 8),
+  GST_PLAY_FLAG_DEINTERLACE = (1 << 9),
+  GST_PLAY_FLAG_SOFT_COLORBALANCE = (1 << 10),
+  GST_PLAY_FLAG_FORCE_FILTERS = (1 << 11),
+} GstPlayFlags;
+
+static const GList *grl_chromaprint_source_supported_keys (GrlSource *source);
+
+static gboolean grl_chromaprint_source_may_resolve (GrlSource *source,
+                                                    GrlMedia  *media,
+                                                    GrlKeyID   key_id,
+                                                    GList    **missing_keys);
+
+static void grl_chromaprint_source_resolve (GrlSource            *source,
+                                            GrlSourceResolveSpec *rs);
+
+static void grl_chromaprint_source_finalize (GObject *object);
+
+static GrlChromaprintSource* grl_chromaprint_source_new (void);
+
+/* ================== Chromaprint Plugin  ================= */
+
+static gboolean
+grl_chromaprint_plugin_init (GrlRegistry *registry,
+                             GrlPlugin   *plugin,
+                             GList       *configs)
+{
+  GrlChromaprintSource *source;
+
+  GRL_LOG_DOMAIN_INIT (chromaprint_log_domain, "chromaprint");
+
+  GRL_DEBUG ("chromaprint_plugin_init");
+
+  gst_init (NULL, NULL);
+
+  source = grl_chromaprint_source_new ();
+  grl_registry_register_source (registry,
+                                plugin,
+                                GRL_SOURCE (source),
+                                NULL);
+  return TRUE;
+}
+
+static void
+grl_chromaprint_plugin_register_keys (GrlRegistry *registry,
+                                      GrlPlugin   *plugin)
+{
+  GParamSpec *spec;
+
+  spec = g_param_spec_string ("chromaprint",
+                              "chromaprint",
+                              "The fingerprint of the audio.",
+                              NULL,
+                              G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE),
+  GRL_CHROMAPRINT_METADATA_KEY_FINGERPRINT =
+    grl_registry_register_metadata_key (registry, spec, GRL_METADATA_KEY_INVALID, NULL);
+}
+
+GRL_PLUGIN_DEFINE (GRL_MAJOR,
+                   GRL_MINOR,
+                   SOURCE_ID,
+                   SOURCE_NAME,
+                   "A plugin to get metadata using chromaprint framework",
+                   "Victor Toso",
+                   VERSION,
+                   "LGPL",
+                   "http://victortoso.com";,
+                   grl_chromaprint_plugin_init,
+                   NULL,
+                   grl_chromaprint_plugin_register_keys);
+
+/* ================== Chromaprint GObject ================= */
+
+static GrlChromaprintSource *
+grl_chromaprint_source_new ()
+{
+  GObject *object;
+  GrlChromaprintSource *source;
+
+  GRL_DEBUG ("chromaprint_source_new");
+
+  object = g_object_new (GRL_CHROMAPRINT_SOURCE_TYPE,
+                         "source-id", SOURCE_ID,
+                         "source-name", SOURCE_NAME,
+                         "source-desc", SOURCE_DESC,
+                         "supported-media", GRL_SUPPORTED_MEDIA_AUDIO,
+                         NULL);
+
+  source = GRL_CHROMAPRINT_SOURCE (object);
+  return source;
+}
+
+static void
+grl_chromaprint_source_class_init (GrlChromaprintSourceClass * klass)
+{
+  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+  GrlSourceClass *source_class = GRL_SOURCE_CLASS (klass);
+
+  source_class->supported_keys = grl_chromaprint_source_supported_keys;
+  source_class->may_resolve = grl_chromaprint_source_may_resolve;
+  source_class->resolve = grl_chromaprint_source_resolve;
+  gobject_class->finalize = grl_chromaprint_source_finalize;
+
+  g_type_class_add_private (klass, sizeof (GrlChromaprintPrivate));
+}
+
+static void
+grl_chromaprint_source_init (GrlChromaprintSource *source)
+{
+  GRL_DEBUG ("chromaprint_source_init");
+
+  source->priv = GRL_CHROMAPRINT_GET_PRIVATE (source);
+
+  /* All supported keys in a GList */
+  source->priv->supported_keys =
+    grl_metadata_key_list_new (GRL_CHROMAPRINT_METADATA_KEY_FINGERPRINT,
+                               GRL_METADATA_KEY_DURATION,
+                               GRL_METADATA_KEY_INVALID);
+}
+
+G_DEFINE_TYPE (GrlChromaprintSource, grl_chromaprint_source, GRL_TYPE_SOURCE);
+
+static void
+grl_chromaprint_source_finalize (GObject *object)
+{
+  GrlChromaprintSource *source;
+
+  GRL_DEBUG ("grl_chromaprint_source_finalize");
+
+  source = GRL_CHROMAPRINT_SOURCE (object);
+
+  g_list_free (source->priv->supported_keys);
+
+  G_OBJECT_CLASS (grl_chromaprint_source_parent_class)->finalize (object);
+}
+
+/* ======================= Utilities ==================== */
+static gchar *
+get_uri_to_file (const gchar *url)
+{
+  GFile *file;
+  gchar *uri;
+
+  file = g_file_new_for_commandline_arg (url);
+  uri = g_file_get_uri (file);
+  g_object_unref (file);
+  return uri;
+}
+
+static void
+free_operation_spec (OperationSpec *os)
+{
+  g_list_free (os->keys);
+  g_clear_pointer (&os->fingerprint, g_free);
+  g_slice_free (OperationSpec, os);
+}
+
+static void
+chromaprint_build_media (OperationSpec *os)
+{
+  GList *it;
+  gint missing_keys = 0;
+
+  for (it = os->keys; it != NULL; it = it->next) {
+    GrlKeyID key_id = GRLPOINTER_TO_KEYID (it->data);
+    switch (key_id) {
+    case GRL_METADATA_KEY_DURATION:
+      grl_media_set_duration (os->media, os->duration);
+      break;
+
+    default:
+      if (key_id == GRL_CHROMAPRINT_METADATA_KEY_FINGERPRINT) {
+        grl_data_set_string (GRL_DATA (os->media),
+                             GRL_CHROMAPRINT_METADATA_KEY_FINGERPRINT,
+                             os->fingerprint);
+
+      } else {
+        missing_keys++;
+      }
+    }
+  }
+
+  if (missing_keys > 0) {
+    GRL_DEBUG ("Operation-id %d missed %d keys",
+               os->operation_id, missing_keys);
+  }
+}
+
+
+static void
+chromaprint_gstreamer_done (OperationSpec *os)
+{
+  if (os->fingerprint == NULL)
+    goto resolve_end;
+
+  GRL_DEBUG ("duration: %d", os->duration);
+  GRL_DEBUG ("fingerprint: %s", os->fingerprint);
+  chromaprint_build_media (os);
+
+resolve_end:
+  os->callback (os->source, os->operation_id, os->media, os->user_data, NULL);
+  free_operation_spec (os);
+}
+
+
+static gboolean
+bus_call (GstBus     *bus,
+          GstMessage *msg,
+          gpointer    user_data)
+{
+  OperationSpec *os;
+
+  os = (OperationSpec *) user_data;
+
+  switch (GST_MESSAGE_TYPE (msg)) {
+
+    case GST_MESSAGE_EOS: {
+      gint64 len;
+      guint  seconds;
+      gchar *str;
+      GstElement *chromaprint;
+
+      chromaprint = gst_bin_get_by_name (GST_BIN (os->pipeline),
+                                         GST_ELEMENT_CHROMAPRINT);
+      g_object_get (G_OBJECT (chromaprint), "fingerprint", &str, NULL);
+      gst_element_query_duration (os->pipeline, GST_FORMAT_TIME, &len);
+      seconds = GST_TIME_AS_SECONDS (len);
+
+      gst_element_set_state (os->pipeline, GST_STATE_NULL);
+      gst_object_unref (GST_OBJECT (os->pipeline));
+      gst_object_unref (GST_OBJECT (chromaprint));
+
+      os->duration = seconds;
+      os->fingerprint = str;
+      chromaprint_gstreamer_done (os);
+      return FALSE;
+    }
+
+    case GST_MESSAGE_ERROR: {
+      gchar  *debug;
+      GError *error;
+
+      gst_message_parse_error (msg, &error, &debug);
+      g_free (debug);
+
+      GRL_DEBUG ("Error: %s\n", error->message);
+      g_error_free (error);
+
+      gst_element_set_state (os->pipeline, GST_STATE_NULL);
+      gst_object_unref (GST_OBJECT (os->pipeline));
+      chromaprint_gstreamer_done (os);
+      return FALSE;
+    }
+
+    default:
+      break;
+  }
+
+  return TRUE;
+}
+
+static void
+chromaprint_execute_resolve (OperationSpec *os)
+{
+  GstElement *playbin, *sink, *chromaprint;
+  GstBus *bus;
+  gchar *uri;
+  gint flags;
+
+  uri = get_uri_to_file (grl_media_get_url (os->media));
+
+  /* Create the elemtens */
+  playbin = gst_element_factory_make ("playbin", "playbin");
+  if (playbin == NULL) {
+      GRL_WARNING ("error upon creation of 'playbin' element");
+      goto err_playbin;
+  }
+
+  sink = gst_element_factory_make ("fakesink", "sink");
+  if (sink == NULL) {
+      GRL_WARNING ("error upon creation of 'fakesink' element");
+      goto err_sink;
+  }
+
+  chromaprint = gst_element_factory_make ("chromaprint", GST_ELEMENT_CHROMAPRINT);
+  if (chromaprint == NULL) {
+      GRL_WARNING ("error upon creation of 'chromaprint' element");
+      goto err_chromaprint;
+  }
+
+  g_object_set (playbin,
+                "uri", uri,
+                "audio-filter", chromaprint,
+                "audio-sink", sink,
+                NULL);
+  g_free (uri);
+
+  /* Disable video from playbin */
+  g_object_get (playbin, "flags", &flags, NULL);
+  flags &= ~GST_PLAY_FLAG_VIDEO;
+  g_object_set (playbin, "flags", flags, NULL);
+
+  bus = gst_pipeline_get_bus (GST_PIPELINE (playbin));
+  gst_bus_add_watch (bus, bus_call, os);
+  gst_object_unref (bus);
+
+  os->pipeline = playbin;
+  gst_element_set_state (playbin, GST_STATE_PLAYING);
+  return;
+
+err_chromaprint:
+  gst_object_unref (chromaprint);
+err_sink:
+  gst_object_unref (sink);
+err_playbin:
+  gst_object_unref (playbin);
+  g_clear_pointer (&uri, g_free);
+
+  os->callback (os->source, os->operation_id, os->media, os->user_data, NULL);
+  free_operation_spec (os);
+}
+
+
+/* ================== API Implementation ================ */
+static void
+grl_chromaprint_source_resolve (GrlSource            *source,
+                                GrlSourceResolveSpec *rs)
+{
+  OperationSpec *os = NULL;
+
+  GRL_DEBUG ("chromaprint_resolve");
+
+  os = g_slice_new0 (OperationSpec);
+  os->source = rs->source;
+  os->operation_id = rs->operation_id;
+  os->keys = g_list_copy (rs->keys);
+  os->callback = rs->callback;
+  os->media = rs->media;
+  os->user_data = rs->user_data;
+
+  /* FIXME: here we should resolve depending on media type (audio/video) */
+  chromaprint_execute_resolve (os);
+}
+
+static gboolean
+grl_chromaprint_source_may_resolve (GrlSource *source,
+                                    GrlMedia  *media,
+                                    GrlKeyID   key_id,
+                                    GList    **missing_keys)
+{
+  GrlChromaprintSource *gst_source = GRL_CHROMAPRINT_SOURCE (source);
+  gchar *uri;
+
+  GRL_DEBUG ("chromaprint_may_resolve");
+
+  /* Check if this key is supported */
+  if (!g_list_find (gst_source->priv->supported_keys,
+                    GRLKEYID_TO_POINTER (key_id)))
+    return FALSE;
+
+  /* Check if resolve type and media type match */
+  if (media && !grl_media_is_audio (media))
+    return FALSE;
+
+  /* Check if the media has an url to a valid name */
+  if (!media || !grl_data_has_key (GRL_DATA (media), GRL_METADATA_KEY_URL)) {
+    if (missing_keys)
+      *missing_keys = grl_metadata_key_list_new (GRL_METADATA_KEY_URL, NULL);
+
+    return FALSE;
+  }
+
+  uri = get_uri_to_file (grl_media_get_url (media));
+  if (uri == NULL)
+    return FALSE;
+
+  g_free (uri);
+  return TRUE;
+}
+
+static const GList *
+grl_chromaprint_source_supported_keys (GrlSource *source)
+{
+  GrlChromaprintSource *gst_source = GRL_CHROMAPRINT_SOURCE (source);
+
+  return gst_source->priv->supported_keys;
+}
diff --git a/src/chromaprint/grl-chromaprint.h b/src/chromaprint/grl-chromaprint.h
new file mode 100644
index 0000000..018505c
--- /dev/null
+++ b/src/chromaprint/grl-chromaprint.h
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2016 Grilo Project
+ *
+ * Contact: Victor Toso <me victortoso com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#ifndef _GRL_CHROMAPRINT_SOURCE_H_
+#define _GRL_CHROMAPRINT_SOURCE_H_
+
+#include <grilo.h>
+
+#define GRL_CHROMAPRINT_SOURCE_TYPE                        \
+  (grl_chromaprint_source_get_type ())
+
+#define GRL_CHROMAPRINT_SOURCE(obj)                        \
+  (G_TYPE_CHECK_INSTANCE_CAST((obj),                       \
+                              GRL_CHROMAPRINT_SOURCE_TYPE, \
+                              GrlChromaprintSource))
+
+#define GRL_CHROMAPRINT_SOURCE_CLASS(klass)                \
+  (G_TYPE_CHECK_CLASS_CAST((klass),                        \
+                           GRL_CHROMAPRINT_SOURCE_TYPE,    \
+                           GrlChromaprintSourceClass))
+
+#define GRL_IS_CHROMAPRINT_SOURCE_CLASS(klass)             \
+  (G_TYPE_CHECK_CLASS_TYPE((klass),                        \
+                           GRL_CHROMAPRINT_SOURCE_TYPE))
+
+#define GRL_CHROMAPRINT_SOURCE_GET_CLASS(obj)              \
+  (G_TYPE_INSTANCE_GET_CLASS((obj),                        \
+                             GRL_CHROMAPRINT_SOURCE_TYPE,  \
+                             GrlCHROMAPRINTSourceClass))
+
+typedef struct _GrlChromaprintPrivate GrlChromaprintPrivate;
+typedef struct _GrlChromaprintSource  GrlChromaprintSource;
+
+struct _GrlChromaprintSource {
+  GrlSource parent;
+  GrlChromaprintPrivate *priv;
+};
+
+typedef struct _GrlChromaprintSourceClass GrlChromaprintSourceClass;
+
+struct _GrlChromaprintSourceClass {
+  GrlSourceClass parent_class;
+};
+
+GType grl_chromaprint_source_get_type (void);
+
+#endif /* _GRL_CHROMAPRINT_SOURCE_H_ */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]