/thirdparty/liblastfm2/src/fingerprint/fplib/FingerprintExtractor.h

http://github.com/tomahawk-player/tomahawk · C Header · 77 lines · 23 code · 18 blank · 36 comment · 0 complexity · 59cec2489c1fca3a108ad083fd4467a7 MD5 · raw file

  1. /*
  2. Copyright 2005-2009 Last.fm Ltd. <mir@last.fm>
  3. This file is part of liblastfm.
  4. liblastfm is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  8. liblastfm is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with liblastfm. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. #ifndef __FINGERPRINT_EXTRACTOR_H
  16. #define __FINGERPRINT_EXTRACTOR_H
  17. #include <utility> // for pair
  18. #include <cstddef> // for size_t
  19. namespace fingerprint {
  20. // -----------------------------------------------------------------------------
  21. class PimplData;
  22. class FingerprintExtractor
  23. {
  24. public:
  25. FingerprintExtractor(); // ctor
  26. ~FingerprintExtractor(); // dtor
  27. // duration (in seconds!) is optional, but if you want to submit tracks <34 secs
  28. // it must be provided.
  29. void initForQuery(int freq, int nchannels, int duration = -1);
  30. void initForFullSubmit(int freq, int nchannels);
  31. // return false if it needs more data, otherwise true
  32. // IMPORTANT: num_samples specify the size of the *short* array pPCM, that is
  33. // the number of samples that are in the buffer. This includes
  34. // the stereo samples, i.e.
  35. // [L][R][L][R][L][R][L][R] would be num_samples=8
  36. bool process(const short* pPCM, size_t num_samples, bool end_of_stream = false);
  37. // returns pair<NULL, 0> if the data is not ready
  38. std::pair<const char*, size_t> getFingerprint();
  39. //////////////////////////////////////////////////////////////////////////
  40. // The FingerprintExtractor assumes that the file start from the beginning
  41. // but since the first SkipMs are ignored, it's possible to feed it with NULL.
  42. // In order to know how much must be skipped (in milliseconds) call this function.
  43. // Remark: this is only for "advanced" users!
  44. size_t getToSkipMs();
  45. // Return the minimum duration of the file (in ms)
  46. // Any file with a length smaller than this value will be discarded
  47. static size_t getMinimumDurationMs();
  48. // return the version of the fingerprint
  49. static size_t getVersion();
  50. private:
  51. PimplData* m_pPimplData;
  52. };
  53. // -----------------------------------------------------------------------------
  54. } // end of namespace fingerprint
  55. #endif // __FINGERPRINT_EXTRACTOR_H