Line data Source code
1 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* vim: set ts=2 et sw=2 tw=80: */
3 : /* This Source Code Form is subject to the terms of the Mozilla Public
4 : * License, v. 2.0. If a copy of the MPL was not distributed with this file,
5 : * You can obtain one at http://mozilla.org/MPL/2.0/. */
6 :
7 : // Original author: ekr@rtfm.com
8 :
9 : // This is a wrapper around the nICEr ICE stack
10 : #ifndef transportlayerice_h__
11 : #define transportlayerice_h__
12 :
13 : #include <vector>
14 :
15 : #include "sigslot.h"
16 :
17 : #include "mozilla/RefPtr.h"
18 : #include "nsCOMPtr.h"
19 : #include "nsIEventTarget.h"
20 : #include "nsITimer.h"
21 :
22 : #include "m_cpp_utils.h"
23 :
24 : #include "nricemediastream.h"
25 : #include "transportflow.h"
26 : #include "transportlayer.h"
27 :
28 : // An ICE transport layer -- corresponds to a single ICE
29 : namespace mozilla {
30 :
31 : class TransportLayerIce : public TransportLayer {
32 : public:
33 : explicit TransportLayerIce(const std::string& name);
34 :
35 : virtual ~TransportLayerIce();
36 :
37 : void SetParameters(RefPtr<NrIceCtx> ctx,
38 : RefPtr<NrIceMediaStream> stream,
39 : int component);
40 :
41 : void ResetOldStream(); // called after successful ice restart
42 : void RestoreOldStream(); // called after unsuccessful ice restart
43 :
44 : // Transport layer overrides.
45 : TransportResult SendPacket(const unsigned char *data, size_t len) override;
46 :
47 : // Slots for ICE
48 : void IceCandidate(NrIceMediaStream *stream, const std::string&);
49 : void IceReady(NrIceMediaStream *stream);
50 : void IceFailed(NrIceMediaStream *stream);
51 : void IcePacketReceived(NrIceMediaStream *stream, int component,
52 : const unsigned char *data, int len);
53 :
54 0 : TRANSPORT_LAYER_ID("ice")
55 :
56 : private:
57 : DISALLOW_COPY_ASSIGN(TransportLayerIce);
58 : void PostSetup();
59 :
60 : const std::string name_;
61 : RefPtr<NrIceCtx> ctx_;
62 : RefPtr<NrIceMediaStream> stream_;
63 : int component_;
64 :
65 : // used to hold the old stream
66 : RefPtr<NrIceMediaStream> old_stream_;
67 : };
68 :
69 : } // close namespace
70 : #endif
|