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

Side by Side Diff: third_party/WebKit/Source/modules/peerconnection/RTCPeerConnection.cpp

Issue 2946663003: content::RTCRtpSenders/Receivers using track adapter references. (Closed)
Patch Set: scoped_refptr and std::move Created 3 years, 6 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 1117 matching lines...) Expand 10 before | Expand all | Expand 10 after
1128 } 1128 }
1129 1129
1130 size_t pos = local_streams_.Find(stream); 1130 size_t pos = local_streams_.Find(stream);
1131 if (pos == kNotFound) 1131 if (pos == kNotFound)
1132 return; 1132 return;
1133 1133
1134 local_streams_.erase(pos); 1134 local_streams_.erase(pos);
1135 stream->UnregisterObserver(this); 1135 stream->UnregisterObserver(this);
1136 1136
1137 peer_handler_->RemoveStream(stream->Descriptor()); 1137 peer_handler_->RemoveStream(stream->Descriptor());
1138
1139 // The senders of removed tracks will have become inactive.
1140 RemoveInactiveSenders();
1141 } 1138 }
1142 1139
1143 MediaStreamVector RTCPeerConnection::getLocalStreams() const { 1140 MediaStreamVector RTCPeerConnection::getLocalStreams() const {
1144 return local_streams_; 1141 return local_streams_;
1145 } 1142 }
1146 1143
1147 MediaStreamVector RTCPeerConnection::getRemoteStreams() const { 1144 MediaStreamVector RTCPeerConnection::getRemoteStreams() const {
1148 return remote_streams_; 1145 return remote_streams_;
1149 } 1146 }
1150 1147
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
1281 has_data_channels_ = true; 1278 has_data_channels_ = true;
1282 1279
1283 return channel; 1280 return channel;
1284 } 1281 }
1285 1282
1286 MediaStreamTrack* RTCPeerConnection::GetTrack( 1283 MediaStreamTrack* RTCPeerConnection::GetTrack(
1287 const WebMediaStreamTrack& web_track) const { 1284 const WebMediaStreamTrack& web_track) const {
1288 return tracks_.at(static_cast<MediaStreamComponent*>(web_track)); 1285 return tracks_.at(static_cast<MediaStreamComponent*>(web_track));
1289 } 1286 }
1290 1287
1291 void RTCPeerConnection::RemoveInactiveSenders() {
1292 std::set<uintptr_t> inactive_sender_ids;
1293 for (uintptr_t id : rtp_senders_.Keys()) {
1294 inactive_sender_ids.insert(id);
1295 }
1296 for (const auto& web_rtp_sender : peer_handler_->GetSenders()) {
1297 inactive_sender_ids.erase(web_rtp_sender->Id());
1298 }
1299 for (uintptr_t id : inactive_sender_ids) {
1300 rtp_senders_.erase(id);
1301 }
1302 }
1303
1304 void RTCPeerConnection::RemoveInactiveReceivers() {
1305 std::set<uintptr_t> inactive_receiver_ids;
1306 for (uintptr_t id : rtp_receivers_.Keys()) {
1307 inactive_receiver_ids.insert(id);
1308 }
1309 for (const auto& web_rtp_receiver : peer_handler_->GetReceivers()) {
1310 inactive_receiver_ids.erase(web_rtp_receiver->Id());
1311 }
1312 for (uintptr_t id : inactive_receiver_ids) {
1313 rtp_receivers_.erase(id);
1314 }
1315 }
1316
1317 RTCDTMFSender* RTCPeerConnection::createDTMFSender( 1288 RTCDTMFSender* RTCPeerConnection::createDTMFSender(
1318 MediaStreamTrack* track, 1289 MediaStreamTrack* track,
1319 ExceptionState& exception_state) { 1290 ExceptionState& exception_state) {
1320 if (ThrowExceptionIfSignalingStateClosed(signaling_state_, exception_state)) 1291 if (ThrowExceptionIfSignalingStateClosed(signaling_state_, exception_state))
1321 return nullptr; 1292 return nullptr;
1322 1293
1323 DCHECK(track); 1294 DCHECK(track);
1324 1295
1325 bool is_local_stream_track = false; 1296 bool is_local_stream_track = false;
1326 for (const auto& local_stream : local_streams_) { 1297 for (const auto& local_stream : local_streams_) {
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1436 stream->StreamEnded(); 1407 stream->StreamEnded();
1437 1408
1438 if (signaling_state_ == kSignalingStateClosed) 1409 if (signaling_state_ == kSignalingStateClosed)
1439 return; 1410 return;
1440 1411
1441 size_t pos = remote_streams_.Find(stream); 1412 size_t pos = remote_streams_.Find(stream);
1442 DCHECK(pos != kNotFound); 1413 DCHECK(pos != kNotFound);
1443 remote_streams_.erase(pos); 1414 remote_streams_.erase(pos);
1444 stream->UnregisterObserver(this); 1415 stream->UnregisterObserver(this);
1445 1416
1446 // The receivers of removed tracks will have become inactive.
1447 RemoveInactiveReceivers();
1448
1449 ScheduleDispatchEvent( 1417 ScheduleDispatchEvent(
1450 MediaStreamEvent::Create(EventTypeNames::removestream, stream)); 1418 MediaStreamEvent::Create(EventTypeNames::removestream, stream));
1451 } 1419 }
1452 1420
1453 void RTCPeerConnection::DidAddRemoteDataChannel( 1421 void RTCPeerConnection::DidAddRemoteDataChannel(
1454 WebRTCDataChannelHandler* handler) { 1422 WebRTCDataChannelHandler* handler) {
1455 DCHECK(!closed_); 1423 DCHECK(!closed_);
1456 DCHECK(GetExecutionContext()->IsContextThread()); 1424 DCHECK(GetExecutionContext()->IsContextThread());
1457 1425
1458 if (signaling_state_ == kSignalingStateClosed) 1426 if (signaling_state_ == kSignalingStateClosed)
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
1619 visitor->Trace(rtp_senders_); 1587 visitor->Trace(rtp_senders_);
1620 visitor->Trace(rtp_receivers_); 1588 visitor->Trace(rtp_receivers_);
1621 visitor->Trace(dispatch_scheduled_event_runner_); 1589 visitor->Trace(dispatch_scheduled_event_runner_);
1622 visitor->Trace(scheduled_events_); 1590 visitor->Trace(scheduled_events_);
1623 EventTargetWithInlineData::Trace(visitor); 1591 EventTargetWithInlineData::Trace(visitor);
1624 SuspendableObject::Trace(visitor); 1592 SuspendableObject::Trace(visitor);
1625 MediaStreamObserver::Trace(visitor); 1593 MediaStreamObserver::Trace(visitor);
1626 } 1594 }
1627 1595
1628 } // namespace blink 1596 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698