1 /*****************************************************************************
2 * vlc_fingerprinter.h: Fingerprinter abstraction layer
3 *****************************************************************************
4 * Copyright (C) 2012 VLC authors and VideoLAN
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
19 *****************************************************************************/
21 #ifndef VLC_FINGERPRINTER_H
22 # define VLC_FINGERPRINTER_H
24 #include <vlc_common.h>
26 #include <vlc_input_item.h>
27 #include <vlc_arrays.h>
33 typedef struct fingerprinter_sys_t fingerprinter_sys_t
;
35 struct fingerprint_request_t
38 unsigned int i_duration
; /* track length hint in seconds, 0 if unknown */
41 char *psz_fingerprint
;
42 vlc_array_t metas_array
;
45 typedef struct fingerprint_request_t fingerprint_request_t
;
47 static inline fingerprint_request_t
*fingerprint_request_New( input_item_t
*p_item
)
49 fingerprint_request_t
*p_r
=
50 ( fingerprint_request_t
* ) calloc( 1, sizeof( fingerprint_request_t
) );
51 if ( !p_r
) return NULL
;
52 p_r
->results
.psz_fingerprint
= NULL
;
54 input_item_Hold( p_item
);
56 vlc_array_init( & p_r
->results
.metas_array
); /* shouldn't be needed */
60 static inline void fingerprint_request_Delete( fingerprint_request_t
*p_f
)
62 input_item_Release( p_f
->p_item
);
63 free( p_f
->results
.psz_fingerprint
);
64 for( size_t i
= 0; i
< vlc_array_count( & p_f
->results
.metas_array
); i
++ )
65 vlc_meta_Delete( (vlc_meta_t
*) vlc_array_item_at_index( & p_f
->results
.metas_array
, i
) );
69 struct fingerprinter_thread_t
71 struct vlc_common_members obj
;
73 /* Specific interfaces */
74 fingerprinter_sys_t
* p_sys
;
78 int ( *pf_enqueue
) ( struct fingerprinter_thread_t
*f
, fingerprint_request_t
*r
);
79 fingerprint_request_t
* ( *pf_getresults
) ( struct fingerprinter_thread_t
*f
);
80 void ( *pf_apply
) ( fingerprint_request_t
*, size_t i_resultid
);
82 typedef struct fingerprinter_thread_t fingerprinter_thread_t
;
84 VLC_API fingerprinter_thread_t
*fingerprinter_Create( vlc_object_t
*p_this
);
85 VLC_API
void fingerprinter_Destroy( fingerprinter_thread_t
*p_fingerprint
);