1
0

playlist.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. #ifndef NULLSOFT_BurnerPlaylist_HEADER
  2. #define NULLSOFT_BurnerPlaylist_HEADER
  3. #include "./main.h"
  4. #include "./api.h"
  5. #include <api/service/waServiceFactory.h>
  6. #include "../playlist/api_playlistmanager.h"
  7. #include "../playlist/ifc_playlistloadercallback.h"
  8. #include "../winamp/api_decodefile.h"
  9. #include "../nu/vector.h"
  10. #include "./item.h"
  11. #include "./manager.h"
  12. #define BURNERPLAYLIST_SUCCESS 0x0000
  13. #define BURNERPLAYLIST_STATUS 0x0000
  14. #define BURNERPLAYLIST_ERROR 0x1000
  15. // error codes
  16. #define BURNERPLAYLIST_FAILED ((BURNERPLAYLIST_ERROR) + 0x001)
  17. #define BURNERPLAYLIST_BADFILENAME ((BURNERPLAYLIST_ERROR) + 0x002)
  18. #define BURNERPLAYLIST_UNABLEOPENFILE ((BURNERPLAYLIST_ERROR) + 0x003)
  19. #define BURNERPLAYLIST_WRITEERROR ((BURNERPLAYLIST_ERROR) + 0x004)
  20. #define BURNERPLAYLIST_DECODEERROR ((BURNERPLAYLIST_ERROR) + 0x005)
  21. #define BURNERPLAYLIST_DECODESERVICEFAILED ((BURNERPLAYLIST_ERROR) + 0x006)
  22. #define BURNERPLAYLIST_THREADCREATEFAILED ((BURNERPLAYLIST_ERROR) + 0x007)
  23. #define BURNERPLAYLIST_NOFILES ((BURNERPLAYLIST_ERROR) + 0x008)
  24. #define BURNERPLAYLIST_WRONGFILECOUNT ((BURNERPLAYLIST_ERROR) + 0x009)
  25. //
  26. #define BURNERPLAYLIST_ABORTED ((BURNERPLAYLIST_STATUS) +0x100)
  27. #define BURNERPLAYLIST_DECODENEXTITEM ((BURNERPLAYLIST_ERROR) + 0x111)
  28. #define BURNERPLAYLIST_DECODEITEM ((BURNERPLAYLIST_ERROR) + 0x112)
  29. #define BURNERPLAYLIST_NEWAUDIOFAILED ((BURNERPLAYLIST_ERROR) + 0x131)
  30. #define BURNERPLAYLIST_ADDITEMFAILED ((BURNERPLAYLIST_ERROR) + 0x132)
  31. #define BURNERPLAYLIST_ADDITEMSKIPPED ((BURNERPLAYLIST_ERROR) + 0x133)
  32. #define BURNERPLAYLIST_ITEMADDED ((BURNERPLAYLIST_ERROR) + 0x134)
  33. #define BURNERPLAYLIST_BEGINBURN ((BURNERPLAYLIST_ERROR) + 0x135)
  34. #define BURNERPLAYLIST_ENDBURN ((BURNERPLAYLIST_ERROR) + 0x136)
  35. #define BURNERPLAYLIST_BEGINBURNFAILED ((BURNERPLAYLIST_ERROR) + 0x137)
  36. #define BURNERPLAYLIST_ENDBURNFAILED ((BURNERPLAYLIST_ERROR) + 0x138)
  37. #define BURNERPLAYLIST_WRITEAUDIOFAILED ((BURNERPLAYLIST_ERROR) + 0x139)
  38. #define BURNERPLAYLIST_WRITELEADIN ((BURNERPLAYLIST_ERROR) + 0x13A)
  39. #define BURNERPLAYLIST_WRITEDATA ((BURNERPLAYLIST_ERROR) + 0x13B)
  40. #define BURNERPLAYLIST_WRITELEADOUT ((BURNERPLAYLIST_ERROR) + 0x13C)
  41. #define BURNERPLAYLIST_DISCOPEN ((BURNERPLAYLIST_ERROR) + 0x13D)
  42. #define BURNERPLAYLIST_DISCCLOSE ((BURNERPLAYLIST_ERROR) + 0x13E)
  43. #define BURNERPLAYLIST_WRITEITEMBEGIN ((BURNERPLAYLIST_ERROR) + 0x13F)
  44. #define BURNERPLAYLIST_WRITEITEMEND ((BURNERPLAYLIST_ERROR) + 0x140)
  45. #define BURNERPLAYLIST_BURNFAILED ((BURNERPLAYLIST_ERROR) + 0x141)
  46. //
  47. #define BURNERPLAYLIST_FILENOTLICENSED ((BURNERPLAYLIST_ERROR) + 0x150)
  48. // statuses
  49. #define BURNERPLAYLIST_LICENSINGFINISHED ((BURNERPLAYLIST_STATUS) + 0x001)
  50. #define BURNERPLAYLIST_LICENSINGSTARTING ((BURNERPLAYLIST_STATUS) + 0x002)
  51. #define BURNERPLAYLIST_LICENSINGPROGRESS ((BURNERPLAYLIST_STATUS) + 0x003)
  52. #define BURNERPLAYLIST_DECODEFINISHED ((BURNERPLAYLIST_STATUS) + 0x010)
  53. #define BURNERPLAYLIST_DECODESTARTING ((BURNERPLAYLIST_STATUS) + 0x011)
  54. #define BURNERPLAYLIST_DECODEPROGRESS ((BURNERPLAYLIST_STATUS) + 0x012)
  55. #define BURNERPLAYLIST_DECODECANCELING ((BURNERPLAYLIST_STATUS) + 0x013)
  56. #define BURNERPLAYLIST_BURNFINISHED ((BURNERPLAYLIST_STATUS) + 0x031)
  57. #define BURNERPLAYLIST_BURNSTARTING ((BURNERPLAYLIST_STATUS) + 0x032)
  58. #define BURNERPLAYLIST_BURNPROGRESS ((BURNERPLAYLIST_STATUS) + 0x033)
  59. #define BURNERPLAYLIST_BURNCANCELING ((BURNERPLAYLIST_STATUS) + 0x034)
  60. #define BURNERPLAYLIST_BURNFINISHING ((BURNERPLAYLIST_STATUS) + 0x035)
  61. // callback returns
  62. #define BURNERPLAYLIST_CONTINUE 0
  63. #define BURNERPLAYLIST_STOP 1
  64. typedef Vector<BurnerItem*> BurnerVector;
  65. typedef struct _BPLDECODEINFO
  66. {
  67. BurnerItem *iInstance;
  68. int iIndex;
  69. DWORD iNotifyCode;
  70. DWORD iErrorCode;
  71. float percentCompleted;
  72. }BPLDECODEINFO;
  73. typedef struct _BPLRUNSTATUS
  74. {
  75. DWORD sCurrent;
  76. DWORD sTotal;
  77. BurnerItem *iInstance;
  78. int iIndex;
  79. float percentCompleted;
  80. }BPLRUNSTATUS;
  81. typedef DWORD (WINAPI *BURNERPLAYLISTCALLBACK)(void *sender, void *userparam, DWORD notifyCode, DWORD errorCode, ULONG_PTR param);
  82. class BurnerPlaylist : private ifc_playlistloadercallback, BurnerVector, BurnManagerCallback
  83. {
  84. public:
  85. BURNLIB_API BurnerPlaylist(void);
  86. BURNLIB_API ~BurnerPlaylist(void);
  87. BURNLIB_API HRESULT Load(const wchar_t *filename);
  88. BURNLIB_API HRESULT CheckLicense(BURNERPLAYLISTCALLBACK notifyCB, void *userparam);
  89. BURNLIB_API HRESULT Decode(void* hFile, BURNERPLAYLISTCALLBACK notifyCB, void *userparam, BOOL block);
  90. BURNLIB_API HRESULT Burn(obj_primo *primoSDK, DWORD drive, DWORD maxspeed, DWORD burnFlags, void* hFile,
  91. BURNERPLAYLISTCALLBACK notifyCB, void *userparam, BOOL block);
  92. BURNLIB_API DWORD AddCompilationToCDDB(void);
  93. BURNLIB_API size_t GetCount(void) { return size(); }
  94. BURNLIB_API DWORD GetTotalLengthMS(void) { return length; }
  95. BURNLIB_API BurnerItem* &operator[](size_t index) { return BurnerVector::at(index); }
  96. BURNLIB_API BurnerItem* &at(size_t index) { return BurnerVector::at(index); }
  97. BURNLIB_API DWORD GetTotalSectors(void);
  98. BURNLIB_API BOOL SetEjectWhenDone(BOOL eject) { BOOL tmp = ejectDone; ejectDone = eject; return tmp; }
  99. BURNLIB_API DWORD GetStatus(DWORD *retCode); // if retCode not NULL - can return completed percentage or error code
  100. // state based calls
  101. BURNLIB_API size_t GetStateCount(DWORD state, DWORD code);
  102. BURNLIB_API DWORD GetStateLengthMS(DWORD state, DWORD code);
  103. BURNLIB_API DWORD GetStateSectors(DWORD state, DWORD code);
  104. protected:
  105. static DWORD WINAPI DecodeWorker(void* param);
  106. static DWORD WINAPI BurnerWorker(void* param);
  107. void OnFile(const wchar_t *filename, const wchar_t *title, int lengthInMS, ifc_plentryinfo *info);
  108. static DWORD WINAPI OnItemDecode(void* sender, void *param, DWORD notifyCode, DWORD errorCode);
  109. DWORD OnNotify(DWORD notifyCode, DWORD errorCode, ULONG_PTR param);
  110. void OnLicenseCallback(size_t numFiles, WRESULT *results);
  111. RECVS_DISPATCH;
  112. protected:
  113. unsigned long length;
  114. wchar_t tmpfullname;
  115. obj_primo *primoSDK;
  116. DWORD drive;
  117. BURNERPLAYLISTCALLBACK notifyCB;
  118. void *userparam;
  119. HANDLE hThread;
  120. HANDLE hFile;
  121. BPLDECODEINFO *activeDecode;
  122. float percentStep;
  123. DWORD maxspeed;
  124. DWORD burnFlags;
  125. DWORD statusCode;
  126. DWORD errorCode;
  127. HANDLE evntCancel;
  128. BOOL ejectDone;
  129. BurnManager manager;
  130. };
  131. #endif //NULLSOFT_BurnerPlaylist_HEADER