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

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

Issue 2946663003: content::RTCRtpSenders/Receivers using track adapter references. (Closed)
Patch Set: 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 1111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1122 return; 1122 return;
1123 } 1123 }
1124 1124
1125 size_t pos = local_streams_.Find(stream); 1125 size_t pos = local_streams_.Find(stream);
1126 if (pos == kNotFound) 1126 if (pos == kNotFound)
1127 return; 1127 return;
1128 1128
1129 local_streams_.erase(pos); 1129 local_streams_.erase(pos);
1130 1130
1131 peer_handler_->RemoveStream(stream->Descriptor()); 1131 peer_handler_->RemoveStream(stream->Descriptor());
1132
1133 // The senders of removed tracks will have become inactive.
1134 RemoveInactiveSenders();
1135 } 1132 }
1136 1133
1137 MediaStreamVector RTCPeerConnection::getLocalStreams() const { 1134 MediaStreamVector RTCPeerConnection::getLocalStreams() const {
1138 return local_streams_; 1135 return local_streams_;
1139 } 1136 }
1140 1137
1141 MediaStreamVector RTCPeerConnection::getRemoteStreams() const { 1138 MediaStreamVector RTCPeerConnection::getRemoteStreams() const {
1142 return remote_streams_; 1139 return remote_streams_;
1143 } 1140 }
1144 1141
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
1291 MediaStreamTrack* RTCPeerConnection::GetRemoteTrackById( 1288 MediaStreamTrack* RTCPeerConnection::GetRemoteTrackById(
1292 const String& track_id) const { 1289 const String& track_id) const {
1293 for (const auto& remote_stream : remote_streams_) { 1290 for (const auto& remote_stream : remote_streams_) {
1294 MediaStreamTrack* track = remote_stream->getTrackById(track_id); 1291 MediaStreamTrack* track = remote_stream->getTrackById(track_id);
1295 if (track) 1292 if (track)
1296 return track; 1293 return track;
1297 } 1294 }
1298 return nullptr; 1295 return nullptr;
1299 } 1296 }
1300 1297
1301 void RTCPeerConnection::RemoveInactiveSenders() {
1302 std::set<uintptr_t> inactive_sender_ids;
1303 for (uintptr_t id : rtp_senders_.Keys()) {
1304 inactive_sender_ids.insert(id);
1305 }
1306 for (const auto& web_rtp_sender : peer_handler_->GetSenders()) {
1307 inactive_sender_ids.erase(web_rtp_sender->Id());
1308 }
1309 for (uintptr_t id : inactive_sender_ids) {
1310 rtp_senders_.erase(id);
1311 }
1312 }
1313
1314 void RTCPeerConnection::RemoveInactiveReceivers() {
1315 std::set<uintptr_t> inactive_receiver_ids;
1316 for (uintptr_t id : rtp_receivers_.Keys()) {
1317 inactive_receiver_ids.insert(id);
1318 }
1319 for (const auto& web_rtp_receiver : peer_handler_->GetReceivers()) {
1320 inactive_receiver_ids.erase(web_rtp_receiver->Id());
1321 }
1322 for (uintptr_t id : inactive_receiver_ids) {
1323 rtp_receivers_.erase(id);
1324 }
1325 }
1326
1327 RTCDTMFSender* RTCPeerConnection::createDTMFSender( 1298 RTCDTMFSender* RTCPeerConnection::createDTMFSender(
1328 MediaStreamTrack* track, 1299 MediaStreamTrack* track,
1329 ExceptionState& exception_state) { 1300 ExceptionState& exception_state) {
1330 if (ThrowExceptionIfSignalingStateClosed(signaling_state_, exception_state)) 1301 if (ThrowExceptionIfSignalingStateClosed(signaling_state_, exception_state))
1331 return nullptr; 1302 return nullptr;
1332 1303
1333 DCHECK(track); 1304 DCHECK(track);
1334 1305
1335 if (!GetLocalTrackById(track->id())) { 1306 if (!GetLocalTrackById(track->id())) {
1336 exception_state.ThrowDOMException( 1307 exception_state.ThrowDOMException(
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1418 MediaStream* stream = static_cast<MediaStream*>(stream_descriptor->Client()); 1389 MediaStream* stream = static_cast<MediaStream*>(stream_descriptor->Client());
1419 stream->StreamEnded(); 1390 stream->StreamEnded();
1420 1391
1421 if (signaling_state_ == kSignalingStateClosed) 1392 if (signaling_state_ == kSignalingStateClosed)
1422 return; 1393 return;
1423 1394
1424 size_t pos = remote_streams_.Find(stream); 1395 size_t pos = remote_streams_.Find(stream);
1425 DCHECK(pos != kNotFound); 1396 DCHECK(pos != kNotFound);
1426 remote_streams_.erase(pos); 1397 remote_streams_.erase(pos);
1427 1398
1428 // The receivers of removed tracks will have become inactive.
1429 RemoveInactiveReceivers();
1430
1431 ScheduleDispatchEvent( 1399 ScheduleDispatchEvent(
1432 MediaStreamEvent::Create(EventTypeNames::removestream, stream)); 1400 MediaStreamEvent::Create(EventTypeNames::removestream, stream));
1433 } 1401 }
1434 1402
1435 void RTCPeerConnection::DidAddRemoteDataChannel( 1403 void RTCPeerConnection::DidAddRemoteDataChannel(
1436 WebRTCDataChannelHandler* handler) { 1404 WebRTCDataChannelHandler* handler) {
1437 DCHECK(!closed_); 1405 DCHECK(!closed_);
1438 DCHECK(GetExecutionContext()->IsContextThread()); 1406 DCHECK(GetExecutionContext()->IsContextThread());
1439 1407
1440 if (signaling_state_ == kSignalingStateClosed) 1408 if (signaling_state_ == kSignalingStateClosed)
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
1602 visitor->Trace(remote_streams_); 1570 visitor->Trace(remote_streams_);
1603 visitor->Trace(rtp_senders_); 1571 visitor->Trace(rtp_senders_);
1604 visitor->Trace(rtp_receivers_); 1572 visitor->Trace(rtp_receivers_);
1605 visitor->Trace(dispatch_scheduled_event_runner_); 1573 visitor->Trace(dispatch_scheduled_event_runner_);
1606 visitor->Trace(scheduled_events_); 1574 visitor->Trace(scheduled_events_);
1607 EventTargetWithInlineData::Trace(visitor); 1575 EventTargetWithInlineData::Trace(visitor);
1608 SuspendableObject::Trace(visitor); 1576 SuspendableObject::Trace(visitor);
1609 } 1577 }
1610 1578
1611 } // namespace blink 1579 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698