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

Side by Side Diff: webrtc/api/peerconnection.cc

Issue 1816143002: Removed MediaStreamTrackInterface::set_state (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@track_state_listen_on_source2
Patch Set: Rebased Created 4 years, 9 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/api/peerconnection.h ('k') | webrtc/api/peerconnectioninterface_unittest.cc » ('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 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2012 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 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 session_options->AddSendStream(cricket::MEDIA_TYPE_DATA, streamid, 370 session_options->AddSendStream(cricket::MEDIA_TYPE_DATA, streamid,
371 sync_label); 371 sync_label);
372 } 372 }
373 } 373 }
374 } 374 }
375 375
376 } // namespace 376 } // namespace
377 377
378 namespace webrtc { 378 namespace webrtc {
379 379
380 // Factory class for creating remote MediaStreams and MediaStreamTracks.
381 class RemoteMediaStreamFactory {
382 public:
383 explicit RemoteMediaStreamFactory(rtc::Thread* signaling_thread)
384 : signaling_thread_(signaling_thread) {}
385
386 rtc::scoped_refptr<MediaStreamInterface> CreateMediaStream(
387 const std::string& stream_label) {
388 return MediaStreamProxy::Create(signaling_thread_,
389 MediaStream::Create(stream_label));
390 }
391
392 AudioTrackInterface* AddAudioTrack(uint32_t ssrc,
393 AudioProviderInterface* provider,
394 webrtc::MediaStreamInterface* stream,
395 const std::string& track_id) {
396 return AddTrack<AudioTrackInterface, AudioTrack, AudioTrackProxy>(
397 stream, track_id, RemoteAudioSource::Create(ssrc, provider));
398 }
399
400 private:
401 template <typename TI, typename T, typename TP, typename S>
402 TI* AddTrack(MediaStreamInterface* stream,
403 const std::string& track_id,
404 const S& source) {
405 rtc::scoped_refptr<TI> track(
406 TP::Create(signaling_thread_, T::Create(track_id, source)));
407 track->set_state(webrtc::MediaStreamTrackInterface::kLive);
408 if (stream->AddTrack(track)) {
409 return track;
410 }
411 return nullptr;
412 }
413
414 rtc::Thread* signaling_thread_;
415 };
416
417 bool ExtractMediaSessionOptions( 380 bool ExtractMediaSessionOptions(
418 const PeerConnectionInterface::RTCOfferAnswerOptions& rtc_options, 381 const PeerConnectionInterface::RTCOfferAnswerOptions& rtc_options,
419 bool is_offer, 382 bool is_offer,
420 cricket::MediaSessionOptions* session_options) { 383 cricket::MediaSessionOptions* session_options) {
421 typedef PeerConnectionInterface::RTCOfferAnswerOptions RTCOfferAnswerOptions; 384 typedef PeerConnectionInterface::RTCOfferAnswerOptions RTCOfferAnswerOptions;
422 if (!IsValidOfferToReceiveMedia(rtc_options.offer_to_receive_audio) || 385 if (!IsValidOfferToReceiveMedia(rtc_options.offer_to_receive_audio) ||
423 !IsValidOfferToReceiveMedia(rtc_options.offer_to_receive_video)) { 386 !IsValidOfferToReceiveMedia(rtc_options.offer_to_receive_video)) {
424 return false; 387 return false;
425 } 388 }
426 389
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 portallocator_flags |= cricket::PORTALLOCATOR_DISABLE_TCP; 564 portallocator_flags |= cricket::PORTALLOCATOR_DISABLE_TCP;
602 LOG(LS_INFO) << "TCP candidates are disabled."; 565 LOG(LS_INFO) << "TCP candidates are disabled.";
603 } 566 }
604 567
605 port_allocator_->set_flags(portallocator_flags); 568 port_allocator_->set_flags(portallocator_flags);
606 // No step delay is used while allocating ports. 569 // No step delay is used while allocating ports.
607 port_allocator_->set_step_delay(cricket::kMinimumStepDelay); 570 port_allocator_->set_step_delay(cricket::kMinimumStepDelay);
608 571
609 media_controller_.reset(factory_->CreateMediaController(media_config)); 572 media_controller_.reset(factory_->CreateMediaController(media_config));
610 573
611 remote_stream_factory_.reset(
612 new RemoteMediaStreamFactory(factory_->signaling_thread()));
613
614 session_.reset( 574 session_.reset(
615 new WebRtcSession(media_controller_.get(), factory_->signaling_thread(), 575 new WebRtcSession(media_controller_.get(), factory_->signaling_thread(),
616 factory_->worker_thread(), port_allocator_.get())); 576 factory_->worker_thread(), port_allocator_.get()));
617 stats_.reset(new StatsCollector(this)); 577 stats_.reset(new StatsCollector(this));
618 578
619 // Initialize the WebRtcSession. It creates transport channels etc. 579 // Initialize the WebRtcSession. It creates transport channels etc.
620 if (!session_->Initialize(factory_->options(), std::move(dtls_identity_store), 580 if (!session_->Initialize(factory_->options(), std::move(dtls_identity_store),
621 configuration)) { 581 configuration)) {
622 return false; 582 return false;
623 } 583 }
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after
1313 sctp_data_channels_to_free_.clear(); 1273 sctp_data_channels_to_free_.clear();
1314 break; 1274 break;
1315 } 1275 }
1316 default: 1276 default:
1317 RTC_DCHECK(false && "Not implemented"); 1277 RTC_DCHECK(false && "Not implemented");
1318 break; 1278 break;
1319 } 1279 }
1320 } 1280 }
1321 1281
1322 void PeerConnection::CreateAudioReceiver(MediaStreamInterface* stream, 1282 void PeerConnection::CreateAudioReceiver(MediaStreamInterface* stream,
1323 AudioTrackInterface* audio_track, 1283 const std::string& track_id,
1324 uint32_t ssrc) { 1284 uint32_t ssrc) {
1325 receivers_.push_back(RtpReceiverProxy::Create( 1285 receivers_.push_back(RtpReceiverProxy::Create(
1326 signaling_thread(), 1286 signaling_thread(),
1327 new AudioRtpReceiver(audio_track, ssrc, session_.get()))); 1287 new AudioRtpReceiver(stream, track_id, ssrc, session_.get())));
1328 } 1288 }
1329 1289
1330 void PeerConnection::CreateVideoReceiver(MediaStreamInterface* stream, 1290 void PeerConnection::CreateVideoReceiver(MediaStreamInterface* stream,
1331 const std::string& track_id, 1291 const std::string& track_id,
1332 uint32_t ssrc) { 1292 uint32_t ssrc) {
1333 VideoRtpReceiver* video_receiver = new VideoRtpReceiver( 1293 receivers_.push_back(RtpReceiverProxy::Create(
1334 stream, track_id, factory_->worker_thread(), ssrc, session_.get()); 1294 signaling_thread(),
1335 receivers_.push_back( 1295 new VideoRtpReceiver(stream, track_id, factory_->worker_thread(), ssrc,
1336 RtpReceiverProxy::Create(signaling_thread(), video_receiver)); 1296 session_.get())));
1337 } 1297 }
1338 1298
1339 // TODO(deadbeef): Keep RtpReceivers around even if track goes away in remote 1299 // TODO(deadbeef): Keep RtpReceivers around even if track goes away in remote
1340 // description. 1300 // description.
1341 void PeerConnection::DestroyAudioReceiver(MediaStreamInterface* stream, 1301 void PeerConnection::DestroyReceiver(const std::string& track_id) {
1342 AudioTrackInterface* audio_track) { 1302 auto it = FindReceiverForTrack(track_id);
1343 auto it = FindReceiverForTrack(audio_track);
1344 if (it == receivers_.end()) { 1303 if (it == receivers_.end()) {
1345 LOG(LS_WARNING) << "RtpReceiver for track with id " << audio_track->id() 1304 LOG(LS_WARNING) << "RtpReceiver for track with id " << track_id
1346 << " doesn't exist."; 1305 << " doesn't exist.";
1347 } else { 1306 } else {
1348 (*it)->Stop(); 1307 (*it)->Stop();
1349 receivers_.erase(it); 1308 receivers_.erase(it);
1350 } 1309 }
1351 } 1310 }
1352 1311
1353 void PeerConnection::DestroyVideoReceiver(MediaStreamInterface* stream, 1312 void PeerConnection::StopReceivers(cricket::MediaType media_type) {
1354 VideoTrackInterface* video_track) { 1313 TrackInfos* current_tracks = GetRemoteTracks(media_type);
1355 auto it = FindReceiverForTrack(video_track); 1314 for (const auto& track_info : *current_tracks) {
1356 if (it == receivers_.end()) { 1315 auto it = FindReceiverForTrack(track_info.track_id);
1357 LOG(LS_WARNING) << "RtpReceiver for track with id " << video_track->id() 1316 if (it == receivers_.end()) {
1358 << " doesn't exist."; 1317 LOG(LS_WARNING) << "RtpReceiver for track with id " << track_info.track_id
1359 } else { 1318 << " doesn't exist.";
1360 (*it)->Stop(); 1319 } else {
1361 receivers_.erase(it); 1320 (*it)->Stop();
1321 }
1362 } 1322 }
1363 } 1323 }
1364 1324
1365 void PeerConnection::OnIceConnectionChange( 1325 void PeerConnection::OnIceConnectionChange(
1366 PeerConnectionInterface::IceConnectionState new_state) { 1326 PeerConnectionInterface::IceConnectionState new_state) {
1367 RTC_DCHECK(signaling_thread()->IsCurrent()); 1327 RTC_DCHECK(signaling_thread()->IsCurrent());
1368 // After transitioning to "closed", ignore any additional states from 1328 // After transitioning to "closed", ignore any additional states from
1369 // WebRtcSession (such as "disconnected"). 1329 // WebRtcSession (such as "disconnected").
1370 if (IsClosed()) { 1330 if (IsClosed()) {
1371 return; 1331 return;
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
1632 // The sync_label is the MediaStream label and the |stream.id| is the 1592 // The sync_label is the MediaStream label and the |stream.id| is the
1633 // track id. 1593 // track id.
1634 const std::string& stream_label = params.sync_label; 1594 const std::string& stream_label = params.sync_label;
1635 const std::string& track_id = params.id; 1595 const std::string& track_id = params.id;
1636 uint32_t ssrc = params.first_ssrc(); 1596 uint32_t ssrc = params.first_ssrc();
1637 1597
1638 rtc::scoped_refptr<MediaStreamInterface> stream = 1598 rtc::scoped_refptr<MediaStreamInterface> stream =
1639 remote_streams_->find(stream_label); 1599 remote_streams_->find(stream_label);
1640 if (!stream) { 1600 if (!stream) {
1641 // This is a new MediaStream. Create a new remote MediaStream. 1601 // This is a new MediaStream. Create a new remote MediaStream.
1642 stream = remote_stream_factory_->CreateMediaStream(stream_label); 1602 stream = MediaStreamProxy::Create(rtc::Thread::Current(),
1603 MediaStream::Create(stream_label));
1643 remote_streams_->AddStream(stream); 1604 remote_streams_->AddStream(stream);
1644 new_streams->AddStream(stream); 1605 new_streams->AddStream(stream);
1645 } 1606 }
1646 1607
1647 const TrackInfo* track_info = 1608 const TrackInfo* track_info =
1648 FindTrackInfo(*current_tracks, stream_label, track_id); 1609 FindTrackInfo(*current_tracks, stream_label, track_id);
1649 if (!track_info) { 1610 if (!track_info) {
1650 current_tracks->push_back(TrackInfo(stream_label, track_id, ssrc)); 1611 current_tracks->push_back(TrackInfo(stream_label, track_id, ssrc));
1651 OnRemoteTrackSeen(stream_label, track_id, ssrc, media_type); 1612 OnRemoteTrackSeen(stream_label, track_id, ssrc, media_type);
1652 } 1613 }
1653 } 1614 }
1654 1615
1655 // Add default track if necessary. 1616 // Add default track if necessary.
1656 if (default_track_needed) { 1617 if (default_track_needed) {
1657 rtc::scoped_refptr<MediaStreamInterface> default_stream = 1618 rtc::scoped_refptr<MediaStreamInterface> default_stream =
1658 remote_streams_->find(kDefaultStreamLabel); 1619 remote_streams_->find(kDefaultStreamLabel);
1659 if (!default_stream) { 1620 if (!default_stream) {
1660 // Create the new default MediaStream. 1621 // Create the new default MediaStream.
1661 default_stream = 1622 default_stream = MediaStreamProxy::Create(
1662 remote_stream_factory_->CreateMediaStream(kDefaultStreamLabel); 1623 rtc::Thread::Current(), MediaStream::Create(kDefaultStreamLabel));
1663 remote_streams_->AddStream(default_stream); 1624 remote_streams_->AddStream(default_stream);
1664 new_streams->AddStream(default_stream); 1625 new_streams->AddStream(default_stream);
1665 } 1626 }
1666 std::string default_track_id = (media_type == cricket::MEDIA_TYPE_AUDIO) 1627 std::string default_track_id = (media_type == cricket::MEDIA_TYPE_AUDIO)
1667 ? kDefaultAudioTrackLabel 1628 ? kDefaultAudioTrackLabel
1668 : kDefaultVideoTrackLabel; 1629 : kDefaultVideoTrackLabel;
1669 const TrackInfo* default_track_info = 1630 const TrackInfo* default_track_info =
1670 FindTrackInfo(*current_tracks, kDefaultStreamLabel, default_track_id); 1631 FindTrackInfo(*current_tracks, kDefaultStreamLabel, default_track_id);
1671 if (!default_track_info) { 1632 if (!default_track_info) {
1672 current_tracks->push_back( 1633 current_tracks->push_back(
1673 TrackInfo(kDefaultStreamLabel, default_track_id, 0)); 1634 TrackInfo(kDefaultStreamLabel, default_track_id, 0));
1674 OnRemoteTrackSeen(kDefaultStreamLabel, default_track_id, 0, media_type); 1635 OnRemoteTrackSeen(kDefaultStreamLabel, default_track_id, 0, media_type);
1675 } 1636 }
1676 } 1637 }
1677 } 1638 }
1678 1639
1679 void PeerConnection::OnRemoteTrackSeen(const std::string& stream_label, 1640 void PeerConnection::OnRemoteTrackSeen(const std::string& stream_label,
1680 const std::string& track_id, 1641 const std::string& track_id,
1681 uint32_t ssrc, 1642 uint32_t ssrc,
1682 cricket::MediaType media_type) { 1643 cricket::MediaType media_type) {
1683 MediaStreamInterface* stream = remote_streams_->find(stream_label); 1644 MediaStreamInterface* stream = remote_streams_->find(stream_label);
1684 1645
1685 if (media_type == cricket::MEDIA_TYPE_AUDIO) { 1646 if (media_type == cricket::MEDIA_TYPE_AUDIO) {
1686 AudioTrackInterface* audio_track = remote_stream_factory_->AddAudioTrack( 1647 CreateAudioReceiver(stream, track_id, ssrc);
1687 ssrc, session_.get(), stream, track_id);
1688 CreateAudioReceiver(stream, audio_track, ssrc);
1689 } else if (media_type == cricket::MEDIA_TYPE_VIDEO) { 1648 } else if (media_type == cricket::MEDIA_TYPE_VIDEO) {
1690 CreateVideoReceiver(stream, track_id, ssrc); 1649 CreateVideoReceiver(stream, track_id, ssrc);
1691 } else { 1650 } else {
1692 RTC_DCHECK(false && "Invalid media type"); 1651 RTC_DCHECK(false && "Invalid media type");
1693 } 1652 }
1694 } 1653 }
1695 1654
1696 void PeerConnection::OnRemoteTrackRemoved(const std::string& stream_label, 1655 void PeerConnection::OnRemoteTrackRemoved(const std::string& stream_label,
1697 const std::string& track_id, 1656 const std::string& track_id,
1698 cricket::MediaType media_type) { 1657 cricket::MediaType media_type) {
1699 MediaStreamInterface* stream = remote_streams_->find(stream_label); 1658 MediaStreamInterface* stream = remote_streams_->find(stream_label);
1700 1659
1701 if (media_type == cricket::MEDIA_TYPE_AUDIO) { 1660 if (media_type == cricket::MEDIA_TYPE_AUDIO) {
1661 // When the MediaEngine audio channel is destroyed, the RemoteAudioSource
1662 // will be notified which will end the AudioRtpReceiver::track().
1663 DestroyReceiver(track_id);
1702 rtc::scoped_refptr<AudioTrackInterface> audio_track = 1664 rtc::scoped_refptr<AudioTrackInterface> audio_track =
1703 stream->FindAudioTrack(track_id); 1665 stream->FindAudioTrack(track_id);
1704 if (audio_track) { 1666 if (audio_track) {
1705 audio_track->set_state(webrtc::MediaStreamTrackInterface::kEnded);
1706 stream->RemoveTrack(audio_track); 1667 stream->RemoveTrack(audio_track);
1707 DestroyAudioReceiver(stream, audio_track);
1708 } 1668 }
1709 } else if (media_type == cricket::MEDIA_TYPE_VIDEO) { 1669 } else if (media_type == cricket::MEDIA_TYPE_VIDEO) {
1670 // Stopping or destroying a VideoRtpReceiver will end the
1671 // VideoRtpReceiver::track().
1672 DestroyReceiver(track_id);
1710 rtc::scoped_refptr<VideoTrackInterface> video_track = 1673 rtc::scoped_refptr<VideoTrackInterface> video_track =
1711 stream->FindVideoTrack(track_id); 1674 stream->FindVideoTrack(track_id);
1712 if (video_track) { 1675 if (video_track) {
1676 // There's no guarantee the track is still available, e.g. the track may
1677 // have been removed from the stream by an application.
1713 stream->RemoveTrack(video_track); 1678 stream->RemoveTrack(video_track);
1714 // Stopping or destroying a VideoRtpReceiver will end the
1715 // VideoRtpReceiver::track().
1716 DestroyVideoReceiver(stream, video_track);
1717 } 1679 }
1718 } else { 1680 } else {
1719 ASSERT(false && "Invalid media type"); 1681 ASSERT(false && "Invalid media type");
1720 } 1682 }
1721 } 1683 }
1722 1684
1723 void PeerConnection::UpdateEndedRemoteMediaStreams() { 1685 void PeerConnection::UpdateEndedRemoteMediaStreams() {
1724 std::vector<rtc::scoped_refptr<MediaStreamInterface>> streams_to_remove; 1686 std::vector<rtc::scoped_refptr<MediaStreamInterface>> streams_to_remove;
1725 for (size_t i = 0; i < remote_streams_->count(); ++i) { 1687 for (size_t i = 0; i < remote_streams_->count(); ++i) {
1726 MediaStreamInterface* stream = remote_streams_->at(i); 1688 MediaStreamInterface* stream = remote_streams_->at(i);
1727 if (stream->GetAudioTracks().empty() && stream->GetVideoTracks().empty()) { 1689 if (stream->GetAudioTracks().empty() && stream->GetVideoTracks().empty()) {
1728 streams_to_remove.push_back(stream); 1690 streams_to_remove.push_back(stream);
1729 } 1691 }
1730 } 1692 }
1731 1693
1732 for (const auto& stream : streams_to_remove) { 1694 for (const auto& stream : streams_to_remove) {
1733 remote_streams_->RemoveStream(stream); 1695 remote_streams_->RemoveStream(stream);
1734 observer_->OnRemoveStream(stream); 1696 observer_->OnRemoveStream(stream);
1735 } 1697 }
1736 } 1698 }
1737 1699
1738 void PeerConnection::EndRemoteTracks(cricket::MediaType media_type) {
1739 TrackInfos* current_tracks = GetRemoteTracks(media_type);
1740 for (TrackInfos::iterator track_it = current_tracks->begin();
1741 track_it != current_tracks->end(); ++track_it) {
1742 const TrackInfo& info = *track_it;
1743 MediaStreamInterface* stream = remote_streams_->find(info.stream_label);
1744 if (media_type == cricket::MEDIA_TYPE_AUDIO) {
1745 AudioTrackInterface* track = stream->FindAudioTrack(info.track_id);
1746 // There's no guarantee the track is still available, e.g. the track may
1747 // have been removed from the stream by javascript.
1748 if (track) {
1749 track->set_state(webrtc::MediaStreamTrackInterface::kEnded);
1750 }
1751 }
1752 if (media_type == cricket::MEDIA_TYPE_VIDEO) {
1753 VideoTrackInterface* track = stream->FindVideoTrack(info.track_id);
1754 // There's no guarantee the track is still available, e.g. the track may
1755 // have been removed from the stream by javascript.
1756 if (track) {
1757 track->set_state(webrtc::MediaStreamTrackInterface::kEnded);
1758 }
1759 }
1760 }
1761 }
1762
1763 void PeerConnection::UpdateLocalTracks( 1700 void PeerConnection::UpdateLocalTracks(
1764 const std::vector<cricket::StreamParams>& streams, 1701 const std::vector<cricket::StreamParams>& streams,
1765 cricket::MediaType media_type) { 1702 cricket::MediaType media_type) {
1766 TrackInfos* current_tracks = GetLocalTracks(media_type); 1703 TrackInfos* current_tracks = GetLocalTracks(media_type);
1767 1704
1768 // Find removed tracks. I.e., tracks where the track id, stream label or ssrc 1705 // Find removed tracks. I.e., tracks where the track id, stream label or ssrc
1769 // don't match the new StreamParam. 1706 // don't match the new StreamParam.
1770 TrackInfos::iterator track_it = current_tracks->begin(); 1707 TrackInfos::iterator track_it = current_tracks->begin();
1771 while (track_it != current_tracks->end()) { 1708 while (track_it != current_tracks->end()) {
1772 const TrackInfo& info = *track_it; 1709 const TrackInfo& info = *track_it;
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
2012 // we can't free it directly here; we need to free it asynchronously. 1949 // we can't free it directly here; we need to free it asynchronously.
2013 sctp_data_channels_to_free_.push_back(*it); 1950 sctp_data_channels_to_free_.push_back(*it);
2014 sctp_data_channels_.erase(it); 1951 sctp_data_channels_.erase(it);
2015 signaling_thread()->Post(this, MSG_FREE_DATACHANNELS, nullptr); 1952 signaling_thread()->Post(this, MSG_FREE_DATACHANNELS, nullptr);
2016 return; 1953 return;
2017 } 1954 }
2018 } 1955 }
2019 } 1956 }
2020 1957
2021 void PeerConnection::OnVoiceChannelDestroyed() { 1958 void PeerConnection::OnVoiceChannelDestroyed() {
2022 EndRemoteTracks(cricket::MEDIA_TYPE_AUDIO); 1959 StopReceivers(cricket::MEDIA_TYPE_AUDIO);
2023 } 1960 }
2024 1961
2025 void PeerConnection::OnVideoChannelDestroyed() { 1962 void PeerConnection::OnVideoChannelDestroyed() {
2026 EndRemoteTracks(cricket::MEDIA_TYPE_VIDEO); 1963 StopReceivers(cricket::MEDIA_TYPE_VIDEO);
2027 } 1964 }
2028 1965
2029 void PeerConnection::OnDataChannelCreated() { 1966 void PeerConnection::OnDataChannelCreated() {
2030 for (const auto& channel : sctp_data_channels_) { 1967 for (const auto& channel : sctp_data_channels_) {
2031 channel->OnTransportChannelCreated(); 1968 channel->OnTransportChannelCreated();
2032 } 1969 }
2033 } 1970 }
2034 1971
2035 void PeerConnection::OnDataChannelDestroyed() { 1972 void PeerConnection::OnDataChannelDestroyed() {
2036 // Use a temporary copy of the RTP/SCTP DataChannel list because the 1973 // Use a temporary copy of the RTP/SCTP DataChannel list because the
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
2074 std::vector<rtc::scoped_refptr<RtpSenderInterface>>::iterator 2011 std::vector<rtc::scoped_refptr<RtpSenderInterface>>::iterator
2075 PeerConnection::FindSenderForTrack(MediaStreamTrackInterface* track) { 2012 PeerConnection::FindSenderForTrack(MediaStreamTrackInterface* track) {
2076 return std::find_if( 2013 return std::find_if(
2077 senders_.begin(), senders_.end(), 2014 senders_.begin(), senders_.end(),
2078 [track](const rtc::scoped_refptr<RtpSenderInterface>& sender) { 2015 [track](const rtc::scoped_refptr<RtpSenderInterface>& sender) {
2079 return sender->track() == track; 2016 return sender->track() == track;
2080 }); 2017 });
2081 } 2018 }
2082 2019
2083 std::vector<rtc::scoped_refptr<RtpReceiverInterface>>::iterator 2020 std::vector<rtc::scoped_refptr<RtpReceiverInterface>>::iterator
2084 PeerConnection::FindReceiverForTrack(MediaStreamTrackInterface* track) { 2021 PeerConnection::FindReceiverForTrack(const std::string& track_id) {
2085 return std::find_if( 2022 return std::find_if(
2086 receivers_.begin(), receivers_.end(), 2023 receivers_.begin(), receivers_.end(),
2087 [track](const rtc::scoped_refptr<RtpReceiverInterface>& receiver) { 2024 [track_id](const rtc::scoped_refptr<RtpReceiverInterface>& receiver) {
2088 return receiver->track() == track; 2025 return receiver->id() == track_id;
2089 }); 2026 });
2090 } 2027 }
2091 2028
2092 PeerConnection::TrackInfos* PeerConnection::GetRemoteTracks( 2029 PeerConnection::TrackInfos* PeerConnection::GetRemoteTracks(
2093 cricket::MediaType media_type) { 2030 cricket::MediaType media_type) {
2094 RTC_DCHECK(media_type == cricket::MEDIA_TYPE_AUDIO || 2031 RTC_DCHECK(media_type == cricket::MEDIA_TYPE_AUDIO ||
2095 media_type == cricket::MEDIA_TYPE_VIDEO); 2032 media_type == cricket::MEDIA_TYPE_VIDEO);
2096 return (media_type == cricket::MEDIA_TYPE_AUDIO) ? &remote_audio_tracks_ 2033 return (media_type == cricket::MEDIA_TYPE_AUDIO) ? &remote_audio_tracks_
2097 : &remote_video_tracks_; 2034 : &remote_video_tracks_;
2098 } 2035 }
(...skipping 22 matching lines...) Expand all
2121 DataChannel* PeerConnection::FindDataChannelBySid(int sid) const { 2058 DataChannel* PeerConnection::FindDataChannelBySid(int sid) const {
2122 for (const auto& channel : sctp_data_channels_) { 2059 for (const auto& channel : sctp_data_channels_) {
2123 if (channel->id() == sid) { 2060 if (channel->id() == sid) {
2124 return channel; 2061 return channel;
2125 } 2062 }
2126 } 2063 }
2127 return nullptr; 2064 return nullptr;
2128 } 2065 }
2129 2066
2130 } // namespace webrtc 2067 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/api/peerconnection.h ('k') | webrtc/api/peerconnectioninterface_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698