diff --git a/pc/peerconnection.cc b/pc/peerconnection.cc index ef5294ffcc..245e89d216 100644 --- a/pc/peerconnection.cc +++ b/pc/peerconnection.cc @@ -986,15 +986,23 @@ RTCError PeerConnection::ValidateConfiguration( rtc::scoped_refptr PeerConnection::local_streams() { + RTC_CHECK(!IsUnifiedPlan()) << "local_streams is not available with Unified " + "Plan SdpSemantics. Please use GetSenders " + "instead."; return local_streams_; } rtc::scoped_refptr PeerConnection::remote_streams() { + RTC_CHECK(!IsUnifiedPlan()) << "remote_streams is not available with Unified " + "Plan SdpSemantics. Please use GetReceivers " + "instead."; return remote_streams_; } bool PeerConnection::AddStream(MediaStreamInterface* local_stream) { + RTC_CHECK(!IsUnifiedPlan()) << "AddStream is not available with Unified Plan " + "SdpSemantics. Please use AddTrack instead."; TRACE_EVENT0("webrtc", "PeerConnection::AddStream"); if (IsClosed()) { return false; @@ -1028,6 +1036,9 @@ bool PeerConnection::AddStream(MediaStreamInterface* local_stream) { } void PeerConnection::RemoveStream(MediaStreamInterface* local_stream) { + RTC_CHECK(!IsUnifiedPlan()) << "RemoveStream is not available with Unified " + "Plan SdpSemantics. Please use RemoveTrack " + "instead."; TRACE_EVENT0("webrtc", "PeerConnection::RemoveStream"); if (!IsClosed()) { for (const auto& track : local_stream->GetAudioTracks()) { @@ -1261,11 +1272,8 @@ RTCErrorOr> PeerConnection::AddTransceiver( rtc::scoped_refptr track, const RtpTransceiverInit& init) { - if (!IsUnifiedPlan()) { - LOG_AND_RETURN_ERROR( - RTCErrorType::INTERNAL_ERROR, - "AddTransceiver only supported when Unified Plan is enabled."); - } + RTC_CHECK(IsUnifiedPlan()) + << "AddTransceiver is only available with Unified Plan SdpSemantics"; if (!track) { LOG_AND_RETURN_ERROR(RTCErrorType::INVALID_PARAMETER, "track is null"); } @@ -1289,11 +1297,8 @@ PeerConnection::AddTransceiver(cricket::MediaType media_type) { RTCErrorOr> PeerConnection::AddTransceiver(cricket::MediaType media_type, const RtpTransceiverInit& init) { - if (!IsUnifiedPlan()) { - LOG_AND_RETURN_ERROR( - RTCErrorType::INTERNAL_ERROR, - "AddTransceiver only supported when Unified Plan is enabled."); - } + RTC_CHECK(IsUnifiedPlan()) + << "AddTransceiver is only available with Unified Plan SdpSemantics"; if (!(media_type == cricket::MEDIA_TYPE_AUDIO || media_type == cricket::MEDIA_TYPE_VIDEO)) { LOG_AND_RETURN_ERROR(RTCErrorType::INVALID_PARAMETER, @@ -1427,6 +1432,9 @@ rtc::scoped_refptr PeerConnection::CreateDtmfSender( rtc::scoped_refptr PeerConnection::CreateSender( const std::string& kind, const std::string& stream_id) { + RTC_CHECK(!IsUnifiedPlan()) << "CreateSender is not available with Unified " + "Plan SdpSemantics. Please use AddTransceiver " + "instead."; TRACE_EVENT0("webrtc", "PeerConnection::CreateSender"); if (IsClosed()) { return nullptr; @@ -1506,7 +1514,8 @@ PeerConnection::GetReceiversInternal() const { std::vector> PeerConnection::GetTransceivers() const { - RTC_DCHECK(IsUnifiedPlan()); + RTC_CHECK(IsUnifiedPlan()) + << "GetTransceivers is only supported with Unified Plan SdpSemantics."; std::vector> all_transceivers; for (auto transceiver : transceivers_) { all_transceivers.push_back(transceiver); diff --git a/pc/peerconnection_integrationtest.cc b/pc/peerconnection_integrationtest.cc index 312407cbad..30dbdc8288 100644 --- a/pc/peerconnection_integrationtest.cc +++ b/pc/peerconnection_integrationtest.cc @@ -2326,11 +2326,9 @@ TEST_P(PeerConnectionIntegrationTest, GetCaptureStartNtpTimeWithOldStatsApi) { // Get the remote audio track created on the receiver, so they can be used as // GetStats filters. - StreamCollectionInterface* remote_streams = callee()->remote_streams(); - ASSERT_EQ(1u, remote_streams->count()); - ASSERT_EQ(1u, remote_streams->at(0)->GetAudioTracks().size()); - MediaStreamTrackInterface* remote_audio_track = - remote_streams->at(0)->GetAudioTracks()[0]; + auto receivers = callee()->pc()->GetReceivers(); + ASSERT_EQ(1u, receivers.size()); + auto remote_audio_track = receivers[0]->track(); // Get the audio output level stats. Note that the level is not available // until an RTCP packet has been received. diff --git a/pc/test/peerconnectiontestwrapper.cc b/pc/test/peerconnectiontestwrapper.cc index b34d7f80c5..e2f606756a 100644 --- a/pc/test/peerconnectiontestwrapper.cc +++ b/pc/test/peerconnectiontestwrapper.cc @@ -263,9 +263,8 @@ rtc::scoped_refptr PeerConnectionTestWrapper::GetUserMedia( bool audio, const webrtc::FakeConstraints& audio_constraints, bool video, const webrtc::FakeConstraints& video_constraints) { - std::string label = kStreamLabelBase + - rtc::ToString( - static_cast(peer_connection_->local_streams()->count())); + std::string label = + kStreamLabelBase + rtc::ToString(num_get_user_media_calls_++); rtc::scoped_refptr stream = peer_connection_factory_->CreateLocalMediaStream(label); diff --git a/pc/test/peerconnectiontestwrapper.h b/pc/test/peerconnectiontestwrapper.h index aaf9408ed3..338b31df57 100644 --- a/pc/test/peerconnectiontestwrapper.h +++ b/pc/test/peerconnectiontestwrapper.h @@ -107,6 +107,7 @@ class PeerConnectionTestWrapper peer_connection_factory_; rtc::scoped_refptr fake_audio_capture_module_; std::unique_ptr renderer_; + int num_get_user_media_calls_ = 0; }; #endif // PC_TEST_PEERCONNECTIONTESTWRAPPER_H_