Debian Codegraph @

src/fingerprint/contrib/FlacSource.h

raw symbols SCIP
1 /*
2 Copyright 2009 Last.fm Ltd.
3 Copyright 2009 John Stamp <[email protected]>
4
5 This file is part of liblastfm.
6
7 liblastfm is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11
12 liblastfm is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with liblastfm. If not, see <http://www.gnu.org/licenses/>.
19 */
20 #ifndef __FLAC_SOURCE_H__
21 #define __FLAC_SOURCE_H__
22
23 #include <lastfm/FingerprintableSource>
24 #include <FLAC/stream_decoder.h>
25 #include <FLAC/metadata.h>
26
27
28 class FlacSource : public lastfm::FingerprintableSource
29 {
30 public:
31 FlacSource();
32 virtual ~FlacSource();
33
34 virtual void getInfo(int& lengthSecs, int& samplerate, int& bitrate, int& nchannels);
35 virtual void init(const QString& fileName);
36
37 // return a chunk of PCM data from the FLAC file
38 virtual int updateBuffer(signed short* pBuffer, size_t bufferSize);
39
40 virtual void skip(const int mSecs);
41 virtual void skipSilence(double silenceThreshold = 0.0001);
42
43 //QString getMbid();
44
45 bool eof() const { return m_eof; }
46
47 private:
48 static FLAC__StreamDecoderWriteStatus _write_callback(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);
49 static void _metadata_callback(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data);
50 static void _error_callback(const ::FLAC__StreamDecoder *decoder, ::FLAC__StreamDecoderErrorStatus status, void *client_data);
51
52 FLAC__StreamDecoderWriteStatus write_callback(const FLAC__Frame *frame, const FLAC__int32 * const buffer[]);
53 void metadata_callback( const FLAC__StreamMetadata *metadata );
54 void error_callback(FLAC__StreamDecoderErrorStatus status);
55
56 FLAC__StreamDecoder *m_decoder;
57 QString m_fileName;
58 size_t m_fileSize;
59 short *m_outBuf;
60 size_t m_outBufLen;
61 size_t m_outBufPos;
62 FLAC__uint64 m_samplePos;
63 unsigned m_maxFrameSize;
64 FLAC__StreamMetadata* m_commentData;
65 unsigned m_bps;
66 unsigned m_channels;
67 unsigned m_samplerate;
68 FLAC__uint64 m_totalSamples;
69
70 bool m_eof;
71 };
72
73 #endif
74