api_albumart.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. #ifndef NULLSOFT_WINAMP_API_ALBUMART_H
  2. #define NULLSOFT_WINAMP_API_ALBUMART_H
  3. #include <bfc/dispatch.h>
  4. #include <bfc/platform/types.h>
  5. #include <api/service/services.h>
  6. enum
  7. {
  8. ALBUMART_SUCCESS = 0,
  9. ALBUMART_FAILURE = 1,
  10. };
  11. enum
  12. {
  13. ALBUMART_NONE = 0,
  14. ALBUMART_EMBEDDED = 1,
  15. ALBUMART_ALBUM = 2,
  16. ALBUMART_NFO = 3,
  17. ALBUMART_FILENAME = 4,
  18. ALBUMART_FOLDER = 5,
  19. ALBUMART_FRONT = 6,
  20. ALBUMART_ARTWORK = 7,
  21. };
  22. class api_albumart : public Dispatchable
  23. {
  24. protected:
  25. api_albumart(){}
  26. ~api_albumart(){}
  27. public:
  28. static FOURCC getServiceType() { return WaSvc::UNIQUE; }
  29. // use WASABI_API_MEMMGR->sysFree on the bits you get back from here.
  30. // if this function fails (return value != ALBUMART_SUCCESS), there is no guarantee about the values
  31. // in w, h or bits. please, please, please don't check bits == 0 for success/failure
  32. int GetAlbumArt(const wchar_t *filename, const wchar_t *type, int *w, int *h, ARGB32 **bits);
  33. // hack alert
  34. int GetAlbumArt_NoAMG(const wchar_t *filename, const wchar_t *type, int *w, int *h, ARGB32 **bits);
  35. // use to get still-compressed data
  36. int GetAlbumArtData(const wchar_t *filename, const wchar_t *type, void **bits, size_t *len, wchar_t **mimeType);
  37. // use to get the origin of the artwork for the file, e.g. folder, embedded
  38. int GetAlbumArtOrigin(const wchar_t *filename, const wchar_t *type, wchar_t **mimeType);
  39. // use WASABI_API_MEMMGR->sysFree to free types
  40. int GetAlbumArtTypes(const wchar_t *filename, wchar_t **types);
  41. int GetValidAlbumArtTypes(const wchar_t *filename, wchar_t **types);
  42. // returns ALBUMART_SUCCESS or ALBUMART_FAILURE
  43. // if mimeType is NULL, bits is ARGB32. w and h are not used for mimeTypes where the dimentions are in the data
  44. // if bits is NULL, this removes albumart.
  45. int SetAlbumArt(const wchar_t *filename, const wchar_t *type, int w, int h, const void *bits, size_t len, const wchar_t *mimeType);
  46. int DeleteAlbumArt(const wchar_t *filename, const wchar_t *type);
  47. // copies all album art from one file to another
  48. // also copies bits like folder.jpg if the two files live in different places
  49. // if you don't like the logic of this function, implement your own using svc_albumArtProvider directly
  50. int CopyAlbumArt(const wchar_t *sourceFilename, const wchar_t *destinationFilename);
  51. DISPATCH_CODES
  52. {
  53. API_ALBUMART_GETALBUMART = 10,
  54. API_ALBUMART_GETALBUMART_NOAMG = 11,
  55. API_ALBUMART_GETALBUMARTDATA = 12,
  56. API_ALBUMART_GETALBUMARTORIGIN = 13,
  57. API_ALBUMART_GETALBUMARTTYPES = 20,
  58. API_ALBUMART_GETVALIDALBUMARTTYPES = 30,
  59. API_ALBUMART_SETALBUMART = 40,
  60. API_ALBUMART_DELETEALBUMART = 50,
  61. API_ALBUMART_COPYALBUMART = 60,
  62. };
  63. };
  64. inline int api_albumart::GetAlbumArt(const wchar_t *filename, const wchar_t *type, int *w, int *h, ARGB32 **bits)
  65. {
  66. return _call(API_ALBUMART_GETALBUMART, (int)ALBUMART_FAILURE, filename, type, w, h, bits);
  67. }
  68. inline int api_albumart::GetAlbumArt_NoAMG(const wchar_t *filename, const wchar_t *type, int *w, int *h, ARGB32 **bits)
  69. {
  70. return _call(API_ALBUMART_GETALBUMART_NOAMG, (int)ALBUMART_FAILURE, filename, type, w, h, bits);
  71. }
  72. inline int api_albumart::GetAlbumArtData(const wchar_t *filename, const wchar_t *type, void **bits, size_t *len, wchar_t **mimeType)
  73. {
  74. return _call(API_ALBUMART_GETALBUMARTDATA, (int)ALBUMART_FAILURE, filename, type, bits, len, mimeType);
  75. }
  76. inline int api_albumart::GetAlbumArtOrigin(const wchar_t *filename, const wchar_t *type, wchar_t **mimeType)
  77. {
  78. return _call(API_ALBUMART_GETALBUMARTORIGIN, (int)ALBUMART_FAILURE, filename, type, mimeType);
  79. }
  80. inline int api_albumart::GetAlbumArtTypes(const wchar_t *filename, wchar_t **types)
  81. {
  82. return _call(API_ALBUMART_GETALBUMARTTYPES, (int)ALBUMART_FAILURE, filename, types);
  83. }
  84. inline int api_albumart::GetValidAlbumArtTypes(const wchar_t *filename, wchar_t **types)
  85. {
  86. return _call(API_ALBUMART_GETVALIDALBUMARTTYPES, (int)ALBUMART_FAILURE, filename, types);
  87. }
  88. inline int api_albumart::SetAlbumArt(const wchar_t *filename, const wchar_t *type, int w, int h, const void *bits, size_t len, const wchar_t *mimeType)
  89. {
  90. return _call(API_ALBUMART_SETALBUMART, (int)ALBUMART_FAILURE, filename, type, w, h, bits, len, mimeType);
  91. }
  92. inline int api_albumart::DeleteAlbumArt(const wchar_t *filename, const wchar_t *type)
  93. {
  94. return _call(API_ALBUMART_DELETEALBUMART, (int)ALBUMART_FAILURE, filename, type);
  95. }
  96. inline int api_albumart::CopyAlbumArt(const wchar_t *sourceFilename, const wchar_t *destinationFilename)
  97. {
  98. return _call(API_ALBUMART_COPYALBUMART, (int)ALBUMART_FAILURE, sourceFilename, destinationFilename);
  99. }
  100. // {AC4C4468-F91F-41f3-A5FA-E2B81DC6EB3A}
  101. static const GUID albumArtGUID =
  102. { 0xac4c4468, 0xf91f, 0x41f3, { 0xa5, 0xfa, 0xe2, 0xb8, 0x1d, 0xc6, 0xeb, 0x3a } };
  103. #endif