nricectxhandler.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #ifndef nricectxhandler_h__
  2. #define nricectxhandler_h__
  3. #include "nricectx.h"
  4. namespace mozilla {
  5. class NrIceCtxHandler {
  6. public:
  7. // TODO(ekr@rtfm.com): Too many bools here. Bug 1193437.
  8. static RefPtr<NrIceCtxHandler> Create(const std::string& name,
  9. bool offerer,
  10. bool allow_loopback = false,
  11. bool tcp_enabled = true,
  12. bool allow_link_local = false,
  13. NrIceCtx::Policy policy =
  14. NrIceCtx::ICE_POLICY_ALL);
  15. RefPtr<NrIceMediaStream> CreateStream(const std::string& name,
  16. int components);
  17. // CreateCtx is necessary so we can create and initialize the context
  18. // on main thread, but begin the ice restart mechanics on STS thread
  19. RefPtr<NrIceCtx> CreateCtx() const; // for test
  20. RefPtr<NrIceCtx> CreateCtx(const std::string& ufrag,
  21. const std::string& pwd) const;
  22. RefPtr<NrIceCtx> ctx() { return current_ctx; }
  23. bool BeginIceRestart(RefPtr<NrIceCtx> new_ctx);
  24. bool IsRestarting() const { return (old_ctx != nullptr); }
  25. void FinalizeIceRestart();
  26. void RollbackIceRestart();
  27. NS_INLINE_DECL_THREADSAFE_REFCOUNTING(NrIceCtxHandler)
  28. private:
  29. NrIceCtxHandler(const std::string& name,
  30. bool offerer,
  31. NrIceCtx::Policy policy);
  32. NrIceCtxHandler() = delete;
  33. ~NrIceCtxHandler() {}
  34. DISALLOW_COPY_ASSIGN(NrIceCtxHandler);
  35. RefPtr<NrIceCtx> current_ctx;
  36. RefPtr<NrIceCtx> old_ctx; // for while restart is in progress
  37. int restart_count; // used to differentiate streams between restarted ctx
  38. };
  39. } // close namespace
  40. #endif // nricectxhandler_h__