| 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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 LOG(LS_INFO) << "Destroyed channel: " << content_name_; | 191 LOG(LS_INFO) << "Destroyed channel: " << content_name_; |
| 192 } | 192 } |
| 193 | 193 |
| 194 void BaseChannel::DisconnectTransportChannels_n() { | 194 void BaseChannel::DisconnectTransportChannels_n() { |
| 195 // Send any outstanding RTCP packets. | 195 // Send any outstanding RTCP packets. |
| 196 FlushRtcpMessages_n(); | 196 FlushRtcpMessages_n(); |
| 197 | 197 |
| 198 // Stop signals from transport channels, but keep them alive because | 198 // Stop signals from transport channels, but keep them alive because |
| 199 // media_channel may use them from a different thread. | 199 // media_channel may use them from a different thread. |
| 200 if (rtp_dtls_transport_) { | 200 if (rtp_dtls_transport_) { |
| 201 DisconnectFromTransport(rtp_dtls_transport_); | 201 DisconnectFromDtlsTransport(rtp_dtls_transport_); |
| 202 } else if (rtp_packet_transport_) { |
| 203 DisconnectFromPacketTransport(rtp_packet_transport_); |
| 202 } | 204 } |
| 203 if (rtcp_dtls_transport_) { | 205 if (rtcp_dtls_transport_) { |
| 204 DisconnectFromTransport(rtcp_dtls_transport_); | 206 DisconnectFromDtlsTransport(rtcp_dtls_transport_); |
| 207 } else if (rtcp_packet_transport_) { |
| 208 DisconnectFromPacketTransport(rtcp_packet_transport_); |
| 205 } | 209 } |
| 206 | 210 |
| 207 // Clear pending read packets/messages. | 211 // Clear pending read packets/messages. |
| 208 network_thread_->Clear(&invoker_); | 212 network_thread_->Clear(&invoker_); |
| 209 network_thread_->Clear(this); | 213 network_thread_->Clear(this); |
| 210 } | 214 } |
| 211 | 215 |
| 212 bool BaseChannel::Init_w(DtlsTransportInternal* rtp_dtls_transport, | 216 bool BaseChannel::Init_w(DtlsTransportInternal* rtp_dtls_transport, |
| 213 DtlsTransportInternal* rtcp_dtls_transport) { | 217 DtlsTransportInternal* rtcp_dtls_transport, |
| 218 rtc::PacketTransportInterface* rtp_packet_transport, |
| 219 rtc::PacketTransportInterface* rtcp_packet_transport) { |
| 214 if (!network_thread_->Invoke<bool>( | 220 if (!network_thread_->Invoke<bool>( |
| 215 RTC_FROM_HERE, Bind(&BaseChannel::InitNetwork_n, this, | 221 RTC_FROM_HERE, Bind(&BaseChannel::InitNetwork_n, this, |
| 216 rtp_dtls_transport, rtcp_dtls_transport))) { | 222 rtp_dtls_transport, rtcp_dtls_transport, |
| 223 rtp_packet_transport, rtcp_packet_transport))) { |
| 217 return false; | 224 return false; |
| 218 } | 225 } |
| 219 | 226 // Both RTP and RTCP channels should be set, we can call SetInterface on |
| 220 // Both RTP and RTCP channels are set, we can call SetInterface on | 227 // the media channel and it can set network options. |
| 221 // media channel and it can set network options. | 228 RTC_DCHECK_RUN_ON(worker_thread_); |
| 222 RTC_DCHECK(worker_thread_->IsCurrent()); | |
| 223 media_channel_->SetInterface(this); | 229 media_channel_->SetInterface(this); |
| 224 return true; | 230 return true; |
| 225 } | 231 } |
| 226 | 232 |
| 227 bool BaseChannel::InitNetwork_n(DtlsTransportInternal* rtp_dtls_transport, | 233 bool BaseChannel::InitNetwork_n( |
| 228 DtlsTransportInternal* rtcp_dtls_transport) { | 234 DtlsTransportInternal* rtp_dtls_transport, |
| 235 DtlsTransportInternal* rtcp_dtls_transport, |
| 236 rtc::PacketTransportInterface* rtp_packet_transport, |
| 237 rtc::PacketTransportInterface* rtcp_packet_transport) { |
| 229 RTC_DCHECK(network_thread_->IsCurrent()); | 238 RTC_DCHECK(network_thread_->IsCurrent()); |
| 230 SetTransports_n(rtp_dtls_transport, rtcp_dtls_transport); | 239 SetTransports_n(rtp_dtls_transport, rtcp_dtls_transport, rtp_packet_transport, |
| 240 rtcp_packet_transport); |
| 231 | 241 |
| 232 if (!SetDtlsSrtpCryptoSuites_n(rtp_dtls_transport_, false)) { | 242 if (rtp_dtls_transport_ && |
| 243 !SetDtlsSrtpCryptoSuites_n(rtp_dtls_transport_, false)) { |
| 233 return false; | 244 return false; |
| 234 } | 245 } |
| 235 if (rtcp_dtls_transport_ && | 246 if (rtcp_dtls_transport_ && |
| 236 !SetDtlsSrtpCryptoSuites_n(rtcp_dtls_transport_, true)) { | 247 !SetDtlsSrtpCryptoSuites_n(rtcp_dtls_transport_, true)) { |
| 237 return false; | 248 return false; |
| 238 } | 249 } |
| 239 if (rtcp_mux_required_) { | 250 if (rtcp_mux_required_) { |
| 240 rtcp_mux_filter_.SetActive(); | 251 rtcp_mux_filter_.SetActive(); |
| 241 } | 252 } |
| 242 return true; | 253 return true; |
| 243 } | 254 } |
| 244 | 255 |
| 245 void BaseChannel::Deinit() { | 256 void BaseChannel::Deinit() { |
| 246 RTC_DCHECK(worker_thread_->IsCurrent()); | 257 RTC_DCHECK(worker_thread_->IsCurrent()); |
| 247 media_channel_->SetInterface(NULL); | 258 media_channel_->SetInterface(NULL); |
| 248 // Packets arrive on the network thread, processing packets calls virtual | 259 // Packets arrive on the network thread, processing packets calls virtual |
| 249 // functions, so need to stop this process in Deinit that is called in | 260 // functions, so need to stop this process in Deinit that is called in |
| 250 // derived classes destructor. | 261 // derived classes destructor. |
| 251 network_thread_->Invoke<void>( | 262 network_thread_->Invoke<void>( |
| 252 RTC_FROM_HERE, Bind(&BaseChannel::DisconnectTransportChannels_n, this)); | 263 RTC_FROM_HERE, Bind(&BaseChannel::DisconnectTransportChannels_n, this)); |
| 253 } | 264 } |
| 254 | 265 |
| 255 void BaseChannel::SetTransports(DtlsTransportInternal* rtp_dtls_transport, | 266 void BaseChannel::SetTransports(DtlsTransportInternal* rtp_dtls_transport, |
| 256 DtlsTransportInternal* rtcp_dtls_transport) { | 267 DtlsTransportInternal* rtcp_dtls_transport) { |
| 257 network_thread_->Invoke<void>(RTC_FROM_HERE, | 268 network_thread_->Invoke<void>( |
| 258 Bind(&BaseChannel::SetTransports_n, this, | 269 RTC_FROM_HERE, |
| 259 rtp_dtls_transport, rtcp_dtls_transport)); | 270 Bind(&BaseChannel::SetTransports_n, this, rtp_dtls_transport, |
| 271 rtcp_dtls_transport, rtp_dtls_transport, rtcp_dtls_transport)); |
| 260 } | 272 } |
| 261 | 273 |
| 262 void BaseChannel::SetTransports_n(DtlsTransportInternal* rtp_dtls_transport, | 274 void BaseChannel::SetTransports( |
| 263 DtlsTransportInternal* rtcp_dtls_transport) { | 275 rtc::PacketTransportInterface* rtp_packet_transport, |
| 276 rtc::PacketTransportInterface* rtcp_packet_transport) { |
| 277 network_thread_->Invoke<void>( |
| 278 RTC_FROM_HERE, Bind(&BaseChannel::SetTransports_n, this, nullptr, nullptr, |
| 279 rtp_packet_transport, rtcp_packet_transport)); |
| 280 } |
| 281 |
| 282 void BaseChannel::SetTransports_n( |
| 283 DtlsTransportInternal* rtp_dtls_transport, |
| 284 DtlsTransportInternal* rtcp_dtls_transport, |
| 285 rtc::PacketTransportInterface* rtp_packet_transport, |
| 286 rtc::PacketTransportInterface* rtcp_packet_transport) { |
| 264 RTC_DCHECK(network_thread_->IsCurrent()); | 287 RTC_DCHECK(network_thread_->IsCurrent()); |
| 265 if (!rtp_dtls_transport && !rtcp_dtls_transport) { | 288 // Validate some assertions about the input. |
| 266 LOG(LS_ERROR) << "Setting nullptr to RTP Transport and RTCP Transport."; | 289 RTC_DCHECK(rtp_packet_transport); |
| 267 return; | 290 RTC_DCHECK_EQ(NeedsRtcpTransport(), rtcp_packet_transport != nullptr); |
| 291 if (rtp_dtls_transport || rtcp_dtls_transport) { |
| 292 // DTLS/non-DTLS pointers should be to the same object. |
| 293 RTC_DCHECK(rtp_dtls_transport == rtp_packet_transport); |
| 294 RTC_DCHECK(rtcp_dtls_transport == rtcp_packet_transport); |
| 295 // Can't go from non-DTLS to DTLS. |
| 296 RTC_DCHECK(!rtp_packet_transport_ || rtp_dtls_transport_); |
| 297 } else { |
| 298 // Can't go from DTLS to non-DTLS. |
| 299 RTC_DCHECK(!rtp_dtls_transport_); |
| 268 } | 300 } |
| 269 | 301 // Transport names should be the same. |
| 270 if (rtp_dtls_transport && rtcp_dtls_transport) { | 302 if (rtp_dtls_transport && rtcp_dtls_transport) { |
| 271 RTC_DCHECK(rtp_dtls_transport->transport_name() == | 303 RTC_DCHECK(rtp_dtls_transport->transport_name() == |
| 272 rtcp_dtls_transport->transport_name()); | 304 rtcp_dtls_transport->transport_name()); |
| 273 RTC_DCHECK(NeedsRtcpTransport()); | |
| 274 } | 305 } |
| 275 | 306 std::string debug_name; |
| 276 std::string transport_name = rtp_dtls_transport | 307 if (rtp_dtls_transport) { |
| 277 ? rtp_dtls_transport->transport_name() | 308 transport_name_ = rtp_dtls_transport->transport_name(); |
| 278 : rtcp_dtls_transport->transport_name(); | 309 debug_name = transport_name_; |
| 279 if (transport_name == transport_name_) { | 310 } else { |
| 280 // Nothing to do if transport name isn't changing. | 311 debug_name = rtp_packet_transport->debug_name(); |
| 312 } |
| 313 if (rtp_packet_transport == rtp_packet_transport_) { |
| 314 // Nothing to do if transport isn't changing. |
| 281 return; | 315 return; |
| 282 } | 316 } |
| 283 | 317 |
| 284 transport_name_ = transport_name; | |
| 285 | |
| 286 // When using DTLS-SRTP, we must reset the SrtpFilter every time the transport | 318 // When using DTLS-SRTP, we must reset the SrtpFilter every time the transport |
| 287 // changes and wait until the DTLS handshake is complete to set the newly | 319 // changes and wait until the DTLS handshake is complete to set the newly |
| 288 // negotiated parameters. | 320 // negotiated parameters. |
| 289 if (ShouldSetupDtlsSrtp_n()) { | 321 if (ShouldSetupDtlsSrtp_n()) { |
| 290 // Set |writable_| to false such that UpdateWritableState_w can set up | 322 // Set |writable_| to false such that UpdateWritableState_w can set up |
| 291 // DTLS-SRTP when |writable_| becomes true again. | 323 // DTLS-SRTP when |writable_| becomes true again. |
| 292 writable_ = false; | 324 writable_ = false; |
| 293 srtp_filter_.ResetParams(); | 325 srtp_filter_.ResetParams(); |
| 294 } | 326 } |
| 295 | 327 |
| 296 // If this BaseChannel doesn't require RTCP mux and we haven't fully | 328 // If this BaseChannel doesn't require RTCP mux and we haven't fully |
| 297 // negotiated RTCP mux, we need an RTCP transport. | 329 // negotiated RTCP mux, we need an RTCP transport. |
| 298 if (NeedsRtcpTransport()) { | 330 if (rtcp_packet_transport) { |
| 299 LOG(LS_INFO) << "Setting RTCP Transport for " << content_name() << " on " | 331 LOG(LS_INFO) << "Setting RTCP Transport for " << content_name() << " on " |
| 300 << transport_name << " transport " << rtcp_dtls_transport; | 332 << debug_name << " transport " << rtcp_packet_transport; |
| 301 SetTransport_n(true, rtcp_dtls_transport); | 333 SetTransport_n(true, rtcp_dtls_transport, rtcp_packet_transport); |
| 302 RTC_DCHECK(rtcp_dtls_transport_); | |
| 303 } | 334 } |
| 304 | 335 |
| 305 LOG(LS_INFO) << "Setting non-RTCP Transport for " << content_name() << " on " | 336 LOG(LS_INFO) << "Setting RTP Transport for " << content_name() << " on " |
| 306 << transport_name << " transport " << rtp_dtls_transport; | 337 << debug_name << " transport " << rtp_packet_transport; |
| 307 SetTransport_n(false, rtp_dtls_transport); | 338 SetTransport_n(false, rtp_dtls_transport, rtp_packet_transport); |
| 308 RTC_DCHECK(rtp_dtls_transport_); | |
| 309 | 339 |
| 310 // Update aggregate writable/ready-to-send state between RTP and RTCP upon | 340 // Update aggregate writable/ready-to-send state between RTP and RTCP upon |
| 311 // setting new transport channels. | 341 // setting new transport channels. |
| 312 UpdateWritableState_n(); | 342 UpdateWritableState_n(); |
| 313 // We can only update ready-to-send after updating writability. | 343 // We can only update ready-to-send after updating writability. |
| 314 // | 344 // |
| 315 // On setting a new channel, assume it's ready to send if it's writable, | 345 // On setting a new channel, assume it's ready to send if it's writable, |
| 316 // because we have no way of knowing otherwise (the channel doesn't give us | 346 // because we have no way of knowing otherwise (the channel doesn't give us |
| 317 // "was last send successful?"). | 347 // "was last send successful?"). |
| 318 // | 348 // |
| 319 // This won't always be accurate (the last SendPacket call from another | 349 // This won't always be accurate (the last SendPacket call from another |
| 320 // BaseChannel could have resulted in an error), but even so, we'll just | 350 // BaseChannel could have resulted in an error), but even so, we'll just |
| 321 // encounter the error again and update "ready to send" accordingly. | 351 // encounter the error again and update "ready to send" accordingly. |
| 322 SetTransportChannelReadyToSend( | 352 SetTransportChannelReadyToSend( |
| 323 false, rtp_dtls_transport_ && rtp_dtls_transport_->writable()); | 353 false, rtp_packet_transport_ && rtp_packet_transport_->writable()); |
| 324 SetTransportChannelReadyToSend( | 354 SetTransportChannelReadyToSend( |
| 325 true, rtcp_dtls_transport_ && rtcp_dtls_transport_->writable()); | 355 true, rtcp_packet_transport_ && rtcp_packet_transport_->writable()); |
| 326 } | 356 } |
| 327 | 357 |
| 328 void BaseChannel::SetTransport_n(bool rtcp, | 358 void BaseChannel::SetTransport_n( |
| 329 DtlsTransportInternal* new_transport) { | 359 bool rtcp, |
| 360 DtlsTransportInternal* new_dtls_transport, |
| 361 rtc::PacketTransportInterface* new_packet_transport) { |
| 330 RTC_DCHECK(network_thread_->IsCurrent()); | 362 RTC_DCHECK(network_thread_->IsCurrent()); |
| 331 DtlsTransportInternal*& old_transport = | 363 DtlsTransportInternal*& old_dtls_transport = |
| 332 rtcp ? rtcp_dtls_transport_ : rtp_dtls_transport_; | 364 rtcp ? rtcp_dtls_transport_ : rtp_dtls_transport_; |
| 365 rtc::PacketTransportInterface*& old_packet_transport = |
| 366 rtcp ? rtcp_packet_transport_ : rtp_packet_transport_; |
| 333 | 367 |
| 334 if (!old_transport && !new_transport) { | 368 if (!old_packet_transport && !new_packet_transport) { |
| 335 // Nothing to do. | 369 // Nothing to do. |
| 336 return; | 370 return; |
| 337 } | 371 } |
| 338 | 372 |
| 339 RTC_DCHECK(old_transport != new_transport); | 373 RTC_DCHECK(old_packet_transport != new_packet_transport); |
| 340 if (old_transport) { | 374 if (old_dtls_transport) { |
| 341 DisconnectFromTransport(old_transport); | 375 DisconnectFromDtlsTransport(old_dtls_transport); |
| 376 } else if (old_packet_transport) { |
| 377 DisconnectFromPacketTransport(old_packet_transport); |
| 342 } | 378 } |
| 343 | 379 |
| 344 old_transport = new_transport; | 380 old_packet_transport = new_packet_transport; |
| 381 old_dtls_transport = new_dtls_transport; |
| 345 | 382 |
| 346 if (new_transport) { | 383 // If there's no new transport, we're done after disconnecting from old one. |
| 347 if (rtcp) { | 384 if (!new_packet_transport) { |
| 348 RTC_CHECK(!(ShouldSetupDtlsSrtp_n() && srtp_filter_.IsActive())) | 385 return; |
| 349 << "Setting RTCP for DTLS/SRTP after SrtpFilter is active " | 386 } |
| 350 << "should never happen."; | 387 |
| 351 } | 388 if (rtcp && new_dtls_transport) { |
| 352 ConnectToTransport(new_transport); | 389 RTC_CHECK(!(ShouldSetupDtlsSrtp_n() && srtp_filter_.IsActive())) |
| 353 auto& socket_options = rtcp ? rtcp_socket_options_ : socket_options_; | 390 << "Setting RTCP for DTLS/SRTP after SrtpFilter is active " |
| 354 for (const auto& pair : socket_options) { | 391 << "should never happen."; |
| 355 new_transport->SetOption(pair.first, pair.second); | 392 } |
| 356 } | 393 if (new_dtls_transport) { |
| 394 ConnectToDtlsTransport(new_dtls_transport); |
| 395 } else { |
| 396 ConnectToPacketTransport(new_packet_transport); |
| 397 } |
| 398 auto& socket_options = rtcp ? rtcp_socket_options_ : socket_options_; |
| 399 for (const auto& pair : socket_options) { |
| 400 new_packet_transport->SetOption(pair.first, pair.second); |
| 357 } | 401 } |
| 358 } | 402 } |
| 359 | 403 |
| 360 void BaseChannel::ConnectToTransport(DtlsTransportInternal* transport) { | 404 void BaseChannel::ConnectToDtlsTransport(DtlsTransportInternal* transport) { |
| 361 RTC_DCHECK(network_thread_->IsCurrent()); | 405 RTC_DCHECK(network_thread_->IsCurrent()); |
| 362 | 406 |
| 363 transport->SignalWritableState.connect(this, &BaseChannel::OnWritableState); | 407 transport->SignalWritableState.connect(this, &BaseChannel::OnWritableState); |
| 364 transport->SignalReadPacket.connect(this, &BaseChannel::OnPacketRead); | 408 transport->SignalReadPacket.connect(this, &BaseChannel::OnPacketRead); |
| 365 transport->SignalReadyToSend.connect(this, &BaseChannel::OnReadyToSend); | 409 transport->SignalReadyToSend.connect(this, &BaseChannel::OnReadyToSend); |
| 366 transport->SignalDtlsState.connect(this, &BaseChannel::OnDtlsState); | 410 transport->SignalDtlsState.connect(this, &BaseChannel::OnDtlsState); |
| 367 transport->SignalSentPacket.connect(this, &BaseChannel::SignalSentPacket_n); | 411 transport->SignalSentPacket.connect(this, &BaseChannel::SignalSentPacket_n); |
| 368 transport->ice_transport()->SignalSelectedCandidatePairChanged.connect( | 412 transport->ice_transport()->SignalSelectedCandidatePairChanged.connect( |
| 369 this, &BaseChannel::OnSelectedCandidatePairChanged); | 413 this, &BaseChannel::OnSelectedCandidatePairChanged); |
| 370 } | 414 } |
| 371 | 415 |
| 372 void BaseChannel::DisconnectFromTransport(DtlsTransportInternal* transport) { | 416 void BaseChannel::DisconnectFromDtlsTransport( |
| 417 DtlsTransportInternal* transport) { |
| 373 RTC_DCHECK(network_thread_->IsCurrent()); | 418 RTC_DCHECK(network_thread_->IsCurrent()); |
| 374 OnSelectedCandidatePairChanged(transport->ice_transport(), nullptr, -1, | 419 OnSelectedCandidatePairChanged(transport->ice_transport(), nullptr, -1, |
| 375 false); | 420 false); |
| 376 | 421 |
| 377 transport->SignalWritableState.disconnect(this); | 422 transport->SignalWritableState.disconnect(this); |
| 378 transport->SignalReadPacket.disconnect(this); | 423 transport->SignalReadPacket.disconnect(this); |
| 379 transport->SignalReadyToSend.disconnect(this); | 424 transport->SignalReadyToSend.disconnect(this); |
| 380 transport->SignalDtlsState.disconnect(this); | 425 transport->SignalDtlsState.disconnect(this); |
| 381 transport->SignalSentPacket.disconnect(this); | 426 transport->SignalSentPacket.disconnect(this); |
| 382 transport->ice_transport()->SignalSelectedCandidatePairChanged.disconnect( | 427 transport->ice_transport()->SignalSelectedCandidatePairChanged.disconnect( |
| 383 this); | 428 this); |
| 384 } | 429 } |
| 385 | 430 |
| 431 void BaseChannel::ConnectToPacketTransport( |
| 432 rtc::PacketTransportInterface* transport) { |
| 433 RTC_DCHECK_RUN_ON(network_thread_); |
| 434 transport->SignalWritableState.connect(this, &BaseChannel::OnWritableState); |
| 435 transport->SignalReadPacket.connect(this, &BaseChannel::OnPacketRead); |
| 436 transport->SignalReadyToSend.connect(this, &BaseChannel::OnReadyToSend); |
| 437 transport->SignalSentPacket.connect(this, &BaseChannel::SignalSentPacket_n); |
| 438 } |
| 439 |
| 440 void BaseChannel::DisconnectFromPacketTransport( |
| 441 rtc::PacketTransportInterface* transport) { |
| 442 RTC_DCHECK_RUN_ON(network_thread_); |
| 443 transport->SignalWritableState.disconnect(this); |
| 444 transport->SignalReadPacket.disconnect(this); |
| 445 transport->SignalReadyToSend.disconnect(this); |
| 446 transport->SignalSentPacket.disconnect(this); |
| 447 } |
| 448 |
| 386 bool BaseChannel::Enable(bool enable) { | 449 bool BaseChannel::Enable(bool enable) { |
| 387 worker_thread_->Invoke<void>( | 450 worker_thread_->Invoke<void>( |
| 388 RTC_FROM_HERE, | 451 RTC_FROM_HERE, |
| 389 Bind(enable ? &BaseChannel::EnableMedia_w : &BaseChannel::DisableMedia_w, | 452 Bind(enable ? &BaseChannel::EnableMedia_w : &BaseChannel::DisableMedia_w, |
| 390 this)); | 453 this)); |
| 391 return true; | 454 return true; |
| 392 } | 455 } |
| 393 | 456 |
| 394 bool BaseChannel::AddRecvStream(const StreamParams& sp) { | 457 bool BaseChannel::AddRecvStream(const StreamParams& sp) { |
| 395 return InvokeOnWorker(RTC_FROM_HERE, | 458 return InvokeOnWorker(RTC_FROM_HERE, |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 | 506 |
| 444 void BaseChannel::StopConnectionMonitor() { | 507 void BaseChannel::StopConnectionMonitor() { |
| 445 if (connection_monitor_) { | 508 if (connection_monitor_) { |
| 446 connection_monitor_->Stop(); | 509 connection_monitor_->Stop(); |
| 447 connection_monitor_.reset(); | 510 connection_monitor_.reset(); |
| 448 } | 511 } |
| 449 } | 512 } |
| 450 | 513 |
| 451 bool BaseChannel::GetConnectionStats(ConnectionInfos* infos) { | 514 bool BaseChannel::GetConnectionStats(ConnectionInfos* infos) { |
| 452 RTC_DCHECK(network_thread_->IsCurrent()); | 515 RTC_DCHECK(network_thread_->IsCurrent()); |
| 516 if (!rtp_dtls_transport_) { |
| 517 return false; |
| 518 } |
| 453 return rtp_dtls_transport_->ice_transport()->GetStats(infos); | 519 return rtp_dtls_transport_->ice_transport()->GetStats(infos); |
| 454 } | 520 } |
| 455 | 521 |
| 456 bool BaseChannel::NeedsRtcpTransport() { | 522 bool BaseChannel::NeedsRtcpTransport() { |
| 457 // If this BaseChannel doesn't require RTCP mux and we haven't fully | 523 // If this BaseChannel doesn't require RTCP mux and we haven't fully |
| 458 // negotiated RTCP mux, we need an RTCP transport. | 524 // negotiated RTCP mux, we need an RTCP transport. |
| 459 return !rtcp_mux_required_ && !rtcp_mux_filter_.IsFullyActive(); | 525 return !rtcp_mux_required_ && !rtcp_mux_filter_.IsFullyActive(); |
| 460 } | 526 } |
| 461 | 527 |
| 462 bool BaseChannel::IsReadyToReceiveMedia_w() const { | 528 bool BaseChannel::IsReadyToReceiveMedia_w() const { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 492 int BaseChannel::SetOption(SocketType type, rtc::Socket::Option opt, | 558 int BaseChannel::SetOption(SocketType type, rtc::Socket::Option opt, |
| 493 int value) { | 559 int value) { |
| 494 return network_thread_->Invoke<int>( | 560 return network_thread_->Invoke<int>( |
| 495 RTC_FROM_HERE, Bind(&BaseChannel::SetOption_n, this, type, opt, value)); | 561 RTC_FROM_HERE, Bind(&BaseChannel::SetOption_n, this, type, opt, value)); |
| 496 } | 562 } |
| 497 | 563 |
| 498 int BaseChannel::SetOption_n(SocketType type, | 564 int BaseChannel::SetOption_n(SocketType type, |
| 499 rtc::Socket::Option opt, | 565 rtc::Socket::Option opt, |
| 500 int value) { | 566 int value) { |
| 501 RTC_DCHECK(network_thread_->IsCurrent()); | 567 RTC_DCHECK(network_thread_->IsCurrent()); |
| 502 DtlsTransportInternal* transport = nullptr; | 568 rtc::PacketTransportInterface* transport = nullptr; |
| 503 switch (type) { | 569 switch (type) { |
| 504 case ST_RTP: | 570 case ST_RTP: |
| 505 transport = rtp_dtls_transport_; | 571 transport = rtp_packet_transport_; |
| 506 socket_options_.push_back( | 572 socket_options_.push_back( |
| 507 std::pair<rtc::Socket::Option, int>(opt, value)); | 573 std::pair<rtc::Socket::Option, int>(opt, value)); |
| 508 break; | 574 break; |
| 509 case ST_RTCP: | 575 case ST_RTCP: |
| 510 transport = rtcp_dtls_transport_; | 576 transport = rtcp_packet_transport_; |
| 511 rtcp_socket_options_.push_back( | 577 rtcp_socket_options_.push_back( |
| 512 std::pair<rtc::Socket::Option, int>(opt, value)); | 578 std::pair<rtc::Socket::Option, int>(opt, value)); |
| 513 break; | 579 break; |
| 514 } | 580 } |
| 515 return transport ? transport->ice_transport()->SetOption(opt, value) : -1; | 581 return transport ? transport->SetOption(opt, value) : -1; |
| 516 } | 582 } |
| 517 | 583 |
| 518 bool BaseChannel::SetCryptoOptions(const rtc::CryptoOptions& crypto_options) { | 584 bool BaseChannel::SetCryptoOptions(const rtc::CryptoOptions& crypto_options) { |
| 519 crypto_options_ = crypto_options; | 585 crypto_options_ = crypto_options; |
| 520 return true; | 586 return true; |
| 521 } | 587 } |
| 522 | 588 |
| 523 void BaseChannel::OnWritableState(rtc::PacketTransportInterface* transport) { | 589 void BaseChannel::OnWritableState(rtc::PacketTransportInterface* transport) { |
| 524 RTC_DCHECK(transport == rtp_dtls_transport_ || | 590 RTC_DCHECK(transport == rtp_packet_transport_ || |
| 525 transport == rtcp_dtls_transport_); | 591 transport == rtcp_packet_transport_); |
| 526 RTC_DCHECK(network_thread_->IsCurrent()); | 592 RTC_DCHECK(network_thread_->IsCurrent()); |
| 527 UpdateWritableState_n(); | 593 UpdateWritableState_n(); |
| 528 } | 594 } |
| 529 | 595 |
| 530 void BaseChannel::OnPacketRead(rtc::PacketTransportInterface* transport, | 596 void BaseChannel::OnPacketRead(rtc::PacketTransportInterface* transport, |
| 531 const char* data, | 597 const char* data, |
| 532 size_t len, | 598 size_t len, |
| 533 const rtc::PacketTime& packet_time, | 599 const rtc::PacketTime& packet_time, |
| 534 int flags) { | 600 int flags) { |
| 535 TRACE_EVENT0("webrtc", "BaseChannel::OnPacketRead"); | 601 TRACE_EVENT0("webrtc", "BaseChannel::OnPacketRead"); |
| 536 // OnPacketRead gets called from P2PSocket; now pass data to MediaEngine | 602 // OnPacketRead gets called from P2PSocket; now pass data to MediaEngine |
| 537 RTC_DCHECK(network_thread_->IsCurrent()); | 603 RTC_DCHECK(network_thread_->IsCurrent()); |
| 538 | 604 |
| 539 // When using RTCP multiplexing we might get RTCP packets on the RTP | 605 // When using RTCP multiplexing we might get RTCP packets on the RTP |
| 540 // transport. We feed RTP traffic into the demuxer to determine if it is RTCP. | 606 // transport. We feed RTP traffic into the demuxer to determine if it is RTCP. |
| 541 bool rtcp = PacketIsRtcp(transport, data, len); | 607 bool rtcp = PacketIsRtcp(transport, data, len); |
| 542 rtc::CopyOnWriteBuffer packet(data, len); | 608 rtc::CopyOnWriteBuffer packet(data, len); |
| 543 HandlePacket(rtcp, &packet, packet_time); | 609 HandlePacket(rtcp, &packet, packet_time); |
| 544 } | 610 } |
| 545 | 611 |
| 546 void BaseChannel::OnReadyToSend(rtc::PacketTransportInterface* transport) { | 612 void BaseChannel::OnReadyToSend(rtc::PacketTransportInterface* transport) { |
| 547 RTC_DCHECK(transport == rtp_dtls_transport_ || | 613 RTC_DCHECK(transport == rtp_packet_transport_ || |
| 548 transport == rtcp_dtls_transport_); | 614 transport == rtcp_packet_transport_); |
| 549 SetTransportChannelReadyToSend(transport == rtcp_dtls_transport_, true); | 615 SetTransportChannelReadyToSend(transport == rtcp_packet_transport_, true); |
| 550 } | 616 } |
| 551 | 617 |
| 552 void BaseChannel::OnDtlsState(DtlsTransportInternal* transport, | 618 void BaseChannel::OnDtlsState(DtlsTransportInternal* transport, |
| 553 DtlsTransportState state) { | 619 DtlsTransportState state) { |
| 554 if (!ShouldSetupDtlsSrtp_n()) { | 620 if (!ShouldSetupDtlsSrtp_n()) { |
| 555 return; | 621 return; |
| 556 } | 622 } |
| 557 | 623 |
| 558 // Reset the srtp filter if it's not the CONNECTED state. For the CONNECTED | 624 // Reset the srtp filter if it's not the CONNECTED state. For the CONNECTED |
| 559 // state, setting up DTLS-SRTP context is deferred to ChannelWritable_w to | 625 // state, setting up DTLS-SRTP context is deferred to ChannelWritable_w to |
| 560 // cover other scenarios like the whole transport is writable (not just this | 626 // cover other scenarios like the whole transport is writable (not just this |
| 561 // TransportChannel) or when TransportChannel is attached after DTLS is | 627 // TransportChannel) or when TransportChannel is attached after DTLS is |
| 562 // negotiated. | 628 // negotiated. |
| 563 if (state != DTLS_TRANSPORT_CONNECTED) { | 629 if (state != DTLS_TRANSPORT_CONNECTED) { |
| 564 srtp_filter_.ResetParams(); | 630 srtp_filter_.ResetParams(); |
| 565 } | 631 } |
| 566 } | 632 } |
| 567 | 633 |
| 568 void BaseChannel::OnSelectedCandidatePairChanged( | 634 void BaseChannel::OnSelectedCandidatePairChanged( |
| 569 IceTransportInternal* ice_transport, | 635 IceTransportInternal* ice_transport, |
| 570 CandidatePairInterface* selected_candidate_pair, | 636 CandidatePairInterface* selected_candidate_pair, |
| 571 int last_sent_packet_id, | 637 int last_sent_packet_id, |
| 572 bool ready_to_send) { | 638 bool ready_to_send) { |
| 573 RTC_DCHECK(ice_transport == rtp_dtls_transport_->ice_transport() || | 639 RTC_DCHECK((rtp_dtls_transport_ && |
| 574 ice_transport == rtcp_dtls_transport_->ice_transport()); | 640 ice_transport == rtp_dtls_transport_->ice_transport()) || |
| 641 (rtcp_dtls_transport_ && |
| 642 ice_transport == rtcp_dtls_transport_->ice_transport())); |
| 575 RTC_DCHECK(network_thread_->IsCurrent()); | 643 RTC_DCHECK(network_thread_->IsCurrent()); |
| 576 selected_candidate_pair_ = selected_candidate_pair; | 644 selected_candidate_pair_ = selected_candidate_pair; |
| 577 std::string transport_name = ice_transport->transport_name(); | 645 std::string transport_name = ice_transport->transport_name(); |
| 578 rtc::NetworkRoute network_route; | 646 rtc::NetworkRoute network_route; |
| 579 if (selected_candidate_pair) { | 647 if (selected_candidate_pair) { |
| 580 network_route = rtc::NetworkRoute( | 648 network_route = rtc::NetworkRoute( |
| 581 ready_to_send, selected_candidate_pair->local_candidate().network_id(), | 649 ready_to_send, selected_candidate_pair->local_candidate().network_id(), |
| 582 selected_candidate_pair->remote_candidate().network_id(), | 650 selected_candidate_pair->remote_candidate().network_id(), |
| 583 last_sent_packet_id); | 651 last_sent_packet_id); |
| 584 | 652 |
| 585 UpdateTransportOverhead(); | 653 UpdateTransportOverhead(); |
| 586 } | 654 } |
| 587 invoker_.AsyncInvoke<void>( | 655 invoker_.AsyncInvoke<void>( |
| 588 RTC_FROM_HERE, worker_thread_, | 656 RTC_FROM_HERE, worker_thread_, |
| 589 Bind(&MediaChannel::OnNetworkRouteChanged, media_channel_, transport_name, | 657 Bind(&MediaChannel::OnNetworkRouteChanged, media_channel_, transport_name, |
| 590 network_route)); | 658 network_route)); |
| 591 } | 659 } |
| 592 | 660 |
| 593 void BaseChannel::SetTransportChannelReadyToSend(bool rtcp, bool ready) { | 661 void BaseChannel::SetTransportChannelReadyToSend(bool rtcp, bool ready) { |
| 594 RTC_DCHECK(network_thread_->IsCurrent()); | 662 RTC_DCHECK(network_thread_->IsCurrent()); |
| 595 if (rtcp) { | 663 if (rtcp) { |
| 596 rtcp_ready_to_send_ = ready; | 664 rtcp_ready_to_send_ = ready; |
| 597 } else { | 665 } else { |
| 598 rtp_ready_to_send_ = ready; | 666 rtp_ready_to_send_ = ready; |
| 599 } | 667 } |
| 600 | 668 |
| 601 bool ready_to_send = | 669 bool ready_to_send = |
| 602 (rtp_ready_to_send_ && | 670 (rtp_ready_to_send_ && |
| 603 // In the case of rtcp mux |rtcp_dtls_transport_| will be null. | 671 // In the case of rtcp mux |rtcp_packet_transport_| will be null. |
| 604 (rtcp_ready_to_send_ || !rtcp_dtls_transport_)); | 672 (rtcp_ready_to_send_ || !rtcp_packet_transport_)); |
| 605 | 673 |
| 606 invoker_.AsyncInvoke<void>( | 674 invoker_.AsyncInvoke<void>( |
| 607 RTC_FROM_HERE, worker_thread_, | 675 RTC_FROM_HERE, worker_thread_, |
| 608 Bind(&MediaChannel::OnReadyToSend, media_channel_, ready_to_send)); | 676 Bind(&MediaChannel::OnReadyToSend, media_channel_, ready_to_send)); |
| 609 } | 677 } |
| 610 | 678 |
| 611 bool BaseChannel::PacketIsRtcp(const rtc::PacketTransportInterface* transport, | 679 bool BaseChannel::PacketIsRtcp(const rtc::PacketTransportInterface* transport, |
| 612 const char* data, | 680 const char* data, |
| 613 size_t len) { | 681 size_t len) { |
| 614 return (transport == rtcp_dtls_transport_ || | 682 return (transport == rtcp_packet_transport_ || |
| 615 rtcp_mux_filter_.DemuxRtcp(data, static_cast<int>(len))); | 683 rtcp_mux_filter_.DemuxRtcp(data, static_cast<int>(len))); |
| 616 } | 684 } |
| 617 | 685 |
| 618 bool BaseChannel::SendPacket(bool rtcp, | 686 bool BaseChannel::SendPacket(bool rtcp, |
| 619 rtc::CopyOnWriteBuffer* packet, | 687 rtc::CopyOnWriteBuffer* packet, |
| 620 const rtc::PacketOptions& options) { | 688 const rtc::PacketOptions& options) { |
| 621 // SendPacket gets called from MediaEngine, on a pacer or an encoder thread. | 689 // SendPacket gets called from MediaEngine, on a pacer or an encoder thread. |
| 622 // If the thread is not our network thread, we will post to our network | 690 // If the thread is not our network thread, we will post to our network |
| 623 // so that the real work happens on our network. This avoids us having to | 691 // so that the real work happens on our network. This avoids us having to |
| 624 // synchronize access to all the pieces of the send path, including | 692 // synchronize access to all the pieces of the send path, including |
| 625 // SRTP and the inner workings of the transport channels. | 693 // SRTP and the inner workings of the transport channels. |
| 626 // The only downside is that we can't return a proper failure code if | 694 // The only downside is that we can't return a proper failure code if |
| 627 // needed. Since UDP is unreliable anyway, this should be a non-issue. | 695 // needed. Since UDP is unreliable anyway, this should be a non-issue. |
| 628 if (!network_thread_->IsCurrent()) { | 696 if (!network_thread_->IsCurrent()) { |
| 629 // Avoid a copy by transferring the ownership of the packet data. | 697 // Avoid a copy by transferring the ownership of the packet data. |
| 630 int message_id = rtcp ? MSG_SEND_RTCP_PACKET : MSG_SEND_RTP_PACKET; | 698 int message_id = rtcp ? MSG_SEND_RTCP_PACKET : MSG_SEND_RTP_PACKET; |
| 631 SendPacketMessageData* data = new SendPacketMessageData; | 699 SendPacketMessageData* data = new SendPacketMessageData; |
| 632 data->packet = std::move(*packet); | 700 data->packet = std::move(*packet); |
| 633 data->options = options; | 701 data->options = options; |
| 634 network_thread_->Post(RTC_FROM_HERE, this, message_id, data); | 702 network_thread_->Post(RTC_FROM_HERE, this, message_id, data); |
| 635 return true; | 703 return true; |
| 636 } | 704 } |
| 637 TRACE_EVENT0("webrtc", "BaseChannel::SendPacket"); | 705 TRACE_EVENT0("webrtc", "BaseChannel::SendPacket"); |
| 638 | 706 |
| 639 // Now that we are on the correct thread, ensure we have a place to send this | 707 // Now that we are on the correct thread, ensure we have a place to send this |
| 640 // packet before doing anything. (We might get RTCP packets that we don't | 708 // packet before doing anything. (We might get RTCP packets that we don't |
| 641 // intend to send.) If we've negotiated RTCP mux, send RTCP over the RTP | 709 // intend to send.) If we've negotiated RTCP mux, send RTCP over the RTP |
| 642 // transport. | 710 // transport. |
| 643 DtlsTransportInternal* transport = (!rtcp || rtcp_mux_filter_.IsActive()) | 711 rtc::PacketTransportInterface* transport = |
| 644 ? rtp_dtls_transport_ | 712 (!rtcp || rtcp_mux_filter_.IsActive()) ? rtp_packet_transport_ |
| 645 : rtcp_dtls_transport_; | 713 : rtcp_packet_transport_; |
| 646 if (!transport || !transport->writable()) { | 714 if (!transport || !transport->writable()) { |
| 647 return false; | 715 return false; |
| 648 } | 716 } |
| 649 | 717 |
| 650 // Protect ourselves against crazy data. | 718 // Protect ourselves against crazy data. |
| 651 if (!ValidPacket(rtcp, packet)) { | 719 if (!ValidPacket(rtcp, packet)) { |
| 652 LOG(LS_ERROR) << "Dropping outgoing " << content_name_ << " " | 720 LOG(LS_ERROR) << "Dropping outgoing " << content_name_ << " " |
| 653 << PacketType(rtcp) | 721 << PacketType(rtcp) |
| 654 << " packet: wrong size=" << packet->size(); | 722 << " packet: wrong size=" << packet->size(); |
| 655 return false; | 723 return false; |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 884 RTC_DCHECK(worker_thread_ == rtc::Thread::Current()); | 952 RTC_DCHECK(worker_thread_ == rtc::Thread::Current()); |
| 885 if (!enabled_) | 953 if (!enabled_) |
| 886 return; | 954 return; |
| 887 | 955 |
| 888 LOG(LS_INFO) << "Channel disabled"; | 956 LOG(LS_INFO) << "Channel disabled"; |
| 889 enabled_ = false; | 957 enabled_ = false; |
| 890 UpdateMediaSendRecvState_w(); | 958 UpdateMediaSendRecvState_w(); |
| 891 } | 959 } |
| 892 | 960 |
| 893 void BaseChannel::UpdateWritableState_n() { | 961 void BaseChannel::UpdateWritableState_n() { |
| 894 if (rtp_dtls_transport_ && rtp_dtls_transport_->writable() && | 962 if (rtp_packet_transport_ && rtp_packet_transport_->writable() && |
| 895 (!rtcp_dtls_transport_ || rtcp_dtls_transport_->writable())) { | 963 (!rtcp_packet_transport_ || rtcp_packet_transport_->writable())) { |
| 896 ChannelWritable_n(); | 964 ChannelWritable_n(); |
| 897 } else { | 965 } else { |
| 898 ChannelNotWritable_n(); | 966 ChannelNotWritable_n(); |
| 899 } | 967 } |
| 900 } | 968 } |
| 901 | 969 |
| 902 void BaseChannel::ChannelWritable_n() { | 970 void BaseChannel::ChannelWritable_n() { |
| 903 RTC_DCHECK(network_thread_->IsCurrent()); | 971 RTC_DCHECK(network_thread_->IsCurrent()); |
| 904 if (writable_) { | 972 if (writable_) { |
| 905 return; | 973 return; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 952 } | 1020 } |
| 953 | 1021 |
| 954 // This function returns true if either DTLS-SRTP is not in use | 1022 // This function returns true if either DTLS-SRTP is not in use |
| 955 // *or* DTLS-SRTP is successfully set up. | 1023 // *or* DTLS-SRTP is successfully set up. |
| 956 bool BaseChannel::SetupDtlsSrtp_n(bool rtcp) { | 1024 bool BaseChannel::SetupDtlsSrtp_n(bool rtcp) { |
| 957 RTC_DCHECK(network_thread_->IsCurrent()); | 1025 RTC_DCHECK(network_thread_->IsCurrent()); |
| 958 bool ret = false; | 1026 bool ret = false; |
| 959 | 1027 |
| 960 DtlsTransportInternal* transport = | 1028 DtlsTransportInternal* transport = |
| 961 rtcp ? rtcp_dtls_transport_ : rtp_dtls_transport_; | 1029 rtcp ? rtcp_dtls_transport_ : rtp_dtls_transport_; |
| 962 | 1030 RTC_DCHECK(transport); |
| 963 RTC_DCHECK(transport->IsDtlsActive()); | 1031 RTC_DCHECK(transport->IsDtlsActive()); |
| 964 | 1032 |
| 965 int selected_crypto_suite; | 1033 int selected_crypto_suite; |
| 966 | 1034 |
| 967 if (!transport->GetSrtpCryptoSuite(&selected_crypto_suite)) { | 1035 if (!transport->GetSrtpCryptoSuite(&selected_crypto_suite)) { |
| 968 LOG(LS_ERROR) << "No DTLS-SRTP selected crypto suite"; | 1036 LOG(LS_ERROR) << "No DTLS-SRTP selected crypto suite"; |
| 969 return false; | 1037 return false; |
| 970 } | 1038 } |
| 971 | 1039 |
| 972 LOG(LS_INFO) << "Installing keys from DTLS-SRTP on " << content_name() << " " | 1040 LOG(LS_INFO) << "Installing keys from DTLS-SRTP on " << content_name() << " " |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1103 } | 1171 } |
| 1104 | 1172 |
| 1105 return true; | 1173 return true; |
| 1106 } | 1174 } |
| 1107 | 1175 |
| 1108 // |dtls| will be set to true if DTLS is active for transport and crypto is | 1176 // |dtls| will be set to true if DTLS is active for transport and crypto is |
| 1109 // empty. | 1177 // empty. |
| 1110 bool BaseChannel::CheckSrtpConfig_n(const std::vector<CryptoParams>& cryptos, | 1178 bool BaseChannel::CheckSrtpConfig_n(const std::vector<CryptoParams>& cryptos, |
| 1111 bool* dtls, | 1179 bool* dtls, |
| 1112 std::string* error_desc) { | 1180 std::string* error_desc) { |
| 1113 *dtls = rtp_dtls_transport_->IsDtlsActive(); | 1181 *dtls = rtp_dtls_transport_ && rtp_dtls_transport_->IsDtlsActive(); |
| 1114 if (*dtls && !cryptos.empty()) { | 1182 if (*dtls && !cryptos.empty()) { |
| 1115 SafeSetError("Cryptos must be empty when DTLS is active.", error_desc); | 1183 SafeSetError("Cryptos must be empty when DTLS is active.", error_desc); |
| 1116 return false; | 1184 return false; |
| 1117 } | 1185 } |
| 1118 return true; | 1186 return true; |
| 1119 } | 1187 } |
| 1120 | 1188 |
| 1121 bool BaseChannel::SetSrtp_n(const std::vector<CryptoParams>& cryptos, | 1189 bool BaseChannel::SetSrtp_n(const std::vector<CryptoParams>& cryptos, |
| 1122 ContentAction action, | 1190 ContentAction action, |
| 1123 ContentSource src, | 1191 ContentSource src, |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1188 // because the final answer may deactivate it. | 1256 // because the final answer may deactivate it. |
| 1189 ret = rtcp_mux_filter_.SetProvisionalAnswer(enable, src); | 1257 ret = rtcp_mux_filter_.SetProvisionalAnswer(enable, src); |
| 1190 break; | 1258 break; |
| 1191 case CA_ANSWER: | 1259 case CA_ANSWER: |
| 1192 ret = rtcp_mux_filter_.SetAnswer(enable, src); | 1260 ret = rtcp_mux_filter_.SetAnswer(enable, src); |
| 1193 if (ret && rtcp_mux_filter_.IsActive()) { | 1261 if (ret && rtcp_mux_filter_.IsActive()) { |
| 1194 // We activated RTCP mux, close down the RTCP transport. | 1262 // We activated RTCP mux, close down the RTCP transport. |
| 1195 LOG(LS_INFO) << "Enabling rtcp-mux for " << content_name() | 1263 LOG(LS_INFO) << "Enabling rtcp-mux for " << content_name() |
| 1196 << " by destroying RTCP transport for " | 1264 << " by destroying RTCP transport for " |
| 1197 << transport_name(); | 1265 << transport_name(); |
| 1198 if (rtcp_dtls_transport()) { | 1266 if (rtcp_packet_transport_) { |
| 1199 SetTransport_n(true, nullptr); | 1267 SetTransport_n(true, nullptr, nullptr); |
| 1200 SignalRtcpMuxFullyActive(rtp_dtls_transport()->transport_name()); | 1268 SignalRtcpMuxFullyActive(transport_name_); |
| 1201 } | 1269 } |
| 1202 UpdateWritableState_n(); | 1270 UpdateWritableState_n(); |
| 1203 SetTransportChannelReadyToSend(true, false); | 1271 SetTransportChannelReadyToSend(true, false); |
| 1204 } | 1272 } |
| 1205 break; | 1273 break; |
| 1206 case CA_UPDATE: | 1274 case CA_UPDATE: |
| 1207 // No RTCP mux info. | 1275 // No RTCP mux info. |
| 1208 ret = true; | 1276 ret = true; |
| 1209 break; | 1277 break; |
| 1210 default: | 1278 default: |
| 1211 break; | 1279 break; |
| 1212 } | 1280 } |
| 1213 if (!ret) { | 1281 if (!ret) { |
| 1214 SafeSetError("Failed to setup RTCP mux filter.", error_desc); | 1282 SafeSetError("Failed to setup RTCP mux filter.", error_desc); |
| 1215 return false; | 1283 return false; |
| 1216 } | 1284 } |
| 1217 // |rtcp_mux_filter_| can be active if |action| is CA_PRANSWER or | 1285 // |rtcp_mux_filter_| can be active if |action| is CA_PRANSWER or |
| 1218 // CA_ANSWER, but we only want to tear down the RTCP transport if we received | 1286 // CA_ANSWER, but we only want to tear down the RTCP transport if we received |
| 1219 // a final answer. | 1287 // a final answer. |
| 1220 if (rtcp_mux_filter_.IsActive()) { | 1288 if (rtcp_mux_filter_.IsActive()) { |
| 1221 // If the RTP transport is already writable, then so are we. | 1289 // If the RTP transport is already writable, then so are we. |
| 1222 if (rtp_dtls_transport_->writable()) { | 1290 if (rtp_packet_transport_->writable()) { |
| 1223 ChannelWritable_n(); | 1291 ChannelWritable_n(); |
| 1224 } | 1292 } |
| 1225 } | 1293 } |
| 1226 | 1294 |
| 1227 return true; | 1295 return true; |
| 1228 } | 1296 } |
| 1229 | 1297 |
| 1230 bool BaseChannel::AddRecvStream_w(const StreamParams& sp) { | 1298 bool BaseChannel::AddRecvStream_w(const StreamParams& sp) { |
| 1231 RTC_DCHECK(worker_thread() == rtc::Thread::Current()); | 1299 RTC_DCHECK(worker_thread() == rtc::Thread::Current()); |
| 1232 return media_channel()->AddRecvStream(sp); | 1300 return media_channel()->AddRecvStream(sp); |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1472 | 1540 |
| 1473 VoiceChannel::~VoiceChannel() { | 1541 VoiceChannel::~VoiceChannel() { |
| 1474 TRACE_EVENT0("webrtc", "VoiceChannel::~VoiceChannel"); | 1542 TRACE_EVENT0("webrtc", "VoiceChannel::~VoiceChannel"); |
| 1475 StopAudioMonitor(); | 1543 StopAudioMonitor(); |
| 1476 StopMediaMonitor(); | 1544 StopMediaMonitor(); |
| 1477 // this can't be done in the base class, since it calls a virtual | 1545 // this can't be done in the base class, since it calls a virtual |
| 1478 DisableMedia_w(); | 1546 DisableMedia_w(); |
| 1479 Deinit(); | 1547 Deinit(); |
| 1480 } | 1548 } |
| 1481 | 1549 |
| 1482 bool VoiceChannel::Init_w(DtlsTransportInternal* rtp_dtls_transport, | |
| 1483 DtlsTransportInternal* rtcp_dtls_transport) { | |
| 1484 return BaseChannel::Init_w(rtp_dtls_transport, rtcp_dtls_transport); | |
| 1485 } | |
| 1486 | |
| 1487 bool VoiceChannel::SetAudioSend(uint32_t ssrc, | 1550 bool VoiceChannel::SetAudioSend(uint32_t ssrc, |
| 1488 bool enable, | 1551 bool enable, |
| 1489 const AudioOptions* options, | 1552 const AudioOptions* options, |
| 1490 AudioSource* source) { | 1553 AudioSource* source) { |
| 1491 return InvokeOnWorker(RTC_FROM_HERE, | 1554 return InvokeOnWorker(RTC_FROM_HERE, |
| 1492 Bind(&VoiceMediaChannel::SetAudioSend, media_channel(), | 1555 Bind(&VoiceMediaChannel::SetAudioSend, media_channel(), |
| 1493 ssrc, enable, options, source)); | 1556 ssrc, enable, options, source)); |
| 1494 } | 1557 } |
| 1495 | 1558 |
| 1496 // TODO(juberti): Handle early media the right way. We should get an explicit | 1559 // TODO(juberti): Handle early media the right way. We should get an explicit |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1874 bool rtcp_mux_required, | 1937 bool rtcp_mux_required, |
| 1875 bool srtp_required) | 1938 bool srtp_required) |
| 1876 : BaseChannel(worker_thread, | 1939 : BaseChannel(worker_thread, |
| 1877 network_thread, | 1940 network_thread, |
| 1878 signaling_thread, | 1941 signaling_thread, |
| 1879 media_channel, | 1942 media_channel, |
| 1880 content_name, | 1943 content_name, |
| 1881 rtcp_mux_required, | 1944 rtcp_mux_required, |
| 1882 srtp_required) {} | 1945 srtp_required) {} |
| 1883 | 1946 |
| 1884 bool VideoChannel::Init_w(DtlsTransportInternal* rtp_dtls_transport, | |
| 1885 DtlsTransportInternal* rtcp_dtls_transport) { | |
| 1886 return BaseChannel::Init_w(rtp_dtls_transport, rtcp_dtls_transport); | |
| 1887 } | |
| 1888 | |
| 1889 VideoChannel::~VideoChannel() { | 1947 VideoChannel::~VideoChannel() { |
| 1890 TRACE_EVENT0("webrtc", "VideoChannel::~VideoChannel"); | 1948 TRACE_EVENT0("webrtc", "VideoChannel::~VideoChannel"); |
| 1891 StopMediaMonitor(); | 1949 StopMediaMonitor(); |
| 1892 // this can't be done in the base class, since it calls a virtual | 1950 // this can't be done in the base class, since it calls a virtual |
| 1893 DisableMedia_w(); | 1951 DisableMedia_w(); |
| 1894 | 1952 |
| 1895 Deinit(); | 1953 Deinit(); |
| 1896 } | 1954 } |
| 1897 | 1955 |
| 1898 bool VideoChannel::SetSink(uint32_t ssrc, | 1956 bool VideoChannel::SetSink(uint32_t ssrc, |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2144 | 2202 |
| 2145 RtpDataChannel::~RtpDataChannel() { | 2203 RtpDataChannel::~RtpDataChannel() { |
| 2146 TRACE_EVENT0("webrtc", "RtpDataChannel::~RtpDataChannel"); | 2204 TRACE_EVENT0("webrtc", "RtpDataChannel::~RtpDataChannel"); |
| 2147 StopMediaMonitor(); | 2205 StopMediaMonitor(); |
| 2148 // this can't be done in the base class, since it calls a virtual | 2206 // this can't be done in the base class, since it calls a virtual |
| 2149 DisableMedia_w(); | 2207 DisableMedia_w(); |
| 2150 | 2208 |
| 2151 Deinit(); | 2209 Deinit(); |
| 2152 } | 2210 } |
| 2153 | 2211 |
| 2154 bool RtpDataChannel::Init_w(DtlsTransportInternal* rtp_dtls_transport, | 2212 bool RtpDataChannel::Init_w( |
| 2155 DtlsTransportInternal* rtcp_dtls_transport) { | 2213 DtlsTransportInternal* rtp_dtls_transport, |
| 2156 if (!BaseChannel::Init_w(rtp_dtls_transport, rtcp_dtls_transport)) { | 2214 DtlsTransportInternal* rtcp_dtls_transport, |
| 2215 rtc::PacketTransportInterface* rtp_packet_transport, |
| 2216 rtc::PacketTransportInterface* rtcp_packet_transport) { |
| 2217 if (!BaseChannel::Init_w(rtp_dtls_transport, rtcp_dtls_transport, |
| 2218 rtp_packet_transport, rtcp_packet_transport)) { |
| 2157 return false; | 2219 return false; |
| 2158 } | 2220 } |
| 2159 media_channel()->SignalDataReceived.connect(this, | 2221 media_channel()->SignalDataReceived.connect(this, |
| 2160 &RtpDataChannel::OnDataReceived); | 2222 &RtpDataChannel::OnDataReceived); |
| 2161 media_channel()->SignalReadyToSend.connect( | 2223 media_channel()->SignalReadyToSend.connect( |
| 2162 this, &RtpDataChannel::OnDataChannelReadyToSend); | 2224 this, &RtpDataChannel::OnDataChannelReadyToSend); |
| 2163 return true; | 2225 return true; |
| 2164 } | 2226 } |
| 2165 | 2227 |
| 2166 bool RtpDataChannel::SendData(const SendDataParams& params, | 2228 bool RtpDataChannel::SendData(const SendDataParams& params, |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2392 signaling_thread()->Post(RTC_FROM_HERE, this, MSG_READYTOSENDDATA, | 2454 signaling_thread()->Post(RTC_FROM_HERE, this, MSG_READYTOSENDDATA, |
| 2393 new DataChannelReadyToSendMessageData(writable)); | 2455 new DataChannelReadyToSendMessageData(writable)); |
| 2394 } | 2456 } |
| 2395 | 2457 |
| 2396 void RtpDataChannel::GetSrtpCryptoSuites_n( | 2458 void RtpDataChannel::GetSrtpCryptoSuites_n( |
| 2397 std::vector<int>* crypto_suites) const { | 2459 std::vector<int>* crypto_suites) const { |
| 2398 GetSupportedDataCryptoSuites(crypto_options(), crypto_suites); | 2460 GetSupportedDataCryptoSuites(crypto_options(), crypto_suites); |
| 2399 } | 2461 } |
| 2400 | 2462 |
| 2401 } // namespace cricket | 2463 } // namespace cricket |
| OLD | NEW |