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 28 matching lines...) Expand all Loading... |
39 #include "webrtc/p2p/client/basicportallocator.h" | 39 #include "webrtc/p2p/client/basicportallocator.h" |
40 #include "webrtc/pc/channelmanager.h" | 40 #include "webrtc/pc/channelmanager.h" |
41 #include "webrtc/system_wrappers/include/field_trial.h" | 41 #include "webrtc/system_wrappers/include/field_trial.h" |
42 | 42 |
43 namespace { | 43 namespace { |
44 | 44 |
45 using webrtc::DataChannel; | 45 using webrtc::DataChannel; |
46 using webrtc::MediaConstraintsInterface; | 46 using webrtc::MediaConstraintsInterface; |
47 using webrtc::MediaStreamInterface; | 47 using webrtc::MediaStreamInterface; |
48 using webrtc::PeerConnectionInterface; | 48 using webrtc::PeerConnectionInterface; |
| 49 using webrtc::RtpSender; |
49 using webrtc::RtpSenderInterface; | 50 using webrtc::RtpSenderInterface; |
| 51 using webrtc::RtpSenderProxy; |
| 52 using webrtc::RtpSenderProxyEx; |
50 using webrtc::StreamCollection; | 53 using webrtc::StreamCollection; |
51 | 54 |
52 static const char kDefaultStreamLabel[] = "default"; | 55 static const char kDefaultStreamLabel[] = "default"; |
53 static const char kDefaultAudioTrackLabel[] = "defaulta0"; | 56 static const char kDefaultAudioTrackLabel[] = "defaulta0"; |
54 static const char kDefaultVideoTrackLabel[] = "defaultv0"; | 57 static const char kDefaultVideoTrackLabel[] = "defaultv0"; |
55 | 58 |
56 // The min number of tokens must present in Turn host uri. | 59 // The min number of tokens must present in Turn host uri. |
57 // e.g. user@turn.example.org | 60 // e.g. user@turn.example.org |
58 static const size_t kTurnHostTokensNum = 2; | 61 static const size_t kTurnHostTokensNum = 2; |
59 // Number of tokens must be preset when TURN uri has transport param. | 62 // Number of tokens must be preset when TURN uri has transport param. |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 | 343 |
341 bool IsValidOfferToReceiveMedia(int value) { | 344 bool IsValidOfferToReceiveMedia(int value) { |
342 typedef PeerConnectionInterface::RTCOfferAnswerOptions Options; | 345 typedef PeerConnectionInterface::RTCOfferAnswerOptions Options; |
343 return (value >= Options::kUndefined) && | 346 return (value >= Options::kUndefined) && |
344 (value <= Options::kMaxOfferToReceiveMedia); | 347 (value <= Options::kMaxOfferToReceiveMedia); |
345 } | 348 } |
346 | 349 |
347 // Add the stream and RTP data channel info to |session_options|. | 350 // Add the stream and RTP data channel info to |session_options|. |
348 void AddSendStreams( | 351 void AddSendStreams( |
349 cricket::MediaSessionOptions* session_options, | 352 cricket::MediaSessionOptions* session_options, |
350 const std::vector<rtc::scoped_refptr<RtpSenderInterface>>& senders, | 353 const std::vector<rtc::scoped_refptr<RtpSenderProxyEx<RtpSender>>>& senders, |
351 const std::map<std::string, rtc::scoped_refptr<DataChannel>>& | 354 const std::map<std::string, rtc::scoped_refptr<DataChannel>>& |
352 rtp_data_channels) { | 355 rtp_data_channels) { |
353 session_options->streams.clear(); | 356 session_options->streams.clear(); |
354 for (const auto& sender : senders) { | 357 for (const auto& sender : senders) { |
355 session_options->AddSendStream(sender->media_type(), sender->id(), | 358 session_options->AddSendStream(sender->media_type(), sender->id(), |
356 sender->stream_id()); | 359 sender->get()->stream_id()); |
357 } | 360 } |
358 | 361 |
359 // Check for data channels. | 362 // Check for data channels. |
360 for (const auto& kv : rtp_data_channels) { | 363 for (const auto& kv : rtp_data_channels) { |
361 const DataChannel* channel = kv.second; | 364 const DataChannel* channel = kv.second; |
362 if (channel->state() == DataChannel::kConnecting || | 365 if (channel->state() == DataChannel::kConnecting || |
363 channel->state() == DataChannel::kOpen) { | 366 channel->state() == DataChannel::kOpen) { |
364 // |streamid| and |sync_label| are both set to the DataChannel label | 367 // |streamid| and |sync_label| are both set to the DataChannel label |
365 // here so they can be signaled the same way as MediaStreams and Tracks. | 368 // here so they can be signaled the same way as MediaStreams and Tracks. |
366 // For MediaStreams, the sync_label is the MediaStream label and the | 369 // For MediaStreams, the sync_label is the MediaStream label and the |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 ice_gathering_state_(kIceGatheringNew), | 513 ice_gathering_state_(kIceGatheringNew), |
511 local_streams_(StreamCollection::Create()), | 514 local_streams_(StreamCollection::Create()), |
512 remote_streams_(StreamCollection::Create()) {} | 515 remote_streams_(StreamCollection::Create()) {} |
513 | 516 |
514 PeerConnection::~PeerConnection() { | 517 PeerConnection::~PeerConnection() { |
515 TRACE_EVENT0("webrtc", "PeerConnection::~PeerConnection"); | 518 TRACE_EVENT0("webrtc", "PeerConnection::~PeerConnection"); |
516 RTC_DCHECK(signaling_thread()->IsCurrent()); | 519 RTC_DCHECK(signaling_thread()->IsCurrent()); |
517 // Need to detach RTP senders/receivers from WebRtcSession, | 520 // Need to detach RTP senders/receivers from WebRtcSession, |
518 // since it's about to be destroyed. | 521 // since it's about to be destroyed. |
519 for (const auto& sender : senders_) { | 522 for (const auto& sender : senders_) { |
520 sender->Stop(); | 523 sender->get()->Stop(); |
521 } | 524 } |
522 for (const auto& receiver : receivers_) { | 525 for (const auto& receiver : receivers_) { |
523 receiver->Stop(); | 526 receiver->Stop(); |
524 } | 527 } |
525 } | 528 } |
526 | 529 |
527 bool PeerConnection::Initialize( | 530 bool PeerConnection::Initialize( |
528 const PeerConnectionInterface::RTCConfiguration& configuration, | 531 const PeerConnectionInterface::RTCConfiguration& configuration, |
529 std::unique_ptr<cricket::PortAllocator> allocator, | 532 std::unique_ptr<cricket::PortAllocator> allocator, |
530 std::unique_ptr<DtlsIdentityStoreInterface> dtls_identity_store, | 533 std::unique_ptr<DtlsIdentityStoreInterface> dtls_identity_store, |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
679 << "Adding a track with two streams is not currently supported."; | 682 << "Adding a track with two streams is not currently supported."; |
680 return nullptr; | 683 return nullptr; |
681 } | 684 } |
682 // TODO(deadbeef): Support adding a track to two different senders. | 685 // TODO(deadbeef): Support adding a track to two different senders. |
683 if (FindSenderForTrack(track) != senders_.end()) { | 686 if (FindSenderForTrack(track) != senders_.end()) { |
684 LOG(LS_ERROR) << "Sender for track " << track->id() << " already exists."; | 687 LOG(LS_ERROR) << "Sender for track " << track->id() << " already exists."; |
685 return nullptr; | 688 return nullptr; |
686 } | 689 } |
687 | 690 |
688 // TODO(deadbeef): Support adding a track to multiple streams. | 691 // TODO(deadbeef): Support adding a track to multiple streams. |
689 rtc::scoped_refptr<RtpSenderInterface> new_sender; | 692 rtc::scoped_refptr<RtpSenderProxyEx<RtpSender>> new_sender; |
690 if (track->kind() == MediaStreamTrackInterface::kAudioKind) { | 693 if (track->kind() == MediaStreamTrackInterface::kAudioKind) { |
691 new_sender = RtpSenderProxy::Create( | 694 new_sender = RtpSenderProxyEx<RtpSender>::Create( |
692 signaling_thread(), | 695 signaling_thread(), |
693 new AudioRtpSender(static_cast<AudioTrackInterface*>(track), | 696 new AudioRtpSender(static_cast<AudioTrackInterface*>(track), |
694 session_.get(), stats_.get())); | 697 session_.get(), stats_.get())); |
695 if (!streams.empty()) { | 698 if (!streams.empty()) { |
696 new_sender->set_stream_id(streams[0]->label()); | 699 new_sender->get()->set_stream_id(streams[0]->label()); |
697 } | 700 } |
698 const TrackInfo* track_info = FindTrackInfo( | 701 const TrackInfo* track_info = FindTrackInfo( |
699 local_audio_tracks_, new_sender->stream_id(), track->id()); | 702 local_audio_tracks_, new_sender->get()->stream_id(), track->id()); |
700 if (track_info) { | 703 if (track_info) { |
701 new_sender->SetSsrc(track_info->ssrc); | 704 new_sender->get()->SetSsrc(track_info->ssrc); |
702 } | 705 } |
703 } else if (track->kind() == MediaStreamTrackInterface::kVideoKind) { | 706 } else if (track->kind() == MediaStreamTrackInterface::kVideoKind) { |
704 new_sender = RtpSenderProxy::Create( | 707 new_sender = RtpSenderProxyEx<RtpSender>::Create( |
705 signaling_thread(), | 708 signaling_thread(), |
706 new VideoRtpSender(static_cast<VideoTrackInterface*>(track), | 709 new VideoRtpSender(static_cast<VideoTrackInterface*>(track), |
707 session_.get())); | 710 session_.get())); |
708 if (!streams.empty()) { | 711 if (!streams.empty()) { |
709 new_sender->set_stream_id(streams[0]->label()); | 712 new_sender->get()->set_stream_id(streams[0]->label()); |
710 } | 713 } |
711 const TrackInfo* track_info = FindTrackInfo( | 714 const TrackInfo* track_info = FindTrackInfo( |
712 local_video_tracks_, new_sender->stream_id(), track->id()); | 715 local_video_tracks_, new_sender->get()->stream_id(), track->id()); |
713 if (track_info) { | 716 if (track_info) { |
714 new_sender->SetSsrc(track_info->ssrc); | 717 new_sender->get()->SetSsrc(track_info->ssrc); |
715 } | 718 } |
716 } else { | 719 } else { |
717 LOG(LS_ERROR) << "CreateSender called with invalid kind: " << track->kind(); | 720 LOG(LS_ERROR) << "CreateSender called with invalid kind: " << track->kind(); |
718 return rtc::scoped_refptr<RtpSenderInterface>(); | 721 return rtc::scoped_refptr<RtpSenderInterface>(); |
719 } | 722 } |
720 | 723 |
721 senders_.push_back(new_sender); | 724 senders_.push_back(new_sender); |
722 observer_->OnRenegotiationNeeded(); | 725 observer_->OnRenegotiationNeeded(); |
723 return new_sender; | 726 return new_sender; |
724 } | 727 } |
725 | 728 |
726 bool PeerConnection::RemoveTrack(RtpSenderInterface* sender) { | 729 bool PeerConnection::RemoveTrack(RtpSenderInterface* sender) { |
727 TRACE_EVENT0("webrtc", "PeerConnection::RemoveTrack"); | 730 TRACE_EVENT0("webrtc", "PeerConnection::RemoveTrack"); |
728 if (IsClosed()) { | 731 if (IsClosed()) { |
729 return false; | 732 return false; |
730 } | 733 } |
731 | 734 |
732 auto it = std::find(senders_.begin(), senders_.end(), sender); | 735 auto it = std::find(senders_.begin(), senders_.end(), sender); |
733 if (it == senders_.end()) { | 736 if (it == senders_.end()) { |
734 LOG(LS_ERROR) << "Couldn't find sender " << sender->id() << " to remove."; | 737 LOG(LS_ERROR) << "Couldn't find sender " << sender->id() << " to remove."; |
735 return false; | 738 return false; |
736 } | 739 } |
737 (*it)->Stop(); | 740 (*it)->get()->Stop(); |
738 senders_.erase(it); | 741 senders_.erase(it); |
739 | 742 |
740 observer_->OnRenegotiationNeeded(); | 743 observer_->OnRenegotiationNeeded(); |
741 return true; | 744 return true; |
742 } | 745 } |
743 | 746 |
744 rtc::scoped_refptr<DtmfSenderInterface> PeerConnection::CreateDtmfSender( | 747 rtc::scoped_refptr<DtmfSenderInterface> PeerConnection::CreateDtmfSender( |
745 AudioTrackInterface* track) { | 748 AudioTrackInterface* track) { |
746 TRACE_EVENT0("webrtc", "PeerConnection::CreateDtmfSender"); | 749 TRACE_EVENT0("webrtc", "PeerConnection::CreateDtmfSender"); |
747 if (!track) { | 750 if (!track) { |
(...skipping 11 matching lines...) Expand all Loading... |
759 LOG(LS_ERROR) << "CreateDtmfSender failed on DtmfSender::Create."; | 762 LOG(LS_ERROR) << "CreateDtmfSender failed on DtmfSender::Create."; |
760 return NULL; | 763 return NULL; |
761 } | 764 } |
762 return DtmfSenderProxy::Create(signaling_thread(), sender.get()); | 765 return DtmfSenderProxy::Create(signaling_thread(), sender.get()); |
763 } | 766 } |
764 | 767 |
765 rtc::scoped_refptr<RtpSenderInterface> PeerConnection::CreateSender( | 768 rtc::scoped_refptr<RtpSenderInterface> PeerConnection::CreateSender( |
766 const std::string& kind, | 769 const std::string& kind, |
767 const std::string& stream_id) { | 770 const std::string& stream_id) { |
768 TRACE_EVENT0("webrtc", "PeerConnection::CreateSender"); | 771 TRACE_EVENT0("webrtc", "PeerConnection::CreateSender"); |
769 rtc::scoped_refptr<RtpSenderInterface> new_sender; | 772 rtc::scoped_refptr<RtpSenderProxyEx<RtpSender>> new_sender; |
770 if (kind == MediaStreamTrackInterface::kAudioKind) { | 773 if (kind == MediaStreamTrackInterface::kAudioKind) { |
771 new_sender = RtpSenderProxy::Create( | 774 new_sender = RtpSenderProxyEx<RtpSender>::Create( |
772 signaling_thread(), new AudioRtpSender(session_.get(), stats_.get())); | 775 signaling_thread(), new AudioRtpSender(session_.get(), stats_.get())); |
773 } else if (kind == MediaStreamTrackInterface::kVideoKind) { | 776 } else if (kind == MediaStreamTrackInterface::kVideoKind) { |
774 new_sender = RtpSenderProxy::Create(signaling_thread(), | 777 new_sender = RtpSenderProxyEx<RtpSender>::Create(signaling_thread(), |
775 new VideoRtpSender(session_.get())); | 778 new VideoRtpSender(session_.get())); |
776 } else { | 779 } else { |
777 LOG(LS_ERROR) << "CreateSender called with invalid kind: " << kind; | 780 LOG(LS_ERROR) << "CreateSender called with invalid kind: " << kind; |
778 return new_sender; | 781 return new_sender; |
779 } | 782 } |
780 if (!stream_id.empty()) { | 783 if (!stream_id.empty()) { |
781 new_sender->set_stream_id(stream_id); | 784 new_sender->get()->set_stream_id(stream_id); |
782 } | 785 } |
783 senders_.push_back(new_sender); | 786 senders_.push_back(new_sender); |
784 return new_sender; | 787 return new_sender; |
785 } | 788 } |
786 | 789 |
787 std::vector<rtc::scoped_refptr<RtpSenderInterface>> PeerConnection::GetSenders() | 790 std::vector<rtc::scoped_refptr<RtpSenderInterface>> PeerConnection::GetSenders() |
788 const { | 791 const { |
789 return senders_; | 792 std::vector<rtc::scoped_refptr<RtpSenderInterface>> ret; |
| 793 for (const auto& sender : senders_) { |
| 794 ret.push_back(sender.get()); |
| 795 } |
| 796 return ret; |
790 } | 797 } |
791 | 798 |
792 std::vector<rtc::scoped_refptr<RtpReceiverInterface>> | 799 std::vector<rtc::scoped_refptr<RtpReceiverInterface>> |
793 PeerConnection::GetReceivers() const { | 800 PeerConnection::GetReceivers() const { |
794 return receivers_; | 801 return receivers_; |
795 } | 802 } |
796 | 803 |
797 bool PeerConnection::GetStats(StatsObserver* observer, | 804 bool PeerConnection::GetStats(StatsObserver* observer, |
798 MediaStreamTrackInterface* track, | 805 MediaStreamTrackInterface* track, |
799 StatsOutputLevel level) { | 806 StatsOutputLevel level) { |
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1373 } | 1380 } |
1374 observer_->OnSignalingChange(signaling_state_); | 1381 observer_->OnSignalingChange(signaling_state_); |
1375 } | 1382 } |
1376 | 1383 |
1377 void PeerConnection::OnAudioTrackAdded(AudioTrackInterface* track, | 1384 void PeerConnection::OnAudioTrackAdded(AudioTrackInterface* track, |
1378 MediaStreamInterface* stream) { | 1385 MediaStreamInterface* stream) { |
1379 auto sender = FindSenderForTrack(track); | 1386 auto sender = FindSenderForTrack(track); |
1380 if (sender != senders_.end()) { | 1387 if (sender != senders_.end()) { |
1381 // We already have a sender for this track, so just change the stream_id | 1388 // We already have a sender for this track, so just change the stream_id |
1382 // so that it's correct in the next call to CreateOffer. | 1389 // so that it's correct in the next call to CreateOffer. |
1383 (*sender)->set_stream_id(stream->label()); | 1390 (*sender)->get()->set_stream_id(stream->label()); |
1384 return; | 1391 return; |
1385 } | 1392 } |
1386 | 1393 |
1387 // Normal case; we've never seen this track before. | 1394 // Normal case; we've never seen this track before. |
1388 rtc::scoped_refptr<RtpSenderInterface> new_sender = RtpSenderProxy::Create( | 1395 rtc::scoped_refptr<RtpSenderProxyEx<RtpSender>> new_sender = RtpSenderProxyEx<
RtpSender>::Create( |
1389 signaling_thread(), | 1396 signaling_thread(), |
1390 new AudioRtpSender(track, stream->label(), session_.get(), stats_.get())); | 1397 new AudioRtpSender(track, stream->label(), session_.get(), stats_.get())); |
1391 senders_.push_back(new_sender); | 1398 senders_.push_back(new_sender); |
1392 // If the sender has already been configured in SDP, we call SetSsrc, | 1399 // If the sender has already been configured in SDP, we call SetSsrc, |
1393 // which will connect the sender to the underlying transport. This can | 1400 // which will connect the sender to the underlying transport. This can |
1394 // occur if a local session description that contains the ID of the sender | 1401 // occur if a local session description that contains the ID of the sender |
1395 // is set before AddStream is called. It can also occur if the local | 1402 // is set before AddStream is called. It can also occur if the local |
1396 // session description is not changed and RemoveStream is called, and | 1403 // session description is not changed and RemoveStream is called, and |
1397 // later AddStream is called again with the same stream. | 1404 // later AddStream is called again with the same stream. |
1398 const TrackInfo* track_info = | 1405 const TrackInfo* track_info = |
1399 FindTrackInfo(local_audio_tracks_, stream->label(), track->id()); | 1406 FindTrackInfo(local_audio_tracks_, stream->label(), track->id()); |
1400 if (track_info) { | 1407 if (track_info) { |
1401 new_sender->SetSsrc(track_info->ssrc); | 1408 new_sender->get()->SetSsrc(track_info->ssrc); |
1402 } | 1409 } |
1403 } | 1410 } |
1404 | 1411 |
1405 // TODO(deadbeef): Don't destroy RtpSenders here; they should be kept around | 1412 // TODO(deadbeef): Don't destroy RtpSenders here; they should be kept around |
1406 // indefinitely, when we have unified plan SDP. | 1413 // indefinitely, when we have unified plan SDP. |
1407 void PeerConnection::OnAudioTrackRemoved(AudioTrackInterface* track, | 1414 void PeerConnection::OnAudioTrackRemoved(AudioTrackInterface* track, |
1408 MediaStreamInterface* stream) { | 1415 MediaStreamInterface* stream) { |
1409 auto sender = FindSenderForTrack(track); | 1416 auto sender = FindSenderForTrack(track); |
1410 if (sender == senders_.end()) { | 1417 if (sender == senders_.end()) { |
1411 LOG(LS_WARNING) << "RtpSender for track with id " << track->id() | 1418 LOG(LS_WARNING) << "RtpSender for track with id " << track->id() |
1412 << " doesn't exist."; | 1419 << " doesn't exist."; |
1413 return; | 1420 return; |
1414 } | 1421 } |
1415 (*sender)->Stop(); | 1422 (*sender)->get()->Stop(); |
1416 senders_.erase(sender); | 1423 senders_.erase(sender); |
1417 } | 1424 } |
1418 | 1425 |
1419 void PeerConnection::OnVideoTrackAdded(VideoTrackInterface* track, | 1426 void PeerConnection::OnVideoTrackAdded(VideoTrackInterface* track, |
1420 MediaStreamInterface* stream) { | 1427 MediaStreamInterface* stream) { |
1421 auto sender = FindSenderForTrack(track); | 1428 auto sender = FindSenderForTrack(track); |
1422 if (sender != senders_.end()) { | 1429 if (sender != senders_.end()) { |
1423 // We already have a sender for this track, so just change the stream_id | 1430 // We already have a sender for this track, so just change the stream_id |
1424 // so that it's correct in the next call to CreateOffer. | 1431 // so that it's correct in the next call to CreateOffer. |
1425 (*sender)->set_stream_id(stream->label()); | 1432 (*sender)->get()->set_stream_id(stream->label()); |
1426 return; | 1433 return; |
1427 } | 1434 } |
1428 | 1435 |
1429 // Normal case; we've never seen this track before. | 1436 // Normal case; we've never seen this track before. |
1430 rtc::scoped_refptr<RtpSenderInterface> new_sender = RtpSenderProxy::Create( | 1437 rtc::scoped_refptr<RtpSenderProxyEx<RtpSender>> new_sender = RtpSenderProxyEx<
RtpSender>::Create( |
1431 signaling_thread(), | 1438 signaling_thread(), |
1432 new VideoRtpSender(track, stream->label(), session_.get())); | 1439 new VideoRtpSender(track, stream->label(), session_.get())); |
1433 senders_.push_back(new_sender); | 1440 senders_.push_back(new_sender); |
1434 const TrackInfo* track_info = | 1441 const TrackInfo* track_info = |
1435 FindTrackInfo(local_video_tracks_, stream->label(), track->id()); | 1442 FindTrackInfo(local_video_tracks_, stream->label(), track->id()); |
1436 if (track_info) { | 1443 if (track_info) { |
1437 new_sender->SetSsrc(track_info->ssrc); | 1444 new_sender->get()->SetSsrc(track_info->ssrc); |
1438 } | 1445 } |
1439 } | 1446 } |
1440 | 1447 |
1441 void PeerConnection::OnVideoTrackRemoved(VideoTrackInterface* track, | 1448 void PeerConnection::OnVideoTrackRemoved(VideoTrackInterface* track, |
1442 MediaStreamInterface* stream) { | 1449 MediaStreamInterface* stream) { |
1443 auto sender = FindSenderForTrack(track); | 1450 auto sender = FindSenderForTrack(track); |
1444 if (sender == senders_.end()) { | 1451 if (sender == senders_.end()) { |
1445 LOG(LS_WARNING) << "RtpSender for track with id " << track->id() | 1452 LOG(LS_WARNING) << "RtpSender for track with id " << track->id() |
1446 << " doesn't exist."; | 1453 << " doesn't exist."; |
1447 return; | 1454 return; |
1448 } | 1455 } |
1449 (*sender)->Stop(); | 1456 (*sender)->get()->Stop(); |
1450 senders_.erase(sender); | 1457 senders_.erase(sender); |
1451 } | 1458 } |
1452 | 1459 |
1453 void PeerConnection::PostSetSessionDescriptionFailure( | 1460 void PeerConnection::PostSetSessionDescriptionFailure( |
1454 SetSessionDescriptionObserver* observer, | 1461 SetSessionDescriptionObserver* observer, |
1455 const std::string& error) { | 1462 const std::string& error) { |
1456 SetSessionDescriptionMsg* msg = new SetSessionDescriptionMsg(observer); | 1463 SetSessionDescriptionMsg* msg = new SetSessionDescriptionMsg(observer); |
1457 msg->error = error; | 1464 msg->error = error; |
1458 signaling_thread()->Post(this, MSG_SET_SESSIONDESCRIPTION_FAILED, msg); | 1465 signaling_thread()->Post(this, MSG_SET_SESSIONDESCRIPTION_FAILED, msg); |
1459 } | 1466 } |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1732 current_tracks->push_back(TrackInfo(stream_label, track_id, ssrc)); | 1739 current_tracks->push_back(TrackInfo(stream_label, track_id, ssrc)); |
1733 OnLocalTrackSeen(stream_label, track_id, params.first_ssrc(), media_type); | 1740 OnLocalTrackSeen(stream_label, track_id, params.first_ssrc(), media_type); |
1734 } | 1741 } |
1735 } | 1742 } |
1736 } | 1743 } |
1737 | 1744 |
1738 void PeerConnection::OnLocalTrackSeen(const std::string& stream_label, | 1745 void PeerConnection::OnLocalTrackSeen(const std::string& stream_label, |
1739 const std::string& track_id, | 1746 const std::string& track_id, |
1740 uint32_t ssrc, | 1747 uint32_t ssrc, |
1741 cricket::MediaType media_type) { | 1748 cricket::MediaType media_type) { |
1742 RtpSenderInterface* sender = FindSenderById(track_id); | 1749 RtpSender* sender = FindSenderById(track_id); |
1743 if (!sender) { | 1750 if (!sender) { |
1744 LOG(LS_WARNING) << "An unknown RtpSender with id " << track_id | 1751 LOG(LS_WARNING) << "An unknown RtpSender with id " << track_id |
1745 << " has been configured in the local description."; | 1752 << " has been configured in the local description."; |
1746 return; | 1753 return; |
1747 } | 1754 } |
1748 | 1755 |
1749 if (sender->media_type() != media_type) { | 1756 if (sender->media_type() != media_type) { |
1750 LOG(LS_WARNING) << "An RtpSender has been configured in the local" | 1757 LOG(LS_WARNING) << "An RtpSender has been configured in the local" |
1751 << " description with an unexpected media type."; | 1758 << " description with an unexpected media type."; |
1752 return; | 1759 return; |
1753 } | 1760 } |
1754 | 1761 |
1755 sender->set_stream_id(stream_label); | 1762 sender->set_stream_id(stream_label); |
1756 sender->SetSsrc(ssrc); | 1763 sender->SetSsrc(ssrc); |
1757 } | 1764 } |
1758 | 1765 |
1759 void PeerConnection::OnLocalTrackRemoved(const std::string& stream_label, | 1766 void PeerConnection::OnLocalTrackRemoved(const std::string& stream_label, |
1760 const std::string& track_id, | 1767 const std::string& track_id, |
1761 uint32_t ssrc, | 1768 uint32_t ssrc, |
1762 cricket::MediaType media_type) { | 1769 cricket::MediaType media_type) { |
1763 RtpSenderInterface* sender = FindSenderById(track_id); | 1770 RtpSender* sender = FindSenderById(track_id); |
1764 if (!sender) { | 1771 if (!sender) { |
1765 // This is the normal case. I.e., RemoveStream has been called and the | 1772 // This is the normal case. I.e., RemoveStream has been called and the |
1766 // SessionDescriptions has been renegotiated. | 1773 // SessionDescriptions has been renegotiated. |
1767 return; | 1774 return; |
1768 } | 1775 } |
1769 | 1776 |
1770 // A sender has been removed from the SessionDescription but it's still | 1777 // A sender has been removed from the SessionDescription but it's still |
1771 // associated with the PeerConnection. This only occurs if the SDP doesn't | 1778 // associated with the PeerConnection. This only occurs if the SDP doesn't |
1772 // match with the calls to CreateSender, AddStream and RemoveStream. | 1779 // match with the calls to CreateSender, AddStream and RemoveStream. |
1773 if (sender->media_type() != media_type) { | 1780 if (sender->media_type() != media_type) { |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1992 InternalCreateDataChannel(label, &config)); | 1999 InternalCreateDataChannel(label, &config)); |
1993 if (!channel.get()) { | 2000 if (!channel.get()) { |
1994 LOG(LS_ERROR) << "Failed to create DataChannel from the OPEN message."; | 2001 LOG(LS_ERROR) << "Failed to create DataChannel from the OPEN message."; |
1995 return; | 2002 return; |
1996 } | 2003 } |
1997 | 2004 |
1998 observer_->OnDataChannel( | 2005 observer_->OnDataChannel( |
1999 DataChannelProxy::Create(signaling_thread(), channel)); | 2006 DataChannelProxy::Create(signaling_thread(), channel)); |
2000 } | 2007 } |
2001 | 2008 |
2002 RtpSenderInterface* PeerConnection::FindSenderById(const std::string& id) { | 2009 RtpSender* PeerConnection::FindSenderById(const std::string& id) { |
2003 auto it = | 2010 auto it = |
2004 std::find_if(senders_.begin(), senders_.end(), | 2011 std::find_if(senders_.begin(), senders_.end(), |
2005 [id](const rtc::scoped_refptr<RtpSenderInterface>& sender) { | 2012 [id](const rtc::scoped_refptr<RtpSenderProxyEx<RtpSender>>& s
ender) { |
2006 return sender->id() == id; | 2013 return sender->id() == id; |
2007 }); | 2014 }); |
2008 return it != senders_.end() ? it->get() : nullptr; | 2015 return it != senders_.end() ? it->get()->get() : nullptr; |
2009 } | 2016 } |
2010 | 2017 |
2011 std::vector<rtc::scoped_refptr<RtpSenderInterface>>::iterator | 2018 std::vector<rtc::scoped_refptr<RtpSenderProxyEx<RtpSender>>>::iterator |
2012 PeerConnection::FindSenderForTrack(MediaStreamTrackInterface* track) { | 2019 PeerConnection::FindSenderForTrack(MediaStreamTrackInterface* track) { |
2013 return std::find_if( | 2020 return std::find_if( |
2014 senders_.begin(), senders_.end(), | 2021 senders_.begin(), senders_.end(), |
2015 [track](const rtc::scoped_refptr<RtpSenderInterface>& sender) { | 2022 [track](const rtc::scoped_refptr<RtpSenderInterface>& sender) { |
2016 return sender->track() == track; | 2023 return sender->track() == track; |
2017 }); | 2024 }); |
2018 } | 2025 } |
2019 | 2026 |
2020 std::vector<rtc::scoped_refptr<RtpReceiverInterface>>::iterator | 2027 std::vector<rtc::scoped_refptr<RtpReceiverInterface>>::iterator |
2021 PeerConnection::FindReceiverForTrack(const std::string& track_id) { | 2028 PeerConnection::FindReceiverForTrack(const std::string& track_id) { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2058 DataChannel* PeerConnection::FindDataChannelBySid(int sid) const { | 2065 DataChannel* PeerConnection::FindDataChannelBySid(int sid) const { |
2059 for (const auto& channel : sctp_data_channels_) { | 2066 for (const auto& channel : sctp_data_channels_) { |
2060 if (channel->id() == sid) { | 2067 if (channel->id() == sid) { |
2061 return channel; | 2068 return channel; |
2062 } | 2069 } |
2063 } | 2070 } |
2064 return nullptr; | 2071 return nullptr; |
2065 } | 2072 } |
2066 | 2073 |
2067 } // namespace webrtc | 2074 } // namespace webrtc |
OLD | NEW |