OLD | NEW |
---|---|
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2004 Google Inc. | 3 * Copyright 2004 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
258 | 258 |
259 if (transport_name == transport_name_) { | 259 if (transport_name == transport_name_) { |
260 // Nothing to do if transport name isn't changing | 260 // Nothing to do if transport name isn't changing |
261 return true; | 261 return true; |
262 } | 262 } |
263 | 263 |
264 // When using DTLS-SRTP, we must reset the SrtpFilter every time the transport | 264 // When using DTLS-SRTP, we must reset the SrtpFilter every time the transport |
265 // changes and wait until the DTLS handshake is complete to set the newly | 265 // changes and wait until the DTLS handshake is complete to set the newly |
266 // negotiated parameters. | 266 // negotiated parameters. |
267 if (ShouldSetupDtlsSrtp()) { | 267 if (ShouldSetupDtlsSrtp()) { |
268 // Set |writable_| to false such that UpdateWritableState_w could set up | |
269 // DTLS-SRTP again. | |
pthatcher1
2015/12/17 23:38:54
could => can
again => when the writable_ becomes t
guoweis_webrtc
2015/12/17 23:43:17
Done.
| |
270 writable_ = false; | |
268 srtp_filter_.ResetParams(); | 271 srtp_filter_.ResetParams(); |
269 } | 272 } |
270 | 273 |
274 // TODO(guoweis): Remove this grossness when we remove non-muxed RTCP. | |
275 if (rtcp_transport_enabled()) { | |
276 LOG(LS_INFO) << "Create RTCP TransportChannel for " << content_name() | |
277 << " on " << transport_name << " transport "; | |
278 set_rtcp_transport_channel( | |
279 transport_controller_->CreateTransportChannel_w( | |
280 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTCP), | |
281 false /* update_writablity */); | |
282 if (!rtcp_transport_channel()) { | |
283 return false; | |
284 } | |
285 } | |
286 | |
287 // We're not updating the writablity during the transition state. | |
271 set_transport_channel(transport_controller_->CreateTransportChannel_w( | 288 set_transport_channel(transport_controller_->CreateTransportChannel_w( |
272 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP)); | 289 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP)); |
273 if (!transport_channel()) { | 290 if (!transport_channel()) { |
274 return false; | 291 return false; |
275 } | 292 } |
293 | |
294 // TODO(guoweis): Remove this grossness when we remove non-muxed RTCP. | |
276 if (rtcp_transport_enabled()) { | 295 if (rtcp_transport_enabled()) { |
277 LOG(LS_INFO) << "Create RTCP TransportChannel for " << content_name() | 296 // Update aggregate writable/ready-to-send state between RTP and RTCP upon |
278 << " on " << transport_name << " transport "; | 297 // setting new channel |
pthatcher1
2015/12/17 23:38:54
This comment isn't accurate any more. Perhaps som
guoweis_webrtc
2015/12/17 23:43:17
Done.
| |
279 set_rtcp_transport_channel(transport_controller_->CreateTransportChannel_w( | 298 SetReadyToSend( |
280 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTCP)); | 299 true, rtcp_transport_channel() && rtcp_transport_channel()->writable()); |
281 if (!rtcp_transport_channel()) { | |
282 return false; | |
283 } | |
284 } | 300 } |
285 | |
286 transport_name_ = transport_name; | 301 transport_name_ = transport_name; |
287 return true; | 302 return true; |
288 } | 303 } |
289 | 304 |
290 void BaseChannel::set_transport_channel(TransportChannel* new_tc) { | 305 void BaseChannel::set_transport_channel(TransportChannel* new_tc) { |
291 ASSERT(worker_thread_ == rtc::Thread::Current()); | 306 ASSERT(worker_thread_ == rtc::Thread::Current()); |
292 | 307 |
293 TransportChannel* old_tc = transport_channel_; | 308 TransportChannel* old_tc = transport_channel_; |
294 if (!old_tc && !new_tc) { | 309 if (!old_tc && !new_tc) { |
295 // Nothing to do | 310 // Nothing to do |
(...skipping 15 matching lines...) Expand all Loading... | |
311 new_tc->SetOption(pair.first, pair.second); | 326 new_tc->SetOption(pair.first, pair.second); |
312 } | 327 } |
313 } | 328 } |
314 | 329 |
315 // Update aggregate writable/ready-to-send state between RTP and RTCP upon | 330 // Update aggregate writable/ready-to-send state between RTP and RTCP upon |
316 // setting new channel | 331 // setting new channel |
317 UpdateWritableState_w(); | 332 UpdateWritableState_w(); |
318 SetReadyToSend(false, new_tc && new_tc->writable()); | 333 SetReadyToSend(false, new_tc && new_tc->writable()); |
319 } | 334 } |
320 | 335 |
321 void BaseChannel::set_rtcp_transport_channel(TransportChannel* new_tc) { | 336 void BaseChannel::set_rtcp_transport_channel(TransportChannel* new_tc, |
337 bool update_writablity) { | |
322 ASSERT(worker_thread_ == rtc::Thread::Current()); | 338 ASSERT(worker_thread_ == rtc::Thread::Current()); |
323 | 339 |
324 TransportChannel* old_tc = rtcp_transport_channel_; | 340 TransportChannel* old_tc = rtcp_transport_channel_; |
325 if (!old_tc && !new_tc) { | 341 if (!old_tc && !new_tc) { |
326 // Nothing to do | 342 // Nothing to do |
327 return; | 343 return; |
328 } | 344 } |
329 ASSERT(old_tc != new_tc); | 345 ASSERT(old_tc != new_tc); |
330 | 346 |
331 if (old_tc) { | 347 if (old_tc) { |
332 DisconnectFromTransportChannel(old_tc); | 348 DisconnectFromTransportChannel(old_tc); |
333 transport_controller_->DestroyTransportChannel_w( | 349 transport_controller_->DestroyTransportChannel_w( |
334 transport_name_, cricket::ICE_CANDIDATE_COMPONENT_RTCP); | 350 transport_name_, cricket::ICE_CANDIDATE_COMPONENT_RTCP); |
335 } | 351 } |
336 | 352 |
337 rtcp_transport_channel_ = new_tc; | 353 rtcp_transport_channel_ = new_tc; |
338 | 354 |
339 if (new_tc) { | 355 if (new_tc) { |
340 RTC_CHECK(!(ShouldSetupDtlsSrtp() && srtp_filter_.IsActive())) | 356 RTC_CHECK(!(ShouldSetupDtlsSrtp() && srtp_filter_.IsActive())) |
341 << "Setting RTCP for DTLS/SRTP after SrtpFilter is active " | 357 << "Setting RTCP for DTLS/SRTP after SrtpFilter is active " |
342 << "should never happen."; | 358 << "should never happen."; |
343 ConnectToTransportChannel(new_tc); | 359 ConnectToTransportChannel(new_tc); |
344 for (const auto& pair : rtcp_socket_options_) { | 360 for (const auto& pair : rtcp_socket_options_) { |
345 new_tc->SetOption(pair.first, pair.second); | 361 new_tc->SetOption(pair.first, pair.second); |
346 } | 362 } |
347 } | 363 } |
348 | 364 |
349 // Update aggregate writable/ready-to-send state between RTP and RTCP upon | 365 if (update_writablity) { |
350 // setting new channel | 366 // Update aggregate writable/ready-to-send state between RTP and RTCP upon |
351 UpdateWritableState_w(); | 367 // setting new channel |
352 SetReadyToSend(true, new_tc && new_tc->writable()); | 368 UpdateWritableState_w(); |
369 SetReadyToSend(true, new_tc && new_tc->writable()); | |
370 } | |
353 } | 371 } |
354 | 372 |
355 void BaseChannel::ConnectToTransportChannel(TransportChannel* tc) { | 373 void BaseChannel::ConnectToTransportChannel(TransportChannel* tc) { |
356 ASSERT(worker_thread_ == rtc::Thread::Current()); | 374 ASSERT(worker_thread_ == rtc::Thread::Current()); |
357 | 375 |
358 tc->SignalWritableState.connect(this, &BaseChannel::OnWritableState); | 376 tc->SignalWritableState.connect(this, &BaseChannel::OnWritableState); |
359 tc->SignalReadPacket.connect(this, &BaseChannel::OnChannelRead); | 377 tc->SignalReadPacket.connect(this, &BaseChannel::OnChannelRead); |
360 tc->SignalReadyToSend.connect(this, &BaseChannel::OnReadyToSend); | 378 tc->SignalReadyToSend.connect(this, &BaseChannel::OnReadyToSend); |
361 tc->SignalDtlsState.connect(this, &BaseChannel::OnDtlsState); | 379 tc->SignalDtlsState.connect(this, &BaseChannel::OnDtlsState); |
362 } | 380 } |
(...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1063 } | 1081 } |
1064 | 1082 |
1065 void BaseChannel::ActivateRtcpMux() { | 1083 void BaseChannel::ActivateRtcpMux() { |
1066 worker_thread_->Invoke<void>(Bind( | 1084 worker_thread_->Invoke<void>(Bind( |
1067 &BaseChannel::ActivateRtcpMux_w, this)); | 1085 &BaseChannel::ActivateRtcpMux_w, this)); |
1068 } | 1086 } |
1069 | 1087 |
1070 void BaseChannel::ActivateRtcpMux_w() { | 1088 void BaseChannel::ActivateRtcpMux_w() { |
1071 if (!rtcp_mux_filter_.IsActive()) { | 1089 if (!rtcp_mux_filter_.IsActive()) { |
1072 rtcp_mux_filter_.SetActive(); | 1090 rtcp_mux_filter_.SetActive(); |
1073 set_rtcp_transport_channel(nullptr); | 1091 set_rtcp_transport_channel(nullptr, true); |
1074 rtcp_transport_enabled_ = false; | 1092 rtcp_transport_enabled_ = false; |
1075 } | 1093 } |
1076 } | 1094 } |
1077 | 1095 |
1078 bool BaseChannel::SetRtcpMux_w(bool enable, ContentAction action, | 1096 bool BaseChannel::SetRtcpMux_w(bool enable, ContentAction action, |
1079 ContentSource src, | 1097 ContentSource src, |
1080 std::string* error_desc) { | 1098 std::string* error_desc) { |
1081 bool ret = false; | 1099 bool ret = false; |
1082 switch (action) { | 1100 switch (action) { |
1083 case CA_OFFER: | 1101 case CA_OFFER: |
1084 ret = rtcp_mux_filter_.SetOffer(enable, src); | 1102 ret = rtcp_mux_filter_.SetOffer(enable, src); |
1085 break; | 1103 break; |
1086 case CA_PRANSWER: | 1104 case CA_PRANSWER: |
1087 ret = rtcp_mux_filter_.SetProvisionalAnswer(enable, src); | 1105 ret = rtcp_mux_filter_.SetProvisionalAnswer(enable, src); |
1088 break; | 1106 break; |
1089 case CA_ANSWER: | 1107 case CA_ANSWER: |
1090 ret = rtcp_mux_filter_.SetAnswer(enable, src); | 1108 ret = rtcp_mux_filter_.SetAnswer(enable, src); |
1091 if (ret && rtcp_mux_filter_.IsActive()) { | 1109 if (ret && rtcp_mux_filter_.IsActive()) { |
1092 // We activated RTCP mux, close down the RTCP transport. | 1110 // We activated RTCP mux, close down the RTCP transport. |
1093 LOG(LS_INFO) << "Enabling rtcp-mux for " << content_name() | 1111 LOG(LS_INFO) << "Enabling rtcp-mux for " << content_name() |
1094 << " by destroying RTCP transport channel for " | 1112 << " by destroying RTCP transport channel for " |
1095 << transport_name(); | 1113 << transport_name(); |
1096 set_rtcp_transport_channel(nullptr); | 1114 set_rtcp_transport_channel(nullptr, true); |
1097 rtcp_transport_enabled_ = false; | 1115 rtcp_transport_enabled_ = false; |
1098 } | 1116 } |
1099 break; | 1117 break; |
1100 case CA_UPDATE: | 1118 case CA_UPDATE: |
1101 // No RTCP mux info. | 1119 // No RTCP mux info. |
1102 ret = true; | 1120 ret = true; |
1103 break; | 1121 break; |
1104 default: | 1122 default: |
1105 break; | 1123 break; |
1106 } | 1124 } |
(...skipping 1226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2333 return (data_channel_type_ == DCT_RTP) && BaseChannel::ShouldSetupDtlsSrtp(); | 2351 return (data_channel_type_ == DCT_RTP) && BaseChannel::ShouldSetupDtlsSrtp(); |
2334 } | 2352 } |
2335 | 2353 |
2336 void DataChannel::OnStreamClosedRemotely(uint32_t sid) { | 2354 void DataChannel::OnStreamClosedRemotely(uint32_t sid) { |
2337 rtc::TypedMessageData<uint32_t>* message = | 2355 rtc::TypedMessageData<uint32_t>* message = |
2338 new rtc::TypedMessageData<uint32_t>(sid); | 2356 new rtc::TypedMessageData<uint32_t>(sid); |
2339 signaling_thread()->Post(this, MSG_STREAMCLOSEDREMOTELY, message); | 2357 signaling_thread()->Post(this, MSG_STREAMCLOSEDREMOTELY, message); |
2340 } | 2358 } |
2341 | 2359 |
2342 } // namespace cricket | 2360 } // namespace cricket |
OLD | NEW |