]> git.sesse.net Git - vlc/commitdiff
chromaprint: add libvlccore definitions
authorFrancois Cartegnie <fcvlcdev@free.fr>
Mon, 19 Nov 2012 18:34:24 +0000 (19:34 +0100)
committerFrancois Cartegnie <fcvlcdev@free.fr>
Fri, 5 Apr 2013 13:22:40 +0000 (15:22 +0200)
include/vlc_fingerprinter.h [new file with mode: 0644]
src/Makefile.am
src/libvlccore.sym
src/misc/fingerprinter.c [new file with mode: 0644]

diff --git a/include/vlc_fingerprinter.h b/include/vlc_fingerprinter.h
new file mode 100644 (file)
index 0000000..0e7d19b
--- /dev/null
@@ -0,0 +1,92 @@
+/*****************************************************************************
+ * vlc_fingerprinter.h: Fingerprinter abstraction layer
+ *****************************************************************************
+ * Copyright (C) 2012 VLC authors and VideoLAN
+ *
+ * This program 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; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#ifndef VLC_FINGERPRINTER_H
+# define VLC_FINGERPRINTER_H
+
+#include <vlc_common.h>
+#include <vlc_meta.h>
+#include <vlc_input_item.h>
+#include <vlc_arrays.h>
+
+# ifdef __cplusplus
+extern "C" {
+# endif
+
+typedef struct fingerprinter_sys_t fingerprinter_sys_t;
+
+struct fingerprint_request_t
+{
+    input_item_t *p_item;
+    unsigned int i_duration; /* track length hint in seconds, 0 if unkown */
+    struct
+    {
+        char *psz_fingerprint;
+        vlc_array_t metas_array;
+    } results ;
+};
+typedef struct fingerprint_request_t fingerprint_request_t;
+
+static inline fingerprint_request_t *fingerprint_request_New( input_item_t *p_item )
+{
+    fingerprint_request_t *p_r =
+            ( fingerprint_request_t * ) calloc( 1, sizeof( fingerprint_request_t ) );
+    if ( !p_r ) return NULL;
+    p_r->results.psz_fingerprint = NULL;
+    p_r->i_duration = 0;
+    vlc_gc_incref( p_item );
+    p_r->p_item = p_item;
+    vlc_array_init( & p_r->results.metas_array ); /* shouldn't be needed */
+    return p_r;
+}
+
+static inline void fingerprint_request_Delete( fingerprint_request_t *p_f )
+{
+    vlc_gc_decref( p_f->p_item );
+    free( p_f->results.psz_fingerprint );
+    for ( int i=0; i< vlc_array_count( & p_f->results.metas_array ) ; i++ )
+        vlc_meta_Delete( (vlc_meta_t *) vlc_array_item_at_index( & p_f->results.metas_array, i ) );
+    free( p_f );
+}
+
+struct fingerprinter_thread_t
+{
+    VLC_COMMON_MEMBERS
+
+    /* Specific interfaces */
+    fingerprinter_sys_t * p_sys;
+
+    module_t *   p_module;
+    void ( *pf_run ) ( struct fingerprinter_thread_t * );
+
+    void ( *pf_enqueue ) ( struct fingerprinter_thread_t *f, fingerprint_request_t *r );
+    fingerprint_request_t * ( *pf_getresults ) ( struct fingerprinter_thread_t *f );
+    void ( *pf_apply ) ( fingerprint_request_t *, int i_resultid );
+};
+typedef struct fingerprinter_thread_t fingerprinter_thread_t;
+
+VLC_API fingerprinter_thread_t *fingerprinter_Create( vlc_object_t *p_this );
+VLC_API void fingerprinter_Destroy( fingerprinter_thread_t *p_fingerprint );
+
+# ifdef __cplusplus
+}
+# endif
+
+#endif
index 6e7b23aa509ee2cab1aab35a13d6e6d187cb2750..9257a0e49bd9a231ddfc86e283e3b33614b867a2 100644 (file)
@@ -76,6 +76,7 @@ pluginsinclude_HEADERS = \
        ../include/vlc_probe.h \
        ../include/vlc_rand.h \
        ../include/vlc_services_discovery.h \
+       ../include/vlc_fingerprinter.h \
        ../include/vlc_sout.h \
        ../include/vlc_spu.h \
        ../include/vlc_stream.h \
@@ -465,6 +466,7 @@ SOURCES_libvlc_common = \
        misc/filter.c \
        misc/filter_chain.c \
        misc/http_auth.c \
+       misc/fingerprinter.c \
        misc/text_style.c \
        misc/subpicture.c \
        misc/subpicture.h \
index 25d83c54e02a5a9e5bf5a606c6130093a5aab2eb..e657854b3ed89a18b85d6de47a194fe342fefef0 100644 (file)
@@ -631,3 +631,5 @@ xml_ReaderDelete
 xml_ReaderReset
 vlc_keycode2str
 vlc_str2keycode
+fingerprinter_Create
+fingerprinter_Destroy
diff --git a/src/misc/fingerprinter.c b/src/misc/fingerprinter.c
new file mode 100644 (file)
index 0000000..9e70755
--- /dev/null
@@ -0,0 +1,58 @@
+/*****************************************************************************
+ * fingerprinter.c: Fingerprinter creator and destructor
+ *****************************************************************************
+ * Copyright (C) 2012 VLC authors and VideoLAN
+ *
+ * This program 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; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <vlc_common.h>
+#include <vlc_fingerprinter.h>
+#include <vlc_modules.h>
+#include "libvlc.h"
+
+fingerprinter_thread_t *fingerprinter_Create( vlc_object_t *p_this )
+{
+    fingerprinter_thread_t *p_fingerprint;
+
+    p_fingerprint = ( fingerprinter_thread_t * )
+            vlc_custom_create( p_this, sizeof( *p_fingerprint ), "fingerprinter" );
+    if( !p_fingerprint )
+    {
+        msg_Err( p_this, "unable to create fingerprinter" );
+        return NULL;
+    }
+
+    p_fingerprint->p_module = module_need( p_fingerprint, "fingerprinter",
+                                           "acoustid", false );
+    if( !p_fingerprint->p_module )
+    {
+        vlc_object_release( p_fingerprint );
+        msg_Err( p_this, "AcoustID fingerprinter not found" );
+        return NULL;
+    }
+
+    return p_fingerprint;
+}
+
+void fingerprinter_Destroy( fingerprinter_thread_t *p_fingerprint )
+{
+    module_unneed( p_fingerprint, p_fingerprint->p_module );
+    vlc_object_release( p_fingerprint );
+}