From 1c7d1b2fa743b8ee129be19d35e6510314c97124 Mon Sep 17 00:00:00 2001 From: slimshady999z Date: Thu, 14 Sep 2023 21:04:22 +0800 Subject: [PATCH] fix patch Signed-off-by: slimshady999z Change-Id: Id19d68fadaf3d71e22e508caae6b90f79f6c25c6 --- modules/pacing/packet_router.cc | 18 +++--- modules/pacing/packet_router_unittest.cc | 24 ++++---- pc/peer_connection_bundle_unittest.cc | 74 ++++++++++++------------ pc/sdp_offer_answer.cc | 32 +++++----- pc/sdp_offer_answer_unittest.cc | 36 ++++++------ 5 files changed, 92 insertions(+), 92 deletions(-) diff --git a/modules/pacing/packet_router.cc b/modules/pacing/packet_router.cc index 0d04497a..1013ddf6 100644 --- a/modules/pacing/packet_router.cc +++ b/modules/pacing/packet_router.cc @@ -85,15 +85,15 @@ void PacketRouter::AddSendRtpModuleToMap(RtpRtcpInterface* rtp_module, } void PacketRouter::RemoveSendRtpModuleFromMap(uint32_t ssrc) { - - auto it = send_modules_map_.find(ssrc); - if (it == send_modules_map_.end()) { - RTC_LOG(LS_ERROR) << "No send module found for ssrc " << ssrc; - return; - } - send_modules_list_.remove(it->second); - - send_modules_map_.erase(it); + + auto it = send_modules_map_.find(ssrc); + if (it == send_modules_map_.end()) { + RTC_LOG(LS_ERROR) << "No send module found for ssrc " << ssrc; + return; + } + send_modules_list_.remove(it->second); + + send_modules_map_.erase(it); } void PacketRouter::RemoveSendRtpModule(RtpRtcpInterface* rtp_module) { diff --git a/modules/pacing/packet_router_unittest.cc b/modules/pacing/packet_router_unittest.cc index 3bed444f..573ed75c 100644 --- a/modules/pacing/packet_router_unittest.cc +++ b/modules/pacing/packet_router_unittest.cc @@ -423,23 +423,23 @@ TEST_F(PacketRouterDeathTest, DoubleRegistrationOfReceiveModuleDisallowed) { packet_router_.RemoveReceiveRtpModule(&module); } -TEST_F(PacketRouterDeathTest, RemovalOfNeverAddedReceiveModuleDisallowed) { +TEST_F(PacketRouterDeathTest, RemovalOfNeverAddedReceiveModuleDisallowed) { NiceMock module; - EXPECT_DEATH(packet_router_.RemoveReceiveRtpModule(&module), ""); + EXPECT_DEATH(packet_router_.RemoveReceiveRtpModule(&module), ""); } -#endif // RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) +#endif // RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) -TEST_F(PacketRouterTest, RemovalOfNeverAddedSendModuleIgnored) { +TEST_F(PacketRouterTest, RemovalOfNeverAddedSendModuleIgnored) { NiceMock module; - packet_router_.RemoveSendRtpModule(&module); -} - -TEST_F(PacketRouterTest, DuplicateRemovalOfSendModuleIgnored) { - NiceMock module; - packet_router_.AddSendRtpModule(&module, false); - packet_router_.RemoveSendRtpModule(&module); - packet_router_.RemoveSendRtpModule(&module); + packet_router_.RemoveSendRtpModule(&module); +} + +TEST_F(PacketRouterTest, DuplicateRemovalOfSendModuleIgnored) { + NiceMock module; + packet_router_.AddSendRtpModule(&module, false); + packet_router_.RemoveSendRtpModule(&module); + packet_router_.RemoveSendRtpModule(&module); } TEST(PacketRouterRembTest, ChangeSendRtpModuleChangeRembSender) { diff --git a/pc/peer_connection_bundle_unittest.cc b/pc/peer_connection_bundle_unittest.cc index a59983c8..4c4ca472 100644 --- a/pc/peer_connection_bundle_unittest.cc +++ b/pc/peer_connection_bundle_unittest.cc @@ -675,17 +675,17 @@ TEST_P(PeerConnectionBundleTest, BundleOnFirstMidInAnswer) { } // This tests that applying description with conflicted RTP demuxing criteria -// will fail when using BUNDLE. -TEST_P(PeerConnectionBundleTest, ApplyDescriptionWithSameSsrcsBundledFails) { +// will fail when using BUNDLE. +TEST_P(PeerConnectionBundleTest, ApplyDescriptionWithSameSsrcsBundledFails) { auto caller = CreatePeerConnectionWithAudioVideo(); auto callee = CreatePeerConnectionWithAudioVideo(); RTCOfferAnswerOptions options; - options.use_rtp_mux = true; + options.use_rtp_mux = true; auto offer = caller->CreateOffer(options); - EXPECT_TRUE( - caller->SetLocalDescription(CloneSessionDescription(offer.get()))); - // Modify the remote SDP to make two m= sections have the same SSRC. + EXPECT_TRUE( + caller->SetLocalDescription(CloneSessionDescription(offer.get()))); + // Modify the remote SDP to make two m= sections have the same SSRC. ASSERT_GE(offer->description()->contents().size(), 2U); offer->description() ->contents()[0] @@ -697,42 +697,42 @@ TEST_P(PeerConnectionBundleTest, ApplyDescriptionWithSameSsrcsBundledFails) { .media_description() ->mutable_streams()[0] .ssrcs[0] = 1111222; - EXPECT_TRUE(callee->SetRemoteDescription(std::move(offer))); - - // When BUNDLE is enabled, applying the description is expected to fail - // because the demuxing criteria can not be satisfied. - auto answer = callee->CreateAnswer(options); - EXPECT_FALSE(callee->SetLocalDescription(std::move(answer))); -} - -// A variant of the above, without BUNDLE duplicate SSRCs are allowed. -TEST_P(PeerConnectionBundleTest, - ApplyDescriptionWithSameSsrcsUnbundledSucceeds) { - auto caller = CreatePeerConnectionWithAudioVideo(); - auto callee = CreatePeerConnectionWithAudioVideo(); - - RTCOfferAnswerOptions options; - options.use_rtp_mux = false; - auto offer = caller->CreateOffer(options); + EXPECT_TRUE(callee->SetRemoteDescription(std::move(offer))); + + // When BUNDLE is enabled, applying the description is expected to fail + // because the demuxing criteria can not be satisfied. + auto answer = callee->CreateAnswer(options); + EXPECT_FALSE(callee->SetLocalDescription(std::move(answer))); +} + +// A variant of the above, without BUNDLE duplicate SSRCs are allowed. +TEST_P(PeerConnectionBundleTest, + ApplyDescriptionWithSameSsrcsUnbundledSucceeds) { + auto caller = CreatePeerConnectionWithAudioVideo(); + auto callee = CreatePeerConnectionWithAudioVideo(); + + RTCOfferAnswerOptions options; + options.use_rtp_mux = false; + auto offer = caller->CreateOffer(options); EXPECT_TRUE( caller->SetLocalDescription(CloneSessionDescription(offer.get()))); - // Modify the remote SDP to make two m= sections have the same SSRC. - ASSERT_GE(offer->description()->contents().size(), 2U); - offer->description() - ->contents()[0] - .media_description() - ->mutable_streams()[0] - .ssrcs[0] = 1111222; - offer->description() - ->contents()[1] - .media_description() - ->mutable_streams()[0] - .ssrcs[0] = 1111222; + // Modify the remote SDP to make two m= sections have the same SSRC. + ASSERT_GE(offer->description()->contents().size(), 2U); + offer->description() + ->contents()[0] + .media_description() + ->mutable_streams()[0] + .ssrcs[0] = 1111222; + offer->description() + ->contents()[1] + .media_description() + ->mutable_streams()[0] + .ssrcs[0] = 1111222; EXPECT_TRUE(callee->SetRemoteDescription(std::move(offer))); - // Without BUNDLE, demuxing is done per-transport. + // Without BUNDLE, demuxing is done per-transport. auto answer = callee->CreateAnswer(options); - EXPECT_TRUE(callee->SetLocalDescription(std::move(answer))); + EXPECT_TRUE(callee->SetLocalDescription(std::move(answer))); } // This tests that changing the pre-negotiated BUNDLE tag is not supported. diff --git a/pc/sdp_offer_answer.cc b/pc/sdp_offer_answer.cc index c3a56c63..3e62eabc 100644 --- a/pc/sdp_offer_answer.cc +++ b/pc/sdp_offer_answer.cc @@ -1587,7 +1587,7 @@ RTCError SdpOfferAnswerHandler::ApplyLocalDescription( if (type == SdpType::kOffer) { // TODO(bugs.webrtc.org/4676) - Handle CreateChannel failure, as new local // description is applied. Restore back to old description. - error = CreateChannels(*local_description()->description()); + error = CreateChannels(*local_description()->description()); if (!error.ok()) { RTC_LOG(LS_ERROR) << error.message() << " (" << SdpTypeToString(type) << ")"; @@ -1622,21 +1622,21 @@ RTCError SdpOfferAnswerHandler::ApplyLocalDescription( data_channel_controller()->AllocateSctpSids(role); } - // Validate SSRCs, we do not allow duplicates. - std::set used_ssrcs; - for (const auto& content : local_description()->description()->contents()) { - for (const auto& stream : content.media_description()->streams()) { - for (uint32_t ssrc : stream.ssrcs) { - auto result = used_ssrcs.insert(ssrc); - if (!result.second) { - LOG_AND_RETURN_ERROR( - RTCErrorType::INVALID_PARAMETER, - "Duplicate ssrc " + rtc::ToString(ssrc) + " is not allowed"); - } - } - } - } - + // Validate SSRCs, we do not allow duplicates. + std::set used_ssrcs; + for (const auto& content : local_description()->description()->contents()) { + for (const auto& stream : content.media_description()->streams()) { + for (uint32_t ssrc : stream.ssrcs) { + auto result = used_ssrcs.insert(ssrc); + if (!result.second) { + LOG_AND_RETURN_ERROR( + RTCErrorType::INVALID_PARAMETER, + "Duplicate ssrc " + rtc::ToString(ssrc) + " is not allowed"); + } + } + } + } + if (IsUnifiedPlan()) { // We must use List and not ListInternal here because // transceivers()->StableState() is indexed by the non-internal refptr. diff --git a/pc/sdp_offer_answer_unittest.cc b/pc/sdp_offer_answer_unittest.cc index d3469393..35bb0306 100644 --- a/pc/sdp_offer_answer_unittest.cc +++ b/pc/sdp_offer_answer_unittest.cc @@ -14,7 +14,7 @@ #include #include #include -#include "absl/strings/str_replace.h" +#include "absl/strings/str_replace.h" #include "absl/types/optional.h" #include "api/audio/audio_mixer.h" #include "api/audio_codecs/audio_decoder_factory.h" @@ -137,21 +137,21 @@ TEST_F(SdpOfferAnswerTest, OnTrackReturnsProxiedObject) { transceiver->stopped(); } -TEST_F(SdpOfferAnswerTest, DuplicateSsrcsDisallowedInLocalDescription) { - auto pc = CreatePeerConnection(); - pc->AddAudioTrack("audio_track", {}); - pc->AddVideoTrack("video_track", {}); - auto offer = pc->CreateOffer(); - auto& offer_contents = offer->description()->contents(); - ASSERT_EQ(offer_contents.size(), 2u); - uint32_t second_ssrc = offer_contents[1].media_description()->first_ssrc(); - - offer->description() - ->contents()[0] - .media_description() - ->mutable_streams()[0] - .ssrcs[0] = second_ssrc; - EXPECT_FALSE(pc->SetLocalDescription(std::move(offer))); -} - +TEST_F(SdpOfferAnswerTest, DuplicateSsrcsDisallowedInLocalDescription) { + auto pc = CreatePeerConnection(); + pc->AddAudioTrack("audio_track", {}); + pc->AddVideoTrack("video_track", {}); + auto offer = pc->CreateOffer(); + auto& offer_contents = offer->description()->contents(); + ASSERT_EQ(offer_contents.size(), 2u); + uint32_t second_ssrc = offer_contents[1].media_description()->first_ssrc(); + + offer->description() + ->contents()[0] + .media_description() + ->mutable_streams()[0] + .ssrcs[0] = second_ssrc; + EXPECT_FALSE(pc->SetLocalDescription(std::move(offer))); +} + } // namespace webrtc -- Gitee