/thirdparty/liblastfm2/src/fingerprint/contrib/FlacSource.h

http://github.com/tomahawk-player/tomahawk · C Header · 74 lines · 39 code · 14 blank · 21 comment · 0 complexity · 91c76d0b5e60e379473d5644dd30c2c4 MD5 · raw file

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