svc_playlisthandler.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. #ifndef NULLSOFT_SVC_PLAYLISTHANDLER_H
  2. #define NULLSOFT_SVC_PLAYLISTHANDLER_H
  3. #include <bfc/dispatch.h>
  4. #include <bfc/platform/types.h>
  5. #include "ifc_playlistloader.h"
  6. #include <stdint.h>
  7. enum
  8. {
  9. SVC_PLAYLISTHANDLER_SUCCESS = 0,
  10. SVC_PLAYLISTHANDLER_FAILED = 1,
  11. };
  12. class svc_playlisthandler : public Dispatchable
  13. {
  14. protected:
  15. svc_playlisthandler() {}
  16. ~svc_playlisthandler() {}
  17. public:
  18. static FOURCC getServiceType() { return svc_playlisthandler::SERVICETYPE; }
  19. const wchar_t *EnumerateExtensions(size_t n); // returns 0 when it's done
  20. const char *EnumerateMIMETypes(size_t n); // returns 0 when it's done, returns char * to match HTTP specs
  21. const wchar_t *GetName(); // returns a name suitable for display to user of this playlist form (e.g. PLS Playlist)
  22. int SupportedFilename(const wchar_t *filename); // returns SUCCESS and FAILED, so be careful ...
  23. int SupportedMIMEType(const char *filename); // returns SUCCESS and FAILED, so be careful ...
  24. ifc_playlistloader *CreateLoader(const wchar_t *filename);
  25. void ReleaseLoader(ifc_playlistloader *loader);
  26. int HasWriter(); // returns 1 if writing is supported
  27. //ifc_playlistwriter CreateWriter(const wchar_t *writer);
  28. //void ReleaseWriter(ifc_playlistwriter *writer);
  29. size_t SniffSizeRequired(); // return number of bytes required for detection on an unknown file
  30. bool IsOurs(const int8_t *data, size_t sizeBytes);
  31. public:
  32. DISPATCH_CODES
  33. {
  34. SVC_PLAYLISTHANDLER_ENUMEXTENSIONS = 10,
  35. SVC_PLAYLISTHANDLER_ENUMMIMETYPES = 20,
  36. SVC_PLAYLISTHANDLER_SUPPORTFILENAME= 30,
  37. SVC_PLAYLISTHANDLER_SUPPORTMIME= 40,
  38. SVC_PLAYLISTHANDLER_CREATELOADER = 50,
  39. SVC_PLAYLISTHANDLER_RELEASELOADER = 60,
  40. SVC_PLAYLISTHANDLER_CREATEWRITER= 70,
  41. SVC_PLAYLISTHANDLER_RELEASEWRITER= 80,
  42. SVC_PLAYLISTHANDLER_SNIFFSIZE=90,
  43. SVC_PLAYLISTHANDLER_SNIFF=100,
  44. SVC_PLAYLISTHANDLER_GETNAME=110,
  45. SVC_PLAYLISTHANDLER_HASWRITER=120,
  46. };
  47. enum
  48. {
  49. SERVICETYPE = MK3CC('p','l','h')
  50. };
  51. };
  52. inline const wchar_t *svc_playlisthandler::GetName()
  53. {
  54. return _call(SVC_PLAYLISTHANDLER_GETNAME, (const wchar_t *)0);
  55. }
  56. inline const wchar_t *svc_playlisthandler::EnumerateExtensions(size_t n)
  57. {
  58. return _call(SVC_PLAYLISTHANDLER_ENUMEXTENSIONS, (const wchar_t *)0, n);
  59. };
  60. inline const char *svc_playlisthandler::EnumerateMIMETypes(size_t n)
  61. {
  62. return _call(SVC_PLAYLISTHANDLER_ENUMMIMETYPES, (const char *)0, n);
  63. }
  64. inline int svc_playlisthandler::SupportedFilename(const wchar_t *filename)
  65. {
  66. return _call(SVC_PLAYLISTHANDLER_SUPPORTFILENAME, (int)SVC_PLAYLISTHANDLER_FAILED, filename);
  67. }
  68. inline int svc_playlisthandler::SupportedMIMEType(const char *filename)
  69. {
  70. return _call(SVC_PLAYLISTHANDLER_SUPPORTMIME, (int)SVC_PLAYLISTHANDLER_FAILED, filename);
  71. }
  72. inline ifc_playlistloader *svc_playlisthandler::CreateLoader(const wchar_t *filename)
  73. {
  74. return _call(SVC_PLAYLISTHANDLER_CREATELOADER, (ifc_playlistloader *)0, filename);
  75. }
  76. inline void svc_playlisthandler::ReleaseLoader(ifc_playlistloader *loader)
  77. {
  78. _voidcall(SVC_PLAYLISTHANDLER_RELEASELOADER, loader);
  79. }
  80. inline size_t svc_playlisthandler::SniffSizeRequired()
  81. {
  82. return _call(SVC_PLAYLISTHANDLER_SNIFFSIZE, (size_t)0);
  83. }
  84. inline bool svc_playlisthandler::IsOurs(const int8_t *data, size_t sizeBytes)
  85. {
  86. return _call(SVC_PLAYLISTHANDLER_SNIFF, (bool)false, data, sizeBytes);
  87. }
  88. inline int svc_playlisthandler::HasWriter()
  89. {
  90. return _call(SVC_PLAYLISTHANDLER_HASWRITER, (int)0);
  91. }
  92. #endif