xref: /aosp_15_r20/external/webrtc/video/end_to_end_tests/config_tests.cc (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1 /*
2  *  Copyright 2018 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 #include <map>
12 #include <vector>
13 
14 #include "api/crypto/crypto_options.h"
15 #include "api/rtp_headers.h"
16 #include "call/flexfec_receive_stream.h"
17 #include "call/rtp_config.h"
18 #include "call/video_receive_stream.h"
19 #include "call/video_send_stream.h"
20 #include "test/call_test.h"
21 #include "test/gtest.h"
22 #include "test/null_transport.h"
23 
24 namespace webrtc {
25 
26 class ConfigEndToEndTest : public test::CallTest {};
27 
28 namespace {
VerifyEmptyNackConfig(const NackConfig & config)29 void VerifyEmptyNackConfig(const NackConfig& config) {
30   EXPECT_EQ(0, config.rtp_history_ms)
31       << "Enabling NACK requires rtcp-fb: nack negotiation.";
32 }
33 
VerifyEmptyUlpfecConfig(const UlpfecConfig & config)34 void VerifyEmptyUlpfecConfig(const UlpfecConfig& config) {
35   EXPECT_EQ(-1, config.ulpfec_payload_type)
36       << "Enabling ULPFEC requires rtpmap: ulpfec negotiation.";
37   EXPECT_EQ(-1, config.red_payload_type)
38       << "Enabling ULPFEC requires rtpmap: red negotiation.";
39   EXPECT_EQ(-1, config.red_rtx_payload_type)
40       << "Enabling RTX in ULPFEC requires rtpmap: rtx negotiation.";
41 }
42 
VerifyEmptyFlexfecConfig(const RtpConfig::Flexfec & config)43 void VerifyEmptyFlexfecConfig(const RtpConfig::Flexfec& config) {
44   EXPECT_EQ(-1, config.payload_type)
45       << "Enabling FlexFEC requires rtpmap: flexfec negotiation.";
46   EXPECT_EQ(0U, config.ssrc)
47       << "Enabling FlexFEC requires ssrc-group: FEC-FR negotiation.";
48   EXPECT_TRUE(config.protected_media_ssrcs.empty())
49       << "Enabling FlexFEC requires ssrc-group: FEC-FR negotiation.";
50 }
51 }  // namespace
52 
TEST_F(ConfigEndToEndTest,VerifyDefaultSendConfigParameters)53 TEST_F(ConfigEndToEndTest, VerifyDefaultSendConfigParameters) {
54   VideoSendStream::Config default_send_config(nullptr);
55   EXPECT_FALSE(default_send_config.rtp.lntf.enabled)
56       << "Enabling LNTF require rtcp-fb: goog-lntf negotiation.";
57   EXPECT_EQ(0, default_send_config.rtp.nack.rtp_history_ms)
58       << "Enabling NACK require rtcp-fb: nack negotiation.";
59   EXPECT_TRUE(default_send_config.rtp.rtx.ssrcs.empty())
60       << "Enabling RTX requires rtpmap: rtx negotiation.";
61   EXPECT_TRUE(default_send_config.rtp.extensions.empty())
62       << "Enabling RTP extensions require negotiation.";
63   EXPECT_EQ(nullptr, default_send_config.frame_encryptor)
64       << "Enabling Frame Encryption requires a frame encryptor to be attached";
65   EXPECT_FALSE(
66       default_send_config.crypto_options.sframe.require_frame_encryption)
67       << "Enabling Require Frame Encryption means an encryptor must be "
68          "attached";
69 
70   VerifyEmptyNackConfig(default_send_config.rtp.nack);
71   VerifyEmptyUlpfecConfig(default_send_config.rtp.ulpfec);
72   VerifyEmptyFlexfecConfig(default_send_config.rtp.flexfec);
73 }
74 
TEST_F(ConfigEndToEndTest,VerifyDefaultVideoReceiveConfigParameters)75 TEST_F(ConfigEndToEndTest, VerifyDefaultVideoReceiveConfigParameters) {
76   VideoReceiveStreamInterface::Config default_receive_config(nullptr);
77   EXPECT_EQ(RtcpMode::kCompound, default_receive_config.rtp.rtcp_mode)
78       << "Reduced-size RTCP require rtcp-rsize to be negotiated.";
79   EXPECT_FALSE(default_receive_config.rtp.lntf.enabled)
80       << "Enabling LNTF require rtcp-fb: goog-lntf negotiation.";
81   EXPECT_FALSE(
82       default_receive_config.rtp.rtcp_xr.receiver_reference_time_report)
83       << "RTCP XR settings require rtcp-xr to be negotiated.";
84   EXPECT_EQ(0U, default_receive_config.rtp.rtx_ssrc)
85       << "Enabling RTX requires ssrc-group: FID negotiation";
86   EXPECT_TRUE(default_receive_config.rtp.rtx_associated_payload_types.empty())
87       << "Enabling RTX requires rtpmap: rtx negotiation.";
88   EXPECT_TRUE(default_receive_config.rtp.extensions.empty())
89       << "Enabling RTP extensions require negotiation.";
90   VerifyEmptyNackConfig(default_receive_config.rtp.nack);
91   EXPECT_EQ(-1, default_receive_config.rtp.ulpfec_payload_type)
92       << "Enabling ULPFEC requires rtpmap: ulpfec negotiation.";
93   EXPECT_EQ(-1, default_receive_config.rtp.red_payload_type)
94       << "Enabling ULPFEC requires rtpmap: red negotiation.";
95   EXPECT_EQ(nullptr, default_receive_config.frame_decryptor)
96       << "Enabling Frame Decryption requires a frame decryptor to be attached";
97   EXPECT_FALSE(
98       default_receive_config.crypto_options.sframe.require_frame_encryption)
99       << "Enabling Require Frame Encryption means a decryptor must be attached";
100 }
101 
TEST_F(ConfigEndToEndTest,VerifyDefaultFlexfecReceiveConfigParameters)102 TEST_F(ConfigEndToEndTest, VerifyDefaultFlexfecReceiveConfigParameters) {
103   test::NullTransport rtcp_send_transport;
104   FlexfecReceiveStream::Config default_receive_config(&rtcp_send_transport);
105   EXPECT_EQ(-1, default_receive_config.payload_type)
106       << "Enabling FlexFEC requires rtpmap: flexfec negotiation.";
107   EXPECT_EQ(0U, default_receive_config.rtp.remote_ssrc)
108       << "Enabling FlexFEC requires ssrc-group: FEC-FR negotiation.";
109   EXPECT_TRUE(default_receive_config.protected_media_ssrcs.empty())
110       << "Enabling FlexFEC requires ssrc-group: FEC-FR negotiation.";
111 }
112 
113 }  // namespace webrtc
114