summaryrefslogtreecommitdiffstats
path: root/media/webrtc/signaling/src/jsep/JsepTransport.h
blob: 3b0d38ad64b2d851728aa86d0777488e49876954 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef _JSEPTRANSPORT_H_
#define _JSEPTRANSPORT_H_

#include <string>
#include <vector>

#include <mozilla/RefPtr.h>
#include <mozilla/UniquePtr.h>
#include "nsISupportsImpl.h"

#include "signaling/src/sdp/SdpAttribute.h"

namespace mozilla {

class JsepDtlsTransport
{
public:
  JsepDtlsTransport() : mRole(kJsepDtlsInvalidRole) {}

  virtual ~JsepDtlsTransport() {}

  enum Role {
    kJsepDtlsClient,
    kJsepDtlsServer,
    kJsepDtlsInvalidRole
  };

  virtual const SdpFingerprintAttributeList&
  GetFingerprints() const
  {
    return mFingerprints;
  }

  virtual Role
  GetRole() const
  {
    return mRole;
  }

private:
  friend class JsepSessionImpl;

  SdpFingerprintAttributeList mFingerprints;
  Role mRole;
};

class JsepIceTransport
{
public:
  JsepIceTransport() {}

  virtual ~JsepIceTransport() {}

  const std::string&
  GetUfrag() const
  {
    return mUfrag;
  }
  const std::string&
  GetPassword() const
  {
    return mPwd;
  }
  const std::vector<std::string>&
  GetCandidates() const
  {
    return mCandidates;
  }

private:
  friend class JsepSessionImpl;

  std::string mUfrag;
  std::string mPwd;
  std::vector<std::string> mCandidates;
};

class JsepTransport
{
public:
  JsepTransport()
      : mComponents(0)
  {
  }

  void Close()
  {
    mComponents = 0;
    mTransportId.clear();
    mIce.reset();
    mDtls.reset();
  }

  // Unique identifier for this transport within this call. Group?
  std::string mTransportId;

  // ICE stuff.
  UniquePtr<JsepIceTransport> mIce;
  UniquePtr<JsepDtlsTransport> mDtls;

  // Number of required components.
  size_t mComponents;

  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(JsepTransport);

protected:
  ~JsepTransport() {}
};

} // namespace mozilla

#endif