| OLD | NEW |
| 1 /* | 1 /* |
| 2 * libjingle | 2 * libjingle |
| 3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
| 9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 #include "talk/app/webrtc/rtpsender.h" | 44 #include "talk/app/webrtc/rtpsender.h" |
| 45 #include "talk/app/webrtc/streamcollection.h" | 45 #include "talk/app/webrtc/streamcollection.h" |
| 46 #include "talk/app/webrtc/videosource.h" | 46 #include "talk/app/webrtc/videosource.h" |
| 47 #include "talk/app/webrtc/videotrack.h" | 47 #include "talk/app/webrtc/videotrack.h" |
| 48 #include "talk/media/sctp/sctpdataengine.h" | 48 #include "talk/media/sctp/sctpdataengine.h" |
| 49 #include "talk/session/media/channelmanager.h" | 49 #include "talk/session/media/channelmanager.h" |
| 50 #include "webrtc/base/arraysize.h" | 50 #include "webrtc/base/arraysize.h" |
| 51 #include "webrtc/base/logging.h" | 51 #include "webrtc/base/logging.h" |
| 52 #include "webrtc/base/stringencode.h" | 52 #include "webrtc/base/stringencode.h" |
| 53 #include "webrtc/base/stringutils.h" | 53 #include "webrtc/base/stringutils.h" |
| 54 #include "webrtc/base/trace_event.h" |
| 54 #include "webrtc/p2p/client/basicportallocator.h" | 55 #include "webrtc/p2p/client/basicportallocator.h" |
| 55 #include "webrtc/system_wrappers/include/field_trial.h" | 56 #include "webrtc/system_wrappers/include/field_trial.h" |
| 56 | 57 |
| 57 namespace { | 58 namespace { |
| 58 | 59 |
| 59 using webrtc::DataChannel; | 60 using webrtc::DataChannel; |
| 60 using webrtc::MediaConstraintsInterface; | 61 using webrtc::MediaConstraintsInterface; |
| 61 using webrtc::MediaStreamInterface; | 62 using webrtc::MediaStreamInterface; |
| 62 using webrtc::PeerConnectionInterface; | 63 using webrtc::PeerConnectionInterface; |
| 63 using webrtc::RtpSenderInterface; | 64 using webrtc::RtpSenderInterface; |
| (...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 observer_(NULL), | 589 observer_(NULL), |
| 589 uma_observer_(NULL), | 590 uma_observer_(NULL), |
| 590 signaling_state_(kStable), | 591 signaling_state_(kStable), |
| 591 ice_state_(kIceNew), | 592 ice_state_(kIceNew), |
| 592 ice_connection_state_(kIceConnectionNew), | 593 ice_connection_state_(kIceConnectionNew), |
| 593 ice_gathering_state_(kIceGatheringNew), | 594 ice_gathering_state_(kIceGatheringNew), |
| 594 local_streams_(StreamCollection::Create()), | 595 local_streams_(StreamCollection::Create()), |
| 595 remote_streams_(StreamCollection::Create()) {} | 596 remote_streams_(StreamCollection::Create()) {} |
| 596 | 597 |
| 597 PeerConnection::~PeerConnection() { | 598 PeerConnection::~PeerConnection() { |
| 599 TRACE_EVENT0("webrtc", "PeerConnection::~PeerConnection"); |
| 598 RTC_DCHECK(signaling_thread()->IsCurrent()); | 600 RTC_DCHECK(signaling_thread()->IsCurrent()); |
| 599 // Finish any pending deletions. | 601 // Finish any pending deletions. |
| 600 signaling_thread()->Clear(this, MSG_DELETE, nullptr); | 602 signaling_thread()->Clear(this, MSG_DELETE, nullptr); |
| 601 // Need to detach RTP senders/receivers from WebRtcSession, | 603 // Need to detach RTP senders/receivers from WebRtcSession, |
| 602 // since it's about to be destroyed. | 604 // since it's about to be destroyed. |
| 603 for (const auto& sender : senders_) { | 605 for (const auto& sender : senders_) { |
| 604 sender->Stop(); | 606 sender->Stop(); |
| 605 } | 607 } |
| 606 for (const auto& receiver : receivers_) { | 608 for (const auto& receiver : receivers_) { |
| 607 receiver->Stop(); | 609 receiver->Stop(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 631 return Initialize(configuration, constraints, allocator.Pass(), | 633 return Initialize(configuration, constraints, allocator.Pass(), |
| 632 dtls_identity_store.Pass(), observer); | 634 dtls_identity_store.Pass(), observer); |
| 633 } | 635 } |
| 634 | 636 |
| 635 bool PeerConnection::Initialize( | 637 bool PeerConnection::Initialize( |
| 636 const PeerConnectionInterface::RTCConfiguration& configuration, | 638 const PeerConnectionInterface::RTCConfiguration& configuration, |
| 637 const MediaConstraintsInterface* constraints, | 639 const MediaConstraintsInterface* constraints, |
| 638 rtc::scoped_ptr<cricket::PortAllocator> allocator, | 640 rtc::scoped_ptr<cricket::PortAllocator> allocator, |
| 639 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store, | 641 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store, |
| 640 PeerConnectionObserver* observer) { | 642 PeerConnectionObserver* observer) { |
| 643 TRACE_EVENT0("webrtc", "PeerConnection::Initialize"); |
| 641 RTC_DCHECK(observer != nullptr); | 644 RTC_DCHECK(observer != nullptr); |
| 642 if (!observer) { | 645 if (!observer) { |
| 643 return false; | 646 return false; |
| 644 } | 647 } |
| 645 observer_ = observer; | 648 observer_ = observer; |
| 646 | 649 |
| 647 port_allocator_ = allocator.Pass(); | 650 port_allocator_ = allocator.Pass(); |
| 648 | 651 |
| 649 std::vector<PortAllocatorFactoryInterface::StunConfiguration> stun_config; | 652 std::vector<PortAllocatorFactoryInterface::StunConfiguration> stun_config; |
| 650 std::vector<PortAllocatorFactoryInterface::TurnConfiguration> turn_config; | 653 std::vector<PortAllocatorFactoryInterface::TurnConfiguration> turn_config; |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 721 PeerConnection::local_streams() { | 724 PeerConnection::local_streams() { |
| 722 return local_streams_; | 725 return local_streams_; |
| 723 } | 726 } |
| 724 | 727 |
| 725 rtc::scoped_refptr<StreamCollectionInterface> | 728 rtc::scoped_refptr<StreamCollectionInterface> |
| 726 PeerConnection::remote_streams() { | 729 PeerConnection::remote_streams() { |
| 727 return remote_streams_; | 730 return remote_streams_; |
| 728 } | 731 } |
| 729 | 732 |
| 730 bool PeerConnection::AddStream(MediaStreamInterface* local_stream) { | 733 bool PeerConnection::AddStream(MediaStreamInterface* local_stream) { |
| 734 TRACE_EVENT0("webrtc", "PeerConnection::AddStream"); |
| 731 if (IsClosed()) { | 735 if (IsClosed()) { |
| 732 return false; | 736 return false; |
| 733 } | 737 } |
| 734 if (!CanAddLocalMediaStream(local_streams_, local_stream)) { | 738 if (!CanAddLocalMediaStream(local_streams_, local_stream)) { |
| 735 return false; | 739 return false; |
| 736 } | 740 } |
| 737 | 741 |
| 738 local_streams_->AddStream(local_stream); | 742 local_streams_->AddStream(local_stream); |
| 739 | 743 |
| 740 for (const auto& track : local_stream->GetAudioTracks()) { | 744 for (const auto& track : local_stream->GetAudioTracks()) { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 781 } | 785 } |
| 782 | 786 |
| 783 stats_->AddStream(local_stream); | 787 stats_->AddStream(local_stream); |
| 784 observer_->OnRenegotiationNeeded(); | 788 observer_->OnRenegotiationNeeded(); |
| 785 return true; | 789 return true; |
| 786 } | 790 } |
| 787 | 791 |
| 788 // TODO(deadbeef): Don't destroy RtpSenders here; they should be kept around | 792 // TODO(deadbeef): Don't destroy RtpSenders here; they should be kept around |
| 789 // indefinitely, when we have unified plan SDP. | 793 // indefinitely, when we have unified plan SDP. |
| 790 void PeerConnection::RemoveStream(MediaStreamInterface* local_stream) { | 794 void PeerConnection::RemoveStream(MediaStreamInterface* local_stream) { |
| 795 TRACE_EVENT0("webrtc", "PeerConnection::RemoveStream"); |
| 791 for (const auto& track : local_stream->GetAudioTracks()) { | 796 for (const auto& track : local_stream->GetAudioTracks()) { |
| 792 auto sender = FindSenderForTrack(track.get()); | 797 auto sender = FindSenderForTrack(track.get()); |
| 793 if (sender == senders_.end()) { | 798 if (sender == senders_.end()) { |
| 794 LOG(LS_WARNING) << "RtpSender for track with id " << track->id() | 799 LOG(LS_WARNING) << "RtpSender for track with id " << track->id() |
| 795 << " doesn't exist."; | 800 << " doesn't exist."; |
| 796 continue; | 801 continue; |
| 797 } | 802 } |
| 798 (*sender)->Stop(); | 803 (*sender)->Stop(); |
| 799 senders_.erase(sender); | 804 senders_.erase(sender); |
| 800 } | 805 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 812 local_streams_->RemoveStream(local_stream); | 817 local_streams_->RemoveStream(local_stream); |
| 813 | 818 |
| 814 if (IsClosed()) { | 819 if (IsClosed()) { |
| 815 return; | 820 return; |
| 816 } | 821 } |
| 817 observer_->OnRenegotiationNeeded(); | 822 observer_->OnRenegotiationNeeded(); |
| 818 } | 823 } |
| 819 | 824 |
| 820 rtc::scoped_refptr<DtmfSenderInterface> PeerConnection::CreateDtmfSender( | 825 rtc::scoped_refptr<DtmfSenderInterface> PeerConnection::CreateDtmfSender( |
| 821 AudioTrackInterface* track) { | 826 AudioTrackInterface* track) { |
| 827 TRACE_EVENT0("webrtc", "PeerConnection::CreateDtmfSender"); |
| 822 if (!track) { | 828 if (!track) { |
| 823 LOG(LS_ERROR) << "CreateDtmfSender - track is NULL."; | 829 LOG(LS_ERROR) << "CreateDtmfSender - track is NULL."; |
| 824 return NULL; | 830 return NULL; |
| 825 } | 831 } |
| 826 if (!local_streams_->FindAudioTrack(track->id())) { | 832 if (!local_streams_->FindAudioTrack(track->id())) { |
| 827 LOG(LS_ERROR) << "CreateDtmfSender is called with a non local audio track."; | 833 LOG(LS_ERROR) << "CreateDtmfSender is called with a non local audio track."; |
| 828 return NULL; | 834 return NULL; |
| 829 } | 835 } |
| 830 | 836 |
| 831 rtc::scoped_refptr<DtmfSenderInterface> sender( | 837 rtc::scoped_refptr<DtmfSenderInterface> sender( |
| 832 DtmfSender::Create(track, signaling_thread(), session_.get())); | 838 DtmfSender::Create(track, signaling_thread(), session_.get())); |
| 833 if (!sender.get()) { | 839 if (!sender.get()) { |
| 834 LOG(LS_ERROR) << "CreateDtmfSender failed on DtmfSender::Create."; | 840 LOG(LS_ERROR) << "CreateDtmfSender failed on DtmfSender::Create."; |
| 835 return NULL; | 841 return NULL; |
| 836 } | 842 } |
| 837 return DtmfSenderProxy::Create(signaling_thread(), sender.get()); | 843 return DtmfSenderProxy::Create(signaling_thread(), sender.get()); |
| 838 } | 844 } |
| 839 | 845 |
| 840 rtc::scoped_refptr<RtpSenderInterface> PeerConnection::CreateSender( | 846 rtc::scoped_refptr<RtpSenderInterface> PeerConnection::CreateSender( |
| 841 const std::string& kind) { | 847 const std::string& kind) { |
| 848 TRACE_EVENT0("webrtc", "PeerConnection::CreateSender"); |
| 842 RtpSenderInterface* new_sender; | 849 RtpSenderInterface* new_sender; |
| 843 if (kind == MediaStreamTrackInterface::kAudioKind) { | 850 if (kind == MediaStreamTrackInterface::kAudioKind) { |
| 844 new_sender = new AudioRtpSender(session_.get(), stats_.get()); | 851 new_sender = new AudioRtpSender(session_.get(), stats_.get()); |
| 845 } else if (kind == MediaStreamTrackInterface::kVideoKind) { | 852 } else if (kind == MediaStreamTrackInterface::kVideoKind) { |
| 846 new_sender = new VideoRtpSender(session_.get()); | 853 new_sender = new VideoRtpSender(session_.get()); |
| 847 } else { | 854 } else { |
| 848 LOG(LS_ERROR) << "CreateSender called with invalid kind: " << kind; | 855 LOG(LS_ERROR) << "CreateSender called with invalid kind: " << kind; |
| 849 return rtc::scoped_refptr<RtpSenderInterface>(); | 856 return rtc::scoped_refptr<RtpSenderInterface>(); |
| 850 } | 857 } |
| 851 senders_.push_back(new_sender); | 858 senders_.push_back(new_sender); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 867 for (const auto& receiver : receivers_) { | 874 for (const auto& receiver : receivers_) { |
| 868 receivers.push_back( | 875 receivers.push_back( |
| 869 RtpReceiverProxy::Create(signaling_thread(), receiver.get())); | 876 RtpReceiverProxy::Create(signaling_thread(), receiver.get())); |
| 870 } | 877 } |
| 871 return receivers; | 878 return receivers; |
| 872 } | 879 } |
| 873 | 880 |
| 874 bool PeerConnection::GetStats(StatsObserver* observer, | 881 bool PeerConnection::GetStats(StatsObserver* observer, |
| 875 MediaStreamTrackInterface* track, | 882 MediaStreamTrackInterface* track, |
| 876 StatsOutputLevel level) { | 883 StatsOutputLevel level) { |
| 884 TRACE_EVENT0("webrtc", "PeerConnection::GetStats"); |
| 877 RTC_DCHECK(signaling_thread()->IsCurrent()); | 885 RTC_DCHECK(signaling_thread()->IsCurrent()); |
| 878 if (!VERIFY(observer != NULL)) { | 886 if (!VERIFY(observer != NULL)) { |
| 879 LOG(LS_ERROR) << "GetStats - observer is NULL."; | 887 LOG(LS_ERROR) << "GetStats - observer is NULL."; |
| 880 return false; | 888 return false; |
| 881 } | 889 } |
| 882 | 890 |
| 883 stats_->UpdateStats(level); | 891 stats_->UpdateStats(level); |
| 884 signaling_thread()->Post(this, MSG_GETSTATS, | 892 signaling_thread()->Post(this, MSG_GETSTATS, |
| 885 new GetStatsMsg(observer, track)); | 893 new GetStatsMsg(observer, track)); |
| 886 return true; | 894 return true; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 901 | 909 |
| 902 PeerConnectionInterface::IceGatheringState | 910 PeerConnectionInterface::IceGatheringState |
| 903 PeerConnection::ice_gathering_state() { | 911 PeerConnection::ice_gathering_state() { |
| 904 return ice_gathering_state_; | 912 return ice_gathering_state_; |
| 905 } | 913 } |
| 906 | 914 |
| 907 rtc::scoped_refptr<DataChannelInterface> | 915 rtc::scoped_refptr<DataChannelInterface> |
| 908 PeerConnection::CreateDataChannel( | 916 PeerConnection::CreateDataChannel( |
| 909 const std::string& label, | 917 const std::string& label, |
| 910 const DataChannelInit* config) { | 918 const DataChannelInit* config) { |
| 919 TRACE_EVENT0("webrtc", "PeerConnection::CreateDataChannel"); |
| 911 bool first_datachannel = !HasDataChannels(); | 920 bool first_datachannel = !HasDataChannels(); |
| 912 | 921 |
| 913 rtc::scoped_ptr<InternalDataChannelInit> internal_config; | 922 rtc::scoped_ptr<InternalDataChannelInit> internal_config; |
| 914 if (config) { | 923 if (config) { |
| 915 internal_config.reset(new InternalDataChannelInit(*config)); | 924 internal_config.reset(new InternalDataChannelInit(*config)); |
| 916 } | 925 } |
| 917 rtc::scoped_refptr<DataChannelInterface> channel( | 926 rtc::scoped_refptr<DataChannelInterface> channel( |
| 918 InternalCreateDataChannel(label, internal_config.get())); | 927 InternalCreateDataChannel(label, internal_config.get())); |
| 919 if (!channel.get()) { | 928 if (!channel.get()) { |
| 920 return nullptr; | 929 return nullptr; |
| 921 } | 930 } |
| 922 | 931 |
| 923 // Trigger the onRenegotiationNeeded event for every new RTP DataChannel, or | 932 // Trigger the onRenegotiationNeeded event for every new RTP DataChannel, or |
| 924 // the first SCTP DataChannel. | 933 // the first SCTP DataChannel. |
| 925 if (session_->data_channel_type() == cricket::DCT_RTP || first_datachannel) { | 934 if (session_->data_channel_type() == cricket::DCT_RTP || first_datachannel) { |
| 926 observer_->OnRenegotiationNeeded(); | 935 observer_->OnRenegotiationNeeded(); |
| 927 } | 936 } |
| 928 | 937 |
| 929 return DataChannelProxy::Create(signaling_thread(), channel.get()); | 938 return DataChannelProxy::Create(signaling_thread(), channel.get()); |
| 930 } | 939 } |
| 931 | 940 |
| 932 void PeerConnection::CreateOffer(CreateSessionDescriptionObserver* observer, | 941 void PeerConnection::CreateOffer(CreateSessionDescriptionObserver* observer, |
| 933 const MediaConstraintsInterface* constraints) { | 942 const MediaConstraintsInterface* constraints) { |
| 943 TRACE_EVENT0("webrtc", "PeerConnection::CreateOffer"); |
| 934 if (!VERIFY(observer != nullptr)) { | 944 if (!VERIFY(observer != nullptr)) { |
| 935 LOG(LS_ERROR) << "CreateOffer - observer is NULL."; | 945 LOG(LS_ERROR) << "CreateOffer - observer is NULL."; |
| 936 return; | 946 return; |
| 937 } | 947 } |
| 938 RTCOfferAnswerOptions options; | 948 RTCOfferAnswerOptions options; |
| 939 | 949 |
| 940 bool value; | 950 bool value; |
| 941 size_t mandatory_constraints = 0; | 951 size_t mandatory_constraints = 0; |
| 942 | 952 |
| 943 if (FindConstraint(constraints, | 953 if (FindConstraint(constraints, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 975 &value, | 985 &value, |
| 976 &mandatory_constraints)) { | 986 &mandatory_constraints)) { |
| 977 options.use_rtp_mux = value; | 987 options.use_rtp_mux = value; |
| 978 } | 988 } |
| 979 | 989 |
| 980 CreateOffer(observer, options); | 990 CreateOffer(observer, options); |
| 981 } | 991 } |
| 982 | 992 |
| 983 void PeerConnection::CreateOffer(CreateSessionDescriptionObserver* observer, | 993 void PeerConnection::CreateOffer(CreateSessionDescriptionObserver* observer, |
| 984 const RTCOfferAnswerOptions& options) { | 994 const RTCOfferAnswerOptions& options) { |
| 995 TRACE_EVENT0("webrtc", "PeerConnection::CreateOffer"); |
| 985 if (!VERIFY(observer != nullptr)) { | 996 if (!VERIFY(observer != nullptr)) { |
| 986 LOG(LS_ERROR) << "CreateOffer - observer is NULL."; | 997 LOG(LS_ERROR) << "CreateOffer - observer is NULL."; |
| 987 return; | 998 return; |
| 988 } | 999 } |
| 989 | 1000 |
| 990 cricket::MediaSessionOptions session_options; | 1001 cricket::MediaSessionOptions session_options; |
| 991 if (!GetOptionsForOffer(options, &session_options)) { | 1002 if (!GetOptionsForOffer(options, &session_options)) { |
| 992 std::string error = "CreateOffer called with invalid options."; | 1003 std::string error = "CreateOffer called with invalid options."; |
| 993 LOG(LS_ERROR) << error; | 1004 LOG(LS_ERROR) << error; |
| 994 PostCreateSessionDescriptionFailure(observer, error); | 1005 PostCreateSessionDescriptionFailure(observer, error); |
| 995 return; | 1006 return; |
| 996 } | 1007 } |
| 997 | 1008 |
| 998 session_->CreateOffer(observer, options, session_options); | 1009 session_->CreateOffer(observer, options, session_options); |
| 999 } | 1010 } |
| 1000 | 1011 |
| 1001 void PeerConnection::CreateAnswer( | 1012 void PeerConnection::CreateAnswer( |
| 1002 CreateSessionDescriptionObserver* observer, | 1013 CreateSessionDescriptionObserver* observer, |
| 1003 const MediaConstraintsInterface* constraints) { | 1014 const MediaConstraintsInterface* constraints) { |
| 1015 TRACE_EVENT0("webrtc", "PeerConnection::CreateAnswer"); |
| 1004 if (!VERIFY(observer != nullptr)) { | 1016 if (!VERIFY(observer != nullptr)) { |
| 1005 LOG(LS_ERROR) << "CreateAnswer - observer is NULL."; | 1017 LOG(LS_ERROR) << "CreateAnswer - observer is NULL."; |
| 1006 return; | 1018 return; |
| 1007 } | 1019 } |
| 1008 | 1020 |
| 1009 cricket::MediaSessionOptions session_options; | 1021 cricket::MediaSessionOptions session_options; |
| 1010 if (!GetOptionsForAnswer(constraints, &session_options)) { | 1022 if (!GetOptionsForAnswer(constraints, &session_options)) { |
| 1011 std::string error = "CreateAnswer called with invalid constraints."; | 1023 std::string error = "CreateAnswer called with invalid constraints."; |
| 1012 LOG(LS_ERROR) << error; | 1024 LOG(LS_ERROR) << error; |
| 1013 PostCreateSessionDescriptionFailure(observer, error); | 1025 PostCreateSessionDescriptionFailure(observer, error); |
| 1014 return; | 1026 return; |
| 1015 } | 1027 } |
| 1016 | 1028 |
| 1017 session_->CreateAnswer(observer, constraints, session_options); | 1029 session_->CreateAnswer(observer, constraints, session_options); |
| 1018 } | 1030 } |
| 1019 | 1031 |
| 1020 void PeerConnection::SetLocalDescription( | 1032 void PeerConnection::SetLocalDescription( |
| 1021 SetSessionDescriptionObserver* observer, | 1033 SetSessionDescriptionObserver* observer, |
| 1022 SessionDescriptionInterface* desc) { | 1034 SessionDescriptionInterface* desc) { |
| 1035 TRACE_EVENT0("webrtc", "PeerConnection::SetLocalDescription"); |
| 1023 if (!VERIFY(observer != nullptr)) { | 1036 if (!VERIFY(observer != nullptr)) { |
| 1024 LOG(LS_ERROR) << "SetLocalDescription - observer is NULL."; | 1037 LOG(LS_ERROR) << "SetLocalDescription - observer is NULL."; |
| 1025 return; | 1038 return; |
| 1026 } | 1039 } |
| 1027 if (!desc) { | 1040 if (!desc) { |
| 1028 PostSetSessionDescriptionFailure(observer, "SessionDescription is NULL."); | 1041 PostSetSessionDescriptionFailure(observer, "SessionDescription is NULL."); |
| 1029 return; | 1042 return; |
| 1030 } | 1043 } |
| 1031 // Update stats here so that we have the most recent stats for tracks and | 1044 // Update stats here so that we have the most recent stats for tracks and |
| 1032 // streams that might be removed by updating the session description. | 1045 // streams that might be removed by updating the session description. |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1090 | 1103 |
| 1091 // MaybeStartGathering needs to be called after posting | 1104 // MaybeStartGathering needs to be called after posting |
| 1092 // MSG_SET_SESSIONDESCRIPTION_SUCCESS, so that we don't signal any candidates | 1105 // MSG_SET_SESSIONDESCRIPTION_SUCCESS, so that we don't signal any candidates |
| 1093 // before signaling that SetLocalDescription completed. | 1106 // before signaling that SetLocalDescription completed. |
| 1094 session_->MaybeStartGathering(); | 1107 session_->MaybeStartGathering(); |
| 1095 } | 1108 } |
| 1096 | 1109 |
| 1097 void PeerConnection::SetRemoteDescription( | 1110 void PeerConnection::SetRemoteDescription( |
| 1098 SetSessionDescriptionObserver* observer, | 1111 SetSessionDescriptionObserver* observer, |
| 1099 SessionDescriptionInterface* desc) { | 1112 SessionDescriptionInterface* desc) { |
| 1113 TRACE_EVENT0("webrtc", "PeerConnection::SetRemoteDescription"); |
| 1100 if (!VERIFY(observer != nullptr)) { | 1114 if (!VERIFY(observer != nullptr)) { |
| 1101 LOG(LS_ERROR) << "SetRemoteDescription - observer is NULL."; | 1115 LOG(LS_ERROR) << "SetRemoteDescription - observer is NULL."; |
| 1102 return; | 1116 return; |
| 1103 } | 1117 } |
| 1104 if (!desc) { | 1118 if (!desc) { |
| 1105 PostSetSessionDescriptionFailure(observer, "SessionDescription is NULL."); | 1119 PostSetSessionDescriptionFailure(observer, "SessionDescription is NULL."); |
| 1106 return; | 1120 return; |
| 1107 } | 1121 } |
| 1108 // Update stats here so that we have the most recent stats for tracks and | 1122 // Update stats here so that we have the most recent stats for tracks and |
| 1109 // streams that might be removed by updating the session description. | 1123 // streams that might be removed by updating the session description. |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1191 UpdateEndedRemoteMediaStreams(); | 1205 UpdateEndedRemoteMediaStreams(); |
| 1192 remote_info_.msid_supported |= remote_streams_->count() > 0; | 1206 remote_info_.msid_supported |= remote_streams_->count() > 0; |
| 1193 } | 1207 } |
| 1194 MaybeCreateDefaultStream(); | 1208 MaybeCreateDefaultStream(); |
| 1195 | 1209 |
| 1196 SetSessionDescriptionMsg* msg = new SetSessionDescriptionMsg(observer); | 1210 SetSessionDescriptionMsg* msg = new SetSessionDescriptionMsg(observer); |
| 1197 signaling_thread()->Post(this, MSG_SET_SESSIONDESCRIPTION_SUCCESS, msg); | 1211 signaling_thread()->Post(this, MSG_SET_SESSIONDESCRIPTION_SUCCESS, msg); |
| 1198 } | 1212 } |
| 1199 | 1213 |
| 1200 bool PeerConnection::SetConfiguration(const RTCConfiguration& config) { | 1214 bool PeerConnection::SetConfiguration(const RTCConfiguration& config) { |
| 1215 TRACE_EVENT0("webrtc", "PeerConnection::SetConfiguration"); |
| 1201 if (port_allocator_) { | 1216 if (port_allocator_) { |
| 1202 std::vector<PortAllocatorFactoryInterface::StunConfiguration> stuns; | 1217 std::vector<PortAllocatorFactoryInterface::StunConfiguration> stuns; |
| 1203 std::vector<PortAllocatorFactoryInterface::TurnConfiguration> turns; | 1218 std::vector<PortAllocatorFactoryInterface::TurnConfiguration> turns; |
| 1204 if (!ParseIceServers(config.servers, &stuns, &turns)) { | 1219 if (!ParseIceServers(config.servers, &stuns, &turns)) { |
| 1205 return false; | 1220 return false; |
| 1206 } | 1221 } |
| 1207 | 1222 |
| 1208 cricket::ServerAddresses cricket_stuns; | 1223 cricket::ServerAddresses cricket_stuns; |
| 1209 std::vector<cricket::RelayServerConfig> cricket_turns; | 1224 std::vector<cricket::RelayServerConfig> cricket_turns; |
| 1210 ConvertToCricketIceServers(stuns, turns, &cricket_stuns, &cricket_turns); | 1225 ConvertToCricketIceServers(stuns, turns, &cricket_stuns, &cricket_turns); |
| 1211 port_allocator_->SetIceServers(cricket_stuns, cricket_turns); | 1226 port_allocator_->SetIceServers(cricket_stuns, cricket_turns); |
| 1212 } | 1227 } |
| 1213 session_->SetIceConfig(session_->ParseIceConfig(config)); | 1228 session_->SetIceConfig(session_->ParseIceConfig(config)); |
| 1214 return session_->SetIceTransports(config.type); | 1229 return session_->SetIceTransports(config.type); |
| 1215 } | 1230 } |
| 1216 | 1231 |
| 1217 bool PeerConnection::AddIceCandidate( | 1232 bool PeerConnection::AddIceCandidate( |
| 1218 const IceCandidateInterface* ice_candidate) { | 1233 const IceCandidateInterface* ice_candidate) { |
| 1234 TRACE_EVENT0("webrtc", "PeerConnection::AddIceCandidate"); |
| 1219 return session_->ProcessIceMessage(ice_candidate); | 1235 return session_->ProcessIceMessage(ice_candidate); |
| 1220 } | 1236 } |
| 1221 | 1237 |
| 1222 void PeerConnection::RegisterUMAObserver(UMAObserver* observer) { | 1238 void PeerConnection::RegisterUMAObserver(UMAObserver* observer) { |
| 1239 TRACE_EVENT0("webrtc", "PeerConnection::RegisterUmaObserver"); |
| 1223 uma_observer_ = observer; | 1240 uma_observer_ = observer; |
| 1224 | 1241 |
| 1225 if (session_) { | 1242 if (session_) { |
| 1226 session_->set_metrics_observer(uma_observer_); | 1243 session_->set_metrics_observer(uma_observer_); |
| 1227 } | 1244 } |
| 1228 | 1245 |
| 1229 // Send information about IPv4/IPv6 status. | 1246 // Send information about IPv4/IPv6 status. |
| 1230 if (uma_observer_ && port_allocator_) { | 1247 if (uma_observer_ && port_allocator_) { |
| 1231 if (port_allocator_->flags() & cricket::PORTALLOCATOR_ENABLE_IPV6) { | 1248 if (port_allocator_->flags() & cricket::PORTALLOCATOR_ENABLE_IPV6) { |
| 1232 uma_observer_->IncrementEnumCounter( | 1249 uma_observer_->IncrementEnumCounter( |
| 1233 kEnumCounterAddressFamily, kPeerConnection_IPv6, | 1250 kEnumCounterAddressFamily, kPeerConnection_IPv6, |
| 1234 kPeerConnectionAddressFamilyCounter_Max); | 1251 kPeerConnectionAddressFamilyCounter_Max); |
| 1235 } else { | 1252 } else { |
| 1236 uma_observer_->IncrementEnumCounter( | 1253 uma_observer_->IncrementEnumCounter( |
| 1237 kEnumCounterAddressFamily, kPeerConnection_IPv4, | 1254 kEnumCounterAddressFamily, kPeerConnection_IPv4, |
| 1238 kPeerConnectionAddressFamilyCounter_Max); | 1255 kPeerConnectionAddressFamilyCounter_Max); |
| 1239 } | 1256 } |
| 1240 } | 1257 } |
| 1241 } | 1258 } |
| 1242 | 1259 |
| 1243 const SessionDescriptionInterface* PeerConnection::local_description() const { | 1260 const SessionDescriptionInterface* PeerConnection::local_description() const { |
| 1244 return session_->local_description(); | 1261 return session_->local_description(); |
| 1245 } | 1262 } |
| 1246 | 1263 |
| 1247 const SessionDescriptionInterface* PeerConnection::remote_description() const { | 1264 const SessionDescriptionInterface* PeerConnection::remote_description() const { |
| 1248 return session_->remote_description(); | 1265 return session_->remote_description(); |
| 1249 } | 1266 } |
| 1250 | 1267 |
| 1251 void PeerConnection::Close() { | 1268 void PeerConnection::Close() { |
| 1269 TRACE_EVENT0("webrtc", "PeerConnection::Close"); |
| 1252 // Update stats here so that we have the most recent stats for tracks and | 1270 // Update stats here so that we have the most recent stats for tracks and |
| 1253 // streams before the channels are closed. | 1271 // streams before the channels are closed. |
| 1254 stats_->UpdateStats(kStatsOutputLevelStandard); | 1272 stats_->UpdateStats(kStatsOutputLevelStandard); |
| 1255 | 1273 |
| 1256 session_->Close(); | 1274 session_->Close(); |
| 1257 } | 1275 } |
| 1258 | 1276 |
| 1259 void PeerConnection::OnSessionStateChange(WebRtcSession* /*session*/, | 1277 void PeerConnection::OnSessionStateChange(WebRtcSession* /*session*/, |
| 1260 WebRtcSession::State state) { | 1278 WebRtcSession::State state) { |
| 1261 switch (state) { | 1279 switch (state) { |
| (...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2021 DataChannel* PeerConnection::FindDataChannelBySid(int sid) const { | 2039 DataChannel* PeerConnection::FindDataChannelBySid(int sid) const { |
| 2022 for (const auto& channel : sctp_data_channels_) { | 2040 for (const auto& channel : sctp_data_channels_) { |
| 2023 if (channel->id() == sid) { | 2041 if (channel->id() == sid) { |
| 2024 return channel; | 2042 return channel; |
| 2025 } | 2043 } |
| 2026 } | 2044 } |
| 2027 return nullptr; | 2045 return nullptr; |
| 2028 } | 2046 } |
| 2029 | 2047 |
| 2030 } // namespace webrtc | 2048 } // namespace webrtc |
| OLD | NEW |