test: do not use SDP munging to enable corruption detection

BUG=webrtc:358039777

Change-Id: Ibe3fc1f230185b542ee6312596a31d94c3c9156e
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/370713
Reviewed-by: Erik Språng <sprang@webrtc.org>
Commit-Queue: Philipp Hancke <phancke@meta.com>
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#43561}
This commit is contained in:
Philipp Hancke 2024-12-09 16:25:42 -08:00 committed by WebRTC LUCI CQ
parent 021cf5ac3e
commit 316d93b415
2 changed files with 28 additions and 39 deletions

View File

@ -4119,15 +4119,15 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan,
ASSERT_TRUE(CreatePeerConnectionWrappersWithConfig(config, config));
ConnectFakeSignaling();
// Munge the corruption detection header extension into the SDP.
// If caller adds corruption detection header extension to its SDP offer, it
// will receive it from the callee.
caller()->AddCorruptionDetectionHeader();
// Do normal offer/answer and wait for some frames to be received in each
// direction, and `corruption_score` to be aggregated.
caller()->AddAudioVideoTracks();
callee()->AddAudioVideoTracks();
// Negotiate the corruption detection header extension in SDP.
// If caller adds corruption detection header extension to its SDP offer, it
// will receive it from the callee.
caller()->NegotiateCorruptionDetectionHeader();
caller()->CreateAndSetAndSignalOffer();
ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
ASSERT_TRUE_WAIT(caller()->GetCorruptionScoreCount() > 0, kMaxWaitForStatsMs);
@ -4174,16 +4174,18 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan,
ASSERT_TRUE(CreatePeerConnectionWrappersWithConfig(config, config));
ConnectFakeSignaling();
// Munge the corruption detection header extension into the SDP.
// If caller adds corruption detection header extension to its SDP offer, it
// will receive it from the callee.
caller()->AddCorruptionDetectionHeader();
callee()->AddCorruptionDetectionHeader();
// Do normal offer/answer and wait for some frames to be received in each
// direction, and `corruption_score` to be aggregated.
caller()->AddAudioVideoTracks();
callee()->AddAudioVideoTracks();
// Negotiate the corruption detection header extension in SDP.
// If caller adds corruption detection header extension to its SDP offer, it
// will receive it from the callee.
caller()->NegotiateCorruptionDetectionHeader();
callee()->NegotiateCorruptionDetectionHeader();
caller()->CreateAndSetAndSignalOffer();
ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
ASSERT_TRUE_WAIT(caller()->GetCorruptionScoreCount() > 0, kMaxWaitForStatsMs);
@ -4221,11 +4223,11 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan,
ASSERT_TRUE(CreatePeerConnectionWrappersWithConfig(config, config));
ConnectFakeSignaling();
// Munge the corruption detection header extension into the SDP.
// Negotiate the corruption detection header extension in SDP.
// If caller adds corruption detection header extension to its SDP offer, it
// will receive it from the callee.
caller()->AddCorruptionDetectionHeader();
callee()->AddCorruptionDetectionHeader();
caller()->NegotiateCorruptionDetectionHeader();
callee()->NegotiateCorruptionDetectionHeader();
// Do normal offer/answer and wait for some frames to be received in each
// direction, and `corruption_score` to be aggregated.

View File

@ -698,32 +698,19 @@ class PeerConnectionIntegrationWrapper : public PeerConnectionObserver,
return observer->error().ok();
}
void AddCorruptionDetectionHeader() {
SetGeneratedSdpMunger(
[&](std::unique_ptr<SessionDescriptionInterface>& sdp) {
for (ContentInfo& content : sdp->description()->contents()) {
cricket::MediaContentDescription* media =
content.media_description();
// Corruption detection is only a valid RTP header extension for
// video stream.
if (media->type() != cricket::MediaType::MEDIA_TYPE_VIDEO) {
continue;
}
cricket::RtpHeaderExtensions extensions =
media->rtp_header_extensions();
// Find a valid id.
int id = extensions.size();
while (IdExists(extensions, id)) {
++id;
}
extensions.push_back(RtpExtension(
RtpExtension::kCorruptionDetectionUri, id, /*encrypt=*/true));
media->set_rtp_header_extensions(extensions);
break;
}
});
void NegotiateCorruptionDetectionHeader() {
for (const auto& transceiver : pc()->GetTransceivers()) {
if (transceiver->media_type() != cricket::MEDIA_TYPE_VIDEO) {
continue;
}
auto extensions = transceiver->GetHeaderExtensionsToNegotiate();
for (auto& extension : extensions) {
if (extension.uri == RtpExtension::kCorruptionDetectionUri) {
extension.direction = RtpTransceiverDirection::kSendRecv;
}
}
transceiver->SetHeaderExtensionsToNegotiate(extensions);
}
}
uint32_t GetCorruptionScoreCount() {