1
0

main.cpp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #define WIN32_LEAN_AND_MEAN
  2. #include "api.h"
  3. #include <bfc/platform/export.h>
  4. #include "../Agave/Component/ifc_wa5component.h"
  5. #include "../nu/Singleton.h"
  6. //#include "ogg_theora_decoder.h"
  7. #include "mkv_theora_decoder.h"
  8. api_service *WASABI_API_SVC=0;
  9. class TheoraComponent : public ifc_wa5component
  10. {
  11. public:
  12. void RegisterServices(api_service *service);
  13. int RegisterServicesSafeModeOk();
  14. void DeregisterServices(api_service *service);
  15. protected:
  16. RECVS_DISPATCH;
  17. };
  18. template <class api_T>
  19. void ServiceBuild(api_T *&api_t, GUID factoryGUID_t)
  20. {
  21. if (WASABI_API_SVC)
  22. {
  23. waServiceFactory *factory = WASABI_API_SVC->service_getServiceByGuid(factoryGUID_t);
  24. if (factory)
  25. api_t = reinterpret_cast<api_T *>( factory->getInterface() );
  26. }
  27. }
  28. template <class api_T>
  29. void ServiceRelease(api_T *api_t, GUID factoryGUID_t)
  30. {
  31. if (WASABI_API_SVC && api_t)
  32. {
  33. waServiceFactory *factory = WASABI_API_SVC->service_getServiceByGuid(factoryGUID_t);
  34. if (factory)
  35. factory->releaseInterface(api_t);
  36. }
  37. api_t = NULL;
  38. }
  39. //OggDecoderFactory ogg_decoder;
  40. //static SingletonServiceFactory<svc_oggdecoder, OggDecoderFactory> ogg_factory;
  41. MKVDecoder mkv_decoder;
  42. static SingletonServiceFactory<svc_mkvdecoder, MKVDecoder> mkv_factory;
  43. void TheoraComponent::RegisterServices(api_service *service)
  44. {
  45. WASABI_API_SVC = service;
  46. //ogg_factory.Register(WASABI_API_SVC, &ogg_decoder);
  47. mkv_factory.Register(WASABI_API_SVC, &mkv_decoder);
  48. }
  49. int TheoraComponent::RegisterServicesSafeModeOk()
  50. {
  51. return 1;
  52. }
  53. void TheoraComponent::DeregisterServices(api_service *service)
  54. {
  55. //ogg_factory.Deregister(WASABI_API_SVC);
  56. mkv_factory.Deregister(WASABI_API_SVC);
  57. }
  58. static TheoraComponent component;
  59. extern "C" DLLEXPORT ifc_wa5component *GetWinamp5SystemComponent()
  60. {
  61. return &component;
  62. }
  63. #define CBCLASS TheoraComponent
  64. START_DISPATCH;
  65. VCB(API_WA5COMPONENT_REGISTERSERVICES, RegisterServices)
  66. CB(15, RegisterServicesSafeModeOk)
  67. VCB(API_WA5COMPONENT_DEREEGISTERSERVICES, DeregisterServices)
  68. END_DISPATCH;
  69. #undef CBCLASS