/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
- /* ------------------------------------------------------------------
- libofa -- the Open Fingerprint Architecture library
- Public Domain (PD) 2006 Predixis Corporation
- No rights reserved.
- -------------------------------------------------------------------*/
- #ifndef __PROTOCOL_H__
- #define __PROTOCOL_H__
- #include <string>
- #include "ofa1/ofa.h"
- using namespace std;
- // This object must be filled out completely prior to making any
- // calls to the server. On return, some fields will be filled out.
- class TrackInformation {
- private:
- string puid;
- string print;
- string encoding; // All other strings must honor this encoding
- string client_key; // Get your unique key at http://www.musicdns.org
- string client_version; // Use your own version here: "1.0 beta 2"
- bool get_metadata; // If false, only the PUID will be returned
- int bitrate; // i.e. "192kbps", use 0 for VBR or freeformat
- string format; // File extension
- long length_in_ms; // In milliseconds
- string artist;
- string track;
- string album;
- int trackNum; // use 0 if not known
- string genre;
- string year;
- public:
- // Get your unique key at http://www.musicdns.org
- TrackInformation(string _key, string _version) :
- client_key(_key), client_version(_version), get_metadata(false),
- bitrate(0), length_in_ms(0), trackNum(0) {}
- ~TrackInformation() {}
- void setPrint(string p) { print = p; }
- string getPrint() const { return print; }
- // Only supported encodings are UTF-8 (default) and ISO-8859-15
- void setEncoding(string e) { encoding = e; }
- string getEncoding() const { return encoding; }
- string getClientKey() const { return client_key; }
- string getClientVersion() const { return client_version; }
- void setMetadataFlag(bool b) { get_metadata = b; }
- bool getMetadataFlag() const { return get_metadata; }
- void setBitrate(int b) { bitrate = b; }
- int getBitrate() const { return bitrate; }
- void setFormat(string fmt) { format = fmt; }
- string getFormat() const { return format; }
- void setLengthInMS(long ms) { length_in_ms = ms; }
- long getLengthInMS() const { return length_in_ms; }
- void setArtist(string name) { artist = name; }
- string getArtist() const { return artist; }
- void setTrack(string name) { track = name; }
- string getTrack() const { return track; }
- void setAlbum(string name) { album = name; }
- string getAlbum() const { return album; }
- void setTrackNum(int t) { trackNum = t; }
- int getTrackNum() const { return trackNum; }
- void setGenre(string g) { genre = g; }
- string getGenre() const { return genre; }
- void setYear(string y) { year = y; }
- string getYear() const { return year; }
- void setPUID(string id) { puid = id; }
- string getPUID() const { return puid; }
- };
- bool retrieve_metadata(TrackInformation *info);
- class AudioData {
- private:
- unsigned char *samples;
- int byteOrder;
- long size;
- int sRate;
- bool stereo;
- public:
- TrackInformation info;
- AudioData(string _key, string _version) : samples(0), size(0), sRate(0),
- stereo(false), info(_key, _version) {}
- virtual ~AudioData() {
- delete[] samples;
- }
- void setData(unsigned char*_samples, int _byteOrder, long _size, int _sRate, bool _stereo) {
- samples = _samples;
- byteOrder = _byteOrder;
- size = _size;
- sRate = _sRate;
- stereo = _stereo;
- }
- int getByteOrder() const { return byteOrder; }
- long getSize() const { return size; }
- int getSRate() const { return sRate; }
- bool getStereo() const { return stereo; }
- bool createPrint() {
- const char *print = ofa_create_print(samples, byteOrder, size, sRate, stereo);
- samples = 0;
- if (!print)
- return false;
- info.setPrint(print);
- return true;
- }
- };
- #endif