| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2004 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2004 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 // Both RTP and RTCP channels are set, we can call SetInterface on | 221 // Both RTP and RTCP channels are set, we can call SetInterface on |
| 222 // media channel and it can set network options. | 222 // media channel and it can set network options. |
| 223 RTC_DCHECK(worker_thread_->IsCurrent()); | 223 RTC_DCHECK(worker_thread_->IsCurrent()); |
| 224 media_channel_->SetInterface(this); | 224 media_channel_->SetInterface(this); |
| 225 return true; | 225 return true; |
| 226 } | 226 } |
| 227 | 227 |
| 228 bool BaseChannel::InitNetwork_n(TransportChannel* rtp_transport, | 228 bool BaseChannel::InitNetwork_n(TransportChannel* rtp_transport, |
| 229 TransportChannel* rtcp_transport) { | 229 TransportChannel* rtcp_transport) { |
| 230 RTC_DCHECK(network_thread_->IsCurrent()); | 230 RTC_DCHECK(network_thread_->IsCurrent()); |
| 231 // const std::string& transport_name = | 231 SetTransport_n(rtp_transport, rtcp_transport); |
| 232 // (bundle_transport_name ? *bundle_transport_name : content_name()); | |
| 233 if (!SetTransport_n(rtp_transport, rtcp_transport)) { | |
| 234 return false; | |
| 235 } | |
| 236 | 232 |
| 237 if (!SetDtlsSrtpCryptoSuites_n(rtp_transport_, false)) { | 233 if (!SetDtlsSrtpCryptoSuites_n(rtp_transport_, false)) { |
| 238 return false; | 234 return false; |
| 239 } | 235 } |
| 240 if (rtcp_transport_ && !SetDtlsSrtpCryptoSuites_n(rtcp_transport_, true)) { | 236 if (rtcp_transport_ && !SetDtlsSrtpCryptoSuites_n(rtcp_transport_, true)) { |
| 241 return false; | 237 return false; |
| 242 } | 238 } |
| 243 if (rtcp_mux_required_) { | 239 if (rtcp_mux_required_) { |
| 244 rtcp_mux_filter_.SetActive(); | 240 rtcp_mux_filter_.SetActive(); |
| 245 } | 241 } |
| 246 return true; | 242 return true; |
| 247 } | 243 } |
| 248 | 244 |
| 249 void BaseChannel::Deinit() { | 245 void BaseChannel::Deinit() { |
| 250 RTC_DCHECK(worker_thread_->IsCurrent()); | 246 RTC_DCHECK(worker_thread_->IsCurrent()); |
| 251 media_channel_->SetInterface(NULL); | 247 media_channel_->SetInterface(NULL); |
| 252 // Packets arrive on the network thread, processing packets calls virtual | 248 // Packets arrive on the network thread, processing packets calls virtual |
| 253 // functions, so need to stop this process in Deinit that is called in | 249 // functions, so need to stop this process in Deinit that is called in |
| 254 // derived classes destructor. | 250 // derived classes destructor. |
| 255 network_thread_->Invoke<void>( | 251 network_thread_->Invoke<void>( |
| 256 RTC_FROM_HERE, Bind(&BaseChannel::DisconnectTransportChannels_n, this)); | 252 RTC_FROM_HERE, Bind(&BaseChannel::DisconnectTransportChannels_n, this)); |
| 257 } | 253 } |
| 258 | 254 |
| 259 bool BaseChannel::SetTransport(TransportChannel* rtp_transport, | 255 void BaseChannel::SetTransports(TransportChannel* rtp_transport, |
| 260 TransportChannel* rtcp_transport) { | 256 TransportChannel* rtcp_transport) { |
| 261 return network_thread_->Invoke<bool>( | 257 network_thread_->Invoke<void>( |
| 262 RTC_FROM_HERE, | 258 RTC_FROM_HERE, |
| 263 Bind(&BaseChannel::SetTransport_n, this, rtp_transport, rtcp_transport)); | 259 Bind(&BaseChannel::SetTransport_n, this, rtp_transport, rtcp_transport)); |
| 264 } | 260 } |
| 265 | 261 |
| 266 bool BaseChannel::SetTransport_n(TransportChannel* rtp_transport, | 262 void BaseChannel::SetTransport_n(TransportChannel* rtp_transport, |
| 267 TransportChannel* rtcp_transport) { | 263 TransportChannel* rtcp_transport) { |
| 268 RTC_DCHECK(network_thread_->IsCurrent()); | 264 RTC_DCHECK(network_thread_->IsCurrent()); |
| 269 if (!rtp_transport && !rtcp_transport) { | 265 // Verify some assumptions (as described in the comment above SetTransport). |
| 270 LOG(LS_ERROR) << "Setting nullptr to RTP Transport and RTCP Transport."; | 266 RTC_DCHECK(rtp_transport); |
| 271 return false; | 267 RTC_DCHECK(NeedsRtcpTransport() == (rtcp_transport != nullptr)); |
| 272 } | |
| 273 | |
| 274 if (rtcp_transport) { | 268 if (rtcp_transport) { |
| 275 RTC_DCHECK(rtp_transport->transport_name() == | 269 RTC_DCHECK(rtp_transport->transport_name() == |
| 276 rtcp_transport->transport_name()); | 270 rtcp_transport->transport_name()); |
| 277 RTC_DCHECK(NeedsRtcpTransport()); | |
| 278 } | 271 } |
| 279 | 272 |
| 280 if (rtp_transport->transport_name() == transport_name_) { | 273 if (rtp_transport->transport_name() == transport_name_) { |
| 281 // Nothing to do if transport name isn't changing. | 274 // Nothing to do if transport name isn't changing. |
| 282 return true; | 275 return; |
| 283 } | 276 } |
| 284 | 277 |
| 285 transport_name_ = rtp_transport->transport_name(); | 278 transport_name_ = rtp_transport->transport_name(); |
| 286 | 279 |
| 287 // When using DTLS-SRTP, we must reset the SrtpFilter every time the transport | 280 // When using DTLS-SRTP, we must reset the SrtpFilter every time the transport |
| 288 // changes and wait until the DTLS handshake is complete to set the newly | 281 // changes and wait until the DTLS handshake is complete to set the newly |
| 289 // negotiated parameters. | 282 // negotiated parameters. |
| 290 if (ShouldSetupDtlsSrtp_n()) { | 283 if (ShouldSetupDtlsSrtp_n()) { |
| 291 // Set |writable_| to false such that UpdateWritableState_w can set up | 284 // Set |writable_| to false such that UpdateWritableState_w can set up |
| 292 // DTLS-SRTP when |writable_| becomes true again. | 285 // DTLS-SRTP when |writable_| becomes true again. |
| 293 writable_ = false; | 286 writable_ = false; |
| 294 srtp_filter_.ResetParams(); | 287 srtp_filter_.ResetParams(); |
| 295 } | 288 } |
| 296 | 289 |
| 297 // If this BaseChannel doesn't require RTCP mux and we haven't fully | 290 // If this BaseChannel doesn't require RTCP mux and we haven't fully |
| 298 // negotiated RTCP mux, we need an RTCP transport. | 291 // negotiated RTCP mux, we need an RTCP transport. |
| 299 if (NeedsRtcpTransport()) { | 292 if (NeedsRtcpTransport()) { |
| 300 LOG(LS_INFO) << "Setting RTCP Transport for " << content_name() << " on " | 293 LOG(LS_INFO) << "Setting RTCP Transport for " << content_name() << " on " |
| 301 << transport_name() << " transport " << rtcp_transport; | 294 << transport_name() << " transport " << rtcp_transport; |
| 302 SetTransportChannel_n(true, rtcp_transport); | 295 SetTransportChannel_n(true, rtcp_transport); |
| 303 if (!rtcp_transport_) { | 296 RTC_DCHECK(rtcp_transport_); |
| 304 return false; | |
| 305 } | |
| 306 } | 297 } |
| 307 | 298 |
| 308 LOG(LS_INFO) << "Setting non-RTCP Transport for " << content_name() << " on " | 299 LOG(LS_INFO) << "Setting non-RTCP Transport for " << content_name() << " on " |
| 309 << transport_name() << " transport " << rtp_transport; | 300 << transport_name() << " transport " << rtp_transport; |
| 310 SetTransportChannel_n(false, rtp_transport); | 301 SetTransportChannel_n(false, rtp_transport); |
| 311 if (!rtp_transport_) { | 302 RTC_DCHECK(rtp_transport_); |
| 312 return false; | |
| 313 } | |
| 314 | 303 |
| 315 // Update aggregate writable/ready-to-send state between RTP and RTCP upon | 304 // Update aggregate writable/ready-to-send state between RTP and RTCP upon |
| 316 // setting new transport channels. | 305 // setting new transport channels. |
| 317 UpdateWritableState_n(); | 306 UpdateWritableState_n(); |
| 318 // We can only update ready-to-send after updating writability. | 307 // We can only update ready-to-send after updating writability. |
| 319 // | 308 // |
| 320 // On setting a new channel, assume it's ready to send if it's writable, | 309 // On setting a new channel, assume it's ready to send if it's writable, |
| 321 // because we have no way of knowing otherwise (the channel doesn't give us | 310 // because we have no way of knowing otherwise (the channel doesn't give us |
| 322 // "was last send successful?"). | 311 // "was last send successful?"). |
| 323 // | 312 // |
| 324 // This won't always be accurate (the last SendPacket call from another | 313 // This won't always be accurate (the last SendPacket call from another |
| 325 // BaseChannel could have resulted in an error), but even so, we'll just | 314 // BaseChannel could have resulted in an error), but even so, we'll just |
| 326 // encounter the error again and update "ready to send" accordingly. | 315 // encounter the error again and update "ready to send" accordingly. |
| 327 SetTransportChannelReadyToSend(false, | 316 SetTransportChannelReadyToSend(false, |
| 328 rtp_transport_ && rtp_transport_->writable()); | 317 rtp_transport_ && rtp_transport_->writable()); |
| 329 SetTransportChannelReadyToSend( | 318 SetTransportChannelReadyToSend( |
| 330 true, rtcp_transport_ && rtcp_transport_->writable()); | 319 true, rtcp_transport_ && rtcp_transport_->writable()); |
| 331 return true; | |
| 332 } | 320 } |
| 333 | 321 |
| 334 void BaseChannel::SetTransportChannel_n(bool rtcp, | 322 void BaseChannel::SetTransportChannel_n(bool rtcp, |
| 335 TransportChannel* new_transport) { | 323 TransportChannel* new_transport) { |
| 336 RTC_DCHECK(network_thread_->IsCurrent()); | 324 RTC_DCHECK(network_thread_->IsCurrent()); |
| 337 TransportChannel*& old_transport = rtcp ? rtcp_transport_ : rtp_transport_; | 325 TransportChannel*& old_transport = rtcp ? rtcp_transport_ : rtp_transport_; |
| 338 if (!old_transport && !new_transport) { | 326 if (!old_transport && !new_transport) { |
| 339 // Nothing to do. | 327 // Nothing to do. |
| 340 return; | 328 return; |
| 341 } | 329 } |
| (...skipping 2047 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2389 signaling_thread()->Post(RTC_FROM_HERE, this, MSG_READYTOSENDDATA, | 2377 signaling_thread()->Post(RTC_FROM_HERE, this, MSG_READYTOSENDDATA, |
| 2390 new DataChannelReadyToSendMessageData(writable)); | 2378 new DataChannelReadyToSendMessageData(writable)); |
| 2391 } | 2379 } |
| 2392 | 2380 |
| 2393 void RtpDataChannel::GetSrtpCryptoSuites_n( | 2381 void RtpDataChannel::GetSrtpCryptoSuites_n( |
| 2394 std::vector<int>* crypto_suites) const { | 2382 std::vector<int>* crypto_suites) const { |
| 2395 GetSupportedDataCryptoSuites(crypto_options(), crypto_suites); | 2383 GetSupportedDataCryptoSuites(crypto_options(), crypto_suites); |
| 2396 } | 2384 } |
| 2397 | 2385 |
| 2398 } // namespace cricket | 2386 } // namespace cricket |
| OLD | NEW |