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