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