solenberg | c7a8b08 | 2015-10-16 14:35:07 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
| 11 | #include <list> |
kwiberg | 1c07c70 | 2017-03-27 07:15:49 -0700 | [diff] [blame] | 12 | #include <map> |
kwiberg | b25345e | 2016-03-12 06:10:44 -0800 | [diff] [blame] | 13 | #include <memory> |
zstein | 7cb69d5 | 2017-05-08 11:52:38 -0700 | [diff] [blame] | 14 | #include <utility> |
solenberg | c7a8b08 | 2015-10-16 14:35:07 -0700 | [diff] [blame] | 15 | |
Karl Wiberg | 918f50c | 2018-07-05 11:40:33 +0200 | [diff] [blame] | 16 | #include "absl/memory/memory.h" |
Karl Wiberg | f3850f6 | 2017-11-02 13:04:41 +0100 | [diff] [blame] | 17 | #include "api/audio_codecs/builtin_audio_decoder_factory.h" |
Piotr (Peter) Slatala | cc8e8bb | 2018-11-15 08:26:19 -0800 | [diff] [blame] | 18 | #include "api/test/fake_media_transport.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 19 | #include "api/test/mock_audio_mixer.h" |
Fredrik Solenberg | 8f5787a | 2018-01-11 13:52:30 +0100 | [diff] [blame] | 20 | #include "audio/audio_receive_stream.h" |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 21 | #include "audio/audio_send_stream.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 22 | #include "call/audio_state.h" |
| 23 | #include "call/call.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 24 | #include "logging/rtc_event_log/rtc_event_log.h" |
| 25 | #include "modules/audio_device/include/mock_audio_device.h" |
Fredrik Solenberg | 2a87797 | 2017-12-15 16:42:15 +0100 | [diff] [blame] | 26 | #include "modules/audio_processing/include/mock_audio_processing.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 27 | #include "modules/pacing/mock/mock_paced_sender.h" |
| 28 | #include "modules/rtp_rtcp/include/rtp_rtcp.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 29 | #include "test/fake_encoder.h" |
| 30 | #include "test/gtest.h" |
| 31 | #include "test/mock_audio_decoder_factory.h" |
| 32 | #include "test/mock_transport.h" |
solenberg | c7a8b08 | 2015-10-16 14:35:07 -0700 | [diff] [blame] | 33 | |
| 34 | namespace { |
| 35 | |
| 36 | struct CallHelper { |
Fredrik Solenberg | 8f5787a | 2018-01-11 13:52:30 +0100 | [diff] [blame] | 37 | CallHelper() { |
solenberg | 566ef24 | 2015-11-06 15:34:49 -0800 | [diff] [blame] | 38 | webrtc::AudioState::Config audio_state_config; |
Fredrik Solenberg | 2a87797 | 2017-12-15 16:42:15 +0100 | [diff] [blame] | 39 | audio_state_config.audio_mixer = |
| 40 | new rtc::RefCountedObject<webrtc::test::MockAudioMixer>(); |
| 41 | audio_state_config.audio_processing = |
| 42 | new rtc::RefCountedObject<webrtc::test::MockAudioProcessing>(); |
| 43 | audio_state_config.audio_device_module = |
| 44 | new rtc::RefCountedObject<webrtc::test::MockAudioDeviceModule>(); |
skvlad | 11a9cbf | 2016-10-07 11:53:05 -0700 | [diff] [blame] | 45 | webrtc::Call::Config config(&event_log_); |
solenberg | 566ef24 | 2015-11-06 15:34:49 -0800 | [diff] [blame] | 46 | config.audio_state = webrtc::AudioState::Create(audio_state_config); |
solenberg | c7a8b08 | 2015-10-16 14:35:07 -0700 | [diff] [blame] | 47 | call_.reset(webrtc::Call::Create(config)); |
| 48 | } |
| 49 | |
| 50 | webrtc::Call* operator->() { return call_.get(); } |
| 51 | |
| 52 | private: |
skvlad | 11a9cbf | 2016-10-07 11:53:05 -0700 | [diff] [blame] | 53 | webrtc::RtcEventLogNullImpl event_log_; |
kwiberg | b25345e | 2016-03-12 06:10:44 -0800 | [diff] [blame] | 54 | std::unique_ptr<webrtc::Call> call_; |
solenberg | c7a8b08 | 2015-10-16 14:35:07 -0700 | [diff] [blame] | 55 | }; |
| 56 | } // namespace |
| 57 | |
| 58 | namespace webrtc { |
| 59 | |
| 60 | TEST(CallTest, ConstructDestruct) { |
| 61 | CallHelper call; |
| 62 | } |
| 63 | |
| 64 | TEST(CallTest, CreateDestroy_AudioSendStream) { |
| 65 | CallHelper call; |
Niels Möller | 7d76a31 | 2018-10-26 12:57:07 +0200 | [diff] [blame] | 66 | AudioSendStream::Config config(/*send_transport=*/nullptr, |
| 67 | /*media_transport=*/nullptr); |
solenberg | c7a8b08 | 2015-10-16 14:35:07 -0700 | [diff] [blame] | 68 | config.rtp.ssrc = 42; |
solenberg | c7a8b08 | 2015-10-16 14:35:07 -0700 | [diff] [blame] | 69 | AudioSendStream* stream = call->CreateAudioSendStream(config); |
| 70 | EXPECT_NE(stream, nullptr); |
| 71 | call->DestroyAudioSendStream(stream); |
| 72 | } |
| 73 | |
| 74 | TEST(CallTest, CreateDestroy_AudioReceiveStream) { |
Fredrik Solenberg | 8f5787a | 2018-01-11 13:52:30 +0100 | [diff] [blame] | 75 | CallHelper call; |
solenberg | c7a8b08 | 2015-10-16 14:35:07 -0700 | [diff] [blame] | 76 | AudioReceiveStream::Config config; |
Niels Möller | ae4237e | 2018-10-05 11:28:38 +0200 | [diff] [blame] | 77 | MockTransport rtcp_send_transport; |
solenberg | c7a8b08 | 2015-10-16 14:35:07 -0700 | [diff] [blame] | 78 | config.rtp.remote_ssrc = 42; |
Niels Möller | ae4237e | 2018-10-05 11:28:38 +0200 | [diff] [blame] | 79 | config.rtcp_send_transport = &rtcp_send_transport; |
Fredrik Solenberg | 8f5787a | 2018-01-11 13:52:30 +0100 | [diff] [blame] | 80 | config.decoder_factory = |
| 81 | new rtc::RefCountedObject<webrtc::MockAudioDecoderFactory>(); |
solenberg | c7a8b08 | 2015-10-16 14:35:07 -0700 | [diff] [blame] | 82 | AudioReceiveStream* stream = call->CreateAudioReceiveStream(config); |
| 83 | EXPECT_NE(stream, nullptr); |
| 84 | call->DestroyAudioReceiveStream(stream); |
| 85 | } |
| 86 | |
| 87 | TEST(CallTest, CreateDestroy_AudioSendStreams) { |
| 88 | CallHelper call; |
Niels Möller | 7d76a31 | 2018-10-26 12:57:07 +0200 | [diff] [blame] | 89 | AudioSendStream::Config config(/*send_transport=*/nullptr, |
| 90 | /*media_transport=*/nullptr); |
solenberg | c7a8b08 | 2015-10-16 14:35:07 -0700 | [diff] [blame] | 91 | std::list<AudioSendStream*> streams; |
| 92 | for (int i = 0; i < 2; ++i) { |
| 93 | for (uint32_t ssrc = 0; ssrc < 1234567; ssrc += 34567) { |
| 94 | config.rtp.ssrc = ssrc; |
| 95 | AudioSendStream* stream = call->CreateAudioSendStream(config); |
| 96 | EXPECT_NE(stream, nullptr); |
| 97 | if (ssrc & 1) { |
| 98 | streams.push_back(stream); |
| 99 | } else { |
| 100 | streams.push_front(stream); |
| 101 | } |
| 102 | } |
| 103 | for (auto s : streams) { |
| 104 | call->DestroyAudioSendStream(s); |
| 105 | } |
| 106 | streams.clear(); |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | TEST(CallTest, CreateDestroy_AudioReceiveStreams) { |
Fredrik Solenberg | 8f5787a | 2018-01-11 13:52:30 +0100 | [diff] [blame] | 111 | CallHelper call; |
solenberg | c7a8b08 | 2015-10-16 14:35:07 -0700 | [diff] [blame] | 112 | AudioReceiveStream::Config config; |
Niels Möller | ae4237e | 2018-10-05 11:28:38 +0200 | [diff] [blame] | 113 | MockTransport rtcp_send_transport; |
| 114 | config.rtcp_send_transport = &rtcp_send_transport; |
Fredrik Solenberg | 8f5787a | 2018-01-11 13:52:30 +0100 | [diff] [blame] | 115 | config.decoder_factory = |
| 116 | new rtc::RefCountedObject<webrtc::MockAudioDecoderFactory>(); |
solenberg | c7a8b08 | 2015-10-16 14:35:07 -0700 | [diff] [blame] | 117 | std::list<AudioReceiveStream*> streams; |
| 118 | for (int i = 0; i < 2; ++i) { |
| 119 | for (uint32_t ssrc = 0; ssrc < 1234567; ssrc += 34567) { |
| 120 | config.rtp.remote_ssrc = ssrc; |
| 121 | AudioReceiveStream* stream = call->CreateAudioReceiveStream(config); |
| 122 | EXPECT_NE(stream, nullptr); |
| 123 | if (ssrc & 1) { |
| 124 | streams.push_back(stream); |
| 125 | } else { |
| 126 | streams.push_front(stream); |
| 127 | } |
| 128 | } |
| 129 | for (auto s : streams) { |
| 130 | call->DestroyAudioReceiveStream(s); |
| 131 | } |
| 132 | streams.clear(); |
| 133 | } |
| 134 | } |
brandtr | 25445d3 | 2016-10-23 23:37:14 -0700 | [diff] [blame] | 135 | |
solenberg | 7602aab | 2016-11-14 11:30:07 -0800 | [diff] [blame] | 136 | TEST(CallTest, CreateDestroy_AssociateAudioSendReceiveStreams_RecvFirst) { |
Fredrik Solenberg | 8f5787a | 2018-01-11 13:52:30 +0100 | [diff] [blame] | 137 | CallHelper call; |
solenberg | 7602aab | 2016-11-14 11:30:07 -0800 | [diff] [blame] | 138 | AudioReceiveStream::Config recv_config; |
Niels Möller | ae4237e | 2018-10-05 11:28:38 +0200 | [diff] [blame] | 139 | MockTransport rtcp_send_transport; |
solenberg | 7602aab | 2016-11-14 11:30:07 -0800 | [diff] [blame] | 140 | recv_config.rtp.remote_ssrc = 42; |
| 141 | recv_config.rtp.local_ssrc = 777; |
Niels Möller | ae4237e | 2018-10-05 11:28:38 +0200 | [diff] [blame] | 142 | recv_config.rtcp_send_transport = &rtcp_send_transport; |
Fredrik Solenberg | 8f5787a | 2018-01-11 13:52:30 +0100 | [diff] [blame] | 143 | recv_config.decoder_factory = |
| 144 | new rtc::RefCountedObject<webrtc::MockAudioDecoderFactory>(); |
solenberg | 7602aab | 2016-11-14 11:30:07 -0800 | [diff] [blame] | 145 | AudioReceiveStream* recv_stream = call->CreateAudioReceiveStream(recv_config); |
| 146 | EXPECT_NE(recv_stream, nullptr); |
| 147 | |
Niels Möller | 7d76a31 | 2018-10-26 12:57:07 +0200 | [diff] [blame] | 148 | AudioSendStream::Config send_config(/*send_transport=*/nullptr, |
| 149 | /*media_transport=*/nullptr); |
solenberg | 7602aab | 2016-11-14 11:30:07 -0800 | [diff] [blame] | 150 | send_config.rtp.ssrc = 777; |
solenberg | 7602aab | 2016-11-14 11:30:07 -0800 | [diff] [blame] | 151 | AudioSendStream* send_stream = call->CreateAudioSendStream(send_config); |
| 152 | EXPECT_NE(send_stream, nullptr); |
| 153 | |
Fredrik Solenberg | 8f5787a | 2018-01-11 13:52:30 +0100 | [diff] [blame] | 154 | internal::AudioReceiveStream* internal_recv_stream = |
| 155 | static_cast<internal::AudioReceiveStream*>(recv_stream); |
| 156 | EXPECT_EQ(send_stream, |
| 157 | internal_recv_stream->GetAssociatedSendStreamForTesting()); |
solenberg | 7602aab | 2016-11-14 11:30:07 -0800 | [diff] [blame] | 158 | |
Fredrik Solenberg | 8f5787a | 2018-01-11 13:52:30 +0100 | [diff] [blame] | 159 | call->DestroyAudioSendStream(send_stream); |
| 160 | EXPECT_EQ(nullptr, internal_recv_stream->GetAssociatedSendStreamForTesting()); |
| 161 | |
solenberg | 7602aab | 2016-11-14 11:30:07 -0800 | [diff] [blame] | 162 | call->DestroyAudioReceiveStream(recv_stream); |
| 163 | } |
| 164 | |
| 165 | TEST(CallTest, CreateDestroy_AssociateAudioSendReceiveStreams_SendFirst) { |
Fredrik Solenberg | 8f5787a | 2018-01-11 13:52:30 +0100 | [diff] [blame] | 166 | CallHelper call; |
Niels Möller | 7d76a31 | 2018-10-26 12:57:07 +0200 | [diff] [blame] | 167 | AudioSendStream::Config send_config(/*send_transport=*/nullptr, |
| 168 | /*media_transport=*/nullptr); |
solenberg | 7602aab | 2016-11-14 11:30:07 -0800 | [diff] [blame] | 169 | send_config.rtp.ssrc = 777; |
solenberg | 7602aab | 2016-11-14 11:30:07 -0800 | [diff] [blame] | 170 | AudioSendStream* send_stream = call->CreateAudioSendStream(send_config); |
| 171 | EXPECT_NE(send_stream, nullptr); |
| 172 | |
| 173 | AudioReceiveStream::Config recv_config; |
Niels Möller | ae4237e | 2018-10-05 11:28:38 +0200 | [diff] [blame] | 174 | MockTransport rtcp_send_transport; |
solenberg | 7602aab | 2016-11-14 11:30:07 -0800 | [diff] [blame] | 175 | recv_config.rtp.remote_ssrc = 42; |
| 176 | recv_config.rtp.local_ssrc = 777; |
Niels Möller | ae4237e | 2018-10-05 11:28:38 +0200 | [diff] [blame] | 177 | recv_config.rtcp_send_transport = &rtcp_send_transport; |
Fredrik Solenberg | 8f5787a | 2018-01-11 13:52:30 +0100 | [diff] [blame] | 178 | recv_config.decoder_factory = |
| 179 | new rtc::RefCountedObject<webrtc::MockAudioDecoderFactory>(); |
solenberg | 7602aab | 2016-11-14 11:30:07 -0800 | [diff] [blame] | 180 | AudioReceiveStream* recv_stream = call->CreateAudioReceiveStream(recv_config); |
| 181 | EXPECT_NE(recv_stream, nullptr); |
| 182 | |
Fredrik Solenberg | 8f5787a | 2018-01-11 13:52:30 +0100 | [diff] [blame] | 183 | internal::AudioReceiveStream* internal_recv_stream = |
| 184 | static_cast<internal::AudioReceiveStream*>(recv_stream); |
| 185 | EXPECT_EQ(send_stream, |
| 186 | internal_recv_stream->GetAssociatedSendStreamForTesting()); |
| 187 | |
solenberg | 7602aab | 2016-11-14 11:30:07 -0800 | [diff] [blame] | 188 | call->DestroyAudioReceiveStream(recv_stream); |
| 189 | |
| 190 | call->DestroyAudioSendStream(send_stream); |
| 191 | } |
| 192 | |
brandtr | 25445d3 | 2016-10-23 23:37:14 -0700 | [diff] [blame] | 193 | TEST(CallTest, CreateDestroy_FlexfecReceiveStream) { |
| 194 | CallHelper call; |
brandtr | 8313a6f | 2017-01-13 07:41:19 -0800 | [diff] [blame] | 195 | MockTransport rtcp_send_transport; |
| 196 | FlexfecReceiveStream::Config config(&rtcp_send_transport); |
brandtr | 1cfbd60 | 2016-12-08 04:17:53 -0800 | [diff] [blame] | 197 | config.payload_type = 118; |
| 198 | config.remote_ssrc = 38837212; |
brandtr | 25445d3 | 2016-10-23 23:37:14 -0700 | [diff] [blame] | 199 | config.protected_media_ssrcs = {27273}; |
| 200 | |
| 201 | FlexfecReceiveStream* stream = call->CreateFlexfecReceiveStream(config); |
| 202 | EXPECT_NE(stream, nullptr); |
| 203 | call->DestroyFlexfecReceiveStream(stream); |
| 204 | } |
| 205 | |
| 206 | TEST(CallTest, CreateDestroy_FlexfecReceiveStreams) { |
| 207 | CallHelper call; |
brandtr | 8313a6f | 2017-01-13 07:41:19 -0800 | [diff] [blame] | 208 | MockTransport rtcp_send_transport; |
| 209 | FlexfecReceiveStream::Config config(&rtcp_send_transport); |
brandtr | 1cfbd60 | 2016-12-08 04:17:53 -0800 | [diff] [blame] | 210 | config.payload_type = 118; |
brandtr | 25445d3 | 2016-10-23 23:37:14 -0700 | [diff] [blame] | 211 | std::list<FlexfecReceiveStream*> streams; |
| 212 | |
| 213 | for (int i = 0; i < 2; ++i) { |
| 214 | for (uint32_t ssrc = 0; ssrc < 1234567; ssrc += 34567) { |
brandtr | 1cfbd60 | 2016-12-08 04:17:53 -0800 | [diff] [blame] | 215 | config.remote_ssrc = ssrc; |
brandtr | 25445d3 | 2016-10-23 23:37:14 -0700 | [diff] [blame] | 216 | config.protected_media_ssrcs = {ssrc + 1}; |
| 217 | FlexfecReceiveStream* stream = call->CreateFlexfecReceiveStream(config); |
| 218 | EXPECT_NE(stream, nullptr); |
| 219 | if (ssrc & 1) { |
| 220 | streams.push_back(stream); |
| 221 | } else { |
| 222 | streams.push_front(stream); |
| 223 | } |
| 224 | } |
| 225 | for (auto s : streams) { |
| 226 | call->DestroyFlexfecReceiveStream(s); |
| 227 | } |
| 228 | streams.clear(); |
| 229 | } |
| 230 | } |
| 231 | |
| 232 | TEST(CallTest, MultipleFlexfecReceiveStreamsProtectingSingleVideoStream) { |
| 233 | CallHelper call; |
brandtr | 8313a6f | 2017-01-13 07:41:19 -0800 | [diff] [blame] | 234 | MockTransport rtcp_send_transport; |
| 235 | FlexfecReceiveStream::Config config(&rtcp_send_transport); |
brandtr | 1cfbd60 | 2016-12-08 04:17:53 -0800 | [diff] [blame] | 236 | config.payload_type = 118; |
brandtr | 25445d3 | 2016-10-23 23:37:14 -0700 | [diff] [blame] | 237 | config.protected_media_ssrcs = {1324234}; |
| 238 | FlexfecReceiveStream* stream; |
| 239 | std::list<FlexfecReceiveStream*> streams; |
| 240 | |
brandtr | 1cfbd60 | 2016-12-08 04:17:53 -0800 | [diff] [blame] | 241 | config.remote_ssrc = 838383; |
brandtr | 25445d3 | 2016-10-23 23:37:14 -0700 | [diff] [blame] | 242 | stream = call->CreateFlexfecReceiveStream(config); |
| 243 | EXPECT_NE(stream, nullptr); |
| 244 | streams.push_back(stream); |
| 245 | |
brandtr | 1cfbd60 | 2016-12-08 04:17:53 -0800 | [diff] [blame] | 246 | config.remote_ssrc = 424993; |
brandtr | 25445d3 | 2016-10-23 23:37:14 -0700 | [diff] [blame] | 247 | stream = call->CreateFlexfecReceiveStream(config); |
| 248 | EXPECT_NE(stream, nullptr); |
| 249 | streams.push_back(stream); |
| 250 | |
brandtr | 1cfbd60 | 2016-12-08 04:17:53 -0800 | [diff] [blame] | 251 | config.remote_ssrc = 99383; |
brandtr | 25445d3 | 2016-10-23 23:37:14 -0700 | [diff] [blame] | 252 | stream = call->CreateFlexfecReceiveStream(config); |
| 253 | EXPECT_NE(stream, nullptr); |
| 254 | streams.push_back(stream); |
| 255 | |
brandtr | 1cfbd60 | 2016-12-08 04:17:53 -0800 | [diff] [blame] | 256 | config.remote_ssrc = 5548; |
brandtr | 25445d3 | 2016-10-23 23:37:14 -0700 | [diff] [blame] | 257 | stream = call->CreateFlexfecReceiveStream(config); |
| 258 | EXPECT_NE(stream, nullptr); |
| 259 | streams.push_back(stream); |
| 260 | |
| 261 | for (auto s : streams) { |
| 262 | call->DestroyFlexfecReceiveStream(s); |
| 263 | } |
| 264 | } |
| 265 | |
ossu | c3d4b48 | 2017-05-23 06:07:11 -0700 | [diff] [blame] | 266 | TEST(CallTest, RecreatingAudioStreamWithSameSsrcReusesRtpState) { |
| 267 | constexpr uint32_t kSSRC = 12345; |
Fredrik Solenberg | 8f5787a | 2018-01-11 13:52:30 +0100 | [diff] [blame] | 268 | CallHelper call; |
ossu | c3d4b48 | 2017-05-23 06:07:11 -0700 | [diff] [blame] | 269 | |
| 270 | auto create_stream_and_get_rtp_state = [&](uint32_t ssrc) { |
Niels Möller | 7d76a31 | 2018-10-26 12:57:07 +0200 | [diff] [blame] | 271 | AudioSendStream::Config config(/*send_transport=*/nullptr, |
| 272 | /*media_transport=*/nullptr); |
ossu | c3d4b48 | 2017-05-23 06:07:11 -0700 | [diff] [blame] | 273 | config.rtp.ssrc = ssrc; |
ossu | c3d4b48 | 2017-05-23 06:07:11 -0700 | [diff] [blame] | 274 | AudioSendStream* stream = call->CreateAudioSendStream(config); |
Fredrik Solenberg | 8f5787a | 2018-01-11 13:52:30 +0100 | [diff] [blame] | 275 | const RtpState rtp_state = |
| 276 | static_cast<internal::AudioSendStream*>(stream)->GetRtpState(); |
ossu | c3d4b48 | 2017-05-23 06:07:11 -0700 | [diff] [blame] | 277 | call->DestroyAudioSendStream(stream); |
ossu | c3d4b48 | 2017-05-23 06:07:11 -0700 | [diff] [blame] | 278 | return rtp_state; |
| 279 | }; |
| 280 | |
| 281 | const RtpState rtp_state1 = create_stream_and_get_rtp_state(kSSRC); |
| 282 | const RtpState rtp_state2 = create_stream_and_get_rtp_state(kSSRC); |
| 283 | |
| 284 | EXPECT_EQ(rtp_state1.sequence_number, rtp_state2.sequence_number); |
| 285 | EXPECT_EQ(rtp_state1.start_timestamp, rtp_state2.start_timestamp); |
| 286 | EXPECT_EQ(rtp_state1.timestamp, rtp_state2.timestamp); |
| 287 | EXPECT_EQ(rtp_state1.capture_time_ms, rtp_state2.capture_time_ms); |
| 288 | EXPECT_EQ(rtp_state1.last_timestamp_time_ms, |
| 289 | rtp_state2.last_timestamp_time_ms); |
| 290 | EXPECT_EQ(rtp_state1.media_has_been_sent, rtp_state2.media_has_been_sent); |
| 291 | } |
Fredrik Solenberg | 8f5787a | 2018-01-11 13:52:30 +0100 | [diff] [blame] | 292 | |
Piotr (Peter) Slatala | 179a392 | 2018-11-16 09:57:58 -0800 | [diff] [blame^] | 293 | TEST(CallTest, RegisterMediaTransportBitrateCallbacksInCreateStream) { |
| 294 | CallHelper call; |
| 295 | MediaTransportSettings settings; |
| 296 | webrtc::FakeMediaTransport fake_media_transport(settings); |
| 297 | |
| 298 | EXPECT_EQ(0, fake_media_transport.target_rate_observers_size()); |
| 299 | AudioSendStream::Config config(/*send_transport=*/nullptr, |
| 300 | /*media_transport=*/&fake_media_transport); |
| 301 | |
| 302 | call->MediaTransportChange(&fake_media_transport); |
| 303 | AudioSendStream* stream = call->CreateAudioSendStream(config); |
| 304 | |
| 305 | // We get 2 subscribers: one subscriber from call.cc, and one from |
| 306 | // ChannelSend. |
| 307 | EXPECT_EQ(2, fake_media_transport.target_rate_observers_size()); |
| 308 | |
| 309 | call->DestroyAudioSendStream(stream); |
| 310 | EXPECT_EQ(1, fake_media_transport.target_rate_observers_size()); |
| 311 | |
| 312 | call->MediaTransportChange(nullptr); |
| 313 | EXPECT_EQ(0, fake_media_transport.target_rate_observers_size()); |
| 314 | } |
| 315 | |
solenberg | c7a8b08 | 2015-10-16 14:35:07 -0700 | [diff] [blame] | 316 | } // namespace webrtc |