| [email protected] | 5f93d0a | 2015-01-20 21:36:13 | [diff] [blame] | 1 | /* |
| kjellander | 65c7f67 | 2016-02-12 08:05:01 | [diff] [blame] | 2 | * Copyright 2009 The WebRTC project authors. All Rights Reserved. |
| [email protected] | 5f93d0a | 2015-01-20 21:36:13 | [diff] [blame] | 3 | * |
| kjellander | 65c7f67 | 2016-02-12 08:05:01 | [diff] [blame] | 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. |
| [email protected] | 5f93d0a | 2015-01-20 21:36:13 | [diff] [blame] | 9 | */ |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 10 | |
| Anton Sukhanov | 4f08faa | 2019-05-21 18:12:57 | [diff] [blame] | 11 | #include "pc/channel.h" |
| 12 | |
| Philipp Hancke | b2ea936 | 2025-07-18 17:47:39 | [diff] [blame] | 13 | #include <cstddef> |
| Yves Gerey | 3e70781 | 2018-11-28 15:47:49 | [diff] [blame] | 14 | #include <cstdint> |
| Philipp Hancke | 740d726 | 2024-12-09 05:26:34 | [diff] [blame] | 15 | #include <memory> |
| 16 | #include <optional> |
| Harald Alvestrand | c24a218 | 2022-02-23 13:44:59 | [diff] [blame] | 17 | #include <string> |
| Philipp Hancke | 740d726 | 2024-12-09 05:26:34 | [diff] [blame] | 18 | #include <utility> |
| 19 | #include <vector> |
| kwiberg | 3102294 | 2016-03-11 22:18:21 | [diff] [blame] | 20 | |
| Danil Chapovalov | a30439b | 2022-07-07 08:08:49 | [diff] [blame] | 21 | #include "absl/functional/any_invocable.h" |
| Mirko Bonadei | 92ea95e | 2017-09-15 04:47:31 | [diff] [blame] | 22 | #include "api/array_view.h" |
| Yves Gerey | 3e70781 | 2018-11-28 15:47:49 | [diff] [blame] | 23 | #include "api/audio_options.h" |
| Philipp Hancke | 740d726 | 2024-12-09 05:26:34 | [diff] [blame] | 24 | #include "api/crypto/crypto_options.h" |
| Danil Chapovalov | 6e65ae3 | 2025-06-10 11:06:03 | [diff] [blame] | 25 | #include "api/field_trials.h" |
| Philipp Hancke | 740d726 | 2024-12-09 05:26:34 | [diff] [blame] | 26 | #include "api/jsep.h" |
| Tomas Lundqvist | b40c559 | 2024-11-22 13:45:27 | [diff] [blame] | 27 | #include "api/rtp_headers.h" |
| Steve Anton | 10542f2 | 2019-01-11 17:11:00 | [diff] [blame] | 28 | #include "api/rtp_parameters.h" |
| Philipp Hancke | 740d726 | 2024-12-09 05:26:34 | [diff] [blame] | 29 | #include "api/rtp_transceiver_direction.h" |
| 30 | #include "api/scoped_refptr.h" |
| 31 | #include "api/sequence_checker.h" |
| Artem Titov | c374d11 | 2022-06-16 19:27:45 | [diff] [blame] | 32 | #include "api/task_queue/pending_task_safety_flag.h" |
| Yves Gerey | 3e70781 | 2018-11-28 15:47:49 | [diff] [blame] | 33 | #include "media/base/codec.h" |
| Steve Anton | 10542f2 | 2019-01-11 17:11:00 | [diff] [blame] | 34 | #include "media/base/fake_media_engine.h" |
| 35 | #include "media/base/fake_rtp.h" |
| 36 | #include "media/base/media_channel.h" |
| Harald Alvestrand | c24a218 | 2022-02-23 13:44:59 | [diff] [blame] | 37 | #include "media/base/media_constants.h" |
| 38 | #include "media/base/rid_description.h" |
| Philipp Hancke | 740d726 | 2024-12-09 05:26:34 | [diff] [blame] | 39 | #include "media/base/stream_params.h" |
| Steve Anton | 10542f2 | 2019-01-11 17:11:00 | [diff] [blame] | 40 | #include "p2p/base/candidate_pair_interface.h" |
| Steve Anton | 10542f2 | 2019-01-11 17:11:00 | [diff] [blame] | 41 | #include "p2p/base/ice_transport_internal.h" |
| 42 | #include "p2p/base/p2p_constants.h" |
| Harald Alvestrand | c24a218 | 2022-02-23 13:44:59 | [diff] [blame] | 43 | #include "p2p/base/packet_transport_internal.h" |
| Philipp Hancke | 740d726 | 2024-12-09 05:26:34 | [diff] [blame] | 44 | #include "p2p/dtls/dtls_transport_internal.h" |
| 45 | #include "p2p/dtls/fake_dtls_transport.h" |
| Jonas Oreland | b85686c | 2025-02-27 09:52:35 | [diff] [blame] | 46 | #include "p2p/test/fake_packet_transport.h" |
| Steve Anton | 10542f2 | 2019-01-11 17:11:00 | [diff] [blame] | 47 | #include "pc/dtls_srtp_transport.h" |
| Steve Anton | 10542f2 | 2019-01-11 17:11:00 | [diff] [blame] | 48 | #include "pc/rtp_transport.h" |
| Philipp Hancke | 740d726 | 2024-12-09 05:26:34 | [diff] [blame] | 49 | #include "pc/rtp_transport_internal.h" |
| 50 | #include "pc/session_description.h" |
| Harald Alvestrand | 3d09240 | 2025-05-05 13:32:53 | [diff] [blame] | 51 | #include "rtc_base/async_packet_socket.h" |
| Mirko Bonadei | 92ea95e | 2017-09-15 04:47:31 | [diff] [blame] | 52 | #include "rtc_base/buffer.h" |
| Steve Anton | 10542f2 | 2019-01-11 17:11:00 | [diff] [blame] | 53 | #include "rtc_base/byte_order.h" |
| Mirko Bonadei | 92ea95e | 2017-09-15 04:47:31 | [diff] [blame] | 54 | #include "rtc_base/checks.h" |
| Philipp Hancke | 740d726 | 2024-12-09 05:26:34 | [diff] [blame] | 55 | #include "rtc_base/network_route.h" |
| Steve Anton | 10542f2 | 2019-01-11 17:11:00 | [diff] [blame] | 56 | #include "rtc_base/rtc_certificate.h" |
| Philipp Hancke | 740d726 | 2024-12-09 05:26:34 | [diff] [blame] | 57 | #include "rtc_base/socket.h" |
| Steve Anton | 10542f2 | 2019-01-11 17:11:00 | [diff] [blame] | 58 | #include "rtc_base/ssl_identity.h" |
| Danil Chapovalov | 2aaef45 | 2022-08-12 13:55:11 | [diff] [blame] | 59 | #include "rtc_base/task_queue_for_test.h" |
| Philipp Hancke | 740d726 | 2024-12-09 05:26:34 | [diff] [blame] | 60 | #include "rtc_base/thread.h" |
| 61 | #include "rtc_base/unique_id_generator.h" |
| Danil Chapovalov | 6e65ae3 | 2025-06-10 11:06:03 | [diff] [blame] | 62 | #include "test/create_test_field_trials.h" |
| Mirta Dvornicic | 479a3c0 | 2019-06-04 13:38:50 | [diff] [blame] | 63 | #include "test/gmock.h" |
| Yves Gerey | 3e70781 | 2018-11-28 15:47:49 | [diff] [blame] | 64 | #include "test/gtest.h" |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 65 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 66 | namespace { |
| Emil Lundmark | 17304c3 | 2023-09-15 14:33:03 | [diff] [blame] | 67 | |
| Emil Lundmark | 17304c3 | 2023-09-15 14:33:03 | [diff] [blame] | 68 | using ::testing::AllOf; |
| 69 | using ::testing::ElementsAre; |
| 70 | using ::testing::Field; |
| Danil Chapovalov | 52c16dc | 2025-06-02 07:57:15 | [diff] [blame] | 71 | using ::webrtc::ArrayView; |
| Danil Chapovalov | 6e65ae3 | 2025-06-10 11:06:03 | [diff] [blame] | 72 | using ::webrtc::CreateTestFieldTrials; |
| Evan Shrubsole | e6a1f70 | 2025-04-15 14:55:42 | [diff] [blame] | 73 | using ::webrtc::DtlsTransportInternal; |
| Evan Shrubsole | 945e517 | 2025-04-08 14:11:45 | [diff] [blame] | 74 | using ::webrtc::FakeVoiceMediaReceiveChannel; |
| 75 | using ::webrtc::FakeVoiceMediaSendChannel; |
| Danil Chapovalov | 6e65ae3 | 2025-06-10 11:06:03 | [diff] [blame] | 76 | using ::webrtc::FieldTrials; |
| Evan Shrubsole | 945e517 | 2025-04-08 14:11:45 | [diff] [blame] | 77 | using ::webrtc::RidDescription; |
| 78 | using ::webrtc::RidDirection; |
| Per K | 38bb331 | 2025-08-19 13:46:24 | [diff] [blame] | 79 | using ::webrtc::RtpExtension; |
| Emil Lundmark | 17304c3 | 2023-09-15 14:33:03 | [diff] [blame] | 80 | using ::webrtc::RtpTransceiverDirection; |
| 81 | using ::webrtc::SdpType; |
| Evan Shrubsole | 945e517 | 2025-04-08 14:11:45 | [diff] [blame] | 82 | using ::webrtc::StreamParams; |
| Emil Lundmark | 17304c3 | 2023-09-15 14:33:03 | [diff] [blame] | 83 | |
| Evan Shrubsole | 0b212e3 | 2025-04-07 13:43:01 | [diff] [blame] | 84 | const webrtc::Codec kPcmuCodec = webrtc::CreateAudioCodec(0, "PCMU", 64000, 1); |
| 85 | const webrtc::Codec kPcmaCodec = webrtc::CreateAudioCodec(8, "PCMA", 64000, 1); |
| 86 | const webrtc::Codec kIsacCodec = |
| 87 | webrtc::CreateAudioCodec(103, "ISAC", 40000, 1); |
| 88 | const webrtc::Codec kH264Codec = webrtc::CreateVideoCodec(97, "H264"); |
| 89 | const webrtc::Codec kH264SvcCodec = webrtc::CreateVideoCodec(99, "H264-SVC"); |
| Philipp Hancke | 81f4e78 | 2025-07-07 18:57:09 | [diff] [blame] | 90 | constexpr uint32_t kSsrc1 = 0x1111; |
| 91 | constexpr uint32_t kSsrc2 = 0x2222; |
| 92 | constexpr uint32_t kSsrc3 = 0x3333; |
| 93 | constexpr uint32_t kSsrc4 = 0x4444; |
| 94 | constexpr int kAudioPts[] = {0, 8}; |
| 95 | constexpr int kVideoPts[] = {97, 99}; |
| 96 | constexpr char kAudioMid[] = "0"; |
| 97 | constexpr char kVideoMid[] = "1"; |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 98 | enum class NetworkIsWorker { Yes, No }; |
| Niels Möller | 0228485 | 2018-01-17 09:22:47 | [diff] [blame] | 99 | |
| deadbeef | cbecd35 | 2015-09-23 18:50:27 | [diff] [blame] | 100 | template <class ChannelT, |
| Harald Alvestrand | 50454ef | 2022-12-15 16:49:13 | [diff] [blame] | 101 | class MediaSendChannelT, |
| 102 | class MediaReceiveChannelT, |
| Florent Castelli | 1f31c20 | 2023-06-26 00:26:07 | [diff] [blame] | 103 | class MediaSendChannelInterfaceT, |
| 104 | class MediaReceiveChannelInterfaceT, |
| deadbeef | cbecd35 | 2015-09-23 18:50:27 | [diff] [blame] | 105 | class ContentT, |
| deadbeef | cbecd35 | 2015-09-23 18:50:27 | [diff] [blame] | 106 | class MediaInfoT, |
| 107 | class OptionsT> |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 108 | class Traits { |
| 109 | public: |
| Harald Alvestrand | 3d09240 | 2025-05-05 13:32:53 | [diff] [blame] | 110 | using Channel = ChannelT; |
| 111 | using MediaSendChannel = MediaSendChannelT; |
| 112 | using MediaReceiveChannel = MediaReceiveChannelT; |
| 113 | using MediaSendChannelInterface = MediaSendChannelInterfaceT; |
| 114 | using MediaReceiveChannelInterface = MediaReceiveChannelInterfaceT; |
| 115 | using Content = ContentT; |
| 116 | using MediaInfo = MediaInfoT; |
| 117 | using Options = OptionsT; |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 118 | }; |
| 119 | |
| Evan Shrubsole | 3c825f1 | 2025-04-04 14:07:27 | [diff] [blame] | 120 | class VoiceTraits : public Traits<webrtc::VoiceChannel, |
| Evan Shrubsole | 945e517 | 2025-04-08 14:11:45 | [diff] [blame] | 121 | webrtc::FakeVoiceMediaSendChannel, |
| 122 | webrtc::FakeVoiceMediaReceiveChannel, |
| 123 | webrtc::VoiceMediaSendChannelInterface, |
| 124 | webrtc::VoiceMediaReceiveChannelInterface, |
| Evan Shrubsole | 080cdac | 2025-03-20 09:34:48 | [diff] [blame] | 125 | webrtc::AudioContentDescription, |
| Evan Shrubsole | 945e517 | 2025-04-08 14:11:45 | [diff] [blame] | 126 | webrtc::VoiceMediaInfo, |
| 127 | webrtc::AudioOptions> {}; |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 128 | |
| Evan Shrubsole | 3c825f1 | 2025-04-04 14:07:27 | [diff] [blame] | 129 | class VideoTraits : public Traits<webrtc::VideoChannel, |
| Evan Shrubsole | 945e517 | 2025-04-08 14:11:45 | [diff] [blame] | 130 | webrtc::FakeVideoMediaSendChannel, |
| 131 | webrtc::FakeVideoMediaReceiveChannel, |
| 132 | webrtc::VideoMediaSendChannelInterface, |
| 133 | webrtc::VideoMediaReceiveChannelInterface, |
| Evan Shrubsole | 080cdac | 2025-03-20 09:34:48 | [diff] [blame] | 134 | webrtc::VideoContentDescription, |
| Evan Shrubsole | 945e517 | 2025-04-08 14:11:45 | [diff] [blame] | 135 | webrtc::VideoMediaInfo, |
| 136 | webrtc::VideoOptions> {}; |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 137 | |
| Harald Alvestrand | 48171ec | 2021-04-20 15:06:03 | [diff] [blame] | 138 | // Base class for Voice/Video tests |
| Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 139 | template <class T> |
| Philipp Hancke | d22c6e6 | 2025-08-04 23:15:30 | [diff] [blame] | 140 | class ChannelTest : public ::testing::Test { |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 141 | public: |
| deadbeef | ac22f70 | 2017-01-13 05:59:29 | [diff] [blame] | 142 | enum Flags { |
| 143 | RTCP_MUX = 0x1, |
| deadbeef | ac22f70 | 2017-01-13 05:59:29 | [diff] [blame] | 144 | SSRC_MUX = 0x8, |
| 145 | DTLS = 0x10, |
| deadbeef | 5bd5ca3 | 2017-02-10 19:31:50 | [diff] [blame] | 146 | // Use BaseChannel with PacketTransportInternal rather than |
| deadbeef | f534659 | 2017-01-25 05:51:21 | [diff] [blame] | 147 | // DtlsTransportInternal. |
| deadbeef | 7914b8c | 2017-04-21 10:23:33 | [diff] [blame] | 148 | RAW_PACKET_TRANSPORT = 0x20, |
| deadbeef | ac22f70 | 2017-01-13 05:59:29 | [diff] [blame] | 149 | }; |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 150 | |
| Peter Boström | 34fbfff | 2015-09-24 17:20:30 | [diff] [blame] | 151 | ChannelTest(bool verify_playout, |
| Evan Shrubsole | e6a1f70 | 2025-04-15 14:55:42 | [diff] [blame] | 152 | webrtc::ArrayView<const uint8_t> rtp_data, |
| 153 | webrtc::ArrayView<const uint8_t> rtcp_data, |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 154 | NetworkIsWorker network_is_worker) |
| Peter Boström | 34fbfff | 2015-09-24 17:20:30 | [diff] [blame] | 155 | : verify_playout_(verify_playout), |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 156 | rtp_packet_(rtp_data.data(), rtp_data.size()), |
| deadbeef | f534659 | 2017-01-25 05:51:21 | [diff] [blame] | 157 | rtcp_packet_(rtcp_data.data(), rtcp_data.size()) { |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 158 | if (network_is_worker == NetworkIsWorker::Yes) { |
| Evan Shrubsole | 6a9a1ae | 2025-03-21 12:54:15 | [diff] [blame] | 159 | network_thread_ = webrtc::Thread::Current(); |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 160 | } else { |
| Evan Shrubsole | 6a9a1ae | 2025-03-21 12:54:15 | [diff] [blame] | 161 | network_thread_keeper_ = webrtc::Thread::Create(); |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 162 | network_thread_keeper_->SetName("Network", nullptr); |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 163 | network_thread_ = network_thread_keeper_.get(); |
| 164 | } |
| Tommi | c9625f0 | 2021-05-06 20:03:19 | [diff] [blame] | 165 | RTC_DCHECK(network_thread_); |
| 166 | } |
| 167 | |
| Philipp Hancke | c6d7e6c | 2025-06-13 17:28:17 | [diff] [blame] | 168 | ~ChannelTest() override { |
| Tommi | c9625f0 | 2021-05-06 20:03:19 | [diff] [blame] | 169 | if (network_thread_) { |
| Danil Chapovalov | 2aaef45 | 2022-08-12 13:55:11 | [diff] [blame] | 170 | SendTask(network_thread_, [this]() { |
| Tomas Gunnarsson | 1933d3b | 2022-01-17 10:25:21 | [diff] [blame] | 171 | network_thread_safety_->SetNotAlive(); |
| 172 | DeinitChannels(); |
| Per K | f4aadf3 | 2024-02-27 08:01:15 | [diff] [blame] | 173 | |
| 174 | // Transports must be created and destroyed on the network thread. |
| 175 | fake_rtp_dtls_transport1_ = nullptr; |
| 176 | fake_rtcp_dtls_transport1_ = nullptr; |
| 177 | fake_rtp_dtls_transport2_ = nullptr; |
| 178 | fake_rtcp_dtls_transport2_ = nullptr; |
| 179 | fake_rtp_packet_transport1_ = nullptr; |
| 180 | fake_rtcp_packet_transport1_ = nullptr; |
| 181 | fake_rtp_packet_transport2_ = nullptr; |
| 182 | fake_rtcp_packet_transport2_ = nullptr; |
| 183 | rtp_transport1_ = nullptr; |
| 184 | rtp_transport2_ = nullptr; |
| 185 | new_rtp_transport_ = nullptr; |
| Tomas Gunnarsson | 1933d3b | 2022-01-17 10:25:21 | [diff] [blame] | 186 | }); |
| Tommi | c9625f0 | 2021-05-06 20:03:19 | [diff] [blame] | 187 | } |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 188 | } |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 189 | |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 190 | void CreateChannels(int flags1, int flags2) { |
| Florent Castelli | 1f31c20 | 2023-06-26 00:26:07 | [diff] [blame] | 191 | CreateChannels(std::make_unique<typename T::MediaSendChannel>( |
| Harald Alvestrand | 16579cc | 2023-02-09 13:01:24 | [diff] [blame] | 192 | typename T::Options(), network_thread_), |
| Florent Castelli | 1f31c20 | 2023-06-26 00:26:07 | [diff] [blame] | 193 | std::make_unique<typename T::MediaReceiveChannel>( |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 194 | typename T::Options(), network_thread_), |
| Florent Castelli | 1f31c20 | 2023-06-26 00:26:07 | [diff] [blame] | 195 | std::make_unique<typename T::MediaSendChannel>( |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 196 | typename T::Options(), network_thread_), |
| Florent Castelli | 1f31c20 | 2023-06-26 00:26:07 | [diff] [blame] | 197 | std::make_unique<typename T::MediaReceiveChannel>( |
| Harald Alvestrand | 16579cc | 2023-02-09 13:01:24 | [diff] [blame] | 198 | typename T::Options(), network_thread_), |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 199 | flags1, flags2); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 200 | } |
| Florent Castelli | 1f31c20 | 2023-06-26 00:26:07 | [diff] [blame] | 201 | void CreateChannels(std::unique_ptr<typename T::MediaSendChannel> ch1s, |
| 202 | std::unique_ptr<typename T::MediaReceiveChannel> ch1r, |
| 203 | std::unique_ptr<typename T::MediaSendChannel> ch2s, |
| 204 | std::unique_ptr<typename T::MediaReceiveChannel> ch2r, |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 205 | int flags1, |
| 206 | int flags2) { |
| Tommi | c9625f0 | 2021-05-06 20:03:19 | [diff] [blame] | 207 | RTC_DCHECK(!channel1_); |
| 208 | RTC_DCHECK(!channel2_); |
| 209 | |
| deadbeef | f534659 | 2017-01-25 05:51:21 | [diff] [blame] | 210 | // Network thread is started in CreateChannels, to allow the test to |
| 211 | // configure a fake clock before any threads are spawned and attempt to |
| 212 | // access the time. |
| 213 | if (network_thread_keeper_) { |
| 214 | network_thread_keeper_->Start(); |
| 215 | } |
| Zhi Huang | e830e68 | 2018-03-30 17:48:35 | [diff] [blame] | 216 | |
| deadbeef | f534659 | 2017-01-25 05:51:21 | [diff] [blame] | 217 | // Make sure if using raw packet transports, they're used for both |
| 218 | // channels. |
| 219 | RTC_DCHECK_EQ(flags1 & RAW_PACKET_TRANSPORT, flags2 & RAW_PACKET_TRANSPORT); |
| Evan Shrubsole | 6a9a1ae | 2025-03-21 12:54:15 | [diff] [blame] | 220 | webrtc::Thread* worker_thread = webrtc::Thread::Current(); |
| Per K | f4aadf3 | 2024-02-27 08:01:15 | [diff] [blame] | 221 | |
| 222 | network_thread_->BlockingCall([&] { |
| 223 | // Based on flags, create fake DTLS or raw packet transports. |
| 224 | |
| 225 | if (flags1 & RAW_PACKET_TRANSPORT) { |
| 226 | fake_rtp_packet_transport1_.reset( |
| Evan Shrubsole | c13956e | 2025-03-13 12:45:54 | [diff] [blame] | 227 | new webrtc::FakePacketTransport("channel1_rtp")); |
| Per K | f4aadf3 | 2024-02-27 08:01:15 | [diff] [blame] | 228 | if (!(flags1 & RTCP_MUX)) { |
| 229 | fake_rtcp_packet_transport1_.reset( |
| Evan Shrubsole | c13956e | 2025-03-13 12:45:54 | [diff] [blame] | 230 | new webrtc::FakePacketTransport("channel1_rtcp")); |
| Per K | f4aadf3 | 2024-02-27 08:01:15 | [diff] [blame] | 231 | } |
| 232 | } else { |
| 233 | // Confirmed to work with KT_RSA and KT_ECDSA. |
| Evan Shrubsole | e4b09d7 | 2025-03-17 13:25:49 | [diff] [blame] | 234 | fake_rtp_dtls_transport1_.reset(new webrtc::FakeDtlsTransport( |
| Evan Shrubsole | 945e517 | 2025-04-08 14:11:45 | [diff] [blame] | 235 | "channel1", webrtc::ICE_CANDIDATE_COMPONENT_RTP, network_thread_)); |
| Per K | f4aadf3 | 2024-02-27 08:01:15 | [diff] [blame] | 236 | if (!(flags1 & RTCP_MUX)) { |
| Evan Shrubsole | e4b09d7 | 2025-03-17 13:25:49 | [diff] [blame] | 237 | fake_rtcp_dtls_transport1_.reset(new webrtc::FakeDtlsTransport( |
| Evan Shrubsole | 945e517 | 2025-04-08 14:11:45 | [diff] [blame] | 238 | "channel1", webrtc::ICE_CANDIDATE_COMPONENT_RTCP, |
| Per K | f4aadf3 | 2024-02-27 08:01:15 | [diff] [blame] | 239 | network_thread_)); |
| 240 | } |
| 241 | if (flags1 & DTLS) { |
| Evan Shrubsole | 8990f2a | 2025-03-13 10:01:12 | [diff] [blame] | 242 | auto cert1 = webrtc::RTCCertificate::Create( |
| Evan Shrubsole | 8f7678f | 2025-04-01 14:23:55 | [diff] [blame] | 243 | webrtc::SSLIdentity::Create("session1", webrtc::KT_DEFAULT)); |
| Per K | f4aadf3 | 2024-02-27 08:01:15 | [diff] [blame] | 244 | fake_rtp_dtls_transport1_->SetLocalCertificate(cert1); |
| 245 | if (fake_rtcp_dtls_transport1_) { |
| 246 | fake_rtcp_dtls_transport1_->SetLocalCertificate(cert1); |
| 247 | } |
| deadbeef | f534659 | 2017-01-25 05:51:21 | [diff] [blame] | 248 | } |
| 249 | } |
| Per K | f4aadf3 | 2024-02-27 08:01:15 | [diff] [blame] | 250 | // Based on flags, create fake DTLS or raw packet transports. |
| 251 | if (flags2 & RAW_PACKET_TRANSPORT) { |
| 252 | fake_rtp_packet_transport2_.reset( |
| Evan Shrubsole | c13956e | 2025-03-13 12:45:54 | [diff] [blame] | 253 | new webrtc::FakePacketTransport("channel2_rtp")); |
| Per K | f4aadf3 | 2024-02-27 08:01:15 | [diff] [blame] | 254 | if (!(flags2 & RTCP_MUX)) { |
| 255 | fake_rtcp_packet_transport2_.reset( |
| Evan Shrubsole | c13956e | 2025-03-13 12:45:54 | [diff] [blame] | 256 | new webrtc::FakePacketTransport("channel2_rtcp")); |
| Per K | f4aadf3 | 2024-02-27 08:01:15 | [diff] [blame] | 257 | } |
| 258 | } else { |
| 259 | // Confirmed to work with KT_RSA and KT_ECDSA. |
| Evan Shrubsole | e4b09d7 | 2025-03-17 13:25:49 | [diff] [blame] | 260 | fake_rtp_dtls_transport2_.reset(new webrtc::FakeDtlsTransport( |
| Evan Shrubsole | 945e517 | 2025-04-08 14:11:45 | [diff] [blame] | 261 | "channel2", webrtc::ICE_CANDIDATE_COMPONENT_RTP, network_thread_)); |
| Per K | f4aadf3 | 2024-02-27 08:01:15 | [diff] [blame] | 262 | if (!(flags2 & RTCP_MUX)) { |
| Evan Shrubsole | e4b09d7 | 2025-03-17 13:25:49 | [diff] [blame] | 263 | fake_rtcp_dtls_transport2_.reset(new webrtc::FakeDtlsTransport( |
| Evan Shrubsole | 945e517 | 2025-04-08 14:11:45 | [diff] [blame] | 264 | "channel2", webrtc::ICE_CANDIDATE_COMPONENT_RTCP, |
| Per K | f4aadf3 | 2024-02-27 08:01:15 | [diff] [blame] | 265 | network_thread_)); |
| 266 | } |
| 267 | if (flags2 & DTLS) { |
| Evan Shrubsole | 8990f2a | 2025-03-13 10:01:12 | [diff] [blame] | 268 | auto cert2 = webrtc::RTCCertificate::Create( |
| Evan Shrubsole | 8f7678f | 2025-04-01 14:23:55 | [diff] [blame] | 269 | webrtc::SSLIdentity::Create("session2", webrtc::KT_DEFAULT)); |
| Per K | f4aadf3 | 2024-02-27 08:01:15 | [diff] [blame] | 270 | fake_rtp_dtls_transport2_->SetLocalCertificate(cert2); |
| 271 | if (fake_rtcp_dtls_transport2_) { |
| 272 | fake_rtcp_dtls_transport2_->SetLocalCertificate(cert2); |
| 273 | } |
| deadbeef | f534659 | 2017-01-25 05:51:21 | [diff] [blame] | 274 | } |
| 275 | } |
| Per K | f4aadf3 | 2024-02-27 08:01:15 | [diff] [blame] | 276 | rtp_transport1_ = CreateRtpTransportBasedOnFlags( |
| 277 | fake_rtp_packet_transport1_.get(), fake_rtcp_packet_transport1_.get(), |
| 278 | fake_rtp_dtls_transport1_.get(), fake_rtcp_dtls_transport1_.get(), |
| 279 | flags1); |
| 280 | rtp_transport2_ = CreateRtpTransportBasedOnFlags( |
| 281 | fake_rtp_packet_transport2_.get(), fake_rtcp_packet_transport2_.get(), |
| 282 | fake_rtp_dtls_transport2_.get(), fake_rtcp_dtls_transport2_.get(), |
| 283 | flags2); |
| 284 | }); |
| Zhi Huang | e830e68 | 2018-03-30 17:48:35 | [diff] [blame] | 285 | |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 286 | channel1_ = CreateChannel(worker_thread, network_thread_, std::move(ch1s), |
| 287 | std::move(ch1r), rtp_transport1_.get(), flags1); |
| 288 | channel2_ = CreateChannel(worker_thread, network_thread_, std::move(ch2s), |
| 289 | std::move(ch2r), rtp_transport2_.get(), flags2); |
| Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 290 | CreateContent(flags1, kPcmuCodec, kH264Codec, &local_media_content1_); |
| 291 | CreateContent(flags2, kPcmuCodec, kH264Codec, &local_media_content2_); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 292 | CopyContent(local_media_content1_, &remote_media_content1_); |
| 293 | CopyContent(local_media_content2_, &remote_media_content2_); |
| 294 | |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 295 | // Add stream information (SSRC) to the local content but not to the remote |
| 296 | // content. This means that we per default know the SSRC of what we send but |
| 297 | // not what we receive. |
| 298 | AddLegacyStreamInContent(kSsrc1, flags1, &local_media_content1_); |
| 299 | AddLegacyStreamInContent(kSsrc2, flags2, &local_media_content2_); |
| 300 | |
| 301 | // If SSRC_MUX is used we also need to know the SSRC of the incoming stream. |
| 302 | if (flags1 & SSRC_MUX) { |
| 303 | AddLegacyStreamInContent(kSsrc1, flags1, &remote_media_content1_); |
| 304 | } |
| 305 | if (flags2 & SSRC_MUX) { |
| 306 | AddLegacyStreamInContent(kSsrc2, flags2, &remote_media_content2_); |
| 307 | } |
| 308 | } |
| Steve Anton | 8699a32 | 2017-11-06 23:53:33 | [diff] [blame] | 309 | std::unique_ptr<typename T::Channel> CreateChannel( |
| Evan Shrubsole | 6a9a1ae | 2025-03-21 12:54:15 | [diff] [blame] | 310 | webrtc::Thread* worker_thread, |
| 311 | webrtc::Thread* network_thread, |
| Florent Castelli | 1f31c20 | 2023-06-26 00:26:07 | [diff] [blame] | 312 | std::unique_ptr<typename T::MediaSendChannel> ch_send, |
| 313 | std::unique_ptr<typename T::MediaReceiveChannel> ch_receive, |
| Zhi Huang | e830e68 | 2018-03-30 17:48:35 | [diff] [blame] | 314 | webrtc::RtpTransportInternal* rtp_transport, |
| Sebastian Jansson | 1b83a9e | 2019-09-18 16:22:12 | [diff] [blame] | 315 | int flags); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 316 | |
| Zhi Huang | e830e68 | 2018-03-30 17:48:35 | [diff] [blame] | 317 | std::unique_ptr<webrtc::RtpTransportInternal> CreateRtpTransportBasedOnFlags( |
| Evan Shrubsole | 8f7678f | 2025-04-01 14:23:55 | [diff] [blame] | 318 | webrtc::PacketTransportInternal* rtp_packet_transport, |
| 319 | webrtc::PacketTransportInternal* rtcp_packet_transport, |
| Zhi Huang | e830e68 | 2018-03-30 17:48:35 | [diff] [blame] | 320 | DtlsTransportInternal* rtp_dtls_transport, |
| 321 | DtlsTransportInternal* rtcp_dtls_transport, |
| 322 | int flags) { |
| 323 | if (flags & RTCP_MUX) { |
| 324 | rtcp_packet_transport = nullptr; |
| 325 | rtcp_dtls_transport = nullptr; |
| 326 | } |
| 327 | |
| 328 | if (flags & DTLS) { |
| 329 | return CreateDtlsSrtpTransport(rtp_dtls_transport, rtcp_dtls_transport); |
| 330 | } else { |
| 331 | if (flags & RAW_PACKET_TRANSPORT) { |
| 332 | return CreateUnencryptedTransport(rtp_packet_transport, |
| 333 | rtcp_packet_transport); |
| 334 | } else { |
| 335 | return CreateUnencryptedTransport(rtp_dtls_transport, |
| 336 | rtcp_dtls_transport); |
| 337 | } |
| 338 | } |
| 339 | } |
| 340 | |
| Tomas Gunnarsson | 1933d3b | 2022-01-17 10:25:21 | [diff] [blame] | 341 | // Unininitializes the channels on the network thread. |
| 342 | void DeinitChannels() { |
| 343 | if (!channel1_ && !channel2_) |
| 344 | return; |
| Danil Chapovalov | 2aaef45 | 2022-08-12 13:55:11 | [diff] [blame] | 345 | SendTask(network_thread_, [this]() { |
| Tomas Gunnarsson | 1933d3b | 2022-01-17 10:25:21 | [diff] [blame] | 346 | if (channel1_) { |
| 347 | RTC_DCHECK_RUN_ON(channel1_->network_thread()); |
| Tomas Gunnarsson | 4f8a58c | 2022-01-19 10:36:23 | [diff] [blame] | 348 | channel1_->SetRtpTransport(nullptr); |
| Tomas Gunnarsson | 1933d3b | 2022-01-17 10:25:21 | [diff] [blame] | 349 | } |
| 350 | if (channel2_) { |
| 351 | RTC_DCHECK_RUN_ON(channel2_->network_thread()); |
| Tomas Gunnarsson | 4f8a58c | 2022-01-19 10:36:23 | [diff] [blame] | 352 | channel2_->SetRtpTransport(nullptr); |
| Tomas Gunnarsson | 1933d3b | 2022-01-17 10:25:21 | [diff] [blame] | 353 | } |
| 354 | }); |
| 355 | } |
| 356 | |
| Zhi Huang | e830e68 | 2018-03-30 17:48:35 | [diff] [blame] | 357 | std::unique_ptr<webrtc::RtpTransport> CreateUnencryptedTransport( |
| Evan Shrubsole | 8f7678f | 2025-04-01 14:23:55 | [diff] [blame] | 358 | webrtc::PacketTransportInternal* rtp_packet_transport, |
| 359 | webrtc::PacketTransportInternal* rtcp_packet_transport) { |
| Mirko Bonadei | 317a1f0 | 2019-09-17 15:06:18 | [diff] [blame] | 360 | auto rtp_transport = std::make_unique<webrtc::RtpTransport>( |
| Per K | b60f0ff | 2024-08-22 08:54:32 | [diff] [blame] | 361 | rtcp_packet_transport == nullptr, field_trials_); |
| Zhi Huang | e830e68 | 2018-03-30 17:48:35 | [diff] [blame] | 362 | |
| Danil Chapovalov | 2aaef45 | 2022-08-12 13:55:11 | [diff] [blame] | 363 | SendTask(network_thread_, |
| 364 | [&rtp_transport, rtp_packet_transport, rtcp_packet_transport] { |
| 365 | rtp_transport->SetRtpPacketTransport(rtp_packet_transport); |
| 366 | if (rtcp_packet_transport) { |
| 367 | rtp_transport->SetRtcpPacketTransport(rtcp_packet_transport); |
| 368 | } |
| 369 | }); |
| Zhi Huang | e830e68 | 2018-03-30 17:48:35 | [diff] [blame] | 370 | return rtp_transport; |
| 371 | } |
| 372 | |
| 373 | std::unique_ptr<webrtc::DtlsSrtpTransport> CreateDtlsSrtpTransport( |
| Evan Shrubsole | 945e517 | 2025-04-08 14:11:45 | [diff] [blame] | 374 | webrtc::DtlsTransportInternal* rtp_dtls_transport, |
| 375 | webrtc::DtlsTransportInternal* rtcp_dtls_transport) { |
| Mirko Bonadei | 317a1f0 | 2019-09-17 15:06:18 | [diff] [blame] | 376 | auto dtls_srtp_transport = std::make_unique<webrtc::DtlsSrtpTransport>( |
| Jonas Oreland | ed99dae | 2022-03-09 08:28:10 | [diff] [blame] | 377 | rtcp_dtls_transport == nullptr, field_trials_); |
| Zhi Huang | e830e68 | 2018-03-30 17:48:35 | [diff] [blame] | 378 | |
| Danil Chapovalov | 2aaef45 | 2022-08-12 13:55:11 | [diff] [blame] | 379 | SendTask(network_thread_, |
| 380 | [&dtls_srtp_transport, rtp_dtls_transport, rtcp_dtls_transport] { |
| 381 | dtls_srtp_transport->SetDtlsTransports(rtp_dtls_transport, |
| 382 | rtcp_dtls_transport); |
| 383 | }); |
| Zhi Huang | e830e68 | 2018-03-30 17:48:35 | [diff] [blame] | 384 | return dtls_srtp_transport; |
| 385 | } |
| 386 | |
| deadbeef | f534659 | 2017-01-25 05:51:21 | [diff] [blame] | 387 | void ConnectFakeTransports() { |
| Danil Chapovalov | 2aaef45 | 2022-08-12 13:55:11 | [diff] [blame] | 388 | SendTask(network_thread_, [this] { |
| deadbeef | f534659 | 2017-01-25 05:51:21 | [diff] [blame] | 389 | bool asymmetric = false; |
| 390 | // Depending on test flags, could be using DTLS or raw packet transport. |
| 391 | if (fake_rtp_dtls_transport1_ && fake_rtp_dtls_transport2_) { |
| 392 | fake_rtp_dtls_transport1_->SetDestination( |
| 393 | fake_rtp_dtls_transport2_.get(), asymmetric); |
| 394 | } |
| 395 | if (fake_rtcp_dtls_transport1_ && fake_rtcp_dtls_transport2_) { |
| 396 | fake_rtcp_dtls_transport1_->SetDestination( |
| 397 | fake_rtcp_dtls_transport2_.get(), asymmetric); |
| 398 | } |
| 399 | if (fake_rtp_packet_transport1_ && fake_rtp_packet_transport2_) { |
| 400 | fake_rtp_packet_transport1_->SetDestination( |
| 401 | fake_rtp_packet_transport2_.get(), asymmetric); |
| 402 | } |
| 403 | if (fake_rtcp_packet_transport1_ && fake_rtcp_packet_transport2_) { |
| 404 | fake_rtcp_packet_transport1_->SetDestination( |
| 405 | fake_rtcp_packet_transport2_.get(), asymmetric); |
| 406 | } |
| 407 | }); |
| Taylor Brandstetter | 2ab9b28 | 2021-02-01 22:39:07 | [diff] [blame] | 408 | // The transport becoming writable will asynchronously update the send state |
| 409 | // on the worker thread; since this test uses the main thread as the worker |
| 410 | // thread, we must process the message queue for this to occur. |
| 411 | WaitForThreads(); |
| deadbeef | f534659 | 2017-01-25 05:51:21 | [diff] [blame] | 412 | } |
| 413 | |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 414 | bool SendInitiate() { |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 415 | std::string err; |
| [email protected] | 4b26e2e | 2014-01-15 23:15:54 | [diff] [blame] | 416 | bool result = channel1_->SetLocalContent(&local_media_content1_, |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 417 | SdpType::kOffer, err); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 418 | if (result) { |
| 419 | channel1_->Enable(true); |
| Tommi | 1959f8f | 2021-04-26 08:20:19 | [diff] [blame] | 420 | FlushCurrentThread(); |
| [email protected] | 4b26e2e | 2014-01-15 23:15:54 | [diff] [blame] | 421 | result = channel2_->SetRemoteContent(&remote_media_content1_, |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 422 | SdpType::kOffer, err); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 423 | if (result) { |
| deadbeef | f534659 | 2017-01-25 05:51:21 | [diff] [blame] | 424 | ConnectFakeTransports(); |
| [email protected] | 4b26e2e | 2014-01-15 23:15:54 | [diff] [blame] | 425 | result = channel2_->SetLocalContent(&local_media_content2_, |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 426 | SdpType::kAnswer, err); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 427 | } |
| 428 | } |
| 429 | return result; |
| 430 | } |
| 431 | |
| 432 | bool SendAccept() { |
| 433 | channel2_->Enable(true); |
| Tommi | 1959f8f | 2021-04-26 08:20:19 | [diff] [blame] | 434 | FlushCurrentThread(); |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 435 | std::string err; |
| [email protected] | 4b26e2e | 2014-01-15 23:15:54 | [diff] [blame] | 436 | return channel1_->SetRemoteContent(&remote_media_content2_, |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 437 | SdpType::kAnswer, err); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 438 | } |
| 439 | |
| 440 | bool SendOffer() { |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 441 | std::string err; |
| [email protected] | 4b26e2e | 2014-01-15 23:15:54 | [diff] [blame] | 442 | bool result = channel1_->SetLocalContent(&local_media_content1_, |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 443 | SdpType::kOffer, err); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 444 | if (result) { |
| 445 | channel1_->Enable(true); |
| [email protected] | 4b26e2e | 2014-01-15 23:15:54 | [diff] [blame] | 446 | result = channel2_->SetRemoteContent(&remote_media_content1_, |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 447 | SdpType::kOffer, err); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 448 | } |
| 449 | return result; |
| 450 | } |
| 451 | |
| 452 | bool SendProvisionalAnswer() { |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 453 | std::string err; |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 454 | bool result = channel2_->SetLocalContent(&local_media_content2_, |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 455 | SdpType::kPrAnswer, err); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 456 | if (result) { |
| 457 | channel2_->Enable(true); |
| 458 | result = channel1_->SetRemoteContent(&remote_media_content2_, |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 459 | SdpType::kPrAnswer, err); |
| deadbeef | f534659 | 2017-01-25 05:51:21 | [diff] [blame] | 460 | ConnectFakeTransports(); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 461 | } |
| 462 | return result; |
| 463 | } |
| 464 | |
| 465 | bool SendFinalAnswer() { |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 466 | std::string err; |
| [email protected] | 4b26e2e | 2014-01-15 23:15:54 | [diff] [blame] | 467 | bool result = channel2_->SetLocalContent(&local_media_content2_, |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 468 | SdpType::kAnswer, err); |
| 469 | if (result) { |
| [email protected] | 4b26e2e | 2014-01-15 23:15:54 | [diff] [blame] | 470 | result = channel1_->SetRemoteContent(&remote_media_content2_, |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 471 | SdpType::kAnswer, err); |
| 472 | } |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 473 | return result; |
| 474 | } |
| 475 | |
| Evan Shrubsole | e6a1f70 | 2025-04-15 14:55:42 | [diff] [blame] | 476 | void SendRtp(typename T::MediaSendChannel* media_channel, |
| 477 | webrtc::Buffer data) { |
| Danil Chapovalov | a30439b | 2022-07-07 08:08:49 | [diff] [blame] | 478 | network_thread_->PostTask(webrtc::SafeTask( |
| Tommi | c9625f0 | 2021-05-06 20:03:19 | [diff] [blame] | 479 | network_thread_safety_, [media_channel, data = std::move(data)]() { |
| Florent Castelli | 1f31c20 | 2023-06-26 00:26:07 | [diff] [blame] | 480 | media_channel->SendPacket(data.data(), data.size(), |
| Evan Shrubsole | e6a1f70 | 2025-04-15 14:55:42 | [diff] [blame] | 481 | webrtc::AsyncSocketPacketOptions()); |
| Tommi | c9625f0 | 2021-05-06 20:03:19 | [diff] [blame] | 482 | })); |
| 483 | } |
| 484 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 485 | void SendRtp1() { |
| Evan Shrubsole | e6a1f70 | 2025-04-15 14:55:42 | [diff] [blame] | 486 | SendRtp1(webrtc::Buffer(rtp_packet_.data(), rtp_packet_.size())); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 487 | } |
| Tommi | c9625f0 | 2021-05-06 20:03:19 | [diff] [blame] | 488 | |
| Evan Shrubsole | e6a1f70 | 2025-04-15 14:55:42 | [diff] [blame] | 489 | void SendRtp1(webrtc::Buffer data) { |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 490 | SendRtp(media_send_channel1_impl(), std::move(data)); |
| Tommi | c9625f0 | 2021-05-06 20:03:19 | [diff] [blame] | 491 | } |
| 492 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 493 | void SendRtp2() { |
| Evan Shrubsole | e6a1f70 | 2025-04-15 14:55:42 | [diff] [blame] | 494 | SendRtp2(webrtc::Buffer(rtp_packet_.data(), rtp_packet_.size())); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 495 | } |
| Tommi | c9625f0 | 2021-05-06 20:03:19 | [diff] [blame] | 496 | |
| Evan Shrubsole | e6a1f70 | 2025-04-15 14:55:42 | [diff] [blame] | 497 | void SendRtp2(webrtc::Buffer data) { |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 498 | SendRtp(media_send_channel2_impl(), std::move(data)); |
| Tommi | c9625f0 | 2021-05-06 20:03:19 | [diff] [blame] | 499 | } |
| 500 | |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 501 | // Methods to send custom data. |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 502 | void SendCustomRtp1(uint32_t ssrc, int sequence_number, int pl_type = -1) { |
| Tommi | c9625f0 | 2021-05-06 20:03:19 | [diff] [blame] | 503 | SendRtp1(CreateRtpData(ssrc, sequence_number, pl_type)); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 504 | } |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 505 | void SendCustomRtp2(uint32_t ssrc, int sequence_number, int pl_type = -1) { |
| Tommi | c9625f0 | 2021-05-06 20:03:19 | [diff] [blame] | 506 | SendRtp2(CreateRtpData(ssrc, sequence_number, pl_type)); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 507 | } |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 508 | |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 509 | bool CheckRtp1() { |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 510 | return media_receive_channel1_impl()->CheckRtp(rtp_packet_.data(), |
| 511 | rtp_packet_.size()); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 512 | } |
| 513 | bool CheckRtp2() { |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 514 | return media_receive_channel2_impl()->CheckRtp(rtp_packet_.data(), |
| 515 | rtp_packet_.size()); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 516 | } |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 517 | // Methods to check custom data. |
| Peter Boström | 0c4e06b | 2015-10-07 10:23:21 | [diff] [blame] | 518 | bool CheckCustomRtp1(uint32_t ssrc, int sequence_number, int pl_type = -1) { |
| Evan Shrubsole | e6a1f70 | 2025-04-15 14:55:42 | [diff] [blame] | 519 | webrtc::Buffer data = CreateRtpData(ssrc, sequence_number, pl_type); |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 520 | return media_receive_channel1_impl()->CheckRtp(data.data(), data.size()); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 521 | } |
| Peter Boström | 0c4e06b | 2015-10-07 10:23:21 | [diff] [blame] | 522 | bool CheckCustomRtp2(uint32_t ssrc, int sequence_number, int pl_type = -1) { |
| Evan Shrubsole | e6a1f70 | 2025-04-15 14:55:42 | [diff] [blame] | 523 | webrtc::Buffer data = CreateRtpData(ssrc, sequence_number, pl_type); |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 524 | return media_receive_channel2_impl()->CheckRtp(data.data(), data.size()); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 525 | } |
| Evan Shrubsole | e6a1f70 | 2025-04-15 14:55:42 | [diff] [blame] | 526 | webrtc::Buffer CreateRtpData(uint32_t ssrc, |
| 527 | int sequence_number, |
| 528 | int pl_type) { |
| 529 | webrtc::Buffer data(rtp_packet_.data(), rtp_packet_.size()); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 530 | // Set SSRC in the rtp packet copy. |
| Evan Shrubsole | 49ba3e2 | 2025-03-07 12:54:07 | [diff] [blame] | 531 | webrtc::SetBE32(data.data() + 8, ssrc); |
| 532 | webrtc::SetBE16(data.data() + 2, sequence_number); |
| [email protected] | 5ee0f05 | 2014-05-05 20:18:08 | [diff] [blame] | 533 | if (pl_type >= 0) { |
| Evan Shrubsole | 49ba3e2 | 2025-03-07 12:54:07 | [diff] [blame] | 534 | webrtc::Set8(data.data(), 1, static_cast<uint8_t>(pl_type)); |
| [email protected] | 5ee0f05 | 2014-05-05 20:18:08 | [diff] [blame] | 535 | } |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 536 | return data; |
| 537 | } |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 538 | |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 539 | bool CheckNoRtp1() { return media_send_channel1_impl()->CheckNoRtp(); } |
| 540 | bool CheckNoRtp2() { return media_send_channel2_impl()->CheckNoRtp(); } |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 541 | |
| 542 | void CreateContent(int flags, |
| Evan Shrubsole | 0b212e3 | 2025-04-07 13:43:01 | [diff] [blame] | 543 | const webrtc::Codec& audio_codec, |
| 544 | const webrtc::Codec& video_codec, |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 545 | typename T::Content* content) { |
| 546 | // overridden in specialized classes |
| 547 | } |
| 548 | void CopyContent(const typename T::Content& source, |
| 549 | typename T::Content* content) { |
| 550 | // overridden in specialized classes |
| 551 | } |
| 552 | |
| Steve Anton | 18ee1d5 | 2017-09-11 18:32:35 | [diff] [blame] | 553 | // Creates a MediaContent with one stream. |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 554 | // kPcmuCodec is used as audio codec and kH264Codec is used as video codec. |
| Steve Anton | 18ee1d5 | 2017-09-11 18:32:35 | [diff] [blame] | 555 | typename T::Content* CreateMediaContentWithStream(uint32_t ssrc) { |
| 556 | typename T::Content* content = new typename T::Content(); |
| Zhi Huang | e830e68 | 2018-03-30 17:48:35 | [diff] [blame] | 557 | CreateContent(0, kPcmuCodec, kH264Codec, content); |
| Steve Anton | 18ee1d5 | 2017-09-11 18:32:35 | [diff] [blame] | 558 | AddLegacyStreamInContent(ssrc, 0, content); |
| 559 | return content; |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 560 | } |
| 561 | |
| ossu | 292d658 | 2016-03-17 09:31:13 | [diff] [blame] | 562 | // Will manage the lifetime of a CallThread, making sure it's |
| 563 | // destroyed before this object goes out of scope. |
| 564 | class ScopedCallThread { |
| 565 | public: |
| Danil Chapovalov | a30439b | 2022-07-07 08:08:49 | [diff] [blame] | 566 | explicit ScopedCallThread(absl::AnyInvocable<void() &&> functor) |
| Evan Shrubsole | 6a9a1ae | 2025-03-21 12:54:15 | [diff] [blame] | 567 | : thread_(webrtc::Thread::Create()) { |
| ossu | 292d658 | 2016-03-17 09:31:13 | [diff] [blame] | 568 | thread_->Start(); |
| Danil Chapovalov | a30439b | 2022-07-07 08:08:49 | [diff] [blame] | 569 | thread_->PostTask(std::move(functor)); |
| ossu | 292d658 | 2016-03-17 09:31:13 | [diff] [blame] | 570 | } |
| 571 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 572 | ~ScopedCallThread() { thread_->Stop(); } |
| ossu | 292d658 | 2016-03-17 09:31:13 | [diff] [blame] | 573 | |
| Evan Shrubsole | 6a9a1ae | 2025-03-21 12:54:15 | [diff] [blame] | 574 | webrtc::Thread* thread() { return thread_.get(); } |
| ossu | 292d658 | 2016-03-17 09:31:13 | [diff] [blame] | 575 | |
| 576 | private: |
| Evan Shrubsole | 6a9a1ae | 2025-03-21 12:54:15 | [diff] [blame] | 577 | std::unique_ptr<webrtc::Thread> thread_; |
| ossu | 292d658 | 2016-03-17 09:31:13 | [diff] [blame] | 578 | }; |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 579 | |
| Evan Shrubsole | 945e517 | 2025-04-08 14:11:45 | [diff] [blame] | 580 | webrtc::CandidatePairInterface* last_selected_candidate_pair() { |
| Honghai Zhang | cc411c0 | 2016-03-30 00:27:21 | [diff] [blame] | 581 | return last_selected_candidate_pair_; |
| 582 | } |
| 583 | |
| Peter Boström | 0c4e06b | 2015-10-07 10:23:21 | [diff] [blame] | 584 | void AddLegacyStreamInContent(uint32_t ssrc, |
| 585 | int flags, |
| 586 | typename T::Content* content) { |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 587 | // Base implementation. |
| 588 | } |
| 589 | |
| Tomas Gunnarsson | 6cd5081 | 2021-04-06 09:26:47 | [diff] [blame] | 590 | // Utility method that calls BaseChannel::srtp_active() on the network thread |
| Artem Titov | 880fa81 | 2021-07-30 20:30:23 | [diff] [blame] | 591 | // and returns the result. The `srtp_active()` state is maintained on the |
| Tomas Gunnarsson | 6cd5081 | 2021-04-06 09:26:47 | [diff] [blame] | 592 | // network thread, which callers need to factor in. |
| 593 | bool IsSrtpActive(std::unique_ptr<typename T::Channel>& channel) { |
| 594 | RTC_DCHECK(channel.get()); |
| Danil Chapovalov | 2aaef45 | 2022-08-12 13:55:11 | [diff] [blame] | 595 | bool result; |
| 596 | SendTask(network_thread_, [&] { result = channel->srtp_active(); }); |
| 597 | return result; |
| Tomas Gunnarsson | 6cd5081 | 2021-04-06 09:26:47 | [diff] [blame] | 598 | } |
| 599 | |
| 600 | // Returns true iff the transport is set for a channel and rtcp_mux_enabled() |
| 601 | // returns true. |
| 602 | bool IsRtcpMuxEnabled(std::unique_ptr<typename T::Channel>& channel) { |
| 603 | RTC_DCHECK(channel.get()); |
| Danil Chapovalov | 2aaef45 | 2022-08-12 13:55:11 | [diff] [blame] | 604 | bool result; |
| 605 | SendTask(network_thread_, [&] { |
| 606 | result = channel->rtp_transport() && |
| 607 | channel->rtp_transport()->rtcp_mux_enabled(); |
| Tomas Gunnarsson | 6cd5081 | 2021-04-06 09:26:47 | [diff] [blame] | 608 | }); |
| Danil Chapovalov | 2aaef45 | 2022-08-12 13:55:11 | [diff] [blame] | 609 | return result; |
| Tomas Gunnarsson | 6cd5081 | 2021-04-06 09:26:47 | [diff] [blame] | 610 | } |
| 611 | |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 612 | // Tests that can be used by derived classes. |
| 613 | |
| 614 | // Basic sanity check. |
| 615 | void TestInit() { |
| 616 | CreateChannels(0, 0); |
| Tomas Gunnarsson | 6cd5081 | 2021-04-06 09:26:47 | [diff] [blame] | 617 | EXPECT_FALSE(IsSrtpActive(channel1_)); |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 618 | EXPECT_FALSE(media_send_channel1_impl()->sending()); |
| Peter Boström | 34fbfff | 2015-09-24 17:20:30 | [diff] [blame] | 619 | if (verify_playout_) { |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 620 | EXPECT_FALSE(media_receive_channel1_impl()->playout()); |
| Peter Boström | 34fbfff | 2015-09-24 17:20:30 | [diff] [blame] | 621 | } |
| Florent Castelli | 1f31c20 | 2023-06-26 00:26:07 | [diff] [blame] | 622 | EXPECT_TRUE(media_send_channel1_impl()->send_codecs().empty()); |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 623 | EXPECT_TRUE(media_receive_channel1_impl()->recv_streams().empty()); |
| 624 | EXPECT_TRUE(media_send_channel1_impl()->rtp_packets().empty()); |
| Harald Alvestrand | 50454ef | 2022-12-15 16:49:13 | [diff] [blame] | 625 | // Basic sanity test for send and receive channel objects |
| 626 | EXPECT_EQ(channel1_->media_send_channel()->media_type(), |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 627 | media_send_channel1_impl()->media_type()); |
| Harald Alvestrand | 50454ef | 2022-12-15 16:49:13 | [diff] [blame] | 628 | EXPECT_EQ(channel1_->media_receive_channel()->media_type(), |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 629 | media_receive_channel1_impl()->media_type()); |
| 630 | EXPECT_EQ(channel1_->media_send_channel()->media_type(), |
| 631 | channel1_->media_receive_channel()->media_type()); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 632 | } |
| 633 | |
| 634 | // Test that SetLocalContent and SetRemoteContent properly configure |
| 635 | // the codecs. |
| 636 | void TestSetContents() { |
| 637 | CreateChannels(0, 0); |
| 638 | typename T::Content content; |
| 639 | CreateContent(0, kPcmuCodec, kH264Codec, &content); |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 640 | std::string err; |
| 641 | EXPECT_TRUE(channel1_->SetLocalContent(&content, SdpType::kOffer, err)); |
| Florent Castelli | 1f31c20 | 2023-06-26 00:26:07 | [diff] [blame] | 642 | EXPECT_EQ(0U, media_send_channel1_impl()->send_codecs().size()); |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 643 | EXPECT_TRUE(channel1_->SetRemoteContent(&content, SdpType::kAnswer, err)); |
| Florent Castelli | 1f31c20 | 2023-06-26 00:26:07 | [diff] [blame] | 644 | ASSERT_EQ(1U, media_send_channel1_impl()->send_codecs().size()); |
| Philipp Hancke | b527699 | 2023-10-18 07:23:55 | [diff] [blame] | 645 | EXPECT_EQ(content.codecs()[0], |
| 646 | media_send_channel1_impl()->send_codecs()[0]); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 647 | } |
| 648 | |
| Per K | 38bb331 | 2025-08-19 13:46:24 | [diff] [blame] | 649 | void TestRemovesExtensionNotPresentInRemoteAnswer() { |
| 650 | typename T::Content local; |
| 651 | typename T::Content remote; |
| 652 | CreateContent(/*flags=*/0, kPcmuCodec, kH264Codec, &local); |
| 653 | CreateContent(/*flags=*/0, kPcmuCodec, kH264Codec, &remote); |
| 654 | local.set_rtp_header_extensions({ |
| 655 | RtpExtension(RtpExtension::kTransportSequenceNumberUri, 0), |
| 656 | RtpExtension(RtpExtension::kVideoRotationUri, 1), |
| 657 | }); |
| 658 | remote.set_rtp_header_extensions({ |
| 659 | RtpExtension(RtpExtension::kVideoRotationUri, 1), |
| 660 | }); |
| 661 | |
| 662 | CreateChannels(0, 0); |
| 663 | std::string err; |
| 664 | ASSERT_TRUE(channel1_->SetLocalContent(&local, SdpType::kOffer, err)) |
| 665 | << err; |
| 666 | ASSERT_TRUE(channel1_->SetRemoteContent(&remote, SdpType::kAnswer, err)) |
| 667 | << err; |
| 668 | |
| 669 | EXPECT_THAT(media_receive_channel1_impl()->recv_extensions(), |
| 670 | ElementsAre(AllOf(Field("id", &RtpExtension::id, 1), |
| 671 | Field("uri", &RtpExtension::uri, |
| 672 | RtpExtension::kVideoRotationUri)))); |
| 673 | EXPECT_THAT(media_send_channel1_impl()->send_extensions(), |
| 674 | ElementsAre(AllOf(Field("id", &RtpExtension::id, 1), |
| 675 | Field("uri", &RtpExtension::uri, |
| 676 | RtpExtension::kVideoRotationUri)))); |
| 677 | } |
| 678 | void TestRemovesExtensionNotPresentInLocalAnswer() { |
| 679 | typename T::Content local; |
| 680 | typename T::Content remote; |
| 681 | CreateContent(/*flags=*/0, kPcmuCodec, kH264Codec, &local); |
| 682 | CreateContent(/*flags=*/0, kPcmuCodec, kH264Codec, &remote); |
| 683 | local.set_rtp_header_extensions({ |
| 684 | RtpExtension(RtpExtension::kVideoRotationUri, 1), |
| 685 | }); |
| 686 | remote.set_rtp_header_extensions({ |
| 687 | RtpExtension(RtpExtension::kTransportSequenceNumberUri, 0), |
| 688 | RtpExtension(RtpExtension::kVideoRotationUri, 1), |
| 689 | }); |
| 690 | |
| 691 | CreateChannels(0, 0); |
| 692 | std::string err; |
| 693 | ASSERT_TRUE(channel1_->SetRemoteContent(&remote, SdpType::kOffer, err)) |
| 694 | << err; |
| 695 | ASSERT_TRUE(channel1_->SetLocalContent(&local, SdpType::kAnswer, err)) |
| 696 | << err; |
| 697 | |
| 698 | EXPECT_THAT(media_receive_channel1_impl()->recv_extensions(), |
| 699 | ElementsAre(AllOf(Field("id", &RtpExtension::id, 1), |
| 700 | Field("uri", &RtpExtension::uri, |
| 701 | RtpExtension::kVideoRotationUri)))); |
| 702 | EXPECT_THAT(media_send_channel1_impl()->send_extensions(), |
| 703 | ElementsAre(AllOf(Field("id", &RtpExtension::id, 1), |
| 704 | Field("uri", &RtpExtension::uri, |
| 705 | RtpExtension::kVideoRotationUri)))); |
| 706 | } |
| 707 | |
| Johannes Kron | 9190b82 | 2018-10-29 10:22:05 | [diff] [blame] | 708 | // Test that SetLocalContent and SetRemoteContent properly configure |
| 709 | // extmap-allow-mixed. |
| 710 | void TestSetContentsExtmapAllowMixedCaller(bool offer, bool answer) { |
| 711 | // For a caller, SetLocalContent() is called first with an offer and next |
| 712 | // SetRemoteContent() is called with the answer. |
| 713 | CreateChannels(0, 0); |
| 714 | typename T::Content content; |
| 715 | CreateContent(0, kPcmuCodec, kH264Codec, &content); |
| 716 | auto offer_enum = offer ? (T::Content::kSession) : (T::Content::kNo); |
| 717 | auto answer_enum = answer ? (T::Content::kSession) : (T::Content::kNo); |
| 718 | content.set_extmap_allow_mixed_enum(offer_enum); |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 719 | std::string err; |
| 720 | EXPECT_TRUE(channel1_->SetLocalContent(&content, SdpType::kOffer, err)); |
| Johannes Kron | 9190b82 | 2018-10-29 10:22:05 | [diff] [blame] | 721 | content.set_extmap_allow_mixed_enum(answer_enum); |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 722 | EXPECT_TRUE(channel1_->SetRemoteContent(&content, SdpType::kAnswer, err)); |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 723 | EXPECT_EQ(answer, media_send_channel1_impl()->ExtmapAllowMixed()); |
| Johannes Kron | 9190b82 | 2018-10-29 10:22:05 | [diff] [blame] | 724 | } |
| 725 | void TestSetContentsExtmapAllowMixedCallee(bool offer, bool answer) { |
| 726 | // For a callee, SetRemoteContent() is called first with an offer and next |
| 727 | // SetLocalContent() is called with the answer. |
| 728 | CreateChannels(0, 0); |
| 729 | typename T::Content content; |
| 730 | CreateContent(0, kPcmuCodec, kH264Codec, &content); |
| 731 | auto offer_enum = offer ? (T::Content::kSession) : (T::Content::kNo); |
| 732 | auto answer_enum = answer ? (T::Content::kSession) : (T::Content::kNo); |
| 733 | content.set_extmap_allow_mixed_enum(offer_enum); |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 734 | std::string err; |
| 735 | EXPECT_TRUE(channel1_->SetRemoteContent(&content, SdpType::kOffer, err)); |
| Johannes Kron | 9190b82 | 2018-10-29 10:22:05 | [diff] [blame] | 736 | content.set_extmap_allow_mixed_enum(answer_enum); |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 737 | EXPECT_TRUE(channel1_->SetLocalContent(&content, SdpType::kAnswer, err)); |
| Harald Alvestrand | 36fafc8 | 2022-12-08 08:47:42 | [diff] [blame] | 738 | EXPECT_EQ(answer, media_send_channel1()->ExtmapAllowMixed()); |
| Johannes Kron | 9190b82 | 2018-10-29 10:22:05 | [diff] [blame] | 739 | } |
| 740 | |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 741 | // Test that SetLocalContent and SetRemoteContent properly deals |
| 742 | // with an empty offer. |
| 743 | void TestSetContentsNullOffer() { |
| 744 | CreateChannels(0, 0); |
| 745 | typename T::Content content; |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 746 | std::string err; |
| 747 | EXPECT_TRUE(channel1_->SetLocalContent(&content, SdpType::kOffer, err)); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 748 | CreateContent(0, kPcmuCodec, kH264Codec, &content); |
| Florent Castelli | 1f31c20 | 2023-06-26 00:26:07 | [diff] [blame] | 749 | EXPECT_EQ(0U, media_send_channel1_impl()->send_codecs().size()); |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 750 | EXPECT_TRUE(channel1_->SetRemoteContent(&content, SdpType::kAnswer, err)); |
| Florent Castelli | 1f31c20 | 2023-06-26 00:26:07 | [diff] [blame] | 751 | ASSERT_EQ(1U, media_send_channel1_impl()->send_codecs().size()); |
| Philipp Hancke | b527699 | 2023-10-18 07:23:55 | [diff] [blame] | 752 | EXPECT_EQ(content.codecs()[0], |
| 753 | media_send_channel1_impl()->send_codecs()[0]); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 754 | } |
| 755 | |
| 756 | // Test that SetLocalContent and SetRemoteContent properly set RTCP |
| 757 | // mux. |
| 758 | void TestSetContentsRtcpMux() { |
| deadbeef | ac22f70 | 2017-01-13 05:59:29 | [diff] [blame] | 759 | CreateChannels(0, 0); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 760 | typename T::Content content; |
| 761 | CreateContent(0, kPcmuCodec, kH264Codec, &content); |
| 762 | // Both sides agree on mux. Should no longer be a separate RTCP channel. |
| 763 | content.set_rtcp_mux(true); |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 764 | std::string err; |
| 765 | EXPECT_TRUE(channel1_->SetLocalContent(&content, SdpType::kOffer, err)); |
| 766 | EXPECT_TRUE(channel1_->SetRemoteContent(&content, SdpType::kAnswer, err)); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 767 | // Only initiator supports mux. Should still have a separate RTCP channel. |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 768 | EXPECT_TRUE(channel2_->SetLocalContent(&content, SdpType::kOffer, err)); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 769 | content.set_rtcp_mux(false); |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 770 | EXPECT_TRUE(channel2_->SetRemoteContent(&content, SdpType::kAnswer, err)); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 771 | } |
| 772 | |
| Tomas Lundqvist | b40c559 | 2024-11-22 13:45:27 | [diff] [blame] | 773 | // Test that SetLocalContent and SetRemoteContent properly set RTCP |
| 774 | // reduced_size. |
| 775 | void TestSetContentsRtcpReducedSize() { |
| 776 | CreateChannels(0, 0); |
| 777 | typename T::Content content; |
| 778 | CreateContent(0, kPcmuCodec, kH264Codec, &content); |
| 779 | // Both sides agree on reduced size. |
| 780 | content.set_rtcp_reduced_size(true); |
| 781 | std::string err; |
| 782 | // The RTCP mode is a send property and should be configured based on |
| 783 | // the remote content and not the local content. |
| 784 | EXPECT_TRUE(channel1_->SetLocalContent(&content, SdpType::kOffer, err)); |
| 785 | EXPECT_EQ(media_receive_channel1_impl()->RtcpMode(), |
| 786 | webrtc::RtcpMode::kCompound); |
| 787 | EXPECT_TRUE(channel1_->SetRemoteContent(&content, SdpType::kAnswer, err)); |
| 788 | EXPECT_EQ(media_receive_channel1_impl()->RtcpMode(), |
| 789 | webrtc::RtcpMode::kReducedSize); |
| 790 | // Only initiator supports reduced size. |
| 791 | EXPECT_TRUE(channel2_->SetLocalContent(&content, SdpType::kOffer, err)); |
| 792 | EXPECT_EQ(media_receive_channel2_impl()->RtcpMode(), |
| 793 | webrtc::RtcpMode::kCompound); |
| 794 | content.set_rtcp_reduced_size(false); |
| 795 | EXPECT_TRUE(channel2_->SetRemoteContent(&content, SdpType::kAnswer, err)); |
| 796 | EXPECT_EQ(media_receive_channel2_impl()->RtcpMode(), |
| 797 | webrtc::RtcpMode::kCompound); |
| 798 | // Peer renegotiates without reduced size. |
| 799 | EXPECT_TRUE(channel1_->SetRemoteContent(&content, SdpType::kAnswer, err)); |
| 800 | EXPECT_EQ(media_receive_channel1_impl()->RtcpMode(), |
| 801 | webrtc::RtcpMode::kCompound); |
| 802 | } |
| 803 | |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 804 | // Test that SetLocalContent and SetRemoteContent properly |
| 805 | // handles adding and removing StreamParams when the action is a full |
| Steve Anton | 3828c06 | 2017-12-06 18:34:51 | [diff] [blame] | 806 | // SdpType::kOffer / SdpType::kAnswer. |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 807 | void TestChangeStreamParamsInContent() { |
| Evan Shrubsole | 945e517 | 2025-04-08 14:11:45 | [diff] [blame] | 808 | webrtc::StreamParams stream1; |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 809 | stream1.id = "stream1"; |
| 810 | stream1.ssrcs.push_back(kSsrc1); |
| 811 | stream1.cname = "stream1_cname"; |
| 812 | |
| Evan Shrubsole | 945e517 | 2025-04-08 14:11:45 | [diff] [blame] | 813 | webrtc::StreamParams stream2; |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 814 | stream2.id = "stream2"; |
| 815 | stream2.ssrcs.push_back(kSsrc2); |
| 816 | stream2.cname = "stream2_cname"; |
| 817 | |
| Artem Titov | 880fa81 | 2021-07-30 20:30:23 | [diff] [blame] | 818 | // Setup a call where channel 1 send `stream1` to channel 2. |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 819 | CreateChannels(0, 0); |
| 820 | typename T::Content content1; |
| 821 | CreateContent(0, kPcmuCodec, kH264Codec, &content1); |
| 822 | content1.AddStream(stream1); |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 823 | std::string err; |
| 824 | EXPECT_TRUE(channel1_->SetLocalContent(&content1, SdpType::kOffer, err)); |
| Tommi | 1959f8f | 2021-04-26 08:20:19 | [diff] [blame] | 825 | channel1_->Enable(true); |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 826 | EXPECT_EQ(1u, media_send_channel1_impl()->send_streams().size()); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 827 | |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 828 | EXPECT_TRUE(channel2_->SetRemoteContent(&content1, SdpType::kOffer, err)); |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 829 | EXPECT_EQ(1u, media_receive_channel2_impl()->recv_streams().size()); |
| deadbeef | f534659 | 2017-01-25 05:51:21 | [diff] [blame] | 830 | ConnectFakeTransports(); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 831 | |
| 832 | // Channel 2 do not send anything. |
| 833 | typename T::Content content2; |
| 834 | CreateContent(0, kPcmuCodec, kH264Codec, &content2); |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 835 | EXPECT_TRUE(channel1_->SetRemoteContent(&content2, SdpType::kAnswer, err)); |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 836 | EXPECT_EQ(0u, media_receive_channel1_impl()->recv_streams().size()); |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 837 | EXPECT_TRUE(channel2_->SetLocalContent(&content2, SdpType::kAnswer, err)); |
| Tommi | 1959f8f | 2021-04-26 08:20:19 | [diff] [blame] | 838 | channel2_->Enable(true); |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 839 | EXPECT_EQ(0u, media_send_channel2_impl()->send_streams().size()); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 840 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 841 | SendCustomRtp1(kSsrc1, 0); |
| 842 | WaitForThreads(); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 843 | EXPECT_TRUE(CheckCustomRtp2(kSsrc1, 0)); |
| 844 | |
| Artem Titov | 880fa81 | 2021-07-30 20:30:23 | [diff] [blame] | 845 | // Let channel 2 update the content by sending `stream2` and enable SRTP. |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 846 | typename T::Content content3; |
| Zhi Huang | e830e68 | 2018-03-30 17:48:35 | [diff] [blame] | 847 | CreateContent(0, kPcmuCodec, kH264Codec, &content3); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 848 | content3.AddStream(stream2); |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 849 | EXPECT_TRUE(channel2_->SetLocalContent(&content3, SdpType::kOffer, err)); |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 850 | ASSERT_EQ(1u, media_send_channel2_impl()->send_streams().size()); |
| 851 | EXPECT_EQ(stream2, media_send_channel2_impl()->send_streams()[0]); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 852 | |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 853 | EXPECT_TRUE(channel1_->SetRemoteContent(&content3, SdpType::kOffer, err)); |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 854 | ASSERT_EQ(1u, media_receive_channel1_impl()->recv_streams().size()); |
| 855 | EXPECT_EQ(stream2, media_receive_channel1_impl()->recv_streams()[0]); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 856 | |
| 857 | // Channel 1 replies but stop sending stream1. |
| 858 | typename T::Content content4; |
| Zhi Huang | e830e68 | 2018-03-30 17:48:35 | [diff] [blame] | 859 | CreateContent(0, kPcmuCodec, kH264Codec, &content4); |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 860 | EXPECT_TRUE(channel1_->SetLocalContent(&content4, SdpType::kAnswer, err)); |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 861 | EXPECT_EQ(0u, media_send_channel1_impl()->send_streams().size()); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 862 | |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 863 | EXPECT_TRUE(channel2_->SetRemoteContent(&content4, SdpType::kAnswer, err)); |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 864 | EXPECT_EQ(0u, media_receive_channel2_impl()->recv_streams().size()); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 865 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 866 | SendCustomRtp2(kSsrc2, 0); |
| 867 | WaitForThreads(); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 868 | EXPECT_TRUE(CheckCustomRtp1(kSsrc2, 0)); |
| 869 | } |
| 870 | |
| 871 | // Test that we only start playout and sending at the right times. |
| 872 | void TestPlayoutAndSendingStates() { |
| 873 | CreateChannels(0, 0); |
| Peter Boström | 34fbfff | 2015-09-24 17:20:30 | [diff] [blame] | 874 | if (verify_playout_) { |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 875 | EXPECT_FALSE(media_receive_channel1_impl()->playout()); |
| Peter Boström | 34fbfff | 2015-09-24 17:20:30 | [diff] [blame] | 876 | } |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 877 | EXPECT_FALSE(media_send_channel1_impl()->sending()); |
| Peter Boström | 34fbfff | 2015-09-24 17:20:30 | [diff] [blame] | 878 | if (verify_playout_) { |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 879 | EXPECT_FALSE(media_receive_channel2_impl()->playout()); |
| Peter Boström | 34fbfff | 2015-09-24 17:20:30 | [diff] [blame] | 880 | } |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 881 | EXPECT_FALSE(media_send_channel2_impl()->sending()); |
| Tommi | 1959f8f | 2021-04-26 08:20:19 | [diff] [blame] | 882 | channel1_->Enable(true); |
| 883 | FlushCurrentThread(); |
| Peter Boström | 34fbfff | 2015-09-24 17:20:30 | [diff] [blame] | 884 | if (verify_playout_) { |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 885 | EXPECT_FALSE(media_receive_channel1_impl()->playout()); |
| Peter Boström | 34fbfff | 2015-09-24 17:20:30 | [diff] [blame] | 886 | } |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 887 | EXPECT_FALSE(media_send_channel1_impl()->sending()); |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 888 | std::string err; |
| [email protected] | 4b26e2e | 2014-01-15 23:15:54 | [diff] [blame] | 889 | EXPECT_TRUE(channel1_->SetLocalContent(&local_media_content1_, |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 890 | SdpType::kOffer, err)); |
| Peter Boström | 34fbfff | 2015-09-24 17:20:30 | [diff] [blame] | 891 | if (verify_playout_) { |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 892 | EXPECT_TRUE(media_receive_channel1_impl()->playout()); |
| Peter Boström | 34fbfff | 2015-09-24 17:20:30 | [diff] [blame] | 893 | } |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 894 | EXPECT_FALSE(media_send_channel1_impl()->sending()); |
| [email protected] | 4b26e2e | 2014-01-15 23:15:54 | [diff] [blame] | 895 | EXPECT_TRUE(channel2_->SetRemoteContent(&local_media_content1_, |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 896 | SdpType::kOffer, err)); |
| Peter Boström | 34fbfff | 2015-09-24 17:20:30 | [diff] [blame] | 897 | if (verify_playout_) { |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 898 | EXPECT_FALSE(media_receive_channel2_impl()->playout()); |
| Peter Boström | 34fbfff | 2015-09-24 17:20:30 | [diff] [blame] | 899 | } |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 900 | EXPECT_FALSE(media_send_channel2_impl()->sending()); |
| [email protected] | 4b26e2e | 2014-01-15 23:15:54 | [diff] [blame] | 901 | EXPECT_TRUE(channel2_->SetLocalContent(&local_media_content2_, |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 902 | SdpType::kAnswer, err)); |
| Peter Boström | 34fbfff | 2015-09-24 17:20:30 | [diff] [blame] | 903 | if (verify_playout_) { |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 904 | EXPECT_FALSE(media_receive_channel2_impl()->playout()); |
| Peter Boström | 34fbfff | 2015-09-24 17:20:30 | [diff] [blame] | 905 | } |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 906 | EXPECT_FALSE(media_send_channel2_impl()->sending()); |
| deadbeef | f534659 | 2017-01-25 05:51:21 | [diff] [blame] | 907 | ConnectFakeTransports(); |
| Peter Boström | 34fbfff | 2015-09-24 17:20:30 | [diff] [blame] | 908 | if (verify_playout_) { |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 909 | EXPECT_TRUE(media_receive_channel1_impl()->playout()); |
| Peter Boström | 34fbfff | 2015-09-24 17:20:30 | [diff] [blame] | 910 | } |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 911 | EXPECT_FALSE(media_send_channel1_impl()->sending()); |
| Peter Boström | 34fbfff | 2015-09-24 17:20:30 | [diff] [blame] | 912 | if (verify_playout_) { |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 913 | EXPECT_FALSE(media_receive_channel2_impl()->playout()); |
| Peter Boström | 34fbfff | 2015-09-24 17:20:30 | [diff] [blame] | 914 | } |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 915 | EXPECT_FALSE(media_send_channel2_impl()->sending()); |
| Tommi | 1959f8f | 2021-04-26 08:20:19 | [diff] [blame] | 916 | channel2_->Enable(true); |
| 917 | FlushCurrentThread(); |
| Peter Boström | 34fbfff | 2015-09-24 17:20:30 | [diff] [blame] | 918 | if (verify_playout_) { |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 919 | EXPECT_TRUE(media_receive_channel2_impl()->playout()); |
| Peter Boström | 34fbfff | 2015-09-24 17:20:30 | [diff] [blame] | 920 | } |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 921 | EXPECT_TRUE(media_send_channel2_impl()->sending()); |
| [email protected] | 4b26e2e | 2014-01-15 23:15:54 | [diff] [blame] | 922 | EXPECT_TRUE(channel1_->SetRemoteContent(&local_media_content2_, |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 923 | SdpType::kAnswer, err)); |
| Peter Boström | 34fbfff | 2015-09-24 17:20:30 | [diff] [blame] | 924 | if (verify_playout_) { |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 925 | EXPECT_TRUE(media_receive_channel1_impl()->playout()); |
| Peter Boström | 34fbfff | 2015-09-24 17:20:30 | [diff] [blame] | 926 | } |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 927 | EXPECT_TRUE(media_send_channel1_impl()->sending()); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 928 | } |
| 929 | |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 930 | // Test that changing the MediaContentDirection in the local and remote |
| 931 | // session description start playout and sending at the right time. |
| 932 | void TestMediaContentDirection() { |
| 933 | CreateChannels(0, 0); |
| 934 | typename T::Content content1; |
| 935 | CreateContent(0, kPcmuCodec, kH264Codec, &content1); |
| 936 | typename T::Content content2; |
| 937 | CreateContent(0, kPcmuCodec, kH264Codec, &content2); |
| Artem Titov | 880fa81 | 2021-07-30 20:30:23 | [diff] [blame] | 938 | // Set `content2` to be InActive. |
| Steve Anton | 4e70a72 | 2017-11-28 22:57:10 | [diff] [blame] | 939 | content2.set_direction(RtpTransceiverDirection::kInactive); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 940 | |
| Tommi | 1959f8f | 2021-04-26 08:20:19 | [diff] [blame] | 941 | channel1_->Enable(true); |
| 942 | channel2_->Enable(true); |
| 943 | FlushCurrentThread(); |
| Peter Boström | 34fbfff | 2015-09-24 17:20:30 | [diff] [blame] | 944 | if (verify_playout_) { |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 945 | EXPECT_FALSE(media_receive_channel1_impl()->playout()); |
| Peter Boström | 34fbfff | 2015-09-24 17:20:30 | [diff] [blame] | 946 | } |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 947 | EXPECT_FALSE(media_send_channel1_impl()->sending()); |
| Peter Boström | 34fbfff | 2015-09-24 17:20:30 | [diff] [blame] | 948 | if (verify_playout_) { |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 949 | EXPECT_FALSE(media_receive_channel2_impl()->playout()); |
| Peter Boström | 34fbfff | 2015-09-24 17:20:30 | [diff] [blame] | 950 | } |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 951 | EXPECT_FALSE(media_send_channel2_impl()->sending()); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 952 | |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 953 | std::string err; |
| 954 | EXPECT_TRUE(channel1_->SetLocalContent(&content1, SdpType::kOffer, err)); |
| 955 | EXPECT_TRUE(channel2_->SetRemoteContent(&content1, SdpType::kOffer, err)); |
| 956 | EXPECT_TRUE(channel2_->SetLocalContent(&content2, SdpType::kPrAnswer, err)); |
| Steve Anton | 3828c06 | 2017-12-06 18:34:51 | [diff] [blame] | 957 | EXPECT_TRUE( |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 958 | channel1_->SetRemoteContent(&content2, SdpType::kPrAnswer, err)); |
| deadbeef | f534659 | 2017-01-25 05:51:21 | [diff] [blame] | 959 | ConnectFakeTransports(); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 960 | |
| Peter Boström | 34fbfff | 2015-09-24 17:20:30 | [diff] [blame] | 961 | if (verify_playout_) { |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 962 | EXPECT_TRUE(media_receive_channel1_impl()->playout()); |
| Peter Boström | 34fbfff | 2015-09-24 17:20:30 | [diff] [blame] | 963 | } |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 964 | EXPECT_FALSE(media_send_channel1_impl()->sending()); // remote InActive |
| Peter Boström | 34fbfff | 2015-09-24 17:20:30 | [diff] [blame] | 965 | if (verify_playout_) { |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 966 | EXPECT_FALSE(media_receive_channel2_impl()->playout()); // local InActive |
| Peter Boström | 34fbfff | 2015-09-24 17:20:30 | [diff] [blame] | 967 | } |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 968 | EXPECT_FALSE(media_send_channel2_impl()->sending()); // local InActive |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 969 | |
| Artem Titov | 880fa81 | 2021-07-30 20:30:23 | [diff] [blame] | 970 | // Update `content2` to be RecvOnly. |
| Steve Anton | 4e70a72 | 2017-11-28 22:57:10 | [diff] [blame] | 971 | content2.set_direction(RtpTransceiverDirection::kRecvOnly); |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 972 | EXPECT_TRUE(channel2_->SetLocalContent(&content2, SdpType::kPrAnswer, err)); |
| Steve Anton | 3828c06 | 2017-12-06 18:34:51 | [diff] [blame] | 973 | EXPECT_TRUE( |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 974 | channel1_->SetRemoteContent(&content2, SdpType::kPrAnswer, err)); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 975 | |
| Peter Boström | 34fbfff | 2015-09-24 17:20:30 | [diff] [blame] | 976 | if (verify_playout_) { |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 977 | EXPECT_TRUE(media_receive_channel1_impl()->playout()); |
| Peter Boström | 34fbfff | 2015-09-24 17:20:30 | [diff] [blame] | 978 | } |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 979 | EXPECT_TRUE(media_send_channel1_impl()->sending()); |
| Peter Boström | 34fbfff | 2015-09-24 17:20:30 | [diff] [blame] | 980 | if (verify_playout_) { |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 981 | EXPECT_TRUE(media_receive_channel2_impl()->playout()); // local RecvOnly |
| Peter Boström | 34fbfff | 2015-09-24 17:20:30 | [diff] [blame] | 982 | } |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 983 | EXPECT_FALSE(media_send_channel2_impl()->sending()); // local RecvOnly |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 984 | |
| Artem Titov | 880fa81 | 2021-07-30 20:30:23 | [diff] [blame] | 985 | // Update `content2` to be SendRecv. |
| Steve Anton | 4e70a72 | 2017-11-28 22:57:10 | [diff] [blame] | 986 | content2.set_direction(RtpTransceiverDirection::kSendRecv); |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 987 | EXPECT_TRUE(channel2_->SetLocalContent(&content2, SdpType::kAnswer, err)); |
| 988 | EXPECT_TRUE(channel1_->SetRemoteContent(&content2, SdpType::kAnswer, err)); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 989 | |
| Peter Boström | 34fbfff | 2015-09-24 17:20:30 | [diff] [blame] | 990 | if (verify_playout_) { |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 991 | EXPECT_TRUE(media_receive_channel1_impl()->playout()); |
| Peter Boström | 34fbfff | 2015-09-24 17:20:30 | [diff] [blame] | 992 | } |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 993 | EXPECT_TRUE(media_send_channel1_impl()->sending()); |
| Peter Boström | 34fbfff | 2015-09-24 17:20:30 | [diff] [blame] | 994 | if (verify_playout_) { |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 995 | EXPECT_TRUE(media_receive_channel2_impl()->playout()); |
| Peter Boström | 34fbfff | 2015-09-24 17:20:30 | [diff] [blame] | 996 | } |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 997 | EXPECT_TRUE(media_send_channel2_impl()->sending()); |
| Philipp Hancke | 7924915 | 2023-05-11 16:13:34 | [diff] [blame] | 998 | |
| 999 | // Update `content2` to be inactive on the receiver while sending at the |
| 1000 | // sender. |
| 1001 | content2.set_direction(RtpTransceiverDirection::kInactive); |
| 1002 | EXPECT_TRUE(channel1_->SetLocalContent(&content1, SdpType::kOffer, err)); |
| 1003 | EXPECT_TRUE(channel2_->SetRemoteContent(&content1, SdpType::kOffer, err)); |
| 1004 | EXPECT_TRUE(channel2_->SetLocalContent(&content2, SdpType::kAnswer, err)); |
| 1005 | content2.set_direction(RtpTransceiverDirection::kRecvOnly); |
| 1006 | EXPECT_TRUE(channel1_->SetRemoteContent(&content2, SdpType::kAnswer, err)); |
| 1007 | if (verify_playout_) { |
| 1008 | EXPECT_FALSE(media_receive_channel2_impl()->playout()); |
| 1009 | } |
| 1010 | EXPECT_TRUE(media_send_channel1_impl()->sending()); |
| 1011 | |
| 1012 | // Re-enable `content2`. |
| 1013 | content2.set_direction(RtpTransceiverDirection::kSendRecv); |
| 1014 | EXPECT_TRUE(channel1_->SetLocalContent(&content1, SdpType::kOffer, err)); |
| 1015 | EXPECT_TRUE(channel2_->SetRemoteContent(&content1, SdpType::kOffer, err)); |
| 1016 | EXPECT_TRUE(channel2_->SetLocalContent(&content2, SdpType::kAnswer, err)); |
| 1017 | EXPECT_TRUE(channel1_->SetRemoteContent(&content2, SdpType::kAnswer, err)); |
| 1018 | if (verify_playout_) { |
| 1019 | EXPECT_TRUE(media_receive_channel2_impl()->playout()); |
| 1020 | } |
| 1021 | EXPECT_TRUE(media_send_channel1_impl()->sending()); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1022 | } |
| 1023 | |
| Honghai Zhang | cc411c0 | 2016-03-30 00:27:21 | [diff] [blame] | 1024 | // Tests that when the transport channel signals a candidate pair change |
| 1025 | // event, the media channel will receive a call on the network route change. |
| 1026 | void TestNetworkRouteChanges() { |
| eladalon | 05b07bb | 2017-08-24 14:40:16 | [diff] [blame] | 1027 | static constexpr uint16_t kLocalNetId = 1; |
| 1028 | static constexpr uint16_t kRemoteNetId = 2; |
| 1029 | static constexpr int kLastPacketId = 100; |
| Zhi Huang | 942bc2e | 2017-11-13 21:26:07 | [diff] [blame] | 1030 | // Ipv4(20) + UDP(8). |
| 1031 | static constexpr int kTransportOverheadPerPacket = 28; |
| Zhi Huang | cf6e24a | 2018-02-21 18:40:07 | [diff] [blame] | 1032 | static constexpr int kSrtpOverheadPerPacket = 10; |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 1033 | |
| Zhi Huang | cf6e24a | 2018-02-21 18:40:07 | [diff] [blame] | 1034 | CreateChannels(DTLS, DTLS); |
| 1035 | SendInitiate(); |
| Honghai Zhang | cc411c0 | 2016-03-30 00:27:21 | [diff] [blame] | 1036 | |
| Florent Castelli | 1f31c20 | 2023-06-26 00:26:07 | [diff] [blame] | 1037 | typename T::MediaSendChannel* media_send_channel1_impl = |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 1038 | this->media_send_channel1_impl(); |
| 1039 | ASSERT_TRUE(media_send_channel1_impl); |
| Honghai Zhang | cc411c0 | 2016-03-30 00:27:21 | [diff] [blame] | 1040 | |
| Zhi Huang | 942bc2e | 2017-11-13 21:26:07 | [diff] [blame] | 1041 | // Need to wait for the threads before calling |
| Artem Titov | 880fa81 | 2021-07-30 20:30:23 | [diff] [blame] | 1042 | // `set_num_network_route_changes` because the network route would be set |
| Zhi Huang | 942bc2e | 2017-11-13 21:26:07 | [diff] [blame] | 1043 | // when creating the channel. |
| 1044 | WaitForThreads(); |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 1045 | media_send_channel1_impl->set_num_network_route_changes(0); |
| Danil Chapovalov | 2aaef45 | 2022-08-12 13:55:11 | [diff] [blame] | 1046 | SendTask(network_thread_, [this] { |
| Evan Shrubsole | daf96cf | 2025-03-31 12:34:02 | [diff] [blame] | 1047 | webrtc::NetworkRoute network_route; |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 1048 | // The transport channel becomes disconnected. |
| Lena Kaplan | 83b0eaa | 2025-09-15 16:53:39 | [diff] [blame] | 1049 | fake_rtp_dtls_transport1_->ice_transport()->NotifyNetworkRouteChanged( |
| Evan Shrubsole | daf96cf | 2025-03-31 12:34:02 | [diff] [blame] | 1050 | std::optional<webrtc::NetworkRoute>(network_route)); |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 1051 | }); |
| 1052 | WaitForThreads(); |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 1053 | EXPECT_EQ(1, media_send_channel1_impl->num_network_route_changes()); |
| 1054 | EXPECT_FALSE(media_send_channel1_impl->last_network_route().connected); |
| 1055 | media_send_channel1_impl->set_num_network_route_changes(0); |
| Honghai Zhang | cc411c0 | 2016-03-30 00:27:21 | [diff] [blame] | 1056 | |
| Danil Chapovalov | 2aaef45 | 2022-08-12 13:55:11 | [diff] [blame] | 1057 | SendTask(network_thread_, [this] { |
| Evan Shrubsole | daf96cf | 2025-03-31 12:34:02 | [diff] [blame] | 1058 | webrtc::NetworkRoute network_route; |
| Zhi Huang | 942bc2e | 2017-11-13 21:26:07 | [diff] [blame] | 1059 | network_route.connected = true; |
| Jonas Oreland | 71fda36 | 2020-03-20 15:11:56 | [diff] [blame] | 1060 | network_route.local = |
| Evan Shrubsole | daf96cf | 2025-03-31 12:34:02 | [diff] [blame] | 1061 | webrtc::RouteEndpoint::CreateWithNetworkId(kLocalNetId); |
| Jonas Oreland | 71fda36 | 2020-03-20 15:11:56 | [diff] [blame] | 1062 | network_route.remote = |
| Evan Shrubsole | daf96cf | 2025-03-31 12:34:02 | [diff] [blame] | 1063 | webrtc::RouteEndpoint::CreateWithNetworkId(kRemoteNetId); |
| Zhi Huang | 942bc2e | 2017-11-13 21:26:07 | [diff] [blame] | 1064 | network_route.last_sent_packet_id = kLastPacketId; |
| 1065 | network_route.packet_overhead = kTransportOverheadPerPacket; |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 1066 | // The transport channel becomes connected. |
| Lena Kaplan | 83b0eaa | 2025-09-15 16:53:39 | [diff] [blame] | 1067 | fake_rtp_dtls_transport1_->ice_transport()->NotifyNetworkRouteChanged( |
| Zhi Huang | 942bc2e | 2017-11-13 21:26:07 | [diff] [blame] | 1068 | |
| Evan Shrubsole | daf96cf | 2025-03-31 12:34:02 | [diff] [blame] | 1069 | std::optional<webrtc::NetworkRoute>(network_route)); |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 1070 | }); |
| 1071 | WaitForThreads(); |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 1072 | EXPECT_EQ(1, media_send_channel1_impl->num_network_route_changes()); |
| 1073 | EXPECT_TRUE(media_send_channel1_impl->last_network_route().connected); |
| 1074 | EXPECT_EQ( |
| 1075 | kLocalNetId, |
| 1076 | media_send_channel1_impl->last_network_route().local.network_id()); |
| 1077 | EXPECT_EQ( |
| 1078 | kRemoteNetId, |
| 1079 | media_send_channel1_impl->last_network_route().remote.network_id()); |
| 1080 | EXPECT_EQ( |
| 1081 | kLastPacketId, |
| 1082 | media_send_channel1_impl->last_network_route().last_sent_packet_id); |
| Zhi Huang | cf6e24a | 2018-02-21 18:40:07 | [diff] [blame] | 1083 | EXPECT_EQ(kTransportOverheadPerPacket + kSrtpOverheadPerPacket, |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 1084 | media_send_channel1_impl->transport_overhead_per_packet()); |
| Honghai Zhang | cc411c0 | 2016-03-30 00:27:21 | [diff] [blame] | 1085 | } |
| 1086 | |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1087 | // Test setting up a call. |
| 1088 | void TestCallSetup() { |
| 1089 | CreateChannels(0, 0); |
| Tomas Gunnarsson | 6cd5081 | 2021-04-06 09:26:47 | [diff] [blame] | 1090 | EXPECT_FALSE(IsSrtpActive(channel1_)); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1091 | EXPECT_TRUE(SendInitiate()); |
| Peter Boström | 34fbfff | 2015-09-24 17:20:30 | [diff] [blame] | 1092 | if (verify_playout_) { |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 1093 | EXPECT_TRUE(media_receive_channel1_impl()->playout()); |
| Peter Boström | 34fbfff | 2015-09-24 17:20:30 | [diff] [blame] | 1094 | } |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 1095 | EXPECT_FALSE(media_send_channel1_impl()->sending()); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1096 | EXPECT_TRUE(SendAccept()); |
| Tomas Gunnarsson | 6cd5081 | 2021-04-06 09:26:47 | [diff] [blame] | 1097 | EXPECT_FALSE(IsSrtpActive(channel1_)); |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 1098 | EXPECT_TRUE(media_send_channel1_impl()->sending()); |
| Florent Castelli | 1f31c20 | 2023-06-26 00:26:07 | [diff] [blame] | 1099 | EXPECT_EQ(1U, media_send_channel1_impl()->send_codecs().size()); |
| Peter Boström | 34fbfff | 2015-09-24 17:20:30 | [diff] [blame] | 1100 | if (verify_playout_) { |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 1101 | EXPECT_TRUE(media_receive_channel2_impl()->playout()); |
| Peter Boström | 34fbfff | 2015-09-24 17:20:30 | [diff] [blame] | 1102 | } |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 1103 | EXPECT_TRUE(media_send_channel2_impl()->sending()); |
| Florent Castelli | 1f31c20 | 2023-06-26 00:26:07 | [diff] [blame] | 1104 | EXPECT_EQ(1U, media_send_channel2_impl()->send_codecs().size()); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1105 | } |
| 1106 | |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1107 | // Send voice RTP data to the other side and ensure it gets there. |
| 1108 | void SendRtpToRtp() { |
| Zhi Huang | e830e68 | 2018-03-30 17:48:35 | [diff] [blame] | 1109 | CreateChannels(RTCP_MUX, RTCP_MUX); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1110 | EXPECT_TRUE(SendInitiate()); |
| 1111 | EXPECT_TRUE(SendAccept()); |
| Tomas Gunnarsson | 6cd5081 | 2021-04-06 09:26:47 | [diff] [blame] | 1112 | EXPECT_TRUE(IsRtcpMuxEnabled(channel1_)); |
| 1113 | EXPECT_TRUE(IsRtcpMuxEnabled(channel2_)); |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 1114 | SendRtp1(); |
| 1115 | SendRtp2(); |
| 1116 | WaitForThreads(); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1117 | EXPECT_TRUE(CheckRtp1()); |
| 1118 | EXPECT_TRUE(CheckRtp2()); |
| 1119 | EXPECT_TRUE(CheckNoRtp1()); |
| 1120 | EXPECT_TRUE(CheckNoRtp2()); |
| 1121 | } |
| 1122 | |
| Danil Chapovalov | dae07ba | 2016-05-13 23:43:50 | [diff] [blame] | 1123 | void TestDeinit() { |
| deadbeef | ac22f70 | 2017-01-13 05:59:29 | [diff] [blame] | 1124 | CreateChannels(0, 0); |
| Danil Chapovalov | dae07ba | 2016-05-13 23:43:50 | [diff] [blame] | 1125 | EXPECT_TRUE(SendInitiate()); |
| 1126 | EXPECT_TRUE(SendAccept()); |
| 1127 | SendRtp1(); |
| 1128 | SendRtp2(); |
| Tomas Gunnarsson | 1933d3b | 2022-01-17 10:25:21 | [diff] [blame] | 1129 | |
| 1130 | DeinitChannels(); |
| 1131 | |
| Danil Chapovalov | dae07ba | 2016-05-13 23:43:50 | [diff] [blame] | 1132 | // Do not wait, destroy channels. |
| 1133 | channel1_.reset(nullptr); |
| 1134 | channel2_.reset(nullptr); |
| 1135 | } |
| 1136 | |
| Zhi Huang | e830e68 | 2018-03-30 17:48:35 | [diff] [blame] | 1137 | void SendDtlsSrtpToDtlsSrtp(int flags1, int flags2) { |
| 1138 | CreateChannels(flags1 | DTLS, flags2 | DTLS); |
| Tomas Gunnarsson | 6cd5081 | 2021-04-06 09:26:47 | [diff] [blame] | 1139 | EXPECT_FALSE(IsSrtpActive(channel1_)); |
| 1140 | EXPECT_FALSE(IsSrtpActive(channel2_)); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1141 | EXPECT_TRUE(SendInitiate()); |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 1142 | WaitForThreads(); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1143 | EXPECT_TRUE(SendAccept()); |
| Tomas Gunnarsson | 6cd5081 | 2021-04-06 09:26:47 | [diff] [blame] | 1144 | EXPECT_TRUE(IsSrtpActive(channel1_)); |
| 1145 | EXPECT_TRUE(IsSrtpActive(channel2_)); |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 1146 | SendRtp1(); |
| 1147 | SendRtp2(); |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 1148 | WaitForThreads(); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1149 | EXPECT_TRUE(CheckRtp1()); |
| 1150 | EXPECT_TRUE(CheckRtp2()); |
| 1151 | EXPECT_TRUE(CheckNoRtp1()); |
| 1152 | EXPECT_TRUE(CheckNoRtp2()); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1153 | } |
| 1154 | |
| 1155 | // Test that we can send and receive early media when a provisional answer is |
| 1156 | // sent and received. The test uses SRTP, RTCP mux and SSRC mux. |
| 1157 | void SendEarlyMediaUsingRtcpMuxSrtp() { |
| Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 1158 | int sequence_number1_1 = 0, sequence_number2_2 = 0; |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1159 | |
| Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 1160 | CreateChannels(SSRC_MUX | RTCP_MUX | DTLS, SSRC_MUX | RTCP_MUX | DTLS); |
| 1161 | EXPECT_TRUE(SendOffer()); |
| 1162 | EXPECT_TRUE(SendProvisionalAnswer()); |
| Tomas Gunnarsson | 6cd5081 | 2021-04-06 09:26:47 | [diff] [blame] | 1163 | EXPECT_TRUE(IsSrtpActive(channel1_)); |
| 1164 | EXPECT_TRUE(IsSrtpActive(channel2_)); |
| 1165 | EXPECT_TRUE(IsRtcpMuxEnabled(channel1_)); |
| 1166 | EXPECT_TRUE(IsRtcpMuxEnabled(channel2_)); |
| Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 1167 | WaitForThreads(); // Wait for 'sending' flag go through network thread. |
| Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 1168 | SendCustomRtp1(kSsrc1, ++sequence_number1_1); |
| 1169 | WaitForThreads(); |
| Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 1170 | EXPECT_TRUE(CheckCustomRtp2(kSsrc1, sequence_number1_1)); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1171 | |
| Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 1172 | // Send packets from callee and verify that it is received. |
| Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 1173 | SendCustomRtp2(kSsrc2, ++sequence_number2_2); |
| 1174 | WaitForThreads(); |
| Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 1175 | EXPECT_TRUE(CheckCustomRtp1(kSsrc2, sequence_number2_2)); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1176 | |
| Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 1177 | // Complete call setup and ensure everything is still OK. |
| 1178 | EXPECT_TRUE(SendFinalAnswer()); |
| Tomas Gunnarsson | 6cd5081 | 2021-04-06 09:26:47 | [diff] [blame] | 1179 | EXPECT_TRUE(IsSrtpActive(channel1_)); |
| 1180 | EXPECT_TRUE(IsSrtpActive(channel2_)); |
| Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 1181 | SendCustomRtp1(kSsrc1, ++sequence_number1_1); |
| Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 1182 | SendCustomRtp2(kSsrc2, ++sequence_number2_2); |
| 1183 | WaitForThreads(); |
| Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 1184 | EXPECT_TRUE(CheckCustomRtp2(kSsrc1, sequence_number1_1)); |
| Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 1185 | EXPECT_TRUE(CheckCustomRtp1(kSsrc2, sequence_number2_2)); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1186 | } |
| 1187 | |
| 1188 | // Test that we properly send RTP without SRTP from a thread. |
| 1189 | void SendRtpToRtpOnThread() { |
| deadbeef | ac22f70 | 2017-01-13 05:59:29 | [diff] [blame] | 1190 | CreateChannels(0, 0); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1191 | EXPECT_TRUE(SendInitiate()); |
| 1192 | EXPECT_TRUE(SendAccept()); |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 1193 | ScopedCallThread send_rtp1([this] { SendRtp1(); }); |
| 1194 | ScopedCallThread send_rtp2([this] { SendRtp2(); }); |
| Evan Shrubsole | 6a9a1ae | 2025-03-21 12:54:15 | [diff] [blame] | 1195 | webrtc::Thread* involved_threads[] = {send_rtp1.thread(), |
| 1196 | send_rtp2.thread()}; |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 1197 | WaitForThreads(involved_threads); |
| 1198 | EXPECT_TRUE(CheckRtp1()); |
| 1199 | EXPECT_TRUE(CheckRtp2()); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1200 | EXPECT_TRUE(CheckNoRtp1()); |
| 1201 | EXPECT_TRUE(CheckNoRtp2()); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1202 | } |
| 1203 | |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1204 | // Test that the mediachannel retains its sending state after the transport |
| 1205 | // becomes non-writable. |
| 1206 | void SendWithWritabilityLoss() { |
| Zhi Huang | e830e68 | 2018-03-30 17:48:35 | [diff] [blame] | 1207 | CreateChannels(RTCP_MUX, RTCP_MUX); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1208 | EXPECT_TRUE(SendInitiate()); |
| 1209 | EXPECT_TRUE(SendAccept()); |
| Tomas Gunnarsson | 6cd5081 | 2021-04-06 09:26:47 | [diff] [blame] | 1210 | EXPECT_TRUE(IsRtcpMuxEnabled(channel1_)); |
| 1211 | EXPECT_TRUE(IsRtcpMuxEnabled(channel2_)); |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 1212 | SendRtp1(); |
| 1213 | SendRtp2(); |
| 1214 | WaitForThreads(); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1215 | EXPECT_TRUE(CheckRtp1()); |
| 1216 | EXPECT_TRUE(CheckRtp2()); |
| 1217 | EXPECT_TRUE(CheckNoRtp1()); |
| 1218 | EXPECT_TRUE(CheckNoRtp2()); |
| 1219 | |
| [email protected] | 97077a3 | 2013-10-25 21:18:33 | [diff] [blame] | 1220 | // Lose writability, which should fail. |
| Danil Chapovalov | 2aaef45 | 2022-08-12 13:55:11 | [diff] [blame] | 1221 | SendTask(network_thread_, |
| 1222 | [this] { fake_rtp_dtls_transport1_->SetWritable(false); }); |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 1223 | SendRtp1(); |
| 1224 | SendRtp2(); |
| 1225 | WaitForThreads(); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1226 | EXPECT_TRUE(CheckRtp1()); |
| 1227 | EXPECT_TRUE(CheckNoRtp2()); |
| 1228 | |
| 1229 | // Regain writability |
| Danil Chapovalov | 2aaef45 | 2022-08-12 13:55:11 | [diff] [blame] | 1230 | SendTask(network_thread_, |
| 1231 | [this] { fake_rtp_dtls_transport1_->SetWritable(true); }); |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 1232 | EXPECT_TRUE(media_send_channel1_impl()->sending()); |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 1233 | SendRtp1(); |
| 1234 | SendRtp2(); |
| 1235 | WaitForThreads(); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1236 | EXPECT_TRUE(CheckRtp1()); |
| 1237 | EXPECT_TRUE(CheckRtp2()); |
| 1238 | EXPECT_TRUE(CheckNoRtp1()); |
| 1239 | EXPECT_TRUE(CheckNoRtp2()); |
| 1240 | |
| 1241 | // Lose writability completely |
| Danil Chapovalov | 2aaef45 | 2022-08-12 13:55:11 | [diff] [blame] | 1242 | SendTask(network_thread_, [this] { |
| deadbeef | f534659 | 2017-01-25 05:51:21 | [diff] [blame] | 1243 | bool asymmetric = true; |
| 1244 | fake_rtp_dtls_transport1_->SetDestination(nullptr, asymmetric); |
| 1245 | }); |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 1246 | EXPECT_TRUE(media_send_channel1_impl()->sending()); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1247 | |
| [email protected] | 97077a3 | 2013-10-25 21:18:33 | [diff] [blame] | 1248 | // Should fail also. |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 1249 | SendRtp1(); |
| 1250 | SendRtp2(); |
| 1251 | WaitForThreads(); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1252 | EXPECT_TRUE(CheckRtp1()); |
| 1253 | EXPECT_TRUE(CheckNoRtp2()); |
| zhihuang | b2cdd93 | 2017-01-20 00:54:25 | [diff] [blame] | 1254 | EXPECT_TRUE(CheckNoRtp1()); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1255 | |
| 1256 | // Gain writability back |
| Danil Chapovalov | 2aaef45 | 2022-08-12 13:55:11 | [diff] [blame] | 1257 | SendTask(network_thread_, [this] { |
| deadbeef | f534659 | 2017-01-25 05:51:21 | [diff] [blame] | 1258 | bool asymmetric = true; |
| 1259 | fake_rtp_dtls_transport1_->SetDestination(fake_rtp_dtls_transport2_.get(), |
| 1260 | asymmetric); |
| Taylor Brandstetter | 5d97a9a | 2016-06-10 21:17:27 | [diff] [blame] | 1261 | }); |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 1262 | EXPECT_TRUE(media_send_channel1_impl()->sending()); |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 1263 | SendRtp1(); |
| 1264 | SendRtp2(); |
| 1265 | WaitForThreads(); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1266 | EXPECT_TRUE(CheckRtp1()); |
| 1267 | EXPECT_TRUE(CheckRtp2()); |
| 1268 | EXPECT_TRUE(CheckNoRtp1()); |
| 1269 | EXPECT_TRUE(CheckNoRtp2()); |
| 1270 | } |
| 1271 | |
| Danil Chapovalov | 52c16dc | 2025-06-02 07:57:15 | [diff] [blame] | 1272 | void SendBundleToBundle(ArrayView<const int, 2> pl_types, |
| Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 1273 | bool rtcp_mux, |
| 1274 | bool secure) { |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1275 | int sequence_number1_1 = 0, sequence_number2_2 = 0; |
| Artem Titov | 880fa81 | 2021-07-30 20:30:23 | [diff] [blame] | 1276 | // Only pl_type1 was added to the bundle filter for both `channel1_` |
| 1277 | // and `channel2_`. |
| [email protected] | 5ee0f05 | 2014-05-05 20:18:08 | [diff] [blame] | 1278 | int pl_type1 = pl_types[0]; |
| 1279 | int pl_type2 = pl_types[1]; |
| deadbeef | ac22f70 | 2017-01-13 05:59:29 | [diff] [blame] | 1280 | int flags = SSRC_MUX; |
| Zhi Huang | e830e68 | 2018-03-30 17:48:35 | [diff] [blame] | 1281 | if (secure) |
| 1282 | flags |= DTLS; |
| [email protected] | 5ee0f05 | 2014-05-05 20:18:08 | [diff] [blame] | 1283 | if (rtcp_mux) { |
| 1284 | flags |= RTCP_MUX; |
| [email protected] | 5ee0f05 | 2014-05-05 20:18:08 | [diff] [blame] | 1285 | } |
| 1286 | CreateChannels(flags, flags); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1287 | EXPECT_TRUE(SendInitiate()); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1288 | EXPECT_TRUE(SendAccept()); |
| [email protected] | 5ee0f05 | 2014-05-05 20:18:08 | [diff] [blame] | 1289 | |
| 1290 | // Both channels can receive pl_type1 only. |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 1291 | SendCustomRtp1(kSsrc1, ++sequence_number1_1, pl_type1); |
| 1292 | SendCustomRtp2(kSsrc2, ++sequence_number2_2, pl_type1); |
| 1293 | WaitForThreads(); |
| [email protected] | 5ee0f05 | 2014-05-05 20:18:08 | [diff] [blame] | 1294 | EXPECT_TRUE(CheckCustomRtp2(kSsrc1, sequence_number1_1, pl_type1)); |
| [email protected] | 5ee0f05 | 2014-05-05 20:18:08 | [diff] [blame] | 1295 | EXPECT_TRUE(CheckCustomRtp1(kSsrc2, sequence_number2_2, pl_type1)); |
| 1296 | EXPECT_TRUE(CheckNoRtp1()); |
| 1297 | EXPECT_TRUE(CheckNoRtp2()); |
| 1298 | |
| Zhi Huang | 365381f | 2018-04-13 23:44:34 | [diff] [blame] | 1299 | SendCustomRtp1(kSsrc3, ++sequence_number1_1, pl_type2); |
| 1300 | SendCustomRtp2(kSsrc4, ++sequence_number2_2, pl_type2); |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 1301 | WaitForThreads(); |
| Zhi Huang | 365381f | 2018-04-13 23:44:34 | [diff] [blame] | 1302 | EXPECT_FALSE(CheckCustomRtp2(kSsrc3, sequence_number1_1, pl_type2)); |
| 1303 | EXPECT_FALSE(CheckCustomRtp1(kSsrc4, sequence_number2_2, pl_type2)); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1304 | } |
| 1305 | |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1306 | void TestSetContentFailure() { |
| 1307 | CreateChannels(0, 0); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1308 | |
| Peter Thatcher | a6d2444 | 2015-07-10 04:26:36 | [diff] [blame] | 1309 | std::string err; |
| Steve Anton | 18ee1d5 | 2017-09-11 18:32:35 | [diff] [blame] | 1310 | std::unique_ptr<typename T::Content> content( |
| 1311 | CreateMediaContentWithStream(1)); |
| 1312 | |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 1313 | media_receive_channel1_impl()->set_fail_set_recv_codecs(true); |
| Steve Anton | 18ee1d5 | 2017-09-11 18:32:35 | [diff] [blame] | 1314 | EXPECT_FALSE( |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 1315 | channel1_->SetLocalContent(content.get(), SdpType::kOffer, err)); |
| Steve Anton | 18ee1d5 | 2017-09-11 18:32:35 | [diff] [blame] | 1316 | EXPECT_FALSE( |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 1317 | channel1_->SetLocalContent(content.get(), SdpType::kAnswer, err)); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1318 | |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 1319 | media_send_channel1_impl()->set_fail_set_send_codecs(true); |
| Steve Anton | 18ee1d5 | 2017-09-11 18:32:35 | [diff] [blame] | 1320 | EXPECT_FALSE( |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 1321 | channel1_->SetRemoteContent(content.get(), SdpType::kOffer, err)); |
| Steve Anton | 18ee1d5 | 2017-09-11 18:32:35 | [diff] [blame] | 1322 | |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 1323 | media_send_channel1_impl()->set_fail_set_send_codecs(true); |
| Steve Anton | 18ee1d5 | 2017-09-11 18:32:35 | [diff] [blame] | 1324 | EXPECT_FALSE( |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 1325 | channel1_->SetRemoteContent(content.get(), SdpType::kAnswer, err)); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1326 | } |
| 1327 | |
| 1328 | void TestSendTwoOffers() { |
| 1329 | CreateChannels(0, 0); |
| 1330 | |
| Peter Thatcher | a6d2444 | 2015-07-10 04:26:36 | [diff] [blame] | 1331 | std::string err; |
| Steve Anton | 18ee1d5 | 2017-09-11 18:32:35 | [diff] [blame] | 1332 | std::unique_ptr<typename T::Content> content1( |
| 1333 | CreateMediaContentWithStream(1)); |
| 1334 | EXPECT_TRUE( |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 1335 | channel1_->SetLocalContent(content1.get(), SdpType::kOffer, err)); |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 1336 | EXPECT_TRUE(media_send_channel1_impl()->HasSendStream(1)); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1337 | |
| Steve Anton | 18ee1d5 | 2017-09-11 18:32:35 | [diff] [blame] | 1338 | std::unique_ptr<typename T::Content> content2( |
| 1339 | CreateMediaContentWithStream(2)); |
| 1340 | EXPECT_TRUE( |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 1341 | channel1_->SetLocalContent(content2.get(), SdpType::kOffer, err)); |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 1342 | EXPECT_FALSE(media_send_channel1_impl()->HasSendStream(1)); |
| 1343 | EXPECT_TRUE(media_send_channel1_impl()->HasSendStream(2)); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1344 | } |
| 1345 | |
| 1346 | void TestReceiveTwoOffers() { |
| 1347 | CreateChannels(0, 0); |
| 1348 | |
| Peter Thatcher | a6d2444 | 2015-07-10 04:26:36 | [diff] [blame] | 1349 | std::string err; |
| Steve Anton | 18ee1d5 | 2017-09-11 18:32:35 | [diff] [blame] | 1350 | std::unique_ptr<typename T::Content> content1( |
| 1351 | CreateMediaContentWithStream(1)); |
| 1352 | EXPECT_TRUE( |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 1353 | channel1_->SetRemoteContent(content1.get(), SdpType::kOffer, err)); |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 1354 | EXPECT_TRUE(media_receive_channel1_impl()->HasRecvStream(1)); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1355 | |
| Steve Anton | 18ee1d5 | 2017-09-11 18:32:35 | [diff] [blame] | 1356 | std::unique_ptr<typename T::Content> content2( |
| 1357 | CreateMediaContentWithStream(2)); |
| 1358 | EXPECT_TRUE( |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 1359 | channel1_->SetRemoteContent(content2.get(), SdpType::kOffer, err)); |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 1360 | EXPECT_FALSE(media_receive_channel1_impl()->HasRecvStream(1)); |
| 1361 | EXPECT_TRUE(media_receive_channel1_impl()->HasRecvStream(2)); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1362 | } |
| 1363 | |
| 1364 | void TestSendPrAnswer() { |
| 1365 | CreateChannels(0, 0); |
| 1366 | |
| Peter Thatcher | a6d2444 | 2015-07-10 04:26:36 | [diff] [blame] | 1367 | std::string err; |
| 1368 | // Receive offer |
| Steve Anton | 18ee1d5 | 2017-09-11 18:32:35 | [diff] [blame] | 1369 | std::unique_ptr<typename T::Content> content1( |
| 1370 | CreateMediaContentWithStream(1)); |
| 1371 | EXPECT_TRUE( |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 1372 | channel1_->SetRemoteContent(content1.get(), SdpType::kOffer, err)); |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 1373 | EXPECT_TRUE(media_receive_channel1_impl()->HasRecvStream(1)); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1374 | |
| Peter Thatcher | a6d2444 | 2015-07-10 04:26:36 | [diff] [blame] | 1375 | // Send PR answer |
| Steve Anton | 18ee1d5 | 2017-09-11 18:32:35 | [diff] [blame] | 1376 | std::unique_ptr<typename T::Content> content2( |
| 1377 | CreateMediaContentWithStream(2)); |
| 1378 | EXPECT_TRUE( |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 1379 | channel1_->SetLocalContent(content2.get(), SdpType::kPrAnswer, err)); |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 1380 | EXPECT_TRUE(media_receive_channel1_impl()->HasRecvStream(1)); |
| 1381 | EXPECT_TRUE(media_send_channel1_impl()->HasSendStream(2)); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1382 | |
| Peter Thatcher | a6d2444 | 2015-07-10 04:26:36 | [diff] [blame] | 1383 | // Send answer |
| Steve Anton | 18ee1d5 | 2017-09-11 18:32:35 | [diff] [blame] | 1384 | std::unique_ptr<typename T::Content> content3( |
| 1385 | CreateMediaContentWithStream(3)); |
| 1386 | EXPECT_TRUE( |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 1387 | channel1_->SetLocalContent(content3.get(), SdpType::kAnswer, err)); |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 1388 | EXPECT_TRUE(media_receive_channel1_impl()->HasRecvStream(1)); |
| 1389 | EXPECT_FALSE(media_send_channel1_impl()->HasSendStream(2)); |
| 1390 | EXPECT_TRUE(media_send_channel1_impl()->HasSendStream(3)); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1391 | } |
| 1392 | |
| 1393 | void TestReceivePrAnswer() { |
| 1394 | CreateChannels(0, 0); |
| 1395 | |
| Peter Thatcher | a6d2444 | 2015-07-10 04:26:36 | [diff] [blame] | 1396 | std::string err; |
| 1397 | // Send offer |
| Steve Anton | 18ee1d5 | 2017-09-11 18:32:35 | [diff] [blame] | 1398 | std::unique_ptr<typename T::Content> content1( |
| 1399 | CreateMediaContentWithStream(1)); |
| 1400 | EXPECT_TRUE( |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 1401 | channel1_->SetLocalContent(content1.get(), SdpType::kOffer, err)); |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 1402 | EXPECT_TRUE(media_send_channel1_impl()->HasSendStream(1)); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1403 | |
| Peter Thatcher | a6d2444 | 2015-07-10 04:26:36 | [diff] [blame] | 1404 | // Receive PR answer |
| Steve Anton | 18ee1d5 | 2017-09-11 18:32:35 | [diff] [blame] | 1405 | std::unique_ptr<typename T::Content> content2( |
| 1406 | CreateMediaContentWithStream(2)); |
| Steve Anton | 3828c06 | 2017-12-06 18:34:51 | [diff] [blame] | 1407 | EXPECT_TRUE( |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 1408 | channel1_->SetRemoteContent(content2.get(), SdpType::kPrAnswer, err)); |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 1409 | EXPECT_TRUE(media_send_channel1_impl()->HasSendStream(1)); |
| 1410 | EXPECT_TRUE(media_receive_channel1_impl()->HasRecvStream(2)); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1411 | |
| Peter Thatcher | a6d2444 | 2015-07-10 04:26:36 | [diff] [blame] | 1412 | // Receive answer |
| Steve Anton | 18ee1d5 | 2017-09-11 18:32:35 | [diff] [blame] | 1413 | std::unique_ptr<typename T::Content> content3( |
| 1414 | CreateMediaContentWithStream(3)); |
| 1415 | EXPECT_TRUE( |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 1416 | channel1_->SetRemoteContent(content3.get(), SdpType::kAnswer, err)); |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 1417 | EXPECT_TRUE(media_send_channel1_impl()->HasSendStream(1)); |
| 1418 | EXPECT_FALSE(media_receive_channel1_impl()->HasRecvStream(2)); |
| 1419 | EXPECT_TRUE(media_receive_channel1_impl()->HasRecvStream(3)); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1420 | } |
| 1421 | |
| zstein | 56162b9 | 2017-04-24 23:54:35 | [diff] [blame] | 1422 | void TestOnTransportReadyToSend() { |
| deadbeef | ac22f70 | 2017-01-13 05:59:29 | [diff] [blame] | 1423 | CreateChannels(0, 0); |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 1424 | EXPECT_FALSE(media_send_channel1_impl()->ready_to_send()); |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 1425 | |
| Tomas Gunnarsson | ad32586 | 2021-02-03 15:23:40 | [diff] [blame] | 1426 | network_thread_->PostTask( |
| Henrik Boström | 2deee4b | 2022-01-20 10:58:05 | [diff] [blame] | 1427 | [this] { channel1_->OnTransportReadyToSend(true); }); |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 1428 | WaitForThreads(); |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 1429 | EXPECT_TRUE(media_send_channel1_impl()->ready_to_send()); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1430 | |
| Tomas Gunnarsson | ad32586 | 2021-02-03 15:23:40 | [diff] [blame] | 1431 | network_thread_->PostTask( |
| Henrik Boström | 2deee4b | 2022-01-20 10:58:05 | [diff] [blame] | 1432 | [this] { channel1_->OnTransportReadyToSend(false); }); |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 1433 | WaitForThreads(); |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 1434 | EXPECT_FALSE(media_send_channel1_impl()->ready_to_send()); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1435 | } |
| 1436 | |
| skvlad | dc1c62c | 2016-03-17 02:07:43 | [diff] [blame] | 1437 | bool SetRemoteContentWithBitrateLimit(int remote_limit) { |
| 1438 | typename T::Content content; |
| 1439 | CreateContent(0, kPcmuCodec, kH264Codec, &content); |
| 1440 | content.set_bandwidth(remote_limit); |
| Steve Anton | 3828c06 | 2017-12-06 18:34:51 | [diff] [blame] | 1441 | return channel1_->SetRemoteContent(&content, SdpType::kOffer, NULL); |
| skvlad | dc1c62c | 2016-03-17 02:07:43 | [diff] [blame] | 1442 | } |
| 1443 | |
| Florent Castelli | 8037fc6 | 2024-08-29 13:00:40 | [diff] [blame] | 1444 | webrtc::RtpParameters BitrateLimitedParameters(std::optional<int> limit) { |
| skvlad | dc1c62c | 2016-03-17 02:07:43 | [diff] [blame] | 1445 | webrtc::RtpParameters parameters; |
| 1446 | webrtc::RtpEncodingParameters encoding; |
| Mirko Bonadei | 05cf6be | 2019-01-31 20:38:12 | [diff] [blame] | 1447 | encoding.max_bitrate_bps = limit; |
| skvlad | dc1c62c | 2016-03-17 02:07:43 | [diff] [blame] | 1448 | parameters.encodings.push_back(encoding); |
| 1449 | return parameters; |
| 1450 | } |
| 1451 | |
| 1452 | void VerifyMaxBitrate(const webrtc::RtpParameters& parameters, |
| Florent Castelli | 8037fc6 | 2024-08-29 13:00:40 | [diff] [blame] | 1453 | std::optional<int> expected_bitrate) { |
| skvlad | dc1c62c | 2016-03-17 02:07:43 | [diff] [blame] | 1454 | EXPECT_EQ(1UL, parameters.encodings.size()); |
| 1455 | EXPECT_EQ(expected_bitrate, parameters.encodings[0].max_bitrate_bps); |
| 1456 | } |
| 1457 | |
| 1458 | void DefaultMaxBitrateIsUnlimited() { |
| 1459 | CreateChannels(0, 0); |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 1460 | std::string err; |
| Steve Anton | 3828c06 | 2017-12-06 18:34:51 | [diff] [blame] | 1461 | EXPECT_TRUE(channel1_->SetLocalContent(&local_media_content1_, |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 1462 | SdpType::kOffer, err)); |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 1463 | EXPECT_EQ(media_send_channel1_impl()->max_bps(), -1); |
| Harald Alvestrand | 36fafc8 | 2022-12-08 08:47:42 | [diff] [blame] | 1464 | VerifyMaxBitrate(media_send_channel1()->GetRtpSendParameters(kSsrc1), |
| Florent Castelli | 8037fc6 | 2024-08-29 13:00:40 | [diff] [blame] | 1465 | std::nullopt); |
| skvlad | dc1c62c | 2016-03-17 02:07:43 | [diff] [blame] | 1466 | } |
| 1467 | |
| Zhi Huang | e830e68 | 2018-03-30 17:48:35 | [diff] [blame] | 1468 | // Test that when a channel gets new RtpTransport with a call to |
| Artem Titov | 880fa81 | 2021-07-30 20:30:23 | [diff] [blame] | 1469 | // `SetRtpTransport`, the socket options from the old RtpTransport is merged |
| Zhi Huang | e830e68 | 2018-03-30 17:48:35 | [diff] [blame] | 1470 | // with the options on the new one. |
| 1471 | |
| Steve Anton | 8a63f78 | 2017-10-23 20:08:53 | [diff] [blame] | 1472 | // For example, audio and video may use separate socket options, but initially |
| 1473 | // be unbundled, then later become bundled. When this happens, their preferred |
| 1474 | // socket options should be merged to the underlying transport they share. |
| 1475 | void SocketOptionsMergedOnSetTransport() { |
| 1476 | constexpr int kSndBufSize = 4000; |
| 1477 | constexpr int kRcvBufSize = 8000; |
| 1478 | |
| Zhi Huang | e830e68 | 2018-03-30 17:48:35 | [diff] [blame] | 1479 | CreateChannels(DTLS, DTLS); |
| Steve Anton | 8a63f78 | 2017-10-23 20:08:53 | [diff] [blame] | 1480 | |
| Niels Möller | 9243088 | 2021-03-18 09:03:19 | [diff] [blame] | 1481 | bool rcv_success, send_success; |
| 1482 | int rcv_buf, send_buf; |
| Danil Chapovalov | 2aaef45 | 2022-08-12 13:55:11 | [diff] [blame] | 1483 | SendTask(network_thread_, [&] { |
| Per K | f4aadf3 | 2024-02-27 08:01:15 | [diff] [blame] | 1484 | new_rtp_transport_ = CreateDtlsSrtpTransport( |
| 1485 | fake_rtp_dtls_transport2_.get(), fake_rtcp_dtls_transport2_.get()); |
| Evan Shrubsole | 3c825f1 | 2025-04-04 14:07:27 | [diff] [blame] | 1486 | channel1_->SetOption(webrtc::BaseChannel::ST_RTP, |
| Evan Shrubsole | 03b6880 | 2025-03-18 12:23:05 | [diff] [blame] | 1487 | webrtc::Socket::Option::OPT_SNDBUF, kSndBufSize); |
| Evan Shrubsole | 3c825f1 | 2025-04-04 14:07:27 | [diff] [blame] | 1488 | channel2_->SetOption(webrtc::BaseChannel::ST_RTP, |
| Evan Shrubsole | 03b6880 | 2025-03-18 12:23:05 | [diff] [blame] | 1489 | webrtc::Socket::Option::OPT_RCVBUF, kRcvBufSize); |
| Tomas Gunnarsson | d9a51b0 | 2021-04-02 15:42:02 | [diff] [blame] | 1490 | channel1_->SetRtpTransport(new_rtp_transport_.get()); |
| Niels Möller | 9243088 | 2021-03-18 09:03:19 | [diff] [blame] | 1491 | send_success = fake_rtp_dtls_transport2_->GetOption( |
| Evan Shrubsole | 03b6880 | 2025-03-18 12:23:05 | [diff] [blame] | 1492 | webrtc::Socket::Option::OPT_SNDBUF, &send_buf); |
| Niels Möller | 9243088 | 2021-03-18 09:03:19 | [diff] [blame] | 1493 | rcv_success = fake_rtp_dtls_transport2_->GetOption( |
| Evan Shrubsole | 03b6880 | 2025-03-18 12:23:05 | [diff] [blame] | 1494 | webrtc::Socket::Option::OPT_RCVBUF, &rcv_buf); |
| Niels Möller | 9243088 | 2021-03-18 09:03:19 | [diff] [blame] | 1495 | }); |
| 1496 | |
| 1497 | ASSERT_TRUE(send_success); |
| 1498 | EXPECT_EQ(kSndBufSize, send_buf); |
| 1499 | ASSERT_TRUE(rcv_success); |
| 1500 | EXPECT_EQ(kRcvBufSize, rcv_buf); |
| Steve Anton | 8a63f78 | 2017-10-23 20:08:53 | [diff] [blame] | 1501 | } |
| 1502 | |
| Amit Hilbuch | bcd39d4 | 2019-01-26 01:13:56 | [diff] [blame] | 1503 | void CreateSimulcastContent(const std::vector<std::string>& rids, |
| 1504 | typename T::Content* content) { |
| 1505 | std::vector<RidDescription> rid_descriptions; |
| Courtney Edwards | 134c699 | 2020-03-03 10:36:35 | [diff] [blame] | 1506 | for (const std::string& name : rids) { |
| Amit Hilbuch | bcd39d4 | 2019-01-26 01:13:56 | [diff] [blame] | 1507 | rid_descriptions.push_back(RidDescription(name, RidDirection::kSend)); |
| 1508 | } |
| 1509 | |
| 1510 | StreamParams stream; |
| 1511 | stream.set_rids(rid_descriptions); |
| 1512 | CreateContent(0, kPcmuCodec, kH264Codec, content); |
| 1513 | // This is for unified plan, so there can be only one StreamParams. |
| 1514 | content->mutable_streams().clear(); |
| 1515 | content->AddStream(stream); |
| 1516 | } |
| 1517 | |
| 1518 | void VerifySimulcastStreamParams(const StreamParams& expected, |
| 1519 | const typename T::Channel* channel) { |
| 1520 | const std::vector<StreamParams>& streams = channel->local_streams(); |
| 1521 | ASSERT_EQ(1u, streams.size()); |
| 1522 | const StreamParams& result = streams[0]; |
| 1523 | EXPECT_EQ(expected.rids(), result.rids()); |
| 1524 | EXPECT_TRUE(result.has_ssrcs()); |
| 1525 | EXPECT_EQ(expected.rids().size() * 2, result.ssrcs.size()); |
| 1526 | std::vector<uint32_t> primary_ssrcs; |
| 1527 | result.GetPrimarySsrcs(&primary_ssrcs); |
| 1528 | EXPECT_EQ(expected.rids().size(), primary_ssrcs.size()); |
| 1529 | } |
| 1530 | |
| 1531 | void TestUpdateLocalStreamsWithSimulcast() { |
| 1532 | CreateChannels(0, 0); |
| 1533 | typename T::Content content1, content2, content3; |
| 1534 | CreateSimulcastContent({"f", "h", "q"}, &content1); |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 1535 | std::string err; |
| 1536 | EXPECT_TRUE(channel1_->SetLocalContent(&content1, SdpType::kOffer, err)); |
| Amit Hilbuch | bcd39d4 | 2019-01-26 01:13:56 | [diff] [blame] | 1537 | VerifySimulcastStreamParams(content1.streams()[0], channel1_.get()); |
| 1538 | StreamParams stream1 = channel1_->local_streams()[0]; |
| 1539 | |
| 1540 | // Create a similar offer. SetLocalContent should not remove and add. |
| 1541 | CreateSimulcastContent({"f", "h", "q"}, &content2); |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 1542 | EXPECT_TRUE(channel1_->SetLocalContent(&content2, SdpType::kOffer, err)); |
| Amit Hilbuch | bcd39d4 | 2019-01-26 01:13:56 | [diff] [blame] | 1543 | VerifySimulcastStreamParams(content2.streams()[0], channel1_.get()); |
| 1544 | StreamParams stream2 = channel1_->local_streams()[0]; |
| 1545 | // Check that the streams are identical (SSRCs didn't change). |
| 1546 | EXPECT_EQ(stream1, stream2); |
| 1547 | |
| 1548 | // Create third offer that has same RIDs in different order. |
| 1549 | CreateSimulcastContent({"f", "q", "h"}, &content3); |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 1550 | EXPECT_TRUE(channel1_->SetLocalContent(&content3, SdpType::kOffer, err)); |
| Amit Hilbuch | bcd39d4 | 2019-01-26 01:13:56 | [diff] [blame] | 1551 | VerifySimulcastStreamParams(content3.streams()[0], channel1_.get()); |
| 1552 | } |
| 1553 | |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1554 | protected: |
| Evan Shrubsole | e6a1f70 | 2025-04-15 14:55:42 | [diff] [blame] | 1555 | void WaitForThreads() { |
| 1556 | WaitForThreads(webrtc::ArrayView<webrtc::Thread*>()); |
| 1557 | } |
| Evan Shrubsole | 6a9a1ae | 2025-03-21 12:54:15 | [diff] [blame] | 1558 | static void ProcessThreadQueue(webrtc::Thread* thread) { |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 1559 | RTC_DCHECK(thread->IsCurrent()); |
| 1560 | while (!thread->empty()) { |
| 1561 | thread->ProcessMessages(0); |
| 1562 | } |
| 1563 | } |
| Tommi | 1959f8f | 2021-04-26 08:20:19 | [diff] [blame] | 1564 | static void FlushCurrentThread() { |
| Evan Shrubsole | 6a9a1ae | 2025-03-21 12:54:15 | [diff] [blame] | 1565 | webrtc::Thread::Current()->ProcessMessages(0); |
| Tommi | 1959f8f | 2021-04-26 08:20:19 | [diff] [blame] | 1566 | } |
| Evan Shrubsole | e6a1f70 | 2025-04-15 14:55:42 | [diff] [blame] | 1567 | void WaitForThreads(webrtc::ArrayView<webrtc::Thread*> threads) { |
| Artem Titov | 880fa81 | 2021-07-30 20:30:23 | [diff] [blame] | 1568 | // `threads` and current thread post packets to network thread. |
| Evan Shrubsole | e6a1f70 | 2025-04-15 14:55:42 | [diff] [blame] | 1569 | for (webrtc::Thread* thread : threads) { |
| Danil Chapovalov | 2aaef45 | 2022-08-12 13:55:11 | [diff] [blame] | 1570 | SendTask(thread, [thread] { ProcessThreadQueue(thread); }); |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 1571 | } |
| Evan Shrubsole | 6a9a1ae | 2025-03-21 12:54:15 | [diff] [blame] | 1572 | ProcessThreadQueue(webrtc::Thread::Current()); |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 1573 | // Network thread move them around and post back to worker = current thread. |
| 1574 | if (!network_thread_->IsCurrent()) { |
| Danil Chapovalov | 2aaef45 | 2022-08-12 13:55:11 | [diff] [blame] | 1575 | SendTask(network_thread_, |
| 1576 | [this] { ProcessThreadQueue(network_thread_); }); |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 1577 | } |
| 1578 | // Worker thread = current Thread process received messages. |
| Evan Shrubsole | 6a9a1ae | 2025-03-21 12:54:15 | [diff] [blame] | 1579 | ProcessThreadQueue(webrtc::Thread::Current()); |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 1580 | } |
| Tommi | c9625f0 | 2021-05-06 20:03:19 | [diff] [blame] | 1581 | |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 1582 | // Accessors that return the standard VideoMedia{Send|Receive}ChannelInterface |
| Florent Castelli | 1f31c20 | 2023-06-26 00:26:07 | [diff] [blame] | 1583 | typename T::MediaSendChannelInterface* media_send_channel1() { |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 1584 | return channel1_->media_send_channel(); |
| 1585 | } |
| Florent Castelli | 1f31c20 | 2023-06-26 00:26:07 | [diff] [blame] | 1586 | typename T::MediaSendChannelInterface* media_send_channel2() { |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 1587 | return channel2_->media_send_channel(); |
| 1588 | } |
| Florent Castelli | 1f31c20 | 2023-06-26 00:26:07 | [diff] [blame] | 1589 | typename T::MediaReceiveChannelInterface* media_receive_channel1() { |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 1590 | return channel1_->media_receive_channel(); |
| 1591 | } |
| Florent Castelli | 1f31c20 | 2023-06-26 00:26:07 | [diff] [blame] | 1592 | typename T::MediaReceiveChannelInterface* media_receive_channel2() { |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 1593 | return channel2_->media_receive_channel(); |
| 1594 | } |
| 1595 | |
| Florent Castelli | 1f31c20 | 2023-06-26 00:26:07 | [diff] [blame] | 1596 | // Accessors that return the FakeMedia<type>SendChannel object. |
| Harald Alvestrand | 50454ef | 2022-12-15 16:49:13 | [diff] [blame] | 1597 | // Note that these depend on getting the object back that was |
| 1598 | // passed to the channel constructor. |
| Florent Castelli | 1f31c20 | 2023-06-26 00:26:07 | [diff] [blame] | 1599 | // T::MediaSendChannel is either FakeVoiceMediaSendChannel or |
| 1600 | // FakeVideoMediaSendChannel. |
| 1601 | typename T::MediaSendChannel* media_send_channel1_impl() { |
| Harald Alvestrand | 50454ef | 2022-12-15 16:49:13 | [diff] [blame] | 1602 | RTC_DCHECK(channel1_); |
| Florent Castelli | 1f31c20 | 2023-06-26 00:26:07 | [diff] [blame] | 1603 | return static_cast<typename T::MediaSendChannel*>( |
| Harald Alvestrand | 847208e | 2023-06-06 09:45:45 | [diff] [blame] | 1604 | channel1_->media_send_channel()); |
| Harald Alvestrand | 50454ef | 2022-12-15 16:49:13 | [diff] [blame] | 1605 | } |
| 1606 | |
| Florent Castelli | 1f31c20 | 2023-06-26 00:26:07 | [diff] [blame] | 1607 | typename T::MediaSendChannel* media_send_channel2_impl() { |
| Harald Alvestrand | 50454ef | 2022-12-15 16:49:13 | [diff] [blame] | 1608 | RTC_DCHECK(channel2_); |
| Harald Alvestrand | 36fafc8 | 2022-12-08 08:47:42 | [diff] [blame] | 1609 | RTC_DCHECK(channel2_->media_send_channel()); |
| Florent Castelli | 1f31c20 | 2023-06-26 00:26:07 | [diff] [blame] | 1610 | return static_cast<typename T::MediaSendChannel*>( |
| Harald Alvestrand | 847208e | 2023-06-06 09:45:45 | [diff] [blame] | 1611 | channel2_->media_send_channel()); |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 1612 | } |
| Florent Castelli | 1f31c20 | 2023-06-26 00:26:07 | [diff] [blame] | 1613 | typename T::MediaReceiveChannel* media_receive_channel1_impl() { |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 1614 | RTC_DCHECK(channel1_); |
| 1615 | RTC_DCHECK(channel1_->media_receive_channel()); |
| Florent Castelli | 1f31c20 | 2023-06-26 00:26:07 | [diff] [blame] | 1616 | return static_cast<typename T::MediaReceiveChannel*>( |
| Harald Alvestrand | 847208e | 2023-06-06 09:45:45 | [diff] [blame] | 1617 | channel1_->media_receive_channel()); |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 1618 | } |
| 1619 | |
| Florent Castelli | 1f31c20 | 2023-06-26 00:26:07 | [diff] [blame] | 1620 | typename T::MediaReceiveChannel* media_receive_channel2_impl() { |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 1621 | RTC_DCHECK(channel2_); |
| 1622 | RTC_DCHECK(channel2_->media_receive_channel()); |
| Florent Castelli | 1f31c20 | 2023-06-26 00:26:07 | [diff] [blame] | 1623 | return static_cast<typename T::MediaReceiveChannel*>( |
| Harald Alvestrand | 847208e | 2023-06-06 09:45:45 | [diff] [blame] | 1624 | channel2_->media_receive_channel()); |
| Tommi | c9625f0 | 2021-05-06 20:03:19 | [diff] [blame] | 1625 | } |
| 1626 | |
| Evan Shrubsole | 6a9a1ae | 2025-03-21 12:54:15 | [diff] [blame] | 1627 | webrtc::AutoThread main_thread_; |
| Peter Boström | 34fbfff | 2015-09-24 17:20:30 | [diff] [blame] | 1628 | // TODO(pbos): Remove playout from all media channels and let renderers mute |
| 1629 | // themselves. |
| 1630 | const bool verify_playout_; |
| Evan Shrubsole | e6a1f70 | 2025-04-15 14:55:42 | [diff] [blame] | 1631 | webrtc::scoped_refptr<webrtc::PendingTaskSafetyFlag> network_thread_safety_ = |
| Tommi | c9625f0 | 2021-05-06 20:03:19 | [diff] [blame] | 1632 | webrtc::PendingTaskSafetyFlag::CreateDetached(); |
| Evan Shrubsole | 6a9a1ae | 2025-03-21 12:54:15 | [diff] [blame] | 1633 | std::unique_ptr<webrtc::Thread> network_thread_keeper_; |
| 1634 | webrtc::Thread* network_thread_; |
| Evan Shrubsole | e4b09d7 | 2025-03-17 13:25:49 | [diff] [blame] | 1635 | std::unique_ptr<webrtc::FakeDtlsTransport> fake_rtp_dtls_transport1_; |
| 1636 | std::unique_ptr<webrtc::FakeDtlsTransport> fake_rtcp_dtls_transport1_; |
| 1637 | std::unique_ptr<webrtc::FakeDtlsTransport> fake_rtp_dtls_transport2_; |
| 1638 | std::unique_ptr<webrtc::FakeDtlsTransport> fake_rtcp_dtls_transport2_; |
| Evan Shrubsole | c13956e | 2025-03-13 12:45:54 | [diff] [blame] | 1639 | std::unique_ptr<webrtc::FakePacketTransport> fake_rtp_packet_transport1_; |
| 1640 | std::unique_ptr<webrtc::FakePacketTransport> fake_rtcp_packet_transport1_; |
| 1641 | std::unique_ptr<webrtc::FakePacketTransport> fake_rtp_packet_transport2_; |
| 1642 | std::unique_ptr<webrtc::FakePacketTransport> fake_rtcp_packet_transport2_; |
| Zhi Huang | e830e68 | 2018-03-30 17:48:35 | [diff] [blame] | 1643 | std::unique_ptr<webrtc::RtpTransportInternal> rtp_transport1_; |
| 1644 | std::unique_ptr<webrtc::RtpTransportInternal> rtp_transport2_; |
| 1645 | std::unique_ptr<webrtc::RtpTransportInternal> new_rtp_transport_; |
| Evan Shrubsole | 945e517 | 2025-04-08 14:11:45 | [diff] [blame] | 1646 | webrtc::FakeMediaEngine media_engine_; |
| kwiberg | 3102294 | 2016-03-11 22:18:21 | [diff] [blame] | 1647 | std::unique_ptr<typename T::Channel> channel1_; |
| 1648 | std::unique_ptr<typename T::Channel> channel2_; |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1649 | typename T::Content local_media_content1_; |
| 1650 | typename T::Content local_media_content2_; |
| 1651 | typename T::Content remote_media_content1_; |
| 1652 | typename T::Content remote_media_content2_; |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1653 | // The RTP and RTCP packets to send in the tests. |
| Evan Shrubsole | e6a1f70 | 2025-04-15 14:55:42 | [diff] [blame] | 1654 | webrtc::Buffer rtp_packet_; |
| 1655 | webrtc::Buffer rtcp_packet_; |
| Evan Shrubsole | 945e517 | 2025-04-08 14:11:45 | [diff] [blame] | 1656 | webrtc::CandidatePairInterface* last_selected_candidate_pair_; |
| Evan Shrubsole | 5f8bcf9 | 2025-02-25 12:10:05 | [diff] [blame] | 1657 | webrtc::UniqueRandomIdGenerator ssrc_generator_; |
| Danil Chapovalov | 6e65ae3 | 2025-06-10 11:06:03 | [diff] [blame] | 1658 | FieldTrials field_trials_ = CreateTestFieldTrials(); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1659 | }; |
| 1660 | |
| Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 1661 | template <> |
| Evan Shrubsole | 3c825f1 | 2025-04-04 14:07:27 | [diff] [blame] | 1662 | std::unique_ptr<webrtc::VoiceChannel> ChannelTest<VoiceTraits>::CreateChannel( |
| Evan Shrubsole | 6a9a1ae | 2025-03-21 12:54:15 | [diff] [blame] | 1663 | webrtc::Thread* worker_thread, |
| 1664 | webrtc::Thread* network_thread, |
| Evan Shrubsole | 945e517 | 2025-04-08 14:11:45 | [diff] [blame] | 1665 | std::unique_ptr<webrtc::FakeVoiceMediaSendChannel> send_ch, |
| 1666 | std::unique_ptr<webrtc::FakeVoiceMediaReceiveChannel> receive_ch, |
| Sebastian Jansson | 1b83a9e | 2019-09-18 16:22:12 | [diff] [blame] | 1667 | webrtc::RtpTransportInternal* rtp_transport, |
| 1668 | int flags) { |
| Evan Shrubsole | 6a9a1ae | 2025-03-21 12:54:15 | [diff] [blame] | 1669 | webrtc::Thread* signaling_thread = webrtc::Thread::Current(); |
| Evan Shrubsole | 3c825f1 | 2025-04-04 14:07:27 | [diff] [blame] | 1670 | auto channel = std::make_unique<webrtc::VoiceChannel>( |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 1671 | worker_thread, network_thread, signaling_thread, std::move(send_ch), |
| Philipp Hancke | 643e216 | 2025-07-01 17:27:16 | [diff] [blame] | 1672 | std::move(receive_ch), kAudioMid, (flags & DTLS) != 0, |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 1673 | webrtc::CryptoOptions(), &ssrc_generator_); |
| Danil Chapovalov | 2aaef45 | 2022-08-12 13:55:11 | [diff] [blame] | 1674 | SendTask(network_thread, [&]() { |
| Tomas Gunnarsson | 1933d3b | 2022-01-17 10:25:21 | [diff] [blame] | 1675 | RTC_DCHECK_RUN_ON(channel->network_thread()); |
| Tomas Gunnarsson | 4f8a58c | 2022-01-19 10:36:23 | [diff] [blame] | 1676 | channel->SetRtpTransport(rtp_transport); |
| Tomas Gunnarsson | 1933d3b | 2022-01-17 10:25:21 | [diff] [blame] | 1677 | }); |
| Sebastian Jansson | 1b83a9e | 2019-09-18 16:22:12 | [diff] [blame] | 1678 | return channel; |
| 1679 | } |
| 1680 | |
| 1681 | template <> |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1682 | void ChannelTest<VoiceTraits>::CreateContent( |
| 1683 | int flags, |
| Evan Shrubsole | 0b212e3 | 2025-04-07 13:43:01 | [diff] [blame] | 1684 | const webrtc::Codec& audio_codec, |
| 1685 | const webrtc::Codec& video_codec, |
| Evan Shrubsole | 080cdac | 2025-03-20 09:34:48 | [diff] [blame] | 1686 | webrtc::AudioContentDescription* audio) { |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1687 | audio->AddCodec(audio_codec); |
| 1688 | audio->set_rtcp_mux((flags & RTCP_MUX) != 0); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1689 | } |
| 1690 | |
| Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 1691 | template <> |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1692 | void ChannelTest<VoiceTraits>::CopyContent( |
| Evan Shrubsole | 080cdac | 2025-03-20 09:34:48 | [diff] [blame] | 1693 | const webrtc::AudioContentDescription& source, |
| 1694 | webrtc::AudioContentDescription* audio) { |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1695 | *audio = source; |
| 1696 | } |
| 1697 | |
| Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 1698 | template <> |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1699 | void ChannelTest<VoiceTraits>::AddLegacyStreamInContent( |
| Peter Boström | 0c4e06b | 2015-10-07 10:23:21 | [diff] [blame] | 1700 | uint32_t ssrc, |
| 1701 | int flags, |
| Evan Shrubsole | 080cdac | 2025-03-20 09:34:48 | [diff] [blame] | 1702 | webrtc::AudioContentDescription* audio) { |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1703 | audio->AddLegacyStream(ssrc); |
| 1704 | } |
| 1705 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 1706 | class VoiceChannelSingleThreadTest : public ChannelTest<VoiceTraits> { |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1707 | public: |
| Harald Alvestrand | 3d09240 | 2025-05-05 13:32:53 | [diff] [blame] | 1708 | using Base = ChannelTest<VoiceTraits>; |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 1709 | VoiceChannelSingleThreadTest() |
| 1710 | : Base(true, kPcmuFrame, kRtcpReport, NetworkIsWorker::Yes) {} |
| 1711 | }; |
| 1712 | |
| 1713 | class VoiceChannelDoubleThreadTest : public ChannelTest<VoiceTraits> { |
| 1714 | public: |
| Harald Alvestrand | 3d09240 | 2025-05-05 13:32:53 | [diff] [blame] | 1715 | using Base = ChannelTest<VoiceTraits>; |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 1716 | VoiceChannelDoubleThreadTest() |
| 1717 | : Base(true, kPcmuFrame, kRtcpReport, NetworkIsWorker::No) {} |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1718 | }; |
| 1719 | |
| jbauch | 5869f50 | 2017-06-29 19:31:36 | [diff] [blame] | 1720 | class VoiceChannelWithEncryptedRtpHeaderExtensionsSingleThreadTest |
| Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 1721 | : public ChannelTest<VoiceTraits> { |
| jbauch | 5869f50 | 2017-06-29 19:31:36 | [diff] [blame] | 1722 | public: |
| Harald Alvestrand | 3d09240 | 2025-05-05 13:32:53 | [diff] [blame] | 1723 | using Base = ChannelTest<VoiceTraits>; |
| jbauch | 5869f50 | 2017-06-29 19:31:36 | [diff] [blame] | 1724 | VoiceChannelWithEncryptedRtpHeaderExtensionsSingleThreadTest() |
| Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 1725 | : Base(true, |
| 1726 | kPcmuFrameWithExtensions, |
| 1727 | kRtcpReport, |
| 1728 | NetworkIsWorker::Yes) {} |
| jbauch | 5869f50 | 2017-06-29 19:31:36 | [diff] [blame] | 1729 | }; |
| 1730 | |
| 1731 | class VoiceChannelWithEncryptedRtpHeaderExtensionsDoubleThreadTest |
| Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 1732 | : public ChannelTest<VoiceTraits> { |
| jbauch | 5869f50 | 2017-06-29 19:31:36 | [diff] [blame] | 1733 | public: |
| Harald Alvestrand | 3d09240 | 2025-05-05 13:32:53 | [diff] [blame] | 1734 | using Base = ChannelTest<VoiceTraits>; |
| jbauch | 5869f50 | 2017-06-29 19:31:36 | [diff] [blame] | 1735 | VoiceChannelWithEncryptedRtpHeaderExtensionsDoubleThreadTest() |
| Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 1736 | : Base(true, kPcmuFrameWithExtensions, kRtcpReport, NetworkIsWorker::No) { |
| 1737 | } |
| jbauch | 5869f50 | 2017-06-29 19:31:36 | [diff] [blame] | 1738 | }; |
| 1739 | |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1740 | // override to add NULL parameter |
| deadbeef | cbecd35 | 2015-09-23 18:50:27 | [diff] [blame] | 1741 | template <> |
| Evan Shrubsole | 3c825f1 | 2025-04-04 14:07:27 | [diff] [blame] | 1742 | std::unique_ptr<webrtc::VideoChannel> ChannelTest<VideoTraits>::CreateChannel( |
| Evan Shrubsole | 6a9a1ae | 2025-03-21 12:54:15 | [diff] [blame] | 1743 | webrtc::Thread* worker_thread, |
| 1744 | webrtc::Thread* network_thread, |
| Evan Shrubsole | 945e517 | 2025-04-08 14:11:45 | [diff] [blame] | 1745 | std::unique_ptr<webrtc::FakeVideoMediaSendChannel> send_ch, |
| 1746 | std::unique_ptr<webrtc::FakeVideoMediaReceiveChannel> receive_ch, |
| Zhi Huang | e830e68 | 2018-03-30 17:48:35 | [diff] [blame] | 1747 | webrtc::RtpTransportInternal* rtp_transport, |
| jbauch | cb56065 | 2016-08-04 12:20:32 | [diff] [blame] | 1748 | int flags) { |
| Evan Shrubsole | 6a9a1ae | 2025-03-21 12:54:15 | [diff] [blame] | 1749 | webrtc::Thread* signaling_thread = webrtc::Thread::Current(); |
| Evan Shrubsole | 3c825f1 | 2025-04-04 14:07:27 | [diff] [blame] | 1750 | auto channel = std::make_unique<webrtc::VideoChannel>( |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 1751 | worker_thread, network_thread, signaling_thread, std::move(send_ch), |
| Philipp Hancke | 643e216 | 2025-07-01 17:27:16 | [diff] [blame] | 1752 | std::move(receive_ch), kVideoMid, (flags & DTLS) != 0, |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 1753 | webrtc::CryptoOptions(), &ssrc_generator_); |
| Danil Chapovalov | 2aaef45 | 2022-08-12 13:55:11 | [diff] [blame] | 1754 | SendTask(network_thread, [&]() { |
| Tomas Gunnarsson | 1933d3b | 2022-01-17 10:25:21 | [diff] [blame] | 1755 | RTC_DCHECK_RUN_ON(channel->network_thread()); |
| Tomas Gunnarsson | 4f8a58c | 2022-01-19 10:36:23 | [diff] [blame] | 1756 | channel->SetRtpTransport(rtp_transport); |
| Tomas Gunnarsson | 1933d3b | 2022-01-17 10:25:21 | [diff] [blame] | 1757 | }); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1758 | return channel; |
| 1759 | } |
| 1760 | |
| Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 1761 | template <> |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1762 | void ChannelTest<VideoTraits>::CreateContent( |
| 1763 | int flags, |
| Evan Shrubsole | 0b212e3 | 2025-04-07 13:43:01 | [diff] [blame] | 1764 | const webrtc::Codec& audio_codec, |
| 1765 | const webrtc::Codec& video_codec, |
| Evan Shrubsole | 080cdac | 2025-03-20 09:34:48 | [diff] [blame] | 1766 | webrtc::VideoContentDescription* video) { |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1767 | video->AddCodec(video_codec); |
| 1768 | video->set_rtcp_mux((flags & RTCP_MUX) != 0); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1769 | } |
| 1770 | |
| Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 1771 | template <> |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1772 | void ChannelTest<VideoTraits>::CopyContent( |
| Evan Shrubsole | 080cdac | 2025-03-20 09:34:48 | [diff] [blame] | 1773 | const webrtc::VideoContentDescription& source, |
| 1774 | webrtc::VideoContentDescription* video) { |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1775 | *video = source; |
| 1776 | } |
| 1777 | |
| Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 1778 | template <> |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1779 | void ChannelTest<VideoTraits>::AddLegacyStreamInContent( |
| Peter Boström | 0c4e06b | 2015-10-07 10:23:21 | [diff] [blame] | 1780 | uint32_t ssrc, |
| 1781 | int flags, |
| Evan Shrubsole | 080cdac | 2025-03-20 09:34:48 | [diff] [blame] | 1782 | webrtc::VideoContentDescription* video) { |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1783 | video->AddLegacyStream(ssrc); |
| 1784 | } |
| 1785 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 1786 | class VideoChannelSingleThreadTest : public ChannelTest<VideoTraits> { |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1787 | public: |
| Harald Alvestrand | 3d09240 | 2025-05-05 13:32:53 | [diff] [blame] | 1788 | using Base = ChannelTest<VideoTraits>; |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 1789 | VideoChannelSingleThreadTest() |
| 1790 | : Base(false, kH264Packet, kRtcpReport, NetworkIsWorker::Yes) {} |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1791 | }; |
| 1792 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 1793 | class VideoChannelDoubleThreadTest : public ChannelTest<VideoTraits> { |
| 1794 | public: |
| Harald Alvestrand | 3d09240 | 2025-05-05 13:32:53 | [diff] [blame] | 1795 | using Base = ChannelTest<VideoTraits>; |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 1796 | VideoChannelDoubleThreadTest() |
| 1797 | : Base(false, kH264Packet, kRtcpReport, NetworkIsWorker::No) {} |
| 1798 | }; |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1799 | |
| Kári Tristan Helgason | 8b35df7 | 2017-09-25 12:46:43 | [diff] [blame] | 1800 | TEST_F(VoiceChannelSingleThreadTest, TestInit) { |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1801 | Base::TestInit(); |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 1802 | EXPECT_FALSE(media_send_channel1_impl()->IsStreamMuted(0)); |
| 1803 | EXPECT_TRUE(media_send_channel1_impl()->dtmf_info_queue().empty()); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1804 | } |
| 1805 | |
| Danil Chapovalov | dae07ba | 2016-05-13 23:43:50 | [diff] [blame] | 1806 | TEST_F(VoiceChannelSingleThreadTest, TestDeinit) { |
| 1807 | Base::TestDeinit(); |
| 1808 | } |
| 1809 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 1810 | TEST_F(VoiceChannelSingleThreadTest, TestSetContents) { |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1811 | Base::TestSetContents(); |
| 1812 | } |
| 1813 | |
| Johannes Kron | 9190b82 | 2018-10-29 10:22:05 | [diff] [blame] | 1814 | TEST_F(VoiceChannelSingleThreadTest, TestSetContentsExtmapAllowMixedAsCaller) { |
| 1815 | Base::TestSetContentsExtmapAllowMixedCaller(/*offer=*/true, /*answer=*/true); |
| 1816 | } |
| 1817 | |
| 1818 | TEST_F(VoiceChannelSingleThreadTest, |
| 1819 | TestSetContentsExtmapAllowMixedNotSupportedAsCaller) { |
| 1820 | Base::TestSetContentsExtmapAllowMixedCaller(/*offer=*/true, /*answer=*/false); |
| 1821 | } |
| 1822 | |
| 1823 | TEST_F(VoiceChannelSingleThreadTest, TestSetContentsExtmapAllowMixedAsCallee) { |
| 1824 | Base::TestSetContentsExtmapAllowMixedCallee(/*offer=*/true, /*answer=*/true); |
| 1825 | } |
| 1826 | |
| 1827 | TEST_F(VoiceChannelSingleThreadTest, |
| 1828 | TestSetContentsExtmapAllowMixedNotSupportedAsCallee) { |
| 1829 | Base::TestSetContentsExtmapAllowMixedCallee(/*offer=*/true, /*answer=*/false); |
| 1830 | } |
| 1831 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 1832 | TEST_F(VoiceChannelSingleThreadTest, TestSetContentsNullOffer) { |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1833 | Base::TestSetContentsNullOffer(); |
| 1834 | } |
| 1835 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 1836 | TEST_F(VoiceChannelSingleThreadTest, TestSetContentsRtcpMux) { |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1837 | Base::TestSetContentsRtcpMux(); |
| 1838 | } |
| 1839 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 1840 | TEST_F(VoiceChannelSingleThreadTest, TestSetContentsRtcpMuxWithPrAnswer) { |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1841 | Base::TestSetContentsRtcpMux(); |
| 1842 | } |
| 1843 | |
| Tomas Lundqvist | b40c559 | 2024-11-22 13:45:27 | [diff] [blame] | 1844 | TEST_F(VoiceChannelSingleThreadTest, TestSetContentsRtcpReducedSize) { |
| 1845 | Base::TestSetContentsRtcpReducedSize(); |
| 1846 | } |
| 1847 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 1848 | TEST_F(VoiceChannelSingleThreadTest, TestChangeStreamParamsInContent) { |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1849 | Base::TestChangeStreamParamsInContent(); |
| 1850 | } |
| 1851 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 1852 | TEST_F(VoiceChannelSingleThreadTest, TestPlayoutAndSendingStates) { |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1853 | Base::TestPlayoutAndSendingStates(); |
| 1854 | } |
| 1855 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 1856 | TEST_F(VoiceChannelSingleThreadTest, TestMediaContentDirection) { |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1857 | Base::TestMediaContentDirection(); |
| 1858 | } |
| 1859 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 1860 | TEST_F(VoiceChannelSingleThreadTest, TestNetworkRouteChanges) { |
| Honghai Zhang | cc411c0 | 2016-03-30 00:27:21 | [diff] [blame] | 1861 | Base::TestNetworkRouteChanges(); |
| 1862 | } |
| 1863 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 1864 | TEST_F(VoiceChannelSingleThreadTest, TestCallSetup) { |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1865 | Base::TestCallSetup(); |
| 1866 | } |
| 1867 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 1868 | TEST_F(VoiceChannelSingleThreadTest, SendRtpToRtp) { |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1869 | Base::SendRtpToRtp(); |
| 1870 | } |
| 1871 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 1872 | TEST_F(VoiceChannelSingleThreadTest, SendDtlsSrtpToDtlsSrtp) { |
| Zhi Huang | e830e68 | 2018-03-30 17:48:35 | [diff] [blame] | 1873 | Base::SendDtlsSrtpToDtlsSrtp(0, 0); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1874 | } |
| 1875 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 1876 | TEST_F(VoiceChannelSingleThreadTest, SendDtlsSrtpToDtlsSrtpRtcpMux) { |
| Zhi Huang | e830e68 | 2018-03-30 17:48:35 | [diff] [blame] | 1877 | Base::SendDtlsSrtpToDtlsSrtp(RTCP_MUX, RTCP_MUX); |
| deadbeef | f534659 | 2017-01-25 05:51:21 | [diff] [blame] | 1878 | } |
| 1879 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 1880 | TEST_F(VoiceChannelSingleThreadTest, SendEarlyMediaUsingRtcpMuxSrtp) { |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1881 | Base::SendEarlyMediaUsingRtcpMuxSrtp(); |
| 1882 | } |
| 1883 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 1884 | TEST_F(VoiceChannelSingleThreadTest, SendRtpToRtpOnThread) { |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1885 | Base::SendRtpToRtpOnThread(); |
| 1886 | } |
| 1887 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 1888 | TEST_F(VoiceChannelSingleThreadTest, SendWithWritabilityLoss) { |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1889 | Base::SendWithWritabilityLoss(); |
| 1890 | } |
| 1891 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 1892 | TEST_F(VoiceChannelSingleThreadTest, TestSetContentFailure) { |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1893 | Base::TestSetContentFailure(); |
| 1894 | } |
| 1895 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 1896 | TEST_F(VoiceChannelSingleThreadTest, TestSendTwoOffers) { |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1897 | Base::TestSendTwoOffers(); |
| 1898 | } |
| 1899 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 1900 | TEST_F(VoiceChannelSingleThreadTest, TestReceiveTwoOffers) { |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1901 | Base::TestReceiveTwoOffers(); |
| 1902 | } |
| 1903 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 1904 | TEST_F(VoiceChannelSingleThreadTest, TestSendPrAnswer) { |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1905 | Base::TestSendPrAnswer(); |
| 1906 | } |
| 1907 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 1908 | TEST_F(VoiceChannelSingleThreadTest, TestReceivePrAnswer) { |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1909 | Base::TestReceivePrAnswer(); |
| 1910 | } |
| 1911 | |
| zstein | 56162b9 | 2017-04-24 23:54:35 | [diff] [blame] | 1912 | TEST_F(VoiceChannelSingleThreadTest, TestOnTransportReadyToSend) { |
| 1913 | Base::TestOnTransportReadyToSend(); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1914 | } |
| 1915 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 1916 | TEST_F(VoiceChannelSingleThreadTest, SendBundleToBundle) { |
| Danil Chapovalov | 52c16dc | 2025-06-02 07:57:15 | [diff] [blame] | 1917 | Base::SendBundleToBundle(kAudioPts, false, false); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1918 | } |
| 1919 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 1920 | TEST_F(VoiceChannelSingleThreadTest, SendBundleToBundleSecure) { |
| Danil Chapovalov | 52c16dc | 2025-06-02 07:57:15 | [diff] [blame] | 1921 | Base::SendBundleToBundle(kAudioPts, false, true); |
| [email protected] | 5ee0f05 | 2014-05-05 20:18:08 | [diff] [blame] | 1922 | } |
| 1923 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 1924 | TEST_F(VoiceChannelSingleThreadTest, SendBundleToBundleWithRtcpMux) { |
| Danil Chapovalov | 52c16dc | 2025-06-02 07:57:15 | [diff] [blame] | 1925 | Base::SendBundleToBundle(kAudioPts, true, false); |
| [email protected] | 5ee0f05 | 2014-05-05 20:18:08 | [diff] [blame] | 1926 | } |
| 1927 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 1928 | TEST_F(VoiceChannelSingleThreadTest, SendBundleToBundleWithRtcpMuxSecure) { |
| Danil Chapovalov | 52c16dc | 2025-06-02 07:57:15 | [diff] [blame] | 1929 | Base::SendBundleToBundle(kAudioPts, true, true); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1930 | } |
| 1931 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 1932 | TEST_F(VoiceChannelSingleThreadTest, DefaultMaxBitrateIsUnlimited) { |
| skvlad | e0d4637 | 2016-04-08 05:59:22 | [diff] [blame] | 1933 | Base::DefaultMaxBitrateIsUnlimited(); |
| skvlad | dc1c62c | 2016-03-17 02:07:43 | [diff] [blame] | 1934 | } |
| 1935 | |
| Steve Anton | 8a63f78 | 2017-10-23 20:08:53 | [diff] [blame] | 1936 | TEST_F(VoiceChannelSingleThreadTest, SocketOptionsMergedOnSetTransport) { |
| 1937 | Base::SocketOptionsMergedOnSetTransport(); |
| 1938 | } |
| 1939 | |
| Per K | 38bb331 | 2025-08-19 13:46:24 | [diff] [blame] | 1940 | TEST_F(VoiceChannelSingleThreadTest, RemovesExtensionNotPresentInRemoteAnswer) { |
| 1941 | Base::TestRemovesExtensionNotPresentInRemoteAnswer(); |
| 1942 | } |
| 1943 | |
| 1944 | TEST_F(VoiceChannelSingleThreadTest, RemovesExtensionNotPresentInLocalAnswer) { |
| 1945 | Base::TestRemovesExtensionNotPresentInLocalAnswer(); |
| 1946 | } |
| 1947 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 1948 | // VoiceChannelDoubleThreadTest |
| 1949 | TEST_F(VoiceChannelDoubleThreadTest, TestInit) { |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1950 | Base::TestInit(); |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 1951 | EXPECT_FALSE(media_send_channel1_impl()->IsStreamMuted(0)); |
| 1952 | EXPECT_TRUE(media_send_channel1_impl()->dtmf_info_queue().empty()); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1953 | } |
| 1954 | |
| Danil Chapovalov | dae07ba | 2016-05-13 23:43:50 | [diff] [blame] | 1955 | TEST_F(VoiceChannelDoubleThreadTest, TestDeinit) { |
| 1956 | Base::TestDeinit(); |
| 1957 | } |
| 1958 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 1959 | TEST_F(VoiceChannelDoubleThreadTest, TestSetContents) { |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1960 | Base::TestSetContents(); |
| 1961 | } |
| 1962 | |
| Johannes Kron | 9190b82 | 2018-10-29 10:22:05 | [diff] [blame] | 1963 | TEST_F(VoiceChannelDoubleThreadTest, TestSetContentsExtmapAllowMixedAsCaller) { |
| 1964 | Base::TestSetContentsExtmapAllowMixedCaller(/*offer=*/true, /*answer=*/true); |
| 1965 | } |
| 1966 | |
| 1967 | TEST_F(VoiceChannelDoubleThreadTest, |
| 1968 | TestSetContentsExtmapAllowMixedNotSupportedAsCaller) { |
| 1969 | Base::TestSetContentsExtmapAllowMixedCaller(/*offer=*/true, /*answer=*/false); |
| 1970 | } |
| 1971 | |
| 1972 | TEST_F(VoiceChannelDoubleThreadTest, TestSetContentsExtmapAllowMixedAsCallee) { |
| 1973 | Base::TestSetContentsExtmapAllowMixedCallee(/*offer=*/true, /*answer=*/true); |
| 1974 | } |
| 1975 | |
| 1976 | TEST_F(VoiceChannelDoubleThreadTest, |
| 1977 | TestSetContentsExtmapAllowMixedNotSupportedAsCallee) { |
| 1978 | Base::TestSetContentsExtmapAllowMixedCallee(/*offer=*/true, /*answer=*/false); |
| 1979 | } |
| 1980 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 1981 | TEST_F(VoiceChannelDoubleThreadTest, TestSetContentsNullOffer) { |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1982 | Base::TestSetContentsNullOffer(); |
| 1983 | } |
| 1984 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 1985 | TEST_F(VoiceChannelDoubleThreadTest, TestSetContentsRtcpMux) { |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1986 | Base::TestSetContentsRtcpMux(); |
| 1987 | } |
| 1988 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 1989 | TEST_F(VoiceChannelDoubleThreadTest, TestSetContentsRtcpMuxWithPrAnswer) { |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1990 | Base::TestSetContentsRtcpMux(); |
| 1991 | } |
| 1992 | |
| Tomas Lundqvist | b40c559 | 2024-11-22 13:45:27 | [diff] [blame] | 1993 | TEST_F(VoiceChannelDoubleThreadTest, TestSetContentsRtcpReducedSize) { |
| 1994 | Base::TestSetContentsRtcpReducedSize(); |
| 1995 | } |
| 1996 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 1997 | TEST_F(VoiceChannelDoubleThreadTest, TestChangeStreamParamsInContent) { |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1998 | Base::TestChangeStreamParamsInContent(); |
| 1999 | } |
| 2000 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 2001 | TEST_F(VoiceChannelDoubleThreadTest, TestPlayoutAndSendingStates) { |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 2002 | Base::TestPlayoutAndSendingStates(); |
| 2003 | } |
| 2004 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 2005 | TEST_F(VoiceChannelDoubleThreadTest, TestMediaContentDirection) { |
| 2006 | Base::TestMediaContentDirection(); |
| 2007 | } |
| 2008 | |
| 2009 | TEST_F(VoiceChannelDoubleThreadTest, TestNetworkRouteChanges) { |
| 2010 | Base::TestNetworkRouteChanges(); |
| 2011 | } |
| 2012 | |
| 2013 | TEST_F(VoiceChannelDoubleThreadTest, TestCallSetup) { |
| 2014 | Base::TestCallSetup(); |
| 2015 | } |
| 2016 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 2017 | TEST_F(VoiceChannelDoubleThreadTest, SendRtpToRtp) { |
| 2018 | Base::SendRtpToRtp(); |
| 2019 | } |
| 2020 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 2021 | TEST_F(VoiceChannelDoubleThreadTest, SendDtlsSrtpToDtlsSrtp) { |
| Zhi Huang | e830e68 | 2018-03-30 17:48:35 | [diff] [blame] | 2022 | Base::SendDtlsSrtpToDtlsSrtp(0, 0); |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 2023 | } |
| 2024 | |
| 2025 | TEST_F(VoiceChannelDoubleThreadTest, SendDtlsSrtpToDtlsSrtpRtcpMux) { |
| Zhi Huang | e830e68 | 2018-03-30 17:48:35 | [diff] [blame] | 2026 | Base::SendDtlsSrtpToDtlsSrtp(RTCP_MUX, RTCP_MUX); |
| deadbeef | f534659 | 2017-01-25 05:51:21 | [diff] [blame] | 2027 | } |
| 2028 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 2029 | TEST_F(VoiceChannelDoubleThreadTest, SendEarlyMediaUsingRtcpMuxSrtp) { |
| 2030 | Base::SendEarlyMediaUsingRtcpMuxSrtp(); |
| 2031 | } |
| 2032 | |
| 2033 | TEST_F(VoiceChannelDoubleThreadTest, SendRtpToRtpOnThread) { |
| 2034 | Base::SendRtpToRtpOnThread(); |
| 2035 | } |
| 2036 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 2037 | TEST_F(VoiceChannelDoubleThreadTest, SendWithWritabilityLoss) { |
| 2038 | Base::SendWithWritabilityLoss(); |
| 2039 | } |
| 2040 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 2041 | TEST_F(VoiceChannelDoubleThreadTest, TestSetContentFailure) { |
| 2042 | Base::TestSetContentFailure(); |
| 2043 | } |
| 2044 | |
| 2045 | TEST_F(VoiceChannelDoubleThreadTest, TestSendTwoOffers) { |
| 2046 | Base::TestSendTwoOffers(); |
| 2047 | } |
| 2048 | |
| 2049 | TEST_F(VoiceChannelDoubleThreadTest, TestReceiveTwoOffers) { |
| 2050 | Base::TestReceiveTwoOffers(); |
| 2051 | } |
| 2052 | |
| 2053 | TEST_F(VoiceChannelDoubleThreadTest, TestSendPrAnswer) { |
| 2054 | Base::TestSendPrAnswer(); |
| 2055 | } |
| 2056 | |
| 2057 | TEST_F(VoiceChannelDoubleThreadTest, TestReceivePrAnswer) { |
| 2058 | Base::TestReceivePrAnswer(); |
| 2059 | } |
| 2060 | |
| zstein | 56162b9 | 2017-04-24 23:54:35 | [diff] [blame] | 2061 | TEST_F(VoiceChannelDoubleThreadTest, TestOnTransportReadyToSend) { |
| 2062 | Base::TestOnTransportReadyToSend(); |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 2063 | } |
| 2064 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 2065 | TEST_F(VoiceChannelDoubleThreadTest, SendBundleToBundle) { |
| Danil Chapovalov | 52c16dc | 2025-06-02 07:57:15 | [diff] [blame] | 2066 | Base::SendBundleToBundle(kAudioPts, false, false); |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 2067 | } |
| 2068 | |
| 2069 | TEST_F(VoiceChannelDoubleThreadTest, SendBundleToBundleSecure) { |
| Danil Chapovalov | 52c16dc | 2025-06-02 07:57:15 | [diff] [blame] | 2070 | Base::SendBundleToBundle(kAudioPts, false, true); |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 2071 | } |
| 2072 | |
| 2073 | TEST_F(VoiceChannelDoubleThreadTest, SendBundleToBundleWithRtcpMux) { |
| Danil Chapovalov | 52c16dc | 2025-06-02 07:57:15 | [diff] [blame] | 2074 | Base::SendBundleToBundle(kAudioPts, true, false); |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 2075 | } |
| 2076 | |
| 2077 | TEST_F(VoiceChannelDoubleThreadTest, SendBundleToBundleWithRtcpMuxSecure) { |
| Danil Chapovalov | 52c16dc | 2025-06-02 07:57:15 | [diff] [blame] | 2078 | Base::SendBundleToBundle(kAudioPts, true, true); |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 2079 | } |
| 2080 | |
| 2081 | TEST_F(VoiceChannelDoubleThreadTest, DefaultMaxBitrateIsUnlimited) { |
| 2082 | Base::DefaultMaxBitrateIsUnlimited(); |
| 2083 | } |
| 2084 | |
| Steve Anton | 8a63f78 | 2017-10-23 20:08:53 | [diff] [blame] | 2085 | TEST_F(VoiceChannelDoubleThreadTest, SocketOptionsMergedOnSetTransport) { |
| 2086 | Base::SocketOptionsMergedOnSetTransport(); |
| 2087 | } |
| 2088 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 2089 | // VideoChannelSingleThreadTest |
| 2090 | TEST_F(VideoChannelSingleThreadTest, TestInit) { |
| 2091 | Base::TestInit(); |
| 2092 | } |
| 2093 | |
| Danil Chapovalov | dae07ba | 2016-05-13 23:43:50 | [diff] [blame] | 2094 | TEST_F(VideoChannelSingleThreadTest, TestDeinit) { |
| 2095 | Base::TestDeinit(); |
| 2096 | } |
| 2097 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 2098 | TEST_F(VideoChannelSingleThreadTest, TestSetContents) { |
| 2099 | Base::TestSetContents(); |
| 2100 | } |
| 2101 | |
| Johannes Kron | 9190b82 | 2018-10-29 10:22:05 | [diff] [blame] | 2102 | TEST_F(VideoChannelSingleThreadTest, TestSetContentsExtmapAllowMixedAsCaller) { |
| 2103 | Base::TestSetContentsExtmapAllowMixedCaller(/*offer=*/true, /*answer=*/true); |
| 2104 | } |
| 2105 | |
| 2106 | TEST_F(VideoChannelSingleThreadTest, |
| 2107 | TestSetContentsExtmapAllowMixedNotSupportedAsCaller) { |
| 2108 | Base::TestSetContentsExtmapAllowMixedCaller(/*offer=*/true, /*answer=*/false); |
| 2109 | } |
| 2110 | |
| 2111 | TEST_F(VideoChannelSingleThreadTest, TestSetContentsExtmapAllowMixedAsCallee) { |
| 2112 | Base::TestSetContentsExtmapAllowMixedCallee(/*offer=*/true, /*answer=*/true); |
| 2113 | } |
| 2114 | |
| 2115 | TEST_F(VideoChannelSingleThreadTest, |
| 2116 | TestSetContentsExtmapAllowMixedNotSupportedAsCallee) { |
| 2117 | Base::TestSetContentsExtmapAllowMixedCallee(/*offer=*/true, /*answer=*/false); |
| 2118 | } |
| 2119 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 2120 | TEST_F(VideoChannelSingleThreadTest, TestSetContentsNullOffer) { |
| 2121 | Base::TestSetContentsNullOffer(); |
| 2122 | } |
| 2123 | |
| 2124 | TEST_F(VideoChannelSingleThreadTest, TestSetContentsRtcpMux) { |
| 2125 | Base::TestSetContentsRtcpMux(); |
| 2126 | } |
| 2127 | |
| 2128 | TEST_F(VideoChannelSingleThreadTest, TestSetContentsRtcpMuxWithPrAnswer) { |
| 2129 | Base::TestSetContentsRtcpMux(); |
| 2130 | } |
| 2131 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 2132 | TEST_F(VideoChannelSingleThreadTest, TestChangeStreamParamsInContent) { |
| 2133 | Base::TestChangeStreamParamsInContent(); |
| 2134 | } |
| 2135 | |
| 2136 | TEST_F(VideoChannelSingleThreadTest, TestPlayoutAndSendingStates) { |
| 2137 | Base::TestPlayoutAndSendingStates(); |
| 2138 | } |
| 2139 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 2140 | TEST_F(VideoChannelSingleThreadTest, TestMediaContentDirection) { |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 2141 | Base::TestMediaContentDirection(); |
| 2142 | } |
| 2143 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 2144 | TEST_F(VideoChannelSingleThreadTest, TestNetworkRouteChanges) { |
| Honghai Zhang | cc411c0 | 2016-03-30 00:27:21 | [diff] [blame] | 2145 | Base::TestNetworkRouteChanges(); |
| 2146 | } |
| 2147 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 2148 | TEST_F(VideoChannelSingleThreadTest, TestCallSetup) { |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 2149 | Base::TestCallSetup(); |
| 2150 | } |
| 2151 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 2152 | TEST_F(VideoChannelSingleThreadTest, SendRtpToRtp) { |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 2153 | Base::SendRtpToRtp(); |
| 2154 | } |
| 2155 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 2156 | TEST_F(VideoChannelSingleThreadTest, SendDtlsSrtpToDtlsSrtp) { |
| Zhi Huang | e830e68 | 2018-03-30 17:48:35 | [diff] [blame] | 2157 | Base::SendDtlsSrtpToDtlsSrtp(0, 0); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 2158 | } |
| 2159 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 2160 | TEST_F(VideoChannelSingleThreadTest, SendDtlsSrtpToDtlsSrtpRtcpMux) { |
| Zhi Huang | e830e68 | 2018-03-30 17:48:35 | [diff] [blame] | 2161 | Base::SendDtlsSrtpToDtlsSrtp(RTCP_MUX, RTCP_MUX); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 2162 | } |
| 2163 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 2164 | TEST_F(VideoChannelSingleThreadTest, SendEarlyMediaUsingRtcpMuxSrtp) { |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 2165 | Base::SendEarlyMediaUsingRtcpMuxSrtp(); |
| 2166 | } |
| 2167 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 2168 | TEST_F(VideoChannelSingleThreadTest, SendRtpToRtpOnThread) { |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 2169 | Base::SendRtpToRtpOnThread(); |
| 2170 | } |
| 2171 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 2172 | TEST_F(VideoChannelSingleThreadTest, SendWithWritabilityLoss) { |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 2173 | Base::SendWithWritabilityLoss(); |
| 2174 | } |
| 2175 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 2176 | TEST_F(VideoChannelSingleThreadTest, TestSetContentFailure) { |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 2177 | Base::TestSetContentFailure(); |
| 2178 | } |
| 2179 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 2180 | TEST_F(VideoChannelSingleThreadTest, TestSendTwoOffers) { |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 2181 | Base::TestSendTwoOffers(); |
| 2182 | } |
| 2183 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 2184 | TEST_F(VideoChannelSingleThreadTest, TestReceiveTwoOffers) { |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 2185 | Base::TestReceiveTwoOffers(); |
| 2186 | } |
| 2187 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 2188 | TEST_F(VideoChannelSingleThreadTest, TestSendPrAnswer) { |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 2189 | Base::TestSendPrAnswer(); |
| 2190 | } |
| 2191 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 2192 | TEST_F(VideoChannelSingleThreadTest, TestReceivePrAnswer) { |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 2193 | Base::TestReceivePrAnswer(); |
| 2194 | } |
| 2195 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 2196 | TEST_F(VideoChannelSingleThreadTest, SendBundleToBundle) { |
| Danil Chapovalov | 52c16dc | 2025-06-02 07:57:15 | [diff] [blame] | 2197 | Base::SendBundleToBundle(kVideoPts, false, false); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 2198 | } |
| 2199 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 2200 | TEST_F(VideoChannelSingleThreadTest, SendBundleToBundleSecure) { |
| Danil Chapovalov | 52c16dc | 2025-06-02 07:57:15 | [diff] [blame] | 2201 | Base::SendBundleToBundle(kVideoPts, false, true); |
| [email protected] | 5ee0f05 | 2014-05-05 20:18:08 | [diff] [blame] | 2202 | } |
| 2203 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 2204 | TEST_F(VideoChannelSingleThreadTest, SendBundleToBundleWithRtcpMux) { |
| Danil Chapovalov | 52c16dc | 2025-06-02 07:57:15 | [diff] [blame] | 2205 | Base::SendBundleToBundle(kVideoPts, true, false); |
| [email protected] | 5ee0f05 | 2014-05-05 20:18:08 | [diff] [blame] | 2206 | } |
| 2207 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 2208 | TEST_F(VideoChannelSingleThreadTest, SendBundleToBundleWithRtcpMuxSecure) { |
| Danil Chapovalov | 52c16dc | 2025-06-02 07:57:15 | [diff] [blame] | 2209 | Base::SendBundleToBundle(kVideoPts, true, true); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 2210 | } |
| 2211 | |
| zstein | 56162b9 | 2017-04-24 23:54:35 | [diff] [blame] | 2212 | TEST_F(VideoChannelSingleThreadTest, TestOnTransportReadyToSend) { |
| 2213 | Base::TestOnTransportReadyToSend(); |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 2214 | } |
| 2215 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 2216 | TEST_F(VideoChannelSingleThreadTest, DefaultMaxBitrateIsUnlimited) { |
| skvlad | dc1c62c | 2016-03-17 02:07:43 | [diff] [blame] | 2217 | Base::DefaultMaxBitrateIsUnlimited(); |
| 2218 | } |
| 2219 | |
| Steve Anton | 8a63f78 | 2017-10-23 20:08:53 | [diff] [blame] | 2220 | TEST_F(VideoChannelSingleThreadTest, SocketOptionsMergedOnSetTransport) { |
| 2221 | Base::SocketOptionsMergedOnSetTransport(); |
| 2222 | } |
| 2223 | |
| Amit Hilbuch | bcd39d4 | 2019-01-26 01:13:56 | [diff] [blame] | 2224 | TEST_F(VideoChannelSingleThreadTest, UpdateLocalStreamsWithSimulcast) { |
| 2225 | Base::TestUpdateLocalStreamsWithSimulcast(); |
| 2226 | } |
| 2227 | |
| Per K | 38bb331 | 2025-08-19 13:46:24 | [diff] [blame] | 2228 | TEST_F(VideoChannelSingleThreadTest, RemovesExtensionNotPresentInRemoteAnswer) { |
| 2229 | Base::TestRemovesExtensionNotPresentInRemoteAnswer(); |
| 2230 | } |
| 2231 | |
| 2232 | TEST_F(VideoChannelSingleThreadTest, RemovesExtensionNotPresentInLocalAnswer) { |
| 2233 | Base::TestRemovesExtensionNotPresentInLocalAnswer(); |
| 2234 | } |
| 2235 | |
| Mirta Dvornicic | 479a3c0 | 2019-06-04 13:38:50 | [diff] [blame] | 2236 | TEST_F(VideoChannelSingleThreadTest, TestSetLocalOfferWithPacketization) { |
| Evan Shrubsole | 0b212e3 | 2025-04-07 13:43:01 | [diff] [blame] | 2237 | const webrtc::Codec kVp8Codec = webrtc::CreateVideoCodec(97, "VP8"); |
| 2238 | webrtc::Codec vp9_codec = webrtc::CreateVideoCodec(98, "VP9"); |
| Evan Shrubsole | 945e517 | 2025-04-08 14:11:45 | [diff] [blame] | 2239 | vp9_codec.packetization = webrtc::kPacketizationParamRaw; |
| Evan Shrubsole | 080cdac | 2025-03-20 09:34:48 | [diff] [blame] | 2240 | webrtc::VideoContentDescription video; |
| Mirta Dvornicic | 479a3c0 | 2019-06-04 13:38:50 | [diff] [blame] | 2241 | video.set_codecs({kVp8Codec, vp9_codec}); |
| 2242 | |
| 2243 | CreateChannels(0, 0); |
| 2244 | |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 2245 | std::string err; |
| 2246 | EXPECT_TRUE(channel1_->SetLocalContent(&video, SdpType::kOffer, err)); |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 2247 | EXPECT_THAT(media_send_channel1_impl()->send_codecs(), testing::IsEmpty()); |
| 2248 | ASSERT_THAT(media_receive_channel1_impl()->recv_codecs(), testing::SizeIs(2)); |
| Emil Lundmark | f268afd | 2023-11-08 15:34:11 | [diff] [blame] | 2249 | EXPECT_TRUE( |
| 2250 | media_receive_channel1_impl()->recv_codecs()[0].Matches(kVp8Codec)); |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 2251 | EXPECT_EQ(media_receive_channel1_impl()->recv_codecs()[0].packetization, |
| Florent Castelli | 8037fc6 | 2024-08-29 13:00:40 | [diff] [blame] | 2252 | std::nullopt); |
| Emil Lundmark | f268afd | 2023-11-08 15:34:11 | [diff] [blame] | 2253 | EXPECT_TRUE( |
| 2254 | media_receive_channel1_impl()->recv_codecs()[1].Matches(vp9_codec)); |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 2255 | EXPECT_EQ(media_receive_channel1_impl()->recv_codecs()[1].packetization, |
| Evan Shrubsole | 945e517 | 2025-04-08 14:11:45 | [diff] [blame] | 2256 | webrtc::kPacketizationParamRaw); |
| Mirta Dvornicic | 479a3c0 | 2019-06-04 13:38:50 | [diff] [blame] | 2257 | } |
| 2258 | |
| 2259 | TEST_F(VideoChannelSingleThreadTest, TestSetRemoteOfferWithPacketization) { |
| Evan Shrubsole | 0b212e3 | 2025-04-07 13:43:01 | [diff] [blame] | 2260 | const webrtc::Codec kVp8Codec = webrtc::CreateVideoCodec(97, "VP8"); |
| 2261 | webrtc::Codec vp9_codec = webrtc::CreateVideoCodec(98, "VP9"); |
| Evan Shrubsole | 945e517 | 2025-04-08 14:11:45 | [diff] [blame] | 2262 | vp9_codec.packetization = webrtc::kPacketizationParamRaw; |
| Evan Shrubsole | 080cdac | 2025-03-20 09:34:48 | [diff] [blame] | 2263 | webrtc::VideoContentDescription video; |
| Mirta Dvornicic | 479a3c0 | 2019-06-04 13:38:50 | [diff] [blame] | 2264 | video.set_codecs({kVp8Codec, vp9_codec}); |
| 2265 | |
| 2266 | CreateChannels(0, 0); |
| 2267 | |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 2268 | std::string err; |
| 2269 | EXPECT_TRUE(channel1_->SetRemoteContent(&video, SdpType::kOffer, err)); |
| 2270 | EXPECT_TRUE(err.empty()); |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 2271 | EXPECT_THAT(media_receive_channel1_impl()->recv_codecs(), testing::IsEmpty()); |
| 2272 | ASSERT_THAT(media_send_channel1_impl()->send_codecs(), testing::SizeIs(2)); |
| Emil Lundmark | f268afd | 2023-11-08 15:34:11 | [diff] [blame] | 2273 | EXPECT_TRUE(media_send_channel1_impl()->send_codecs()[0].Matches(kVp8Codec)); |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 2274 | EXPECT_EQ(media_send_channel1_impl()->send_codecs()[0].packetization, |
| Florent Castelli | 8037fc6 | 2024-08-29 13:00:40 | [diff] [blame] | 2275 | std::nullopt); |
| Emil Lundmark | f268afd | 2023-11-08 15:34:11 | [diff] [blame] | 2276 | EXPECT_TRUE(media_send_channel1_impl()->send_codecs()[1].Matches(vp9_codec)); |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 2277 | EXPECT_EQ(media_send_channel1_impl()->send_codecs()[1].packetization, |
| Evan Shrubsole | 945e517 | 2025-04-08 14:11:45 | [diff] [blame] | 2278 | webrtc::kPacketizationParamRaw); |
| Mirta Dvornicic | 479a3c0 | 2019-06-04 13:38:50 | [diff] [blame] | 2279 | } |
| 2280 | |
| 2281 | TEST_F(VideoChannelSingleThreadTest, TestSetAnswerWithPacketization) { |
| Evan Shrubsole | 0b212e3 | 2025-04-07 13:43:01 | [diff] [blame] | 2282 | const webrtc::Codec kVp8Codec = webrtc::CreateVideoCodec(97, "VP8"); |
| 2283 | webrtc::Codec vp9_codec = webrtc::CreateVideoCodec(98, "VP9"); |
| Evan Shrubsole | 945e517 | 2025-04-08 14:11:45 | [diff] [blame] | 2284 | vp9_codec.packetization = webrtc::kPacketizationParamRaw; |
| Evan Shrubsole | 080cdac | 2025-03-20 09:34:48 | [diff] [blame] | 2285 | webrtc::VideoContentDescription video; |
| Mirta Dvornicic | 479a3c0 | 2019-06-04 13:38:50 | [diff] [blame] | 2286 | video.set_codecs({kVp8Codec, vp9_codec}); |
| 2287 | |
| 2288 | CreateChannels(0, 0); |
| 2289 | |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 2290 | std::string err; |
| 2291 | EXPECT_TRUE(channel1_->SetLocalContent(&video, SdpType::kOffer, err)); |
| 2292 | EXPECT_TRUE(err.empty()); |
| 2293 | EXPECT_TRUE(channel1_->SetRemoteContent(&video, SdpType::kAnswer, err)); |
| 2294 | EXPECT_TRUE(err.empty()); |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 2295 | ASSERT_THAT(media_receive_channel1_impl()->recv_codecs(), testing::SizeIs(2)); |
| Emil Lundmark | f268afd | 2023-11-08 15:34:11 | [diff] [blame] | 2296 | EXPECT_TRUE( |
| 2297 | media_receive_channel1_impl()->recv_codecs()[0].Matches(kVp8Codec)); |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 2298 | EXPECT_EQ(media_receive_channel1_impl()->recv_codecs()[0].packetization, |
| Florent Castelli | 8037fc6 | 2024-08-29 13:00:40 | [diff] [blame] | 2299 | std::nullopt); |
| Emil Lundmark | f268afd | 2023-11-08 15:34:11 | [diff] [blame] | 2300 | EXPECT_TRUE( |
| 2301 | media_receive_channel1_impl()->recv_codecs()[1].Matches(vp9_codec)); |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 2302 | EXPECT_EQ(media_receive_channel1_impl()->recv_codecs()[1].packetization, |
| Evan Shrubsole | 945e517 | 2025-04-08 14:11:45 | [diff] [blame] | 2303 | webrtc::kPacketizationParamRaw); |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 2304 | EXPECT_THAT(media_send_channel1_impl()->send_codecs(), testing::SizeIs(2)); |
| Emil Lundmark | f268afd | 2023-11-08 15:34:11 | [diff] [blame] | 2305 | EXPECT_TRUE(media_send_channel1_impl()->send_codecs()[0].Matches(kVp8Codec)); |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 2306 | EXPECT_EQ(media_send_channel1_impl()->send_codecs()[0].packetization, |
| Florent Castelli | 8037fc6 | 2024-08-29 13:00:40 | [diff] [blame] | 2307 | std::nullopt); |
| Emil Lundmark | f268afd | 2023-11-08 15:34:11 | [diff] [blame] | 2308 | EXPECT_TRUE(media_send_channel1_impl()->send_codecs()[1].Matches(vp9_codec)); |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 2309 | EXPECT_EQ(media_send_channel1_impl()->send_codecs()[1].packetization, |
| Evan Shrubsole | 945e517 | 2025-04-08 14:11:45 | [diff] [blame] | 2310 | webrtc::kPacketizationParamRaw); |
| Mirta Dvornicic | 479a3c0 | 2019-06-04 13:38:50 | [diff] [blame] | 2311 | } |
| 2312 | |
| 2313 | TEST_F(VideoChannelSingleThreadTest, TestSetLocalAnswerWithoutPacketization) { |
| Evan Shrubsole | 0b212e3 | 2025-04-07 13:43:01 | [diff] [blame] | 2314 | const webrtc::Codec kLocalCodec = webrtc::CreateVideoCodec(98, "VP8"); |
| 2315 | webrtc::Codec remote_codec = webrtc::CreateVideoCodec(99, "VP8"); |
| Evan Shrubsole | 945e517 | 2025-04-08 14:11:45 | [diff] [blame] | 2316 | remote_codec.packetization = webrtc::kPacketizationParamRaw; |
| Evan Shrubsole | 080cdac | 2025-03-20 09:34:48 | [diff] [blame] | 2317 | webrtc::VideoContentDescription local_video; |
| Mirta Dvornicic | 479a3c0 | 2019-06-04 13:38:50 | [diff] [blame] | 2318 | local_video.set_codecs({kLocalCodec}); |
| Evan Shrubsole | 080cdac | 2025-03-20 09:34:48 | [diff] [blame] | 2319 | webrtc::VideoContentDescription remote_video; |
| Mirta Dvornicic | 479a3c0 | 2019-06-04 13:38:50 | [diff] [blame] | 2320 | remote_video.set_codecs({remote_codec}); |
| 2321 | |
| 2322 | CreateChannels(0, 0); |
| 2323 | |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 2324 | std::string err; |
| 2325 | EXPECT_TRUE(channel1_->SetRemoteContent(&remote_video, SdpType::kOffer, err)); |
| 2326 | EXPECT_TRUE(channel1_->SetLocalContent(&local_video, SdpType::kAnswer, err)); |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 2327 | ASSERT_THAT(media_receive_channel1_impl()->recv_codecs(), testing::SizeIs(1)); |
| 2328 | EXPECT_EQ(media_receive_channel1_impl()->recv_codecs()[0].packetization, |
| Florent Castelli | 8037fc6 | 2024-08-29 13:00:40 | [diff] [blame] | 2329 | std::nullopt); |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 2330 | ASSERT_THAT(media_send_channel1_impl()->send_codecs(), testing::SizeIs(1)); |
| 2331 | EXPECT_EQ(media_send_channel1_impl()->send_codecs()[0].packetization, |
| Florent Castelli | 8037fc6 | 2024-08-29 13:00:40 | [diff] [blame] | 2332 | std::nullopt); |
| Mirta Dvornicic | 479a3c0 | 2019-06-04 13:38:50 | [diff] [blame] | 2333 | } |
| 2334 | |
| 2335 | TEST_F(VideoChannelSingleThreadTest, TestSetRemoteAnswerWithoutPacketization) { |
| Evan Shrubsole | 0b212e3 | 2025-04-07 13:43:01 | [diff] [blame] | 2336 | webrtc::Codec local_codec = webrtc::CreateVideoCodec(98, "VP8"); |
| Evan Shrubsole | 945e517 | 2025-04-08 14:11:45 | [diff] [blame] | 2337 | local_codec.packetization = webrtc::kPacketizationParamRaw; |
| Evan Shrubsole | 0b212e3 | 2025-04-07 13:43:01 | [diff] [blame] | 2338 | const webrtc::Codec kRemoteCodec = webrtc::CreateVideoCodec(99, "VP8"); |
| Evan Shrubsole | 080cdac | 2025-03-20 09:34:48 | [diff] [blame] | 2339 | webrtc::VideoContentDescription local_video; |
| Mirta Dvornicic | 479a3c0 | 2019-06-04 13:38:50 | [diff] [blame] | 2340 | local_video.set_codecs({local_codec}); |
| Evan Shrubsole | 080cdac | 2025-03-20 09:34:48 | [diff] [blame] | 2341 | webrtc::VideoContentDescription remote_video; |
| Mirta Dvornicic | 479a3c0 | 2019-06-04 13:38:50 | [diff] [blame] | 2342 | remote_video.set_codecs({kRemoteCodec}); |
| 2343 | |
| 2344 | CreateChannels(0, 0); |
| 2345 | |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 2346 | std::string err; |
| 2347 | EXPECT_TRUE(channel1_->SetLocalContent(&local_video, SdpType::kOffer, err)); |
| Mirta Dvornicic | 479a3c0 | 2019-06-04 13:38:50 | [diff] [blame] | 2348 | EXPECT_TRUE( |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 2349 | channel1_->SetRemoteContent(&remote_video, SdpType::kAnswer, err)); |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 2350 | ASSERT_THAT(media_receive_channel1_impl()->recv_codecs(), testing::SizeIs(1)); |
| 2351 | EXPECT_EQ(media_receive_channel1_impl()->recv_codecs()[0].packetization, |
| Florent Castelli | 8037fc6 | 2024-08-29 13:00:40 | [diff] [blame] | 2352 | std::nullopt); |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 2353 | ASSERT_THAT(media_send_channel1_impl()->send_codecs(), testing::SizeIs(1)); |
| 2354 | EXPECT_EQ(media_send_channel1_impl()->send_codecs()[0].packetization, |
| Florent Castelli | 8037fc6 | 2024-08-29 13:00:40 | [diff] [blame] | 2355 | std::nullopt); |
| Mirta Dvornicic | 479a3c0 | 2019-06-04 13:38:50 | [diff] [blame] | 2356 | } |
| 2357 | |
| 2358 | TEST_F(VideoChannelSingleThreadTest, |
| 2359 | TestSetRemoteAnswerWithInvalidPacketization) { |
| Evan Shrubsole | 0b212e3 | 2025-04-07 13:43:01 | [diff] [blame] | 2360 | webrtc::Codec local_codec = webrtc::CreateVideoCodec(98, "VP8"); |
| Evan Shrubsole | 945e517 | 2025-04-08 14:11:45 | [diff] [blame] | 2361 | local_codec.packetization = webrtc::kPacketizationParamRaw; |
| Evan Shrubsole | 0b212e3 | 2025-04-07 13:43:01 | [diff] [blame] | 2362 | webrtc::Codec remote_codec = webrtc::CreateVideoCodec(99, "VP8"); |
| Mirta Dvornicic | 479a3c0 | 2019-06-04 13:38:50 | [diff] [blame] | 2363 | remote_codec.packetization = "unknownpacketizationattributevalue"; |
| Evan Shrubsole | 080cdac | 2025-03-20 09:34:48 | [diff] [blame] | 2364 | webrtc::VideoContentDescription local_video; |
| Mirta Dvornicic | 479a3c0 | 2019-06-04 13:38:50 | [diff] [blame] | 2365 | local_video.set_codecs({local_codec}); |
| Evan Shrubsole | 080cdac | 2025-03-20 09:34:48 | [diff] [blame] | 2366 | webrtc::VideoContentDescription remote_video; |
| Mirta Dvornicic | 479a3c0 | 2019-06-04 13:38:50 | [diff] [blame] | 2367 | remote_video.set_codecs({remote_codec}); |
| 2368 | |
| 2369 | CreateChannels(0, 0); |
| 2370 | |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 2371 | std::string err; |
| 2372 | EXPECT_TRUE(channel1_->SetLocalContent(&local_video, SdpType::kOffer, err)); |
| 2373 | EXPECT_TRUE(err.empty()); |
| Mirta Dvornicic | 479a3c0 | 2019-06-04 13:38:50 | [diff] [blame] | 2374 | EXPECT_FALSE( |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 2375 | channel1_->SetRemoteContent(&remote_video, SdpType::kAnswer, err)); |
| 2376 | EXPECT_FALSE(err.empty()); |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 2377 | ASSERT_THAT(media_receive_channel1_impl()->recv_codecs(), testing::SizeIs(1)); |
| 2378 | EXPECT_EQ(media_receive_channel1_impl()->recv_codecs()[0].packetization, |
| Evan Shrubsole | 945e517 | 2025-04-08 14:11:45 | [diff] [blame] | 2379 | webrtc::kPacketizationParamRaw); |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 2380 | EXPECT_THAT(media_send_channel1_impl()->send_codecs(), testing::IsEmpty()); |
| Mirta Dvornicic | 479a3c0 | 2019-06-04 13:38:50 | [diff] [blame] | 2381 | } |
| 2382 | |
| 2383 | TEST_F(VideoChannelSingleThreadTest, |
| 2384 | TestSetLocalAnswerWithInvalidPacketization) { |
| Evan Shrubsole | 0b212e3 | 2025-04-07 13:43:01 | [diff] [blame] | 2385 | webrtc::Codec local_codec = webrtc::CreateVideoCodec(98, "VP8"); |
| Evan Shrubsole | 945e517 | 2025-04-08 14:11:45 | [diff] [blame] | 2386 | local_codec.packetization = webrtc::kPacketizationParamRaw; |
| Evan Shrubsole | 0b212e3 | 2025-04-07 13:43:01 | [diff] [blame] | 2387 | const webrtc::Codec kRemoteCodec = webrtc::CreateVideoCodec(99, "VP8"); |
| Evan Shrubsole | 080cdac | 2025-03-20 09:34:48 | [diff] [blame] | 2388 | webrtc::VideoContentDescription local_video; |
| Mirta Dvornicic | 479a3c0 | 2019-06-04 13:38:50 | [diff] [blame] | 2389 | local_video.set_codecs({local_codec}); |
| Evan Shrubsole | 080cdac | 2025-03-20 09:34:48 | [diff] [blame] | 2390 | webrtc::VideoContentDescription remote_video; |
| Mirta Dvornicic | 479a3c0 | 2019-06-04 13:38:50 | [diff] [blame] | 2391 | remote_video.set_codecs({kRemoteCodec}); |
| 2392 | |
| 2393 | CreateChannels(0, 0); |
| 2394 | |
| Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 2395 | std::string err; |
| 2396 | EXPECT_TRUE(channel1_->SetRemoteContent(&remote_video, SdpType::kOffer, err)); |
| 2397 | EXPECT_TRUE(err.empty()); |
| 2398 | EXPECT_FALSE(channel1_->SetLocalContent(&local_video, SdpType::kAnswer, err)); |
| 2399 | EXPECT_FALSE(err.empty()); |
| Harald Alvestrand | 2f55370 | 2023-03-07 10:10:03 | [diff] [blame] | 2400 | EXPECT_THAT(media_receive_channel1_impl()->recv_codecs(), testing::IsEmpty()); |
| 2401 | ASSERT_THAT(media_send_channel1_impl()->send_codecs(), testing::SizeIs(1)); |
| 2402 | EXPECT_EQ(media_send_channel1_impl()->send_codecs()[0].packetization, |
| Florent Castelli | 8037fc6 | 2024-08-29 13:00:40 | [diff] [blame] | 2403 | std::nullopt); |
| Mirta Dvornicic | 479a3c0 | 2019-06-04 13:38:50 | [diff] [blame] | 2404 | } |
| 2405 | |
| Emil Lundmark | 17304c3 | 2023-09-15 14:33:03 | [diff] [blame] | 2406 | TEST_F(VideoChannelSingleThreadTest, |
| 2407 | StopsPacketizationVerificationWhenMatchIsFoundInRemoteAnswer) { |
| Evan Shrubsole | 0b212e3 | 2025-04-07 13:43:01 | [diff] [blame] | 2408 | webrtc::Codec vp8_foo = webrtc::CreateVideoCodec(96, "VP8"); |
| Emil Lundmark | 17304c3 | 2023-09-15 14:33:03 | [diff] [blame] | 2409 | vp8_foo.packetization = "foo"; |
| Evan Shrubsole | 0b212e3 | 2025-04-07 13:43:01 | [diff] [blame] | 2410 | webrtc::Codec vp8_bar = webrtc::CreateVideoCodec(97, "VP8"); |
| Emil Lundmark | 17304c3 | 2023-09-15 14:33:03 | [diff] [blame] | 2411 | vp8_bar.packetization = "bar"; |
| Evan Shrubsole | 0b212e3 | 2025-04-07 13:43:01 | [diff] [blame] | 2412 | webrtc::Codec vp9 = webrtc::CreateVideoCodec(98, "VP9"); |
| 2413 | webrtc::Codec vp9_foo = webrtc::CreateVideoCodec(99, "VP9"); |
| Emil Lundmark | 17304c3 | 2023-09-15 14:33:03 | [diff] [blame] | 2414 | vp9_foo.packetization = "bar"; |
| Evan Shrubsole | 080cdac | 2025-03-20 09:34:48 | [diff] [blame] | 2415 | webrtc::VideoContentDescription local; |
| Emil Lundmark | 17304c3 | 2023-09-15 14:33:03 | [diff] [blame] | 2416 | local.set_codecs({vp8_foo, vp8_bar, vp9_foo}); |
| Evan Shrubsole | 080cdac | 2025-03-20 09:34:48 | [diff] [blame] | 2417 | webrtc::VideoContentDescription remote; |
| Emil Lundmark | 17304c3 | 2023-09-15 14:33:03 | [diff] [blame] | 2418 | remote.set_codecs({vp8_foo, vp9}); |
| 2419 | |
| 2420 | CreateChannels(0, 0); |
| 2421 | std::string err; |
| 2422 | ASSERT_TRUE(channel1_->SetLocalContent(&local, SdpType::kOffer, err)) << err; |
| 2423 | ASSERT_TRUE(channel1_->SetRemoteContent(&remote, SdpType::kAnswer, err)) |
| 2424 | << err; |
| 2425 | |
| 2426 | EXPECT_THAT( |
| 2427 | media_receive_channel1_impl()->recv_codecs(), |
| Evan Shrubsole | 0b212e3 | 2025-04-07 13:43:01 | [diff] [blame] | 2428 | ElementsAre(AllOf(Field(&webrtc::Codec::id, 96), |
| 2429 | Field(&webrtc::Codec::packetization, "foo")), |
| 2430 | AllOf(Field(&webrtc::Codec::id, 97), |
| 2431 | Field(&webrtc::Codec::packetization, "bar")), |
| 2432 | AllOf(Field(&webrtc::Codec::id, 99), |
| 2433 | Field(&webrtc::Codec::packetization, std::nullopt)))); |
| Emil Lundmark | 17304c3 | 2023-09-15 14:33:03 | [diff] [blame] | 2434 | EXPECT_THAT( |
| 2435 | media_send_channel1_impl()->send_codecs(), |
| Evan Shrubsole | 0b212e3 | 2025-04-07 13:43:01 | [diff] [blame] | 2436 | ElementsAre(AllOf(Field(&webrtc::Codec::id, 96), |
| 2437 | Field(&webrtc::Codec::packetization, "foo")), |
| 2438 | AllOf(Field(&webrtc::Codec::id, 98), |
| 2439 | Field(&webrtc::Codec::packetization, std::nullopt)))); |
| Emil Lundmark | 17304c3 | 2023-09-15 14:33:03 | [diff] [blame] | 2440 | } |
| 2441 | |
| 2442 | TEST_F(VideoChannelSingleThreadTest, |
| 2443 | StopsPacketizationVerificationWhenMatchIsFoundInLocalAnswer) { |
| Evan Shrubsole | 0b212e3 | 2025-04-07 13:43:01 | [diff] [blame] | 2444 | webrtc::Codec vp8_foo = webrtc::CreateVideoCodec(96, "VP8"); |
| Emil Lundmark | 17304c3 | 2023-09-15 14:33:03 | [diff] [blame] | 2445 | vp8_foo.packetization = "foo"; |
| Evan Shrubsole | 0b212e3 | 2025-04-07 13:43:01 | [diff] [blame] | 2446 | webrtc::Codec vp8_bar = webrtc::CreateVideoCodec(97, "VP8"); |
| Emil Lundmark | 17304c3 | 2023-09-15 14:33:03 | [diff] [blame] | 2447 | vp8_bar.packetization = "bar"; |
| Evan Shrubsole | 0b212e3 | 2025-04-07 13:43:01 | [diff] [blame] | 2448 | webrtc::Codec vp9 = webrtc::CreateVideoCodec(98, "VP9"); |
| 2449 | webrtc::Codec vp9_foo = webrtc::CreateVideoCodec(99, "VP9"); |
| Emil Lundmark | 17304c3 | 2023-09-15 14:33:03 | [diff] [blame] | 2450 | vp9_foo.packetization = "bar"; |
| Evan Shrubsole | 080cdac | 2025-03-20 09:34:48 | [diff] [blame] | 2451 | webrtc::VideoContentDescription local; |
| Emil Lundmark | 17304c3 | 2023-09-15 14:33:03 | [diff] [blame] | 2452 | local.set_codecs({vp8_foo, vp9}); |
| Evan Shrubsole | 080cdac | 2025-03-20 09:34:48 | [diff] [blame] | 2453 | webrtc::VideoContentDescription remote; |
| Emil Lundmark | 17304c3 | 2023-09-15 14:33:03 | [diff] [blame] | 2454 | remote.set_codecs({vp8_foo, vp8_bar, vp9_foo}); |
| 2455 | |
| 2456 | CreateChannels(0, 0); |
| 2457 | std::string err; |
| 2458 | ASSERT_TRUE(channel1_->SetRemoteContent(&remote, SdpType::kOffer, err)) |
| 2459 | << err; |
| 2460 | ASSERT_TRUE(channel1_->SetLocalContent(&local, SdpType::kAnswer, err)) << err; |
| 2461 | |
| 2462 | EXPECT_THAT( |
| 2463 | media_receive_channel1_impl()->recv_codecs(), |
| Harald Alvestrand | e30dd59 | 2025-07-16 07:39:24 | [diff] [blame] | 2464 | ElementsAre( |
| 2465 | AllOf(Field("id", &webrtc::Codec::id, 96), |
| 2466 | Field("packetization", &webrtc::Codec::packetization, "foo")), |
| 2467 | AllOf(Field("id", &webrtc::Codec::id, 98), |
| 2468 | Field("packetization", &webrtc::Codec::packetization, |
| 2469 | std::nullopt)))); |
| Emil Lundmark | 17304c3 | 2023-09-15 14:33:03 | [diff] [blame] | 2470 | EXPECT_THAT( |
| 2471 | media_send_channel1_impl()->send_codecs(), |
| Harald Alvestrand | e30dd59 | 2025-07-16 07:39:24 | [diff] [blame] | 2472 | ElementsAre( |
| 2473 | AllOf(Field("id", &webrtc::Codec::id, 96), |
| 2474 | Field("packetization", &webrtc::Codec::packetization, "foo")), |
| 2475 | AllOf(Field("id", &webrtc::Codec::id, 97), |
| 2476 | Field("packetization", &webrtc::Codec::packetization, "bar")), |
| 2477 | AllOf(Field("id", &webrtc::Codec::id, 99), |
| 2478 | Field("packetization", &webrtc::Codec::packetization, |
| 2479 | std::nullopt)))); |
| Emil Lundmark | 17304c3 | 2023-09-15 14:33:03 | [diff] [blame] | 2480 | } |
| 2481 | |
| Emil Lundmark | ec82627 | 2023-09-20 10:22:39 | [diff] [blame] | 2482 | TEST_F(VideoChannelSingleThreadTest, |
| 2483 | ConsidersAllCodecsWithDiffrentPacketizationsInRemoteAnswer) { |
| Evan Shrubsole | 0b212e3 | 2025-04-07 13:43:01 | [diff] [blame] | 2484 | webrtc::Codec vp8 = webrtc::CreateVideoCodec(96, "VP8"); |
| 2485 | webrtc::Codec vp8_raw = webrtc::CreateVideoCodec(97, "VP8"); |
| Evan Shrubsole | 945e517 | 2025-04-08 14:11:45 | [diff] [blame] | 2486 | vp8_raw.packetization = webrtc::kPacketizationParamRaw; |
| Evan Shrubsole | 080cdac | 2025-03-20 09:34:48 | [diff] [blame] | 2487 | webrtc::VideoContentDescription local; |
| Emil Lundmark | ec82627 | 2023-09-20 10:22:39 | [diff] [blame] | 2488 | local.set_codecs({vp8, vp8_raw}); |
| Evan Shrubsole | 080cdac | 2025-03-20 09:34:48 | [diff] [blame] | 2489 | webrtc::VideoContentDescription remote; |
| Emil Lundmark | ec82627 | 2023-09-20 10:22:39 | [diff] [blame] | 2490 | remote.set_codecs({vp8_raw, vp8}); |
| 2491 | |
| 2492 | CreateChannels(0, 0); |
| 2493 | std::string err; |
| 2494 | ASSERT_TRUE(channel1_->SetLocalContent(&local, SdpType::kOffer, err)) << err; |
| 2495 | ASSERT_TRUE(channel1_->SetRemoteContent(&remote, SdpType::kAnswer, err)) |
| 2496 | << err; |
| 2497 | |
| Harald Alvestrand | 4a96060 | 2025-07-29 15:51:10 | [diff] [blame] | 2498 | EXPECT_THAT(media_receive_channel1_impl()->recv_codecs(), |
| 2499 | UnorderedElementsAre( |
| 2500 | AllOf(Field(&webrtc::Codec::id, 96), |
| Evan Shrubsole | 0b212e3 | 2025-04-07 13:43:01 | [diff] [blame] | 2501 | Field(&webrtc::Codec::packetization, std::nullopt)), |
| 2502 | AllOf(Field(&webrtc::Codec::id, 97), |
| 2503 | Field(&webrtc::Codec::packetization, |
| Evan Shrubsole | 945e517 | 2025-04-08 14:11:45 | [diff] [blame] | 2504 | webrtc::kPacketizationParamRaw)))); |
| Harald Alvestrand | 4a96060 | 2025-07-29 15:51:10 | [diff] [blame] | 2505 | EXPECT_THAT(media_send_channel1_impl()->send_codecs(), |
| 2506 | UnorderedElementsAre( |
| 2507 | AllOf(Field(&webrtc::Codec::id, 97), |
| Evan Shrubsole | 0b212e3 | 2025-04-07 13:43:01 | [diff] [blame] | 2508 | Field(&webrtc::Codec::packetization, |
| Evan Shrubsole | 945e517 | 2025-04-08 14:11:45 | [diff] [blame] | 2509 | webrtc::kPacketizationParamRaw)), |
| Evan Shrubsole | 0b212e3 | 2025-04-07 13:43:01 | [diff] [blame] | 2510 | AllOf(Field(&webrtc::Codec::id, 96), |
| 2511 | Field(&webrtc::Codec::packetization, std::nullopt)))); |
| Emil Lundmark | ec82627 | 2023-09-20 10:22:39 | [diff] [blame] | 2512 | } |
| 2513 | |
| 2514 | TEST_F(VideoChannelSingleThreadTest, |
| 2515 | ConsidersAllCodecsWithDiffrentPacketizationsInLocalAnswer) { |
| Evan Shrubsole | 0b212e3 | 2025-04-07 13:43:01 | [diff] [blame] | 2516 | webrtc::Codec vp8 = webrtc::CreateVideoCodec(96, "VP8"); |
| 2517 | webrtc::Codec vp8_raw = webrtc::CreateVideoCodec(97, "VP8"); |
| Evan Shrubsole | 945e517 | 2025-04-08 14:11:45 | [diff] [blame] | 2518 | vp8_raw.packetization = webrtc::kPacketizationParamRaw; |
| Evan Shrubsole | 080cdac | 2025-03-20 09:34:48 | [diff] [blame] | 2519 | webrtc::VideoContentDescription local; |
| Emil Lundmark | ec82627 | 2023-09-20 10:22:39 | [diff] [blame] | 2520 | local.set_codecs({vp8_raw, vp8}); |
| Evan Shrubsole | 080cdac | 2025-03-20 09:34:48 | [diff] [blame] | 2521 | webrtc::VideoContentDescription remote; |
| Emil Lundmark | ec82627 | 2023-09-20 10:22:39 | [diff] [blame] | 2522 | remote.set_codecs({vp8, vp8_raw}); |
| 2523 | |
| 2524 | CreateChannels(0, 0); |
| 2525 | std::string err; |
| 2526 | ASSERT_TRUE(channel1_->SetRemoteContent(&remote, SdpType::kOffer, err)) |
| 2527 | << err; |
| 2528 | ASSERT_TRUE(channel1_->SetLocalContent(&local, SdpType::kAnswer, err)) << err; |
| 2529 | |
| 2530 | EXPECT_THAT( |
| 2531 | media_receive_channel1_impl()->recv_codecs(), |
| Evan Shrubsole | 0b212e3 | 2025-04-07 13:43:01 | [diff] [blame] | 2532 | ElementsAre(AllOf(Field(&webrtc::Codec::id, 97), |
| 2533 | Field(&webrtc::Codec::packetization, |
| Evan Shrubsole | 945e517 | 2025-04-08 14:11:45 | [diff] [blame] | 2534 | webrtc::kPacketizationParamRaw)), |
| Evan Shrubsole | 0b212e3 | 2025-04-07 13:43:01 | [diff] [blame] | 2535 | AllOf(Field(&webrtc::Codec::id, 96), |
| 2536 | Field(&webrtc::Codec::packetization, std::nullopt)))); |
| Emil Lundmark | ec82627 | 2023-09-20 10:22:39 | [diff] [blame] | 2537 | EXPECT_THAT( |
| 2538 | media_send_channel1_impl()->send_codecs(), |
| Evan Shrubsole | 0b212e3 | 2025-04-07 13:43:01 | [diff] [blame] | 2539 | ElementsAre(AllOf(Field(&webrtc::Codec::id, 96), |
| 2540 | Field(&webrtc::Codec::packetization, std::nullopt)), |
| 2541 | AllOf(Field(&webrtc::Codec::id, 97), |
| 2542 | Field(&webrtc::Codec::packetization, |
| Evan Shrubsole | 945e517 | 2025-04-08 14:11:45 | [diff] [blame] | 2543 | webrtc::kPacketizationParamRaw)))); |
| Emil Lundmark | ec82627 | 2023-09-20 10:22:39 | [diff] [blame] | 2544 | } |
| 2545 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 2546 | // VideoChannelDoubleThreadTest |
| 2547 | TEST_F(VideoChannelDoubleThreadTest, TestInit) { |
| 2548 | Base::TestInit(); |
| 2549 | } |
| [email protected] | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 2550 | |
| Danil Chapovalov | dae07ba | 2016-05-13 23:43:50 | [diff] [blame] | 2551 | TEST_F(VideoChannelDoubleThreadTest, TestDeinit) { |
| 2552 | Base::TestDeinit(); |
| 2553 | } |
| 2554 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 2555 | TEST_F(VideoChannelDoubleThreadTest, TestSetContents) { |
| 2556 | Base::TestSetContents(); |
| 2557 | } |
| 2558 | |
| Johannes Kron | 9190b82 | 2018-10-29 10:22:05 | [diff] [blame] | 2559 | TEST_F(VideoChannelDoubleThreadTest, TestSetContentsExtmapAllowMixedAsCaller) { |
| 2560 | Base::TestSetContentsExtmapAllowMixedCaller(/*offer=*/true, /*answer=*/true); |
| 2561 | } |
| 2562 | |
| 2563 | TEST_F(VideoChannelDoubleThreadTest, |
| 2564 | TestSetContentsExtmapAllowMixedNotSupportedAsCaller) { |
| 2565 | Base::TestSetContentsExtmapAllowMixedCaller(/*offer=*/true, /*answer=*/false); |
| 2566 | } |
| 2567 | |
| 2568 | TEST_F(VideoChannelDoubleThreadTest, TestSetContentsExtmapAllowMixedAsCallee) { |
| 2569 | Base::TestSetContentsExtmapAllowMixedCallee(/*offer=*/true, /*answer=*/true); |
| 2570 | } |
| 2571 | |
| 2572 | TEST_F(VideoChannelDoubleThreadTest, |
| 2573 | TestSetContentsExtmapAllowMixedNotSupportedAsCallee) { |
| 2574 | Base::TestSetContentsExtmapAllowMixedCallee(/*offer=*/true, /*answer=*/false); |
| 2575 | } |
| 2576 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 2577 | TEST_F(VideoChannelDoubleThreadTest, TestSetContentsNullOffer) { |
| 2578 | Base::TestSetContentsNullOffer(); |
| 2579 | } |
| 2580 | |
| 2581 | TEST_F(VideoChannelDoubleThreadTest, TestSetContentsRtcpMux) { |
| 2582 | Base::TestSetContentsRtcpMux(); |
| 2583 | } |
| 2584 | |
| 2585 | TEST_F(VideoChannelDoubleThreadTest, TestSetContentsRtcpMuxWithPrAnswer) { |
| 2586 | Base::TestSetContentsRtcpMux(); |
| 2587 | } |
| 2588 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 2589 | TEST_F(VideoChannelDoubleThreadTest, TestChangeStreamParamsInContent) { |
| 2590 | Base::TestChangeStreamParamsInContent(); |
| 2591 | } |
| 2592 | |
| 2593 | TEST_F(VideoChannelDoubleThreadTest, TestPlayoutAndSendingStates) { |
| 2594 | Base::TestPlayoutAndSendingStates(); |
| 2595 | } |
| 2596 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 2597 | TEST_F(VideoChannelDoubleThreadTest, TestMediaContentDirection) { |
| 2598 | Base::TestMediaContentDirection(); |
| 2599 | } |
| 2600 | |
| 2601 | TEST_F(VideoChannelDoubleThreadTest, TestNetworkRouteChanges) { |
| 2602 | Base::TestNetworkRouteChanges(); |
| 2603 | } |
| 2604 | |
| 2605 | TEST_F(VideoChannelDoubleThreadTest, TestCallSetup) { |
| 2606 | Base::TestCallSetup(); |
| 2607 | } |
| 2608 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 2609 | TEST_F(VideoChannelDoubleThreadTest, SendRtpToRtp) { |
| 2610 | Base::SendRtpToRtp(); |
| 2611 | } |
| 2612 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 2613 | TEST_F(VideoChannelDoubleThreadTest, SendDtlsSrtpToDtlsSrtp) { |
| Zhi Huang | e830e68 | 2018-03-30 17:48:35 | [diff] [blame] | 2614 | Base::SendDtlsSrtpToDtlsSrtp(0, 0); |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 2615 | } |
| 2616 | |
| 2617 | TEST_F(VideoChannelDoubleThreadTest, SendDtlsSrtpToDtlsSrtpRtcpMux) { |
| Zhi Huang | e830e68 | 2018-03-30 17:48:35 | [diff] [blame] | 2618 | Base::SendDtlsSrtpToDtlsSrtp(RTCP_MUX, RTCP_MUX); |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 2619 | } |
| 2620 | |
| 2621 | TEST_F(VideoChannelDoubleThreadTest, SendEarlyMediaUsingRtcpMuxSrtp) { |
| 2622 | Base::SendEarlyMediaUsingRtcpMuxSrtp(); |
| 2623 | } |
| 2624 | |
| 2625 | TEST_F(VideoChannelDoubleThreadTest, SendRtpToRtpOnThread) { |
| 2626 | Base::SendRtpToRtpOnThread(); |
| 2627 | } |
| 2628 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 2629 | TEST_F(VideoChannelDoubleThreadTest, SendWithWritabilityLoss) { |
| 2630 | Base::SendWithWritabilityLoss(); |
| 2631 | } |
| 2632 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 2633 | TEST_F(VideoChannelDoubleThreadTest, TestSetContentFailure) { |
| 2634 | Base::TestSetContentFailure(); |
| 2635 | } |
| 2636 | |
| 2637 | TEST_F(VideoChannelDoubleThreadTest, TestSendTwoOffers) { |
| 2638 | Base::TestSendTwoOffers(); |
| 2639 | } |
| 2640 | |
| 2641 | TEST_F(VideoChannelDoubleThreadTest, TestReceiveTwoOffers) { |
| 2642 | Base::TestReceiveTwoOffers(); |
| 2643 | } |
| 2644 | |
| 2645 | TEST_F(VideoChannelDoubleThreadTest, TestSendPrAnswer) { |
| 2646 | Base::TestSendPrAnswer(); |
| 2647 | } |
| 2648 | |
| 2649 | TEST_F(VideoChannelDoubleThreadTest, TestReceivePrAnswer) { |
| 2650 | Base::TestReceivePrAnswer(); |
| 2651 | } |
| 2652 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 2653 | TEST_F(VideoChannelDoubleThreadTest, SendBundleToBundle) { |
| Danil Chapovalov | 52c16dc | 2025-06-02 07:57:15 | [diff] [blame] | 2654 | Base::SendBundleToBundle(kVideoPts, false, false); |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 2655 | } |
| 2656 | |
| 2657 | TEST_F(VideoChannelDoubleThreadTest, SendBundleToBundleSecure) { |
| Danil Chapovalov | 52c16dc | 2025-06-02 07:57:15 | [diff] [blame] | 2658 | Base::SendBundleToBundle(kVideoPts, false, true); |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 2659 | } |
| 2660 | |
| 2661 | TEST_F(VideoChannelDoubleThreadTest, SendBundleToBundleWithRtcpMux) { |
| Danil Chapovalov | 52c16dc | 2025-06-02 07:57:15 | [diff] [blame] | 2662 | Base::SendBundleToBundle(kVideoPts, true, false); |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 2663 | } |
| 2664 | |
| 2665 | TEST_F(VideoChannelDoubleThreadTest, SendBundleToBundleWithRtcpMuxSecure) { |
| Danil Chapovalov | 52c16dc | 2025-06-02 07:57:15 | [diff] [blame] | 2666 | Base::SendBundleToBundle(kVideoPts, true, true); |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 2667 | } |
| 2668 | |
| zstein | 56162b9 | 2017-04-24 23:54:35 | [diff] [blame] | 2669 | TEST_F(VideoChannelDoubleThreadTest, TestOnTransportReadyToSend) { |
| 2670 | Base::TestOnTransportReadyToSend(); |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 2671 | } |
| 2672 | |
| Danil Chapovalov | 33b01f2 | 2016-05-11 17:55:27 | [diff] [blame] | 2673 | TEST_F(VideoChannelDoubleThreadTest, DefaultMaxBitrateIsUnlimited) { |
| 2674 | Base::DefaultMaxBitrateIsUnlimited(); |
| 2675 | } |
| 2676 | |
| Steve Anton | 8a63f78 | 2017-10-23 20:08:53 | [diff] [blame] | 2677 | TEST_F(VideoChannelDoubleThreadTest, SocketOptionsMergedOnSetTransport) { |
| 2678 | Base::SocketOptionsMergedOnSetTransport(); |
| 2679 | } |
| 2680 | |
| Emil Lundmark | 17304c3 | 2023-09-15 14:33:03 | [diff] [blame] | 2681 | } // namespace |