NJBDevice.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. #ifndef _NJBDEVICE_H_
  2. #define _NJBDEVICE_H_
  3. #ifndef _UNICODE
  4. #define _UNICODE
  5. #endif
  6. #ifndef UNICODE
  7. #define UNICODE
  8. #endif
  9. #include <windows.h>
  10. #include <windowsx.h>
  11. #include <Objbase.h>
  12. #include <initguid.h>
  13. #include <stdio.h>
  14. #include <shlobj.h>
  15. #include <wchar.h>
  16. #include "../Plugins/General/gen_ml/ml.h"
  17. #include "../Plugins/Library/ml_pmp/pmp.h"
  18. #include "../Plugins/Library/ml_pmp/transcoder.h"
  19. #include "../Plugins/General/gen_ml/itemlist.h"
  20. #include "Nmsdk.h"
  21. #include "resource.h"
  22. #include "../Agave/Language/api_language.h"
  23. #include <api/service/waServiceFactory.h>
  24. extern PMPDevicePlugin plugin;
  25. extern LRESULT CALLBACK CallbackWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  26. extern C_ItemList devices;
  27. extern ICTJukebox2 * m_pCTJukebox2;
  28. #define fieldlen 256
  29. class Playlist {
  30. public:
  31. bool dirty;
  32. int plid;
  33. wchar_t name[fieldlen];
  34. C_ItemList songs;
  35. };
  36. class Song {
  37. public:
  38. char codec[5];
  39. int trackid;
  40. wchar_t artist[fieldlen];
  41. wchar_t album[fieldlen];
  42. wchar_t title[fieldlen];
  43. wchar_t genre[fieldlen];
  44. int year,track,size,length;
  45. };
  46. class TransferItem {
  47. public:
  48. const itemRecordW * track;
  49. void* callbackContext;
  50. void (*callback)(void * callbackContext, wchar_t * status);
  51. songid_t * songid;
  52. int * killswitch;
  53. int status;
  54. BYTE * meta;
  55. wchar_t * file;
  56. };
  57. class NJBDevice : public Device {
  58. public:
  59. Transcoder * transcoder;
  60. BYTE serial[16];
  61. __int64 transferQueueLength;
  62. DAPSDK_ID playlistRoot;
  63. C_ItemList playlists;
  64. int id;
  65. HWND messageWindow;
  66. TransferItem transferItem;
  67. TransferItem revTransferItem;
  68. CRITICAL_SECTION csTransfer;
  69. CRITICAL_SECTION csRevTransfer;
  70. NJBDevice(long id);
  71. virtual ~NJBDevice();
  72. virtual BOOL WindowMessage(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  73. virtual __int64 getDeviceCapacityAvailable(); // in bytes
  74. virtual __int64 getDeviceCapacityTotal(); // in bytes
  75. virtual void Eject(); // if you ejected successfully, you MUST call plugin.deviceDisconnected(this) and delete this;
  76. virtual void Close(); // save any changes, and call plugin.deviceDisconnected(this) AND delete this;
  77. // return 0 for success, -1 for failed or cancelled
  78. virtual int transferTrackToDevice(const itemRecordW * track, // the track to transfer
  79. void * callbackContext, //pass this to the callback
  80. void (*callback)(void * callbackContext, wchar_t * status), // call this every so often so the GUI can be updated. Including when finished!
  81. songid_t * songid, // fill in the songid when you are finished
  82. int * killswitch // if this gets set to anything other than zero, the transfer has been cancelled by the user
  83. );
  84. virtual int trackAddedToTransferQueue(const itemRecordW * track); // return 0 to accept, -1 for "not enough space", -2 for "incorrect format"
  85. virtual void trackRemovedFromTransferQueue(const itemRecordW * track);
  86. virtual __int64 getTrackSizeOnDevice(const itemRecordW * track); // return the amount of space taken up on the device by the track, or 0 for incompatable (usually the filesize, unless you are transcoding)
  87. virtual void deleteTrack(songid_t songid); // physically remove from device. Be sure to remove it from all the playlists!
  88. virtual void commitChanges(); // optional. Will be called at a good time to save changes
  89. virtual int getPlaylistCount(); // always at least 1. playlistnumber 0 is the Master Playlist containing all tracks.
  90. // PlaylistName(0) should return the name of the device.
  91. virtual void getPlaylistName(int playlistnumber, wchar_t * buf, int len);
  92. virtual int getPlaylistLength(int playlistnumber);
  93. virtual songid_t getPlaylistTrack(int playlistnumber,int songnum); // returns a songid
  94. virtual void setPlaylistName(int playlistnumber, const wchar_t * buf); // with playlistnumber={}, set the name of the device.
  95. virtual void playlistSwapItems(int playlistnumber, int posA, int posB); // swap the songs at position posA and posB
  96. virtual void sortPlaylist(int playlistnumber, int sortBy); // only implement if you are a non-cached device!!!
  97. virtual void addTrackToPlaylist(int playlistnumber, songid_t songid); // adds songid to the end of the playlist
  98. virtual void removeTrackFromPlaylist(int playlistnumber, int songnum); //where songnum is the position of the track in the playlist
  99. virtual void deletePlaylist(int playlistnumber);
  100. virtual int newPlaylist(const wchar_t * name); // create empty playlist, returns playlistnumber
  101. virtual void getTrackArtist(songid_t songid, wchar_t * buf, int len);
  102. virtual void getTrackAlbum(songid_t songid, wchar_t * buf, int len);
  103. virtual void getTrackTitle(songid_t songid, wchar_t * buf, int len);
  104. virtual int getTrackTrackNum(songid_t songid);
  105. virtual int getTrackDiscNum(songid_t songid);
  106. virtual void getTrackGenre(songid_t songid, wchar_t * buf, int len);
  107. virtual int getTrackYear(songid_t songid);
  108. virtual __int64 getTrackSize(songid_t songid); // in bytes
  109. virtual int getTrackLength(songid_t songid); // in millisecs
  110. virtual int getTrackBitrate(songid_t songid); // in kbps
  111. virtual int getTrackPlayCount(songid_t songid);
  112. virtual int getTrackRating(songid_t songid); //0-5
  113. virtual __time64_t getTrackLastPlayed(songid_t songid); // in unix time format
  114. virtual __time64_t getTrackLastUpdated(songid_t songid); // in unix time format
  115. virtual void getTrackExtraInfo(songid_t songid, const wchar_t * field, wchar_t * buf, int len); //optional
  116. // feel free to ignore any you don't support
  117. virtual void setTrackArtist(songid_t songid, const wchar_t * value);
  118. virtual void setTrackAlbum(songid_t songid, const wchar_t * value);
  119. virtual void setTrackTitle(songid_t songid, const wchar_t * value);
  120. virtual void setTrackTrackNum(songid_t songid, int value);
  121. virtual void setTrackDiscNum(songid_t songid, int value){};
  122. virtual void setTrackGenre(songid_t songid, const wchar_t * value);
  123. virtual void setTrackYear(songid_t songid, int year);
  124. virtual void setTrackPlayCount(songid_t songid, int value){};
  125. virtual void setTrackRating(songid_t songid, int value){};
  126. virtual void setTrackLastPlayed(songid_t songid, __time64_t value){}; // in unix time format
  127. virtual void setTrackLastUpdated(songid_t songid, __time64_t value){}; // in unix time format
  128. virtual void setTrackExtraInfo(songid_t songid, const wchar_t * field, const wchar_t * value) {}; //optional
  129. virtual bool playTracks(songid_t * songidList, int listLength, int startPlaybackAt, bool enqueue){return false;}; // return false if unsupported
  130. virtual intptr_t extraActions(intptr_t param1, intptr_t param2, intptr_t param3,intptr_t param4);
  131. virtual bool copyToHardDriveSupported() {return true;} // for now...
  132. virtual __int64 songSizeOnHardDrive(songid_t song) {return getTrackSize(song);} // how big a song will be when copied back. Return -1 for not supported.
  133. virtual int copyToHardDrive(songid_t song, // the song to copy
  134. 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).
  135. void * callbackContext, //pass this to the callback
  136. void (*callback)(void * callbackContext, wchar_t * status), // call this every so often so the GUI can be updated. Including when finished!
  137. int * killswitch // if this gets set to anything other than zero, the transfer has been cancelled by the user
  138. ); // -1 for failed/not supported. 0 for success.
  139. };
  140. #endif //_NJBDEVICE_H_