device.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. #pragma once
  2. #include "../../Library/ml_pmp/pmp.h"
  3. #include "../../Library/ml_pmp/transcoder.h"
  4. #include <vector>
  5. #include "WifiDevice.h"
  6. #include "WifiPlaylist.h"
  7. #include "main.h"
  8. #include <bfc/platform/types.h>
  9. class WifiDevice;
  10. class TemplateDevice : public Device
  11. {
  12. public:
  13. typedef std::vector<WifiTrack*> TrackList;
  14. typedef std::vector<WifiPlaylist*> PlaylistsList;
  15. TemplateDevice(WifiDevice *device, const char *root_url, DeviceInfo *device_info, TemplateDevice::TrackList *track_list, TemplateDevice::PlaylistsList *playlists_list);
  16. ~TemplateDevice();
  17. virtual __int64 getDeviceCapacityAvailable(); // in bytes
  18. virtual __int64 getDeviceCapacityTotal(); // in bytes
  19. virtual void Eject(); // if you ejected successfully, you MUST call PMP_IPC_DEVICEDISCONNECTED and delete this;
  20. virtual void Close(); // save any changes, and call PMP_IPC_DEVICEDISCONNECTED AND delete this;
  21. void CloseAsync();
  22. // return 0 for success, -1 for failed or cancelled
  23. virtual int transferTrackToDevice(const itemRecordW * track, // the track to transfer
  24. void * callbackContext, //pass this to the callback
  25. void (*callback)(void *callbackContext, wchar_t *status), // call this every so often so the GUI can be updated. Including when finished!
  26. songid_t * songid, // fill in the songid when you are finished
  27. int * killswitch // if this gets set to anything other than zero, the transfer has been cancelled by the user
  28. );
  29. virtual int trackAddedToTransferQueue(const itemRecordW *track); // return 0 to accept, -1 for "not enough space", -2 for "incorrect format"
  30. virtual void trackRemovedFromTransferQueue(const itemRecordW *track);
  31. // return the amount of space that will be taken up on the device by the track (once it has been tranferred)
  32. // or 0 for incompatable. This is usually the filesize, unless you are transcoding. An estimate is acceptable.
  33. virtual __int64 getTrackSizeOnDevice(const itemRecordW *track);
  34. virtual void deleteTrack(songid_t songid); // physically remove from device. Be sure to remove it from all the playlists!
  35. virtual void commitChanges(); // optional. Will be called at a good time to save changes
  36. virtual int getPlaylistCount(); // always at least 1. playlistnumber 0 is the Master Playlist containing all tracks.
  37. // PlaylistName(0) should return the name of the device.
  38. virtual void getPlaylistName(int playlistnumber, wchar_t *buf, int len);
  39. virtual int getPlaylistLength(int playlistnumber);
  40. virtual songid_t getPlaylistTrack(int playlistnumber,int songnum); // returns a songid
  41. virtual void setPlaylistName(int playlistnumber, const wchar_t *buf); // with playlistnumber==0, set the name of the device.
  42. virtual void playlistSwapItems(int playlistnumber, int posA, int posB); // swap the songs at position posA and posB
  43. virtual void sortPlaylist(int playlistnumber, int sortBy);
  44. virtual void addTrackToPlaylist(int playlistnumber, songid_t songid); // adds songid to the end of the playlist
  45. virtual void removeTrackFromPlaylist(int playlistnumber, int songnum); //where songnum is the position of the track in the playlist
  46. virtual void deletePlaylist(int playlistnumber);
  47. virtual int newPlaylist(const wchar_t *name); // create empty playlist, returns playlistnumber. -1 for failed.
  48. virtual void getTrackArtist(songid_t songid, wchar_t *buf, int len);
  49. virtual void getTrackAlbum(songid_t songid, wchar_t *buf, int len);
  50. virtual void getTrackTitle(songid_t songid, wchar_t *buf, int len);
  51. virtual int getTrackTrackNum(songid_t songid);
  52. virtual int getTrackDiscNum(songid_t songid);
  53. virtual void getTrackGenre(songid_t songid, wchar_t * buf, int len);
  54. virtual int getTrackYear(songid_t songid);
  55. virtual __int64 getTrackSize(songid_t songid); // in bytes
  56. virtual int getTrackLength(songid_t songid); // in millisecs
  57. virtual int getTrackBitrate(songid_t songid); // in kbps
  58. virtual int getTrackPlayCount(songid_t songid);
  59. virtual int getTrackRating(songid_t songid); //0-5
  60. virtual __time64_t getTrackLastPlayed(songid_t songid); // in unix time format
  61. virtual __time64_t getTrackLastUpdated(songid_t songid); // in unix time format
  62. virtual void getTrackAlbumArtist(songid_t songid, wchar_t *buf, int len);
  63. virtual void getTrackPublisher(songid_t songid, wchar_t *buf, int len);
  64. virtual void getTrackComposer(songid_t songid, wchar_t *buf, int len);
  65. virtual int getTrackType(songid_t songid);
  66. virtual void getTrackExtraInfo(songid_t songid, const wchar_t *field, wchar_t *buf, int len) ; //optional
  67. // feel free to ignore any you don't support
  68. virtual void setTrackArtist(songid_t songid, const wchar_t *value);
  69. virtual void setTrackAlbum(songid_t songid, const wchar_t *value);
  70. virtual void setTrackTitle(songid_t songid, const wchar_t *value);
  71. virtual void setTrackTrackNum(songid_t songid, int value);
  72. virtual void setTrackDiscNum(songid_t songid, int value);
  73. virtual void setTrackGenre(songid_t songid, const wchar_t *value);
  74. virtual void setTrackYear(songid_t songid, int year);
  75. virtual void setTrackPlayCount(songid_t songid, int value);
  76. virtual void setTrackRating(songid_t songid, int value);
  77. virtual void setTrackLastPlayed(songid_t songid, __time64_t value); // in unix time format
  78. virtual void setTrackLastUpdated(songid_t songid, __time64_t value); // in unix time format
  79. virtual void setTrackAlbumArtist(songid_t songid, const wchar_t *value);
  80. virtual void setTrackPublisher(songid_t songid, const wchar_t *value);
  81. virtual void setTrackComposer(songid_t songid, const wchar_t *value);
  82. virtual void setTrackExtraInfo(songid_t songid, const wchar_t *field, const wchar_t *value) ; //optional
  83. virtual bool playTracks(songid_t * songidList, int listLength, int startPlaybackAt, bool enqueue); // return false if unsupported
  84. virtual intptr_t extraActions(intptr_t param1, intptr_t param2, intptr_t param3,intptr_t param4);
  85. virtual bool copyToHardDriveSupported();
  86. virtual __int64 songSizeOnHardDrive(songid_t song); // how big a song will be when copied back. Return -1 for not supported.
  87. virtual int copyToHardDrive(songid_t song, // the song to copy
  88. wchar_t * path, // path to copy to, in the form "c:\directory\song". The directory will already be created, you must append ".mp3" or whatever to this string! (there is space for at least 10 new characters).
  89. void * callbackContext, //pass this to the callback
  90. void (*callback)(void * callbackContext, wchar_t * status), // call this every so often so the GUI can be updated. Including when finished!
  91. int * killswitch // if this gets set to anything other than zero, the transfer has been cancelled by the user
  92. ); // -1 for failed/not supported. 0 for success.
  93. // art functions
  94. virtual void setArt(songid_t songid, void *buf, int w, int h); //buf is in format ARGB32*
  95. virtual pmpart_t getArt(songid_t songid);
  96. virtual void releaseArt(pmpart_t art);
  97. virtual int drawArt(pmpart_t art, HDC dc, int x, int y, int w, int h);
  98. virtual void getArtNaturalSize(pmpart_t art, int *w, int *h);
  99. virtual void setArtNaturalSize(pmpart_t art, int w, int h);
  100. virtual void getArtData(pmpart_t art, void* data); // data ARGB32* is at natural size
  101. virtual bool artIsEqual(pmpart_t a, pmpart_t b);
  102. PlaylistsList playlists;
  103. TrackList tracks;
  104. DeviceInfo device_info;
  105. char *url;
  106. int image16, image160;
  107. Transcoder *transcoder;
  108. int64_t transferQueueLength;
  109. };