OLD | NEW |
---|---|
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 Loading... | |
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 Loading... | |
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 Loading... | |
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::DestroyReceivers(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 DestroyReceiver(track_info.track_id); |
1357 LOG(LS_WARNING) << "RtpReceiver for track with id " << video_track->id() | |
1358 << " doesn't exist."; | |
1359 } else { | |
1360 (*it)->Stop(); | |
1361 receivers_.erase(it); | |
1362 } | 1316 } |
1363 } | 1317 } |
1364 | 1318 |
1365 void PeerConnection::OnIceConnectionChange( | 1319 void PeerConnection::OnIceConnectionChange( |
1366 PeerConnectionInterface::IceConnectionState new_state) { | 1320 PeerConnectionInterface::IceConnectionState new_state) { |
1367 RTC_DCHECK(signaling_thread()->IsCurrent()); | 1321 RTC_DCHECK(signaling_thread()->IsCurrent()); |
1368 // After transitioning to "closed", ignore any additional states from | 1322 // After transitioning to "closed", ignore any additional states from |
1369 // WebRtcSession (such as "disconnected"). | 1323 // WebRtcSession (such as "disconnected"). |
1370 if (IsClosed()) { | 1324 if (IsClosed()) { |
1371 return; | 1325 return; |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1632 // The sync_label is the MediaStream label and the |stream.id| is the | 1586 // The sync_label is the MediaStream label and the |stream.id| is the |
1633 // track id. | 1587 // track id. |
1634 const std::string& stream_label = params.sync_label; | 1588 const std::string& stream_label = params.sync_label; |
1635 const std::string& track_id = params.id; | 1589 const std::string& track_id = params.id; |
1636 uint32_t ssrc = params.first_ssrc(); | 1590 uint32_t ssrc = params.first_ssrc(); |
1637 | 1591 |
1638 rtc::scoped_refptr<MediaStreamInterface> stream = | 1592 rtc::scoped_refptr<MediaStreamInterface> stream = |
1639 remote_streams_->find(stream_label); | 1593 remote_streams_->find(stream_label); |
1640 if (!stream) { | 1594 if (!stream) { |
1641 // This is a new MediaStream. Create a new remote MediaStream. | 1595 // This is a new MediaStream. Create a new remote MediaStream. |
1642 stream = remote_stream_factory_->CreateMediaStream(stream_label); | 1596 stream = MediaStreamProxy::Create(rtc::Thread::Current(), |
1597 MediaStream::Create(stream_label)); | |
1643 remote_streams_->AddStream(stream); | 1598 remote_streams_->AddStream(stream); |
1644 new_streams->AddStream(stream); | 1599 new_streams->AddStream(stream); |
1645 } | 1600 } |
1646 | 1601 |
1647 const TrackInfo* track_info = | 1602 const TrackInfo* track_info = |
1648 FindTrackInfo(*current_tracks, stream_label, track_id); | 1603 FindTrackInfo(*current_tracks, stream_label, track_id); |
1649 if (!track_info) { | 1604 if (!track_info) { |
1650 current_tracks->push_back(TrackInfo(stream_label, track_id, ssrc)); | 1605 current_tracks->push_back(TrackInfo(stream_label, track_id, ssrc)); |
1651 OnRemoteTrackSeen(stream_label, track_id, ssrc, media_type); | 1606 OnRemoteTrackSeen(stream_label, track_id, ssrc, media_type); |
1652 } | 1607 } |
1653 } | 1608 } |
1654 | 1609 |
1655 // Add default track if necessary. | 1610 // Add default track if necessary. |
1656 if (default_track_needed) { | 1611 if (default_track_needed) { |
1657 rtc::scoped_refptr<MediaStreamInterface> default_stream = | 1612 rtc::scoped_refptr<MediaStreamInterface> default_stream = |
1658 remote_streams_->find(kDefaultStreamLabel); | 1613 remote_streams_->find(kDefaultStreamLabel); |
1659 if (!default_stream) { | 1614 if (!default_stream) { |
1660 // Create the new default MediaStream. | 1615 // Create the new default MediaStream. |
1661 default_stream = | 1616 default_stream = MediaStreamProxy::Create( |
1662 remote_stream_factory_->CreateMediaStream(kDefaultStreamLabel); | 1617 rtc::Thread::Current(), MediaStream::Create(kDefaultStreamLabel)); |
1663 remote_streams_->AddStream(default_stream); | 1618 remote_streams_->AddStream(default_stream); |
1664 new_streams->AddStream(default_stream); | 1619 new_streams->AddStream(default_stream); |
1665 } | 1620 } |
1666 std::string default_track_id = (media_type == cricket::MEDIA_TYPE_AUDIO) | 1621 std::string default_track_id = (media_type == cricket::MEDIA_TYPE_AUDIO) |
1667 ? kDefaultAudioTrackLabel | 1622 ? kDefaultAudioTrackLabel |
1668 : kDefaultVideoTrackLabel; | 1623 : kDefaultVideoTrackLabel; |
1669 const TrackInfo* default_track_info = | 1624 const TrackInfo* default_track_info = |
1670 FindTrackInfo(*current_tracks, kDefaultStreamLabel, default_track_id); | 1625 FindTrackInfo(*current_tracks, kDefaultStreamLabel, default_track_id); |
1671 if (!default_track_info) { | 1626 if (!default_track_info) { |
1672 current_tracks->push_back( | 1627 current_tracks->push_back( |
1673 TrackInfo(kDefaultStreamLabel, default_track_id, 0)); | 1628 TrackInfo(kDefaultStreamLabel, default_track_id, 0)); |
1674 OnRemoteTrackSeen(kDefaultStreamLabel, default_track_id, 0, media_type); | 1629 OnRemoteTrackSeen(kDefaultStreamLabel, default_track_id, 0, media_type); |
1675 } | 1630 } |
1676 } | 1631 } |
1677 } | 1632 } |
1678 | 1633 |
1679 void PeerConnection::OnRemoteTrackSeen(const std::string& stream_label, | 1634 void PeerConnection::OnRemoteTrackSeen(const std::string& stream_label, |
1680 const std::string& track_id, | 1635 const std::string& track_id, |
1681 uint32_t ssrc, | 1636 uint32_t ssrc, |
1682 cricket::MediaType media_type) { | 1637 cricket::MediaType media_type) { |
1683 MediaStreamInterface* stream = remote_streams_->find(stream_label); | 1638 MediaStreamInterface* stream = remote_streams_->find(stream_label); |
1684 | 1639 |
1685 if (media_type == cricket::MEDIA_TYPE_AUDIO) { | 1640 if (media_type == cricket::MEDIA_TYPE_AUDIO) { |
1686 AudioTrackInterface* audio_track = remote_stream_factory_->AddAudioTrack( | 1641 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) { | 1642 } else if (media_type == cricket::MEDIA_TYPE_VIDEO) { |
1690 CreateVideoReceiver(stream, track_id, ssrc); | 1643 CreateVideoReceiver(stream, track_id, ssrc); |
1691 } else { | 1644 } else { |
1692 RTC_DCHECK(false && "Invalid media type"); | 1645 RTC_DCHECK(false && "Invalid media type"); |
1693 } | 1646 } |
1694 } | 1647 } |
1695 | 1648 |
1696 void PeerConnection::OnRemoteTrackRemoved(const std::string& stream_label, | 1649 void PeerConnection::OnRemoteTrackRemoved(const std::string& stream_label, |
1697 const std::string& track_id, | 1650 const std::string& track_id, |
1698 cricket::MediaType media_type) { | 1651 cricket::MediaType media_type) { |
1699 MediaStreamInterface* stream = remote_streams_->find(stream_label); | 1652 MediaStreamInterface* stream = remote_streams_->find(stream_label); |
1700 | 1653 |
1701 if (media_type == cricket::MEDIA_TYPE_AUDIO) { | 1654 if (media_type == cricket::MEDIA_TYPE_AUDIO) { |
1655 // When the MediaEngine audio channel is destroyed, the RemoteAudioSource | |
1656 // will be notified which will end the AudioRtpReceiver::track(). | |
1657 DestroyReceiver(track_id); | |
1702 rtc::scoped_refptr<AudioTrackInterface> audio_track = | 1658 rtc::scoped_refptr<AudioTrackInterface> audio_track = |
1703 stream->FindAudioTrack(track_id); | 1659 stream->FindAudioTrack(track_id); |
1704 if (audio_track) { | 1660 if (audio_track) { |
1705 audio_track->set_state(webrtc::MediaStreamTrackInterface::kEnded); | |
1706 stream->RemoveTrack(audio_track); | 1661 stream->RemoveTrack(audio_track); |
1707 DestroyAudioReceiver(stream, audio_track); | |
1708 } | 1662 } |
1709 } else if (media_type == cricket::MEDIA_TYPE_VIDEO) { | 1663 } else if (media_type == cricket::MEDIA_TYPE_VIDEO) { |
1664 // Stopping or destroying a VideoRtpReceiver will end the | |
1665 // VideoRtpReceiver::track(). | |
1666 DestroyReceiver(track_id); | |
1710 rtc::scoped_refptr<VideoTrackInterface> video_track = | 1667 rtc::scoped_refptr<VideoTrackInterface> video_track = |
1711 stream->FindVideoTrack(track_id); | 1668 stream->FindVideoTrack(track_id); |
1712 if (video_track) { | 1669 if (video_track) { |
1670 // There's no guarantee the track is still available, e.g. the track may | |
1671 // have been removed from the stream by an application. | |
1713 stream->RemoveTrack(video_track); | 1672 stream->RemoveTrack(video_track); |
1714 // Stopping or destroying a VideoRtpReceiver will end the | |
1715 // VideoRtpReceiver::track(). | |
1716 DestroyVideoReceiver(stream, video_track); | |
1717 } | 1673 } |
1718 } else { | 1674 } else { |
1719 ASSERT(false && "Invalid media type"); | 1675 ASSERT(false && "Invalid media type"); |
1720 } | 1676 } |
1721 } | 1677 } |
1722 | 1678 |
1723 void PeerConnection::UpdateEndedRemoteMediaStreams() { | 1679 void PeerConnection::UpdateEndedRemoteMediaStreams() { |
1724 std::vector<rtc::scoped_refptr<MediaStreamInterface>> streams_to_remove; | 1680 std::vector<rtc::scoped_refptr<MediaStreamInterface>> streams_to_remove; |
1725 for (size_t i = 0; i < remote_streams_->count(); ++i) { | 1681 for (size_t i = 0; i < remote_streams_->count(); ++i) { |
1726 MediaStreamInterface* stream = remote_streams_->at(i); | 1682 MediaStreamInterface* stream = remote_streams_->at(i); |
1727 if (stream->GetAudioTracks().empty() && stream->GetVideoTracks().empty()) { | 1683 if (stream->GetAudioTracks().empty() && stream->GetVideoTracks().empty()) { |
1728 streams_to_remove.push_back(stream); | 1684 streams_to_remove.push_back(stream); |
1729 } | 1685 } |
1730 } | 1686 } |
1731 | 1687 |
1732 for (const auto& stream : streams_to_remove) { | 1688 for (const auto& stream : streams_to_remove) { |
1733 remote_streams_->RemoveStream(stream); | 1689 remote_streams_->RemoveStream(stream); |
1734 observer_->OnRemoveStream(stream); | 1690 observer_->OnRemoveStream(stream); |
1735 } | 1691 } |
1736 } | 1692 } |
1737 | 1693 |
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( | 1694 void PeerConnection::UpdateLocalTracks( |
1764 const std::vector<cricket::StreamParams>& streams, | 1695 const std::vector<cricket::StreamParams>& streams, |
1765 cricket::MediaType media_type) { | 1696 cricket::MediaType media_type) { |
1766 TrackInfos* current_tracks = GetLocalTracks(media_type); | 1697 TrackInfos* current_tracks = GetLocalTracks(media_type); |
1767 | 1698 |
1768 // Find removed tracks. I.e., tracks where the track id, stream label or ssrc | 1699 // Find removed tracks. I.e., tracks where the track id, stream label or ssrc |
1769 // don't match the new StreamParam. | 1700 // don't match the new StreamParam. |
1770 TrackInfos::iterator track_it = current_tracks->begin(); | 1701 TrackInfos::iterator track_it = current_tracks->begin(); |
1771 while (track_it != current_tracks->end()) { | 1702 while (track_it != current_tracks->end()) { |
1772 const TrackInfo& info = *track_it; | 1703 const TrackInfo& info = *track_it; |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2012 // we can't free it directly here; we need to free it asynchronously. | 1943 // we can't free it directly here; we need to free it asynchronously. |
2013 sctp_data_channels_to_free_.push_back(*it); | 1944 sctp_data_channels_to_free_.push_back(*it); |
2014 sctp_data_channels_.erase(it); | 1945 sctp_data_channels_.erase(it); |
2015 signaling_thread()->Post(this, MSG_FREE_DATACHANNELS, nullptr); | 1946 signaling_thread()->Post(this, MSG_FREE_DATACHANNELS, nullptr); |
2016 return; | 1947 return; |
2017 } | 1948 } |
2018 } | 1949 } |
2019 } | 1950 } |
2020 | 1951 |
2021 void PeerConnection::OnVoiceChannelDestroyed() { | 1952 void PeerConnection::OnVoiceChannelDestroyed() { |
2022 EndRemoteTracks(cricket::MEDIA_TYPE_AUDIO); | 1953 DestroyReceivers(cricket::MEDIA_TYPE_AUDIO); |
Taylor Brandstetter
2016/03/21 18:49:54
I don't think this should go so far as to destroy
perkj_webrtc
2016/03/22 16:59:54
Done.
| |
2023 } | 1954 } |
2024 | 1955 |
2025 void PeerConnection::OnVideoChannelDestroyed() { | 1956 void PeerConnection::OnVideoChannelDestroyed() { |
2026 EndRemoteTracks(cricket::MEDIA_TYPE_VIDEO); | 1957 DestroyReceivers(cricket::MEDIA_TYPE_VIDEO); |
2027 } | 1958 } |
2028 | 1959 |
2029 void PeerConnection::OnDataChannelCreated() { | 1960 void PeerConnection::OnDataChannelCreated() { |
2030 for (const auto& channel : sctp_data_channels_) { | 1961 for (const auto& channel : sctp_data_channels_) { |
2031 channel->OnTransportChannelCreated(); | 1962 channel->OnTransportChannelCreated(); |
2032 } | 1963 } |
2033 } | 1964 } |
2034 | 1965 |
2035 void PeerConnection::OnDataChannelDestroyed() { | 1966 void PeerConnection::OnDataChannelDestroyed() { |
2036 // Use a temporary copy of the RTP/SCTP DataChannel list because the | 1967 // Use a temporary copy of the RTP/SCTP DataChannel list because the |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2074 std::vector<rtc::scoped_refptr<RtpSenderInterface>>::iterator | 2005 std::vector<rtc::scoped_refptr<RtpSenderInterface>>::iterator |
2075 PeerConnection::FindSenderForTrack(MediaStreamTrackInterface* track) { | 2006 PeerConnection::FindSenderForTrack(MediaStreamTrackInterface* track) { |
2076 return std::find_if( | 2007 return std::find_if( |
2077 senders_.begin(), senders_.end(), | 2008 senders_.begin(), senders_.end(), |
2078 [track](const rtc::scoped_refptr<RtpSenderInterface>& sender) { | 2009 [track](const rtc::scoped_refptr<RtpSenderInterface>& sender) { |
2079 return sender->track() == track; | 2010 return sender->track() == track; |
2080 }); | 2011 }); |
2081 } | 2012 } |
2082 | 2013 |
2083 std::vector<rtc::scoped_refptr<RtpReceiverInterface>>::iterator | 2014 std::vector<rtc::scoped_refptr<RtpReceiverInterface>>::iterator |
2084 PeerConnection::FindReceiverForTrack(MediaStreamTrackInterface* track) { | 2015 PeerConnection::FindReceiverForTrack(const std::string& track_id) { |
2085 return std::find_if( | 2016 return std::find_if( |
2086 receivers_.begin(), receivers_.end(), | 2017 receivers_.begin(), receivers_.end(), |
2087 [track](const rtc::scoped_refptr<RtpReceiverInterface>& receiver) { | 2018 [track_id](const rtc::scoped_refptr<RtpReceiverInterface>& receiver) { |
2088 return receiver->track() == track; | 2019 return receiver->id() == track_id; |
2089 }); | 2020 }); |
2090 } | 2021 } |
2091 | 2022 |
2092 PeerConnection::TrackInfos* PeerConnection::GetRemoteTracks( | 2023 PeerConnection::TrackInfos* PeerConnection::GetRemoteTracks( |
2093 cricket::MediaType media_type) { | 2024 cricket::MediaType media_type) { |
2094 RTC_DCHECK(media_type == cricket::MEDIA_TYPE_AUDIO || | 2025 RTC_DCHECK(media_type == cricket::MEDIA_TYPE_AUDIO || |
2095 media_type == cricket::MEDIA_TYPE_VIDEO); | 2026 media_type == cricket::MEDIA_TYPE_VIDEO); |
2096 return (media_type == cricket::MEDIA_TYPE_AUDIO) ? &remote_audio_tracks_ | 2027 return (media_type == cricket::MEDIA_TYPE_AUDIO) ? &remote_audio_tracks_ |
2097 : &remote_video_tracks_; | 2028 : &remote_video_tracks_; |
2098 } | 2029 } |
(...skipping 22 matching lines...) Expand all Loading... | |
2121 DataChannel* PeerConnection::FindDataChannelBySid(int sid) const { | 2052 DataChannel* PeerConnection::FindDataChannelBySid(int sid) const { |
2122 for (const auto& channel : sctp_data_channels_) { | 2053 for (const auto& channel : sctp_data_channels_) { |
2123 if (channel->id() == sid) { | 2054 if (channel->id() == sid) { |
2124 return channel; | 2055 return channel; |
2125 } | 2056 } |
2126 } | 2057 } |
2127 return nullptr; | 2058 return nullptr; |
2128 } | 2059 } |
2129 | 2060 |
2130 } // namespace webrtc | 2061 } // namespace webrtc |
OLD | NEW |