Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(529)

Side by Side Diff: webrtc/pc/channel.cc

Issue 2260963002: Some cleanup in BaseChannel RTCP mux code. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Clarifying comment. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/pc/channel.h ('k') | webrtc/pc/rtcpmuxfilter.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 MediaChannel* media_channel, 162 MediaChannel* media_channel,
163 TransportController* transport_controller, 163 TransportController* transport_controller,
164 const std::string& content_name, 164 const std::string& content_name,
165 bool rtcp) 165 bool rtcp)
166 : worker_thread_(worker_thread), 166 : worker_thread_(worker_thread),
167 network_thread_(network_thread), 167 network_thread_(network_thread),
168 168
169 content_name_(content_name), 169 content_name_(content_name),
170 170
171 transport_controller_(transport_controller), 171 transport_controller_(transport_controller),
172 rtcp_transport_enabled_(rtcp), 172 rtcp_enabled_(rtcp),
173 transport_channel_(nullptr), 173 media_channel_(media_channel) {
174 rtcp_transport_channel_(nullptr),
175 rtp_ready_to_send_(false),
176 rtcp_ready_to_send_(false),
177 writable_(false),
178 was_ever_writable_(false),
179 has_received_packet_(false),
180 dtls_keyed_(false),
181 secure_required_(false),
182 rtp_abs_sendtime_extn_id_(-1),
183
184 media_channel_(media_channel),
185 enabled_(false),
186 local_content_direction_(MD_INACTIVE),
187 remote_content_direction_(MD_INACTIVE) {
188 ASSERT(worker_thread_ == rtc::Thread::Current()); 174 ASSERT(worker_thread_ == rtc::Thread::Current());
189 if (transport_controller) { 175 if (transport_controller) {
190 RTC_DCHECK_EQ(network_thread, transport_controller->network_thread()); 176 RTC_DCHECK_EQ(network_thread, transport_controller->network_thread());
191 } 177 }
192 LOG(LS_INFO) << "Created channel for " << content_name; 178 LOG(LS_INFO) << "Created channel for " << content_name;
193 } 179 }
194 180
195 BaseChannel::~BaseChannel() { 181 BaseChannel::~BaseChannel() {
196 TRACE_EVENT0("webrtc", "BaseChannel::~BaseChannel"); 182 TRACE_EVENT0("webrtc", "BaseChannel::~BaseChannel");
197 ASSERT(worker_thread_ == rtc::Thread::Current()); 183 ASSERT(worker_thread_ == rtc::Thread::Current());
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 RTC_DCHECK(network_thread_->IsCurrent()); 247 RTC_DCHECK(network_thread_->IsCurrent());
262 const std::string& transport_name = 248 const std::string& transport_name =
263 (bundle_transport_name ? *bundle_transport_name : content_name()); 249 (bundle_transport_name ? *bundle_transport_name : content_name());
264 if (!SetTransport_n(transport_name)) { 250 if (!SetTransport_n(transport_name)) {
265 return false; 251 return false;
266 } 252 }
267 253
268 if (!SetDtlsSrtpCryptoSuites_n(transport_channel_, false)) { 254 if (!SetDtlsSrtpCryptoSuites_n(transport_channel_, false)) {
269 return false; 255 return false;
270 } 256 }
271 if (rtcp_transport_enabled() && 257 if (rtcp_transport_channel_ &&
272 !SetDtlsSrtpCryptoSuites_n(rtcp_transport_channel_, true)) { 258 !SetDtlsSrtpCryptoSuites_n(rtcp_transport_channel_, true)) {
273 return false; 259 return false;
274 } 260 }
275 return true; 261 return true;
276 } 262 }
277 263
278 void BaseChannel::Deinit() { 264 void BaseChannel::Deinit() {
279 RTC_DCHECK(worker_thread_->IsCurrent()); 265 RTC_DCHECK(worker_thread_->IsCurrent());
280 media_channel_->SetInterface(NULL); 266 media_channel_->SetInterface(NULL);
281 // Packets arrive on the network thread, processing packets calls virtual 267 // Packets arrive on the network thread, processing packets calls virtual
(...skipping 19 matching lines...) Expand all
301 // When using DTLS-SRTP, we must reset the SrtpFilter every time the transport 287 // When using DTLS-SRTP, we must reset the SrtpFilter every time the transport
302 // changes and wait until the DTLS handshake is complete to set the newly 288 // changes and wait until the DTLS handshake is complete to set the newly
303 // negotiated parameters. 289 // negotiated parameters.
304 if (ShouldSetupDtlsSrtp_n()) { 290 if (ShouldSetupDtlsSrtp_n()) {
305 // Set |writable_| to false such that UpdateWritableState_w can set up 291 // Set |writable_| to false such that UpdateWritableState_w can set up
306 // DTLS-SRTP when the writable_ becomes true again. 292 // DTLS-SRTP when the writable_ becomes true again.
307 writable_ = false; 293 writable_ = false;
308 srtp_filter_.ResetParams(); 294 srtp_filter_.ResetParams();
309 } 295 }
310 296
311 // TODO(guoweis): Remove this grossness when we remove non-muxed RTCP. 297 // If this BaseChannel uses RTCP and we haven't fully negotiated RTCP mux,
312 if (rtcp_transport_enabled()) { 298 // we need an RTCP channel.
299 if (rtcp_enabled_ && !rtcp_mux_filter_.IsFullyActive()) {
313 LOG(LS_INFO) << "Create RTCP TransportChannel for " << content_name() 300 LOG(LS_INFO) << "Create RTCP TransportChannel for " << content_name()
314 << " on " << transport_name << " transport "; 301 << " on " << transport_name << " transport ";
302 // TODO(deadbeef): Remove this grossness when we remove non-muxed RTCP.
315 SetRtcpTransportChannel_n( 303 SetRtcpTransportChannel_n(
316 transport_controller_->CreateTransportChannel_n( 304 transport_controller_->CreateTransportChannel_n(
317 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTCP), 305 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTCP),
318 false /* update_writablity */); 306 false /* update_writablity */);
319 if (!rtcp_transport_channel_) { 307 if (!rtcp_transport_channel_) {
320 return false; 308 return false;
321 } 309 }
322 } 310 }
323 311
324 // We're not updating the writablity during the transition state. 312 // We're not updating the writablity during the transition state.
325 SetTransportChannel_n(transport_controller_->CreateTransportChannel_n( 313 SetTransportChannel_n(transport_controller_->CreateTransportChannel_n(
326 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP)); 314 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP));
327 if (!transport_channel_) { 315 if (!transport_channel_) {
328 return false; 316 return false;
329 } 317 }
330 318
331 // TODO(guoweis): Remove this grossness when we remove non-muxed RTCP. 319 // TODO(deadbeef): Remove this grossness when we remove non-muxed RTCP.
332 if (rtcp_transport_enabled()) { 320 if (rtcp_transport_channel_) {
333 // We can only update the RTCP ready to send after set_transport_channel has 321 // We can only update the RTCP ready to send after set_transport_channel has
334 // handled channel writability. 322 // handled channel writability.
335 SetReadyToSend( 323 SetReadyToSend(true, rtcp_transport_channel_->writable());
336 true, rtcp_transport_channel_ && rtcp_transport_channel_->writable());
337 } 324 }
338 transport_name_ = transport_name; 325 transport_name_ = transport_name;
339 return true; 326 return true;
340 } 327 }
341 328
342 void BaseChannel::SetTransportChannel_n(TransportChannel* new_tc) { 329 void BaseChannel::SetTransportChannel_n(TransportChannel* new_tc) {
343 RTC_DCHECK(network_thread_->IsCurrent()); 330 RTC_DCHECK(network_thread_->IsCurrent());
344 331
345 TransportChannel* old_tc = transport_channel_; 332 TransportChannel* old_tc = transport_channel_;
346 if (!old_tc && !new_tc) { 333 if (!old_tc && !new_tc) {
(...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after
1201 1188
1202 void BaseChannel::ActivateRtcpMux() { 1189 void BaseChannel::ActivateRtcpMux() {
1203 network_thread_->Invoke<void>(RTC_FROM_HERE, 1190 network_thread_->Invoke<void>(RTC_FROM_HERE,
1204 Bind(&BaseChannel::ActivateRtcpMux_n, this)); 1191 Bind(&BaseChannel::ActivateRtcpMux_n, this));
1205 } 1192 }
1206 1193
1207 void BaseChannel::ActivateRtcpMux_n() { 1194 void BaseChannel::ActivateRtcpMux_n() {
1208 if (!rtcp_mux_filter_.IsActive()) { 1195 if (!rtcp_mux_filter_.IsActive()) {
1209 rtcp_mux_filter_.SetActive(); 1196 rtcp_mux_filter_.SetActive();
1210 SetRtcpTransportChannel_n(nullptr, true); 1197 SetRtcpTransportChannel_n(nullptr, true);
1211 rtcp_transport_enabled_ = false;
1212 } 1198 }
1213 } 1199 }
1214 1200
1215 bool BaseChannel::SetRtcpMux_n(bool enable, 1201 bool BaseChannel::SetRtcpMux_n(bool enable,
1216 ContentAction action, 1202 ContentAction action,
1217 ContentSource src, 1203 ContentSource src,
1218 std::string* error_desc) { 1204 std::string* error_desc) {
1219 bool ret = false; 1205 bool ret = false;
1220 switch (action) { 1206 switch (action) {
1221 case CA_OFFER: 1207 case CA_OFFER:
1222 ret = rtcp_mux_filter_.SetOffer(enable, src); 1208 ret = rtcp_mux_filter_.SetOffer(enable, src);
1223 break; 1209 break;
1224 case CA_PRANSWER: 1210 case CA_PRANSWER:
1225 ret = rtcp_mux_filter_.SetProvisionalAnswer(enable, src); 1211 ret = rtcp_mux_filter_.SetProvisionalAnswer(enable, src);
1226 break; 1212 break;
1227 case CA_ANSWER: 1213 case CA_ANSWER:
1228 ret = rtcp_mux_filter_.SetAnswer(enable, src); 1214 ret = rtcp_mux_filter_.SetAnswer(enable, src);
1229 if (ret && rtcp_mux_filter_.IsActive()) { 1215 if (ret && rtcp_mux_filter_.IsActive()) {
1230 // We activated RTCP mux, close down the RTCP transport. 1216 // We activated RTCP mux, close down the RTCP transport.
1231 LOG(LS_INFO) << "Enabling rtcp-mux for " << content_name() 1217 LOG(LS_INFO) << "Enabling rtcp-mux for " << content_name()
1232 << " by destroying RTCP transport channel for " 1218 << " by destroying RTCP transport channel for "
1233 << transport_name(); 1219 << transport_name();
1234 SetRtcpTransportChannel_n(nullptr, true); 1220 SetRtcpTransportChannel_n(nullptr, true);
1235 rtcp_transport_enabled_ = false;
1236 } 1221 }
1237 break; 1222 break;
1238 case CA_UPDATE: 1223 case CA_UPDATE:
1239 // No RTCP mux info. 1224 // No RTCP mux info.
1240 ret = true; 1225 ret = true;
1241 break; 1226 break;
1242 default: 1227 default:
1243 break; 1228 break;
1244 } 1229 }
1245 if (!ret) { 1230 if (!ret) {
(...skipping 1188 matching lines...) Expand 10 before | Expand all | Expand 10 after
2434 } 2419 }
2435 2420
2436 void DataChannel::OnStreamClosedRemotely(uint32_t sid) { 2421 void DataChannel::OnStreamClosedRemotely(uint32_t sid) {
2437 rtc::TypedMessageData<uint32_t>* message = 2422 rtc::TypedMessageData<uint32_t>* message =
2438 new rtc::TypedMessageData<uint32_t>(sid); 2423 new rtc::TypedMessageData<uint32_t>(sid);
2439 signaling_thread()->Post(RTC_FROM_HERE, this, MSG_STREAMCLOSEDREMOTELY, 2424 signaling_thread()->Post(RTC_FROM_HERE, this, MSG_STREAMCLOSEDREMOTELY,
2440 message); 2425 message);
2441 } 2426 }
2442 2427
2443 } // namespace cricket 2428 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/pc/channel.h ('k') | webrtc/pc/rtcpmuxfilter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698