ifc_http.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #pragma once
  2. #include "foundation/dispatch.h"
  3. #include "player/ifc_playback.h"
  4. #include "foundation/types.h"
  5. // TODO: benski> not sure that this is the best name for it, but it works for now
  6. class ifc_http : public Wasabi2::Dispatchable
  7. {
  8. protected:
  9. ifc_http() : Dispatchable(DISPATCHABLE_VERSION) {}
  10. ~ifc_http() {}
  11. public:
  12. enum
  13. {
  14. WAKE_KILL=(1<<0),
  15. WAKE_PLAY=(1<<1),
  16. WAKE_PAUSE=(1<<2),
  17. WAKE_STOP=(1<<3),
  18. WAKE_INTERRUPT=(1<<4),
  19. WAKE_UNPAUSE=(1<<5), // this is actually unused in wake_flags, just used as a return value from Wake/WakeReason
  20. WAKE_RESUME=(1<<6), // this is actually unused in wake_flags, just used as a return value from Wake/WakeReason
  21. WAKE_START_MASK = WAKE_PLAY|WAKE_STOP,
  22. WAKE_KILL_MASK = WAKE_KILL|WAKE_STOP,
  23. WAKE_ALL_MASK = WAKE_KILL|WAKE_PLAY|WAKE_PAUSE|WAKE_STOP|WAKE_INTERRUPT,
  24. };
  25. // these aren't the best names, either
  26. // if playback flag isn't ready, sleeps until a flag changes and returns changed flag
  27. int Wake(int mask) { return HTTP_Wake(mask); }
  28. // checks for pending flags and updates them
  29. int Check(int mask) { return HTTP_Check(mask); }
  30. // like wake, but only wait a specified amount of time. will return 0 if flags didn't change
  31. int Wait(unsigned int milliseconds, int mask) { return HTTP_Wait(milliseconds, mask); }
  32. int Sleep(unsigned int milliseconds, int mask) { return HTTP_Sleep(milliseconds, mask); }
  33. Agave_Seek *GetSeek() { return HTTP_GetSeek(); }
  34. void FreeSeek(Agave_Seek *seek) { HTTP_FreeSeek(seek); }
  35. int Seek(uint64_t byte_position) { return HTTP_Seek(byte_position); }
  36. /* returns NErr_True / NErr_False, returns whether or not it's seekable by Range headers.
  37. NErr_True doesn't mean 100% certainity that the stream is seekable.
  38. Note that some protocols (e.g. RTSP) might still be seekable by other means than Range headers. */
  39. int Seekable() { return HTTP_Seekable(); }
  40. int AudioOpen(const ifc_audioout::Parameters *format, ifc_audioout **out_output) { return HTTP_AudioOpen(format, out_output); }
  41. enum
  42. {
  43. DISPATCHABLE_VERSION,
  44. };
  45. protected:
  46. virtual int WASABICALL HTTP_Wake(int mask)=0;
  47. virtual int WASABICALL HTTP_Check(int mask)=0;
  48. virtual int WASABICALL HTTP_Wait(unsigned int milliseconds, int mask)=0;
  49. virtual int WASABICALL HTTP_Sleep(int milliseconds, int mask)=0;
  50. virtual Agave_Seek *WASABICALL HTTP_GetSeek()=0;
  51. virtual void WASABICALL HTTP_FreeSeek(Agave_Seek *seek)=0;
  52. virtual int WASABICALL HTTP_Seek(uint64_t byte_position)=0;
  53. virtual int WASABICALL HTTP_Seekable()=0;
  54. virtual int WASABICALL HTTP_AudioOpen(const ifc_audioout::Parameters *format, ifc_audioout **out_output)=0;
  55. };