blob: a60553fb5e873b9e70148c8948b45781324ef5b9 [file] [log] [blame]
Harald Alvestranda25c1c02024-10-31 16:35:031/*
2 * Copyright 2024 The WebRTC project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11// This file contains tests that verify that congestion control options
12// are correctly negotiated in the SDP offer/answer.
13
14#include <string>
15
16#include "absl/strings/str_cat.h"
17#include "api/peer_connection_interface.h"
18#include "pc/test/integration_test_helpers.h"
Harald Alvestrand9317a302024-11-01 13:13:5719#include "rtc_base/gunit.h"
Harald Alvestranda25c1c02024-10-31 16:35:0320#include "test/field_trial.h"
21#include "test/gmock.h"
22#include "test/gtest.h"
23
24namespace webrtc {
25
26using testing::HasSubstr;
27
28class PeerConnectionCongestionControlTest
29 : public PeerConnectionIntegrationBaseTest {
30 public:
31 PeerConnectionCongestionControlTest()
32 : PeerConnectionIntegrationBaseTest(SdpSemantics::kUnifiedPlan) {}
33};
34
35TEST_F(PeerConnectionCongestionControlTest, OfferContainsCcfbIfEnabled) {
36 test::ScopedFieldTrials trials(
37 "WebRTC-RFC8888CongestionControlFeedback/Enabled/");
38 ASSERT_TRUE(CreatePeerConnectionWrappers());
39 caller()->AddAudioVideoTracks();
40 auto offer = caller()->CreateOfferAndWait();
41 std::string offer_str = absl::StrCat(*offer);
42 EXPECT_THAT(offer_str, HasSubstr("a=rtcp-fb:* ack ccfb\r\n"));
43}
44
Harald Alvestrand9317a302024-11-01 13:13:5745TEST_F(PeerConnectionCongestionControlTest, ReceiveOfferSetsCcfbFlag) {
46 test::ScopedFieldTrials trials(
47 "WebRTC-RFC8888CongestionControlFeedback/Enabled/");
48 ASSERT_TRUE(CreatePeerConnectionWrappers());
49 ConnectFakeSignalingForSdpOnly();
50 caller()->AddAudioVideoTracks();
51 caller()->CreateAndSetAndSignalOffer();
52 ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
53 // Check that the callee parsed it.
54 auto parsed_contents =
55 callee()->pc()->remote_description()->description()->contents();
56 EXPECT_FALSE(parsed_contents.empty());
57 for (const auto& content : parsed_contents) {
58 EXPECT_TRUE(content.media_description()->rtcp_fb_ack_ccfb());
59 }
60 // Check that the caller also parsed it.
61 parsed_contents =
62 caller()->pc()->remote_description()->description()->contents();
63 EXPECT_FALSE(parsed_contents.empty());
64 for (const auto& content : parsed_contents) {
65 EXPECT_TRUE(content.media_description()->rtcp_fb_ack_ccfb());
66 }
67}
68
Harald Alvestranda25c1c02024-10-31 16:35:0369} // namespace webrtc