1
0

item.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. #pragma once
  2. #include "./main.h"
  3. #include "../Agave/DecodeFile/api_decodefile.h"
  4. #include "../Agave/DecodeFile/ifc_audiostream.h"
  5. #include "./manager.h"
  6. //#include "../primo/obj_primo.h"
  7. #define BURNERITEM_SUCCESS 0x0000
  8. #define BURNERITEM_STATUS 0x0000
  9. #define BURNERITEM_ERROR 0x1000
  10. // states
  11. #define BURNERITEM_SKIPPED 0x0100
  12. #define BURNERITEM_READY 0x0101
  13. #define BURNERITEM_LICENSING 0x0102
  14. #define BURNERITEM_LICENSED 0x0103
  15. #define BURNERITEM_DECODING 0x0104
  16. #define BURNERITEM_DECODED 0x0105
  17. #define BURNERITEM_BURNING 0x0106
  18. #define BURNERITEM_BURNED 0x0107
  19. // error codes
  20. #define BURNERITEM_FAILED ((BURNERITEM_ERROR) + 0x001)
  21. #define BURNERITEM_BADFILENAME ((BURNERITEM_ERROR) + 0x002)
  22. #define BURNERITEM_UNABLEOPENFILE ((BURNERITEM_ERROR) + 0x003)
  23. #define BURNERITEM_WRITEERROR ((BURNERITEM_ERROR) + 0x004)
  24. #define BURNERITEM_DECODEERROR ((BURNERITEM_ERROR) + 0x005)
  25. #define BURNERITEM_ALREADYCREATED ((BURNERITEM_ERROR) + 0x006)
  26. #define BURNERITEM_ADDSTREAMFAILED ((BURNERITEM_ERROR) + 0x007)
  27. #define BURNERITEM_READSTREAMERROR ((BURNERITEM_ERROR) + 0x008)
  28. #define BURNERITEM_ABORTED ((BURNERITEM_ERROR) + 0x009)
  29. #define BURNERITEM_CANCELING ((BURNERITEM_ERROR) + 0x00A)
  30. // statuses
  31. #define BURNERITEM_DECODESTARTING ((BURNERITEM_STATUS) + 0x001)
  32. #define BURNERITEM_DECODEPROGRESS ((BURNERITEM_STATUS) + 0x002)
  33. #define BURNERITEM_DECODECANCELING ((BURNERITEM_STATUS) + 0x003)
  34. #define BURNERITEM_DECODEFINISHED ((BURNERITEM_STATUS) + 0x004)
  35. // callback returns
  36. #define BURNERITEM_CONTINUE 0
  37. #define BURNERITEM_STOP 1
  38. typedef DWORD (WINAPI *BURNERITEMCALLBACK)(void*, void*, DWORD, DWORD); // sender, parameter, notifyCode, errorCode
  39. #define ZEROMEM_SIZE 1024
  40. class BurnerItem
  41. {
  42. friend class BurnerPlaylist;
  43. public:
  44. BURNLIB_API BurnerItem(void);
  45. BURNLIB_API ~BurnerItem(void);
  46. public:
  47. BURNLIB_API HRESULT Create(const wchar_t *fullname, const wchar_t *title, int length);
  48. BURNLIB_API void Destroy(void);
  49. BURNLIB_API HRESULT Decode(BurnManager *manager, void *fileHandle, BURNERITEMCALLBACK notifyCB, void *userparam);
  50. BURNLIB_API HRESULT AddStream(obj_primo *primoSDK, void *fileHandle);
  51. public:
  52. BURNLIB_API const wchar_t* GetFullName(void) { return fullname; }
  53. BURNLIB_API const wchar_t* GetTitle(void) { return title; }
  54. BURNLIB_API int GetLength(void) { return length; }
  55. BURNLIB_API unsigned __int64 GetSize(void) { return sizeBytes; }
  56. BURNLIB_API DWORD GetSizeInSectors(void) { return sizeSectors; }
  57. BURNLIB_API unsigned int GetPreGap(void) { return preGap; }
  58. BURNLIB_API unsigned __int8* GetISRC(void) { return ISRC; }
  59. BURNLIB_API __int64 GetDecodedFilePosition(void) { return fposition; }
  60. BURNLIB_API int GetStatus(DWORD *retCode); // if retCode not NULL - can return completed percentage or error code
  61. void SetPreGap(unsigned int preGap);
  62. void SetISRC(unsigned __int8 *ISRC);
  63. protected:
  64. static wchar_t* DuplicateString(void *heap, const wchar_t *source, unsigned int cchSource);
  65. static DWORD StreamFiller(PBYTE pBuffer, DWORD dwBytesRequested, PDWORD pdwBytesWritten, PVOID pContext);
  66. protected:
  67. void *heap;
  68. wchar_t *fullname;
  69. wchar_t *title;
  70. int length;
  71. unsigned __int64 sizeBytes;
  72. DWORD sizeSectors;
  73. unsigned int preGap;
  74. unsigned __int8 ISRC[12];
  75. void* fhandle;
  76. __int64 fposition;
  77. BOOL needSetFilePos;
  78. unsigned __int64 streamedSize;
  79. int percentCompleted;
  80. int itemStatus;
  81. DWORD errorCode;
  82. static DWORD zeroMem[ZEROMEM_SIZE];
  83. };