PageRenderTime 53ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/libtunepimp-0.5.3/lib/protocol.h

#
C Header | 110 lines | 92 code | 6 blank | 12 comment | 1 complexity | f82ade01dde312800cfa54fb1042ae07 MD5 | raw file
Possible License(s): LGPL-2.1, LGPL-3.0, GPL-2.0, LGPL-2.0
  1. /* ------------------------------------------------------------------
  2. libofa -- the Open Fingerprint Architecture library
  3. Public Domain (PD) 2006 Predixis Corporation
  4. No rights reserved.
  5. -------------------------------------------------------------------*/
  6. #ifndef __PROTOCOL_H__
  7. #define __PROTOCOL_H__
  8. #include <string>
  9. #include "ofa1/ofa.h"
  10. using namespace std;
  11. // This object must be filled out completely prior to making any
  12. // calls to the server. On return, some fields will be filled out.
  13. class TrackInformation {
  14. private:
  15. string puid;
  16. string print;
  17. string encoding; // All other strings must honor this encoding
  18. string client_key; // Get your unique key at http://www.musicdns.org
  19. string client_version; // Use your own version here: "1.0 beta 2"
  20. bool get_metadata; // If false, only the PUID will be returned
  21. int bitrate; // i.e. "192kbps", use 0 for VBR or freeformat
  22. string format; // File extension
  23. long length_in_ms; // In milliseconds
  24. string artist;
  25. string track;
  26. string album;
  27. int trackNum; // use 0 if not known
  28. string genre;
  29. string year;
  30. public:
  31. // Get your unique key at http://www.musicdns.org
  32. TrackInformation(string _key, string _version) :
  33. client_key(_key), client_version(_version), get_metadata(false),
  34. bitrate(0), length_in_ms(0), trackNum(0) {}
  35. ~TrackInformation() {}
  36. void setPrint(string p) { print = p; }
  37. string getPrint() const { return print; }
  38. // Only supported encodings are UTF-8 (default) and ISO-8859-15
  39. void setEncoding(string e) { encoding = e; }
  40. string getEncoding() const { return encoding; }
  41. string getClientKey() const { return client_key; }
  42. string getClientVersion() const { return client_version; }
  43. void setMetadataFlag(bool b) { get_metadata = b; }
  44. bool getMetadataFlag() const { return get_metadata; }
  45. void setBitrate(int b) { bitrate = b; }
  46. int getBitrate() const { return bitrate; }
  47. void setFormat(string fmt) { format = fmt; }
  48. string getFormat() const { return format; }
  49. void setLengthInMS(long ms) { length_in_ms = ms; }
  50. long getLengthInMS() const { return length_in_ms; }
  51. void setArtist(string name) { artist = name; }
  52. string getArtist() const { return artist; }
  53. void setTrack(string name) { track = name; }
  54. string getTrack() const { return track; }
  55. void setAlbum(string name) { album = name; }
  56. string getAlbum() const { return album; }
  57. void setTrackNum(int t) { trackNum = t; }
  58. int getTrackNum() const { return trackNum; }
  59. void setGenre(string g) { genre = g; }
  60. string getGenre() const { return genre; }
  61. void setYear(string y) { year = y; }
  62. string getYear() const { return year; }
  63. void setPUID(string id) { puid = id; }
  64. string getPUID() const { return puid; }
  65. };
  66. bool retrieve_metadata(TrackInformation *info);
  67. class AudioData {
  68. private:
  69. unsigned char *samples;
  70. int byteOrder;
  71. long size;
  72. int sRate;
  73. bool stereo;
  74. public:
  75. TrackInformation info;
  76. AudioData(string _key, string _version) : samples(0), size(0), sRate(0),
  77. stereo(false), info(_key, _version) {}
  78. virtual ~AudioData() {
  79. delete[] samples;
  80. }
  81. void setData(unsigned char*_samples, int _byteOrder, long _size, int _sRate, bool _stereo) {
  82. samples = _samples;
  83. byteOrder = _byteOrder;
  84. size = _size;
  85. sRate = _sRate;
  86. stereo = _stereo;
  87. }
  88. int getByteOrder() const { return byteOrder; }
  89. long getSize() const { return size; }
  90. int getSRate() const { return sRate; }
  91. bool getStereo() const { return stereo; }
  92. bool createPrint() {
  93. const char *print = ofa_create_print(samples, byteOrder, size, sRate, stereo);
  94. samples = 0;
  95. if (!print)
  96. return false;
  97. info.setPrint(print);
  98. return true;
  99. }
  100. };
  101. #endif