henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1 | /* |
kjellander | b24317b | 2016-02-10 07:54:43 -0800 | [diff] [blame] | 2 | * Copyright 2012 The WebRTC project authors. All Rights Reserved. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3 | * |
kjellander | b24317b | 2016-02-10 07:54:43 -0800 | [diff] [blame] | 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 9 | */ |
| 10 | |
ossu | 7bb87ee | 2017-01-23 04:56:25 -0800 | [diff] [blame] | 11 | #ifndef WEBRTC_PC_WEBRTCSESSION_H_ |
| 12 | #define WEBRTC_PC_WEBRTCSESSION_H_ |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 13 | |
jbauch | 555604a | 2016-04-26 03:13:22 -0700 | [diff] [blame] | 14 | #include <memory> |
deadbeef | 0ed85b2 | 2016-02-23 17:24:52 -0800 | [diff] [blame] | 15 | #include <set> |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 16 | #include <string> |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 17 | #include <vector> |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 18 | |
Henrik Kjellander | 15583c1 | 2016-02-10 10:53:12 +0100 | [diff] [blame] | 19 | #include "webrtc/api/peerconnectioninterface.h" |
| 20 | #include "webrtc/api/statstypes.h" |
kwiberg | 4485ffb | 2016-04-26 08:14:39 -0700 | [diff] [blame] | 21 | #include "webrtc/base/constructormagic.h" |
deadbeef | 953c2ce | 2017-01-09 14:53:41 -0800 | [diff] [blame] | 22 | #include "webrtc/base/optional.h" |
buildbot@webrtc.org | a09a999 | 2014-08-13 17:26:08 +0000 | [diff] [blame] | 23 | #include "webrtc/base/sigslot.h" |
Henrik Boström | 5e56c59 | 2015-08-11 10:33:13 +0200 | [diff] [blame] | 24 | #include "webrtc/base/sslidentity.h" |
buildbot@webrtc.org | a09a999 | 2014-08-13 17:26:08 +0000 | [diff] [blame] | 25 | #include "webrtc/base/thread.h" |
kjellander | a96e2d7 | 2016-02-04 23:52:28 -0800 | [diff] [blame] | 26 | #include "webrtc/media/base/mediachannel.h" |
Honghai Zhang | 7fb69db | 2016-03-14 11:59:18 -0700 | [diff] [blame] | 27 | #include "webrtc/p2p/base/candidate.h" |
Tommi | f888bb5 | 2015-12-12 01:37:01 +0100 | [diff] [blame] | 28 | #include "webrtc/p2p/base/transportcontroller.h" |
ossu | 7bb87ee | 2017-01-23 04:56:25 -0800 | [diff] [blame] | 29 | #include "webrtc/pc/datachannel.h" |
ossu | 7bb87ee | 2017-01-23 04:56:25 -0800 | [diff] [blame] | 30 | #include "webrtc/pc/mediacontroller.h" |
kjellander@webrtc.org | 9b8df25 | 2016-02-12 06:47:59 +0100 | [diff] [blame] | 31 | #include "webrtc/pc/mediasession.h" |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 32 | |
zhihuang | 9763d56 | 2016-08-05 11:14:50 -0700 | [diff] [blame] | 33 | #ifdef HAVE_QUIC |
ossu | 7bb87ee | 2017-01-23 04:56:25 -0800 | [diff] [blame] | 34 | #include "webrtc/pc/quicdatatransport.h" |
zhihuang | 9763d56 | 2016-08-05 11:14:50 -0700 | [diff] [blame] | 35 | #endif // HAVE_QUIC |
| 36 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 37 | namespace cricket { |
henrike@webrtc.org | b0ecc1c | 2014-03-26 22:44:28 +0000 | [diff] [blame] | 38 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 39 | class ChannelManager; |
deadbeef | 953c2ce | 2017-01-09 14:53:41 -0800 | [diff] [blame] | 40 | class RtpDataChannel; |
| 41 | class SctpTransportInternal; |
| 42 | class SctpTransportInternalFactory; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 43 | class StatsReport; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 44 | class VideoChannel; |
| 45 | class VoiceChannel; |
henrike@webrtc.org | b0ecc1c | 2014-03-26 22:44:28 +0000 | [diff] [blame] | 46 | |
zhihuang | 9763d56 | 2016-08-05 11:14:50 -0700 | [diff] [blame] | 47 | #ifdef HAVE_QUIC |
| 48 | class QuicTransportChannel; |
| 49 | #endif // HAVE_QUIC |
| 50 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 51 | } // namespace cricket |
| 52 | |
| 53 | namespace webrtc { |
buildbot@webrtc.org | 41451d4 | 2014-05-03 05:39:45 +0000 | [diff] [blame] | 54 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 55 | class IceRestartAnswerLatch; |
buildbot@webrtc.org | 41451d4 | 2014-05-03 05:39:45 +0000 | [diff] [blame] | 56 | class JsepIceCandidate; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 57 | class MediaStreamSignaling; |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 58 | class WebRtcSessionDescriptionFactory; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 59 | |
henrike@webrtc.org | 1e09a71 | 2013-07-26 19:17:59 +0000 | [diff] [blame] | 60 | extern const char kBundleWithoutRtcpMux[]; |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 61 | extern const char kCreateChannelFailed[]; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 62 | extern const char kInvalidCandidates[]; |
| 63 | extern const char kInvalidSdp[]; |
| 64 | extern const char kMlineMismatch[]; |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 65 | extern const char kPushDownTDFailed[]; |
henrike@webrtc.org | b90991d | 2014-03-04 19:54:57 +0000 | [diff] [blame] | 66 | extern const char kSdpWithoutDtlsFingerprint[]; |
| 67 | extern const char kSdpWithoutSdesCrypto[]; |
mallinath@webrtc.org | 19f27e6 | 2013-10-13 17:18:27 +0000 | [diff] [blame] | 68 | extern const char kSdpWithoutIceUfragPwd[]; |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 69 | extern const char kSdpWithoutSdesAndDtlsDisabled[]; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 70 | extern const char kSessionError[]; |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 71 | extern const char kSessionErrorDesc[]; |
deadbeef | 953c2ce | 2017-01-09 14:53:41 -0800 | [diff] [blame] | 72 | extern const char kDtlsSrtpSetupFailureRtp[]; |
| 73 | extern const char kDtlsSrtpSetupFailureRtcp[]; |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 74 | extern const char kEnableBundleFailed[]; |
| 75 | |
buildbot@webrtc.org | 53df88c | 2014-08-07 22:46:01 +0000 | [diff] [blame] | 76 | // Maximum number of received video streams that will be processed by webrtc |
| 77 | // even if they are not signalled beforehand. |
| 78 | extern const int kMaxUnsignalledRecvStreams; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 79 | |
| 80 | // ICE state callback interface. |
| 81 | class IceObserver { |
| 82 | public: |
wu@webrtc.org | 364f204 | 2013-11-20 21:49:41 +0000 | [diff] [blame] | 83 | IceObserver() {} |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 84 | // Called any time the IceConnectionState changes |
zstein | 6dfd53a | 2017-03-06 13:49:03 -0800 | [diff] [blame] | 85 | virtual void OnIceConnectionStateChange( |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 86 | PeerConnectionInterface::IceConnectionState new_state) {} |
| 87 | // Called any time the IceGatheringState changes |
| 88 | virtual void OnIceGatheringChange( |
| 89 | PeerConnectionInterface::IceGatheringState new_state) {} |
| 90 | // New Ice candidate have been found. |
jbauch | 81bf7b0 | 2017-03-25 08:31:12 -0700 | [diff] [blame] | 91 | virtual void OnIceCandidate( |
| 92 | std::unique_ptr<IceCandidateInterface> candidate) = 0; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 93 | |
Honghai Zhang | 7fb69db | 2016-03-14 11:59:18 -0700 | [diff] [blame] | 94 | // Some local ICE candidates have been removed. |
| 95 | virtual void OnIceCandidatesRemoved( |
| 96 | const std::vector<cricket::Candidate>& candidates) = 0; |
| 97 | |
Peter Thatcher | 5436051 | 2015-07-08 11:08:35 -0700 | [diff] [blame] | 98 | // Called whenever the state changes between receiving and not receiving. |
| 99 | virtual void OnIceConnectionReceivingChange(bool receiving) {} |
| 100 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 101 | protected: |
| 102 | ~IceObserver() {} |
wu@webrtc.org | 364f204 | 2013-11-20 21:49:41 +0000 | [diff] [blame] | 103 | |
| 104 | private: |
henrikg | 3c089d7 | 2015-09-16 05:37:44 -0700 | [diff] [blame] | 105 | RTC_DISALLOW_COPY_AND_ASSIGN(IceObserver); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 106 | }; |
| 107 | |
deadbeef | d59daf8 | 2015-10-14 15:02:44 -0700 | [diff] [blame] | 108 | // Statistics for all the transports of the session. |
| 109 | typedef std::map<std::string, cricket::TransportStats> TransportStatsMap; |
| 110 | typedef std::map<std::string, std::string> ProxyTransportMap; |
| 111 | |
| 112 | // TODO(pthatcher): Think of a better name for this. We already have |
| 113 | // a TransportStats in transport.h. Perhaps TransportsStats? |
| 114 | struct SessionStats { |
| 115 | ProxyTransportMap proxy_to_transport; |
| 116 | TransportStatsMap transport_stats; |
| 117 | }; |
| 118 | |
hbos | df6075a | 2016-12-19 04:58:02 -0800 | [diff] [blame] | 119 | struct ChannelNamePair { |
| 120 | ChannelNamePair( |
| 121 | const std::string& content_name, const std::string& transport_name) |
| 122 | : content_name(content_name), transport_name(transport_name) {} |
| 123 | std::string content_name; |
| 124 | std::string transport_name; |
| 125 | }; |
| 126 | |
| 127 | struct ChannelNamePairs { |
| 128 | rtc::Optional<ChannelNamePair> voice; |
| 129 | rtc::Optional<ChannelNamePair> video; |
| 130 | rtc::Optional<ChannelNamePair> data; |
| 131 | }; |
| 132 | |
deadbeef | d59daf8 | 2015-10-14 15:02:44 -0700 | [diff] [blame] | 133 | // A WebRtcSession manages general session state. This includes negotiation |
| 134 | // of both the application-level and network-level protocols: the former |
| 135 | // defines what will be sent and the latter defines how it will be sent. Each |
| 136 | // network-level protocol is represented by a Transport object. Each Transport |
| 137 | // participates in the network-level negotiation. The individual streams of |
| 138 | // packets are represented by TransportChannels. The application-level protocol |
| 139 | // is represented by SessionDecription objects. |
Taylor Brandstetter | ba29c6a | 2016-06-27 16:30:35 -0700 | [diff] [blame] | 140 | class WebRtcSession : |
Taylor Brandstetter | ba29c6a | 2016-06-27 16:30:35 -0700 | [diff] [blame] | 141 | public DataChannelProviderInterface, |
| 142 | public sigslot::has_slots<> { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 143 | public: |
deadbeef | d59daf8 | 2015-10-14 15:02:44 -0700 | [diff] [blame] | 144 | enum State { |
| 145 | STATE_INIT = 0, |
| 146 | STATE_SENTOFFER, // Sent offer, waiting for answer. |
| 147 | STATE_RECEIVEDOFFER, // Received an offer. Need to send answer. |
| 148 | STATE_SENTPRANSWER, // Sent provisional answer. Need to send answer. |
| 149 | STATE_RECEIVEDPRANSWER, // Received provisional answer, waiting for answer. |
| 150 | STATE_INPROGRESS, // Offer/answer exchange completed. |
| 151 | STATE_CLOSED, // Close() was called. |
| 152 | }; |
| 153 | |
| 154 | enum Error { |
| 155 | ERROR_NONE = 0, // no error |
| 156 | ERROR_CONTENT = 1, // channel errors in SetLocalContent/SetRemoteContent |
| 157 | ERROR_TRANSPORT = 2, // transport error of some kind |
| 158 | }; |
| 159 | |
deadbeef | 953c2ce | 2017-01-09 14:53:41 -0800 | [diff] [blame] | 160 | // |sctp_factory| may be null, in which case SCTP is treated as unsupported. |
zhihuang | 29ff844 | 2016-07-27 11:07:25 -0700 | [diff] [blame] | 161 | WebRtcSession( |
| 162 | webrtc::MediaControllerInterface* media_controller, |
| 163 | rtc::Thread* network_thread, |
| 164 | rtc::Thread* worker_thread, |
| 165 | rtc::Thread* signaling_thread, |
| 166 | cricket::PortAllocator* port_allocator, |
deadbeef | 953c2ce | 2017-01-09 14:53:41 -0800 | [diff] [blame] | 167 | std::unique_ptr<cricket::TransportController> transport_controller, |
| 168 | std::unique_ptr<cricket::SctpTransportInternalFactory> sctp_factory); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 169 | virtual ~WebRtcSession(); |
| 170 | |
deadbeef | d59daf8 | 2015-10-14 15:02:44 -0700 | [diff] [blame] | 171 | // These are const to allow them to be called from const methods. |
zhihuang | 9763d56 | 2016-08-05 11:14:50 -0700 | [diff] [blame] | 172 | rtc::Thread* network_thread() const { return network_thread_; } |
deadbeef | d59daf8 | 2015-10-14 15:02:44 -0700 | [diff] [blame] | 173 | rtc::Thread* worker_thread() const { return worker_thread_; } |
danilchap | e9021a3 | 2016-05-17 01:52:02 -0700 | [diff] [blame] | 174 | rtc::Thread* signaling_thread() const { return signaling_thread_; } |
deadbeef | d59daf8 | 2015-10-14 15:02:44 -0700 | [diff] [blame] | 175 | |
| 176 | // The ID of this session. |
| 177 | const std::string& id() const { return sid_; } |
| 178 | |
Henrik Lundin | 64dad83 | 2015-05-11 12:44:23 +0200 | [diff] [blame] | 179 | bool Initialize( |
| 180 | const PeerConnectionFactoryInterface::Options& options, |
Henrik Boström | d03c23b | 2016-06-01 11:44:18 +0200 | [diff] [blame] | 181 | std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator, |
Henrik Lundin | 64dad83 | 2015-05-11 12:44:23 +0200 | [diff] [blame] | 182 | const PeerConnectionInterface::RTCConfiguration& rtc_configuration); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 183 | // Deletes the voice, video and data channel and changes the session state |
deadbeef | d59daf8 | 2015-10-14 15:02:44 -0700 | [diff] [blame] | 184 | // to STATE_CLOSED. |
| 185 | void Close(); |
| 186 | |
| 187 | // Returns true if we were the initial offerer. |
| 188 | bool initial_offerer() const { return initial_offerer_; } |
| 189 | |
| 190 | // Returns the current state of the session. See the enum above for details. |
| 191 | // Each time the state changes, we will fire this signal. |
| 192 | State state() const { return state_; } |
| 193 | sigslot::signal2<WebRtcSession*, State> SignalState; |
| 194 | |
| 195 | // Returns the last error in the session. See the enum above for details. |
| 196 | Error error() const { return error_; } |
| 197 | const std::string& error_desc() const { return error_desc_; } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 198 | |
| 199 | void RegisterIceObserver(IceObserver* observer) { |
| 200 | ice_observer_ = observer; |
| 201 | } |
| 202 | |
deadbeef | 953c2ce | 2017-01-09 14:53:41 -0800 | [diff] [blame] | 203 | // Exposed for stats collecting. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 204 | virtual cricket::VoiceChannel* voice_channel() { |
| 205 | return voice_channel_.get(); |
| 206 | } |
| 207 | virtual cricket::VideoChannel* video_channel() { |
| 208 | return video_channel_.get(); |
| 209 | } |
deadbeef | 953c2ce | 2017-01-09 14:53:41 -0800 | [diff] [blame] | 210 | // Only valid when using deprecated RTP data channels. |
| 211 | virtual cricket::RtpDataChannel* rtp_data_channel() { |
| 212 | return rtp_data_channel_.get(); |
| 213 | } |
| 214 | virtual rtc::Optional<std::string> sctp_content_name() const { |
| 215 | return sctp_content_name_; |
| 216 | } |
| 217 | virtual rtc::Optional<std::string> sctp_transport_name() const { |
| 218 | return sctp_transport_name_; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 219 | } |
| 220 | |
deadbeef | 0ed85b2 | 2016-02-23 17:24:52 -0800 | [diff] [blame] | 221 | cricket::BaseChannel* GetChannel(const std::string& content_name); |
| 222 | |
henrike@webrtc.org | b90991d | 2014-03-04 19:54:57 +0000 | [diff] [blame] | 223 | cricket::SecurePolicy SdesPolicy() const; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 224 | |
deadbeef | 953c2ce | 2017-01-09 14:53:41 -0800 | [diff] [blame] | 225 | // Get current SSL role used by SCTP's underlying transport. |
| 226 | bool GetSctpSslRole(rtc::SSLRole* role); |
| 227 | // Get SSL role for an arbitrary m= section (handles bundling correctly). |
| 228 | // TODO(deadbeef): This is only used internally by the session description |
| 229 | // factory, it shouldn't really be public). |
| 230 | bool GetSslRole(const std::string& content_name, rtc::SSLRole* role); |
sergeyu@chromium.org | 0be6aa0 | 2013-08-23 23:21:25 +0000 | [diff] [blame] | 231 | |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 232 | void CreateOffer( |
| 233 | CreateSessionDescriptionObserver* observer, |
deadbeef | ab9b2d1 | 2015-10-14 11:33:11 -0700 | [diff] [blame] | 234 | const PeerConnectionInterface::RTCOfferAnswerOptions& options, |
| 235 | const cricket::MediaSessionOptions& session_options); |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 236 | void CreateAnswer(CreateSessionDescriptionObserver* observer, |
deadbeef | ab9b2d1 | 2015-10-14 11:33:11 -0700 | [diff] [blame] | 237 | const cricket::MediaSessionOptions& session_options); |
henrike@webrtc.org | 28654cb | 2013-07-22 21:07:49 +0000 | [diff] [blame] | 238 | // The ownership of |desc| will be transferred after this call. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 239 | bool SetLocalDescription(SessionDescriptionInterface* desc, |
| 240 | std::string* err_desc); |
henrike@webrtc.org | 28654cb | 2013-07-22 21:07:49 +0000 | [diff] [blame] | 241 | // The ownership of |desc| will be transferred after this call. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 242 | bool SetRemoteDescription(SessionDescriptionInterface* desc, |
| 243 | std::string* err_desc); |
deadbeef | 953c2ce | 2017-01-09 14:53:41 -0800 | [diff] [blame] | 244 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 245 | bool ProcessIceMessage(const IceCandidateInterface* ice_candidate); |
buildbot@webrtc.org | 41451d4 | 2014-05-03 05:39:45 +0000 | [diff] [blame] | 246 | |
Honghai Zhang | 7fb69db | 2016-03-14 11:59:18 -0700 | [diff] [blame] | 247 | bool RemoveRemoteIceCandidates( |
| 248 | const std::vector<cricket::Candidate>& candidates); |
| 249 | |
honghaiz | 1f429e3 | 2015-09-28 07:57:34 -0700 | [diff] [blame] | 250 | cricket::IceConfig ParseIceConfig( |
| 251 | const PeerConnectionInterface::RTCConfiguration& config) const; |
| 252 | |
deadbeef | d59daf8 | 2015-10-14 15:02:44 -0700 | [diff] [blame] | 253 | void SetIceConfig(const cricket::IceConfig& ice_config); |
| 254 | |
| 255 | // Start gathering candidates for any new transports, or transports doing an |
| 256 | // ICE restart. |
| 257 | void MaybeStartGathering(); |
| 258 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 259 | const SessionDescriptionInterface* local_description() const { |
deadbeef | fe4a8a4 | 2016-12-20 17:56:17 -0800 | [diff] [blame] | 260 | return pending_local_description_ ? pending_local_description_.get() |
| 261 | : current_local_description_.get(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 262 | } |
| 263 | const SessionDescriptionInterface* remote_description() const { |
deadbeef | fe4a8a4 | 2016-12-20 17:56:17 -0800 | [diff] [blame] | 264 | return pending_remote_description_ ? pending_remote_description_.get() |
| 265 | : current_remote_description_.get(); |
| 266 | } |
| 267 | const SessionDescriptionInterface* current_local_description() const { |
| 268 | return current_local_description_.get(); |
| 269 | } |
| 270 | const SessionDescriptionInterface* current_remote_description() const { |
| 271 | return current_remote_description_.get(); |
| 272 | } |
| 273 | const SessionDescriptionInterface* pending_local_description() const { |
| 274 | return pending_local_description_.get(); |
| 275 | } |
| 276 | const SessionDescriptionInterface* pending_remote_description() const { |
| 277 | return pending_remote_description_.get(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 278 | } |
| 279 | |
| 280 | // Get the id used as a media stream track's "id" field from ssrc. |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 281 | virtual bool GetLocalTrackIdBySsrc(uint32_t ssrc, std::string* track_id); |
| 282 | virtual bool GetRemoteTrackIdBySsrc(uint32_t ssrc, std::string* track_id); |
xians@webrtc.org | 4cb0128 | 2014-06-12 14:57:05 +0000 | [diff] [blame] | 283 | |
wu@webrtc.org | 7818752 | 2013-10-07 23:32:02 +0000 | [diff] [blame] | 284 | // Implements DataChannelProviderInterface. |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame] | 285 | bool SendData(const cricket::SendDataParams& params, |
jbauch | eec21bd | 2016-03-20 06:15:43 -0700 | [diff] [blame] | 286 | const rtc::CopyOnWriteBuffer& payload, |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame] | 287 | cricket::SendDataResult* result) override; |
| 288 | bool ConnectDataChannel(DataChannel* webrtc_data_channel) override; |
| 289 | void DisconnectDataChannel(DataChannel* webrtc_data_channel) override; |
| 290 | void AddSctpDataStream(int sid) override; |
| 291 | void RemoveSctpDataStream(int sid) override; |
| 292 | bool ReadyToSendData() const override; |
wu@webrtc.org | 7818752 | 2013-10-07 23:32:02 +0000 | [diff] [blame] | 293 | |
pthatcher@webrtc.org | c04a97f | 2015-03-16 19:31:40 +0000 | [diff] [blame] | 294 | // Returns stats for all channels of all transports. |
| 295 | // This avoids exposing the internal structures used to track them. |
hbos | df6075a | 2016-12-19 04:58:02 -0800 | [diff] [blame] | 296 | // The parameterless version creates |ChannelNamePairs| from |voice_channel|, |
| 297 | // |video_channel| and |voice_channel| if available - this requires it to be |
| 298 | // called on the signaling thread - and invokes the other |GetStats|. The |
| 299 | // other |GetStats| can be invoked on any thread; if not invoked on the |
| 300 | // network thread a thread hop will happen. |
| 301 | std::unique_ptr<SessionStats> GetStats_s(); |
| 302 | virtual std::unique_ptr<SessionStats> GetStats( |
| 303 | const ChannelNamePairs& channel_name_pairs); |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 304 | |
| 305 | // virtual so it can be mocked in unit tests |
| 306 | virtual bool GetLocalCertificate( |
| 307 | const std::string& transport_name, |
| 308 | rtc::scoped_refptr<rtc::RTCCertificate>* certificate); |
| 309 | |
| 310 | // Caller owns returned certificate |
jbauch | 555604a | 2016-04-26 03:13:22 -0700 | [diff] [blame] | 311 | virtual std::unique_ptr<rtc::SSLCertificate> GetRemoteSSLCertificate( |
kwiberg | b4d01c4 | 2016-04-06 05:15:06 -0700 | [diff] [blame] | 312 | const std::string& transport_name); |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 313 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 314 | cricket::DataChannelType data_channel_type() const; |
| 315 | |
deadbeef | d1a38b5 | 2016-12-10 13:15:33 -0800 | [diff] [blame] | 316 | // Returns true if there was an ICE restart initiated by the remote offer. |
deadbeef | 0ed85b2 | 2016-02-23 17:24:52 -0800 | [diff] [blame] | 317 | bool IceRestartPending(const std::string& content_name) const; |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 318 | |
deadbeef | d1a38b5 | 2016-12-10 13:15:33 -0800 | [diff] [blame] | 319 | // Set the "needs-ice-restart" flag as described in JSEP. After the flag is |
| 320 | // set, offers should generate new ufrags/passwords until an ICE restart |
| 321 | // occurs. |
| 322 | void SetNeedsIceRestartFlag(); |
| 323 | // Returns true if the ICE restart flag above was set, and no ICE restart has |
| 324 | // occurred yet for this transport (by applying a local description with |
| 325 | // changed ufrag/password). If the transport has been deleted as a result of |
| 326 | // bundling, returns false. |
| 327 | bool NeedsIceRestart(const std::string& content_name) const; |
| 328 | |
Henrik Boström | d828198 | 2015-08-27 10:12:24 +0200 | [diff] [blame] | 329 | // Called when an RTCCertificate is generated or retrieved by |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 330 | // WebRTCSessionDescriptionFactory. Should happen before setLocalDescription. |
Henrik Boström | d828198 | 2015-08-27 10:12:24 +0200 | [diff] [blame] | 331 | void OnCertificateReady( |
| 332 | const rtc::scoped_refptr<rtc::RTCCertificate>& certificate); |
deadbeef | 953c2ce | 2017-01-09 14:53:41 -0800 | [diff] [blame] | 333 | void OnDtlsSrtpSetupFailure(cricket::BaseChannel*, bool rtcp); |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 334 | |
| 335 | // For unit test. |
Henrik Boström | d828198 | 2015-08-27 10:12:24 +0200 | [diff] [blame] | 336 | bool waiting_for_certificate_for_testing() const; |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 337 | const rtc::scoped_refptr<rtc::RTCCertificate>& certificate_for_testing(); |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 338 | |
guoweis@webrtc.org | 7169afd | 2014-12-04 17:59:29 +0000 | [diff] [blame] | 339 | void set_metrics_observer( |
| 340 | webrtc::MetricsObserverInterface* metrics_observer) { |
| 341 | metrics_observer_ = metrics_observer; |
Honghai Zhang | d93f50c | 2016-10-05 11:47:22 -0700 | [diff] [blame] | 342 | transport_controller_->SetMetricsObserver(metrics_observer); |
guoweis@webrtc.org | 7169afd | 2014-12-04 17:59:29 +0000 | [diff] [blame] | 343 | } |
| 344 | |
deadbeef | 953c2ce | 2017-01-09 14:53:41 -0800 | [diff] [blame] | 345 | // Called when voice_channel_, video_channel_ and |
| 346 | // rtp_data_channel_/sctp_transport_ are created and destroyed. As a result |
| 347 | // of, for example, setting a new description. |
deadbeef | ab9b2d1 | 2015-10-14 11:33:11 -0700 | [diff] [blame] | 348 | sigslot::signal0<> SignalVoiceChannelCreated; |
| 349 | sigslot::signal0<> SignalVoiceChannelDestroyed; |
| 350 | sigslot::signal0<> SignalVideoChannelCreated; |
| 351 | sigslot::signal0<> SignalVideoChannelDestroyed; |
| 352 | sigslot::signal0<> SignalDataChannelCreated; |
| 353 | sigslot::signal0<> SignalDataChannelDestroyed; |
| 354 | |
| 355 | // Called when a valid data channel OPEN message is received. |
| 356 | // std::string represents the data channel label. |
| 357 | sigslot::signal2<const std::string&, const InternalDataChannelInit&> |
| 358 | SignalDataChannelOpenMessage; |
zhihuang | 9763d56 | 2016-08-05 11:14:50 -0700 | [diff] [blame] | 359 | #ifdef HAVE_QUIC |
| 360 | QuicDataTransport* quic_data_transport() { |
| 361 | return quic_data_transport_.get(); |
| 362 | } |
| 363 | #endif // HAVE_QUIC |
deadbeef | ab9b2d1 | 2015-10-14 11:33:11 -0700 | [diff] [blame] | 364 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 365 | private: |
| 366 | // Indicates the type of SessionDescription in a call to SetLocalDescription |
| 367 | // and SetRemoteDescription. |
| 368 | enum Action { |
| 369 | kOffer, |
| 370 | kPrAnswer, |
| 371 | kAnswer, |
| 372 | }; |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 373 | |
deadbeef | fe4a8a4 | 2016-12-20 17:56:17 -0800 | [diff] [blame] | 374 | // Non-const versions of local_description()/remote_description(), for use |
| 375 | // internally. |
| 376 | SessionDescriptionInterface* mutable_local_description() { |
| 377 | return pending_local_description_ ? pending_local_description_.get() |
| 378 | : current_local_description_.get(); |
| 379 | } |
| 380 | SessionDescriptionInterface* mutable_remote_description() { |
| 381 | return pending_remote_description_ ? pending_remote_description_.get() |
| 382 | : current_remote_description_.get(); |
| 383 | } |
| 384 | |
deadbeef | d59daf8 | 2015-10-14 15:02:44 -0700 | [diff] [blame] | 385 | // Log session state. |
| 386 | void LogState(State old_state, State new_state); |
| 387 | |
| 388 | // Updates the state, signaling if necessary. |
| 389 | virtual void SetState(State state); |
| 390 | |
| 391 | // Updates the error state, signaling if necessary. |
| 392 | // TODO(ronghuawu): remove the SetError method that doesn't take |error_desc|. |
| 393 | virtual void SetError(Error error, const std::string& error_desc); |
| 394 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 395 | bool UpdateSessionState(Action action, cricket::ContentSource source, |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 396 | std::string* err_desc); |
| 397 | static Action GetAction(const std::string& type); |
pthatcher@webrtc.org | 592470b | 2015-03-16 21:15:37 +0000 | [diff] [blame] | 398 | // Push the media parts of the local or remote session description |
| 399 | // down to all of the channels. |
| 400 | bool PushdownMediaDescription(cricket::ContentAction action, |
| 401 | cricket::ContentSource source, |
| 402 | std::string* error_desc); |
deadbeef | 953c2ce | 2017-01-09 14:53:41 -0800 | [diff] [blame] | 403 | bool PushdownSctpParameters_n(cricket::ContentSource source); |
pthatcher@webrtc.org | 592470b | 2015-03-16 21:15:37 +0000 | [diff] [blame] | 404 | |
deadbeef | d59daf8 | 2015-10-14 15:02:44 -0700 | [diff] [blame] | 405 | bool PushdownTransportDescription(cricket::ContentSource source, |
| 406 | cricket::ContentAction action, |
| 407 | std::string* error_desc); |
| 408 | |
| 409 | // Helper methods to push local and remote transport descriptions. |
| 410 | bool PushdownLocalTransportDescription( |
| 411 | const cricket::SessionDescription* sdesc, |
| 412 | cricket::ContentAction action, |
| 413 | std::string* error_desc); |
| 414 | bool PushdownRemoteTransportDescription( |
| 415 | const cricket::SessionDescription* sdesc, |
| 416 | cricket::ContentAction action, |
| 417 | std::string* error_desc); |
| 418 | |
| 419 | // Returns true and the TransportInfo of the given |content_name| |
| 420 | // from |description|. Returns false if it's not available. |
| 421 | static bool GetTransportDescription( |
| 422 | const cricket::SessionDescription* description, |
| 423 | const std::string& content_name, |
| 424 | cricket::TransportDescription* info); |
| 425 | |
skvlad | 6c87a67 | 2016-05-17 17:49:52 -0700 | [diff] [blame] | 426 | // Returns the name of the transport channel when BUNDLE is enabled, or |
| 427 | // nullptr if the channel is not part of any bundle. |
| 428 | const std::string* GetBundleTransportName( |
| 429 | const cricket::ContentInfo* content, |
| 430 | const cricket::ContentGroup* bundle); |
| 431 | |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 432 | // Cause all the BaseChannels in the bundle group to have the same |
| 433 | // transport channel. |
| 434 | bool EnableBundle(const cricket::ContentGroup& bundle); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 435 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 436 | // Enables media channels to allow sending of media. |
| 437 | void EnableChannels(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 438 | // Returns the media index for a local ice candidate given the content name. |
| 439 | // Returns false if the local session description does not have a media |
| 440 | // content called |content_name|. |
| 441 | bool GetLocalCandidateMediaIndex(const std::string& content_name, |
| 442 | int* sdp_mline_index); |
| 443 | // Uses all remote candidates in |remote_desc| in this session. |
| 444 | bool UseCandidatesInSessionDescription( |
| 445 | const SessionDescriptionInterface* remote_desc); |
| 446 | // Uses |candidate| in this session. |
| 447 | bool UseCandidate(const IceCandidateInterface* candidate); |
| 448 | // Deletes the corresponding channel of contents that don't exist in |desc|. |
| 449 | // |desc| can be null. This means that all channels are deleted. |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 450 | void RemoveUnusedChannels(const cricket::SessionDescription* desc); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 451 | |
| 452 | // Allocates media channels based on the |desc|. If |desc| doesn't have |
| 453 | // the BUNDLE option, this method will disable BUNDLE in PortAllocator. |
| 454 | // This method will also delete any existing media channels before creating. |
| 455 | bool CreateChannels(const cricket::SessionDescription* desc); |
| 456 | |
| 457 | // Helper methods to create media channels. |
skvlad | 6c87a67 | 2016-05-17 17:49:52 -0700 | [diff] [blame] | 458 | bool CreateVoiceChannel(const cricket::ContentInfo* content, |
| 459 | const std::string* bundle_transport); |
| 460 | bool CreateVideoChannel(const cricket::ContentInfo* content, |
| 461 | const std::string* bundle_transport); |
| 462 | bool CreateDataChannel(const cricket::ContentInfo* content, |
| 463 | const std::string* bundle_transport); |
henrike@webrtc.org | 1e09a71 | 2013-07-26 19:17:59 +0000 | [diff] [blame] | 464 | |
hbos | df6075a | 2016-12-19 04:58:02 -0800 | [diff] [blame] | 465 | std::unique_ptr<SessionStats> GetStats_n( |
| 466 | const ChannelNamePairs& channel_name_pairs); |
| 467 | |
deadbeef | 953c2ce | 2017-01-09 14:53:41 -0800 | [diff] [blame] | 468 | bool CreateSctpTransport_n(const std::string& content_name, |
| 469 | const std::string& transport_name); |
| 470 | // For bundling. |
| 471 | void ChangeSctpTransport_n(const std::string& transport_name); |
| 472 | void DestroySctpTransport_n(); |
| 473 | // SctpTransport signal handlers. Needed to marshal signals from the network |
| 474 | // to signaling thread. |
| 475 | void OnSctpTransportReadyToSendData_n(); |
| 476 | // This may be called with "false" if the direction of the m= section causes |
| 477 | // us to tear down the SCTP connection. |
| 478 | void OnSctpTransportReadyToSendData_s(bool ready); |
| 479 | void OnSctpTransportDataReceived_n(const cricket::ReceiveDataParams& params, |
| 480 | const rtc::CopyOnWriteBuffer& payload); |
| 481 | // Beyond just firing the signal to the signaling thread, listens to SCTP |
| 482 | // CONTROL messages on unused SIDs and processes them as OPEN messages. |
| 483 | void OnSctpTransportDataReceived_s(const cricket::ReceiveDataParams& params, |
| 484 | const rtc::CopyOnWriteBuffer& payload); |
| 485 | void OnSctpStreamClosedRemotely_n(int sid); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 486 | |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 487 | std::string BadStateErrMsg(State state); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 488 | void SetIceConnectionState(PeerConnectionInterface::IceConnectionState state); |
Peter Thatcher | 5436051 | 2015-07-08 11:08:35 -0700 | [diff] [blame] | 489 | void SetIceConnectionReceiving(bool receiving); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 490 | |
sergeyu@chromium.org | 0be6aa0 | 2013-08-23 23:21:25 +0000 | [diff] [blame] | 491 | bool ValidateBundleSettings(const cricket::SessionDescription* desc); |
henrike@webrtc.org | 1e09a71 | 2013-07-26 19:17:59 +0000 | [diff] [blame] | 492 | bool HasRtcpMuxEnabled(const cricket::ContentInfo* content); |
sergeyu@chromium.org | 0be6aa0 | 2013-08-23 23:21:25 +0000 | [diff] [blame] | 493 | // Below methods are helper methods which verifies SDP. |
| 494 | bool ValidateSessionDescription(const SessionDescriptionInterface* sdesc, |
| 495 | cricket::ContentSource source, |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 496 | std::string* err_desc); |
sergeyu@chromium.org | 0be6aa0 | 2013-08-23 23:21:25 +0000 | [diff] [blame] | 497 | |
| 498 | // Check if a call to SetLocalDescription is acceptable with |action|. |
| 499 | bool ExpectSetLocalDescription(Action action); |
| 500 | // Check if a call to SetRemoteDescription is acceptable with |action|. |
| 501 | bool ExpectSetRemoteDescription(Action action); |
| 502 | // Verifies a=setup attribute as per RFC 5763. |
| 503 | bool ValidateDtlsSetupAttribute(const cricket::SessionDescription* desc, |
| 504 | Action action); |
henrike@webrtc.org | 1e09a71 | 2013-07-26 19:17:59 +0000 | [diff] [blame] | 505 | |
jiayl@webrtc.org | e10d28c | 2014-07-17 17:07:49 +0000 | [diff] [blame] | 506 | // Returns true if we are ready to push down the remote candidate. |
| 507 | // |remote_desc| is the new remote description, or NULL if the current remote |
| 508 | // description should be used. Output |valid| is true if the candidate media |
| 509 | // index is valid. |
| 510 | bool ReadyToUseRemoteCandidate(const IceCandidateInterface* candidate, |
| 511 | const SessionDescriptionInterface* remote_desc, |
| 512 | bool* valid); |
| 513 | |
deadbeef | 7af91dd | 2016-12-13 11:29:11 -0800 | [diff] [blame] | 514 | // Returns true if SRTP (either using DTLS-SRTP or SDES) is required by |
| 515 | // this session. |
| 516 | bool SrtpRequired() const; |
| 517 | |
deadbeef | 953c2ce | 2017-01-09 14:53:41 -0800 | [diff] [blame] | 518 | // TransportController signal handlers. |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 519 | void OnTransportControllerConnectionState(cricket::IceConnectionState state); |
| 520 | void OnTransportControllerReceiving(bool receiving); |
| 521 | void OnTransportControllerGatheringState(cricket::IceGatheringState state); |
| 522 | void OnTransportControllerCandidatesGathered( |
| 523 | const std::string& transport_name, |
Honghai Zhang | 7fb69db | 2016-03-14 11:59:18 -0700 | [diff] [blame] | 524 | const std::vector<cricket::Candidate>& candidates); |
| 525 | void OnTransportControllerCandidatesRemoved( |
| 526 | const std::vector<cricket::Candidate>& candidates); |
deadbeef | 953c2ce | 2017-01-09 14:53:41 -0800 | [diff] [blame] | 527 | void OnTransportControllerDtlsHandshakeError(rtc::SSLHandshakeError error); |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 528 | |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 529 | std::string GetSessionErrorMsg(); |
| 530 | |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 531 | // Invoked when TransportController connection completion is signaled. |
| 532 | // Reports stats for all transports in use. |
| 533 | void ReportTransportStats(); |
| 534 | |
| 535 | // Gather the usage of IPv4/IPv6 as best connection. |
jbauch | ac8869e | 2015-07-03 01:36:14 -0700 | [diff] [blame] | 536 | void ReportBestConnectionState(const cricket::TransportStats& stats); |
| 537 | |
| 538 | void ReportNegotiatedCiphers(const cricket::TransportStats& stats); |
guoweis@webrtc.org | 7169afd | 2014-12-04 17:59:29 +0000 | [diff] [blame] | 539 | |
Danil Chapovalov | 33b01f2 | 2016-05-11 19:55:27 +0200 | [diff] [blame] | 540 | void OnSentPacket_w(const rtc::SentPacket& sent_packet); |
stefan | c1aeaf0 | 2015-10-15 07:26:07 -0700 | [diff] [blame] | 541 | |
zhihuang | 9763d56 | 2016-08-05 11:14:50 -0700 | [diff] [blame] | 542 | const std::string GetTransportName(const std::string& content_name); |
| 543 | |
deadbeef | ac22f70 | 2017-01-12 21:59:29 -0800 | [diff] [blame] | 544 | void DestroyRtcpTransport_n(const std::string& transport_name); |
zhihuang | f5b251b | 2017-01-12 19:37:48 -0800 | [diff] [blame] | 545 | void DestroyVideoChannel(); |
| 546 | void DestroyVoiceChannel(); |
| 547 | void DestroyDataChannel(); |
| 548 | |
zhihuang | 9763d56 | 2016-08-05 11:14:50 -0700 | [diff] [blame] | 549 | rtc::Thread* const network_thread_; |
deadbeef | d59daf8 | 2015-10-14 15:02:44 -0700 | [diff] [blame] | 550 | rtc::Thread* const worker_thread_; |
danilchap | e9021a3 | 2016-05-17 01:52:02 -0700 | [diff] [blame] | 551 | rtc::Thread* const signaling_thread_; |
deadbeef | d59daf8 | 2015-10-14 15:02:44 -0700 | [diff] [blame] | 552 | |
| 553 | State state_ = STATE_INIT; |
| 554 | Error error_ = ERROR_NONE; |
| 555 | std::string error_desc_; |
| 556 | |
| 557 | const std::string sid_; |
| 558 | bool initial_offerer_ = false; |
| 559 | |
hbos | df6075a | 2016-12-19 04:58:02 -0800 | [diff] [blame] | 560 | const std::unique_ptr<cricket::TransportController> transport_controller_; |
deadbeef | 953c2ce | 2017-01-09 14:53:41 -0800 | [diff] [blame] | 561 | const std::unique_ptr<cricket::SctpTransportInternalFactory> sctp_factory_; |
stefan | c1aeaf0 | 2015-10-15 07:26:07 -0700 | [diff] [blame] | 562 | MediaControllerInterface* media_controller_; |
kwiberg | d1fe281 | 2016-04-27 06:47:29 -0700 | [diff] [blame] | 563 | std::unique_ptr<cricket::VoiceChannel> voice_channel_; |
| 564 | std::unique_ptr<cricket::VideoChannel> video_channel_; |
deadbeef | 953c2ce | 2017-01-09 14:53:41 -0800 | [diff] [blame] | 565 | // |rtp_data_channel_| is used if in RTP data channel mode, |sctp_transport_| |
| 566 | // when using SCTP. |
| 567 | std::unique_ptr<cricket::RtpDataChannel> rtp_data_channel_; |
| 568 | |
| 569 | std::unique_ptr<cricket::SctpTransportInternal> sctp_transport_; |
| 570 | // |sctp_transport_name_| keeps track of what DTLS transport the SCTP |
| 571 | // transport is using (which can change due to bundling). |
| 572 | rtc::Optional<std::string> sctp_transport_name_; |
| 573 | // |sctp_content_name_| is the content name (MID) in SDP. |
| 574 | rtc::Optional<std::string> sctp_content_name_; |
| 575 | // Value cached on signaling thread. Only updated when SctpReadyToSendData |
| 576 | // fires on the signaling thread. |
| 577 | bool sctp_ready_to_send_data_ = false; |
| 578 | // Same as signals provided by SctpTransport, but these are guaranteed to |
| 579 | // fire on the signaling thread, whereas SctpTransport fires on the networking |
| 580 | // thread. |
| 581 | // |sctp_invoker_| is used so that any signals queued on the signaling thread |
| 582 | // from the network thread are immediately discarded if the SctpTransport is |
| 583 | // destroyed (due to m= section being rejected). |
| 584 | // TODO(deadbeef): Use a proxy object to ensure that method calls/signals |
| 585 | // are marshalled to the right thread. Could almost use proxy.h for this, |
| 586 | // but it doesn't have a mechanism for marshalling sigslot::signals |
| 587 | std::unique_ptr<rtc::AsyncInvoker> sctp_invoker_; |
| 588 | sigslot::signal1<bool> SignalSctpReadyToSendData; |
| 589 | sigslot::signal2<const cricket::ReceiveDataParams&, |
| 590 | const rtc::CopyOnWriteBuffer&> |
| 591 | SignalSctpDataReceived; |
| 592 | sigslot::signal1<int> SignalSctpStreamClosedRemotely; |
| 593 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 594 | cricket::ChannelManager* channel_manager_; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 595 | IceObserver* ice_observer_; |
| 596 | PeerConnectionInterface::IceConnectionState ice_connection_state_; |
Peter Thatcher | 5436051 | 2015-07-08 11:08:35 -0700 | [diff] [blame] | 597 | bool ice_connection_receiving_; |
deadbeef | fe4a8a4 | 2016-12-20 17:56:17 -0800 | [diff] [blame] | 598 | std::unique_ptr<SessionDescriptionInterface> current_local_description_; |
| 599 | std::unique_ptr<SessionDescriptionInterface> pending_local_description_; |
| 600 | std::unique_ptr<SessionDescriptionInterface> current_remote_description_; |
| 601 | std::unique_ptr<SessionDescriptionInterface> pending_remote_description_; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 602 | // If the remote peer is using a older version of implementation. |
| 603 | bool older_version_remote_peer_; |
mallinath@webrtc.org | a27be8e | 2013-09-27 23:04:10 +0000 | [diff] [blame] | 604 | bool dtls_enabled_; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 605 | // Specifies which kind of data channel is allowed. This is controlled |
| 606 | // by the chrome command-line flag and constraints: |
| 607 | // 1. If chrome command-line switch 'enable-sctp-data-channels' is enabled, |
| 608 | // constraint kEnableDtlsSrtp is true, and constaint kEnableRtpDataChannels is |
| 609 | // not set or false, SCTP is allowed (DCT_SCTP); |
| 610 | // 2. If constraint kEnableRtpDataChannels is true, RTP is allowed (DCT_RTP); |
| 611 | // 3. If both 1&2 are false, data channel is not allowed (DCT_NONE). |
zhihuang | 9763d56 | 2016-08-05 11:14:50 -0700 | [diff] [blame] | 612 | // The data channel type could be DCT_QUIC if the QUIC data channel is |
| 613 | // enabled. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 614 | cricket::DataChannelType data_channel_type_; |
deadbeef | 0ed85b2 | 2016-02-23 17:24:52 -0800 | [diff] [blame] | 615 | // List of content names for which the remote side triggered an ICE restart. |
| 616 | std::set<std::string> pending_ice_restarts_; |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 617 | |
kwiberg | d1fe281 | 2016-04-27 06:47:29 -0700 | [diff] [blame] | 618 | std::unique_ptr<WebRtcSessionDescriptionFactory> webrtc_session_desc_factory_; |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 619 | |
henrike@webrtc.org | 6e3dbc2 | 2014-03-25 17:09:47 +0000 | [diff] [blame] | 620 | // Member variables for caching global options. |
| 621 | cricket::AudioOptions audio_options_; |
| 622 | cricket::VideoOptions video_options_; |
guoweis@webrtc.org | 7169afd | 2014-12-04 17:59:29 +0000 | [diff] [blame] | 623 | MetricsObserverInterface* metrics_observer_; |
henrike@webrtc.org | 6e3dbc2 | 2014-03-25 17:09:47 +0000 | [diff] [blame] | 624 | |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 625 | // Declares the bundle policy for the WebRTCSession. |
| 626 | PeerConnectionInterface::BundlePolicy bundle_policy_; |
| 627 | |
Peter Thatcher | af55ccc | 2015-05-21 07:48:41 -0700 | [diff] [blame] | 628 | // Declares the RTCP mux policy for the WebRTCSession. |
| 629 | PeerConnectionInterface::RtcpMuxPolicy rtcp_mux_policy_; |
| 630 | |
zhihuang | 184a3fd | 2016-06-14 11:47:14 -0700 | [diff] [blame] | 631 | bool received_first_video_packet_ = false; |
| 632 | bool received_first_audio_packet_ = false; |
| 633 | |
zhihuang | 9763d56 | 2016-08-05 11:14:50 -0700 | [diff] [blame] | 634 | #ifdef HAVE_QUIC |
| 635 | std::unique_ptr<QuicDataTransport> quic_data_transport_; |
| 636 | #endif // HAVE_QUIC |
| 637 | |
henrikg | 3c089d7 | 2015-09-16 05:37:44 -0700 | [diff] [blame] | 638 | RTC_DISALLOW_COPY_AND_ASSIGN(WebRtcSession); |
wu@webrtc.org | 364f204 | 2013-11-20 21:49:41 +0000 | [diff] [blame] | 639 | }; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 640 | } // namespace webrtc |
| 641 | |
ossu | 7bb87ee | 2017-01-23 04:56:25 -0800 | [diff] [blame] | 642 | #endif // WEBRTC_PC_WEBRTCSESSION_H_ |