Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(914)

Side by Side Diff: webrtc/media/engine/webrtcvideoengine_unittest.cc

Issue 2932073002: s/WebRtcVideoChannel2/WebRtcVideoChannel and s/WebRtcVideoEngine2/WebRtcVideoEngine (Closed)
Patch Set: . Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/media/engine/webrtcvideoengine2_unittest.cc ('k') | webrtc/pc/rtpreceiver.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 10 matching lines...) Expand all
21 #include "webrtc/common_video/h264/profile_level_id.h" 21 #include "webrtc/common_video/h264/profile_level_id.h"
22 #include "webrtc/logging/rtc_event_log/rtc_event_log.h" 22 #include "webrtc/logging/rtc_event_log/rtc_event_log.h"
23 #include "webrtc/media/base/mediaconstants.h" 23 #include "webrtc/media/base/mediaconstants.h"
24 #include "webrtc/media/base/rtputils.h" 24 #include "webrtc/media/base/rtputils.h"
25 #include "webrtc/media/base/testutils.h" 25 #include "webrtc/media/base/testutils.h"
26 #include "webrtc/media/base/videoengine_unittest.h" 26 #include "webrtc/media/base/videoengine_unittest.h"
27 #include "webrtc/media/engine/constants.h" 27 #include "webrtc/media/engine/constants.h"
28 #include "webrtc/media/engine/fakewebrtccall.h" 28 #include "webrtc/media/engine/fakewebrtccall.h"
29 #include "webrtc/media/engine/fakewebrtcvideoengine.h" 29 #include "webrtc/media/engine/fakewebrtcvideoengine.h"
30 #include "webrtc/media/engine/simulcast.h" 30 #include "webrtc/media/engine/simulcast.h"
31 #include "webrtc/media/engine/webrtcvideoengine2.h" 31 #include "webrtc/media/engine/webrtcvideoengine.h"
32 #include "webrtc/media/engine/webrtcvoiceengine.h" 32 #include "webrtc/media/engine/webrtcvoiceengine.h"
33 #include "webrtc/test/field_trial.h" 33 #include "webrtc/test/field_trial.h"
34 34
35 using webrtc::RtpExtension; 35 using webrtc::RtpExtension;
36 36
37 namespace { 37 namespace {
38 static const int kDefaultQpMax = 56; 38 static const int kDefaultQpMax = 56;
39 39
40 static const uint8_t kRedRtxPayloadType = 125; 40 static const uint8_t kRedRtxPayloadType = 125;
41 41
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 } 107 }
108 108
109 cricket::MediaConfig GetMediaConfig() { 109 cricket::MediaConfig GetMediaConfig() {
110 cricket::MediaConfig media_config; 110 cricket::MediaConfig media_config;
111 media_config.video.enable_cpu_overuse_detection = false; 111 media_config.video.enable_cpu_overuse_detection = false;
112 return media_config; 112 return media_config;
113 } 113 }
114 } // namespace 114 } // namespace
115 115
116 namespace cricket { 116 namespace cricket {
117 class WebRtcVideoEngine2Test : public ::testing::Test { 117 class WebRtcVideoEngineTest : public ::testing::Test {
118 public: 118 public:
119 WebRtcVideoEngine2Test() : WebRtcVideoEngine2Test("") {} 119 WebRtcVideoEngineTest() : WebRtcVideoEngineTest("") {}
120 explicit WebRtcVideoEngine2Test(const char* field_trials) 120 explicit WebRtcVideoEngineTest(const char* field_trials)
121 : override_field_trials_(field_trials), 121 : override_field_trials_(field_trials),
122 call_(webrtc::Call::Create(webrtc::Call::Config(&event_log_))), 122 call_(webrtc::Call::Create(webrtc::Call::Config(&event_log_))),
123 engine_() { 123 engine_() {
124 std::vector<VideoCodec> engine_codecs = engine_.codecs(); 124 std::vector<VideoCodec> engine_codecs = engine_.codecs();
125 RTC_DCHECK(!engine_codecs.empty()); 125 RTC_DCHECK(!engine_codecs.empty());
126 bool codec_set = false; 126 bool codec_set = false;
127 for (const cricket::VideoCodec& codec : engine_codecs) { 127 for (const cricket::VideoCodec& codec : engine_codecs) {
128 if (codec.name == "rtx") { 128 if (codec.name == "rtx") {
129 int associated_payload_type; 129 int associated_payload_type;
130 if (codec.GetParam(kCodecParamAssociatedPayloadType, 130 if (codec.GetParam(kCodecParamAssociatedPayloadType,
(...skipping 18 matching lines...) Expand all
149 cricket::WebRtcVideoEncoderFactory* encoder_factory); 149 cricket::WebRtcVideoEncoderFactory* encoder_factory);
150 150
151 VideoMediaChannel* SetUpForExternalDecoderFactory( 151 VideoMediaChannel* SetUpForExternalDecoderFactory(
152 cricket::WebRtcVideoDecoderFactory* decoder_factory, 152 cricket::WebRtcVideoDecoderFactory* decoder_factory,
153 const std::vector<VideoCodec>& codecs); 153 const std::vector<VideoCodec>& codecs);
154 154
155 void TestExtendedEncoderOveruse(bool use_external_encoder); 155 void TestExtendedEncoderOveruse(bool use_external_encoder);
156 156
157 webrtc::test::ScopedFieldTrials override_field_trials_; 157 webrtc::test::ScopedFieldTrials override_field_trials_;
158 webrtc::RtcEventLogNullImpl event_log_; 158 webrtc::RtcEventLogNullImpl event_log_;
159 // Used in WebRtcVideoEngine2VoiceTest, but defined here so it's properly 159 // Used in WebRtcVideoEngineVoiceTest, but defined here so it's properly
160 // initialized when the constructor is called. 160 // initialized when the constructor is called.
161 std::unique_ptr<webrtc::Call> call_; 161 std::unique_ptr<webrtc::Call> call_;
162 WebRtcVideoEngine2 engine_; 162 WebRtcVideoEngine engine_;
163 VideoCodec default_codec_; 163 VideoCodec default_codec_;
164 std::map<int, int> default_apt_rtx_types_; 164 std::map<int, int> default_apt_rtx_types_;
165 }; 165 };
166 166
167 TEST_F(WebRtcVideoEngine2Test, AnnouncesVp9AccordingToBuildFlags) { 167 TEST_F(WebRtcVideoEngineTest, AnnouncesVp9AccordingToBuildFlags) {
168 bool claims_vp9_support = false; 168 bool claims_vp9_support = false;
169 for (const cricket::VideoCodec& codec : engine_.codecs()) { 169 for (const cricket::VideoCodec& codec : engine_.codecs()) {
170 if (codec.name == "VP9") { 170 if (codec.name == "VP9") {
171 claims_vp9_support = true; 171 claims_vp9_support = true;
172 break; 172 break;
173 } 173 }
174 } 174 }
175 #if defined(RTC_DISABLE_VP9) 175 #if defined(RTC_DISABLE_VP9)
176 EXPECT_FALSE(claims_vp9_support); 176 EXPECT_FALSE(claims_vp9_support);
177 #else 177 #else
178 EXPECT_TRUE(claims_vp9_support); 178 EXPECT_TRUE(claims_vp9_support);
179 #endif // defined(RTC_DISABLE_VP9) 179 #endif // defined(RTC_DISABLE_VP9)
180 } 180 }
181 181
182 TEST_F(WebRtcVideoEngine2Test, DefaultRtxCodecHasAssociatedPayloadTypeSet) { 182 TEST_F(WebRtcVideoEngineTest, DefaultRtxCodecHasAssociatedPayloadTypeSet) {
183 std::vector<VideoCodec> engine_codecs = engine_.codecs(); 183 std::vector<VideoCodec> engine_codecs = engine_.codecs();
184 for (size_t i = 0; i < engine_codecs.size(); ++i) { 184 for (size_t i = 0; i < engine_codecs.size(); ++i) {
185 if (engine_codecs[i].name != kRtxCodecName) 185 if (engine_codecs[i].name != kRtxCodecName)
186 continue; 186 continue;
187 int associated_payload_type; 187 int associated_payload_type;
188 EXPECT_TRUE(engine_codecs[i].GetParam(kCodecParamAssociatedPayloadType, 188 EXPECT_TRUE(engine_codecs[i].GetParam(kCodecParamAssociatedPayloadType,
189 &associated_payload_type)); 189 &associated_payload_type));
190 EXPECT_EQ(default_codec_.id, associated_payload_type); 190 EXPECT_EQ(default_codec_.id, associated_payload_type);
191 return; 191 return;
192 } 192 }
193 FAIL() << "No RTX codec found among default codecs."; 193 FAIL() << "No RTX codec found among default codecs.";
194 } 194 }
195 195
196 TEST_F(WebRtcVideoEngine2Test, SupportsTimestampOffsetHeaderExtension) { 196 TEST_F(WebRtcVideoEngineTest, SupportsTimestampOffsetHeaderExtension) {
197 RtpCapabilities capabilities = engine_.GetCapabilities(); 197 RtpCapabilities capabilities = engine_.GetCapabilities();
198 ASSERT_FALSE(capabilities.header_extensions.empty()); 198 ASSERT_FALSE(capabilities.header_extensions.empty());
199 for (const RtpExtension& extension : capabilities.header_extensions) { 199 for (const RtpExtension& extension : capabilities.header_extensions) {
200 if (extension.uri == RtpExtension::kTimestampOffsetUri) { 200 if (extension.uri == RtpExtension::kTimestampOffsetUri) {
201 EXPECT_EQ(RtpExtension::kTimestampOffsetDefaultId, extension.id); 201 EXPECT_EQ(RtpExtension::kTimestampOffsetDefaultId, extension.id);
202 return; 202 return;
203 } 203 }
204 } 204 }
205 FAIL() << "Timestamp offset extension not in header-extension list."; 205 FAIL() << "Timestamp offset extension not in header-extension list.";
206 } 206 }
207 207
208 TEST_F(WebRtcVideoEngine2Test, SupportsAbsoluteSenderTimeHeaderExtension) { 208 TEST_F(WebRtcVideoEngineTest, SupportsAbsoluteSenderTimeHeaderExtension) {
209 RtpCapabilities capabilities = engine_.GetCapabilities(); 209 RtpCapabilities capabilities = engine_.GetCapabilities();
210 ASSERT_FALSE(capabilities.header_extensions.empty()); 210 ASSERT_FALSE(capabilities.header_extensions.empty());
211 for (const RtpExtension& extension : capabilities.header_extensions) { 211 for (const RtpExtension& extension : capabilities.header_extensions) {
212 if (extension.uri == RtpExtension::kAbsSendTimeUri) { 212 if (extension.uri == RtpExtension::kAbsSendTimeUri) {
213 EXPECT_EQ(RtpExtension::kAbsSendTimeDefaultId, extension.id); 213 EXPECT_EQ(RtpExtension::kAbsSendTimeDefaultId, extension.id);
214 return; 214 return;
215 } 215 }
216 } 216 }
217 FAIL() << "Absolute Sender Time extension not in header-extension list."; 217 FAIL() << "Absolute Sender Time extension not in header-extension list.";
218 } 218 }
219 219
220 TEST_F(WebRtcVideoEngine2Test, SupportsTransportSequenceNumberHeaderExtension) { 220 TEST_F(WebRtcVideoEngineTest, SupportsTransportSequenceNumberHeaderExtension) {
221 RtpCapabilities capabilities = engine_.GetCapabilities(); 221 RtpCapabilities capabilities = engine_.GetCapabilities();
222 ASSERT_FALSE(capabilities.header_extensions.empty()); 222 ASSERT_FALSE(capabilities.header_extensions.empty());
223 for (const RtpExtension& extension : capabilities.header_extensions) { 223 for (const RtpExtension& extension : capabilities.header_extensions) {
224 if (extension.uri == RtpExtension::kTransportSequenceNumberUri) { 224 if (extension.uri == RtpExtension::kTransportSequenceNumberUri) {
225 EXPECT_EQ(RtpExtension::kTransportSequenceNumberDefaultId, extension.id); 225 EXPECT_EQ(RtpExtension::kTransportSequenceNumberDefaultId, extension.id);
226 return; 226 return;
227 } 227 }
228 } 228 }
229 FAIL() << "Transport sequence number extension not in header-extension list."; 229 FAIL() << "Transport sequence number extension not in header-extension list.";
230 } 230 }
231 231
232 TEST_F(WebRtcVideoEngine2Test, SupportsVideoRotationHeaderExtension) { 232 TEST_F(WebRtcVideoEngineTest, SupportsVideoRotationHeaderExtension) {
233 RtpCapabilities capabilities = engine_.GetCapabilities(); 233 RtpCapabilities capabilities = engine_.GetCapabilities();
234 ASSERT_FALSE(capabilities.header_extensions.empty()); 234 ASSERT_FALSE(capabilities.header_extensions.empty());
235 for (const RtpExtension& extension : capabilities.header_extensions) { 235 for (const RtpExtension& extension : capabilities.header_extensions) {
236 if (extension.uri == RtpExtension::kVideoRotationUri) { 236 if (extension.uri == RtpExtension::kVideoRotationUri) {
237 EXPECT_EQ(RtpExtension::kVideoRotationDefaultId, extension.id); 237 EXPECT_EQ(RtpExtension::kVideoRotationDefaultId, extension.id);
238 return; 238 return;
239 } 239 }
240 } 240 }
241 FAIL() << "Video Rotation extension not in header-extension list."; 241 FAIL() << "Video Rotation extension not in header-extension list.";
242 } 242 }
243 243
244 TEST_F(WebRtcVideoEngine2Test, CVOSetHeaderExtensionBeforeCapturer) { 244 TEST_F(WebRtcVideoEngineTest, CVOSetHeaderExtensionBeforeCapturer) {
245 // Allocate the capturer first to prevent early destruction before channel's 245 // Allocate the capturer first to prevent early destruction before channel's
246 // dtor is called. 246 // dtor is called.
247 cricket::FakeVideoCapturer capturer; 247 cricket::FakeVideoCapturer capturer;
248 248
249 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; 249 cricket::FakeWebRtcVideoEncoderFactory encoder_factory;
250 encoder_factory.AddSupportedVideoCodecType("VP8"); 250 encoder_factory.AddSupportedVideoCodecType("VP8");
251 251
252 std::unique_ptr<VideoMediaChannel> channel( 252 std::unique_ptr<VideoMediaChannel> channel(
253 SetUpForExternalEncoderFactory(&encoder_factory)); 253 SetUpForExternalEncoderFactory(&encoder_factory));
254 EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(kSsrc))); 254 EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(kSsrc)));
(...skipping 13 matching lines...) Expand all
268 EXPECT_FALSE(capturer.apply_rotation()); 268 EXPECT_FALSE(capturer.apply_rotation());
269 269
270 // Verify removing header extension turns on applying rotation. 270 // Verify removing header extension turns on applying rotation.
271 parameters.extensions.clear(); 271 parameters.extensions.clear();
272 EXPECT_TRUE(channel->SetSendParameters(parameters)); 272 EXPECT_TRUE(channel->SetSendParameters(parameters));
273 EXPECT_TRUE(capturer.apply_rotation()); 273 EXPECT_TRUE(capturer.apply_rotation());
274 } 274 }
275 275
276 276
277 // TODO(ilnik): Remove this test once field trial is gone. 277 // TODO(ilnik): Remove this test once field trial is gone.
278 TEST_F(WebRtcVideoEngine2Test, SupportsVideoContentTypeHeaderExtension) { 278 TEST_F(WebRtcVideoEngineTest, SupportsVideoContentTypeHeaderExtension) {
279 // Extension shound not be reported outside of the field trial. 279 // Extension shound not be reported outside of the field trial.
280 RtpCapabilities capabilities = engine_.GetCapabilities(); 280 RtpCapabilities capabilities = engine_.GetCapabilities();
281 EXPECT_FALSE(capabilities.header_extensions.empty()); 281 EXPECT_FALSE(capabilities.header_extensions.empty());
282 for (const RtpExtension& extension : capabilities.header_extensions) { 282 for (const RtpExtension& extension : capabilities.header_extensions) {
283 EXPECT_NE(extension.uri, RtpExtension::kVideoContentTypeUri); 283 EXPECT_NE(extension.uri, RtpExtension::kVideoContentTypeUri);
284 } 284 }
285 webrtc::test::ScopedFieldTrials override_field_trials_( 285 webrtc::test::ScopedFieldTrials override_field_trials_(
286 "WebRTC-VideoContentTypeExtension/Enabled/"); 286 "WebRTC-VideoContentTypeExtension/Enabled/");
287 // Should be reported within field trial. 287 // Should be reported within field trial.
288 capabilities = engine_.GetCapabilities(); 288 capabilities = engine_.GetCapabilities();
289 EXPECT_FALSE(capabilities.header_extensions.empty()); 289 EXPECT_FALSE(capabilities.header_extensions.empty());
290 for (const RtpExtension& extension : capabilities.header_extensions) { 290 for (const RtpExtension& extension : capabilities.header_extensions) {
291 if (extension.uri == RtpExtension::kVideoContentTypeUri) { 291 if (extension.uri == RtpExtension::kVideoContentTypeUri) {
292 EXPECT_EQ(RtpExtension::kVideoContentTypeDefaultId, extension.id); 292 EXPECT_EQ(RtpExtension::kVideoContentTypeDefaultId, extension.id);
293 return; 293 return;
294 } 294 }
295 } 295 }
296 FAIL() << "Video Content Type extension not in header-extension list."; 296 FAIL() << "Video Content Type extension not in header-extension list.";
297 } 297 }
298 298
299 TEST_F(WebRtcVideoEngine2Test, CVOSetHeaderExtensionBeforeAddSendStream) { 299 TEST_F(WebRtcVideoEngineTest, CVOSetHeaderExtensionBeforeAddSendStream) {
300 // Allocate the capturer first to prevent early destruction before channel's 300 // Allocate the capturer first to prevent early destruction before channel's
301 // dtor is called. 301 // dtor is called.
302 cricket::FakeVideoCapturer capturer; 302 cricket::FakeVideoCapturer capturer;
303 303
304 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; 304 cricket::FakeWebRtcVideoEncoderFactory encoder_factory;
305 encoder_factory.AddSupportedVideoCodecType("VP8"); 305 encoder_factory.AddSupportedVideoCodecType("VP8");
306 306
307 std::unique_ptr<VideoMediaChannel> channel( 307 std::unique_ptr<VideoMediaChannel> channel(
308 SetUpForExternalEncoderFactory(&encoder_factory)); 308 SetUpForExternalEncoderFactory(&encoder_factory));
309 // Add CVO extension. 309 // Add CVO extension.
310 const int id = 1; 310 const int id = 1;
311 cricket::VideoSendParameters parameters; 311 cricket::VideoSendParameters parameters;
312 parameters.codecs.push_back(GetEngineCodec("VP8")); 312 parameters.codecs.push_back(GetEngineCodec("VP8"));
313 parameters.extensions.push_back( 313 parameters.extensions.push_back(
314 RtpExtension(RtpExtension::kVideoRotationUri, id)); 314 RtpExtension(RtpExtension::kVideoRotationUri, id));
315 EXPECT_TRUE(channel->SetSendParameters(parameters)); 315 EXPECT_TRUE(channel->SetSendParameters(parameters));
316 EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(kSsrc))); 316 EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(kSsrc)));
317 317
318 // Set capturer. 318 // Set capturer.
319 EXPECT_TRUE(channel->SetVideoSend(kSsrc, true, nullptr, &capturer)); 319 EXPECT_TRUE(channel->SetVideoSend(kSsrc, true, nullptr, &capturer));
320 320
321 // Verify capturer has turned off applying rotation. 321 // Verify capturer has turned off applying rotation.
322 EXPECT_FALSE(capturer.apply_rotation()); 322 EXPECT_FALSE(capturer.apply_rotation());
323 } 323 }
324 324
325 TEST_F(WebRtcVideoEngine2Test, CVOSetHeaderExtensionAfterCapturer) { 325 TEST_F(WebRtcVideoEngineTest, CVOSetHeaderExtensionAfterCapturer) {
326 cricket::FakeVideoCapturer capturer; 326 cricket::FakeVideoCapturer capturer;
327 327
328 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; 328 cricket::FakeWebRtcVideoEncoderFactory encoder_factory;
329 encoder_factory.AddSupportedVideoCodecType("VP8"); 329 encoder_factory.AddSupportedVideoCodecType("VP8");
330 encoder_factory.AddSupportedVideoCodecType("VP9"); 330 encoder_factory.AddSupportedVideoCodecType("VP9");
331 331
332 std::unique_ptr<VideoMediaChannel> channel( 332 std::unique_ptr<VideoMediaChannel> channel(
333 SetUpForExternalEncoderFactory(&encoder_factory)); 333 SetUpForExternalEncoderFactory(&encoder_factory));
334 EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(kSsrc))); 334 EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(kSsrc)));
335 335
(...skipping 16 matching lines...) Expand all
352 352
353 // Verify capturer has turned off applying rotation. 353 // Verify capturer has turned off applying rotation.
354 EXPECT_FALSE(capturer.apply_rotation()); 354 EXPECT_FALSE(capturer.apply_rotation());
355 355
356 // Verify removing header extension turns on applying rotation. 356 // Verify removing header extension turns on applying rotation.
357 parameters.extensions.clear(); 357 parameters.extensions.clear();
358 EXPECT_TRUE(channel->SetSendParameters(parameters)); 358 EXPECT_TRUE(channel->SetSendParameters(parameters));
359 EXPECT_TRUE(capturer.apply_rotation()); 359 EXPECT_TRUE(capturer.apply_rotation());
360 } 360 }
361 361
362 TEST_F(WebRtcVideoEngine2Test, SetSendFailsBeforeSettingCodecs) { 362 TEST_F(WebRtcVideoEngineTest, SetSendFailsBeforeSettingCodecs) {
363 engine_.Init(); 363 engine_.Init();
364 std::unique_ptr<VideoMediaChannel> channel( 364 std::unique_ptr<VideoMediaChannel> channel(
365 engine_.CreateChannel(call_.get(), GetMediaConfig(), VideoOptions())); 365 engine_.CreateChannel(call_.get(), GetMediaConfig(), VideoOptions()));
366 366
367 EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(123))); 367 EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(123)));
368 368
369 EXPECT_FALSE(channel->SetSend(true)) 369 EXPECT_FALSE(channel->SetSend(true))
370 << "Channel should not start without codecs."; 370 << "Channel should not start without codecs.";
371 EXPECT_TRUE(channel->SetSend(false)) 371 EXPECT_TRUE(channel->SetSend(false))
372 << "Channel should be stoppable even without set codecs."; 372 << "Channel should be stoppable even without set codecs.";
373 } 373 }
374 374
375 TEST_F(WebRtcVideoEngine2Test, GetStatsWithoutSendCodecsSetDoesNotCrash) { 375 TEST_F(WebRtcVideoEngineTest, GetStatsWithoutSendCodecsSetDoesNotCrash) {
376 engine_.Init(); 376 engine_.Init();
377 std::unique_ptr<VideoMediaChannel> channel( 377 std::unique_ptr<VideoMediaChannel> channel(
378 engine_.CreateChannel(call_.get(), GetMediaConfig(), VideoOptions())); 378 engine_.CreateChannel(call_.get(), GetMediaConfig(), VideoOptions()));
379 EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(123))); 379 EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(123)));
380 VideoMediaInfo info; 380 VideoMediaInfo info;
381 channel->GetStats(&info); 381 channel->GetStats(&info);
382 } 382 }
383 383
384 TEST_F(WebRtcVideoEngine2Test, UseExternalFactoryForVp8WhenSupported) { 384 TEST_F(WebRtcVideoEngineTest, UseExternalFactoryForVp8WhenSupported) {
385 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; 385 cricket::FakeWebRtcVideoEncoderFactory encoder_factory;
386 encoder_factory.AddSupportedVideoCodecType("VP8"); 386 encoder_factory.AddSupportedVideoCodecType("VP8");
387 387
388 std::unique_ptr<VideoMediaChannel> channel( 388 std::unique_ptr<VideoMediaChannel> channel(
389 SetUpForExternalEncoderFactory(&encoder_factory)); 389 SetUpForExternalEncoderFactory(&encoder_factory));
390 channel->OnReadyToSend(true); 390 channel->OnReadyToSend(true);
391 391
392 EXPECT_TRUE( 392 EXPECT_TRUE(
393 channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc))); 393 channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc)));
394 EXPECT_EQ(0, encoder_factory.GetNumCreatedEncoders()); 394 EXPECT_EQ(0, encoder_factory.GetNumCreatedEncoders());
(...skipping 21 matching lines...) Expand all
416 // Remove stream previously added to free the external encoder instance. 416 // Remove stream previously added to free the external encoder instance.
417 EXPECT_TRUE(channel->RemoveSendStream(kSsrc)); 417 EXPECT_TRUE(channel->RemoveSendStream(kSsrc));
418 EXPECT_EQ(0u, encoder_factory.encoders().size()); 418 EXPECT_EQ(0u, encoder_factory.encoders().size());
419 } 419 }
420 420
421 // Test that when an external encoder factory supports a codec we don't 421 // Test that when an external encoder factory supports a codec we don't
422 // internally support, we still add an RTX codec for it. 422 // internally support, we still add an RTX codec for it.
423 // TODO(deadbeef): Currently this test is only effective if WebRTC is 423 // TODO(deadbeef): Currently this test is only effective if WebRTC is
424 // built with no internal H264 support. This test should be updated 424 // built with no internal H264 support. This test should be updated
425 // if/when we start adding RTX codecs for unrecognized codec names. 425 // if/when we start adding RTX codecs for unrecognized codec names.
426 TEST_F(WebRtcVideoEngine2Test, RtxCodecAddedForExternalCodec) { 426 TEST_F(WebRtcVideoEngineTest, RtxCodecAddedForExternalCodec) {
427 using webrtc::H264::ProfileLevelIdToString; 427 using webrtc::H264::ProfileLevelIdToString;
428 using webrtc::H264::ProfileLevelId; 428 using webrtc::H264::ProfileLevelId;
429 using webrtc::H264::kLevel1; 429 using webrtc::H264::kLevel1;
430 cricket::VideoCodec h264_constrained_baseline("H264"); 430 cricket::VideoCodec h264_constrained_baseline("H264");
431 h264_constrained_baseline.params[kH264FmtpProfileLevelId] = 431 h264_constrained_baseline.params[kH264FmtpProfileLevelId] =
432 *ProfileLevelIdToString( 432 *ProfileLevelIdToString(
433 ProfileLevelId(webrtc::H264::kProfileConstrainedBaseline, kLevel1)); 433 ProfileLevelId(webrtc::H264::kProfileConstrainedBaseline, kLevel1));
434 cricket::VideoCodec h264_constrained_high("H264"); 434 cricket::VideoCodec h264_constrained_high("H264");
435 h264_constrained_high.params[kH264FmtpProfileLevelId] = 435 h264_constrained_high.params[kH264FmtpProfileLevelId] =
436 *ProfileLevelIdToString( 436 *ProfileLevelIdToString(
(...skipping 14 matching lines...) Expand all
451 // Now search for RTX codecs for them. Expect that they all have associated 451 // Now search for RTX codecs for them. Expect that they all have associated
452 // RTX codecs. 452 // RTX codecs.
453 EXPECT_TRUE(HasRtxCodec( 453 EXPECT_TRUE(HasRtxCodec(
454 codecs, FindMatchingCodec(codecs, h264_constrained_baseline)->id)); 454 codecs, FindMatchingCodec(codecs, h264_constrained_baseline)->id));
455 EXPECT_TRUE(HasRtxCodec( 455 EXPECT_TRUE(HasRtxCodec(
456 codecs, FindMatchingCodec(codecs, h264_constrained_high)->id)); 456 codecs, FindMatchingCodec(codecs, h264_constrained_high)->id));
457 EXPECT_TRUE(HasRtxCodec( 457 EXPECT_TRUE(HasRtxCodec(
458 codecs, FindMatchingCodec(codecs, h264_high)->id)); 458 codecs, FindMatchingCodec(codecs, h264_high)->id));
459 } 459 }
460 460
461 void WebRtcVideoEngine2Test::TestExtendedEncoderOveruse( 461 void WebRtcVideoEngineTest::TestExtendedEncoderOveruse(
462 bool use_external_encoder) { 462 bool use_external_encoder) {
463 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; 463 cricket::FakeWebRtcVideoEncoderFactory encoder_factory;
464 encoder_factory.AddSupportedVideoCodecType("VP8"); 464 encoder_factory.AddSupportedVideoCodecType("VP8");
465 std::unique_ptr<VideoMediaChannel> channel; 465 std::unique_ptr<VideoMediaChannel> channel;
466 FakeCall* fake_call = new FakeCall(webrtc::Call::Config(&event_log_)); 466 FakeCall* fake_call = new FakeCall(webrtc::Call::Config(&event_log_));
467 call_.reset(fake_call); 467 call_.reset(fake_call);
468 if (use_external_encoder) { 468 if (use_external_encoder) {
469 channel.reset(SetUpForExternalEncoderFactory(&encoder_factory)); 469 channel.reset(SetUpForExternalEncoderFactory(&encoder_factory));
470 } else { 470 } else {
471 engine_.Init(); 471 engine_.Init();
472 channel.reset( 472 channel.reset(
473 engine_.CreateChannel(call_.get(), GetMediaConfig(), VideoOptions())); 473 engine_.CreateChannel(call_.get(), GetMediaConfig(), VideoOptions()));
474 } 474 }
475 ASSERT_TRUE( 475 ASSERT_TRUE(
476 channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc))); 476 channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc)));
477 cricket::VideoSendParameters parameters; 477 cricket::VideoSendParameters parameters;
478 parameters.codecs.push_back(GetEngineCodec("VP8")); 478 parameters.codecs.push_back(GetEngineCodec("VP8"));
479 EXPECT_TRUE(channel->SetSendParameters(parameters)); 479 EXPECT_TRUE(channel->SetSendParameters(parameters));
480 EXPECT_TRUE(channel->SetSend(true)); 480 EXPECT_TRUE(channel->SetSend(true));
481 FakeVideoSendStream* stream = fake_call->GetVideoSendStreams()[0]; 481 FakeVideoSendStream* stream = fake_call->GetVideoSendStreams()[0];
482 482
483 EXPECT_EQ(use_external_encoder, 483 EXPECT_EQ(use_external_encoder,
484 stream->GetConfig().encoder_settings.full_overuse_time); 484 stream->GetConfig().encoder_settings.full_overuse_time);
485 // Remove stream previously added to free the external encoder instance. 485 // Remove stream previously added to free the external encoder instance.
486 EXPECT_TRUE(channel->RemoveSendStream(kSsrc)); 486 EXPECT_TRUE(channel->RemoveSendStream(kSsrc));
487 } 487 }
488 488
489 TEST_F(WebRtcVideoEngine2Test, EnablesFullEncoderTimeForExternalEncoders) { 489 TEST_F(WebRtcVideoEngineTest, EnablesFullEncoderTimeForExternalEncoders) {
490 TestExtendedEncoderOveruse(true); 490 TestExtendedEncoderOveruse(true);
491 } 491 }
492 492
493 TEST_F(WebRtcVideoEngine2Test, DisablesFullEncoderTimeForNonExternalEncoders) { 493 TEST_F(WebRtcVideoEngineTest, DisablesFullEncoderTimeForNonExternalEncoders) {
494 TestExtendedEncoderOveruse(false); 494 TestExtendedEncoderOveruse(false);
495 } 495 }
496 496
497 #if !defined(RTC_DISABLE_VP9) 497 #if !defined(RTC_DISABLE_VP9)
498 TEST_F(WebRtcVideoEngine2Test, CanConstructDecoderForVp9EncoderFactory) { 498 TEST_F(WebRtcVideoEngineTest, CanConstructDecoderForVp9EncoderFactory) {
499 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; 499 cricket::FakeWebRtcVideoEncoderFactory encoder_factory;
500 encoder_factory.AddSupportedVideoCodecType("VP9"); 500 encoder_factory.AddSupportedVideoCodecType("VP9");
501 501
502 std::unique_ptr<VideoMediaChannel> channel( 502 std::unique_ptr<VideoMediaChannel> channel(
503 SetUpForExternalEncoderFactory(&encoder_factory)); 503 SetUpForExternalEncoderFactory(&encoder_factory));
504 504
505 EXPECT_TRUE( 505 EXPECT_TRUE(
506 channel->AddRecvStream(cricket::StreamParams::CreateLegacy(kSsrc))); 506 channel->AddRecvStream(cricket::StreamParams::CreateLegacy(kSsrc)));
507 } 507 }
508 #endif // !defined(RTC_DISABLE_VP9) 508 #endif // !defined(RTC_DISABLE_VP9)
509 509
510 TEST_F(WebRtcVideoEngine2Test, PropagatesInputFrameTimestamp) { 510 TEST_F(WebRtcVideoEngineTest, PropagatesInputFrameTimestamp) {
511 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; 511 cricket::FakeWebRtcVideoEncoderFactory encoder_factory;
512 encoder_factory.AddSupportedVideoCodecType("VP8"); 512 encoder_factory.AddSupportedVideoCodecType("VP8");
513 FakeCall* fake_call = new FakeCall(webrtc::Call::Config(&event_log_)); 513 FakeCall* fake_call = new FakeCall(webrtc::Call::Config(&event_log_));
514 call_.reset(fake_call); 514 call_.reset(fake_call);
515 std::unique_ptr<VideoMediaChannel> channel( 515 std::unique_ptr<VideoMediaChannel> channel(
516 SetUpForExternalEncoderFactory(&encoder_factory)); 516 SetUpForExternalEncoderFactory(&encoder_factory));
517 517
518 EXPECT_TRUE( 518 EXPECT_TRUE(
519 channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc))); 519 channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc)));
520 520
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 // Allow error to be no more than 1. 556 // Allow error to be no more than 1.
557 EXPECT_NEAR(cricket::VideoFormat::FpsToInterval(30) / 1E6, interval, 1); 557 EXPECT_NEAR(cricket::VideoFormat::FpsToInterval(30) / 1E6, interval, 1);
558 558
559 last_timestamp = timestamp; 559 last_timestamp = timestamp;
560 } 560 }
561 561
562 // Remove stream previously added to free the external encoder instance. 562 // Remove stream previously added to free the external encoder instance.
563 EXPECT_TRUE(channel->RemoveSendStream(kSsrc)); 563 EXPECT_TRUE(channel->RemoveSendStream(kSsrc));
564 } 564 }
565 565
566 cricket::VideoCodec WebRtcVideoEngine2Test::GetEngineCodec( 566 cricket::VideoCodec WebRtcVideoEngineTest::GetEngineCodec(
567 const std::string& name) { 567 const std::string& name) {
568 for (const cricket::VideoCodec& engine_codec : engine_.codecs()) { 568 for (const cricket::VideoCodec& engine_codec : engine_.codecs()) {
569 if (CodecNamesEq(name, engine_codec.name)) 569 if (CodecNamesEq(name, engine_codec.name))
570 return engine_codec; 570 return engine_codec;
571 } 571 }
572 // This point should never be reached. 572 // This point should never be reached.
573 ADD_FAILURE() << "Unrecognized codec name: " << name; 573 ADD_FAILURE() << "Unrecognized codec name: " << name;
574 return cricket::VideoCodec(); 574 return cricket::VideoCodec();
575 } 575 }
576 576
577 VideoMediaChannel* WebRtcVideoEngine2Test::SetUpForExternalEncoderFactory( 577 VideoMediaChannel* WebRtcVideoEngineTest::SetUpForExternalEncoderFactory(
578 cricket::WebRtcVideoEncoderFactory* encoder_factory) { 578 cricket::WebRtcVideoEncoderFactory* encoder_factory) {
579 engine_.SetExternalEncoderFactory(encoder_factory); 579 engine_.SetExternalEncoderFactory(encoder_factory);
580 engine_.Init(); 580 engine_.Init();
581 581
582 VideoMediaChannel* channel = 582 VideoMediaChannel* channel =
583 engine_.CreateChannel(call_.get(), GetMediaConfig(), VideoOptions()); 583 engine_.CreateChannel(call_.get(), GetMediaConfig(), VideoOptions());
584 cricket::VideoSendParameters parameters; 584 cricket::VideoSendParameters parameters;
585 // We need to look up the codec in the engine to get the correct payload type. 585 // We need to look up the codec in the engine to get the correct payload type.
586 for (const VideoCodec& codec : encoder_factory->supported_codecs()) 586 for (const VideoCodec& codec : encoder_factory->supported_codecs())
587 parameters.codecs.push_back(GetEngineCodec(codec.name)); 587 parameters.codecs.push_back(GetEngineCodec(codec.name));
588 588
589 EXPECT_TRUE(channel->SetSendParameters(parameters)); 589 EXPECT_TRUE(channel->SetSendParameters(parameters));
590 590
591 return channel; 591 return channel;
592 } 592 }
593 593
594 VideoMediaChannel* WebRtcVideoEngine2Test::SetUpForExternalDecoderFactory( 594 VideoMediaChannel* WebRtcVideoEngineTest::SetUpForExternalDecoderFactory(
595 cricket::WebRtcVideoDecoderFactory* decoder_factory, 595 cricket::WebRtcVideoDecoderFactory* decoder_factory,
596 const std::vector<VideoCodec>& codecs) { 596 const std::vector<VideoCodec>& codecs) {
597 engine_.SetExternalDecoderFactory(decoder_factory); 597 engine_.SetExternalDecoderFactory(decoder_factory);
598 engine_.Init(); 598 engine_.Init();
599 599
600 VideoMediaChannel* channel = 600 VideoMediaChannel* channel =
601 engine_.CreateChannel(call_.get(), GetMediaConfig(), VideoOptions()); 601 engine_.CreateChannel(call_.get(), GetMediaConfig(), VideoOptions());
602 cricket::VideoRecvParameters parameters; 602 cricket::VideoRecvParameters parameters;
603 parameters.codecs = codecs; 603 parameters.codecs = codecs;
604 EXPECT_TRUE(channel->SetRecvParameters(parameters)); 604 EXPECT_TRUE(channel->SetRecvParameters(parameters));
605 605
606 return channel; 606 return channel;
607 } 607 }
608 608
609 TEST_F(WebRtcVideoEngine2Test, UsesSimulcastAdapterForVp8Factories) { 609 TEST_F(WebRtcVideoEngineTest, UsesSimulcastAdapterForVp8Factories) {
610 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; 610 cricket::FakeWebRtcVideoEncoderFactory encoder_factory;
611 encoder_factory.AddSupportedVideoCodecType("VP8"); 611 encoder_factory.AddSupportedVideoCodecType("VP8");
612 612
613 std::unique_ptr<VideoMediaChannel> channel( 613 std::unique_ptr<VideoMediaChannel> channel(
614 SetUpForExternalEncoderFactory(&encoder_factory)); 614 SetUpForExternalEncoderFactory(&encoder_factory));
615 615
616 std::vector<uint32_t> ssrcs = MAKE_VECTOR(kSsrcs3); 616 std::vector<uint32_t> ssrcs = MAKE_VECTOR(kSsrcs3);
617 617
618 EXPECT_TRUE( 618 EXPECT_TRUE(
619 channel->AddSendStream(CreateSimStreamParams("cname", ssrcs))); 619 channel->AddSendStream(CreateSimStreamParams("cname", ssrcs)));
(...skipping 18 matching lines...) Expand all
638 EXPECT_GT(codec_settings.width, prev_width); 638 EXPECT_GT(codec_settings.width, prev_width);
639 prev_width = codec_settings.width; 639 prev_width = codec_settings.width;
640 } 640 }
641 641
642 EXPECT_TRUE(channel->SetVideoSend(ssrcs.front(), true, nullptr, nullptr)); 642 EXPECT_TRUE(channel->SetVideoSend(ssrcs.front(), true, nullptr, nullptr));
643 643
644 channel.reset(); 644 channel.reset();
645 ASSERT_EQ(0u, encoder_factory.encoders().size()); 645 ASSERT_EQ(0u, encoder_factory.encoders().size());
646 } 646 }
647 647
648 TEST_F(WebRtcVideoEngine2Test, ChannelWithExternalH264CanChangeToInternalVp8) { 648 TEST_F(WebRtcVideoEngineTest, ChannelWithExternalH264CanChangeToInternalVp8) {
649 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; 649 cricket::FakeWebRtcVideoEncoderFactory encoder_factory;
650 encoder_factory.AddSupportedVideoCodecType("H264"); 650 encoder_factory.AddSupportedVideoCodecType("H264");
651 651
652 std::unique_ptr<VideoMediaChannel> channel( 652 std::unique_ptr<VideoMediaChannel> channel(
653 SetUpForExternalEncoderFactory(&encoder_factory)); 653 SetUpForExternalEncoderFactory(&encoder_factory));
654 654
655 EXPECT_TRUE( 655 EXPECT_TRUE(
656 channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc))); 656 channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc)));
657 ASSERT_EQ(1u, encoder_factory.encoders().size()); 657 ASSERT_EQ(1u, encoder_factory.encoders().size());
658 658
659 cricket::VideoSendParameters parameters; 659 cricket::VideoSendParameters parameters;
660 parameters.codecs.push_back(GetEngineCodec("VP8")); 660 parameters.codecs.push_back(GetEngineCodec("VP8"));
661 EXPECT_TRUE(channel->SetSendParameters(parameters)); 661 EXPECT_TRUE(channel->SetSendParameters(parameters));
662 ASSERT_EQ(0u, encoder_factory.encoders().size()); 662 ASSERT_EQ(0u, encoder_factory.encoders().size());
663 } 663 }
664 664
665 TEST_F(WebRtcVideoEngine2Test, 665 TEST_F(WebRtcVideoEngineTest,
666 DontUseExternalEncoderFactoryForUnsupportedCodecs) { 666 DontUseExternalEncoderFactoryForUnsupportedCodecs) {
667 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; 667 cricket::FakeWebRtcVideoEncoderFactory encoder_factory;
668 encoder_factory.AddSupportedVideoCodecType("H264"); 668 encoder_factory.AddSupportedVideoCodecType("H264");
669 669
670 engine_.SetExternalEncoderFactory(&encoder_factory); 670 engine_.SetExternalEncoderFactory(&encoder_factory);
671 engine_.Init(); 671 engine_.Init();
672 672
673 std::unique_ptr<VideoMediaChannel> channel( 673 std::unique_ptr<VideoMediaChannel> channel(
674 engine_.CreateChannel(call_.get(), GetMediaConfig(), VideoOptions())); 674 engine_.CreateChannel(call_.get(), GetMediaConfig(), VideoOptions()));
675 cricket::VideoSendParameters parameters; 675 cricket::VideoSendParameters parameters;
676 parameters.codecs.push_back(GetEngineCodec("VP8")); 676 parameters.codecs.push_back(GetEngineCodec("VP8"));
677 EXPECT_TRUE(channel->SetSendParameters(parameters)); 677 EXPECT_TRUE(channel->SetSendParameters(parameters));
678 678
679 EXPECT_TRUE( 679 EXPECT_TRUE(
680 channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc))); 680 channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc)));
681 // Make sure DestroyVideoEncoder was called on the factory. 681 // Make sure DestroyVideoEncoder was called on the factory.
682 ASSERT_EQ(0u, encoder_factory.encoders().size()); 682 ASSERT_EQ(0u, encoder_factory.encoders().size());
683 } 683 }
684 684
685 TEST_F(WebRtcVideoEngine2Test, 685 TEST_F(WebRtcVideoEngineTest,
686 UsesSimulcastAdapterForVp8WithCombinedVP8AndH264Factory) { 686 UsesSimulcastAdapterForVp8WithCombinedVP8AndH264Factory) {
687 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; 687 cricket::FakeWebRtcVideoEncoderFactory encoder_factory;
688 encoder_factory.AddSupportedVideoCodecType("VP8"); 688 encoder_factory.AddSupportedVideoCodecType("VP8");
689 encoder_factory.AddSupportedVideoCodecType("H264"); 689 encoder_factory.AddSupportedVideoCodecType("H264");
690 690
691 engine_.SetExternalEncoderFactory(&encoder_factory); 691 engine_.SetExternalEncoderFactory(&encoder_factory);
692 engine_.Init(); 692 engine_.Init();
693 693
694 std::unique_ptr<VideoMediaChannel> channel( 694 std::unique_ptr<VideoMediaChannel> channel(
695 engine_.CreateChannel(call_.get(), GetMediaConfig(), VideoOptions())); 695 engine_.CreateChannel(call_.get(), GetMediaConfig(), VideoOptions()));
(...skipping 19 matching lines...) Expand all
715 ASSERT_TRUE(encoder_factory.WaitForCreatedVideoEncoders(2)); 715 ASSERT_TRUE(encoder_factory.WaitForCreatedVideoEncoders(2));
716 ASSERT_TRUE(encoder_factory.encoders()[0]->WaitForInitEncode()); 716 ASSERT_TRUE(encoder_factory.encoders()[0]->WaitForInitEncode());
717 EXPECT_EQ(webrtc::kVideoCodecVP8, 717 EXPECT_EQ(webrtc::kVideoCodecVP8,
718 encoder_factory.encoders()[0]->GetCodecSettings().codecType); 718 encoder_factory.encoders()[0]->GetCodecSettings().codecType);
719 719
720 channel.reset(); 720 channel.reset();
721 // Make sure DestroyVideoEncoder was called on the factory. 721 // Make sure DestroyVideoEncoder was called on the factory.
722 EXPECT_EQ(0u, encoder_factory.encoders().size()); 722 EXPECT_EQ(0u, encoder_factory.encoders().size());
723 } 723 }
724 724
725 TEST_F(WebRtcVideoEngine2Test, 725 TEST_F(WebRtcVideoEngineTest,
726 DestroysNonSimulcastEncoderFromCombinedVP8AndH264Factory) { 726 DestroysNonSimulcastEncoderFromCombinedVP8AndH264Factory) {
727 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; 727 cricket::FakeWebRtcVideoEncoderFactory encoder_factory;
728 encoder_factory.AddSupportedVideoCodecType("VP8"); 728 encoder_factory.AddSupportedVideoCodecType("VP8");
729 encoder_factory.AddSupportedVideoCodecType("H264"); 729 encoder_factory.AddSupportedVideoCodecType("H264");
730 730
731 engine_.SetExternalEncoderFactory(&encoder_factory); 731 engine_.SetExternalEncoderFactory(&encoder_factory);
732 engine_.Init(); 732 engine_.Init();
733 733
734 std::unique_ptr<VideoMediaChannel> channel( 734 std::unique_ptr<VideoMediaChannel> channel(
735 engine_.CreateChannel(call_.get(), GetMediaConfig(), VideoOptions())); 735 engine_.CreateChannel(call_.get(), GetMediaConfig(), VideoOptions()));
(...skipping 14 matching lines...) Expand all
750 EXPECT_TRUE(capturer.CaptureFrame()); 750 EXPECT_TRUE(capturer.CaptureFrame());
751 ASSERT_TRUE(encoder_factory.encoders()[0]->WaitForInitEncode()); 751 ASSERT_TRUE(encoder_factory.encoders()[0]->WaitForInitEncode());
752 EXPECT_EQ(webrtc::kVideoCodecH264, 752 EXPECT_EQ(webrtc::kVideoCodecH264,
753 encoder_factory.encoders()[0]->GetCodecSettings().codecType); 753 encoder_factory.encoders()[0]->GetCodecSettings().codecType);
754 754
755 channel.reset(); 755 channel.reset();
756 // Make sure DestroyVideoEncoder was called on the factory. 756 // Make sure DestroyVideoEncoder was called on the factory.
757 ASSERT_EQ(0u, encoder_factory.encoders().size()); 757 ASSERT_EQ(0u, encoder_factory.encoders().size());
758 } 758 }
759 759
760 TEST_F(WebRtcVideoEngine2Test, SimulcastDisabledForH264) { 760 TEST_F(WebRtcVideoEngineTest, SimulcastDisabledForH264) {
761 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; 761 cricket::FakeWebRtcVideoEncoderFactory encoder_factory;
762 encoder_factory.AddSupportedVideoCodecType("H264"); 762 encoder_factory.AddSupportedVideoCodecType("H264");
763 763
764 std::unique_ptr<VideoMediaChannel> channel( 764 std::unique_ptr<VideoMediaChannel> channel(
765 SetUpForExternalEncoderFactory(&encoder_factory)); 765 SetUpForExternalEncoderFactory(&encoder_factory));
766 766
767 const std::vector<uint32_t> ssrcs = MAKE_VECTOR(kSsrcs3); 767 const std::vector<uint32_t> ssrcs = MAKE_VECTOR(kSsrcs3);
768 EXPECT_TRUE( 768 EXPECT_TRUE(
769 channel->AddSendStream(cricket::CreateSimStreamParams("cname", ssrcs))); 769 channel->AddSendStream(cricket::CreateSimStreamParams("cname", ssrcs)));
770 770
771 // Send a frame of 720p. This should trigger a "real" encoder initialization. 771 // Send a frame of 720p. This should trigger a "real" encoder initialization.
772 cricket::VideoFormat format( 772 cricket::VideoFormat format(
773 1280, 720, cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420); 773 1280, 720, cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420);
774 cricket::FakeVideoCapturer capturer; 774 cricket::FakeVideoCapturer capturer;
775 EXPECT_TRUE(channel->SetVideoSend(ssrcs[0], true, nullptr, &capturer)); 775 EXPECT_TRUE(channel->SetVideoSend(ssrcs[0], true, nullptr, &capturer));
776 EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(format)); 776 EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(format));
777 EXPECT_TRUE(capturer.CaptureFrame()); 777 EXPECT_TRUE(capturer.CaptureFrame());
778 778
779 ASSERT_EQ(1u, encoder_factory.encoders().size()); 779 ASSERT_EQ(1u, encoder_factory.encoders().size());
780 FakeWebRtcVideoEncoder* encoder = encoder_factory.encoders()[0]; 780 FakeWebRtcVideoEncoder* encoder = encoder_factory.encoders()[0];
781 ASSERT_TRUE(encoder_factory.encoders()[0]->WaitForInitEncode()); 781 ASSERT_TRUE(encoder_factory.encoders()[0]->WaitForInitEncode());
782 EXPECT_EQ(webrtc::kVideoCodecH264, encoder->GetCodecSettings().codecType); 782 EXPECT_EQ(webrtc::kVideoCodecH264, encoder->GetCodecSettings().codecType);
783 EXPECT_EQ(1u, encoder->GetCodecSettings().numberOfSimulcastStreams); 783 EXPECT_EQ(1u, encoder->GetCodecSettings().numberOfSimulcastStreams);
784 EXPECT_TRUE(channel->SetVideoSend(ssrcs[0], true, nullptr, nullptr)); 784 EXPECT_TRUE(channel->SetVideoSend(ssrcs[0], true, nullptr, nullptr));
785 } 785 }
786 786
787 // Test that the FlexFEC field trial properly alters the output of 787 // Test that the FlexFEC field trial properly alters the output of
788 // WebRtcVideoEngine2::codecs(), for an existing |engine_| object. 788 // WebRtcVideoEngine::codecs(), for an existing |engine_| object.
789 // 789 //
790 // TODO(brandtr): Remove this test, when the FlexFEC field trial is gone. 790 // TODO(brandtr): Remove this test, when the FlexFEC field trial is gone.
791 TEST_F(WebRtcVideoEngine2Test, 791 TEST_F(WebRtcVideoEngineTest,
792 Flexfec03SupportedAsInternalCodecBehindFieldTrial) { 792 Flexfec03SupportedAsInternalCodecBehindFieldTrial) {
793 auto is_flexfec = [](const VideoCodec& codec) { 793 auto is_flexfec = [](const VideoCodec& codec) {
794 if (codec.name == "flexfec-03") 794 if (codec.name == "flexfec-03")
795 return true; 795 return true;
796 return false; 796 return false;
797 }; 797 };
798 798
799 // FlexFEC is not active without field trial. 799 // FlexFEC is not active without field trial.
800 engine_.Init(); 800 engine_.Init();
801 const std::vector<VideoCodec> codecs_before = engine_.codecs(); 801 const std::vector<VideoCodec> codecs_before = engine_.codecs();
802 EXPECT_EQ(codecs_before.end(), std::find_if(codecs_before.begin(), 802 EXPECT_EQ(codecs_before.end(), std::find_if(codecs_before.begin(),
803 codecs_before.end(), is_flexfec)); 803 codecs_before.end(), is_flexfec));
804 804
805 // FlexFEC is active with field trial. 805 // FlexFEC is active with field trial.
806 webrtc::test::ScopedFieldTrials override_field_trials_( 806 webrtc::test::ScopedFieldTrials override_field_trials_(
807 "WebRTC-FlexFEC-03-Advertised/Enabled/"); 807 "WebRTC-FlexFEC-03-Advertised/Enabled/");
808 const std::vector<VideoCodec> codecs_after = engine_.codecs(); 808 const std::vector<VideoCodec> codecs_after = engine_.codecs();
809 EXPECT_NE(codecs_after.end(), 809 EXPECT_NE(codecs_after.end(),
810 std::find_if(codecs_after.begin(), codecs_after.end(), is_flexfec)); 810 std::find_if(codecs_after.begin(), codecs_after.end(), is_flexfec));
811 } 811 }
812 812
813 // Test that external codecs are added to the end of the supported codec list. 813 // Test that external codecs are added to the end of the supported codec list.
814 TEST_F(WebRtcVideoEngine2Test, ReportSupportedExternalCodecs) { 814 TEST_F(WebRtcVideoEngineTest, ReportSupportedExternalCodecs) {
815 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; 815 cricket::FakeWebRtcVideoEncoderFactory encoder_factory;
816 encoder_factory.AddSupportedVideoCodecType("FakeExternalCodec"); 816 encoder_factory.AddSupportedVideoCodecType("FakeExternalCodec");
817 engine_.SetExternalEncoderFactory(&encoder_factory); 817 engine_.SetExternalEncoderFactory(&encoder_factory);
818 engine_.Init(); 818 engine_.Init();
819 819
820 std::vector<cricket::VideoCodec> codecs(engine_.codecs()); 820 std::vector<cricket::VideoCodec> codecs(engine_.codecs());
821 ASSERT_GE(codecs.size(), 2u); 821 ASSERT_GE(codecs.size(), 2u);
822 cricket::VideoCodec internal_codec = codecs.front(); 822 cricket::VideoCodec internal_codec = codecs.front();
823 cricket::VideoCodec external_codec = codecs.back(); 823 cricket::VideoCodec external_codec = codecs.back();
824 824
825 // The external codec will appear last in the vector. 825 // The external codec will appear last in the vector.
826 EXPECT_EQ("VP8", internal_codec.name); 826 EXPECT_EQ("VP8", internal_codec.name);
827 EXPECT_EQ("FakeExternalCodec", external_codec.name); 827 EXPECT_EQ("FakeExternalCodec", external_codec.name);
828 } 828 }
829 829
830 // Test that an external codec that was added after the engine was initialized 830 // Test that an external codec that was added after the engine was initialized
831 // does show up in the codec list after it was added. 831 // does show up in the codec list after it was added.
832 TEST_F(WebRtcVideoEngine2Test, ReportSupportedExternalCodecsWithAddedCodec) { 832 TEST_F(WebRtcVideoEngineTest, ReportSupportedExternalCodecsWithAddedCodec) {
833 // Set up external encoder factory with first codec, and initialize engine. 833 // Set up external encoder factory with first codec, and initialize engine.
834 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; 834 cricket::FakeWebRtcVideoEncoderFactory encoder_factory;
835 encoder_factory.AddSupportedVideoCodecType("FakeExternalCodec1"); 835 encoder_factory.AddSupportedVideoCodecType("FakeExternalCodec1");
836 engine_.SetExternalEncoderFactory(&encoder_factory); 836 engine_.SetExternalEncoderFactory(&encoder_factory);
837 engine_.Init(); 837 engine_.Init();
838 838
839 // The first external codec will appear last in the vector. 839 // The first external codec will appear last in the vector.
840 std::vector<cricket::VideoCodec> codecs_before(engine_.codecs()); 840 std::vector<cricket::VideoCodec> codecs_before(engine_.codecs());
841 EXPECT_EQ("FakeExternalCodec1", codecs_before.back().name); 841 EXPECT_EQ("FakeExternalCodec1", codecs_before.back().name);
842 842
843 // Add second codec. 843 // Add second codec.
844 encoder_factory.AddSupportedVideoCodecType("FakeExternalCodec2"); 844 encoder_factory.AddSupportedVideoCodecType("FakeExternalCodec2");
845 std::vector<cricket::VideoCodec> codecs_after(engine_.codecs()); 845 std::vector<cricket::VideoCodec> codecs_after(engine_.codecs());
846 EXPECT_EQ(codecs_before.size() + 1, codecs_after.size()); 846 EXPECT_EQ(codecs_before.size() + 1, codecs_after.size());
847 EXPECT_EQ("FakeExternalCodec2", codecs_after.back().name); 847 EXPECT_EQ("FakeExternalCodec2", codecs_after.back().name);
848 } 848 }
849 849
850 TEST_F(WebRtcVideoEngine2Test, RegisterExternalDecodersIfSupported) { 850 TEST_F(WebRtcVideoEngineTest, RegisterExternalDecodersIfSupported) {
851 cricket::FakeWebRtcVideoDecoderFactory decoder_factory; 851 cricket::FakeWebRtcVideoDecoderFactory decoder_factory;
852 decoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8); 852 decoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8);
853 cricket::VideoRecvParameters parameters; 853 cricket::VideoRecvParameters parameters;
854 parameters.codecs.push_back(GetEngineCodec("VP8")); 854 parameters.codecs.push_back(GetEngineCodec("VP8"));
855 855
856 std::unique_ptr<VideoMediaChannel> channel( 856 std::unique_ptr<VideoMediaChannel> channel(
857 SetUpForExternalDecoderFactory(&decoder_factory, parameters.codecs)); 857 SetUpForExternalDecoderFactory(&decoder_factory, parameters.codecs));
858 858
859 EXPECT_TRUE( 859 EXPECT_TRUE(
860 channel->AddRecvStream(cricket::StreamParams::CreateLegacy(kSsrc))); 860 channel->AddRecvStream(cricket::StreamParams::CreateLegacy(kSsrc)));
861 ASSERT_EQ(1u, decoder_factory.decoders().size()); 861 ASSERT_EQ(1u, decoder_factory.decoders().size());
862 862
863 // Setting codecs of the same type should not reallocate the decoder. 863 // Setting codecs of the same type should not reallocate the decoder.
864 EXPECT_TRUE(channel->SetRecvParameters(parameters)); 864 EXPECT_TRUE(channel->SetRecvParameters(parameters));
865 EXPECT_EQ(1, decoder_factory.GetNumCreatedDecoders()); 865 EXPECT_EQ(1, decoder_factory.GetNumCreatedDecoders());
866 866
867 // Remove stream previously added to free the external decoder instance. 867 // Remove stream previously added to free the external decoder instance.
868 EXPECT_TRUE(channel->RemoveRecvStream(kSsrc)); 868 EXPECT_TRUE(channel->RemoveRecvStream(kSsrc));
869 EXPECT_EQ(0u, decoder_factory.decoders().size()); 869 EXPECT_EQ(0u, decoder_factory.decoders().size());
870 } 870 }
871 871
872 // Verifies that we can set up decoders that are not internally supported. 872 // Verifies that we can set up decoders that are not internally supported.
873 TEST_F(WebRtcVideoEngine2Test, RegisterExternalH264DecoderIfSupported) { 873 TEST_F(WebRtcVideoEngineTest, RegisterExternalH264DecoderIfSupported) {
874 // TODO(pbos): Do not assume that encoder/decoder support is symmetric. We 874 // TODO(pbos): Do not assume that encoder/decoder support is symmetric. We
875 // can't even query the WebRtcVideoDecoderFactory for supported codecs. 875 // can't even query the WebRtcVideoDecoderFactory for supported codecs.
876 // For now we add a FakeWebRtcVideoEncoderFactory to add H264 to supported 876 // For now we add a FakeWebRtcVideoEncoderFactory to add H264 to supported
877 // codecs. 877 // codecs.
878 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; 878 cricket::FakeWebRtcVideoEncoderFactory encoder_factory;
879 encoder_factory.AddSupportedVideoCodecType("H264"); 879 encoder_factory.AddSupportedVideoCodecType("H264");
880 engine_.SetExternalEncoderFactory(&encoder_factory); 880 engine_.SetExternalEncoderFactory(&encoder_factory);
881 cricket::FakeWebRtcVideoDecoderFactory decoder_factory; 881 cricket::FakeWebRtcVideoDecoderFactory decoder_factory;
882 decoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecH264); 882 decoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecH264);
883 std::vector<cricket::VideoCodec> codecs; 883 std::vector<cricket::VideoCodec> codecs;
884 codecs.push_back(GetEngineCodec("H264")); 884 codecs.push_back(GetEngineCodec("H264"));
885 885
886 std::unique_ptr<VideoMediaChannel> channel( 886 std::unique_ptr<VideoMediaChannel> channel(
887 SetUpForExternalDecoderFactory(&decoder_factory, codecs)); 887 SetUpForExternalDecoderFactory(&decoder_factory, codecs));
888 888
889 EXPECT_TRUE( 889 EXPECT_TRUE(
890 channel->AddRecvStream(cricket::StreamParams::CreateLegacy(kSsrc))); 890 channel->AddRecvStream(cricket::StreamParams::CreateLegacy(kSsrc)));
891 ASSERT_EQ(1u, decoder_factory.decoders().size()); 891 ASSERT_EQ(1u, decoder_factory.decoders().size());
892 } 892 }
893 893
894 class WebRtcVideoChannel2BaseTest 894 class WebRtcVideoChannelBaseTest
895 : public VideoMediaChannelTest<WebRtcVideoEngine2, WebRtcVideoChannel2> { 895 : public VideoMediaChannelTest<WebRtcVideoEngine, WebRtcVideoChannel> {
896 protected: 896 protected:
897 typedef VideoMediaChannelTest<WebRtcVideoEngine2, WebRtcVideoChannel2> Base; 897 typedef VideoMediaChannelTest<WebRtcVideoEngine, WebRtcVideoChannel> Base;
898 898
899 cricket::VideoCodec GetEngineCodec(const std::string& name) { 899 cricket::VideoCodec GetEngineCodec(const std::string& name) {
900 for (const cricket::VideoCodec& engine_codec : engine_.codecs()) { 900 for (const cricket::VideoCodec& engine_codec : engine_.codecs()) {
901 if (CodecNamesEq(name, engine_codec.name)) 901 if (CodecNamesEq(name, engine_codec.name))
902 return engine_codec; 902 return engine_codec;
903 } 903 }
904 // This point should never be reached. 904 // This point should never be reached.
905 ADD_FAILURE() << "Unrecognized codec name: " << name; 905 ADD_FAILURE() << "Unrecognized codec name: " << name;
906 return cricket::VideoCodec(); 906 return cricket::VideoCodec();
907 } 907 }
908 908
909 cricket::VideoCodec DefaultCodec() override { return GetEngineCodec("VP8"); } 909 cricket::VideoCodec DefaultCodec() override { return GetEngineCodec("VP8"); }
910 }; 910 };
911 911
912 // Verifies that id given in stream params is passed to the decoder factory. 912 // Verifies that id given in stream params is passed to the decoder factory.
913 TEST_F(WebRtcVideoEngine2Test, StreamParamsIdPassedToDecoderFactory) { 913 TEST_F(WebRtcVideoEngineTest, StreamParamsIdPassedToDecoderFactory) {
914 cricket::FakeWebRtcVideoDecoderFactory decoder_factory; 914 cricket::FakeWebRtcVideoDecoderFactory decoder_factory;
915 decoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8); 915 decoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8);
916 cricket::VideoRecvParameters parameters; 916 cricket::VideoRecvParameters parameters;
917 parameters.codecs.push_back(GetEngineCodec("VP8")); 917 parameters.codecs.push_back(GetEngineCodec("VP8"));
918 918
919 std::unique_ptr<VideoMediaChannel> channel( 919 std::unique_ptr<VideoMediaChannel> channel(
920 SetUpForExternalDecoderFactory(&decoder_factory, parameters.codecs)); 920 SetUpForExternalDecoderFactory(&decoder_factory, parameters.codecs));
921 921
922 StreamParams sp = cricket::StreamParams::CreateLegacy(kSsrc); 922 StreamParams sp = cricket::StreamParams::CreateLegacy(kSsrc);
923 sp.id = "FakeStreamParamsId"; 923 sp.id = "FakeStreamParamsId";
924 EXPECT_TRUE(channel->AddRecvStream(sp)); 924 EXPECT_TRUE(channel->AddRecvStream(sp));
925 EXPECT_EQ(1u, decoder_factory.decoders().size()); 925 EXPECT_EQ(1u, decoder_factory.decoders().size());
926 926
927 std::vector<cricket::VideoDecoderParams> params = decoder_factory.params(); 927 std::vector<cricket::VideoDecoderParams> params = decoder_factory.params();
928 ASSERT_EQ(1u, params.size()); 928 ASSERT_EQ(1u, params.size());
929 EXPECT_EQ(sp.id, params[0].receive_stream_id); 929 EXPECT_EQ(sp.id, params[0].receive_stream_id);
930 } 930 }
931 931
932 TEST_F(WebRtcVideoEngine2Test, DISABLED_RecreatesEncoderOnContentTypeChange) { 932 TEST_F(WebRtcVideoEngineTest, DISABLED_RecreatesEncoderOnContentTypeChange) {
933 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; 933 cricket::FakeWebRtcVideoEncoderFactory encoder_factory;
934 encoder_factory.AddSupportedVideoCodecType("VP8"); 934 encoder_factory.AddSupportedVideoCodecType("VP8");
935 std::unique_ptr<FakeCall> fake_call( 935 std::unique_ptr<FakeCall> fake_call(
936 new FakeCall(webrtc::Call::Config(&event_log_))); 936 new FakeCall(webrtc::Call::Config(&event_log_)));
937 std::unique_ptr<VideoMediaChannel> channel( 937 std::unique_ptr<VideoMediaChannel> channel(
938 SetUpForExternalEncoderFactory(&encoder_factory)); 938 SetUpForExternalEncoderFactory(&encoder_factory));
939 ASSERT_TRUE( 939 ASSERT_TRUE(
940 channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc))); 940 channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc)));
941 cricket::VideoCodec codec = GetEngineCodec("VP8"); 941 cricket::VideoCodec codec = GetEngineCodec("VP8");
942 cricket::VideoSendParameters parameters; 942 cricket::VideoSendParameters parameters;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
985 ASSERT_TRUE(encoder_factory.WaitForCreatedVideoEncoders(3)); 985 ASSERT_TRUE(encoder_factory.WaitForCreatedVideoEncoders(3));
986 EXPECT_EQ(webrtc::kRealtimeVideo, 986 EXPECT_EQ(webrtc::kRealtimeVideo,
987 encoder_factory.encoders().back()->GetCodecSettings().mode); 987 encoder_factory.encoders().back()->GetCodecSettings().mode);
988 988
989 // Remove stream previously added to free the external encoder instance. 989 // Remove stream previously added to free the external encoder instance.
990 EXPECT_TRUE(channel->RemoveSendStream(kSsrc)); 990 EXPECT_TRUE(channel->RemoveSendStream(kSsrc));
991 EXPECT_EQ(0u, encoder_factory.encoders().size()); 991 EXPECT_EQ(0u, encoder_factory.encoders().size());
992 } 992 }
993 993
994 #define WEBRTC_BASE_TEST(test) \ 994 #define WEBRTC_BASE_TEST(test) \
995 TEST_F(WebRtcVideoChannel2BaseTest, test) { Base::test(); } 995 TEST_F(WebRtcVideoChannelBaseTest, test) { Base::test(); }
996 996
997 #define WEBRTC_DISABLED_BASE_TEST(test) \ 997 #define WEBRTC_DISABLED_BASE_TEST(test) \
998 TEST_F(WebRtcVideoChannel2BaseTest, DISABLED_##test) { Base::test(); } 998 TEST_F(WebRtcVideoChannelBaseTest, DISABLED_##test) { Base::test(); }
999 999
1000 WEBRTC_BASE_TEST(SetSend); 1000 WEBRTC_BASE_TEST(SetSend);
1001 WEBRTC_BASE_TEST(SetSendWithoutCodecs); 1001 WEBRTC_BASE_TEST(SetSendWithoutCodecs);
1002 WEBRTC_BASE_TEST(SetSendSetsTransportBufferSizes); 1002 WEBRTC_BASE_TEST(SetSendSetsTransportBufferSizes);
1003 1003
1004 WEBRTC_BASE_TEST(GetStats); 1004 WEBRTC_BASE_TEST(GetStats);
1005 WEBRTC_BASE_TEST(GetStatsMultipleRecvStreams); 1005 WEBRTC_BASE_TEST(GetStatsMultipleRecvStreams);
1006 WEBRTC_BASE_TEST(GetStatsMultipleSendStreams); 1006 WEBRTC_BASE_TEST(GetStatsMultipleSendStreams);
1007 1007
1008 WEBRTC_BASE_TEST(SetSendBandwidth); 1008 WEBRTC_BASE_TEST(SetSendBandwidth);
(...skipping 10 matching lines...) Expand all
1019 WEBRTC_DISABLED_BASE_TEST(AddRemoveCapturer); 1019 WEBRTC_DISABLED_BASE_TEST(AddRemoveCapturer);
1020 1020
1021 WEBRTC_BASE_TEST(RemoveCapturerWithoutAdd); 1021 WEBRTC_BASE_TEST(RemoveCapturerWithoutAdd);
1022 1022
1023 WEBRTC_BASE_TEST(AddRemoveCapturerMultipleSources); 1023 WEBRTC_BASE_TEST(AddRemoveCapturerMultipleSources);
1024 1024
1025 WEBRTC_BASE_TEST(RejectEmptyStreamParams); 1025 WEBRTC_BASE_TEST(RejectEmptyStreamParams);
1026 1026
1027 WEBRTC_BASE_TEST(MultipleSendStreams); 1027 WEBRTC_BASE_TEST(MultipleSendStreams);
1028 1028
1029 TEST_F(WebRtcVideoChannel2BaseTest, SendAndReceiveVp8Vga) { 1029 TEST_F(WebRtcVideoChannelBaseTest, SendAndReceiveVp8Vga) {
1030 SendAndReceive(GetEngineCodec("VP8")); 1030 SendAndReceive(GetEngineCodec("VP8"));
1031 } 1031 }
1032 1032
1033 TEST_F(WebRtcVideoChannel2BaseTest, SendAndReceiveVp8Qvga) { 1033 TEST_F(WebRtcVideoChannelBaseTest, SendAndReceiveVp8Qvga) {
1034 SendAndReceive(GetEngineCodec("VP8")); 1034 SendAndReceive(GetEngineCodec("VP8"));
1035 } 1035 }
1036 1036
1037 TEST_F(WebRtcVideoChannel2BaseTest, SendAndReceiveVp8SvcQqvga) { 1037 TEST_F(WebRtcVideoChannelBaseTest, SendAndReceiveVp8SvcQqvga) {
1038 SendAndReceive(GetEngineCodec("VP8")); 1038 SendAndReceive(GetEngineCodec("VP8"));
1039 } 1039 }
1040 1040
1041 TEST_F(WebRtcVideoChannel2BaseTest, TwoStreamsSendAndReceive) { 1041 TEST_F(WebRtcVideoChannelBaseTest, TwoStreamsSendAndReceive) {
1042 // Set a high bitrate to not be downscaled by VP8 due to low initial start 1042 // Set a high bitrate to not be downscaled by VP8 due to low initial start
1043 // bitrates. This currently happens at <250k, and two streams sharing 300k 1043 // bitrates. This currently happens at <250k, and two streams sharing 300k
1044 // initially will use QVGA instead of VGA. 1044 // initially will use QVGA instead of VGA.
1045 // TODO(pbos): Set up the quality scaler so that both senders reliably start 1045 // TODO(pbos): Set up the quality scaler so that both senders reliably start
1046 // at QVGA, then verify that instead. 1046 // at QVGA, then verify that instead.
1047 cricket::VideoCodec codec = GetEngineCodec("VP8"); 1047 cricket::VideoCodec codec = GetEngineCodec("VP8");
1048 codec.params[kCodecParamStartBitrate] = "1000000"; 1048 codec.params[kCodecParamStartBitrate] = "1000000";
1049 Base::TwoStreamsSendAndReceive(codec); 1049 Base::TwoStreamsSendAndReceive(codec);
1050 } 1050 }
1051 1051
1052 class WebRtcVideoChannel2Test : public WebRtcVideoEngine2Test { 1052 class WebRtcVideoChannelTest : public WebRtcVideoEngineTest {
1053 public: 1053 public:
1054 WebRtcVideoChannel2Test() : WebRtcVideoChannel2Test("") {} 1054 WebRtcVideoChannelTest() : WebRtcVideoChannelTest("") {}
1055 explicit WebRtcVideoChannel2Test(const char* field_trials) 1055 explicit WebRtcVideoChannelTest(const char* field_trials)
1056 : WebRtcVideoEngine2Test(field_trials), last_ssrc_(0) {} 1056 : WebRtcVideoEngineTest(field_trials), last_ssrc_(0) {}
1057 void SetUp() override { 1057 void SetUp() override {
1058 fake_call_.reset(new FakeCall(webrtc::Call::Config(&event_log_))); 1058 fake_call_.reset(new FakeCall(webrtc::Call::Config(&event_log_)));
1059 engine_.Init(); 1059 engine_.Init();
1060 channel_.reset(engine_.CreateChannel(fake_call_.get(), GetMediaConfig(), 1060 channel_.reset(engine_.CreateChannel(fake_call_.get(), GetMediaConfig(),
1061 VideoOptions())); 1061 VideoOptions()));
1062 channel_->OnReadyToSend(true); 1062 channel_->OnReadyToSend(true);
1063 last_ssrc_ = 123; 1063 last_ssrc_ = 123;
1064 send_parameters_.codecs = engine_.codecs(); 1064 send_parameters_.codecs = engine_.codecs();
1065 recv_parameters_.codecs = engine_.codecs(); 1065 recv_parameters_.codecs = engine_.codecs();
1066 ASSERT_TRUE(channel_->SetSendParameters(send_parameters_)); 1066 ASSERT_TRUE(channel_->SetSendParameters(send_parameters_));
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
1282 EXPECT_EQ(expected_encoder_bitrate, GetMaxEncoderBitrate()); 1282 EXPECT_EQ(expected_encoder_bitrate, GetMaxEncoderBitrate());
1283 } 1283 }
1284 1284
1285 std::unique_ptr<FakeCall> fake_call_; 1285 std::unique_ptr<FakeCall> fake_call_;
1286 std::unique_ptr<VideoMediaChannel> channel_; 1286 std::unique_ptr<VideoMediaChannel> channel_;
1287 cricket::VideoSendParameters send_parameters_; 1287 cricket::VideoSendParameters send_parameters_;
1288 cricket::VideoRecvParameters recv_parameters_; 1288 cricket::VideoRecvParameters recv_parameters_;
1289 uint32_t last_ssrc_; 1289 uint32_t last_ssrc_;
1290 }; 1290 };
1291 1291
1292 TEST_F(WebRtcVideoChannel2Test, SetsSyncGroupFromSyncLabel) { 1292 TEST_F(WebRtcVideoChannelTest, SetsSyncGroupFromSyncLabel) {
1293 const uint32_t kVideoSsrc = 123; 1293 const uint32_t kVideoSsrc = 123;
1294 const std::string kSyncLabel = "AvSyncLabel"; 1294 const std::string kSyncLabel = "AvSyncLabel";
1295 1295
1296 cricket::StreamParams sp = cricket::StreamParams::CreateLegacy(kVideoSsrc); 1296 cricket::StreamParams sp = cricket::StreamParams::CreateLegacy(kVideoSsrc);
1297 sp.sync_label = kSyncLabel; 1297 sp.sync_label = kSyncLabel;
1298 EXPECT_TRUE(channel_->AddRecvStream(sp)); 1298 EXPECT_TRUE(channel_->AddRecvStream(sp));
1299 1299
1300 EXPECT_EQ(1, fake_call_->GetVideoReceiveStreams().size()); 1300 EXPECT_EQ(1, fake_call_->GetVideoReceiveStreams().size());
1301 EXPECT_EQ(kSyncLabel, 1301 EXPECT_EQ(kSyncLabel,
1302 fake_call_->GetVideoReceiveStreams()[0]->GetConfig().sync_group) 1302 fake_call_->GetVideoReceiveStreams()[0]->GetConfig().sync_group)
1303 << "SyncGroup should be set based on sync_label"; 1303 << "SyncGroup should be set based on sync_label";
1304 } 1304 }
1305 1305
1306 TEST_F(WebRtcVideoChannel2Test, RecvStreamWithSimAndRtx) { 1306 TEST_F(WebRtcVideoChannelTest, RecvStreamWithSimAndRtx) {
1307 cricket::VideoSendParameters parameters; 1307 cricket::VideoSendParameters parameters;
1308 parameters.codecs = engine_.codecs(); 1308 parameters.codecs = engine_.codecs();
1309 EXPECT_TRUE(channel_->SetSendParameters(parameters)); 1309 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1310 EXPECT_TRUE(channel_->SetSend(true)); 1310 EXPECT_TRUE(channel_->SetSend(true));
1311 parameters.conference_mode = true; 1311 parameters.conference_mode = true;
1312 EXPECT_TRUE(channel_->SetSendParameters(parameters)); 1312 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1313 1313
1314 // Send side. 1314 // Send side.
1315 const std::vector<uint32_t> ssrcs = MAKE_VECTOR(kSsrcs1); 1315 const std::vector<uint32_t> ssrcs = MAKE_VECTOR(kSsrcs1);
1316 const std::vector<uint32_t> rtx_ssrcs = MAKE_VECTOR(kRtxSsrcs1); 1316 const std::vector<uint32_t> rtx_ssrcs = MAKE_VECTOR(kRtxSsrcs1);
1317 FakeVideoSendStream* send_stream = AddSendStream( 1317 FakeVideoSendStream* send_stream = AddSendStream(
1318 cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs)); 1318 cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs));
1319 1319
1320 ASSERT_EQ(rtx_ssrcs.size(), send_stream->GetConfig().rtp.rtx.ssrcs.size()); 1320 ASSERT_EQ(rtx_ssrcs.size(), send_stream->GetConfig().rtp.rtx.ssrcs.size());
1321 for (size_t i = 0; i < rtx_ssrcs.size(); ++i) 1321 for (size_t i = 0; i < rtx_ssrcs.size(); ++i)
1322 EXPECT_EQ(rtx_ssrcs[i], send_stream->GetConfig().rtp.rtx.ssrcs[i]); 1322 EXPECT_EQ(rtx_ssrcs[i], send_stream->GetConfig().rtp.rtx.ssrcs[i]);
1323 1323
1324 // Receiver side. 1324 // Receiver side.
1325 FakeVideoReceiveStream* recv_stream = AddRecvStream( 1325 FakeVideoReceiveStream* recv_stream = AddRecvStream(
1326 cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs)); 1326 cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs));
1327 EXPECT_FALSE(recv_stream->GetConfig().rtp.rtx_payload_types.empty()); 1327 EXPECT_FALSE(recv_stream->GetConfig().rtp.rtx_payload_types.empty());
1328 EXPECT_EQ(recv_stream->GetConfig().decoders.size(), 1328 EXPECT_EQ(recv_stream->GetConfig().decoders.size(),
1329 recv_stream->GetConfig().rtp.rtx_payload_types.size()) 1329 recv_stream->GetConfig().rtp.rtx_payload_types.size())
1330 << "RTX should be mapped for all decoders/payload types."; 1330 << "RTX should be mapped for all decoders/payload types.";
1331 EXPECT_EQ(rtx_ssrcs[0], recv_stream->GetConfig().rtp.rtx_ssrc); 1331 EXPECT_EQ(rtx_ssrcs[0], recv_stream->GetConfig().rtp.rtx_ssrc);
1332 } 1332 }
1333 1333
1334 TEST_F(WebRtcVideoChannel2Test, RecvStreamWithRtx) { 1334 TEST_F(WebRtcVideoChannelTest, RecvStreamWithRtx) {
1335 // Setup one channel with an associated RTX stream. 1335 // Setup one channel with an associated RTX stream.
1336 cricket::StreamParams params = 1336 cricket::StreamParams params =
1337 cricket::StreamParams::CreateLegacy(kSsrcs1[0]); 1337 cricket::StreamParams::CreateLegacy(kSsrcs1[0]);
1338 params.AddFidSsrc(kSsrcs1[0], kRtxSsrcs1[0]); 1338 params.AddFidSsrc(kSsrcs1[0], kRtxSsrcs1[0]);
1339 FakeVideoReceiveStream* recv_stream = AddRecvStream(params); 1339 FakeVideoReceiveStream* recv_stream = AddRecvStream(params);
1340 EXPECT_EQ(kRtxSsrcs1[0], recv_stream->GetConfig().rtp.rtx_ssrc); 1340 EXPECT_EQ(kRtxSsrcs1[0], recv_stream->GetConfig().rtp.rtx_ssrc);
1341 } 1341 }
1342 1342
1343 TEST_F(WebRtcVideoChannel2Test, RecvStreamNoRtx) { 1343 TEST_F(WebRtcVideoChannelTest, RecvStreamNoRtx) {
1344 // Setup one channel without an associated RTX stream. 1344 // Setup one channel without an associated RTX stream.
1345 cricket::StreamParams params = 1345 cricket::StreamParams params =
1346 cricket::StreamParams::CreateLegacy(kSsrcs1[0]); 1346 cricket::StreamParams::CreateLegacy(kSsrcs1[0]);
1347 FakeVideoReceiveStream* recv_stream = AddRecvStream(params); 1347 FakeVideoReceiveStream* recv_stream = AddRecvStream(params);
1348 ASSERT_EQ(0U, recv_stream->GetConfig().rtp.rtx_ssrc); 1348 ASSERT_EQ(0U, recv_stream->GetConfig().rtp.rtx_ssrc);
1349 } 1349 }
1350 1350
1351 TEST_F(WebRtcVideoChannel2Test, NoHeaderExtesionsByDefault) { 1351 TEST_F(WebRtcVideoChannelTest, NoHeaderExtesionsByDefault) {
1352 FakeVideoSendStream* send_stream = 1352 FakeVideoSendStream* send_stream =
1353 AddSendStream(cricket::StreamParams::CreateLegacy(kSsrcs1[0])); 1353 AddSendStream(cricket::StreamParams::CreateLegacy(kSsrcs1[0]));
1354 ASSERT_TRUE(send_stream->GetConfig().rtp.extensions.empty()); 1354 ASSERT_TRUE(send_stream->GetConfig().rtp.extensions.empty());
1355 1355
1356 FakeVideoReceiveStream* recv_stream = 1356 FakeVideoReceiveStream* recv_stream =
1357 AddRecvStream(cricket::StreamParams::CreateLegacy(kSsrcs1[0])); 1357 AddRecvStream(cricket::StreamParams::CreateLegacy(kSsrcs1[0]));
1358 ASSERT_TRUE(recv_stream->GetConfig().rtp.extensions.empty()); 1358 ASSERT_TRUE(recv_stream->GetConfig().rtp.extensions.empty());
1359 } 1359 }
1360 1360
1361 // Test support for RTP timestamp offset header extension. 1361 // Test support for RTP timestamp offset header extension.
1362 TEST_F(WebRtcVideoChannel2Test, SendRtpTimestampOffsetHeaderExtensions) { 1362 TEST_F(WebRtcVideoChannelTest, SendRtpTimestampOffsetHeaderExtensions) {
1363 TestSetSendRtpHeaderExtensions(RtpExtension::kTimestampOffsetUri); 1363 TestSetSendRtpHeaderExtensions(RtpExtension::kTimestampOffsetUri);
1364 } 1364 }
1365 1365
1366 TEST_F(WebRtcVideoChannel2Test, RecvRtpTimestampOffsetHeaderExtensions) { 1366 TEST_F(WebRtcVideoChannelTest, RecvRtpTimestampOffsetHeaderExtensions) {
1367 TestSetRecvRtpHeaderExtensions(RtpExtension::kTimestampOffsetUri); 1367 TestSetRecvRtpHeaderExtensions(RtpExtension::kTimestampOffsetUri);
1368 } 1368 }
1369 1369
1370 // Test support for absolute send time header extension. 1370 // Test support for absolute send time header extension.
1371 TEST_F(WebRtcVideoChannel2Test, SendAbsoluteSendTimeHeaderExtensions) { 1371 TEST_F(WebRtcVideoChannelTest, SendAbsoluteSendTimeHeaderExtensions) {
1372 TestSetSendRtpHeaderExtensions(RtpExtension::kAbsSendTimeUri); 1372 TestSetSendRtpHeaderExtensions(RtpExtension::kAbsSendTimeUri);
1373 } 1373 }
1374 1374
1375 TEST_F(WebRtcVideoChannel2Test, RecvAbsoluteSendTimeHeaderExtensions) { 1375 TEST_F(WebRtcVideoChannelTest, RecvAbsoluteSendTimeHeaderExtensions) {
1376 TestSetRecvRtpHeaderExtensions(RtpExtension::kAbsSendTimeUri); 1376 TestSetRecvRtpHeaderExtensions(RtpExtension::kAbsSendTimeUri);
1377 } 1377 }
1378 1378
1379 TEST_F(WebRtcVideoChannel2Test, FiltersExtensionsPicksTransportSeqNum) { 1379 TEST_F(WebRtcVideoChannelTest, FiltersExtensionsPicksTransportSeqNum) {
1380 // Enable three redundant extensions. 1380 // Enable three redundant extensions.
1381 std::vector<std::string> extensions; 1381 std::vector<std::string> extensions;
1382 extensions.push_back(RtpExtension::kAbsSendTimeUri); 1382 extensions.push_back(RtpExtension::kAbsSendTimeUri);
1383 extensions.push_back(RtpExtension::kTimestampOffsetUri); 1383 extensions.push_back(RtpExtension::kTimestampOffsetUri);
1384 extensions.push_back(RtpExtension::kTransportSequenceNumberUri); 1384 extensions.push_back(RtpExtension::kTransportSequenceNumberUri);
1385 TestExtensionFilter(extensions, RtpExtension::kTransportSequenceNumberUri); 1385 TestExtensionFilter(extensions, RtpExtension::kTransportSequenceNumberUri);
1386 } 1386 }
1387 1387
1388 TEST_F(WebRtcVideoChannel2Test, FiltersExtensionsPicksAbsSendTime) { 1388 TEST_F(WebRtcVideoChannelTest, FiltersExtensionsPicksAbsSendTime) {
1389 // Enable two redundant extensions. 1389 // Enable two redundant extensions.
1390 std::vector<std::string> extensions; 1390 std::vector<std::string> extensions;
1391 extensions.push_back(RtpExtension::kAbsSendTimeUri); 1391 extensions.push_back(RtpExtension::kAbsSendTimeUri);
1392 extensions.push_back(RtpExtension::kTimestampOffsetUri); 1392 extensions.push_back(RtpExtension::kTimestampOffsetUri);
1393 TestExtensionFilter(extensions, RtpExtension::kAbsSendTimeUri); 1393 TestExtensionFilter(extensions, RtpExtension::kAbsSendTimeUri);
1394 } 1394 }
1395 1395
1396 // Test support for transport sequence number header extension. 1396 // Test support for transport sequence number header extension.
1397 TEST_F(WebRtcVideoChannel2Test, SendTransportSequenceNumberHeaderExtensions) { 1397 TEST_F(WebRtcVideoChannelTest, SendTransportSequenceNumberHeaderExtensions) {
1398 TestSetSendRtpHeaderExtensions(RtpExtension::kTransportSequenceNumberUri); 1398 TestSetSendRtpHeaderExtensions(RtpExtension::kTransportSequenceNumberUri);
1399 } 1399 }
1400 TEST_F(WebRtcVideoChannel2Test, RecvTransportSequenceNumberHeaderExtensions) { 1400 TEST_F(WebRtcVideoChannelTest, RecvTransportSequenceNumberHeaderExtensions) {
1401 TestSetRecvRtpHeaderExtensions(RtpExtension::kTransportSequenceNumberUri); 1401 TestSetRecvRtpHeaderExtensions(RtpExtension::kTransportSequenceNumberUri);
1402 } 1402 }
1403 1403
1404 // Test support for video rotation header extension. 1404 // Test support for video rotation header extension.
1405 TEST_F(WebRtcVideoChannel2Test, SendVideoRotationHeaderExtensions) { 1405 TEST_F(WebRtcVideoChannelTest, SendVideoRotationHeaderExtensions) {
1406 TestSetSendRtpHeaderExtensions(RtpExtension::kVideoRotationUri); 1406 TestSetSendRtpHeaderExtensions(RtpExtension::kVideoRotationUri);
1407 } 1407 }
1408 TEST_F(WebRtcVideoChannel2Test, RecvVideoRotationHeaderExtensions) { 1408 TEST_F(WebRtcVideoChannelTest, RecvVideoRotationHeaderExtensions) {
1409 TestSetRecvRtpHeaderExtensions(RtpExtension::kVideoRotationUri); 1409 TestSetRecvRtpHeaderExtensions(RtpExtension::kVideoRotationUri);
1410 } 1410 }
1411 1411
1412 TEST_F(WebRtcVideoChannel2Test, IdenticalSendExtensionsDoesntRecreateStream) { 1412 TEST_F(WebRtcVideoChannelTest, IdenticalSendExtensionsDoesntRecreateStream) {
1413 const int kAbsSendTimeId = 1; 1413 const int kAbsSendTimeId = 1;
1414 const int kVideoRotationId = 2; 1414 const int kVideoRotationId = 2;
1415 send_parameters_.extensions.push_back( 1415 send_parameters_.extensions.push_back(
1416 RtpExtension(RtpExtension::kAbsSendTimeUri, kAbsSendTimeId)); 1416 RtpExtension(RtpExtension::kAbsSendTimeUri, kAbsSendTimeId));
1417 send_parameters_.extensions.push_back( 1417 send_parameters_.extensions.push_back(
1418 RtpExtension(RtpExtension::kVideoRotationUri, kVideoRotationId)); 1418 RtpExtension(RtpExtension::kVideoRotationUri, kVideoRotationId));
1419 1419
1420 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); 1420 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
1421 FakeVideoSendStream* send_stream = 1421 FakeVideoSendStream* send_stream =
1422 AddSendStream(cricket::StreamParams::CreateLegacy(123)); 1422 AddSendStream(cricket::StreamParams::CreateLegacy(123));
1423 1423
1424 EXPECT_EQ(1, fake_call_->GetNumCreatedSendStreams()); 1424 EXPECT_EQ(1, fake_call_->GetNumCreatedSendStreams());
1425 ASSERT_EQ(2u, send_stream->GetConfig().rtp.extensions.size()); 1425 ASSERT_EQ(2u, send_stream->GetConfig().rtp.extensions.size());
1426 1426
1427 // Setting the same extensions (even if in different order) shouldn't 1427 // Setting the same extensions (even if in different order) shouldn't
1428 // reallocate the stream. 1428 // reallocate the stream.
1429 std::reverse(send_parameters_.extensions.begin(), 1429 std::reverse(send_parameters_.extensions.begin(),
1430 send_parameters_.extensions.end()); 1430 send_parameters_.extensions.end());
1431 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); 1431 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
1432 1432
1433 EXPECT_EQ(1, fake_call_->GetNumCreatedSendStreams()); 1433 EXPECT_EQ(1, fake_call_->GetNumCreatedSendStreams());
1434 1434
1435 // Setting different extensions should recreate the stream. 1435 // Setting different extensions should recreate the stream.
1436 send_parameters_.extensions.resize(1); 1436 send_parameters_.extensions.resize(1);
1437 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); 1437 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
1438 1438
1439 EXPECT_EQ(2, fake_call_->GetNumCreatedSendStreams()); 1439 EXPECT_EQ(2, fake_call_->GetNumCreatedSendStreams());
1440 } 1440 }
1441 1441
1442 TEST_F(WebRtcVideoChannel2Test, IdenticalRecvExtensionsDoesntRecreateStream) { 1442 TEST_F(WebRtcVideoChannelTest, IdenticalRecvExtensionsDoesntRecreateStream) {
1443 const int kTOffsetId = 1; 1443 const int kTOffsetId = 1;
1444 const int kAbsSendTimeId = 2; 1444 const int kAbsSendTimeId = 2;
1445 const int kVideoRotationId = 3; 1445 const int kVideoRotationId = 3;
1446 recv_parameters_.extensions.push_back( 1446 recv_parameters_.extensions.push_back(
1447 RtpExtension(RtpExtension::kAbsSendTimeUri, kAbsSendTimeId)); 1447 RtpExtension(RtpExtension::kAbsSendTimeUri, kAbsSendTimeId));
1448 recv_parameters_.extensions.push_back( 1448 recv_parameters_.extensions.push_back(
1449 RtpExtension(RtpExtension::kTimestampOffsetUri, kTOffsetId)); 1449 RtpExtension(RtpExtension::kTimestampOffsetUri, kTOffsetId));
1450 recv_parameters_.extensions.push_back( 1450 recv_parameters_.extensions.push_back(
1451 RtpExtension(RtpExtension::kVideoRotationUri, kVideoRotationId)); 1451 RtpExtension(RtpExtension::kVideoRotationUri, kVideoRotationId));
1452 1452
(...skipping 12 matching lines...) Expand all
1465 1465
1466 EXPECT_EQ(1, fake_call_->GetNumCreatedReceiveStreams()); 1466 EXPECT_EQ(1, fake_call_->GetNumCreatedReceiveStreams());
1467 1467
1468 // Setting different extensions should recreate the stream. 1468 // Setting different extensions should recreate the stream.
1469 recv_parameters_.extensions.resize(1); 1469 recv_parameters_.extensions.resize(1);
1470 EXPECT_TRUE(channel_->SetRecvParameters(recv_parameters_)); 1470 EXPECT_TRUE(channel_->SetRecvParameters(recv_parameters_));
1471 1471
1472 EXPECT_EQ(2, fake_call_->GetNumCreatedReceiveStreams()); 1472 EXPECT_EQ(2, fake_call_->GetNumCreatedReceiveStreams());
1473 } 1473 }
1474 1474
1475 TEST_F(WebRtcVideoChannel2Test, 1475 TEST_F(WebRtcVideoChannelTest,
1476 SetSendRtpHeaderExtensionsExcludeUnsupportedExtensions) { 1476 SetSendRtpHeaderExtensionsExcludeUnsupportedExtensions) {
1477 const int kUnsupportedId = 1; 1477 const int kUnsupportedId = 1;
1478 const int kTOffsetId = 2; 1478 const int kTOffsetId = 2;
1479 1479
1480 send_parameters_.extensions.push_back( 1480 send_parameters_.extensions.push_back(
1481 RtpExtension(kUnsupportedExtensionName, kUnsupportedId)); 1481 RtpExtension(kUnsupportedExtensionName, kUnsupportedId));
1482 send_parameters_.extensions.push_back( 1482 send_parameters_.extensions.push_back(
1483 RtpExtension(RtpExtension::kTimestampOffsetUri, kTOffsetId)); 1483 RtpExtension(RtpExtension::kTimestampOffsetUri, kTOffsetId));
1484 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); 1484 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
1485 FakeVideoSendStream* send_stream = 1485 FakeVideoSendStream* send_stream =
1486 AddSendStream(cricket::StreamParams::CreateLegacy(123)); 1486 AddSendStream(cricket::StreamParams::CreateLegacy(123));
1487 1487
1488 // Only timestamp offset extension is set to send stream, 1488 // Only timestamp offset extension is set to send stream,
1489 // unsupported rtp extension is ignored. 1489 // unsupported rtp extension is ignored.
1490 ASSERT_EQ(1u, send_stream->GetConfig().rtp.extensions.size()); 1490 ASSERT_EQ(1u, send_stream->GetConfig().rtp.extensions.size());
1491 EXPECT_STREQ(RtpExtension::kTimestampOffsetUri, 1491 EXPECT_STREQ(RtpExtension::kTimestampOffsetUri,
1492 send_stream->GetConfig().rtp.extensions[0].uri.c_str()); 1492 send_stream->GetConfig().rtp.extensions[0].uri.c_str());
1493 } 1493 }
1494 1494
1495 TEST_F(WebRtcVideoChannel2Test, 1495 TEST_F(WebRtcVideoChannelTest,
1496 SetRecvRtpHeaderExtensionsExcludeUnsupportedExtensions) { 1496 SetRecvRtpHeaderExtensionsExcludeUnsupportedExtensions) {
1497 const int kUnsupportedId = 1; 1497 const int kUnsupportedId = 1;
1498 const int kTOffsetId = 2; 1498 const int kTOffsetId = 2;
1499 1499
1500 recv_parameters_.extensions.push_back( 1500 recv_parameters_.extensions.push_back(
1501 RtpExtension(kUnsupportedExtensionName, kUnsupportedId)); 1501 RtpExtension(kUnsupportedExtensionName, kUnsupportedId));
1502 recv_parameters_.extensions.push_back( 1502 recv_parameters_.extensions.push_back(
1503 RtpExtension(RtpExtension::kTimestampOffsetUri, kTOffsetId)); 1503 RtpExtension(RtpExtension::kTimestampOffsetUri, kTOffsetId));
1504 EXPECT_TRUE(channel_->SetRecvParameters(recv_parameters_)); 1504 EXPECT_TRUE(channel_->SetRecvParameters(recv_parameters_));
1505 FakeVideoReceiveStream* recv_stream = 1505 FakeVideoReceiveStream* recv_stream =
1506 AddRecvStream(cricket::StreamParams::CreateLegacy(123)); 1506 AddRecvStream(cricket::StreamParams::CreateLegacy(123));
1507 1507
1508 // Only timestamp offset extension is set to receive stream, 1508 // Only timestamp offset extension is set to receive stream,
1509 // unsupported rtp extension is ignored. 1509 // unsupported rtp extension is ignored.
1510 ASSERT_EQ(1u, recv_stream->GetConfig().rtp.extensions.size()); 1510 ASSERT_EQ(1u, recv_stream->GetConfig().rtp.extensions.size());
1511 EXPECT_STREQ(RtpExtension::kTimestampOffsetUri, 1511 EXPECT_STREQ(RtpExtension::kTimestampOffsetUri,
1512 recv_stream->GetConfig().rtp.extensions[0].uri.c_str()); 1512 recv_stream->GetConfig().rtp.extensions[0].uri.c_str());
1513 } 1513 }
1514 1514
1515 TEST_F(WebRtcVideoChannel2Test, SetSendRtpHeaderExtensionsRejectsIncorrectIds) { 1515 TEST_F(WebRtcVideoChannelTest, SetSendRtpHeaderExtensionsRejectsIncorrectIds) {
1516 const int kIncorrectIds[] = {-2, -1, 0, 15, 16}; 1516 const int kIncorrectIds[] = {-2, -1, 0, 15, 16};
1517 for (size_t i = 0; i < arraysize(kIncorrectIds); ++i) { 1517 for (size_t i = 0; i < arraysize(kIncorrectIds); ++i) {
1518 send_parameters_.extensions.push_back( 1518 send_parameters_.extensions.push_back(
1519 RtpExtension(RtpExtension::kTimestampOffsetUri, kIncorrectIds[i])); 1519 RtpExtension(RtpExtension::kTimestampOffsetUri, kIncorrectIds[i]));
1520 EXPECT_FALSE(channel_->SetSendParameters(send_parameters_)) 1520 EXPECT_FALSE(channel_->SetSendParameters(send_parameters_))
1521 << "Bad extension id '" << kIncorrectIds[i] << "' accepted."; 1521 << "Bad extension id '" << kIncorrectIds[i] << "' accepted.";
1522 } 1522 }
1523 } 1523 }
1524 1524
1525 TEST_F(WebRtcVideoChannel2Test, SetRecvRtpHeaderExtensionsRejectsIncorrectIds) { 1525 TEST_F(WebRtcVideoChannelTest, SetRecvRtpHeaderExtensionsRejectsIncorrectIds) {
1526 const int kIncorrectIds[] = {-2, -1, 0, 15, 16}; 1526 const int kIncorrectIds[] = {-2, -1, 0, 15, 16};
1527 for (size_t i = 0; i < arraysize(kIncorrectIds); ++i) { 1527 for (size_t i = 0; i < arraysize(kIncorrectIds); ++i) {
1528 recv_parameters_.extensions.push_back( 1528 recv_parameters_.extensions.push_back(
1529 RtpExtension(RtpExtension::kTimestampOffsetUri, kIncorrectIds[i])); 1529 RtpExtension(RtpExtension::kTimestampOffsetUri, kIncorrectIds[i]));
1530 EXPECT_FALSE(channel_->SetRecvParameters(recv_parameters_)) 1530 EXPECT_FALSE(channel_->SetRecvParameters(recv_parameters_))
1531 << "Bad extension id '" << kIncorrectIds[i] << "' accepted."; 1531 << "Bad extension id '" << kIncorrectIds[i] << "' accepted.";
1532 } 1532 }
1533 } 1533 }
1534 1534
1535 TEST_F(WebRtcVideoChannel2Test, SetSendRtpHeaderExtensionsRejectsDuplicateIds) { 1535 TEST_F(WebRtcVideoChannelTest, SetSendRtpHeaderExtensionsRejectsDuplicateIds) {
1536 const int id = 1; 1536 const int id = 1;
1537 send_parameters_.extensions.push_back( 1537 send_parameters_.extensions.push_back(
1538 RtpExtension(RtpExtension::kTimestampOffsetUri, id)); 1538 RtpExtension(RtpExtension::kTimestampOffsetUri, id));
1539 send_parameters_.extensions.push_back( 1539 send_parameters_.extensions.push_back(
1540 RtpExtension(RtpExtension::kAbsSendTimeUri, id)); 1540 RtpExtension(RtpExtension::kAbsSendTimeUri, id));
1541 EXPECT_FALSE(channel_->SetSendParameters(send_parameters_)); 1541 EXPECT_FALSE(channel_->SetSendParameters(send_parameters_));
1542 1542
1543 // Duplicate entries are also not supported. 1543 // Duplicate entries are also not supported.
1544 send_parameters_.extensions.clear(); 1544 send_parameters_.extensions.clear();
1545 send_parameters_.extensions.push_back( 1545 send_parameters_.extensions.push_back(
1546 RtpExtension(RtpExtension::kTimestampOffsetUri, id)); 1546 RtpExtension(RtpExtension::kTimestampOffsetUri, id));
1547 send_parameters_.extensions.push_back(send_parameters_.extensions.back()); 1547 send_parameters_.extensions.push_back(send_parameters_.extensions.back());
1548 EXPECT_FALSE(channel_->SetSendParameters(send_parameters_)); 1548 EXPECT_FALSE(channel_->SetSendParameters(send_parameters_));
1549 } 1549 }
1550 1550
1551 TEST_F(WebRtcVideoChannel2Test, SetRecvRtpHeaderExtensionsRejectsDuplicateIds) { 1551 TEST_F(WebRtcVideoChannelTest, SetRecvRtpHeaderExtensionsRejectsDuplicateIds) {
1552 const int id = 1; 1552 const int id = 1;
1553 recv_parameters_.extensions.push_back( 1553 recv_parameters_.extensions.push_back(
1554 RtpExtension(RtpExtension::kTimestampOffsetUri, id)); 1554 RtpExtension(RtpExtension::kTimestampOffsetUri, id));
1555 recv_parameters_.extensions.push_back( 1555 recv_parameters_.extensions.push_back(
1556 RtpExtension(RtpExtension::kAbsSendTimeUri, id)); 1556 RtpExtension(RtpExtension::kAbsSendTimeUri, id));
1557 EXPECT_FALSE(channel_->SetRecvParameters(recv_parameters_)); 1557 EXPECT_FALSE(channel_->SetRecvParameters(recv_parameters_));
1558 1558
1559 // Duplicate entries are also not supported. 1559 // Duplicate entries are also not supported.
1560 recv_parameters_.extensions.clear(); 1560 recv_parameters_.extensions.clear();
1561 recv_parameters_.extensions.push_back( 1561 recv_parameters_.extensions.push_back(
1562 RtpExtension(RtpExtension::kTimestampOffsetUri, id)); 1562 RtpExtension(RtpExtension::kTimestampOffsetUri, id));
1563 recv_parameters_.extensions.push_back(recv_parameters_.extensions.back()); 1563 recv_parameters_.extensions.push_back(recv_parameters_.extensions.back());
1564 EXPECT_FALSE(channel_->SetRecvParameters(recv_parameters_)); 1564 EXPECT_FALSE(channel_->SetRecvParameters(recv_parameters_));
1565 } 1565 }
1566 1566
1567 TEST_F(WebRtcVideoChannel2Test, AddRecvStreamOnlyUsesOneReceiveStream) { 1567 TEST_F(WebRtcVideoChannelTest, AddRecvStreamOnlyUsesOneReceiveStream) {
1568 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); 1568 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1)));
1569 EXPECT_EQ(1u, fake_call_->GetVideoReceiveStreams().size()); 1569 EXPECT_EQ(1u, fake_call_->GetVideoReceiveStreams().size());
1570 } 1570 }
1571 1571
1572 TEST_F(WebRtcVideoChannel2Test, RtcpIsCompoundByDefault) { 1572 TEST_F(WebRtcVideoChannelTest, RtcpIsCompoundByDefault) {
1573 FakeVideoReceiveStream* stream = AddRecvStream(); 1573 FakeVideoReceiveStream* stream = AddRecvStream();
1574 EXPECT_EQ(webrtc::RtcpMode::kCompound, stream->GetConfig().rtp.rtcp_mode); 1574 EXPECT_EQ(webrtc::RtcpMode::kCompound, stream->GetConfig().rtp.rtcp_mode);
1575 } 1575 }
1576 1576
1577 TEST_F(WebRtcVideoChannel2Test, RembIsEnabledByDefault) { 1577 TEST_F(WebRtcVideoChannelTest, RembIsEnabledByDefault) {
1578 FakeVideoReceiveStream* stream = AddRecvStream(); 1578 FakeVideoReceiveStream* stream = AddRecvStream();
1579 EXPECT_TRUE(stream->GetConfig().rtp.remb); 1579 EXPECT_TRUE(stream->GetConfig().rtp.remb);
1580 } 1580 }
1581 1581
1582 TEST_F(WebRtcVideoChannel2Test, TransportCcIsEnabledByDefault) { 1582 TEST_F(WebRtcVideoChannelTest, TransportCcIsEnabledByDefault) {
1583 FakeVideoReceiveStream* stream = AddRecvStream(); 1583 FakeVideoReceiveStream* stream = AddRecvStream();
1584 EXPECT_TRUE(stream->GetConfig().rtp.transport_cc); 1584 EXPECT_TRUE(stream->GetConfig().rtp.transport_cc);
1585 } 1585 }
1586 1586
1587 TEST_F(WebRtcVideoChannel2Test, RembCanBeEnabledAndDisabled) { 1587 TEST_F(WebRtcVideoChannelTest, RembCanBeEnabledAndDisabled) {
1588 FakeVideoReceiveStream* stream = AddRecvStream(); 1588 FakeVideoReceiveStream* stream = AddRecvStream();
1589 EXPECT_TRUE(stream->GetConfig().rtp.remb); 1589 EXPECT_TRUE(stream->GetConfig().rtp.remb);
1590 1590
1591 // Verify that REMB is turned off when send(!) codecs without REMB are set. 1591 // Verify that REMB is turned off when send(!) codecs without REMB are set.
1592 cricket::VideoSendParameters parameters; 1592 cricket::VideoSendParameters parameters;
1593 parameters.codecs.push_back(RemoveFeedbackParams(GetEngineCodec("VP8"))); 1593 parameters.codecs.push_back(RemoveFeedbackParams(GetEngineCodec("VP8")));
1594 EXPECT_TRUE(parameters.codecs[0].feedback_params.params().empty()); 1594 EXPECT_TRUE(parameters.codecs[0].feedback_params.params().empty());
1595 EXPECT_TRUE(channel_->SetSendParameters(parameters)); 1595 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1596 stream = fake_call_->GetVideoReceiveStreams()[0]; 1596 stream = fake_call_->GetVideoReceiveStreams()[0];
1597 EXPECT_FALSE(stream->GetConfig().rtp.remb); 1597 EXPECT_FALSE(stream->GetConfig().rtp.remb);
1598 1598
1599 // Verify that REMB is turned on when setting default codecs since the 1599 // Verify that REMB is turned on when setting default codecs since the
1600 // default codecs have REMB enabled. 1600 // default codecs have REMB enabled.
1601 parameters.codecs = engine_.codecs(); 1601 parameters.codecs = engine_.codecs();
1602 EXPECT_TRUE(channel_->SetSendParameters(parameters)); 1602 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1603 stream = fake_call_->GetVideoReceiveStreams()[0]; 1603 stream = fake_call_->GetVideoReceiveStreams()[0];
1604 EXPECT_TRUE(stream->GetConfig().rtp.remb); 1604 EXPECT_TRUE(stream->GetConfig().rtp.remb);
1605 } 1605 }
1606 1606
1607 TEST_F(WebRtcVideoChannel2Test, TransportCcCanBeEnabledAndDisabled) { 1607 TEST_F(WebRtcVideoChannelTest, TransportCcCanBeEnabledAndDisabled) {
1608 FakeVideoReceiveStream* stream = AddRecvStream(); 1608 FakeVideoReceiveStream* stream = AddRecvStream();
1609 EXPECT_TRUE(stream->GetConfig().rtp.transport_cc); 1609 EXPECT_TRUE(stream->GetConfig().rtp.transport_cc);
1610 1610
1611 // Verify that transport cc feedback is turned off when send(!) codecs without 1611 // Verify that transport cc feedback is turned off when send(!) codecs without
1612 // transport cc feedback are set. 1612 // transport cc feedback are set.
1613 cricket::VideoSendParameters parameters; 1613 cricket::VideoSendParameters parameters;
1614 parameters.codecs.push_back(RemoveFeedbackParams(GetEngineCodec("VP8"))); 1614 parameters.codecs.push_back(RemoveFeedbackParams(GetEngineCodec("VP8")));
1615 EXPECT_TRUE(parameters.codecs[0].feedback_params.params().empty()); 1615 EXPECT_TRUE(parameters.codecs[0].feedback_params.params().empty());
1616 EXPECT_TRUE(channel_->SetSendParameters(parameters)); 1616 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1617 stream = fake_call_->GetVideoReceiveStreams()[0]; 1617 stream = fake_call_->GetVideoReceiveStreams()[0];
1618 EXPECT_FALSE(stream->GetConfig().rtp.transport_cc); 1618 EXPECT_FALSE(stream->GetConfig().rtp.transport_cc);
1619 1619
1620 // Verify that transport cc feedback is turned on when setting default codecs 1620 // Verify that transport cc feedback is turned on when setting default codecs
1621 // since the default codecs have transport cc feedback enabled. 1621 // since the default codecs have transport cc feedback enabled.
1622 parameters.codecs = engine_.codecs(); 1622 parameters.codecs = engine_.codecs();
1623 EXPECT_TRUE(channel_->SetSendParameters(parameters)); 1623 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1624 stream = fake_call_->GetVideoReceiveStreams()[0]; 1624 stream = fake_call_->GetVideoReceiveStreams()[0];
1625 EXPECT_TRUE(stream->GetConfig().rtp.transport_cc); 1625 EXPECT_TRUE(stream->GetConfig().rtp.transport_cc);
1626 } 1626 }
1627 1627
1628 TEST_F(WebRtcVideoChannel2Test, NackIsEnabledByDefault) { 1628 TEST_F(WebRtcVideoChannelTest, NackIsEnabledByDefault) {
1629 VerifyCodecHasDefaultFeedbackParams(default_codec_); 1629 VerifyCodecHasDefaultFeedbackParams(default_codec_);
1630 1630
1631 cricket::VideoSendParameters parameters; 1631 cricket::VideoSendParameters parameters;
1632 parameters.codecs = engine_.codecs(); 1632 parameters.codecs = engine_.codecs();
1633 EXPECT_TRUE(channel_->SetSendParameters(parameters)); 1633 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1634 EXPECT_TRUE(channel_->SetSend(true)); 1634 EXPECT_TRUE(channel_->SetSend(true));
1635 1635
1636 // Send side. 1636 // Send side.
1637 FakeVideoSendStream* send_stream = 1637 FakeVideoSendStream* send_stream =
1638 AddSendStream(cricket::StreamParams::CreateLegacy(1)); 1638 AddSendStream(cricket::StreamParams::CreateLegacy(1));
1639 EXPECT_GT(send_stream->GetConfig().rtp.nack.rtp_history_ms, 0); 1639 EXPECT_GT(send_stream->GetConfig().rtp.nack.rtp_history_ms, 0);
1640 1640
1641 // Receiver side. 1641 // Receiver side.
1642 FakeVideoReceiveStream* recv_stream = 1642 FakeVideoReceiveStream* recv_stream =
1643 AddRecvStream(cricket::StreamParams::CreateLegacy(1)); 1643 AddRecvStream(cricket::StreamParams::CreateLegacy(1));
1644 EXPECT_GT(recv_stream->GetConfig().rtp.nack.rtp_history_ms, 0); 1644 EXPECT_GT(recv_stream->GetConfig().rtp.nack.rtp_history_ms, 0);
1645 1645
1646 // Nack history size should match between sender and receiver. 1646 // Nack history size should match between sender and receiver.
1647 EXPECT_EQ(send_stream->GetConfig().rtp.nack.rtp_history_ms, 1647 EXPECT_EQ(send_stream->GetConfig().rtp.nack.rtp_history_ms,
1648 recv_stream->GetConfig().rtp.nack.rtp_history_ms); 1648 recv_stream->GetConfig().rtp.nack.rtp_history_ms);
1649 } 1649 }
1650 1650
1651 TEST_F(WebRtcVideoChannel2Test, NackCanBeEnabledAndDisabled) { 1651 TEST_F(WebRtcVideoChannelTest, NackCanBeEnabledAndDisabled) {
1652 FakeVideoSendStream* send_stream = AddSendStream(); 1652 FakeVideoSendStream* send_stream = AddSendStream();
1653 FakeVideoReceiveStream* recv_stream = AddRecvStream(); 1653 FakeVideoReceiveStream* recv_stream = AddRecvStream();
1654 1654
1655 EXPECT_GT(recv_stream->GetConfig().rtp.nack.rtp_history_ms, 0); 1655 EXPECT_GT(recv_stream->GetConfig().rtp.nack.rtp_history_ms, 0);
1656 EXPECT_GT(send_stream->GetConfig().rtp.nack.rtp_history_ms, 0); 1656 EXPECT_GT(send_stream->GetConfig().rtp.nack.rtp_history_ms, 0);
1657 1657
1658 // Verify that NACK is turned off when send(!) codecs without NACK are set. 1658 // Verify that NACK is turned off when send(!) codecs without NACK are set.
1659 cricket::VideoSendParameters parameters; 1659 cricket::VideoSendParameters parameters;
1660 parameters.codecs.push_back(RemoveFeedbackParams(GetEngineCodec("VP8"))); 1660 parameters.codecs.push_back(RemoveFeedbackParams(GetEngineCodec("VP8")));
1661 EXPECT_TRUE(parameters.codecs[0].feedback_params.params().empty()); 1661 EXPECT_TRUE(parameters.codecs[0].feedback_params.params().empty());
(...skipping 11 matching lines...) Expand all
1673 EXPECT_GT(recv_stream->GetConfig().rtp.nack.rtp_history_ms, 0); 1673 EXPECT_GT(recv_stream->GetConfig().rtp.nack.rtp_history_ms, 0);
1674 send_stream = fake_call_->GetVideoSendStreams()[0]; 1674 send_stream = fake_call_->GetVideoSendStreams()[0];
1675 EXPECT_GT(send_stream->GetConfig().rtp.nack.rtp_history_ms, 0); 1675 EXPECT_GT(send_stream->GetConfig().rtp.nack.rtp_history_ms, 0);
1676 } 1676 }
1677 1677
1678 // This test verifies that new frame sizes reconfigures encoders even though not 1678 // This test verifies that new frame sizes reconfigures encoders even though not
1679 // (yet) sending. The purpose of this is to permit encoding as quickly as 1679 // (yet) sending. The purpose of this is to permit encoding as quickly as
1680 // possible once we start sending. Likely the frames being input are from the 1680 // possible once we start sending. Likely the frames being input are from the
1681 // same source that will be sent later, which just means that we're ready 1681 // same source that will be sent later, which just means that we're ready
1682 // earlier. 1682 // earlier.
1683 TEST_F(WebRtcVideoChannel2Test, ReconfiguresEncodersWhenNotSending) { 1683 TEST_F(WebRtcVideoChannelTest, ReconfiguresEncodersWhenNotSending) {
1684 cricket::VideoSendParameters parameters; 1684 cricket::VideoSendParameters parameters;
1685 parameters.codecs.push_back(GetEngineCodec("VP8")); 1685 parameters.codecs.push_back(GetEngineCodec("VP8"));
1686 ASSERT_TRUE(channel_->SetSendParameters(parameters)); 1686 ASSERT_TRUE(channel_->SetSendParameters(parameters));
1687 channel_->SetSend(false); 1687 channel_->SetSend(false);
1688 1688
1689 FakeVideoSendStream* stream = AddSendStream(); 1689 FakeVideoSendStream* stream = AddSendStream();
1690 1690
1691 // No frames entered. 1691 // No frames entered.
1692 std::vector<webrtc::VideoStream> streams = stream->GetVideoStreams(); 1692 std::vector<webrtc::VideoStream> streams = stream->GetVideoStreams();
1693 EXPECT_EQ(0u, streams[0].width); 1693 EXPECT_EQ(0u, streams[0].width);
1694 EXPECT_EQ(0u, streams[0].height); 1694 EXPECT_EQ(0u, streams[0].height);
1695 1695
1696 cricket::FakeVideoCapturer capturer; 1696 cricket::FakeVideoCapturer capturer;
1697 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, &capturer)); 1697 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, &capturer));
1698 VideoFormat capture_format = capturer.GetSupportedFormats()->front(); 1698 VideoFormat capture_format = capturer.GetSupportedFormats()->front();
1699 EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(capture_format)); 1699 EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(capture_format));
1700 EXPECT_TRUE(capturer.CaptureFrame()); 1700 EXPECT_TRUE(capturer.CaptureFrame());
1701 1701
1702 // Frame entered, should be reconfigured to new dimensions. 1702 // Frame entered, should be reconfigured to new dimensions.
1703 streams = stream->GetVideoStreams(); 1703 streams = stream->GetVideoStreams();
1704 EXPECT_EQ(capture_format.width, streams[0].width); 1704 EXPECT_EQ(capture_format.width, streams[0].width);
1705 EXPECT_EQ(capture_format.height, streams[0].height); 1705 EXPECT_EQ(capture_format.height, streams[0].height);
1706 1706
1707 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); 1707 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr));
1708 } 1708 }
1709 1709
1710 TEST_F(WebRtcVideoChannel2Test, UsesCorrectSettingsForScreencast) { 1710 TEST_F(WebRtcVideoChannelTest, UsesCorrectSettingsForScreencast) {
1711 static const int kScreenshareMinBitrateKbps = 800; 1711 static const int kScreenshareMinBitrateKbps = 800;
1712 cricket::VideoCodec codec = GetEngineCodec("VP8"); 1712 cricket::VideoCodec codec = GetEngineCodec("VP8");
1713 cricket::VideoSendParameters parameters; 1713 cricket::VideoSendParameters parameters;
1714 parameters.codecs.push_back(codec); 1714 parameters.codecs.push_back(codec);
1715 EXPECT_TRUE(channel_->SetSendParameters(parameters)); 1715 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1716 AddSendStream(); 1716 AddSendStream();
1717 1717
1718 cricket::FakeVideoCapturer capturer; 1718 cricket::FakeVideoCapturer capturer;
1719 VideoOptions min_bitrate_options; 1719 VideoOptions min_bitrate_options;
1720 min_bitrate_options.screencast_min_bitrate_kbps = 1720 min_bitrate_options.screencast_min_bitrate_kbps =
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1765 EXPECT_EQ(kScreenshareMinBitrateKbps * 1000, 1765 EXPECT_EQ(kScreenshareMinBitrateKbps * 1000,
1766 encoder_config.min_transmit_bitrate_bps); 1766 encoder_config.min_transmit_bitrate_bps);
1767 1767
1768 streams = send_stream->GetVideoStreams(); 1768 streams = send_stream->GetVideoStreams();
1769 EXPECT_EQ(capture_format_hd.width, streams.front().width); 1769 EXPECT_EQ(capture_format_hd.width, streams.front().width);
1770 EXPECT_EQ(capture_format_hd.height, streams.front().height); 1770 EXPECT_EQ(capture_format_hd.height, streams.front().height);
1771 EXPECT_TRUE(streams[0].temporal_layer_thresholds_bps.empty()); 1771 EXPECT_TRUE(streams[0].temporal_layer_thresholds_bps.empty());
1772 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); 1772 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr));
1773 } 1773 }
1774 1774
1775 TEST_F(WebRtcVideoChannel2Test, 1775 TEST_F(WebRtcVideoChannelTest,
1776 ConferenceModeScreencastConfiguresTemporalLayer) { 1776 ConferenceModeScreencastConfiguresTemporalLayer) {
1777 static const int kConferenceScreencastTemporalBitrateBps = 1777 static const int kConferenceScreencastTemporalBitrateBps =
1778 ScreenshareLayerConfig::GetDefault().tl0_bitrate_kbps * 1000; 1778 ScreenshareLayerConfig::GetDefault().tl0_bitrate_kbps * 1000;
1779 send_parameters_.conference_mode = true; 1779 send_parameters_.conference_mode = true;
1780 channel_->SetSendParameters(send_parameters_); 1780 channel_->SetSendParameters(send_parameters_);
1781 1781
1782 AddSendStream(); 1782 AddSendStream();
1783 VideoOptions options; 1783 VideoOptions options;
1784 options.is_screencast = rtc::Optional<bool>(true); 1784 options.is_screencast = rtc::Optional<bool>(true);
1785 cricket::FakeVideoCapturer capturer; 1785 cricket::FakeVideoCapturer capturer;
(...skipping 18 matching lines...) Expand all
1804 1804
1805 std::vector<webrtc::VideoStream> streams = send_stream->GetVideoStreams(); 1805 std::vector<webrtc::VideoStream> streams = send_stream->GetVideoStreams();
1806 ASSERT_EQ(1u, streams.size()); 1806 ASSERT_EQ(1u, streams.size());
1807 ASSERT_EQ(1u, streams[0].temporal_layer_thresholds_bps.size()); 1807 ASSERT_EQ(1u, streams[0].temporal_layer_thresholds_bps.size());
1808 EXPECT_EQ(kConferenceScreencastTemporalBitrateBps, 1808 EXPECT_EQ(kConferenceScreencastTemporalBitrateBps,
1809 streams[0].temporal_layer_thresholds_bps[0]); 1809 streams[0].temporal_layer_thresholds_bps[0]);
1810 1810
1811 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); 1811 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr));
1812 } 1812 }
1813 1813
1814 TEST_F(WebRtcVideoChannel2Test, SuspendBelowMinBitrateDisabledByDefault) { 1814 TEST_F(WebRtcVideoChannelTest, SuspendBelowMinBitrateDisabledByDefault) {
1815 FakeVideoSendStream* stream = AddSendStream(); 1815 FakeVideoSendStream* stream = AddSendStream();
1816 EXPECT_FALSE(stream->GetConfig().suspend_below_min_bitrate); 1816 EXPECT_FALSE(stream->GetConfig().suspend_below_min_bitrate);
1817 } 1817 }
1818 1818
1819 TEST_F(WebRtcVideoChannel2Test, SetMediaConfigSuspendBelowMinBitrate) { 1819 TEST_F(WebRtcVideoChannelTest, SetMediaConfigSuspendBelowMinBitrate) {
1820 MediaConfig media_config = GetMediaConfig(); 1820 MediaConfig media_config = GetMediaConfig();
1821 media_config.video.suspend_below_min_bitrate = true; 1821 media_config.video.suspend_below_min_bitrate = true;
1822 1822
1823 channel_.reset( 1823 channel_.reset(
1824 engine_.CreateChannel(fake_call_.get(), media_config, VideoOptions())); 1824 engine_.CreateChannel(fake_call_.get(), media_config, VideoOptions()));
1825 channel_->OnReadyToSend(true); 1825 channel_->OnReadyToSend(true);
1826 1826
1827 channel_->SetSendParameters(send_parameters_); 1827 channel_->SetSendParameters(send_parameters_);
1828 1828
1829 FakeVideoSendStream* stream = AddSendStream(); 1829 FakeVideoSendStream* stream = AddSendStream();
1830 EXPECT_TRUE(stream->GetConfig().suspend_below_min_bitrate); 1830 EXPECT_TRUE(stream->GetConfig().suspend_below_min_bitrate);
1831 1831
1832 media_config.video.suspend_below_min_bitrate = false; 1832 media_config.video.suspend_below_min_bitrate = false;
1833 channel_.reset( 1833 channel_.reset(
1834 engine_.CreateChannel(fake_call_.get(), media_config, VideoOptions())); 1834 engine_.CreateChannel(fake_call_.get(), media_config, VideoOptions()));
1835 channel_->OnReadyToSend(true); 1835 channel_->OnReadyToSend(true);
1836 1836
1837 channel_->SetSendParameters(send_parameters_); 1837 channel_->SetSendParameters(send_parameters_);
1838 1838
1839 stream = AddSendStream(); 1839 stream = AddSendStream();
1840 EXPECT_FALSE(stream->GetConfig().suspend_below_min_bitrate); 1840 EXPECT_FALSE(stream->GetConfig().suspend_below_min_bitrate);
1841 } 1841 }
1842 1842
1843 TEST_F(WebRtcVideoChannel2Test, Vp8DenoisingEnabledByDefault) { 1843 TEST_F(WebRtcVideoChannelTest, Vp8DenoisingEnabledByDefault) {
1844 FakeVideoSendStream* stream = AddSendStream(); 1844 FakeVideoSendStream* stream = AddSendStream();
1845 webrtc::VideoCodecVP8 vp8_settings; 1845 webrtc::VideoCodecVP8 vp8_settings;
1846 ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set."; 1846 ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set.";
1847 EXPECT_TRUE(vp8_settings.denoisingOn); 1847 EXPECT_TRUE(vp8_settings.denoisingOn);
1848 } 1848 }
1849 1849
1850 TEST_F(WebRtcVideoChannel2Test, VerifyVp8SpecificSettings) { 1850 TEST_F(WebRtcVideoChannelTest, VerifyVp8SpecificSettings) {
1851 cricket::VideoSendParameters parameters; 1851 cricket::VideoSendParameters parameters;
1852 parameters.codecs.push_back(GetEngineCodec("VP8")); 1852 parameters.codecs.push_back(GetEngineCodec("VP8"));
1853 ASSERT_TRUE(channel_->SetSendParameters(parameters)); 1853 ASSERT_TRUE(channel_->SetSendParameters(parameters));
1854 1854
1855 // Single-stream settings should apply with RTX as well (verifies that we 1855 // Single-stream settings should apply with RTX as well (verifies that we
1856 // check number of regular SSRCs and not StreamParams::ssrcs which contains 1856 // check number of regular SSRCs and not StreamParams::ssrcs which contains
1857 // both RTX and regular SSRCs). 1857 // both RTX and regular SSRCs).
1858 FakeVideoSendStream* stream = SetUpSimulcast(false, true); 1858 FakeVideoSendStream* stream = SetUpSimulcast(false, true);
1859 1859
1860 cricket::FakeVideoCapturer capturer; 1860 cricket::FakeVideoCapturer capturer;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1915 ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set."; 1915 ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set.";
1916 EXPECT_FALSE(vp8_settings.denoisingOn); 1916 EXPECT_FALSE(vp8_settings.denoisingOn);
1917 EXPECT_FALSE(vp8_settings.automaticResizeOn); 1917 EXPECT_FALSE(vp8_settings.automaticResizeOn);
1918 EXPECT_FALSE(vp8_settings.frameDroppingOn); 1918 EXPECT_FALSE(vp8_settings.frameDroppingOn);
1919 1919
1920 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); 1920 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr));
1921 } 1921 }
1922 1922
1923 // Test that setting the same options doesn't result in the encoder being 1923 // Test that setting the same options doesn't result in the encoder being
1924 // reconfigured. 1924 // reconfigured.
1925 TEST_F(WebRtcVideoChannel2Test, SetIdenticalOptionsDoesntReconfigureEncoder) { 1925 TEST_F(WebRtcVideoChannelTest, SetIdenticalOptionsDoesntReconfigureEncoder) {
1926 VideoOptions options; 1926 VideoOptions options;
1927 cricket::FakeVideoCapturer capturer; 1927 cricket::FakeVideoCapturer capturer;
1928 1928
1929 AddSendStream(); 1929 AddSendStream();
1930 EXPECT_EQ(cricket::CS_RUNNING, 1930 EXPECT_EQ(cricket::CS_RUNNING,
1931 capturer.Start(capturer.GetSupportedFormats()->front())); 1931 capturer.Start(capturer.GetSupportedFormats()->front()));
1932 cricket::VideoSendParameters parameters; 1932 cricket::VideoSendParameters parameters;
1933 parameters.codecs.push_back(GetEngineCodec("VP8")); 1933 parameters.codecs.push_back(GetEngineCodec("VP8"));
1934 ASSERT_TRUE(channel_->SetSendParameters(parameters)); 1934 ASSERT_TRUE(channel_->SetSendParameters(parameters));
1935 FakeVideoSendStream* send_stream = fake_call_->GetVideoSendStreams().front(); 1935 FakeVideoSendStream* send_stream = fake_call_->GetVideoSendStreams().front();
1936 1936
1937 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &options, &capturer)); 1937 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &options, &capturer));
1938 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &options, &capturer)); 1938 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &options, &capturer));
1939 EXPECT_TRUE(capturer.CaptureFrame()); 1939 EXPECT_TRUE(capturer.CaptureFrame());
1940 // Expect 1 reconfigurations at this point from the initial configuration. 1940 // Expect 1 reconfigurations at this point from the initial configuration.
1941 EXPECT_EQ(1, send_stream->num_encoder_reconfigurations()); 1941 EXPECT_EQ(1, send_stream->num_encoder_reconfigurations());
1942 1942
1943 // Set the options one more time and expect no additional reconfigurations. 1943 // Set the options one more time and expect no additional reconfigurations.
1944 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &options, &capturer)); 1944 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &options, &capturer));
1945 EXPECT_EQ(1, send_stream->num_encoder_reconfigurations()); 1945 EXPECT_EQ(1, send_stream->num_encoder_reconfigurations());
1946 1946
1947 // Change |options| and expect 2 reconfigurations. 1947 // Change |options| and expect 2 reconfigurations.
1948 options.video_noise_reduction = rtc::Optional<bool>(true); 1948 options.video_noise_reduction = rtc::Optional<bool>(true);
1949 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &options, &capturer)); 1949 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &options, &capturer));
1950 EXPECT_EQ(2, send_stream->num_encoder_reconfigurations()); 1950 EXPECT_EQ(2, send_stream->num_encoder_reconfigurations());
1951 1951
1952 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); 1952 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr));
1953 } 1953 }
1954 1954
1955 class Vp9SettingsTest : public WebRtcVideoChannel2Test { 1955 class Vp9SettingsTest : public WebRtcVideoChannelTest {
1956 public: 1956 public:
1957 Vp9SettingsTest() : Vp9SettingsTest("") {} 1957 Vp9SettingsTest() : Vp9SettingsTest("") {}
1958 explicit Vp9SettingsTest(const char* field_trials) 1958 explicit Vp9SettingsTest(const char* field_trials)
1959 : WebRtcVideoChannel2Test(field_trials) { 1959 : WebRtcVideoChannelTest(field_trials) {
1960 encoder_factory_.AddSupportedVideoCodecType("VP9"); 1960 encoder_factory_.AddSupportedVideoCodecType("VP9");
1961 } 1961 }
1962 virtual ~Vp9SettingsTest() {} 1962 virtual ~Vp9SettingsTest() {}
1963 1963
1964 protected: 1964 protected:
1965 void SetUp() override { 1965 void SetUp() override {
1966 engine_.SetExternalEncoderFactory(&encoder_factory_); 1966 engine_.SetExternalEncoderFactory(&encoder_factory_);
1967 1967
1968 WebRtcVideoChannel2Test::SetUp(); 1968 WebRtcVideoChannelTest::SetUp();
1969 } 1969 }
1970 1970
1971 void TearDown() override { 1971 void TearDown() override {
1972 // Remove references to encoder_factory_ since this will be destroyed 1972 // Remove references to encoder_factory_ since this will be destroyed
1973 // before channel_ and engine_. 1973 // before channel_ and engine_.
1974 ASSERT_TRUE(channel_->SetSendParameters(send_parameters_)); 1974 ASSERT_TRUE(channel_->SetSendParameters(send_parameters_));
1975 } 1975 }
1976 1976
1977 cricket::FakeWebRtcVideoEncoderFactory encoder_factory_; 1977 cricket::FakeWebRtcVideoEncoderFactory encoder_factory_;
1978 }; 1978 };
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
2090 : Vp9SettingsTestWithFieldTrial( 2090 : Vp9SettingsTestWithFieldTrial(
2091 "WebRTC-SupportVP9SVC/EnabledByFlag_2SL3TL/") {} 2091 "WebRTC-SupportVP9SVC/EnabledByFlag_2SL3TL/") {}
2092 }; 2092 };
2093 2093
2094 TEST_F(Vp9SettingsTestWith2SL3TLFlag, VerifySettings) { 2094 TEST_F(Vp9SettingsTestWith2SL3TLFlag, VerifySettings) {
2095 const int kNumSpatialLayers = 2; 2095 const int kNumSpatialLayers = 2;
2096 const int kNumTemporalLayers = 3; 2096 const int kNumTemporalLayers = 3;
2097 VerifySettings(kNumSpatialLayers, kNumTemporalLayers); 2097 VerifySettings(kNumSpatialLayers, kNumTemporalLayers);
2098 } 2098 }
2099 2099
2100 TEST_F(WebRtcVideoChannel2Test, AdaptsOnOveruse) { 2100 TEST_F(WebRtcVideoChannelTest, AdaptsOnOveruse) {
2101 TestCpuAdaptation(true, false); 2101 TestCpuAdaptation(true, false);
2102 } 2102 }
2103 2103
2104 TEST_F(WebRtcVideoChannel2Test, DoesNotAdaptOnOveruseWhenDisabled) { 2104 TEST_F(WebRtcVideoChannelTest, DoesNotAdaptOnOveruseWhenDisabled) {
2105 TestCpuAdaptation(false, false); 2105 TestCpuAdaptation(false, false);
2106 } 2106 }
2107 2107
2108 TEST_F(WebRtcVideoChannel2Test, DoesNotAdaptOnOveruseWhenScreensharing) { 2108 TEST_F(WebRtcVideoChannelTest, DoesNotAdaptOnOveruseWhenScreensharing) {
2109 TestCpuAdaptation(true, true); 2109 TestCpuAdaptation(true, true);
2110 } 2110 }
2111 2111
2112 TEST_F(WebRtcVideoChannel2Test, AdaptsOnOveruseAndChangeResolution) { 2112 TEST_F(WebRtcVideoChannelTest, AdaptsOnOveruseAndChangeResolution) {
2113 cricket::VideoCodec codec = GetEngineCodec("VP8"); 2113 cricket::VideoCodec codec = GetEngineCodec("VP8");
2114 cricket::VideoSendParameters parameters; 2114 cricket::VideoSendParameters parameters;
2115 parameters.codecs.push_back(codec); 2115 parameters.codecs.push_back(codec);
2116 2116
2117 MediaConfig media_config = GetMediaConfig(); 2117 MediaConfig media_config = GetMediaConfig();
2118 channel_.reset( 2118 channel_.reset(
2119 engine_.CreateChannel(fake_call_.get(), media_config, VideoOptions())); 2119 engine_.CreateChannel(fake_call_.get(), media_config, VideoOptions()));
2120 channel_->OnReadyToSend(true); 2120 channel_->OnReadyToSend(true);
2121 ASSERT_TRUE(channel_->SetSendParameters(parameters)); 2121 ASSERT_TRUE(channel_->SetSendParameters(parameters));
2122 2122
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
2182 wants.target_pixel_count = rtc::Optional<int>((current_pixel_count * 5) / 3); 2182 wants.target_pixel_count = rtc::Optional<int>((current_pixel_count * 5) / 3);
2183 send_stream->InjectVideoSinkWants(wants); 2183 send_stream->InjectVideoSinkWants(wants);
2184 EXPECT_TRUE(capturer.CaptureCustomFrame(1284, 724, cricket::FOURCC_I420)); 2184 EXPECT_TRUE(capturer.CaptureCustomFrame(1284, 724, cricket::FOURCC_I420));
2185 EXPECT_EQ(6, send_stream->GetNumberOfSwappedFrames()); 2185 EXPECT_EQ(6, send_stream->GetNumberOfSwappedFrames());
2186 EXPECT_EQ(1284, send_stream->GetLastWidth()); 2186 EXPECT_EQ(1284, send_stream->GetLastWidth());
2187 EXPECT_EQ(724, send_stream->GetLastHeight()); 2187 EXPECT_EQ(724, send_stream->GetLastHeight());
2188 2188
2189 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); 2189 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr));
2190 } 2190 }
2191 2191
2192 TEST_F(WebRtcVideoChannel2Test, PreviousAdaptationDoesNotApplyToScreenshare) { 2192 TEST_F(WebRtcVideoChannelTest, PreviousAdaptationDoesNotApplyToScreenshare) {
2193 cricket::VideoCodec codec = GetEngineCodec("VP8"); 2193 cricket::VideoCodec codec = GetEngineCodec("VP8");
2194 cricket::VideoSendParameters parameters; 2194 cricket::VideoSendParameters parameters;
2195 parameters.codecs.push_back(codec); 2195 parameters.codecs.push_back(codec);
2196 2196
2197 MediaConfig media_config = GetMediaConfig(); 2197 MediaConfig media_config = GetMediaConfig();
2198 media_config.video.enable_cpu_overuse_detection = true; 2198 media_config.video.enable_cpu_overuse_detection = true;
2199 channel_.reset( 2199 channel_.reset(
2200 engine_.CreateChannel(fake_call_.get(), media_config, VideoOptions())); 2200 engine_.CreateChannel(fake_call_.get(), media_config, VideoOptions()));
2201 channel_->OnReadyToSend(true); 2201 channel_->OnReadyToSend(true);
2202 ASSERT_TRUE(channel_->SetSendParameters(parameters)); 2202 ASSERT_TRUE(channel_->SetSendParameters(parameters));
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
2256 EXPECT_TRUE(capturer.CaptureCustomFrame(1280, 720, cricket::FOURCC_I420)); 2256 EXPECT_TRUE(capturer.CaptureCustomFrame(1280, 720, cricket::FOURCC_I420));
2257 ASSERT_EQ(3, fake_call_->GetNumCreatedSendStreams()); 2257 ASSERT_EQ(3, fake_call_->GetNumCreatedSendStreams());
2258 send_stream = fake_call_->GetVideoSendStreams().front(); 2258 send_stream = fake_call_->GetVideoSendStreams().front();
2259 EXPECT_EQ(1, send_stream->GetNumberOfSwappedFrames()); 2259 EXPECT_EQ(1, send_stream->GetNumberOfSwappedFrames());
2260 EXPECT_EQ(1280 * 3 / 4, send_stream->GetLastWidth()); 2260 EXPECT_EQ(1280 * 3 / 4, send_stream->GetLastWidth());
2261 EXPECT_EQ(720 * 3 / 4, send_stream->GetLastHeight()); 2261 EXPECT_EQ(720 * 3 / 4, send_stream->GetLastHeight());
2262 2262
2263 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); 2263 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr));
2264 } 2264 }
2265 2265
2266 void WebRtcVideoChannel2Test::TestCpuAdaptation(bool enable_overuse, 2266 void WebRtcVideoChannelTest::TestCpuAdaptation(bool enable_overuse,
2267 bool is_screenshare) { 2267 bool is_screenshare) {
2268 const int kDefaultFps = 30; 2268 const int kDefaultFps = 30;
2269 cricket::VideoCodec codec = GetEngineCodec("VP8"); 2269 cricket::VideoCodec codec = GetEngineCodec("VP8");
2270 cricket::VideoSendParameters parameters; 2270 cricket::VideoSendParameters parameters;
2271 parameters.codecs.push_back(codec); 2271 parameters.codecs.push_back(codec);
2272 2272
2273 MediaConfig media_config = GetMediaConfig(); 2273 MediaConfig media_config = GetMediaConfig();
2274 if (enable_overuse) { 2274 if (enable_overuse) {
2275 media_config.video.enable_cpu_overuse_detection = true; 2275 media_config.video.enable_cpu_overuse_detection = true;
2276 } 2276 }
2277 channel_.reset( 2277 channel_.reset(
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
2362 } else { 2362 } else {
2363 EXPECT_EQ(kDefaultFps * 2, send_stream->GetNumberOfSwappedFrames()); 2363 EXPECT_EQ(kDefaultFps * 2, send_stream->GetNumberOfSwappedFrames());
2364 } 2364 }
2365 2365
2366 EXPECT_EQ(capture_format.width, send_stream->GetLastWidth()); 2366 EXPECT_EQ(capture_format.width, send_stream->GetLastWidth());
2367 EXPECT_EQ(capture_format.height, send_stream->GetLastHeight()); 2367 EXPECT_EQ(capture_format.height, send_stream->GetLastHeight());
2368 2368
2369 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); 2369 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr));
2370 } 2370 }
2371 2371
2372 TEST_F(WebRtcVideoChannel2Test, EstimatesNtpStartTimeCorrectly) { 2372 TEST_F(WebRtcVideoChannelTest, EstimatesNtpStartTimeCorrectly) {
2373 // Start at last timestamp to verify that wraparounds are estimated correctly. 2373 // Start at last timestamp to verify that wraparounds are estimated correctly.
2374 static const uint32_t kInitialTimestamp = 0xFFFFFFFFu; 2374 static const uint32_t kInitialTimestamp = 0xFFFFFFFFu;
2375 static const int64_t kInitialNtpTimeMs = 1247891230; 2375 static const int64_t kInitialNtpTimeMs = 1247891230;
2376 static const int kFrameOffsetMs = 20; 2376 static const int kFrameOffsetMs = 20;
2377 EXPECT_TRUE(channel_->SetRecvParameters(recv_parameters_)); 2377 EXPECT_TRUE(channel_->SetRecvParameters(recv_parameters_));
2378 2378
2379 FakeVideoReceiveStream* stream = AddRecvStream(); 2379 FakeVideoReceiveStream* stream = AddRecvStream();
2380 cricket::FakeVideoRenderer renderer; 2380 cricket::FakeVideoRenderer renderer;
2381 EXPECT_TRUE(channel_->SetSink(last_ssrc_, &renderer)); 2381 EXPECT_TRUE(channel_->SetSink(last_ssrc_, &renderer));
2382 2382
(...skipping 15 matching lines...) Expand all
2398 2398
2399 EXPECT_EQ(2, renderer.num_rendered_frames()); 2399 EXPECT_EQ(2, renderer.num_rendered_frames());
2400 2400
2401 // Verify that NTP time has been correctly deduced. 2401 // Verify that NTP time has been correctly deduced.
2402 cricket::VideoMediaInfo info; 2402 cricket::VideoMediaInfo info;
2403 ASSERT_TRUE(channel_->GetStats(&info)); 2403 ASSERT_TRUE(channel_->GetStats(&info));
2404 ASSERT_EQ(1u, info.receivers.size()); 2404 ASSERT_EQ(1u, info.receivers.size());
2405 EXPECT_EQ(kInitialNtpTimeMs, info.receivers[0].capture_start_ntp_time_ms); 2405 EXPECT_EQ(kInitialNtpTimeMs, info.receivers[0].capture_start_ntp_time_ms);
2406 } 2406 }
2407 2407
2408 TEST_F(WebRtcVideoChannel2Test, SetDefaultSendCodecs) { 2408 TEST_F(WebRtcVideoChannelTest, SetDefaultSendCodecs) {
2409 ASSERT_TRUE(channel_->SetSendParameters(send_parameters_)); 2409 ASSERT_TRUE(channel_->SetSendParameters(send_parameters_));
2410 2410
2411 VideoCodec codec; 2411 VideoCodec codec;
2412 EXPECT_TRUE(channel_->GetSendCodec(&codec)); 2412 EXPECT_TRUE(channel_->GetSendCodec(&codec));
2413 EXPECT_TRUE(codec.Matches(engine_.codecs()[0])); 2413 EXPECT_TRUE(codec.Matches(engine_.codecs()[0]));
2414 2414
2415 // Using a RTX setup to verify that the default RTX payload type is good. 2415 // Using a RTX setup to verify that the default RTX payload type is good.
2416 const std::vector<uint32_t> ssrcs = MAKE_VECTOR(kSsrcs1); 2416 const std::vector<uint32_t> ssrcs = MAKE_VECTOR(kSsrcs1);
2417 const std::vector<uint32_t> rtx_ssrcs = MAKE_VECTOR(kRtxSsrcs1); 2417 const std::vector<uint32_t> rtx_ssrcs = MAKE_VECTOR(kRtxSsrcs1);
2418 FakeVideoSendStream* stream = AddSendStream( 2418 FakeVideoSendStream* stream = AddSendStream(
2419 cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs)); 2419 cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs));
2420 webrtc::VideoSendStream::Config config = stream->GetConfig().Copy(); 2420 webrtc::VideoSendStream::Config config = stream->GetConfig().Copy();
2421 2421
2422 // Make sure NACK and FEC are enabled on the correct payload types. 2422 // Make sure NACK and FEC are enabled on the correct payload types.
2423 EXPECT_EQ(1000, config.rtp.nack.rtp_history_ms); 2423 EXPECT_EQ(1000, config.rtp.nack.rtp_history_ms);
2424 EXPECT_EQ(GetEngineCodec("ulpfec").id, config.rtp.ulpfec.ulpfec_payload_type); 2424 EXPECT_EQ(GetEngineCodec("ulpfec").id, config.rtp.ulpfec.ulpfec_payload_type);
2425 EXPECT_EQ(GetEngineCodec("red").id, config.rtp.ulpfec.red_payload_type); 2425 EXPECT_EQ(GetEngineCodec("red").id, config.rtp.ulpfec.red_payload_type);
2426 2426
2427 EXPECT_EQ(1u, config.rtp.rtx.ssrcs.size()); 2427 EXPECT_EQ(1u, config.rtp.rtx.ssrcs.size());
2428 EXPECT_EQ(kRtxSsrcs1[0], config.rtp.rtx.ssrcs[0]); 2428 EXPECT_EQ(kRtxSsrcs1[0], config.rtp.rtx.ssrcs[0]);
2429 VerifySendStreamHasRtxTypes(config, default_apt_rtx_types_); 2429 VerifySendStreamHasRtxTypes(config, default_apt_rtx_types_);
2430 // TODO(juberti): Check RTCP, PLI, TMMBR. 2430 // TODO(juberti): Check RTCP, PLI, TMMBR.
2431 } 2431 }
2432 2432
2433 // The following four tests ensures that FlexFEC is not activated by default 2433 // The following four tests ensures that FlexFEC is not activated by default
2434 // when the field trials are not enabled. 2434 // when the field trials are not enabled.
2435 // TODO(brandtr): Remove or update these tests when FlexFEC _is_ enabled by 2435 // TODO(brandtr): Remove or update these tests when FlexFEC _is_ enabled by
2436 // default. 2436 // default.
2437 TEST_F(WebRtcVideoChannel2Test, 2437 TEST_F(WebRtcVideoChannelTest,
2438 FlexfecSendCodecWithoutSsrcNotExposedByDefault) { 2438 FlexfecSendCodecWithoutSsrcNotExposedByDefault) {
2439 FakeVideoSendStream* stream = AddSendStream(); 2439 FakeVideoSendStream* stream = AddSendStream();
2440 webrtc::VideoSendStream::Config config = stream->GetConfig().Copy(); 2440 webrtc::VideoSendStream::Config config = stream->GetConfig().Copy();
2441 2441
2442 EXPECT_EQ(-1, config.rtp.flexfec.payload_type); 2442 EXPECT_EQ(-1, config.rtp.flexfec.payload_type);
2443 EXPECT_EQ(0U, config.rtp.flexfec.ssrc); 2443 EXPECT_EQ(0U, config.rtp.flexfec.ssrc);
2444 EXPECT_TRUE(config.rtp.flexfec.protected_media_ssrcs.empty()); 2444 EXPECT_TRUE(config.rtp.flexfec.protected_media_ssrcs.empty());
2445 } 2445 }
2446 2446
2447 TEST_F(WebRtcVideoChannel2Test, FlexfecSendCodecWithSsrcNotExposedByDefault) { 2447 TEST_F(WebRtcVideoChannelTest, FlexfecSendCodecWithSsrcNotExposedByDefault) {
2448 FakeVideoSendStream* stream = AddSendStream( 2448 FakeVideoSendStream* stream = AddSendStream(
2449 CreatePrimaryWithFecFrStreamParams("cname", kSsrcs1[0], kFlexfecSsrc)); 2449 CreatePrimaryWithFecFrStreamParams("cname", kSsrcs1[0], kFlexfecSsrc));
2450 webrtc::VideoSendStream::Config config = stream->GetConfig().Copy(); 2450 webrtc::VideoSendStream::Config config = stream->GetConfig().Copy();
2451 2451
2452 EXPECT_EQ(-1, config.rtp.flexfec.payload_type); 2452 EXPECT_EQ(-1, config.rtp.flexfec.payload_type);
2453 EXPECT_EQ(0U, config.rtp.flexfec.ssrc); 2453 EXPECT_EQ(0U, config.rtp.flexfec.ssrc);
2454 EXPECT_TRUE(config.rtp.flexfec.protected_media_ssrcs.empty()); 2454 EXPECT_TRUE(config.rtp.flexfec.protected_media_ssrcs.empty());
2455 } 2455 }
2456 2456
2457 TEST_F(WebRtcVideoChannel2Test, 2457 TEST_F(WebRtcVideoChannelTest,
2458 FlexfecRecvCodecWithoutSsrcNotExposedByDefault) { 2458 FlexfecRecvCodecWithoutSsrcNotExposedByDefault) {
2459 AddRecvStream(); 2459 AddRecvStream();
2460 2460
2461 const std::vector<FakeFlexfecReceiveStream*>& streams = 2461 const std::vector<FakeFlexfecReceiveStream*>& streams =
2462 fake_call_->GetFlexfecReceiveStreams(); 2462 fake_call_->GetFlexfecReceiveStreams();
2463 EXPECT_TRUE(streams.empty()); 2463 EXPECT_TRUE(streams.empty());
2464 } 2464 }
2465 2465
2466 TEST_F(WebRtcVideoChannel2Test, FlexfecRecvCodecWithSsrcNotExposedByDefault) { 2466 TEST_F(WebRtcVideoChannelTest, FlexfecRecvCodecWithSsrcNotExposedByDefault) {
2467 AddRecvStream( 2467 AddRecvStream(
2468 CreatePrimaryWithFecFrStreamParams("cname", kSsrcs1[0], kFlexfecSsrc)); 2468 CreatePrimaryWithFecFrStreamParams("cname", kSsrcs1[0], kFlexfecSsrc));
2469 2469
2470 const std::vector<FakeFlexfecReceiveStream*>& streams = 2470 const std::vector<FakeFlexfecReceiveStream*>& streams =
2471 fake_call_->GetFlexfecReceiveStreams(); 2471 fake_call_->GetFlexfecReceiveStreams();
2472 EXPECT_TRUE(streams.empty()); 2472 EXPECT_TRUE(streams.empty());
2473 } 2473 }
2474 2474
2475 // TODO(brandtr): When FlexFEC is no longer behind a field trial, merge all 2475 // TODO(brandtr): When FlexFEC is no longer behind a field trial, merge all
2476 // tests that use this test fixture into the corresponding "non-field trial" 2476 // tests that use this test fixture into the corresponding "non-field trial"
2477 // tests. 2477 // tests.
2478 class WebRtcVideoChannel2FlexfecRecvTest : public WebRtcVideoChannel2Test { 2478 class WebRtcVideoChannelFlexfecRecvTest : public WebRtcVideoChannelTest {
2479 public: 2479 public:
2480 WebRtcVideoChannel2FlexfecRecvTest() 2480 WebRtcVideoChannelFlexfecRecvTest()
2481 : WebRtcVideoChannel2Test("WebRTC-FlexFEC-03-Advertised/Enabled/") {} 2481 : WebRtcVideoChannelTest("WebRTC-FlexFEC-03-Advertised/Enabled/") {}
2482 }; 2482 };
2483 2483
2484 TEST_F(WebRtcVideoChannel2FlexfecRecvTest, 2484 TEST_F(WebRtcVideoChannelFlexfecRecvTest,
2485 DefaultFlexfecCodecHasTransportCcAndRembFeedbackParam) { 2485 DefaultFlexfecCodecHasTransportCcAndRembFeedbackParam) {
2486 EXPECT_TRUE(cricket::HasTransportCc(GetEngineCodec("flexfec-03"))); 2486 EXPECT_TRUE(cricket::HasTransportCc(GetEngineCodec("flexfec-03")));
2487 EXPECT_TRUE(cricket::HasRemb(GetEngineCodec("flexfec-03"))); 2487 EXPECT_TRUE(cricket::HasRemb(GetEngineCodec("flexfec-03")));
2488 } 2488 }
2489 2489
2490 TEST_F(WebRtcVideoChannel2FlexfecRecvTest, SetDefaultRecvCodecsWithoutSsrc) { 2490 TEST_F(WebRtcVideoChannelFlexfecRecvTest, SetDefaultRecvCodecsWithoutSsrc) {
2491 AddRecvStream(); 2491 AddRecvStream();
2492 2492
2493 const std::vector<FakeFlexfecReceiveStream*>& streams = 2493 const std::vector<FakeFlexfecReceiveStream*>& streams =
2494 fake_call_->GetFlexfecReceiveStreams(); 2494 fake_call_->GetFlexfecReceiveStreams();
2495 EXPECT_TRUE(streams.empty()); 2495 EXPECT_TRUE(streams.empty());
2496 } 2496 }
2497 2497
2498 TEST_F(WebRtcVideoChannel2FlexfecRecvTest, SetDefaultRecvCodecsWithSsrc) { 2498 TEST_F(WebRtcVideoChannelFlexfecRecvTest, SetDefaultRecvCodecsWithSsrc) {
2499 AddRecvStream( 2499 AddRecvStream(
2500 CreatePrimaryWithFecFrStreamParams("cname", kSsrcs1[0], kFlexfecSsrc)); 2500 CreatePrimaryWithFecFrStreamParams("cname", kSsrcs1[0], kFlexfecSsrc));
2501 2501
2502 const std::vector<FakeFlexfecReceiveStream*>& streams = 2502 const std::vector<FakeFlexfecReceiveStream*>& streams =
2503 fake_call_->GetFlexfecReceiveStreams(); 2503 fake_call_->GetFlexfecReceiveStreams();
2504 ASSERT_EQ(1U, streams.size()); 2504 ASSERT_EQ(1U, streams.size());
2505 const FakeFlexfecReceiveStream* stream = streams.front(); 2505 const FakeFlexfecReceiveStream* stream = streams.front();
2506 const webrtc::FlexfecReceiveStream::Config& config = stream->GetConfig(); 2506 const webrtc::FlexfecReceiveStream::Config& config = stream->GetConfig();
2507 EXPECT_EQ(GetEngineCodec("flexfec-03").id, config.payload_type); 2507 EXPECT_EQ(GetEngineCodec("flexfec-03").id, config.payload_type);
2508 EXPECT_EQ(kFlexfecSsrc, config.remote_ssrc); 2508 EXPECT_EQ(kFlexfecSsrc, config.remote_ssrc);
2509 ASSERT_EQ(1U, config.protected_media_ssrcs.size()); 2509 ASSERT_EQ(1U, config.protected_media_ssrcs.size());
2510 EXPECT_EQ(kSsrcs1[0], config.protected_media_ssrcs[0]); 2510 EXPECT_EQ(kSsrcs1[0], config.protected_media_ssrcs[0]);
2511 } 2511 }
2512 2512
2513 TEST_F(WebRtcVideoChannel2FlexfecRecvTest, 2513 TEST_F(WebRtcVideoChannelFlexfecRecvTest,
2514 EnablingFlexfecDoesNotRecreateVideoReceiveStream) { 2514 EnablingFlexfecDoesNotRecreateVideoReceiveStream) {
2515 cricket::VideoRecvParameters recv_parameters; 2515 cricket::VideoRecvParameters recv_parameters;
2516 recv_parameters.codecs.push_back(GetEngineCodec("VP8")); 2516 recv_parameters.codecs.push_back(GetEngineCodec("VP8"));
2517 ASSERT_TRUE(channel_->SetRecvParameters(recv_parameters)); 2517 ASSERT_TRUE(channel_->SetRecvParameters(recv_parameters));
2518 2518
2519 AddRecvStream( 2519 AddRecvStream(
2520 CreatePrimaryWithFecFrStreamParams("cname", kSsrcs1[0], kFlexfecSsrc)); 2520 CreatePrimaryWithFecFrStreamParams("cname", kSsrcs1[0], kFlexfecSsrc));
2521 EXPECT_EQ(1, fake_call_->GetNumCreatedReceiveStreams()); 2521 EXPECT_EQ(1, fake_call_->GetNumCreatedReceiveStreams());
2522 EXPECT_EQ(1U, fake_call_->GetVideoReceiveStreams().size()); 2522 EXPECT_EQ(1U, fake_call_->GetVideoReceiveStreams().size());
2523 2523
2524 // Enable FlexFEC. 2524 // Enable FlexFEC.
2525 recv_parameters.codecs.push_back(GetEngineCodec("flexfec-03")); 2525 recv_parameters.codecs.push_back(GetEngineCodec("flexfec-03"));
2526 ASSERT_TRUE(channel_->SetRecvParameters(recv_parameters)); 2526 ASSERT_TRUE(channel_->SetRecvParameters(recv_parameters));
2527 EXPECT_EQ(2, fake_call_->GetNumCreatedReceiveStreams()) 2527 EXPECT_EQ(2, fake_call_->GetNumCreatedReceiveStreams())
2528 << "Enabling FlexFEC should create FlexfecReceiveStream."; 2528 << "Enabling FlexFEC should create FlexfecReceiveStream.";
2529 EXPECT_EQ(1U, fake_call_->GetVideoReceiveStreams().size()) 2529 EXPECT_EQ(1U, fake_call_->GetVideoReceiveStreams().size())
2530 << "Enabling FlexFEC should not create VideoReceiveStream."; 2530 << "Enabling FlexFEC should not create VideoReceiveStream.";
2531 EXPECT_EQ(1U, fake_call_->GetFlexfecReceiveStreams().size()) 2531 EXPECT_EQ(1U, fake_call_->GetFlexfecReceiveStreams().size())
2532 << "Enabling FlexFEC should create a single FlexfecReceiveStream."; 2532 << "Enabling FlexFEC should create a single FlexfecReceiveStream.";
2533 } 2533 }
2534 2534
2535 TEST_F(WebRtcVideoChannel2FlexfecRecvTest, 2535 TEST_F(WebRtcVideoChannelFlexfecRecvTest,
2536 DisablingFlexfecDoesNotRecreateVideoReceiveStream) { 2536 DisablingFlexfecDoesNotRecreateVideoReceiveStream) {
2537 cricket::VideoRecvParameters recv_parameters; 2537 cricket::VideoRecvParameters recv_parameters;
2538 recv_parameters.codecs.push_back(GetEngineCodec("VP8")); 2538 recv_parameters.codecs.push_back(GetEngineCodec("VP8"));
2539 recv_parameters.codecs.push_back(GetEngineCodec("flexfec-03")); 2539 recv_parameters.codecs.push_back(GetEngineCodec("flexfec-03"));
2540 ASSERT_TRUE(channel_->SetRecvParameters(recv_parameters)); 2540 ASSERT_TRUE(channel_->SetRecvParameters(recv_parameters));
2541 2541
2542 AddRecvStream( 2542 AddRecvStream(
2543 CreatePrimaryWithFecFrStreamParams("cname", kSsrcs1[0], kFlexfecSsrc)); 2543 CreatePrimaryWithFecFrStreamParams("cname", kSsrcs1[0], kFlexfecSsrc));
2544 EXPECT_EQ(2, fake_call_->GetNumCreatedReceiveStreams()); 2544 EXPECT_EQ(2, fake_call_->GetNumCreatedReceiveStreams());
2545 EXPECT_EQ(1U, fake_call_->GetVideoReceiveStreams().size()); 2545 EXPECT_EQ(1U, fake_call_->GetVideoReceiveStreams().size());
2546 EXPECT_EQ(1U, fake_call_->GetFlexfecReceiveStreams().size()); 2546 EXPECT_EQ(1U, fake_call_->GetFlexfecReceiveStreams().size());
2547 2547
2548 // Disable FlexFEC. 2548 // Disable FlexFEC.
2549 recv_parameters.codecs.clear(); 2549 recv_parameters.codecs.clear();
2550 recv_parameters.codecs.push_back(GetEngineCodec("VP8")); 2550 recv_parameters.codecs.push_back(GetEngineCodec("VP8"));
2551 ASSERT_TRUE(channel_->SetRecvParameters(recv_parameters)); 2551 ASSERT_TRUE(channel_->SetRecvParameters(recv_parameters));
2552 EXPECT_EQ(2, fake_call_->GetNumCreatedReceiveStreams()) 2552 EXPECT_EQ(2, fake_call_->GetNumCreatedReceiveStreams())
2553 << "Disabling FlexFEC should not recreate VideoReceiveStream."; 2553 << "Disabling FlexFEC should not recreate VideoReceiveStream.";
2554 EXPECT_EQ(1U, fake_call_->GetVideoReceiveStreams().size()) 2554 EXPECT_EQ(1U, fake_call_->GetVideoReceiveStreams().size())
2555 << "Disabling FlexFEC should not destroy VideoReceiveStream."; 2555 << "Disabling FlexFEC should not destroy VideoReceiveStream.";
2556 EXPECT_TRUE(fake_call_->GetFlexfecReceiveStreams().empty()) 2556 EXPECT_TRUE(fake_call_->GetFlexfecReceiveStreams().empty())
2557 << "Disabling FlexFEC should destroy FlexfecReceiveStream."; 2557 << "Disabling FlexFEC should destroy FlexfecReceiveStream.";
2558 } 2558 }
2559 2559
2560 // TODO(brandtr): When FlexFEC is no longer behind a field trial, merge all 2560 // TODO(brandtr): When FlexFEC is no longer behind a field trial, merge all
2561 // tests that use this test fixture into the corresponding "non-field trial" 2561 // tests that use this test fixture into the corresponding "non-field trial"
2562 // tests. 2562 // tests.
2563 class WebRtcVideoChannel2FlexfecSendRecvTest : public WebRtcVideoChannel2Test { 2563 class WebRtcVideoChannelFlexfecSendRecvTest : public WebRtcVideoChannelTest {
2564 public: 2564 public:
2565 WebRtcVideoChannel2FlexfecSendRecvTest() 2565 WebRtcVideoChannelFlexfecSendRecvTest()
2566 : WebRtcVideoChannel2Test( 2566 : WebRtcVideoChannelTest(
2567 "WebRTC-FlexFEC-03-Advertised/Enabled/WebRTC-FlexFEC-03/Enabled/") { 2567 "WebRTC-FlexFEC-03-Advertised/Enabled/WebRTC-FlexFEC-03/Enabled/") {
2568 } 2568 }
2569 }; 2569 };
2570 2570
2571 TEST_F(WebRtcVideoChannel2FlexfecSendRecvTest, 2571 TEST_F(WebRtcVideoChannelFlexfecSendRecvTest,
2572 SetDefaultSendCodecsWithoutSsrc) { 2572 SetDefaultSendCodecsWithoutSsrc) {
2573 FakeVideoSendStream* stream = AddSendStream(); 2573 FakeVideoSendStream* stream = AddSendStream();
2574 webrtc::VideoSendStream::Config config = stream->GetConfig().Copy(); 2574 webrtc::VideoSendStream::Config config = stream->GetConfig().Copy();
2575 2575
2576 EXPECT_EQ(GetEngineCodec("flexfec-03").id, config.rtp.flexfec.payload_type); 2576 EXPECT_EQ(GetEngineCodec("flexfec-03").id, config.rtp.flexfec.payload_type);
2577 EXPECT_EQ(0U, config.rtp.flexfec.ssrc); 2577 EXPECT_EQ(0U, config.rtp.flexfec.ssrc);
2578 EXPECT_TRUE(config.rtp.flexfec.protected_media_ssrcs.empty()); 2578 EXPECT_TRUE(config.rtp.flexfec.protected_media_ssrcs.empty());
2579 } 2579 }
2580 2580
2581 TEST_F(WebRtcVideoChannel2FlexfecSendRecvTest, SetDefaultSendCodecsWithSsrc) { 2581 TEST_F(WebRtcVideoChannelFlexfecSendRecvTest, SetDefaultSendCodecsWithSsrc) {
2582 FakeVideoSendStream* stream = AddSendStream( 2582 FakeVideoSendStream* stream = AddSendStream(
2583 CreatePrimaryWithFecFrStreamParams("cname", kSsrcs1[0], kFlexfecSsrc)); 2583 CreatePrimaryWithFecFrStreamParams("cname", kSsrcs1[0], kFlexfecSsrc));
2584 webrtc::VideoSendStream::Config config = stream->GetConfig().Copy(); 2584 webrtc::VideoSendStream::Config config = stream->GetConfig().Copy();
2585 2585
2586 EXPECT_EQ(GetEngineCodec("flexfec-03").id, config.rtp.flexfec.payload_type); 2586 EXPECT_EQ(GetEngineCodec("flexfec-03").id, config.rtp.flexfec.payload_type);
2587 EXPECT_EQ(kFlexfecSsrc, config.rtp.flexfec.ssrc); 2587 EXPECT_EQ(kFlexfecSsrc, config.rtp.flexfec.ssrc);
2588 ASSERT_EQ(1U, config.rtp.flexfec.protected_media_ssrcs.size()); 2588 ASSERT_EQ(1U, config.rtp.flexfec.protected_media_ssrcs.size());
2589 EXPECT_EQ(kSsrcs1[0], config.rtp.flexfec.protected_media_ssrcs[0]); 2589 EXPECT_EQ(kSsrcs1[0], config.rtp.flexfec.protected_media_ssrcs[0]);
2590 } 2590 }
2591 2591
2592 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithoutFec) { 2592 TEST_F(WebRtcVideoChannelTest, SetSendCodecsWithoutFec) {
2593 cricket::VideoSendParameters parameters; 2593 cricket::VideoSendParameters parameters;
2594 parameters.codecs.push_back(GetEngineCodec("VP8")); 2594 parameters.codecs.push_back(GetEngineCodec("VP8"));
2595 ASSERT_TRUE(channel_->SetSendParameters(parameters)); 2595 ASSERT_TRUE(channel_->SetSendParameters(parameters));
2596 2596
2597 FakeVideoSendStream* stream = AddSendStream(); 2597 FakeVideoSendStream* stream = AddSendStream();
2598 webrtc::VideoSendStream::Config config = stream->GetConfig().Copy(); 2598 webrtc::VideoSendStream::Config config = stream->GetConfig().Copy();
2599 2599
2600 EXPECT_EQ(-1, config.rtp.ulpfec.ulpfec_payload_type); 2600 EXPECT_EQ(-1, config.rtp.ulpfec.ulpfec_payload_type);
2601 EXPECT_EQ(-1, config.rtp.ulpfec.red_payload_type); 2601 EXPECT_EQ(-1, config.rtp.ulpfec.red_payload_type);
2602 } 2602 }
2603 2603
2604 TEST_F(WebRtcVideoChannel2FlexfecSendRecvTest, SetSendCodecsWithoutFec) { 2604 TEST_F(WebRtcVideoChannelFlexfecSendRecvTest, SetSendCodecsWithoutFec) {
2605 cricket::VideoSendParameters parameters; 2605 cricket::VideoSendParameters parameters;
2606 parameters.codecs.push_back(GetEngineCodec("VP8")); 2606 parameters.codecs.push_back(GetEngineCodec("VP8"));
2607 ASSERT_TRUE(channel_->SetSendParameters(parameters)); 2607 ASSERT_TRUE(channel_->SetSendParameters(parameters));
2608 2608
2609 FakeVideoSendStream* stream = AddSendStream(); 2609 FakeVideoSendStream* stream = AddSendStream();
2610 webrtc::VideoSendStream::Config config = stream->GetConfig().Copy(); 2610 webrtc::VideoSendStream::Config config = stream->GetConfig().Copy();
2611 2611
2612 EXPECT_EQ(-1, config.rtp.flexfec.payload_type); 2612 EXPECT_EQ(-1, config.rtp.flexfec.payload_type);
2613 } 2613 }
2614 2614
2615 TEST_F(WebRtcVideoChannel2FlexfecRecvTest, SetRecvCodecsWithFec) { 2615 TEST_F(WebRtcVideoChannelFlexfecRecvTest, SetRecvCodecsWithFec) {
2616 AddRecvStream( 2616 AddRecvStream(
2617 CreatePrimaryWithFecFrStreamParams("cname", kSsrcs1[0], kFlexfecSsrc)); 2617 CreatePrimaryWithFecFrStreamParams("cname", kSsrcs1[0], kFlexfecSsrc));
2618 2618
2619 cricket::VideoRecvParameters recv_parameters; 2619 cricket::VideoRecvParameters recv_parameters;
2620 recv_parameters.codecs.push_back(GetEngineCodec("VP8")); 2620 recv_parameters.codecs.push_back(GetEngineCodec("VP8"));
2621 recv_parameters.codecs.push_back(GetEngineCodec("flexfec-03")); 2621 recv_parameters.codecs.push_back(GetEngineCodec("flexfec-03"));
2622 ASSERT_TRUE(channel_->SetRecvParameters(recv_parameters)); 2622 ASSERT_TRUE(channel_->SetRecvParameters(recv_parameters));
2623 2623
2624 const std::vector<FakeFlexfecReceiveStream*>& flexfec_streams = 2624 const std::vector<FakeFlexfecReceiveStream*>& flexfec_streams =
2625 fake_call_->GetFlexfecReceiveStreams(); 2625 fake_call_->GetFlexfecReceiveStreams();
(...skipping 21 matching lines...) Expand all
2647 EXPECT_EQ(video_stream_config.rtp.transport_cc, 2647 EXPECT_EQ(video_stream_config.rtp.transport_cc,
2648 flexfec_stream_config.transport_cc); 2648 flexfec_stream_config.transport_cc);
2649 EXPECT_EQ(video_stream_config.rtp.rtcp_mode, flexfec_stream_config.rtcp_mode); 2649 EXPECT_EQ(video_stream_config.rtp.rtcp_mode, flexfec_stream_config.rtcp_mode);
2650 EXPECT_EQ(video_stream_config.rtp.extensions, 2650 EXPECT_EQ(video_stream_config.rtp.extensions,
2651 flexfec_stream_config.rtp_header_extensions); 2651 flexfec_stream_config.rtp_header_extensions);
2652 } 2652 }
2653 2653
2654 // We should not send FlexFEC, even if we advertise it, unless the right 2654 // We should not send FlexFEC, even if we advertise it, unless the right
2655 // field trial is set. 2655 // field trial is set.
2656 // TODO(brandtr): Remove when FlexFEC is enabled by default. 2656 // TODO(brandtr): Remove when FlexFEC is enabled by default.
2657 TEST_F(WebRtcVideoChannel2FlexfecRecvTest, 2657 TEST_F(WebRtcVideoChannelFlexfecRecvTest,
2658 SetSendCodecsWithoutSsrcWithFecDoesNotEnableFec) { 2658 SetSendCodecsWithoutSsrcWithFecDoesNotEnableFec) {
2659 cricket::VideoSendParameters parameters; 2659 cricket::VideoSendParameters parameters;
2660 parameters.codecs.push_back(GetEngineCodec("VP8")); 2660 parameters.codecs.push_back(GetEngineCodec("VP8"));
2661 parameters.codecs.push_back(GetEngineCodec("flexfec-03")); 2661 parameters.codecs.push_back(GetEngineCodec("flexfec-03"));
2662 ASSERT_TRUE(channel_->SetSendParameters(parameters)); 2662 ASSERT_TRUE(channel_->SetSendParameters(parameters));
2663 2663
2664 FakeVideoSendStream* stream = AddSendStream(); 2664 FakeVideoSendStream* stream = AddSendStream();
2665 webrtc::VideoSendStream::Config config = stream->GetConfig().Copy(); 2665 webrtc::VideoSendStream::Config config = stream->GetConfig().Copy();
2666 2666
2667 EXPECT_EQ(-1, config.rtp.flexfec.payload_type); 2667 EXPECT_EQ(-1, config.rtp.flexfec.payload_type);
2668 EXPECT_EQ(0, config.rtp.flexfec.ssrc); 2668 EXPECT_EQ(0, config.rtp.flexfec.ssrc);
2669 EXPECT_TRUE(config.rtp.flexfec.protected_media_ssrcs.empty()); 2669 EXPECT_TRUE(config.rtp.flexfec.protected_media_ssrcs.empty());
2670 } 2670 }
2671 2671
2672 TEST_F(WebRtcVideoChannel2FlexfecRecvTest, 2672 TEST_F(WebRtcVideoChannelFlexfecRecvTest,
2673 SetSendCodecsWithSsrcWithFecDoesNotEnableFec) { 2673 SetSendCodecsWithSsrcWithFecDoesNotEnableFec) {
2674 cricket::VideoSendParameters parameters; 2674 cricket::VideoSendParameters parameters;
2675 parameters.codecs.push_back(GetEngineCodec("VP8")); 2675 parameters.codecs.push_back(GetEngineCodec("VP8"));
2676 parameters.codecs.push_back(GetEngineCodec("flexfec-03")); 2676 parameters.codecs.push_back(GetEngineCodec("flexfec-03"));
2677 ASSERT_TRUE(channel_->SetSendParameters(parameters)); 2677 ASSERT_TRUE(channel_->SetSendParameters(parameters));
2678 2678
2679 FakeVideoSendStream* stream = AddSendStream( 2679 FakeVideoSendStream* stream = AddSendStream(
2680 CreatePrimaryWithFecFrStreamParams("cname", kSsrcs1[0], kFlexfecSsrc)); 2680 CreatePrimaryWithFecFrStreamParams("cname", kSsrcs1[0], kFlexfecSsrc));
2681 webrtc::VideoSendStream::Config config = stream->GetConfig().Copy(); 2681 webrtc::VideoSendStream::Config config = stream->GetConfig().Copy();
2682 2682
2683 EXPECT_EQ(-1, config.rtp.flexfec.payload_type); 2683 EXPECT_EQ(-1, config.rtp.flexfec.payload_type);
2684 EXPECT_EQ(0, config.rtp.flexfec.ssrc); 2684 EXPECT_EQ(0, config.rtp.flexfec.ssrc);
2685 EXPECT_TRUE(config.rtp.flexfec.protected_media_ssrcs.empty()); 2685 EXPECT_TRUE(config.rtp.flexfec.protected_media_ssrcs.empty());
2686 } 2686 }
2687 2687
2688 TEST_F(WebRtcVideoChannel2Test, 2688 TEST_F(WebRtcVideoChannelTest,
2689 SetSendCodecRejectsRtxWithoutAssociatedPayloadType) { 2689 SetSendCodecRejectsRtxWithoutAssociatedPayloadType) {
2690 const int kUnusedPayloadType = 127; 2690 const int kUnusedPayloadType = 127;
2691 EXPECT_FALSE(FindCodecById(engine_.codecs(), kUnusedPayloadType)); 2691 EXPECT_FALSE(FindCodecById(engine_.codecs(), kUnusedPayloadType));
2692 2692
2693 cricket::VideoSendParameters parameters; 2693 cricket::VideoSendParameters parameters;
2694 cricket::VideoCodec rtx_codec(kUnusedPayloadType, "rtx"); 2694 cricket::VideoCodec rtx_codec(kUnusedPayloadType, "rtx");
2695 parameters.codecs.push_back(rtx_codec); 2695 parameters.codecs.push_back(rtx_codec);
2696 EXPECT_FALSE(channel_->SetSendParameters(parameters)) 2696 EXPECT_FALSE(channel_->SetSendParameters(parameters))
2697 << "RTX codec without associated payload type should be rejected."; 2697 << "RTX codec without associated payload type should be rejected.";
2698 } 2698 }
2699 2699
2700 TEST_F(WebRtcVideoChannel2Test, 2700 TEST_F(WebRtcVideoChannelTest,
2701 SetSendCodecRejectsRtxWithoutMatchingVideoCodec) { 2701 SetSendCodecRejectsRtxWithoutMatchingVideoCodec) {
2702 const int kUnusedPayloadType1 = 126; 2702 const int kUnusedPayloadType1 = 126;
2703 const int kUnusedPayloadType2 = 127; 2703 const int kUnusedPayloadType2 = 127;
2704 EXPECT_FALSE(FindCodecById(engine_.codecs(), kUnusedPayloadType1)); 2704 EXPECT_FALSE(FindCodecById(engine_.codecs(), kUnusedPayloadType1));
2705 EXPECT_FALSE(FindCodecById(engine_.codecs(), kUnusedPayloadType2)); 2705 EXPECT_FALSE(FindCodecById(engine_.codecs(), kUnusedPayloadType2));
2706 { 2706 {
2707 cricket::VideoCodec rtx_codec = cricket::VideoCodec::CreateRtxCodec( 2707 cricket::VideoCodec rtx_codec = cricket::VideoCodec::CreateRtxCodec(
2708 kUnusedPayloadType1, GetEngineCodec("VP8").id); 2708 kUnusedPayloadType1, GetEngineCodec("VP8").id);
2709 cricket::VideoSendParameters parameters; 2709 cricket::VideoSendParameters parameters;
2710 parameters.codecs.push_back(GetEngineCodec("VP8")); 2710 parameters.codecs.push_back(GetEngineCodec("VP8"));
2711 parameters.codecs.push_back(rtx_codec); 2711 parameters.codecs.push_back(rtx_codec);
2712 ASSERT_TRUE(channel_->SetSendParameters(parameters)); 2712 ASSERT_TRUE(channel_->SetSendParameters(parameters));
2713 } 2713 }
2714 { 2714 {
2715 cricket::VideoCodec rtx_codec = cricket::VideoCodec::CreateRtxCodec( 2715 cricket::VideoCodec rtx_codec = cricket::VideoCodec::CreateRtxCodec(
2716 kUnusedPayloadType1, kUnusedPayloadType2); 2716 kUnusedPayloadType1, kUnusedPayloadType2);
2717 cricket::VideoSendParameters parameters; 2717 cricket::VideoSendParameters parameters;
2718 parameters.codecs.push_back(GetEngineCodec("VP8")); 2718 parameters.codecs.push_back(GetEngineCodec("VP8"));
2719 parameters.codecs.push_back(rtx_codec); 2719 parameters.codecs.push_back(rtx_codec);
2720 EXPECT_FALSE(channel_->SetSendParameters(parameters)) 2720 EXPECT_FALSE(channel_->SetSendParameters(parameters))
2721 << "RTX without matching video codec should be rejected."; 2721 << "RTX without matching video codec should be rejected.";
2722 } 2722 }
2723 } 2723 }
2724 2724
2725 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithChangedRtxPayloadType) { 2725 TEST_F(WebRtcVideoChannelTest, SetSendCodecsWithChangedRtxPayloadType) {
2726 const int kUnusedPayloadType1 = 126; 2726 const int kUnusedPayloadType1 = 126;
2727 const int kUnusedPayloadType2 = 127; 2727 const int kUnusedPayloadType2 = 127;
2728 EXPECT_FALSE(FindCodecById(engine_.codecs(), kUnusedPayloadType1)); 2728 EXPECT_FALSE(FindCodecById(engine_.codecs(), kUnusedPayloadType1));
2729 EXPECT_FALSE(FindCodecById(engine_.codecs(), kUnusedPayloadType2)); 2729 EXPECT_FALSE(FindCodecById(engine_.codecs(), kUnusedPayloadType2));
2730 2730
2731 // SSRCs for RTX. 2731 // SSRCs for RTX.
2732 cricket::StreamParams params = 2732 cricket::StreamParams params =
2733 cricket::StreamParams::CreateLegacy(kSsrcs1[0]); 2733 cricket::StreamParams::CreateLegacy(kSsrcs1[0]);
2734 params.AddFidSsrc(kSsrcs1[0], kRtxSsrcs1[0]); 2734 params.AddFidSsrc(kSsrcs1[0], kRtxSsrcs1[0]);
2735 AddSendStream(params); 2735 AddSendStream(params);
(...skipping 16 matching lines...) Expand all
2752 parameters.codecs[1].id = kUnusedPayloadType2; 2752 parameters.codecs[1].id = kUnusedPayloadType2;
2753 EXPECT_TRUE(channel_->SetSendParameters(parameters)); 2753 EXPECT_TRUE(channel_->SetSendParameters(parameters));
2754 ASSERT_EQ(1U, fake_call_->GetVideoSendStreams().size()); 2754 ASSERT_EQ(1U, fake_call_->GetVideoSendStreams().size());
2755 const webrtc::VideoSendStream::Config& config_after = 2755 const webrtc::VideoSendStream::Config& config_after =
2756 fake_call_->GetVideoSendStreams()[0]->GetConfig(); 2756 fake_call_->GetVideoSendStreams()[0]->GetConfig();
2757 EXPECT_EQ(kUnusedPayloadType2, config_after.rtp.rtx.payload_type); 2757 EXPECT_EQ(kUnusedPayloadType2, config_after.rtp.rtx.payload_type);
2758 ASSERT_EQ(1U, config_after.rtp.rtx.ssrcs.size()); 2758 ASSERT_EQ(1U, config_after.rtp.rtx.ssrcs.size());
2759 EXPECT_EQ(kRtxSsrcs1[0], config_after.rtp.rtx.ssrcs[0]); 2759 EXPECT_EQ(kRtxSsrcs1[0], config_after.rtp.rtx.ssrcs[0]);
2760 } 2760 }
2761 2761
2762 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithoutFecDisablesFec) { 2762 TEST_F(WebRtcVideoChannelTest, SetSendCodecsWithoutFecDisablesFec) {
2763 cricket::VideoSendParameters parameters; 2763 cricket::VideoSendParameters parameters;
2764 parameters.codecs.push_back(GetEngineCodec("VP8")); 2764 parameters.codecs.push_back(GetEngineCodec("VP8"));
2765 parameters.codecs.push_back(GetEngineCodec("ulpfec")); 2765 parameters.codecs.push_back(GetEngineCodec("ulpfec"));
2766 ASSERT_TRUE(channel_->SetSendParameters(parameters)); 2766 ASSERT_TRUE(channel_->SetSendParameters(parameters));
2767 2767
2768 FakeVideoSendStream* stream = AddSendStream(); 2768 FakeVideoSendStream* stream = AddSendStream();
2769 webrtc::VideoSendStream::Config config = stream->GetConfig().Copy(); 2769 webrtc::VideoSendStream::Config config = stream->GetConfig().Copy();
2770 2770
2771 EXPECT_EQ(GetEngineCodec("ulpfec").id, config.rtp.ulpfec.ulpfec_payload_type); 2771 EXPECT_EQ(GetEngineCodec("ulpfec").id, config.rtp.ulpfec.ulpfec_payload_type);
2772 2772
2773 parameters.codecs.pop_back(); 2773 parameters.codecs.pop_back();
2774 ASSERT_TRUE(channel_->SetSendParameters(parameters)); 2774 ASSERT_TRUE(channel_->SetSendParameters(parameters));
2775 stream = fake_call_->GetVideoSendStreams()[0]; 2775 stream = fake_call_->GetVideoSendStreams()[0];
2776 ASSERT_TRUE(stream != nullptr); 2776 ASSERT_TRUE(stream != nullptr);
2777 config = stream->GetConfig().Copy(); 2777 config = stream->GetConfig().Copy();
2778 EXPECT_EQ(-1, config.rtp.ulpfec.ulpfec_payload_type) 2778 EXPECT_EQ(-1, config.rtp.ulpfec.ulpfec_payload_type)
2779 << "SetSendCodec without ULPFEC should disable current ULPFEC."; 2779 << "SetSendCodec without ULPFEC should disable current ULPFEC.";
2780 } 2780 }
2781 2781
2782 TEST_F(WebRtcVideoChannel2FlexfecSendRecvTest, 2782 TEST_F(WebRtcVideoChannelFlexfecSendRecvTest,
2783 SetSendCodecsWithoutFecDisablesFec) { 2783 SetSendCodecsWithoutFecDisablesFec) {
2784 cricket::VideoSendParameters parameters; 2784 cricket::VideoSendParameters parameters;
2785 parameters.codecs.push_back(GetEngineCodec("VP8")); 2785 parameters.codecs.push_back(GetEngineCodec("VP8"));
2786 parameters.codecs.push_back(GetEngineCodec("flexfec-03")); 2786 parameters.codecs.push_back(GetEngineCodec("flexfec-03"));
2787 ASSERT_TRUE(channel_->SetSendParameters(parameters)); 2787 ASSERT_TRUE(channel_->SetSendParameters(parameters));
2788 2788
2789 FakeVideoSendStream* stream = AddSendStream( 2789 FakeVideoSendStream* stream = AddSendStream(
2790 CreatePrimaryWithFecFrStreamParams("cname", kSsrcs1[0], kFlexfecSsrc)); 2790 CreatePrimaryWithFecFrStreamParams("cname", kSsrcs1[0], kFlexfecSsrc));
2791 webrtc::VideoSendStream::Config config = stream->GetConfig().Copy(); 2791 webrtc::VideoSendStream::Config config = stream->GetConfig().Copy();
2792 2792
2793 EXPECT_EQ(GetEngineCodec("flexfec-03").id, config.rtp.flexfec.payload_type); 2793 EXPECT_EQ(GetEngineCodec("flexfec-03").id, config.rtp.flexfec.payload_type);
2794 EXPECT_EQ(kFlexfecSsrc, config.rtp.flexfec.ssrc); 2794 EXPECT_EQ(kFlexfecSsrc, config.rtp.flexfec.ssrc);
2795 ASSERT_EQ(1U, config.rtp.flexfec.protected_media_ssrcs.size()); 2795 ASSERT_EQ(1U, config.rtp.flexfec.protected_media_ssrcs.size());
2796 EXPECT_EQ(kSsrcs1[0], config.rtp.flexfec.protected_media_ssrcs[0]); 2796 EXPECT_EQ(kSsrcs1[0], config.rtp.flexfec.protected_media_ssrcs[0]);
2797 2797
2798 parameters.codecs.pop_back(); 2798 parameters.codecs.pop_back();
2799 ASSERT_TRUE(channel_->SetSendParameters(parameters)); 2799 ASSERT_TRUE(channel_->SetSendParameters(parameters));
2800 stream = fake_call_->GetVideoSendStreams()[0]; 2800 stream = fake_call_->GetVideoSendStreams()[0];
2801 ASSERT_TRUE(stream != nullptr); 2801 ASSERT_TRUE(stream != nullptr);
2802 config = stream->GetConfig().Copy(); 2802 config = stream->GetConfig().Copy();
2803 EXPECT_EQ(-1, config.rtp.flexfec.payload_type) 2803 EXPECT_EQ(-1, config.rtp.flexfec.payload_type)
2804 << "SetSendCodec without FlexFEC should disable current FlexFEC."; 2804 << "SetSendCodec without FlexFEC should disable current FlexFEC.";
2805 } 2805 }
2806 2806
2807 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsChangesExistingStreams) { 2807 TEST_F(WebRtcVideoChannelTest, SetSendCodecsChangesExistingStreams) {
2808 cricket::VideoSendParameters parameters; 2808 cricket::VideoSendParameters parameters;
2809 cricket::VideoCodec codec(100, "VP8"); 2809 cricket::VideoCodec codec(100, "VP8");
2810 codec.SetParam(kCodecParamMaxQuantization, kDefaultQpMax); 2810 codec.SetParam(kCodecParamMaxQuantization, kDefaultQpMax);
2811 parameters.codecs.push_back(codec); 2811 parameters.codecs.push_back(codec);
2812 2812
2813 ASSERT_TRUE(channel_->SetSendParameters(parameters)); 2813 ASSERT_TRUE(channel_->SetSendParameters(parameters));
2814 channel_->SetSend(true); 2814 channel_->SetSend(true);
2815 2815
2816 FakeVideoSendStream* stream = AddSendStream(); 2816 FakeVideoSendStream* stream = AddSendStream();
2817 cricket::FakeVideoCapturer capturer; 2817 cricket::FakeVideoCapturer capturer;
2818 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, &capturer)); 2818 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, &capturer));
2819 2819
2820 std::vector<webrtc::VideoStream> streams = stream->GetVideoStreams(); 2820 std::vector<webrtc::VideoStream> streams = stream->GetVideoStreams();
2821 EXPECT_EQ(kDefaultQpMax, streams[0].max_qp); 2821 EXPECT_EQ(kDefaultQpMax, streams[0].max_qp);
2822 2822
2823 parameters.codecs.clear(); 2823 parameters.codecs.clear();
2824 codec.SetParam(kCodecParamMaxQuantization, kDefaultQpMax + 1); 2824 codec.SetParam(kCodecParamMaxQuantization, kDefaultQpMax + 1);
2825 parameters.codecs.push_back(codec); 2825 parameters.codecs.push_back(codec);
2826 ASSERT_TRUE(channel_->SetSendParameters(parameters)); 2826 ASSERT_TRUE(channel_->SetSendParameters(parameters));
2827 streams = fake_call_->GetVideoSendStreams()[0]->GetVideoStreams(); 2827 streams = fake_call_->GetVideoSendStreams()[0]->GetVideoStreams();
2828 EXPECT_EQ(kDefaultQpMax + 1, streams[0].max_qp); 2828 EXPECT_EQ(kDefaultQpMax + 1, streams[0].max_qp);
2829 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); 2829 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr));
2830 } 2830 }
2831 2831
2832 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithBitrates) { 2832 TEST_F(WebRtcVideoChannelTest, SetSendCodecsWithBitrates) {
2833 SetSendCodecsShouldWorkForBitrates("100", 100000, "150", 150000, "200", 2833 SetSendCodecsShouldWorkForBitrates("100", 100000, "150", 150000, "200",
2834 200000); 2834 200000);
2835 } 2835 }
2836 2836
2837 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithHighMaxBitrate) { 2837 TEST_F(WebRtcVideoChannelTest, SetSendCodecsWithHighMaxBitrate) {
2838 SetSendCodecsShouldWorkForBitrates("", 0, "", -1, "10000", 10000000); 2838 SetSendCodecsShouldWorkForBitrates("", 0, "", -1, "10000", 10000000);
2839 std::vector<webrtc::VideoStream> streams = AddSendStream()->GetVideoStreams(); 2839 std::vector<webrtc::VideoStream> streams = AddSendStream()->GetVideoStreams();
2840 ASSERT_EQ(1u, streams.size()); 2840 ASSERT_EQ(1u, streams.size());
2841 EXPECT_EQ(10000000, streams[0].max_bitrate_bps); 2841 EXPECT_EQ(10000000, streams[0].max_bitrate_bps);
2842 } 2842 }
2843 2843
2844 TEST_F(WebRtcVideoChannel2Test, 2844 TEST_F(WebRtcVideoChannelTest,
2845 SetSendCodecsWithoutBitratesUsesCorrectDefaults) { 2845 SetSendCodecsWithoutBitratesUsesCorrectDefaults) {
2846 SetSendCodecsShouldWorkForBitrates( 2846 SetSendCodecsShouldWorkForBitrates(
2847 "", 0, "", -1, "", -1); 2847 "", 0, "", -1, "", -1);
2848 } 2848 }
2849 2849
2850 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsCapsMinAndStartBitrate) { 2850 TEST_F(WebRtcVideoChannelTest, SetSendCodecsCapsMinAndStartBitrate) {
2851 SetSendCodecsShouldWorkForBitrates("-1", 0, "-100", -1, "", -1); 2851 SetSendCodecsShouldWorkForBitrates("-1", 0, "-100", -1, "", -1);
2852 } 2852 }
2853 2853
2854 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsRejectsMaxLessThanMinBitrate) { 2854 TEST_F(WebRtcVideoChannelTest, SetSendCodecsRejectsMaxLessThanMinBitrate) {
2855 send_parameters_.codecs[0].params[kCodecParamMinBitrate] = "300"; 2855 send_parameters_.codecs[0].params[kCodecParamMinBitrate] = "300";
2856 send_parameters_.codecs[0].params[kCodecParamMaxBitrate] = "200"; 2856 send_parameters_.codecs[0].params[kCodecParamMaxBitrate] = "200";
2857 EXPECT_FALSE(channel_->SetSendParameters(send_parameters_)); 2857 EXPECT_FALSE(channel_->SetSendParameters(send_parameters_));
2858 } 2858 }
2859 2859
2860 // Test that when both the codec-specific bitrate params and max_bandwidth_bps 2860 // Test that when both the codec-specific bitrate params and max_bandwidth_bps
2861 // are present in the same send parameters, the settings are combined correctly. 2861 // are present in the same send parameters, the settings are combined correctly.
2862 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithBitratesAndMaxSendBandwidth) { 2862 TEST_F(WebRtcVideoChannelTest, SetSendCodecsWithBitratesAndMaxSendBandwidth) {
2863 send_parameters_.codecs[0].params[kCodecParamMinBitrate] = "100"; 2863 send_parameters_.codecs[0].params[kCodecParamMinBitrate] = "100";
2864 send_parameters_.codecs[0].params[kCodecParamStartBitrate] = "200"; 2864 send_parameters_.codecs[0].params[kCodecParamStartBitrate] = "200";
2865 send_parameters_.codecs[0].params[kCodecParamMaxBitrate] = "300"; 2865 send_parameters_.codecs[0].params[kCodecParamMaxBitrate] = "300";
2866 send_parameters_.max_bandwidth_bps = 400000; 2866 send_parameters_.max_bandwidth_bps = 400000;
2867 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); 2867 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
2868 EXPECT_EQ(100000, fake_call_->GetConfig().bitrate_config.min_bitrate_bps); 2868 EXPECT_EQ(100000, fake_call_->GetConfig().bitrate_config.min_bitrate_bps);
2869 EXPECT_EQ(200000, fake_call_->GetConfig().bitrate_config.start_bitrate_bps); 2869 EXPECT_EQ(200000, fake_call_->GetConfig().bitrate_config.start_bitrate_bps);
2870 // We expect max_bandwidth_bps to take priority, if set. 2870 // We expect max_bandwidth_bps to take priority, if set.
2871 EXPECT_EQ(400000, fake_call_->GetConfig().bitrate_config.max_bitrate_bps); 2871 EXPECT_EQ(400000, fake_call_->GetConfig().bitrate_config.max_bitrate_bps);
2872 2872
(...skipping 14 matching lines...) Expand all
2887 EXPECT_EQ(300000, fake_call_->GetConfig().bitrate_config.max_bitrate_bps); 2887 EXPECT_EQ(300000, fake_call_->GetConfig().bitrate_config.max_bitrate_bps);
2888 2888
2889 // If we change the codec max, max_bandwidth_bps should still apply. 2889 // If we change the codec max, max_bandwidth_bps should still apply.
2890 send_parameters_.codecs[0].params[kCodecParamMaxBitrate] = "350"; 2890 send_parameters_.codecs[0].params[kCodecParamMaxBitrate] = "350";
2891 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); 2891 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
2892 EXPECT_EQ(100000, fake_call_->GetConfig().bitrate_config.min_bitrate_bps); 2892 EXPECT_EQ(100000, fake_call_->GetConfig().bitrate_config.min_bitrate_bps);
2893 EXPECT_EQ(200000, fake_call_->GetConfig().bitrate_config.start_bitrate_bps); 2893 EXPECT_EQ(200000, fake_call_->GetConfig().bitrate_config.start_bitrate_bps);
2894 EXPECT_EQ(300000, fake_call_->GetConfig().bitrate_config.max_bitrate_bps); 2894 EXPECT_EQ(300000, fake_call_->GetConfig().bitrate_config.max_bitrate_bps);
2895 } 2895 }
2896 2896
2897 TEST_F(WebRtcVideoChannel2Test, 2897 TEST_F(WebRtcVideoChannelTest,
2898 SetMaxSendBandwidthShouldPreserveOtherBitrates) { 2898 SetMaxSendBandwidthShouldPreserveOtherBitrates) {
2899 SetSendCodecsShouldWorkForBitrates("100", 100000, "150", 150000, "200", 2899 SetSendCodecsShouldWorkForBitrates("100", 100000, "150", 150000, "200",
2900 200000); 2900 200000);
2901 send_parameters_.max_bandwidth_bps = 300000; 2901 send_parameters_.max_bandwidth_bps = 300000;
2902 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); 2902 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
2903 EXPECT_EQ(100000, fake_call_->GetConfig().bitrate_config.min_bitrate_bps) 2903 EXPECT_EQ(100000, fake_call_->GetConfig().bitrate_config.min_bitrate_bps)
2904 << "Setting max bitrate should keep previous min bitrate."; 2904 << "Setting max bitrate should keep previous min bitrate.";
2905 EXPECT_EQ(-1, fake_call_->GetConfig().bitrate_config.start_bitrate_bps) 2905 EXPECT_EQ(-1, fake_call_->GetConfig().bitrate_config.start_bitrate_bps)
2906 << "Setting max bitrate should not reset start bitrate."; 2906 << "Setting max bitrate should not reset start bitrate.";
2907 EXPECT_EQ(300000, fake_call_->GetConfig().bitrate_config.max_bitrate_bps); 2907 EXPECT_EQ(300000, fake_call_->GetConfig().bitrate_config.max_bitrate_bps);
2908 } 2908 }
2909 2909
2910 TEST_F(WebRtcVideoChannel2Test, SetMaxSendBandwidthShouldBeRemovable) { 2910 TEST_F(WebRtcVideoChannelTest, SetMaxSendBandwidthShouldBeRemovable) {
2911 send_parameters_.max_bandwidth_bps = 300000; 2911 send_parameters_.max_bandwidth_bps = 300000;
2912 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); 2912 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
2913 EXPECT_EQ(300000, fake_call_->GetConfig().bitrate_config.max_bitrate_bps); 2913 EXPECT_EQ(300000, fake_call_->GetConfig().bitrate_config.max_bitrate_bps);
2914 // -1 means to disable max bitrate (set infinite). 2914 // -1 means to disable max bitrate (set infinite).
2915 send_parameters_.max_bandwidth_bps = -1; 2915 send_parameters_.max_bandwidth_bps = -1;
2916 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); 2916 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
2917 EXPECT_EQ(-1, fake_call_->GetConfig().bitrate_config.max_bitrate_bps) 2917 EXPECT_EQ(-1, fake_call_->GetConfig().bitrate_config.max_bitrate_bps)
2918 << "Setting zero max bitrate did not reset start bitrate."; 2918 << "Setting zero max bitrate did not reset start bitrate.";
2919 } 2919 }
2920 2920
2921 TEST_F(WebRtcVideoChannel2Test, SetMaxSendBandwidthAndAddSendStream) { 2921 TEST_F(WebRtcVideoChannelTest, SetMaxSendBandwidthAndAddSendStream) {
2922 send_parameters_.max_bandwidth_bps = 99999; 2922 send_parameters_.max_bandwidth_bps = 99999;
2923 FakeVideoSendStream* stream = AddSendStream(); 2923 FakeVideoSendStream* stream = AddSendStream();
2924 ASSERT_TRUE(channel_->SetSendParameters(send_parameters_)); 2924 ASSERT_TRUE(channel_->SetSendParameters(send_parameters_));
2925 EXPECT_EQ(send_parameters_.max_bandwidth_bps, 2925 EXPECT_EQ(send_parameters_.max_bandwidth_bps,
2926 fake_call_->GetConfig().bitrate_config.max_bitrate_bps); 2926 fake_call_->GetConfig().bitrate_config.max_bitrate_bps);
2927 ASSERT_EQ(1u, stream->GetVideoStreams().size()); 2927 ASSERT_EQ(1u, stream->GetVideoStreams().size());
2928 EXPECT_EQ(send_parameters_.max_bandwidth_bps, 2928 EXPECT_EQ(send_parameters_.max_bandwidth_bps,
2929 stream->GetVideoStreams()[0].max_bitrate_bps); 2929 stream->GetVideoStreams()[0].max_bitrate_bps);
2930 2930
2931 send_parameters_.max_bandwidth_bps = 77777; 2931 send_parameters_.max_bandwidth_bps = 77777;
2932 ASSERT_TRUE(channel_->SetSendParameters(send_parameters_)); 2932 ASSERT_TRUE(channel_->SetSendParameters(send_parameters_));
2933 EXPECT_EQ(send_parameters_.max_bandwidth_bps, 2933 EXPECT_EQ(send_parameters_.max_bandwidth_bps,
2934 fake_call_->GetConfig().bitrate_config.max_bitrate_bps); 2934 fake_call_->GetConfig().bitrate_config.max_bitrate_bps);
2935 EXPECT_EQ(send_parameters_.max_bandwidth_bps, 2935 EXPECT_EQ(send_parameters_.max_bandwidth_bps,
2936 stream->GetVideoStreams()[0].max_bitrate_bps); 2936 stream->GetVideoStreams()[0].max_bitrate_bps);
2937 } 2937 }
2938 2938
2939 TEST_F(WebRtcVideoChannel2Test, SetMaxSendBitrateCanIncreaseSenderBitrate) { 2939 TEST_F(WebRtcVideoChannelTest, SetMaxSendBitrateCanIncreaseSenderBitrate) {
2940 cricket::VideoSendParameters parameters; 2940 cricket::VideoSendParameters parameters;
2941 parameters.codecs.push_back(GetEngineCodec("VP8")); 2941 parameters.codecs.push_back(GetEngineCodec("VP8"));
2942 ASSERT_TRUE(channel_->SetSendParameters(parameters)); 2942 ASSERT_TRUE(channel_->SetSendParameters(parameters));
2943 channel_->SetSend(true); 2943 channel_->SetSend(true);
2944 2944
2945 FakeVideoSendStream* stream = AddSendStream(); 2945 FakeVideoSendStream* stream = AddSendStream();
2946 2946
2947 cricket::FakeVideoCapturer capturer; 2947 cricket::FakeVideoCapturer capturer;
2948 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, &capturer)); 2948 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, &capturer));
2949 EXPECT_EQ(cricket::CS_RUNNING, 2949 EXPECT_EQ(cricket::CS_RUNNING,
2950 capturer.Start(capturer.GetSupportedFormats()->front())); 2950 capturer.Start(capturer.GetSupportedFormats()->front()));
2951 2951
2952 std::vector<webrtc::VideoStream> streams = stream->GetVideoStreams(); 2952 std::vector<webrtc::VideoStream> streams = stream->GetVideoStreams();
2953 int initial_max_bitrate_bps = streams[0].max_bitrate_bps; 2953 int initial_max_bitrate_bps = streams[0].max_bitrate_bps;
2954 EXPECT_GT(initial_max_bitrate_bps, 0); 2954 EXPECT_GT(initial_max_bitrate_bps, 0);
2955 2955
2956 parameters.max_bandwidth_bps = initial_max_bitrate_bps * 2; 2956 parameters.max_bandwidth_bps = initial_max_bitrate_bps * 2;
2957 EXPECT_TRUE(channel_->SetSendParameters(parameters)); 2957 EXPECT_TRUE(channel_->SetSendParameters(parameters));
2958 // Insert a frame to update the encoder config. 2958 // Insert a frame to update the encoder config.
2959 EXPECT_TRUE(capturer.CaptureFrame()); 2959 EXPECT_TRUE(capturer.CaptureFrame());
2960 streams = stream->GetVideoStreams(); 2960 streams = stream->GetVideoStreams();
2961 EXPECT_EQ(initial_max_bitrate_bps * 2, streams[0].max_bitrate_bps); 2961 EXPECT_EQ(initial_max_bitrate_bps * 2, streams[0].max_bitrate_bps);
2962 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); 2962 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr));
2963 } 2963 }
2964 2964
2965 TEST_F(WebRtcVideoChannel2Test, 2965 TEST_F(WebRtcVideoChannelTest,
2966 SetMaxSendBitrateCanIncreaseSimulcastSenderBitrate) { 2966 SetMaxSendBitrateCanIncreaseSimulcastSenderBitrate) {
2967 cricket::VideoSendParameters parameters; 2967 cricket::VideoSendParameters parameters;
2968 parameters.codecs.push_back(GetEngineCodec("VP8")); 2968 parameters.codecs.push_back(GetEngineCodec("VP8"));
2969 ASSERT_TRUE(channel_->SetSendParameters(parameters)); 2969 ASSERT_TRUE(channel_->SetSendParameters(parameters));
2970 channel_->SetSend(true); 2970 channel_->SetSend(true);
2971 2971
2972 FakeVideoSendStream* stream = AddSendStream( 2972 FakeVideoSendStream* stream = AddSendStream(
2973 cricket::CreateSimStreamParams("cname", MAKE_VECTOR(kSsrcs3))); 2973 cricket::CreateSimStreamParams("cname", MAKE_VECTOR(kSsrcs3)));
2974 2974
2975 // Send a frame to make sure this scales up to >1 stream (simulcast). 2975 // Send a frame to make sure this scales up to >1 stream (simulcast).
(...skipping 13 matching lines...) Expand all
2989 EXPECT_TRUE(channel_->SetSendParameters(parameters)); 2989 EXPECT_TRUE(channel_->SetSendParameters(parameters));
2990 // Insert a frame to update the encoder config. 2990 // Insert a frame to update the encoder config.
2991 EXPECT_TRUE(capturer.CaptureFrame()); 2991 EXPECT_TRUE(capturer.CaptureFrame());
2992 streams = stream->GetVideoStreams(); 2992 streams = stream->GetVideoStreams();
2993 int increased_max_bitrate_bps = GetTotalMaxBitrateBps(streams); 2993 int increased_max_bitrate_bps = GetTotalMaxBitrateBps(streams);
2994 EXPECT_EQ(initial_max_bitrate_bps * 2, increased_max_bitrate_bps); 2994 EXPECT_EQ(initial_max_bitrate_bps * 2, increased_max_bitrate_bps);
2995 2995
2996 EXPECT_TRUE(channel_->SetVideoSend(kSsrcs3[0], true, nullptr, nullptr)); 2996 EXPECT_TRUE(channel_->SetVideoSend(kSsrcs3[0], true, nullptr, nullptr));
2997 } 2997 }
2998 2998
2999 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithMaxQuantization) { 2999 TEST_F(WebRtcVideoChannelTest, SetSendCodecsWithMaxQuantization) {
3000 static const char* kMaxQuantization = "21"; 3000 static const char* kMaxQuantization = "21";
3001 cricket::VideoSendParameters parameters; 3001 cricket::VideoSendParameters parameters;
3002 parameters.codecs.push_back(GetEngineCodec("VP8")); 3002 parameters.codecs.push_back(GetEngineCodec("VP8"));
3003 parameters.codecs[0].params[kCodecParamMaxQuantization] = kMaxQuantization; 3003 parameters.codecs[0].params[kCodecParamMaxQuantization] = kMaxQuantization;
3004 EXPECT_TRUE(channel_->SetSendParameters(parameters)); 3004 EXPECT_TRUE(channel_->SetSendParameters(parameters));
3005 EXPECT_EQ(static_cast<unsigned int>(atoi(kMaxQuantization)), 3005 EXPECT_EQ(static_cast<unsigned int>(atoi(kMaxQuantization)),
3006 AddSendStream()->GetVideoStreams().back().max_qp); 3006 AddSendStream()->GetVideoStreams().back().max_qp);
3007 3007
3008 VideoCodec codec; 3008 VideoCodec codec;
3009 EXPECT_TRUE(channel_->GetSendCodec(&codec)); 3009 EXPECT_TRUE(channel_->GetSendCodec(&codec));
3010 EXPECT_EQ(kMaxQuantization, codec.params[kCodecParamMaxQuantization]); 3010 EXPECT_EQ(kMaxQuantization, codec.params[kCodecParamMaxQuantization]);
3011 } 3011 }
3012 3012
3013 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsRejectBadPayloadTypes) { 3013 TEST_F(WebRtcVideoChannelTest, SetSendCodecsRejectBadPayloadTypes) {
3014 // TODO(pbos): Should we only allow the dynamic range? 3014 // TODO(pbos): Should we only allow the dynamic range?
3015 static const int kIncorrectPayloads[] = {-2, -1, 128, 129}; 3015 static const int kIncorrectPayloads[] = {-2, -1, 128, 129};
3016 cricket::VideoSendParameters parameters; 3016 cricket::VideoSendParameters parameters;
3017 parameters.codecs.push_back(GetEngineCodec("VP8")); 3017 parameters.codecs.push_back(GetEngineCodec("VP8"));
3018 for (size_t i = 0; i < arraysize(kIncorrectPayloads); ++i) { 3018 for (size_t i = 0; i < arraysize(kIncorrectPayloads); ++i) {
3019 parameters.codecs[0].id = kIncorrectPayloads[i]; 3019 parameters.codecs[0].id = kIncorrectPayloads[i];
3020 EXPECT_FALSE(channel_->SetSendParameters(parameters)) 3020 EXPECT_FALSE(channel_->SetSendParameters(parameters))
3021 << "Bad payload type '" << kIncorrectPayloads[i] << "' accepted."; 3021 << "Bad payload type '" << kIncorrectPayloads[i] << "' accepted.";
3022 } 3022 }
3023 } 3023 }
3024 3024
3025 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsAcceptAllValidPayloadTypes) { 3025 TEST_F(WebRtcVideoChannelTest, SetSendCodecsAcceptAllValidPayloadTypes) {
3026 cricket::VideoSendParameters parameters; 3026 cricket::VideoSendParameters parameters;
3027 parameters.codecs.push_back(GetEngineCodec("VP8")); 3027 parameters.codecs.push_back(GetEngineCodec("VP8"));
3028 for (int payload_type = 96; payload_type <= 127; ++payload_type) { 3028 for (int payload_type = 96; payload_type <= 127; ++payload_type) {
3029 parameters.codecs[0].id = payload_type; 3029 parameters.codecs[0].id = payload_type;
3030 EXPECT_TRUE(channel_->SetSendParameters(parameters)) 3030 EXPECT_TRUE(channel_->SetSendParameters(parameters))
3031 << "Payload type '" << payload_type << "' rejected."; 3031 << "Payload type '" << payload_type << "' rejected.";
3032 } 3032 }
3033 } 3033 }
3034 3034
3035 // Test that setting the a different set of codecs but with an identical front 3035 // Test that setting the a different set of codecs but with an identical front
3036 // codec doesn't result in the stream being recreated. 3036 // codec doesn't result in the stream being recreated.
3037 // This may happen when a subsequent negotiation includes fewer codecs, as a 3037 // This may happen when a subsequent negotiation includes fewer codecs, as a
3038 // result of one of the codecs being rejected. 3038 // result of one of the codecs being rejected.
3039 TEST_F(WebRtcVideoChannel2Test, 3039 TEST_F(WebRtcVideoChannelTest,
3040 SetSendCodecsIdenticalFirstCodecDoesntRecreateStream) { 3040 SetSendCodecsIdenticalFirstCodecDoesntRecreateStream) {
3041 cricket::VideoSendParameters parameters1; 3041 cricket::VideoSendParameters parameters1;
3042 parameters1.codecs.push_back(GetEngineCodec("VP8")); 3042 parameters1.codecs.push_back(GetEngineCodec("VP8"));
3043 parameters1.codecs.push_back(GetEngineCodec("VP9")); 3043 parameters1.codecs.push_back(GetEngineCodec("VP9"));
3044 EXPECT_TRUE(channel_->SetSendParameters(parameters1)); 3044 EXPECT_TRUE(channel_->SetSendParameters(parameters1));
3045 3045
3046 AddSendStream(); 3046 AddSendStream();
3047 EXPECT_EQ(1, fake_call_->GetNumCreatedSendStreams()); 3047 EXPECT_EQ(1, fake_call_->GetNumCreatedSendStreams());
3048 3048
3049 cricket::VideoSendParameters parameters2; 3049 cricket::VideoSendParameters parameters2;
3050 parameters2.codecs.push_back(GetEngineCodec("VP8")); 3050 parameters2.codecs.push_back(GetEngineCodec("VP8"));
3051 EXPECT_TRUE(channel_->SetSendParameters(parameters2)); 3051 EXPECT_TRUE(channel_->SetSendParameters(parameters2));
3052 EXPECT_EQ(1, fake_call_->GetNumCreatedSendStreams()); 3052 EXPECT_EQ(1, fake_call_->GetNumCreatedSendStreams());
3053 } 3053 }
3054 3054
3055 TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsWithOnlyVp8) { 3055 TEST_F(WebRtcVideoChannelTest, SetRecvCodecsWithOnlyVp8) {
3056 cricket::VideoRecvParameters parameters; 3056 cricket::VideoRecvParameters parameters;
3057 parameters.codecs.push_back(GetEngineCodec("VP8")); 3057 parameters.codecs.push_back(GetEngineCodec("VP8"));
3058 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); 3058 EXPECT_TRUE(channel_->SetRecvParameters(parameters));
3059 } 3059 }
3060 3060
3061 // Test that we set our inbound RTX codecs properly. 3061 // Test that we set our inbound RTX codecs properly.
3062 TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsWithRtx) { 3062 TEST_F(WebRtcVideoChannelTest, SetRecvCodecsWithRtx) {
3063 const int kUnusedPayloadType1 = 126; 3063 const int kUnusedPayloadType1 = 126;
3064 const int kUnusedPayloadType2 = 127; 3064 const int kUnusedPayloadType2 = 127;
3065 EXPECT_FALSE(FindCodecById(engine_.codecs(), kUnusedPayloadType1)); 3065 EXPECT_FALSE(FindCodecById(engine_.codecs(), kUnusedPayloadType1));
3066 EXPECT_FALSE(FindCodecById(engine_.codecs(), kUnusedPayloadType2)); 3066 EXPECT_FALSE(FindCodecById(engine_.codecs(), kUnusedPayloadType2));
3067 3067
3068 cricket::VideoRecvParameters parameters; 3068 cricket::VideoRecvParameters parameters;
3069 parameters.codecs.push_back(GetEngineCodec("VP8")); 3069 parameters.codecs.push_back(GetEngineCodec("VP8"));
3070 cricket::VideoCodec rtx_codec(kUnusedPayloadType1, "rtx"); 3070 cricket::VideoCodec rtx_codec(kUnusedPayloadType1, "rtx");
3071 parameters.codecs.push_back(rtx_codec); 3071 parameters.codecs.push_back(rtx_codec);
3072 EXPECT_FALSE(channel_->SetRecvParameters(parameters)) 3072 EXPECT_FALSE(channel_->SetRecvParameters(parameters))
3073 << "RTX codec without associated payload should be rejected."; 3073 << "RTX codec without associated payload should be rejected.";
3074 3074
3075 parameters.codecs[1].SetParam("apt", kUnusedPayloadType2); 3075 parameters.codecs[1].SetParam("apt", kUnusedPayloadType2);
3076 EXPECT_FALSE(channel_->SetRecvParameters(parameters)) 3076 EXPECT_FALSE(channel_->SetRecvParameters(parameters))
3077 << "RTX codec with invalid associated payload type should be rejected."; 3077 << "RTX codec with invalid associated payload type should be rejected.";
3078 3078
3079 parameters.codecs[1].SetParam("apt", GetEngineCodec("VP8").id); 3079 parameters.codecs[1].SetParam("apt", GetEngineCodec("VP8").id);
3080 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); 3080 EXPECT_TRUE(channel_->SetRecvParameters(parameters));
3081 3081
3082 cricket::VideoCodec rtx_codec2(kUnusedPayloadType2, "rtx"); 3082 cricket::VideoCodec rtx_codec2(kUnusedPayloadType2, "rtx");
3083 rtx_codec2.SetParam("apt", rtx_codec.id); 3083 rtx_codec2.SetParam("apt", rtx_codec.id);
3084 parameters.codecs.push_back(rtx_codec2); 3084 parameters.codecs.push_back(rtx_codec2);
3085 3085
3086 EXPECT_FALSE(channel_->SetRecvParameters(parameters)) << 3086 EXPECT_FALSE(channel_->SetRecvParameters(parameters)) <<
3087 "RTX codec with another RTX as associated payload type should be " 3087 "RTX codec with another RTX as associated payload type should be "
3088 "rejected."; 3088 "rejected.";
3089 } 3089 }
3090 3090
3091 TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsWithChangedRtxPayloadType) { 3091 TEST_F(WebRtcVideoChannelTest, SetRecvCodecsWithChangedRtxPayloadType) {
3092 const int kUnusedPayloadType1 = 126; 3092 const int kUnusedPayloadType1 = 126;
3093 const int kUnusedPayloadType2 = 127; 3093 const int kUnusedPayloadType2 = 127;
3094 EXPECT_FALSE(FindCodecById(engine_.codecs(), kUnusedPayloadType1)); 3094 EXPECT_FALSE(FindCodecById(engine_.codecs(), kUnusedPayloadType1));
3095 EXPECT_FALSE(FindCodecById(engine_.codecs(), kUnusedPayloadType2)); 3095 EXPECT_FALSE(FindCodecById(engine_.codecs(), kUnusedPayloadType2));
3096 3096
3097 // SSRCs for RTX. 3097 // SSRCs for RTX.
3098 cricket::StreamParams params = 3098 cricket::StreamParams params =
3099 cricket::StreamParams::CreateLegacy(kSsrcs1[0]); 3099 cricket::StreamParams::CreateLegacy(kSsrcs1[0]);
3100 params.AddFidSsrc(kSsrcs1[0], kRtxSsrcs1[0]); 3100 params.AddFidSsrc(kSsrcs1[0], kRtxSsrcs1[0]);
3101 AddRecvStream(params); 3101 AddRecvStream(params);
(...skipping 22 matching lines...) Expand all
3124 const webrtc::VideoReceiveStream::Config& config_after = 3124 const webrtc::VideoReceiveStream::Config& config_after =
3125 fake_call_->GetVideoReceiveStreams()[0]->GetConfig(); 3125 fake_call_->GetVideoReceiveStreams()[0]->GetConfig();
3126 EXPECT_EQ(1U, config_after.rtp.rtx_payload_types.size()); 3126 EXPECT_EQ(1U, config_after.rtp.rtx_payload_types.size());
3127 auto it_after = 3127 auto it_after =
3128 config_after.rtp.rtx_payload_types.find(GetEngineCodec("VP8").id); 3128 config_after.rtp.rtx_payload_types.find(GetEngineCodec("VP8").id);
3129 ASSERT_NE(it_after, config_after.rtp.rtx_payload_types.end()); 3129 ASSERT_NE(it_after, config_after.rtp.rtx_payload_types.end());
3130 EXPECT_EQ(kUnusedPayloadType2, it_after->second); 3130 EXPECT_EQ(kUnusedPayloadType2, it_after->second);
3131 EXPECT_EQ(kRtxSsrcs1[0], config_after.rtp.rtx_ssrc); 3131 EXPECT_EQ(kRtxSsrcs1[0], config_after.rtp.rtx_ssrc);
3132 } 3132 }
3133 3133
3134 TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsDifferentPayloadType) { 3134 TEST_F(WebRtcVideoChannelTest, SetRecvCodecsDifferentPayloadType) {
3135 cricket::VideoRecvParameters parameters; 3135 cricket::VideoRecvParameters parameters;
3136 parameters.codecs.push_back(GetEngineCodec("VP8")); 3136 parameters.codecs.push_back(GetEngineCodec("VP8"));
3137 parameters.codecs[0].id = 99; 3137 parameters.codecs[0].id = 99;
3138 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); 3138 EXPECT_TRUE(channel_->SetRecvParameters(parameters));
3139 } 3139 }
3140 3140
3141 TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsAcceptDefaultCodecs) { 3141 TEST_F(WebRtcVideoChannelTest, SetRecvCodecsAcceptDefaultCodecs) {
3142 cricket::VideoRecvParameters parameters; 3142 cricket::VideoRecvParameters parameters;
3143 parameters.codecs = engine_.codecs(); 3143 parameters.codecs = engine_.codecs();
3144 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); 3144 EXPECT_TRUE(channel_->SetRecvParameters(parameters));
3145 3145
3146 FakeVideoReceiveStream* stream = AddRecvStream(); 3146 FakeVideoReceiveStream* stream = AddRecvStream();
3147 const webrtc::VideoReceiveStream::Config& config = stream->GetConfig(); 3147 const webrtc::VideoReceiveStream::Config& config = stream->GetConfig();
3148 EXPECT_EQ(engine_.codecs()[0].name, config.decoders[0].payload_name); 3148 EXPECT_EQ(engine_.codecs()[0].name, config.decoders[0].payload_name);
3149 EXPECT_EQ(engine_.codecs()[0].id, config.decoders[0].payload_type); 3149 EXPECT_EQ(engine_.codecs()[0].id, config.decoders[0].payload_type);
3150 } 3150 }
3151 3151
3152 TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsRejectUnsupportedCodec) { 3152 TEST_F(WebRtcVideoChannelTest, SetRecvCodecsRejectUnsupportedCodec) {
3153 cricket::VideoRecvParameters parameters; 3153 cricket::VideoRecvParameters parameters;
3154 parameters.codecs.push_back(GetEngineCodec("VP8")); 3154 parameters.codecs.push_back(GetEngineCodec("VP8"));
3155 parameters.codecs.push_back(VideoCodec(101, "WTF3")); 3155 parameters.codecs.push_back(VideoCodec(101, "WTF3"));
3156 EXPECT_FALSE(channel_->SetRecvParameters(parameters)); 3156 EXPECT_FALSE(channel_->SetRecvParameters(parameters));
3157 } 3157 }
3158 3158
3159 TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsAcceptsMultipleVideoCodecs) { 3159 TEST_F(WebRtcVideoChannelTest, SetRecvCodecsAcceptsMultipleVideoCodecs) {
3160 cricket::VideoRecvParameters parameters; 3160 cricket::VideoRecvParameters parameters;
3161 parameters.codecs.push_back(GetEngineCodec("VP8")); 3161 parameters.codecs.push_back(GetEngineCodec("VP8"));
3162 parameters.codecs.push_back(GetEngineCodec("VP9")); 3162 parameters.codecs.push_back(GetEngineCodec("VP9"));
3163 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); 3163 EXPECT_TRUE(channel_->SetRecvParameters(parameters));
3164 } 3164 }
3165 3165
3166 TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsWithoutFecDisablesFec) { 3166 TEST_F(WebRtcVideoChannelTest, SetRecvCodecsWithoutFecDisablesFec) {
3167 cricket::VideoSendParameters send_parameters; 3167 cricket::VideoSendParameters send_parameters;
3168 send_parameters.codecs.push_back(GetEngineCodec("VP8")); 3168 send_parameters.codecs.push_back(GetEngineCodec("VP8"));
3169 send_parameters.codecs.push_back(GetEngineCodec("red")); 3169 send_parameters.codecs.push_back(GetEngineCodec("red"));
3170 send_parameters.codecs.push_back(GetEngineCodec("ulpfec")); 3170 send_parameters.codecs.push_back(GetEngineCodec("ulpfec"));
3171 ASSERT_TRUE(channel_->SetSendParameters(send_parameters)); 3171 ASSERT_TRUE(channel_->SetSendParameters(send_parameters));
3172 3172
3173 FakeVideoReceiveStream* stream = AddRecvStream(); 3173 FakeVideoReceiveStream* stream = AddRecvStream();
3174 3174
3175 EXPECT_EQ(GetEngineCodec("ulpfec").id, 3175 EXPECT_EQ(GetEngineCodec("ulpfec").id,
3176 stream->GetConfig().rtp.ulpfec.ulpfec_payload_type); 3176 stream->GetConfig().rtp.ulpfec.ulpfec_payload_type);
3177 3177
3178 cricket::VideoRecvParameters recv_parameters; 3178 cricket::VideoRecvParameters recv_parameters;
3179 recv_parameters.codecs.push_back(GetEngineCodec("VP8")); 3179 recv_parameters.codecs.push_back(GetEngineCodec("VP8"));
3180 ASSERT_TRUE(channel_->SetRecvParameters(recv_parameters)); 3180 ASSERT_TRUE(channel_->SetRecvParameters(recv_parameters));
3181 stream = fake_call_->GetVideoReceiveStreams()[0]; 3181 stream = fake_call_->GetVideoReceiveStreams()[0];
3182 ASSERT_TRUE(stream != nullptr); 3182 ASSERT_TRUE(stream != nullptr);
3183 EXPECT_EQ(-1, stream->GetConfig().rtp.ulpfec.ulpfec_payload_type) 3183 EXPECT_EQ(-1, stream->GetConfig().rtp.ulpfec.ulpfec_payload_type)
3184 << "SetSendCodec without ULPFEC should disable current ULPFEC."; 3184 << "SetSendCodec without ULPFEC should disable current ULPFEC.";
3185 } 3185 }
3186 3186
3187 TEST_F(WebRtcVideoChannel2FlexfecRecvTest, SetRecvParamsWithoutFecDisablesFec) { 3187 TEST_F(WebRtcVideoChannelFlexfecRecvTest, SetRecvParamsWithoutFecDisablesFec) {
3188 AddRecvStream( 3188 AddRecvStream(
3189 CreatePrimaryWithFecFrStreamParams("cname", kSsrcs1[0], kFlexfecSsrc)); 3189 CreatePrimaryWithFecFrStreamParams("cname", kSsrcs1[0], kFlexfecSsrc));
3190 const std::vector<FakeFlexfecReceiveStream*>& streams = 3190 const std::vector<FakeFlexfecReceiveStream*>& streams =
3191 fake_call_->GetFlexfecReceiveStreams(); 3191 fake_call_->GetFlexfecReceiveStreams();
3192 3192
3193 ASSERT_EQ(1U, streams.size()); 3193 ASSERT_EQ(1U, streams.size());
3194 const FakeFlexfecReceiveStream* stream = streams.front(); 3194 const FakeFlexfecReceiveStream* stream = streams.front();
3195 EXPECT_EQ(GetEngineCodec("flexfec-03").id, stream->GetConfig().payload_type); 3195 EXPECT_EQ(GetEngineCodec("flexfec-03").id, stream->GetConfig().payload_type);
3196 EXPECT_EQ(kFlexfecSsrc, stream->GetConfig().remote_ssrc); 3196 EXPECT_EQ(kFlexfecSsrc, stream->GetConfig().remote_ssrc);
3197 ASSERT_EQ(1U, stream->GetConfig().protected_media_ssrcs.size()); 3197 ASSERT_EQ(1U, stream->GetConfig().protected_media_ssrcs.size());
3198 EXPECT_EQ(kSsrcs1[0], stream->GetConfig().protected_media_ssrcs[0]); 3198 EXPECT_EQ(kSsrcs1[0], stream->GetConfig().protected_media_ssrcs[0]);
3199 3199
3200 cricket::VideoRecvParameters recv_parameters; 3200 cricket::VideoRecvParameters recv_parameters;
3201 recv_parameters.codecs.push_back(GetEngineCodec("VP8")); 3201 recv_parameters.codecs.push_back(GetEngineCodec("VP8"));
3202 ASSERT_TRUE(channel_->SetRecvParameters(recv_parameters)); 3202 ASSERT_TRUE(channel_->SetRecvParameters(recv_parameters));
3203 EXPECT_TRUE(streams.empty()) 3203 EXPECT_TRUE(streams.empty())
3204 << "SetSendCodec without FlexFEC should disable current FlexFEC."; 3204 << "SetSendCodec without FlexFEC should disable current FlexFEC.";
3205 } 3205 }
3206 3206
3207 TEST_F(WebRtcVideoChannel2Test, SetSendParamsWithFecEnablesFec) { 3207 TEST_F(WebRtcVideoChannelTest, SetSendParamsWithFecEnablesFec) {
3208 FakeVideoReceiveStream* stream = AddRecvStream(); 3208 FakeVideoReceiveStream* stream = AddRecvStream();
3209 EXPECT_EQ(GetEngineCodec("ulpfec").id, 3209 EXPECT_EQ(GetEngineCodec("ulpfec").id,
3210 stream->GetConfig().rtp.ulpfec.ulpfec_payload_type); 3210 stream->GetConfig().rtp.ulpfec.ulpfec_payload_type);
3211 3211
3212 cricket::VideoRecvParameters recv_parameters; 3212 cricket::VideoRecvParameters recv_parameters;
3213 recv_parameters.codecs.push_back(GetEngineCodec("VP8")); 3213 recv_parameters.codecs.push_back(GetEngineCodec("VP8"));
3214 recv_parameters.codecs.push_back(GetEngineCodec("red")); 3214 recv_parameters.codecs.push_back(GetEngineCodec("red"));
3215 recv_parameters.codecs.push_back(GetEngineCodec("ulpfec")); 3215 recv_parameters.codecs.push_back(GetEngineCodec("ulpfec"));
3216 ASSERT_TRUE(channel_->SetRecvParameters(recv_parameters)); 3216 ASSERT_TRUE(channel_->SetRecvParameters(recv_parameters));
3217 stream = fake_call_->GetVideoReceiveStreams()[0]; 3217 stream = fake_call_->GetVideoReceiveStreams()[0];
3218 ASSERT_TRUE(stream != nullptr); 3218 ASSERT_TRUE(stream != nullptr);
3219 EXPECT_EQ(GetEngineCodec("ulpfec").id, 3219 EXPECT_EQ(GetEngineCodec("ulpfec").id,
3220 stream->GetConfig().rtp.ulpfec.ulpfec_payload_type) 3220 stream->GetConfig().rtp.ulpfec.ulpfec_payload_type)
3221 << "ULPFEC should be enabled on the receive stream."; 3221 << "ULPFEC should be enabled on the receive stream.";
3222 3222
3223 cricket::VideoSendParameters send_parameters; 3223 cricket::VideoSendParameters send_parameters;
3224 send_parameters.codecs.push_back(GetEngineCodec("VP8")); 3224 send_parameters.codecs.push_back(GetEngineCodec("VP8"));
3225 send_parameters.codecs.push_back(GetEngineCodec("red")); 3225 send_parameters.codecs.push_back(GetEngineCodec("red"));
3226 send_parameters.codecs.push_back(GetEngineCodec("ulpfec")); 3226 send_parameters.codecs.push_back(GetEngineCodec("ulpfec"));
3227 ASSERT_TRUE(channel_->SetSendParameters(send_parameters)); 3227 ASSERT_TRUE(channel_->SetSendParameters(send_parameters));
3228 stream = fake_call_->GetVideoReceiveStreams()[0]; 3228 stream = fake_call_->GetVideoReceiveStreams()[0];
3229 EXPECT_EQ(GetEngineCodec("ulpfec").id, 3229 EXPECT_EQ(GetEngineCodec("ulpfec").id,
3230 stream->GetConfig().rtp.ulpfec.ulpfec_payload_type) 3230 stream->GetConfig().rtp.ulpfec.ulpfec_payload_type)
3231 << "ULPFEC should be enabled on the receive stream."; 3231 << "ULPFEC should be enabled on the receive stream.";
3232 } 3232 }
3233 3233
3234 TEST_F(WebRtcVideoChannel2FlexfecSendRecvTest, 3234 TEST_F(WebRtcVideoChannelFlexfecSendRecvTest,
3235 SetSendRecvParamsWithFecEnablesFec) { 3235 SetSendRecvParamsWithFecEnablesFec) {
3236 AddRecvStream( 3236 AddRecvStream(
3237 CreatePrimaryWithFecFrStreamParams("cname", kSsrcs1[0], kFlexfecSsrc)); 3237 CreatePrimaryWithFecFrStreamParams("cname", kSsrcs1[0], kFlexfecSsrc));
3238 const std::vector<FakeFlexfecReceiveStream*>& streams = 3238 const std::vector<FakeFlexfecReceiveStream*>& streams =
3239 fake_call_->GetFlexfecReceiveStreams(); 3239 fake_call_->GetFlexfecReceiveStreams();
3240 3240
3241 cricket::VideoRecvParameters recv_parameters; 3241 cricket::VideoRecvParameters recv_parameters;
3242 recv_parameters.codecs.push_back(GetEngineCodec("VP8")); 3242 recv_parameters.codecs.push_back(GetEngineCodec("VP8"));
3243 recv_parameters.codecs.push_back(GetEngineCodec("flexfec-03")); 3243 recv_parameters.codecs.push_back(GetEngineCodec("flexfec-03"));
3244 ASSERT_TRUE(channel_->SetRecvParameters(recv_parameters)); 3244 ASSERT_TRUE(channel_->SetRecvParameters(recv_parameters));
(...skipping 15 matching lines...) Expand all
3260 const FakeFlexfecReceiveStream* stream_with_send_params = streams.front(); 3260 const FakeFlexfecReceiveStream* stream_with_send_params = streams.front();
3261 EXPECT_EQ(GetEngineCodec("flexfec-03").id, 3261 EXPECT_EQ(GetEngineCodec("flexfec-03").id,
3262 stream_with_send_params->GetConfig().payload_type); 3262 stream_with_send_params->GetConfig().payload_type);
3263 EXPECT_EQ(kFlexfecSsrc, stream_with_send_params->GetConfig().remote_ssrc); 3263 EXPECT_EQ(kFlexfecSsrc, stream_with_send_params->GetConfig().remote_ssrc);
3264 EXPECT_EQ(1U, 3264 EXPECT_EQ(1U,
3265 stream_with_send_params->GetConfig().protected_media_ssrcs.size()); 3265 stream_with_send_params->GetConfig().protected_media_ssrcs.size());
3266 EXPECT_EQ(kSsrcs1[0], 3266 EXPECT_EQ(kSsrcs1[0],
3267 stream_with_send_params->GetConfig().protected_media_ssrcs[0]); 3267 stream_with_send_params->GetConfig().protected_media_ssrcs[0]);
3268 } 3268 }
3269 3269
3270 TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsRejectDuplicateFecPayloads) { 3270 TEST_F(WebRtcVideoChannelTest, SetRecvCodecsRejectDuplicateFecPayloads) {
3271 cricket::VideoRecvParameters parameters; 3271 cricket::VideoRecvParameters parameters;
3272 parameters.codecs.push_back(GetEngineCodec("VP8")); 3272 parameters.codecs.push_back(GetEngineCodec("VP8"));
3273 parameters.codecs.push_back(GetEngineCodec("red")); 3273 parameters.codecs.push_back(GetEngineCodec("red"));
3274 parameters.codecs[1].id = parameters.codecs[0].id; 3274 parameters.codecs[1].id = parameters.codecs[0].id;
3275 EXPECT_FALSE(channel_->SetRecvParameters(parameters)); 3275 EXPECT_FALSE(channel_->SetRecvParameters(parameters));
3276 } 3276 }
3277 3277
3278 TEST_F(WebRtcVideoChannel2FlexfecRecvTest, 3278 TEST_F(WebRtcVideoChannelFlexfecRecvTest,
3279 SetRecvCodecsRejectDuplicateFecPayloads) { 3279 SetRecvCodecsRejectDuplicateFecPayloads) {
3280 cricket::VideoRecvParameters parameters; 3280 cricket::VideoRecvParameters parameters;
3281 parameters.codecs.push_back(GetEngineCodec("VP8")); 3281 parameters.codecs.push_back(GetEngineCodec("VP8"));
3282 parameters.codecs.push_back(GetEngineCodec("flexfec-03")); 3282 parameters.codecs.push_back(GetEngineCodec("flexfec-03"));
3283 parameters.codecs[1].id = parameters.codecs[0].id; 3283 parameters.codecs[1].id = parameters.codecs[0].id;
3284 EXPECT_FALSE(channel_->SetRecvParameters(parameters)); 3284 EXPECT_FALSE(channel_->SetRecvParameters(parameters));
3285 } 3285 }
3286 3286
3287 TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsRejectDuplicateCodecPayloads) { 3287 TEST_F(WebRtcVideoChannelTest, SetRecvCodecsRejectDuplicateCodecPayloads) {
3288 cricket::VideoRecvParameters parameters; 3288 cricket::VideoRecvParameters parameters;
3289 parameters.codecs.push_back(GetEngineCodec("VP8")); 3289 parameters.codecs.push_back(GetEngineCodec("VP8"));
3290 parameters.codecs.push_back(GetEngineCodec("VP9")); 3290 parameters.codecs.push_back(GetEngineCodec("VP9"));
3291 parameters.codecs[1].id = parameters.codecs[0].id; 3291 parameters.codecs[1].id = parameters.codecs[0].id;
3292 EXPECT_FALSE(channel_->SetRecvParameters(parameters)); 3292 EXPECT_FALSE(channel_->SetRecvParameters(parameters));
3293 } 3293 }
3294 3294
3295 TEST_F(WebRtcVideoChannel2Test, 3295 TEST_F(WebRtcVideoChannelTest,
3296 SetRecvCodecsAcceptSameCodecOnMultiplePayloadTypes) { 3296 SetRecvCodecsAcceptSameCodecOnMultiplePayloadTypes) {
3297 cricket::VideoRecvParameters parameters; 3297 cricket::VideoRecvParameters parameters;
3298 parameters.codecs.push_back(GetEngineCodec("VP8")); 3298 parameters.codecs.push_back(GetEngineCodec("VP8"));
3299 parameters.codecs.push_back(GetEngineCodec("VP8")); 3299 parameters.codecs.push_back(GetEngineCodec("VP8"));
3300 parameters.codecs[1].id += 1; 3300 parameters.codecs[1].id += 1;
3301 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); 3301 EXPECT_TRUE(channel_->SetRecvParameters(parameters));
3302 } 3302 }
3303 3303
3304 // Test that setting the same codecs but with a different order 3304 // Test that setting the same codecs but with a different order
3305 // doesn't result in the stream being recreated. 3305 // doesn't result in the stream being recreated.
3306 TEST_F(WebRtcVideoChannel2Test, 3306 TEST_F(WebRtcVideoChannelTest,
3307 SetRecvCodecsDifferentOrderDoesntRecreateStream) { 3307 SetRecvCodecsDifferentOrderDoesntRecreateStream) {
3308 cricket::VideoRecvParameters parameters1; 3308 cricket::VideoRecvParameters parameters1;
3309 parameters1.codecs.push_back(GetEngineCodec("VP8")); 3309 parameters1.codecs.push_back(GetEngineCodec("VP8"));
3310 parameters1.codecs.push_back(GetEngineCodec("red")); 3310 parameters1.codecs.push_back(GetEngineCodec("red"));
3311 EXPECT_TRUE(channel_->SetRecvParameters(parameters1)); 3311 EXPECT_TRUE(channel_->SetRecvParameters(parameters1));
3312 3312
3313 AddRecvStream(cricket::StreamParams::CreateLegacy(123)); 3313 AddRecvStream(cricket::StreamParams::CreateLegacy(123));
3314 EXPECT_EQ(1, fake_call_->GetNumCreatedReceiveStreams()); 3314 EXPECT_EQ(1, fake_call_->GetNumCreatedReceiveStreams());
3315 3315
3316 cricket::VideoRecvParameters parameters2; 3316 cricket::VideoRecvParameters parameters2;
3317 parameters2.codecs.push_back(GetEngineCodec("red")); 3317 parameters2.codecs.push_back(GetEngineCodec("red"));
3318 parameters2.codecs.push_back(GetEngineCodec("VP8")); 3318 parameters2.codecs.push_back(GetEngineCodec("VP8"));
3319 EXPECT_TRUE(channel_->SetRecvParameters(parameters2)); 3319 EXPECT_TRUE(channel_->SetRecvParameters(parameters2));
3320 EXPECT_EQ(1, fake_call_->GetNumCreatedReceiveStreams()); 3320 EXPECT_EQ(1, fake_call_->GetNumCreatedReceiveStreams());
3321 } 3321 }
3322 3322
3323 TEST_F(WebRtcVideoChannel2Test, SendStreamNotSendingByDefault) { 3323 TEST_F(WebRtcVideoChannelTest, SendStreamNotSendingByDefault) {
3324 EXPECT_FALSE(AddSendStream()->IsSending()); 3324 EXPECT_FALSE(AddSendStream()->IsSending());
3325 } 3325 }
3326 3326
3327 TEST_F(WebRtcVideoChannel2Test, ReceiveStreamReceivingByDefault) { 3327 TEST_F(WebRtcVideoChannelTest, ReceiveStreamReceivingByDefault) {
3328 EXPECT_TRUE(AddRecvStream()->IsReceiving()); 3328 EXPECT_TRUE(AddRecvStream()->IsReceiving());
3329 } 3329 }
3330 3330
3331 TEST_F(WebRtcVideoChannel2Test, SetSend) { 3331 TEST_F(WebRtcVideoChannelTest, SetSend) {
3332 FakeVideoSendStream* stream = AddSendStream(); 3332 FakeVideoSendStream* stream = AddSendStream();
3333 EXPECT_FALSE(stream->IsSending()); 3333 EXPECT_FALSE(stream->IsSending());
3334 3334
3335 // false->true 3335 // false->true
3336 EXPECT_TRUE(channel_->SetSend(true)); 3336 EXPECT_TRUE(channel_->SetSend(true));
3337 EXPECT_TRUE(stream->IsSending()); 3337 EXPECT_TRUE(stream->IsSending());
3338 // true->true 3338 // true->true
3339 EXPECT_TRUE(channel_->SetSend(true)); 3339 EXPECT_TRUE(channel_->SetSend(true));
3340 EXPECT_TRUE(stream->IsSending()); 3340 EXPECT_TRUE(stream->IsSending());
3341 // true->false 3341 // true->false
3342 EXPECT_TRUE(channel_->SetSend(false)); 3342 EXPECT_TRUE(channel_->SetSend(false));
3343 EXPECT_FALSE(stream->IsSending()); 3343 EXPECT_FALSE(stream->IsSending());
3344 // false->false 3344 // false->false
3345 EXPECT_TRUE(channel_->SetSend(false)); 3345 EXPECT_TRUE(channel_->SetSend(false));
3346 EXPECT_FALSE(stream->IsSending()); 3346 EXPECT_FALSE(stream->IsSending());
3347 3347
3348 EXPECT_TRUE(channel_->SetSend(true)); 3348 EXPECT_TRUE(channel_->SetSend(true));
3349 FakeVideoSendStream* new_stream = AddSendStream(); 3349 FakeVideoSendStream* new_stream = AddSendStream();
3350 EXPECT_TRUE(new_stream->IsSending()) 3350 EXPECT_TRUE(new_stream->IsSending())
3351 << "Send stream created after SetSend(true) not sending initially."; 3351 << "Send stream created after SetSend(true) not sending initially.";
3352 } 3352 }
3353 3353
3354 // This test verifies DSCP settings are properly applied on video media channel. 3354 // This test verifies DSCP settings are properly applied on video media channel.
3355 TEST_F(WebRtcVideoChannel2Test, TestSetDscpOptions) { 3355 TEST_F(WebRtcVideoChannelTest, TestSetDscpOptions) {
3356 std::unique_ptr<cricket::FakeNetworkInterface> network_interface( 3356 std::unique_ptr<cricket::FakeNetworkInterface> network_interface(
3357 new cricket::FakeNetworkInterface); 3357 new cricket::FakeNetworkInterface);
3358 MediaConfig config; 3358 MediaConfig config;
3359 std::unique_ptr<VideoMediaChannel> channel; 3359 std::unique_ptr<VideoMediaChannel> channel;
3360 3360
3361 channel.reset(engine_.CreateChannel(call_.get(), config, VideoOptions())); 3361 channel.reset(engine_.CreateChannel(call_.get(), config, VideoOptions()));
3362 channel->SetInterface(network_interface.get()); 3362 channel->SetInterface(network_interface.get());
3363 // Default value when DSCP is disabled should be DSCP_DEFAULT. 3363 // Default value when DSCP is disabled should be DSCP_DEFAULT.
3364 EXPECT_EQ(rtc::DSCP_DEFAULT, network_interface->dscp()); 3364 EXPECT_EQ(rtc::DSCP_DEFAULT, network_interface->dscp());
3365 3365
3366 config.enable_dscp = true; 3366 config.enable_dscp = true;
3367 channel.reset(engine_.CreateChannel(call_.get(), config, VideoOptions())); 3367 channel.reset(engine_.CreateChannel(call_.get(), config, VideoOptions()));
3368 channel->SetInterface(network_interface.get()); 3368 channel->SetInterface(network_interface.get());
3369 EXPECT_EQ(rtc::DSCP_AF41, network_interface->dscp()); 3369 EXPECT_EQ(rtc::DSCP_AF41, network_interface->dscp());
3370 3370
3371 // Verify that setting the option to false resets the 3371 // Verify that setting the option to false resets the
3372 // DiffServCodePoint. 3372 // DiffServCodePoint.
3373 config.enable_dscp = false; 3373 config.enable_dscp = false;
3374 channel.reset(engine_.CreateChannel(call_.get(), config, VideoOptions())); 3374 channel.reset(engine_.CreateChannel(call_.get(), config, VideoOptions()));
3375 channel->SetInterface(network_interface.get()); 3375 channel->SetInterface(network_interface.get());
3376 EXPECT_EQ(rtc::DSCP_DEFAULT, network_interface->dscp()); 3376 EXPECT_EQ(rtc::DSCP_DEFAULT, network_interface->dscp());
3377 } 3377 }
3378 3378
3379 // This test verifies that the RTCP reduced size mode is properly applied to 3379 // This test verifies that the RTCP reduced size mode is properly applied to
3380 // send video streams. 3380 // send video streams.
3381 TEST_F(WebRtcVideoChannel2Test, TestSetSendRtcpReducedSize) { 3381 TEST_F(WebRtcVideoChannelTest, TestSetSendRtcpReducedSize) {
3382 // Create stream, expecting that default mode is "compound". 3382 // Create stream, expecting that default mode is "compound".
3383 FakeVideoSendStream* stream1 = AddSendStream(); 3383 FakeVideoSendStream* stream1 = AddSendStream();
3384 EXPECT_EQ(webrtc::RtcpMode::kCompound, stream1->GetConfig().rtp.rtcp_mode); 3384 EXPECT_EQ(webrtc::RtcpMode::kCompound, stream1->GetConfig().rtp.rtcp_mode);
3385 3385
3386 // Now enable reduced size mode. 3386 // Now enable reduced size mode.
3387 send_parameters_.rtcp.reduced_size = true; 3387 send_parameters_.rtcp.reduced_size = true;
3388 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); 3388 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
3389 stream1 = fake_call_->GetVideoSendStreams()[0]; 3389 stream1 = fake_call_->GetVideoSendStreams()[0];
3390 EXPECT_EQ(webrtc::RtcpMode::kReducedSize, stream1->GetConfig().rtp.rtcp_mode); 3390 EXPECT_EQ(webrtc::RtcpMode::kReducedSize, stream1->GetConfig().rtp.rtcp_mode);
3391 3391
3392 // Create a new stream and ensure it picks up the reduced size mode. 3392 // Create a new stream and ensure it picks up the reduced size mode.
3393 FakeVideoSendStream* stream2 = AddSendStream(); 3393 FakeVideoSendStream* stream2 = AddSendStream();
3394 EXPECT_EQ(webrtc::RtcpMode::kReducedSize, stream2->GetConfig().rtp.rtcp_mode); 3394 EXPECT_EQ(webrtc::RtcpMode::kReducedSize, stream2->GetConfig().rtp.rtcp_mode);
3395 } 3395 }
3396 3396
3397 // This test verifies that the RTCP reduced size mode is properly applied to 3397 // This test verifies that the RTCP reduced size mode is properly applied to
3398 // receive video streams. 3398 // receive video streams.
3399 TEST_F(WebRtcVideoChannel2Test, TestSetRecvRtcpReducedSize) { 3399 TEST_F(WebRtcVideoChannelTest, TestSetRecvRtcpReducedSize) {
3400 // Create stream, expecting that default mode is "compound". 3400 // Create stream, expecting that default mode is "compound".
3401 FakeVideoReceiveStream* stream1 = AddRecvStream(); 3401 FakeVideoReceiveStream* stream1 = AddRecvStream();
3402 EXPECT_EQ(webrtc::RtcpMode::kCompound, stream1->GetConfig().rtp.rtcp_mode); 3402 EXPECT_EQ(webrtc::RtcpMode::kCompound, stream1->GetConfig().rtp.rtcp_mode);
3403 3403
3404 // Now enable reduced size mode. 3404 // Now enable reduced size mode.
3405 // TODO(deadbeef): Once "recv_parameters" becomes "receiver_parameters", 3405 // TODO(deadbeef): Once "recv_parameters" becomes "receiver_parameters",
3406 // the reduced_size flag should come from that. 3406 // the reduced_size flag should come from that.
3407 send_parameters_.rtcp.reduced_size = true; 3407 send_parameters_.rtcp.reduced_size = true;
3408 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); 3408 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
3409 stream1 = fake_call_->GetVideoReceiveStreams()[0]; 3409 stream1 = fake_call_->GetVideoReceiveStreams()[0];
3410 EXPECT_EQ(webrtc::RtcpMode::kReducedSize, stream1->GetConfig().rtp.rtcp_mode); 3410 EXPECT_EQ(webrtc::RtcpMode::kReducedSize, stream1->GetConfig().rtp.rtcp_mode);
3411 3411
3412 // Create a new stream and ensure it picks up the reduced size mode. 3412 // Create a new stream and ensure it picks up the reduced size mode.
3413 FakeVideoReceiveStream* stream2 = AddRecvStream(); 3413 FakeVideoReceiveStream* stream2 = AddRecvStream();
3414 EXPECT_EQ(webrtc::RtcpMode::kReducedSize, stream2->GetConfig().rtp.rtcp_mode); 3414 EXPECT_EQ(webrtc::RtcpMode::kReducedSize, stream2->GetConfig().rtp.rtcp_mode);
3415 } 3415 }
3416 3416
3417 TEST_F(WebRtcVideoChannel2Test, OnReadyToSendSignalsNetworkState) { 3417 TEST_F(WebRtcVideoChannelTest, OnReadyToSendSignalsNetworkState) {
3418 EXPECT_EQ(webrtc::kNetworkUp, 3418 EXPECT_EQ(webrtc::kNetworkUp,
3419 fake_call_->GetNetworkState(webrtc::MediaType::VIDEO)); 3419 fake_call_->GetNetworkState(webrtc::MediaType::VIDEO));
3420 EXPECT_EQ(webrtc::kNetworkUp, 3420 EXPECT_EQ(webrtc::kNetworkUp,
3421 fake_call_->GetNetworkState(webrtc::MediaType::AUDIO)); 3421 fake_call_->GetNetworkState(webrtc::MediaType::AUDIO));
3422 3422
3423 channel_->OnReadyToSend(false); 3423 channel_->OnReadyToSend(false);
3424 EXPECT_EQ(webrtc::kNetworkDown, 3424 EXPECT_EQ(webrtc::kNetworkDown,
3425 fake_call_->GetNetworkState(webrtc::MediaType::VIDEO)); 3425 fake_call_->GetNetworkState(webrtc::MediaType::VIDEO));
3426 EXPECT_EQ(webrtc::kNetworkUp, 3426 EXPECT_EQ(webrtc::kNetworkUp,
3427 fake_call_->GetNetworkState(webrtc::MediaType::AUDIO)); 3427 fake_call_->GetNetworkState(webrtc::MediaType::AUDIO));
3428 3428
3429 channel_->OnReadyToSend(true); 3429 channel_->OnReadyToSend(true);
3430 EXPECT_EQ(webrtc::kNetworkUp, 3430 EXPECT_EQ(webrtc::kNetworkUp,
3431 fake_call_->GetNetworkState(webrtc::MediaType::VIDEO)); 3431 fake_call_->GetNetworkState(webrtc::MediaType::VIDEO));
3432 EXPECT_EQ(webrtc::kNetworkUp, 3432 EXPECT_EQ(webrtc::kNetworkUp,
3433 fake_call_->GetNetworkState(webrtc::MediaType::AUDIO)); 3433 fake_call_->GetNetworkState(webrtc::MediaType::AUDIO));
3434 } 3434 }
3435 3435
3436 TEST_F(WebRtcVideoChannel2Test, GetStatsReportsSentCodecName) { 3436 TEST_F(WebRtcVideoChannelTest, GetStatsReportsSentCodecName) {
3437 cricket::VideoSendParameters parameters; 3437 cricket::VideoSendParameters parameters;
3438 parameters.codecs.push_back(GetEngineCodec("VP8")); 3438 parameters.codecs.push_back(GetEngineCodec("VP8"));
3439 EXPECT_TRUE(channel_->SetSendParameters(parameters)); 3439 EXPECT_TRUE(channel_->SetSendParameters(parameters));
3440 3440
3441 AddSendStream(); 3441 AddSendStream();
3442 3442
3443 cricket::VideoMediaInfo info; 3443 cricket::VideoMediaInfo info;
3444 ASSERT_TRUE(channel_->GetStats(&info)); 3444 ASSERT_TRUE(channel_->GetStats(&info));
3445 EXPECT_EQ("VP8", info.senders[0].codec_name); 3445 EXPECT_EQ("VP8", info.senders[0].codec_name);
3446 } 3446 }
3447 3447
3448 TEST_F(WebRtcVideoChannel2Test, GetStatsReportsEncoderImplementationName) { 3448 TEST_F(WebRtcVideoChannelTest, GetStatsReportsEncoderImplementationName) {
3449 FakeVideoSendStream* stream = AddSendStream(); 3449 FakeVideoSendStream* stream = AddSendStream();
3450 webrtc::VideoSendStream::Stats stats; 3450 webrtc::VideoSendStream::Stats stats;
3451 stats.encoder_implementation_name = "encoder_implementation_name"; 3451 stats.encoder_implementation_name = "encoder_implementation_name";
3452 stream->SetStats(stats); 3452 stream->SetStats(stats);
3453 3453
3454 cricket::VideoMediaInfo info; 3454 cricket::VideoMediaInfo info;
3455 ASSERT_TRUE(channel_->GetStats(&info)); 3455 ASSERT_TRUE(channel_->GetStats(&info));
3456 EXPECT_EQ(stats.encoder_implementation_name, 3456 EXPECT_EQ(stats.encoder_implementation_name,
3457 info.senders[0].encoder_implementation_name); 3457 info.senders[0].encoder_implementation_name);
3458 } 3458 }
3459 3459
3460 TEST_F(WebRtcVideoChannel2Test, GetStatsReportsCpuOveruseMetrics) { 3460 TEST_F(WebRtcVideoChannelTest, GetStatsReportsCpuOveruseMetrics) {
3461 FakeVideoSendStream* stream = AddSendStream(); 3461 FakeVideoSendStream* stream = AddSendStream();
3462 webrtc::VideoSendStream::Stats stats; 3462 webrtc::VideoSendStream::Stats stats;
3463 stats.avg_encode_time_ms = 13; 3463 stats.avg_encode_time_ms = 13;
3464 stats.encode_usage_percent = 42; 3464 stats.encode_usage_percent = 42;
3465 stream->SetStats(stats); 3465 stream->SetStats(stats);
3466 3466
3467 cricket::VideoMediaInfo info; 3467 cricket::VideoMediaInfo info;
3468 ASSERT_TRUE(channel_->GetStats(&info)); 3468 ASSERT_TRUE(channel_->GetStats(&info));
3469 EXPECT_EQ(stats.avg_encode_time_ms, info.senders[0].avg_encode_ms); 3469 EXPECT_EQ(stats.avg_encode_time_ms, info.senders[0].avg_encode_ms);
3470 EXPECT_EQ(stats.encode_usage_percent, info.senders[0].encode_usage_percent); 3470 EXPECT_EQ(stats.encode_usage_percent, info.senders[0].encode_usage_percent);
3471 } 3471 }
3472 3472
3473 TEST_F(WebRtcVideoChannel2Test, GetStatsReportsFramesEncoded) { 3473 TEST_F(WebRtcVideoChannelTest, GetStatsReportsFramesEncoded) {
3474 FakeVideoSendStream* stream = AddSendStream(); 3474 FakeVideoSendStream* stream = AddSendStream();
3475 webrtc::VideoSendStream::Stats stats; 3475 webrtc::VideoSendStream::Stats stats;
3476 stats.frames_encoded = 13; 3476 stats.frames_encoded = 13;
3477 stream->SetStats(stats); 3477 stream->SetStats(stats);
3478 3478
3479 cricket::VideoMediaInfo info; 3479 cricket::VideoMediaInfo info;
3480 ASSERT_TRUE(channel_->GetStats(&info)); 3480 ASSERT_TRUE(channel_->GetStats(&info));
3481 EXPECT_EQ(stats.frames_encoded, info.senders[0].frames_encoded); 3481 EXPECT_EQ(stats.frames_encoded, info.senders[0].frames_encoded);
3482 } 3482 }
3483 3483
3484 TEST_F(WebRtcVideoChannel2Test, GetStatsReportsQpSum) { 3484 TEST_F(WebRtcVideoChannelTest, GetStatsReportsQpSum) {
3485 FakeVideoSendStream* stream = AddSendStream(); 3485 FakeVideoSendStream* stream = AddSendStream();
3486 webrtc::VideoSendStream::Stats stats; 3486 webrtc::VideoSendStream::Stats stats;
3487 stats.qp_sum = rtc::Optional<uint64_t>(13); 3487 stats.qp_sum = rtc::Optional<uint64_t>(13);
3488 stream->SetStats(stats); 3488 stream->SetStats(stats);
3489 3489
3490 cricket::VideoMediaInfo info; 3490 cricket::VideoMediaInfo info;
3491 ASSERT_TRUE(channel_->GetStats(&info)); 3491 ASSERT_TRUE(channel_->GetStats(&info));
3492 EXPECT_EQ(stats.qp_sum, info.senders[0].qp_sum); 3492 EXPECT_EQ(stats.qp_sum, info.senders[0].qp_sum);
3493 } 3493 }
3494 3494
3495 TEST_F(WebRtcVideoChannel2Test, GetStatsReportsUpperResolution) { 3495 TEST_F(WebRtcVideoChannelTest, GetStatsReportsUpperResolution) {
3496 FakeVideoSendStream* stream = AddSendStream(); 3496 FakeVideoSendStream* stream = AddSendStream();
3497 webrtc::VideoSendStream::Stats stats; 3497 webrtc::VideoSendStream::Stats stats;
3498 stats.substreams[17].width = 123; 3498 stats.substreams[17].width = 123;
3499 stats.substreams[17].height = 40; 3499 stats.substreams[17].height = 40;
3500 stats.substreams[42].width = 80; 3500 stats.substreams[42].width = 80;
3501 stats.substreams[42].height = 31; 3501 stats.substreams[42].height = 31;
3502 stats.substreams[11].width = 20; 3502 stats.substreams[11].width = 20;
3503 stats.substreams[11].height = 90; 3503 stats.substreams[11].height = 90;
3504 stream->SetStats(stats); 3504 stream->SetStats(stats);
3505 3505
3506 cricket::VideoMediaInfo info; 3506 cricket::VideoMediaInfo info;
3507 ASSERT_TRUE(channel_->GetStats(&info)); 3507 ASSERT_TRUE(channel_->GetStats(&info));
3508 ASSERT_EQ(1u, info.senders.size()); 3508 ASSERT_EQ(1u, info.senders.size());
3509 EXPECT_EQ(123, info.senders[0].send_frame_width); 3509 EXPECT_EQ(123, info.senders[0].send_frame_width);
3510 EXPECT_EQ(90, info.senders[0].send_frame_height); 3510 EXPECT_EQ(90, info.senders[0].send_frame_height);
3511 } 3511 }
3512 3512
3513 TEST_F(WebRtcVideoChannel2Test, GetStatsReportsPreferredBitrate) { 3513 TEST_F(WebRtcVideoChannelTest, GetStatsReportsPreferredBitrate) {
3514 FakeVideoSendStream* stream = AddSendStream(); 3514 FakeVideoSendStream* stream = AddSendStream();
3515 webrtc::VideoSendStream::Stats stats; 3515 webrtc::VideoSendStream::Stats stats;
3516 stats.preferred_media_bitrate_bps = 5; 3516 stats.preferred_media_bitrate_bps = 5;
3517 stream->SetStats(stats); 3517 stream->SetStats(stats);
3518 3518
3519 cricket::VideoMediaInfo info; 3519 cricket::VideoMediaInfo info;
3520 ASSERT_TRUE(channel_->GetStats(&info)); 3520 ASSERT_TRUE(channel_->GetStats(&info));
3521 ASSERT_EQ(1u, info.senders.size()); 3521 ASSERT_EQ(1u, info.senders.size());
3522 EXPECT_EQ(5, info.senders[0].preferred_bitrate); 3522 EXPECT_EQ(5, info.senders[0].preferred_bitrate);
3523 } 3523 }
3524 3524
3525 TEST_F(WebRtcVideoChannel2Test, GetStatsReportsCpuAdaptationStats) { 3525 TEST_F(WebRtcVideoChannelTest, GetStatsReportsCpuAdaptationStats) {
3526 FakeVideoSendStream* stream = AddSendStream(); 3526 FakeVideoSendStream* stream = AddSendStream();
3527 webrtc::VideoSendStream::Stats stats; 3527 webrtc::VideoSendStream::Stats stats;
3528 stats.number_of_cpu_adapt_changes = 2; 3528 stats.number_of_cpu_adapt_changes = 2;
3529 stats.cpu_limited_resolution = true; 3529 stats.cpu_limited_resolution = true;
3530 stream->SetStats(stats); 3530 stream->SetStats(stats);
3531 3531
3532 cricket::VideoMediaInfo info; 3532 cricket::VideoMediaInfo info;
3533 EXPECT_TRUE(channel_->GetStats(&info)); 3533 EXPECT_TRUE(channel_->GetStats(&info));
3534 ASSERT_EQ(1U, info.senders.size()); 3534 ASSERT_EQ(1U, info.senders.size());
3535 EXPECT_EQ(WebRtcVideoChannel2::ADAPTREASON_CPU, info.senders[0].adapt_reason); 3535 EXPECT_EQ(WebRtcVideoChannel::ADAPTREASON_CPU, info.senders[0].adapt_reason);
3536 EXPECT_EQ(stats.number_of_cpu_adapt_changes, info.senders[0].adapt_changes); 3536 EXPECT_EQ(stats.number_of_cpu_adapt_changes, info.senders[0].adapt_changes);
3537 } 3537 }
3538 3538
3539 TEST_F(WebRtcVideoChannel2Test, GetStatsReportsAdaptationAndBandwidthStats) { 3539 TEST_F(WebRtcVideoChannelTest, GetStatsReportsAdaptationAndBandwidthStats) {
3540 FakeVideoSendStream* stream = AddSendStream(); 3540 FakeVideoSendStream* stream = AddSendStream();
3541 webrtc::VideoSendStream::Stats stats; 3541 webrtc::VideoSendStream::Stats stats;
3542 stats.number_of_cpu_adapt_changes = 2; 3542 stats.number_of_cpu_adapt_changes = 2;
3543 stats.cpu_limited_resolution = true; 3543 stats.cpu_limited_resolution = true;
3544 stats.bw_limited_resolution = true; 3544 stats.bw_limited_resolution = true;
3545 stream->SetStats(stats); 3545 stream->SetStats(stats);
3546 3546
3547 cricket::VideoMediaInfo info; 3547 cricket::VideoMediaInfo info;
3548 EXPECT_TRUE(channel_->GetStats(&info)); 3548 EXPECT_TRUE(channel_->GetStats(&info));
3549 ASSERT_EQ(1U, info.senders.size()); 3549 ASSERT_EQ(1U, info.senders.size());
3550 EXPECT_EQ(WebRtcVideoChannel2::ADAPTREASON_CPU | 3550 EXPECT_EQ(WebRtcVideoChannel::ADAPTREASON_CPU |
3551 WebRtcVideoChannel2::ADAPTREASON_BANDWIDTH, 3551 WebRtcVideoChannel::ADAPTREASON_BANDWIDTH,
3552 info.senders[0].adapt_reason); 3552 info.senders[0].adapt_reason);
3553 EXPECT_EQ(stats.number_of_cpu_adapt_changes, info.senders[0].adapt_changes); 3553 EXPECT_EQ(stats.number_of_cpu_adapt_changes, info.senders[0].adapt_changes);
3554 } 3554 }
3555 3555
3556 TEST_F(WebRtcVideoChannel2Test, 3556 TEST_F(WebRtcVideoChannelTest,
3557 GetStatsTranslatesBandwidthLimitedResolutionCorrectly) { 3557 GetStatsTranslatesBandwidthLimitedResolutionCorrectly) {
3558 FakeVideoSendStream* stream = AddSendStream(); 3558 FakeVideoSendStream* stream = AddSendStream();
3559 webrtc::VideoSendStream::Stats stats; 3559 webrtc::VideoSendStream::Stats stats;
3560 stats.bw_limited_resolution = true; 3560 stats.bw_limited_resolution = true;
3561 stream->SetStats(stats); 3561 stream->SetStats(stats);
3562 3562
3563 cricket::VideoMediaInfo info; 3563 cricket::VideoMediaInfo info;
3564 EXPECT_TRUE(channel_->GetStats(&info)); 3564 EXPECT_TRUE(channel_->GetStats(&info));
3565 ASSERT_EQ(1U, info.senders.size()); 3565 ASSERT_EQ(1U, info.senders.size());
3566 EXPECT_EQ(WebRtcVideoChannel2::ADAPTREASON_BANDWIDTH, 3566 EXPECT_EQ(WebRtcVideoChannel::ADAPTREASON_BANDWIDTH,
3567 info.senders[0].adapt_reason); 3567 info.senders[0].adapt_reason);
3568 } 3568 }
3569 3569
3570 TEST_F(WebRtcVideoChannel2Test, 3570 TEST_F(WebRtcVideoChannelTest,
3571 GetStatsTranslatesSendRtcpPacketTypesCorrectly) { 3571 GetStatsTranslatesSendRtcpPacketTypesCorrectly) {
3572 FakeVideoSendStream* stream = AddSendStream(); 3572 FakeVideoSendStream* stream = AddSendStream();
3573 webrtc::VideoSendStream::Stats stats; 3573 webrtc::VideoSendStream::Stats stats;
3574 stats.substreams[17].rtcp_packet_type_counts.fir_packets = 2; 3574 stats.substreams[17].rtcp_packet_type_counts.fir_packets = 2;
3575 stats.substreams[17].rtcp_packet_type_counts.nack_packets = 3; 3575 stats.substreams[17].rtcp_packet_type_counts.nack_packets = 3;
3576 stats.substreams[17].rtcp_packet_type_counts.pli_packets = 4; 3576 stats.substreams[17].rtcp_packet_type_counts.pli_packets = 4;
3577 3577
3578 stats.substreams[42].rtcp_packet_type_counts.fir_packets = 5; 3578 stats.substreams[42].rtcp_packet_type_counts.fir_packets = 5;
3579 stats.substreams[42].rtcp_packet_type_counts.nack_packets = 7; 3579 stats.substreams[42].rtcp_packet_type_counts.nack_packets = 7;
3580 stats.substreams[42].rtcp_packet_type_counts.pli_packets = 9; 3580 stats.substreams[42].rtcp_packet_type_counts.pli_packets = 9;
3581 3581
3582 stream->SetStats(stats); 3582 stream->SetStats(stats);
3583 3583
3584 cricket::VideoMediaInfo info; 3584 cricket::VideoMediaInfo info;
3585 ASSERT_TRUE(channel_->GetStats(&info)); 3585 ASSERT_TRUE(channel_->GetStats(&info));
3586 EXPECT_EQ(7, info.senders[0].firs_rcvd); 3586 EXPECT_EQ(7, info.senders[0].firs_rcvd);
3587 EXPECT_EQ(10, info.senders[0].nacks_rcvd); 3587 EXPECT_EQ(10, info.senders[0].nacks_rcvd);
3588 EXPECT_EQ(13, info.senders[0].plis_rcvd); 3588 EXPECT_EQ(13, info.senders[0].plis_rcvd);
3589 } 3589 }
3590 3590
3591 TEST_F(WebRtcVideoChannel2Test, 3591 TEST_F(WebRtcVideoChannelTest,
3592 GetStatsTranslatesReceiveRtcpPacketTypesCorrectly) { 3592 GetStatsTranslatesReceiveRtcpPacketTypesCorrectly) {
3593 FakeVideoReceiveStream* stream = AddRecvStream(); 3593 FakeVideoReceiveStream* stream = AddRecvStream();
3594 webrtc::VideoReceiveStream::Stats stats; 3594 webrtc::VideoReceiveStream::Stats stats;
3595 stats.rtcp_packet_type_counts.fir_packets = 2; 3595 stats.rtcp_packet_type_counts.fir_packets = 2;
3596 stats.rtcp_packet_type_counts.nack_packets = 3; 3596 stats.rtcp_packet_type_counts.nack_packets = 3;
3597 stats.rtcp_packet_type_counts.pli_packets = 4; 3597 stats.rtcp_packet_type_counts.pli_packets = 4;
3598 stream->SetStats(stats); 3598 stream->SetStats(stats);
3599 3599
3600 cricket::VideoMediaInfo info; 3600 cricket::VideoMediaInfo info;
3601 ASSERT_TRUE(channel_->GetStats(&info)); 3601 ASSERT_TRUE(channel_->GetStats(&info));
3602 EXPECT_EQ(stats.rtcp_packet_type_counts.fir_packets, 3602 EXPECT_EQ(stats.rtcp_packet_type_counts.fir_packets,
3603 info.receivers[0].firs_sent); 3603 info.receivers[0].firs_sent);
3604 EXPECT_EQ(stats.rtcp_packet_type_counts.nack_packets, 3604 EXPECT_EQ(stats.rtcp_packet_type_counts.nack_packets,
3605 info.receivers[0].nacks_sent); 3605 info.receivers[0].nacks_sent);
3606 EXPECT_EQ(stats.rtcp_packet_type_counts.pli_packets, 3606 EXPECT_EQ(stats.rtcp_packet_type_counts.pli_packets,
3607 info.receivers[0].plis_sent); 3607 info.receivers[0].plis_sent);
3608 } 3608 }
3609 3609
3610 TEST_F(WebRtcVideoChannel2Test, GetStatsTranslatesDecodeStatsCorrectly) { 3610 TEST_F(WebRtcVideoChannelTest, GetStatsTranslatesDecodeStatsCorrectly) {
3611 FakeVideoReceiveStream* stream = AddRecvStream(); 3611 FakeVideoReceiveStream* stream = AddRecvStream();
3612 webrtc::VideoReceiveStream::Stats stats; 3612 webrtc::VideoReceiveStream::Stats stats;
3613 stats.decoder_implementation_name = "decoder_implementation_name"; 3613 stats.decoder_implementation_name = "decoder_implementation_name";
3614 stats.decode_ms = 2; 3614 stats.decode_ms = 2;
3615 stats.max_decode_ms = 3; 3615 stats.max_decode_ms = 3;
3616 stats.current_delay_ms = 4; 3616 stats.current_delay_ms = 4;
3617 stats.target_delay_ms = 5; 3617 stats.target_delay_ms = 5;
3618 stats.jitter_buffer_ms = 6; 3618 stats.jitter_buffer_ms = 6;
3619 stats.min_playout_delay_ms = 7; 3619 stats.min_playout_delay_ms = 7;
3620 stats.render_delay_ms = 8; 3620 stats.render_delay_ms = 8;
(...skipping 19 matching lines...) Expand all
3640 EXPECT_EQ(stats.render_delay_ms, info.receivers[0].render_delay_ms); 3640 EXPECT_EQ(stats.render_delay_ms, info.receivers[0].render_delay_ms);
3641 EXPECT_EQ(stats.width, info.receivers[0].frame_width); 3641 EXPECT_EQ(stats.width, info.receivers[0].frame_width);
3642 EXPECT_EQ(stats.height, info.receivers[0].frame_height); 3642 EXPECT_EQ(stats.height, info.receivers[0].frame_height);
3643 EXPECT_EQ(stats.frame_counts.key_frames + stats.frame_counts.delta_frames, 3643 EXPECT_EQ(stats.frame_counts.key_frames + stats.frame_counts.delta_frames,
3644 info.receivers[0].frames_received); 3644 info.receivers[0].frames_received);
3645 EXPECT_EQ(stats.frames_rendered, info.receivers[0].frames_rendered); 3645 EXPECT_EQ(stats.frames_rendered, info.receivers[0].frames_rendered);
3646 EXPECT_EQ(stats.frames_decoded, info.receivers[0].frames_decoded); 3646 EXPECT_EQ(stats.frames_decoded, info.receivers[0].frames_decoded);
3647 EXPECT_EQ(stats.qp_sum, info.receivers[0].qp_sum); 3647 EXPECT_EQ(stats.qp_sum, info.receivers[0].qp_sum);
3648 } 3648 }
3649 3649
3650 TEST_F(WebRtcVideoChannel2Test, GetStatsTranslatesReceivePacketStatsCorrectly) { 3650 TEST_F(WebRtcVideoChannelTest, GetStatsTranslatesReceivePacketStatsCorrectly) {
3651 FakeVideoReceiveStream* stream = AddRecvStream(); 3651 FakeVideoReceiveStream* stream = AddRecvStream();
3652 webrtc::VideoReceiveStream::Stats stats; 3652 webrtc::VideoReceiveStream::Stats stats;
3653 stats.rtp_stats.transmitted.payload_bytes = 2; 3653 stats.rtp_stats.transmitted.payload_bytes = 2;
3654 stats.rtp_stats.transmitted.header_bytes = 3; 3654 stats.rtp_stats.transmitted.header_bytes = 3;
3655 stats.rtp_stats.transmitted.padding_bytes = 4; 3655 stats.rtp_stats.transmitted.padding_bytes = 4;
3656 stats.rtp_stats.transmitted.packets = 5; 3656 stats.rtp_stats.transmitted.packets = 5;
3657 stats.rtcp_stats.cumulative_lost = 6; 3657 stats.rtcp_stats.cumulative_lost = 6;
3658 stats.rtcp_stats.fraction_lost = 7; 3658 stats.rtcp_stats.fraction_lost = 7;
3659 stream->SetStats(stats); 3659 stream->SetStats(stats);
3660 3660
3661 cricket::VideoMediaInfo info; 3661 cricket::VideoMediaInfo info;
3662 ASSERT_TRUE(channel_->GetStats(&info)); 3662 ASSERT_TRUE(channel_->GetStats(&info));
3663 EXPECT_EQ(stats.rtp_stats.transmitted.payload_bytes + 3663 EXPECT_EQ(stats.rtp_stats.transmitted.payload_bytes +
3664 stats.rtp_stats.transmitted.header_bytes + 3664 stats.rtp_stats.transmitted.header_bytes +
3665 stats.rtp_stats.transmitted.padding_bytes, 3665 stats.rtp_stats.transmitted.padding_bytes,
3666 info.receivers[0].bytes_rcvd); 3666 info.receivers[0].bytes_rcvd);
3667 EXPECT_EQ(stats.rtp_stats.transmitted.packets, 3667 EXPECT_EQ(stats.rtp_stats.transmitted.packets,
3668 info.receivers[0].packets_rcvd); 3668 info.receivers[0].packets_rcvd);
3669 EXPECT_EQ(stats.rtcp_stats.cumulative_lost, info.receivers[0].packets_lost); 3669 EXPECT_EQ(stats.rtcp_stats.cumulative_lost, info.receivers[0].packets_lost);
3670 EXPECT_EQ(static_cast<float>(stats.rtcp_stats.fraction_lost) / (1 << 8), 3670 EXPECT_EQ(static_cast<float>(stats.rtcp_stats.fraction_lost) / (1 << 8),
3671 info.receivers[0].fraction_lost); 3671 info.receivers[0].fraction_lost);
3672 } 3672 }
3673 3673
3674 TEST_F(WebRtcVideoChannel2Test, TranslatesCallStatsCorrectly) { 3674 TEST_F(WebRtcVideoChannelTest, TranslatesCallStatsCorrectly) {
3675 AddSendStream(); 3675 AddSendStream();
3676 AddSendStream(); 3676 AddSendStream();
3677 webrtc::Call::Stats stats; 3677 webrtc::Call::Stats stats;
3678 stats.rtt_ms = 123; 3678 stats.rtt_ms = 123;
3679 fake_call_->SetStats(stats); 3679 fake_call_->SetStats(stats);
3680 3680
3681 cricket::VideoMediaInfo info; 3681 cricket::VideoMediaInfo info;
3682 ASSERT_TRUE(channel_->GetStats(&info)); 3682 ASSERT_TRUE(channel_->GetStats(&info));
3683 ASSERT_EQ(2u, info.senders.size()); 3683 ASSERT_EQ(2u, info.senders.size());
3684 EXPECT_EQ(stats.rtt_ms, info.senders[0].rtt_ms); 3684 EXPECT_EQ(stats.rtt_ms, info.senders[0].rtt_ms);
3685 EXPECT_EQ(stats.rtt_ms, info.senders[1].rtt_ms); 3685 EXPECT_EQ(stats.rtt_ms, info.senders[1].rtt_ms);
3686 } 3686 }
3687 3687
3688 TEST_F(WebRtcVideoChannel2Test, TranslatesSenderBitrateStatsCorrectly) { 3688 TEST_F(WebRtcVideoChannelTest, TranslatesSenderBitrateStatsCorrectly) {
3689 FakeVideoSendStream* stream = AddSendStream(); 3689 FakeVideoSendStream* stream = AddSendStream();
3690 webrtc::VideoSendStream::Stats stats; 3690 webrtc::VideoSendStream::Stats stats;
3691 stats.target_media_bitrate_bps = 156; 3691 stats.target_media_bitrate_bps = 156;
3692 stats.media_bitrate_bps = 123; 3692 stats.media_bitrate_bps = 123;
3693 stats.substreams[17].total_bitrate_bps = 1; 3693 stats.substreams[17].total_bitrate_bps = 1;
3694 stats.substreams[17].retransmit_bitrate_bps = 2; 3694 stats.substreams[17].retransmit_bitrate_bps = 2;
3695 stats.substreams[42].total_bitrate_bps = 3; 3695 stats.substreams[42].total_bitrate_bps = 3;
3696 stats.substreams[42].retransmit_bitrate_bps = 4; 3696 stats.substreams[42].retransmit_bitrate_bps = 4;
3697 stream->SetStats(stats); 3697 stream->SetStats(stats);
3698 3698
(...skipping 19 matching lines...) Expand all
3718 EXPECT_EQ(stats.target_media_bitrate_bps + stats2.target_media_bitrate_bps, 3718 EXPECT_EQ(stats.target_media_bitrate_bps + stats2.target_media_bitrate_bps,
3719 bwe_info.target_enc_bitrate); 3719 bwe_info.target_enc_bitrate);
3720 EXPECT_EQ(stats.media_bitrate_bps + stats2.media_bitrate_bps, 3720 EXPECT_EQ(stats.media_bitrate_bps + stats2.media_bitrate_bps,
3721 bwe_info.actual_enc_bitrate); 3721 bwe_info.actual_enc_bitrate);
3722 EXPECT_EQ(1 + 3 + 5 + 7, bwe_info.transmit_bitrate) 3722 EXPECT_EQ(1 + 3 + 5 + 7, bwe_info.transmit_bitrate)
3723 << "Bandwidth stats should take all streams into account."; 3723 << "Bandwidth stats should take all streams into account.";
3724 EXPECT_EQ(2 + 4 + 6 + 8, bwe_info.retransmit_bitrate) 3724 EXPECT_EQ(2 + 4 + 6 + 8, bwe_info.retransmit_bitrate)
3725 << "Bandwidth stats should take all streams into account."; 3725 << "Bandwidth stats should take all streams into account.";
3726 } 3726 }
3727 3727
3728 TEST_F(WebRtcVideoChannel2Test, DefaultReceiveStreamReconfiguresToUseRtx) { 3728 TEST_F(WebRtcVideoChannelTest, DefaultReceiveStreamReconfiguresToUseRtx) {
3729 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); 3729 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
3730 3730
3731 const std::vector<uint32_t> ssrcs = MAKE_VECTOR(kSsrcs1); 3731 const std::vector<uint32_t> ssrcs = MAKE_VECTOR(kSsrcs1);
3732 const std::vector<uint32_t> rtx_ssrcs = MAKE_VECTOR(kRtxSsrcs1); 3732 const std::vector<uint32_t> rtx_ssrcs = MAKE_VECTOR(kRtxSsrcs1);
3733 3733
3734 ASSERT_EQ(0u, fake_call_->GetVideoReceiveStreams().size()); 3734 ASSERT_EQ(0u, fake_call_->GetVideoReceiveStreams().size());
3735 const size_t kDataLength = 12; 3735 const size_t kDataLength = 12;
3736 uint8_t data[kDataLength]; 3736 uint8_t data[kDataLength];
3737 memset(data, 0, sizeof(data)); 3737 memset(data, 0, sizeof(data));
3738 rtc::SetBE32(&data[8], ssrcs[0]); 3738 rtc::SetBE32(&data[8], ssrcs[0]);
(...skipping 12 matching lines...) Expand all
3751 ASSERT_EQ(1u, fake_call_->GetVideoReceiveStreams().size()) 3751 ASSERT_EQ(1u, fake_call_->GetVideoReceiveStreams().size())
3752 << "AddRecvStream should have reconfigured, not added a new receiver."; 3752 << "AddRecvStream should have reconfigured, not added a new receiver.";
3753 recv_stream = fake_call_->GetVideoReceiveStreams()[0]; 3753 recv_stream = fake_call_->GetVideoReceiveStreams()[0];
3754 EXPECT_FALSE(recv_stream->GetConfig().rtp.rtx_payload_types.empty()); 3754 EXPECT_FALSE(recv_stream->GetConfig().rtp.rtx_payload_types.empty());
3755 EXPECT_EQ(recv_stream->GetConfig().decoders.size(), 3755 EXPECT_EQ(recv_stream->GetConfig().decoders.size(),
3756 recv_stream->GetConfig().rtp.rtx_payload_types.size()) 3756 recv_stream->GetConfig().rtp.rtx_payload_types.size())
3757 << "RTX should be mapped for all decoders/payload types."; 3757 << "RTX should be mapped for all decoders/payload types.";
3758 EXPECT_EQ(rtx_ssrcs[0], recv_stream->GetConfig().rtp.rtx_ssrc); 3758 EXPECT_EQ(rtx_ssrcs[0], recv_stream->GetConfig().rtp.rtx_ssrc);
3759 } 3759 }
3760 3760
3761 TEST_F(WebRtcVideoChannel2Test, RejectsAddingStreamsWithMissingSsrcsForRtx) { 3761 TEST_F(WebRtcVideoChannelTest, RejectsAddingStreamsWithMissingSsrcsForRtx) {
3762 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); 3762 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
3763 3763
3764 const std::vector<uint32_t> ssrcs = MAKE_VECTOR(kSsrcs1); 3764 const std::vector<uint32_t> ssrcs = MAKE_VECTOR(kSsrcs1);
3765 const std::vector<uint32_t> rtx_ssrcs = MAKE_VECTOR(kRtxSsrcs1); 3765 const std::vector<uint32_t> rtx_ssrcs = MAKE_VECTOR(kRtxSsrcs1);
3766 3766
3767 StreamParams sp = 3767 StreamParams sp =
3768 cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs); 3768 cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs);
3769 sp.ssrcs = ssrcs; // Without RTXs, this is the important part. 3769 sp.ssrcs = ssrcs; // Without RTXs, this is the important part.
3770 3770
3771 EXPECT_FALSE(channel_->AddSendStream(sp)); 3771 EXPECT_FALSE(channel_->AddSendStream(sp));
3772 EXPECT_FALSE(channel_->AddRecvStream(sp)); 3772 EXPECT_FALSE(channel_->AddRecvStream(sp));
3773 } 3773 }
3774 3774
3775 TEST_F(WebRtcVideoChannel2Test, RejectsAddingStreamsWithOverlappingRtxSsrcs) { 3775 TEST_F(WebRtcVideoChannelTest, RejectsAddingStreamsWithOverlappingRtxSsrcs) {
3776 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); 3776 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
3777 3777
3778 const std::vector<uint32_t> ssrcs = MAKE_VECTOR(kSsrcs1); 3778 const std::vector<uint32_t> ssrcs = MAKE_VECTOR(kSsrcs1);
3779 const std::vector<uint32_t> rtx_ssrcs = MAKE_VECTOR(kRtxSsrcs1); 3779 const std::vector<uint32_t> rtx_ssrcs = MAKE_VECTOR(kRtxSsrcs1);
3780 3780
3781 StreamParams sp = 3781 StreamParams sp =
3782 cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs); 3782 cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs);
3783 3783
3784 EXPECT_TRUE(channel_->AddSendStream(sp)); 3784 EXPECT_TRUE(channel_->AddSendStream(sp));
3785 EXPECT_TRUE(channel_->AddRecvStream(sp)); 3785 EXPECT_TRUE(channel_->AddRecvStream(sp));
3786 3786
3787 // The RTX SSRC is already used in previous streams, using it should fail. 3787 // The RTX SSRC is already used in previous streams, using it should fail.
3788 sp = cricket::StreamParams::CreateLegacy(rtx_ssrcs[0]); 3788 sp = cricket::StreamParams::CreateLegacy(rtx_ssrcs[0]);
3789 EXPECT_FALSE(channel_->AddSendStream(sp)); 3789 EXPECT_FALSE(channel_->AddSendStream(sp));
3790 EXPECT_FALSE(channel_->AddRecvStream(sp)); 3790 EXPECT_FALSE(channel_->AddRecvStream(sp));
3791 3791
3792 // After removing the original stream this should be fine to add (makes sure 3792 // After removing the original stream this should be fine to add (makes sure
3793 // that RTX ssrcs are not forever taken). 3793 // that RTX ssrcs are not forever taken).
3794 EXPECT_TRUE(channel_->RemoveSendStream(ssrcs[0])); 3794 EXPECT_TRUE(channel_->RemoveSendStream(ssrcs[0]));
3795 EXPECT_TRUE(channel_->RemoveRecvStream(ssrcs[0])); 3795 EXPECT_TRUE(channel_->RemoveRecvStream(ssrcs[0]));
3796 EXPECT_TRUE(channel_->AddSendStream(sp)); 3796 EXPECT_TRUE(channel_->AddSendStream(sp));
3797 EXPECT_TRUE(channel_->AddRecvStream(sp)); 3797 EXPECT_TRUE(channel_->AddRecvStream(sp));
3798 } 3798 }
3799 3799
3800 TEST_F(WebRtcVideoChannel2Test, 3800 TEST_F(WebRtcVideoChannelTest,
3801 RejectsAddingStreamsWithOverlappingSimulcastSsrcs) { 3801 RejectsAddingStreamsWithOverlappingSimulcastSsrcs) {
3802 static const uint32_t kFirstStreamSsrcs[] = {1, 2, 3}; 3802 static const uint32_t kFirstStreamSsrcs[] = {1, 2, 3};
3803 static const uint32_t kOverlappingStreamSsrcs[] = {4, 3, 5}; 3803 static const uint32_t kOverlappingStreamSsrcs[] = {4, 3, 5};
3804 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); 3804 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
3805 3805
3806 StreamParams sp = 3806 StreamParams sp =
3807 cricket::CreateSimStreamParams("cname", MAKE_VECTOR(kFirstStreamSsrcs)); 3807 cricket::CreateSimStreamParams("cname", MAKE_VECTOR(kFirstStreamSsrcs));
3808 3808
3809 EXPECT_TRUE(channel_->AddSendStream(sp)); 3809 EXPECT_TRUE(channel_->AddSendStream(sp));
3810 EXPECT_TRUE(channel_->AddRecvStream(sp)); 3810 EXPECT_TRUE(channel_->AddRecvStream(sp));
3811 3811
3812 // One of the SSRCs is already used in previous streams, using it should fail. 3812 // One of the SSRCs is already used in previous streams, using it should fail.
3813 sp = cricket::CreateSimStreamParams("cname", 3813 sp = cricket::CreateSimStreamParams("cname",
3814 MAKE_VECTOR(kOverlappingStreamSsrcs)); 3814 MAKE_VECTOR(kOverlappingStreamSsrcs));
3815 EXPECT_FALSE(channel_->AddSendStream(sp)); 3815 EXPECT_FALSE(channel_->AddSendStream(sp));
3816 EXPECT_FALSE(channel_->AddRecvStream(sp)); 3816 EXPECT_FALSE(channel_->AddRecvStream(sp));
3817 3817
3818 // After removing the original stream this should be fine to add (makes sure 3818 // After removing the original stream this should be fine to add (makes sure
3819 // that RTX ssrcs are not forever taken). 3819 // that RTX ssrcs are not forever taken).
3820 EXPECT_TRUE(channel_->RemoveSendStream(kFirstStreamSsrcs[0])); 3820 EXPECT_TRUE(channel_->RemoveSendStream(kFirstStreamSsrcs[0]));
3821 EXPECT_TRUE(channel_->RemoveRecvStream(kFirstStreamSsrcs[0])); 3821 EXPECT_TRUE(channel_->RemoveRecvStream(kFirstStreamSsrcs[0]));
3822 EXPECT_TRUE(channel_->AddSendStream(sp)); 3822 EXPECT_TRUE(channel_->AddSendStream(sp));
3823 EXPECT_TRUE(channel_->AddRecvStream(sp)); 3823 EXPECT_TRUE(channel_->AddRecvStream(sp));
3824 } 3824 }
3825 3825
3826 TEST_F(WebRtcVideoChannel2Test, ReportsSsrcGroupsInStats) { 3826 TEST_F(WebRtcVideoChannelTest, ReportsSsrcGroupsInStats) {
3827 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); 3827 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
3828 3828
3829 static const uint32_t kSenderSsrcs[] = {4, 7, 10}; 3829 static const uint32_t kSenderSsrcs[] = {4, 7, 10};
3830 static const uint32_t kSenderRtxSsrcs[] = {5, 8, 11}; 3830 static const uint32_t kSenderRtxSsrcs[] = {5, 8, 11};
3831 3831
3832 StreamParams sender_sp = cricket::CreateSimWithRtxStreamParams( 3832 StreamParams sender_sp = cricket::CreateSimWithRtxStreamParams(
3833 "cname", MAKE_VECTOR(kSenderSsrcs), MAKE_VECTOR(kSenderRtxSsrcs)); 3833 "cname", MAKE_VECTOR(kSenderSsrcs), MAKE_VECTOR(kSenderRtxSsrcs));
3834 3834
3835 EXPECT_TRUE(channel_->AddSendStream(sender_sp)); 3835 EXPECT_TRUE(channel_->AddSendStream(sender_sp));
3836 3836
3837 static const uint32_t kReceiverSsrcs[] = {3}; 3837 static const uint32_t kReceiverSsrcs[] = {3};
3838 static const uint32_t kReceiverRtxSsrcs[] = {2}; 3838 static const uint32_t kReceiverRtxSsrcs[] = {2};
3839 3839
3840 StreamParams receiver_sp = cricket::CreateSimWithRtxStreamParams( 3840 StreamParams receiver_sp = cricket::CreateSimWithRtxStreamParams(
3841 "cname", MAKE_VECTOR(kReceiverSsrcs), MAKE_VECTOR(kReceiverRtxSsrcs)); 3841 "cname", MAKE_VECTOR(kReceiverSsrcs), MAKE_VECTOR(kReceiverRtxSsrcs));
3842 EXPECT_TRUE(channel_->AddRecvStream(receiver_sp)); 3842 EXPECT_TRUE(channel_->AddRecvStream(receiver_sp));
3843 3843
3844 cricket::VideoMediaInfo info; 3844 cricket::VideoMediaInfo info;
3845 ASSERT_TRUE(channel_->GetStats(&info)); 3845 ASSERT_TRUE(channel_->GetStats(&info));
3846 3846
3847 ASSERT_EQ(1u, info.senders.size()); 3847 ASSERT_EQ(1u, info.senders.size());
3848 ASSERT_EQ(1u, info.receivers.size()); 3848 ASSERT_EQ(1u, info.receivers.size());
3849 3849
3850 EXPECT_NE(sender_sp.ssrc_groups, receiver_sp.ssrc_groups); 3850 EXPECT_NE(sender_sp.ssrc_groups, receiver_sp.ssrc_groups);
3851 EXPECT_EQ(sender_sp.ssrc_groups, info.senders[0].ssrc_groups); 3851 EXPECT_EQ(sender_sp.ssrc_groups, info.senders[0].ssrc_groups);
3852 EXPECT_EQ(receiver_sp.ssrc_groups, info.receivers[0].ssrc_groups); 3852 EXPECT_EQ(receiver_sp.ssrc_groups, info.receivers[0].ssrc_groups);
3853 } 3853 }
3854 3854
3855 TEST_F(WebRtcVideoChannel2Test, MapsReceivedPayloadTypeToCodecName) { 3855 TEST_F(WebRtcVideoChannelTest, MapsReceivedPayloadTypeToCodecName) {
3856 FakeVideoReceiveStream* stream = AddRecvStream(); 3856 FakeVideoReceiveStream* stream = AddRecvStream();
3857 webrtc::VideoReceiveStream::Stats stats; 3857 webrtc::VideoReceiveStream::Stats stats;
3858 cricket::VideoMediaInfo info; 3858 cricket::VideoMediaInfo info;
3859 3859
3860 // Report no codec name before receiving. 3860 // Report no codec name before receiving.
3861 stream->SetStats(stats); 3861 stream->SetStats(stats);
3862 ASSERT_TRUE(channel_->GetStats(&info)); 3862 ASSERT_TRUE(channel_->GetStats(&info));
3863 EXPECT_STREQ("", info.receivers[0].codec_name.c_str()); 3863 EXPECT_STREQ("", info.receivers[0].codec_name.c_str());
3864 3864
3865 // Report VP8 if we're receiving it. 3865 // Report VP8 if we're receiving it.
3866 stats.current_payload_type = GetEngineCodec("VP8").id; 3866 stats.current_payload_type = GetEngineCodec("VP8").id;
3867 stream->SetStats(stats); 3867 stream->SetStats(stats);
3868 ASSERT_TRUE(channel_->GetStats(&info)); 3868 ASSERT_TRUE(channel_->GetStats(&info));
3869 EXPECT_STREQ(kVp8CodecName, info.receivers[0].codec_name.c_str()); 3869 EXPECT_STREQ(kVp8CodecName, info.receivers[0].codec_name.c_str());
3870 3870
3871 // Report no codec name for unknown playload types. 3871 // Report no codec name for unknown playload types.
3872 stats.current_payload_type = 3; 3872 stats.current_payload_type = 3;
3873 stream->SetStats(stats); 3873 stream->SetStats(stats);
3874 ASSERT_TRUE(channel_->GetStats(&info)); 3874 ASSERT_TRUE(channel_->GetStats(&info));
3875 EXPECT_STREQ("", info.receivers[0].codec_name.c_str()); 3875 EXPECT_STREQ("", info.receivers[0].codec_name.c_str());
3876 } 3876 }
3877 3877
3878 void WebRtcVideoChannel2Test::TestReceiveUnsignaledSsrcPacket( 3878 void WebRtcVideoChannelTest::TestReceiveUnsignaledSsrcPacket(
3879 uint8_t payload_type, 3879 uint8_t payload_type,
3880 bool expect_created_receive_stream) { 3880 bool expect_created_receive_stream) {
3881 // kRedRtxPayloadType must currently be unused. 3881 // kRedRtxPayloadType must currently be unused.
3882 EXPECT_FALSE(FindCodecById(engine_.codecs(), kRedRtxPayloadType)); 3882 EXPECT_FALSE(FindCodecById(engine_.codecs(), kRedRtxPayloadType));
3883 3883
3884 // Add a RED RTX codec. 3884 // Add a RED RTX codec.
3885 VideoCodec red_rtx_codec = 3885 VideoCodec red_rtx_codec =
3886 VideoCodec::CreateRtxCodec(kRedRtxPayloadType, GetEngineCodec("red").id); 3886 VideoCodec::CreateRtxCodec(kRedRtxPayloadType, GetEngineCodec("red").id);
3887 recv_parameters_.codecs.push_back(red_rtx_codec); 3887 recv_parameters_.codecs.push_back(red_rtx_codec);
3888 EXPECT_TRUE(channel_->SetRecvParameters(recv_parameters_)); 3888 EXPECT_TRUE(channel_->SetRecvParameters(recv_parameters_));
(...skipping 13 matching lines...) Expand all
3902 EXPECT_EQ(1u, fake_call_->GetVideoReceiveStreams().size()) 3902 EXPECT_EQ(1u, fake_call_->GetVideoReceiveStreams().size())
3903 << "Should have created a receive stream for payload type: " 3903 << "Should have created a receive stream for payload type: "
3904 << payload_type; 3904 << payload_type;
3905 } else { 3905 } else {
3906 EXPECT_EQ(0u, fake_call_->GetVideoReceiveStreams().size()) 3906 EXPECT_EQ(0u, fake_call_->GetVideoReceiveStreams().size())
3907 << "Shouldn't have created a receive stream for payload type: " 3907 << "Shouldn't have created a receive stream for payload type: "
3908 << payload_type; 3908 << payload_type;
3909 } 3909 }
3910 } 3910 }
3911 3911
3912 TEST_F(WebRtcVideoChannel2Test, Vp8PacketCreatesUnsignalledStream) { 3912 TEST_F(WebRtcVideoChannelTest, Vp8PacketCreatesUnsignalledStream) {
3913 TestReceiveUnsignaledSsrcPacket(GetEngineCodec("VP8").id, 3913 TestReceiveUnsignaledSsrcPacket(GetEngineCodec("VP8").id,
3914 true /* expect_created_receive_stream */); 3914 true /* expect_created_receive_stream */);
3915 } 3915 }
3916 3916
3917 TEST_F(WebRtcVideoChannel2Test, Vp9PacketCreatesUnsignalledStream) { 3917 TEST_F(WebRtcVideoChannelTest, Vp9PacketCreatesUnsignalledStream) {
3918 TestReceiveUnsignaledSsrcPacket(GetEngineCodec("VP9").id, 3918 TestReceiveUnsignaledSsrcPacket(GetEngineCodec("VP9").id,
3919 true /* expect_created_receive_stream */); 3919 true /* expect_created_receive_stream */);
3920 } 3920 }
3921 3921
3922 TEST_F(WebRtcVideoChannel2Test, RtxPacketDoesntCreateUnsignalledStream) { 3922 TEST_F(WebRtcVideoChannelTest, RtxPacketDoesntCreateUnsignalledStream) {
3923 const cricket::VideoCodec vp8 = GetEngineCodec("VP8"); 3923 const cricket::VideoCodec vp8 = GetEngineCodec("VP8");
3924 const int rtx_vp8_payload_type = default_apt_rtx_types_[vp8.id]; 3924 const int rtx_vp8_payload_type = default_apt_rtx_types_[vp8.id];
3925 TestReceiveUnsignaledSsrcPacket(rtx_vp8_payload_type, 3925 TestReceiveUnsignaledSsrcPacket(rtx_vp8_payload_type,
3926 false /* expect_created_receive_stream */); 3926 false /* expect_created_receive_stream */);
3927 } 3927 }
3928 3928
3929 TEST_F(WebRtcVideoChannel2Test, UlpfecPacketDoesntCreateUnsignalledStream) { 3929 TEST_F(WebRtcVideoChannelTest, UlpfecPacketDoesntCreateUnsignalledStream) {
3930 TestReceiveUnsignaledSsrcPacket(GetEngineCodec("ulpfec").id, 3930 TestReceiveUnsignaledSsrcPacket(GetEngineCodec("ulpfec").id,
3931 false /* expect_created_receive_stream */); 3931 false /* expect_created_receive_stream */);
3932 } 3932 }
3933 3933
3934 TEST_F(WebRtcVideoChannel2FlexfecRecvTest, 3934 TEST_F(WebRtcVideoChannelFlexfecRecvTest,
3935 FlexfecPacketDoesntCreateUnsignalledStream) { 3935 FlexfecPacketDoesntCreateUnsignalledStream) {
3936 TestReceiveUnsignaledSsrcPacket(GetEngineCodec("flexfec-03").id, 3936 TestReceiveUnsignaledSsrcPacket(GetEngineCodec("flexfec-03").id,
3937 false /* expect_created_receive_stream */); 3937 false /* expect_created_receive_stream */);
3938 } 3938 }
3939 3939
3940 TEST_F(WebRtcVideoChannel2Test, RedRtxPacketDoesntCreateUnsignalledStream) { 3940 TEST_F(WebRtcVideoChannelTest, RedRtxPacketDoesntCreateUnsignalledStream) {
3941 TestReceiveUnsignaledSsrcPacket(kRedRtxPayloadType, 3941 TestReceiveUnsignaledSsrcPacket(kRedRtxPayloadType,
3942 false /* expect_created_receive_stream */); 3942 false /* expect_created_receive_stream */);
3943 } 3943 }
3944 3944
3945 // Test that receiving any unsignalled SSRC works even if it changes. 3945 // Test that receiving any unsignalled SSRC works even if it changes.
3946 // The first unsignalled SSRC received will create a default receive stream. 3946 // The first unsignalled SSRC received will create a default receive stream.
3947 // Any different unsignalled SSRC received will replace the default. 3947 // Any different unsignalled SSRC received will replace the default.
3948 TEST_F(WebRtcVideoChannel2Test, ReceiveDifferentUnsignaledSsrc) { 3948 TEST_F(WebRtcVideoChannelTest, ReceiveDifferentUnsignaledSsrc) {
3949 // Allow receiving VP8, VP9, H264 (if enabled). 3949 // Allow receiving VP8, VP9, H264 (if enabled).
3950 cricket::VideoRecvParameters parameters; 3950 cricket::VideoRecvParameters parameters;
3951 parameters.codecs.push_back(GetEngineCodec("VP8")); 3951 parameters.codecs.push_back(GetEngineCodec("VP8"));
3952 parameters.codecs.push_back(GetEngineCodec("VP9")); 3952 parameters.codecs.push_back(GetEngineCodec("VP9"));
3953 3953
3954 #if defined(WEBRTC_USE_H264) 3954 #if defined(WEBRTC_USE_H264)
3955 cricket::VideoCodec H264codec(126, "H264"); 3955 cricket::VideoCodec H264codec(126, "H264");
3956 parameters.codecs.push_back(H264codec); 3956 parameters.codecs.push_back(H264codec);
3957 #endif 3957 #endif
3958 3958
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
4014 webrtc::VideoFrame video_frame3(CreateBlackFrameBuffer(4, 4), 300, 0, 4014 webrtc::VideoFrame video_frame3(CreateBlackFrameBuffer(4, 4), 300, 0,
4015 webrtc::kVideoRotation_0); 4015 webrtc::kVideoRotation_0);
4016 recv_stream->InjectFrame(video_frame3); 4016 recv_stream->InjectFrame(video_frame3);
4017 EXPECT_EQ(3, renderer.num_rendered_frames()); 4017 EXPECT_EQ(3, renderer.num_rendered_frames());
4018 #endif 4018 #endif
4019 } 4019 }
4020 4020
4021 // This test verifies that when a new default stream is created for a new 4021 // This test verifies that when a new default stream is created for a new
4022 // unsignaled SSRC, the new stream does not overwrite any old stream that had 4022 // unsignaled SSRC, the new stream does not overwrite any old stream that had
4023 // been the default receive stream before being properly signaled. 4023 // been the default receive stream before being properly signaled.
4024 TEST_F(WebRtcVideoChannel2Test, 4024 TEST_F(WebRtcVideoChannelTest,
4025 NewUnsignaledStreamDoesNotDestroyPreviouslyUnsignaledStream) { 4025 NewUnsignaledStreamDoesNotDestroyPreviouslyUnsignaledStream) {
4026 cricket::VideoRecvParameters parameters; 4026 cricket::VideoRecvParameters parameters;
4027 parameters.codecs.push_back(GetEngineCodec("VP8")); 4027 parameters.codecs.push_back(GetEngineCodec("VP8"));
4028 ASSERT_TRUE(channel_->SetRecvParameters(parameters)); 4028 ASSERT_TRUE(channel_->SetRecvParameters(parameters));
4029 4029
4030 // No streams signaled and no packets received, so we should not have any 4030 // No streams signaled and no packets received, so we should not have any
4031 // stream objects created yet. 4031 // stream objects created yet.
4032 EXPECT_EQ(0u, fake_call_->GetVideoReceiveStreams().size()); 4032 EXPECT_EQ(0u, fake_call_->GetVideoReceiveStreams().size());
4033 4033
4034 // Receive packet on an unsignaled SSRC. 4034 // Receive packet on an unsignaled SSRC.
(...skipping 25 matching lines...) Expand all
4060 packet.SetData(data, sizeof(data)); 4060 packet.SetData(data, sizeof(data));
4061 channel_->OnPacketReceived(&packet, packet_time); 4061 channel_->OnPacketReceived(&packet, packet_time);
4062 // New default receive stream should be created, but old stream should remain. 4062 // New default receive stream should be created, but old stream should remain.
4063 ASSERT_EQ(2u, fake_call_->GetVideoReceiveStreams().size()); 4063 ASSERT_EQ(2u, fake_call_->GetVideoReceiveStreams().size());
4064 EXPECT_EQ(recv_stream0, fake_call_->GetVideoReceiveStreams()[0]); 4064 EXPECT_EQ(recv_stream0, fake_call_->GetVideoReceiveStreams()[0]);
4065 FakeVideoReceiveStream* recv_stream1 = 4065 FakeVideoReceiveStream* recv_stream1 =
4066 fake_call_->GetVideoReceiveStreams()[1]; 4066 fake_call_->GetVideoReceiveStreams()[1];
4067 EXPECT_EQ(kSsrcs3[1], recv_stream1->GetConfig().rtp.remote_ssrc); 4067 EXPECT_EQ(kSsrcs3[1], recv_stream1->GetConfig().rtp.remote_ssrc);
4068 } 4068 }
4069 4069
4070 TEST_F(WebRtcVideoChannel2Test, CanSentMaxBitrateForExistingStream) { 4070 TEST_F(WebRtcVideoChannelTest, CanSentMaxBitrateForExistingStream) {
4071 AddSendStream(); 4071 AddSendStream();
4072 4072
4073 cricket::FakeVideoCapturer capturer; 4073 cricket::FakeVideoCapturer capturer;
4074 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, &capturer)); 4074 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, &capturer));
4075 cricket::VideoFormat capture_format_hd = 4075 cricket::VideoFormat capture_format_hd =
4076 capturer.GetSupportedFormats()->front(); 4076 capturer.GetSupportedFormats()->front();
4077 EXPECT_EQ(1280, capture_format_hd.width); 4077 EXPECT_EQ(1280, capture_format_hd.width);
4078 EXPECT_EQ(720, capture_format_hd.height); 4078 EXPECT_EQ(720, capture_format_hd.height);
4079 EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(capture_format_hd)); 4079 EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(capture_format_hd));
4080 EXPECT_TRUE(channel_->SetSend(true)); 4080 EXPECT_TRUE(channel_->SetSend(true));
(...skipping 11 matching lines...) Expand all
4092 4092
4093 SetAndExpectMaxBitrate(1000, 0, 1000); 4093 SetAndExpectMaxBitrate(1000, 0, 1000);
4094 SetAndExpectMaxBitrate(1000, 800, 800); 4094 SetAndExpectMaxBitrate(1000, 800, 800);
4095 SetAndExpectMaxBitrate(600, 800, 600); 4095 SetAndExpectMaxBitrate(600, 800, 600);
4096 SetAndExpectMaxBitrate(0, 800, 800); 4096 SetAndExpectMaxBitrate(0, 800, 800);
4097 SetAndExpectMaxBitrate(0, 0, default_encoder_bitrate); 4097 SetAndExpectMaxBitrate(0, 0, default_encoder_bitrate);
4098 4098
4099 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); 4099 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr));
4100 } 4100 }
4101 4101
4102 TEST_F(WebRtcVideoChannel2Test, CannotSetMaxBitrateForNonexistentStream) { 4102 TEST_F(WebRtcVideoChannelTest, CannotSetMaxBitrateForNonexistentStream) {
4103 webrtc::RtpParameters nonexistent_parameters = 4103 webrtc::RtpParameters nonexistent_parameters =
4104 channel_->GetRtpSendParameters(last_ssrc_); 4104 channel_->GetRtpSendParameters(last_ssrc_);
4105 EXPECT_EQ(0, nonexistent_parameters.encodings.size()); 4105 EXPECT_EQ(0, nonexistent_parameters.encodings.size());
4106 4106
4107 nonexistent_parameters.encodings.push_back(webrtc::RtpEncodingParameters()); 4107 nonexistent_parameters.encodings.push_back(webrtc::RtpEncodingParameters());
4108 EXPECT_FALSE( 4108 EXPECT_FALSE(
4109 channel_->SetRtpSendParameters(last_ssrc_, nonexistent_parameters)); 4109 channel_->SetRtpSendParameters(last_ssrc_, nonexistent_parameters));
4110 } 4110 }
4111 4111
4112 TEST_F(WebRtcVideoChannel2Test, 4112 TEST_F(WebRtcVideoChannelTest,
4113 CannotSetRtpSendParametersWithIncorrectNumberOfEncodings) { 4113 CannotSetRtpSendParametersWithIncorrectNumberOfEncodings) {
4114 // This test verifies that setting RtpParameters succeeds only if 4114 // This test verifies that setting RtpParameters succeeds only if
4115 // the structure contains exactly one encoding. 4115 // the structure contains exactly one encoding.
4116 // TODO(skvlad): Update this test when we start supporting setting parameters 4116 // TODO(skvlad): Update this test when we start supporting setting parameters
4117 // for each encoding individually. 4117 // for each encoding individually.
4118 4118
4119 AddSendStream(); 4119 AddSendStream();
4120 webrtc::RtpParameters parameters = channel_->GetRtpSendParameters(last_ssrc_); 4120 webrtc::RtpParameters parameters = channel_->GetRtpSendParameters(last_ssrc_);
4121 // Two or more encodings should result in failure. 4121 // Two or more encodings should result in failure.
4122 parameters.encodings.push_back(webrtc::RtpEncodingParameters()); 4122 parameters.encodings.push_back(webrtc::RtpEncodingParameters());
4123 EXPECT_FALSE(channel_->SetRtpSendParameters(last_ssrc_, parameters)); 4123 EXPECT_FALSE(channel_->SetRtpSendParameters(last_ssrc_, parameters));
4124 // Zero encodings should also fail. 4124 // Zero encodings should also fail.
4125 parameters.encodings.clear(); 4125 parameters.encodings.clear();
4126 EXPECT_FALSE(channel_->SetRtpSendParameters(last_ssrc_, parameters)); 4126 EXPECT_FALSE(channel_->SetRtpSendParameters(last_ssrc_, parameters));
4127 } 4127 }
4128 4128
4129 // Changing the SSRC through RtpParameters is not allowed. 4129 // Changing the SSRC through RtpParameters is not allowed.
4130 TEST_F(WebRtcVideoChannel2Test, CannotSetSsrcInRtpSendParameters) { 4130 TEST_F(WebRtcVideoChannelTest, CannotSetSsrcInRtpSendParameters) {
4131 AddSendStream(); 4131 AddSendStream();
4132 webrtc::RtpParameters parameters = channel_->GetRtpSendParameters(last_ssrc_); 4132 webrtc::RtpParameters parameters = channel_->GetRtpSendParameters(last_ssrc_);
4133 parameters.encodings[0].ssrc = rtc::Optional<uint32_t>(0xdeadbeef); 4133 parameters.encodings[0].ssrc = rtc::Optional<uint32_t>(0xdeadbeef);
4134 EXPECT_FALSE(channel_->SetRtpSendParameters(last_ssrc_, parameters)); 4134 EXPECT_FALSE(channel_->SetRtpSendParameters(last_ssrc_, parameters));
4135 } 4135 }
4136 4136
4137 // Test that a stream will not be sending if its encoding is made inactive 4137 // Test that a stream will not be sending if its encoding is made inactive
4138 // through SetRtpSendParameters. 4138 // through SetRtpSendParameters.
4139 // TODO(deadbeef): Update this test when we start supporting setting parameters 4139 // TODO(deadbeef): Update this test when we start supporting setting parameters
4140 // for each encoding individually. 4140 // for each encoding individually.
4141 TEST_F(WebRtcVideoChannel2Test, SetRtpSendParametersEncodingsActive) { 4141 TEST_F(WebRtcVideoChannelTest, SetRtpSendParametersEncodingsActive) {
4142 FakeVideoSendStream* stream = AddSendStream(); 4142 FakeVideoSendStream* stream = AddSendStream();
4143 EXPECT_TRUE(channel_->SetSend(true)); 4143 EXPECT_TRUE(channel_->SetSend(true));
4144 EXPECT_TRUE(stream->IsSending()); 4144 EXPECT_TRUE(stream->IsSending());
4145 4145
4146 // Get current parameters and change "active" to false. 4146 // Get current parameters and change "active" to false.
4147 webrtc::RtpParameters parameters = channel_->GetRtpSendParameters(last_ssrc_); 4147 webrtc::RtpParameters parameters = channel_->GetRtpSendParameters(last_ssrc_);
4148 ASSERT_EQ(1u, parameters.encodings.size()); 4148 ASSERT_EQ(1u, parameters.encodings.size());
4149 ASSERT_TRUE(parameters.encodings[0].active); 4149 ASSERT_TRUE(parameters.encodings[0].active);
4150 parameters.encodings[0].active = false; 4150 parameters.encodings[0].active = false;
4151 EXPECT_TRUE(channel_->SetRtpSendParameters(last_ssrc_, parameters)); 4151 EXPECT_TRUE(channel_->SetRtpSendParameters(last_ssrc_, parameters));
4152 EXPECT_FALSE(stream->IsSending()); 4152 EXPECT_FALSE(stream->IsSending());
4153 4153
4154 // Now change it back to active and verify we resume sending. 4154 // Now change it back to active and verify we resume sending.
4155 parameters.encodings[0].active = true; 4155 parameters.encodings[0].active = true;
4156 EXPECT_TRUE(channel_->SetRtpSendParameters(last_ssrc_, parameters)); 4156 EXPECT_TRUE(channel_->SetRtpSendParameters(last_ssrc_, parameters));
4157 EXPECT_TRUE(stream->IsSending()); 4157 EXPECT_TRUE(stream->IsSending());
4158 } 4158 }
4159 4159
4160 // Test that if a stream is reconfigured (due to a codec change or other 4160 // Test that if a stream is reconfigured (due to a codec change or other
4161 // change) while its encoding is still inactive, it doesn't start sending. 4161 // change) while its encoding is still inactive, it doesn't start sending.
4162 TEST_F(WebRtcVideoChannel2Test, 4162 TEST_F(WebRtcVideoChannelTest,
4163 InactiveStreamDoesntStartSendingWhenReconfigured) { 4163 InactiveStreamDoesntStartSendingWhenReconfigured) {
4164 // Set an initial codec list, which will be modified later. 4164 // Set an initial codec list, which will be modified later.
4165 cricket::VideoSendParameters parameters1; 4165 cricket::VideoSendParameters parameters1;
4166 parameters1.codecs.push_back(GetEngineCodec("VP8")); 4166 parameters1.codecs.push_back(GetEngineCodec("VP8"));
4167 parameters1.codecs.push_back(GetEngineCodec("VP9")); 4167 parameters1.codecs.push_back(GetEngineCodec("VP9"));
4168 EXPECT_TRUE(channel_->SetSendParameters(parameters1)); 4168 EXPECT_TRUE(channel_->SetSendParameters(parameters1));
4169 4169
4170 FakeVideoSendStream* stream = AddSendStream(); 4170 FakeVideoSendStream* stream = AddSendStream();
4171 EXPECT_TRUE(channel_->SetSend(true)); 4171 EXPECT_TRUE(channel_->SetSend(true));
4172 EXPECT_TRUE(stream->IsSending()); 4172 EXPECT_TRUE(stream->IsSending());
(...skipping 18 matching lines...) Expand all
4191 // Otherwise, this test isn't testing what it set out to test. 4191 // Otherwise, this test isn't testing what it set out to test.
4192 EXPECT_EQ(1u, GetFakeSendStreams().size()); 4192 EXPECT_EQ(1u, GetFakeSendStreams().size());
4193 EXPECT_EQ(2, fake_call_->GetNumCreatedSendStreams()); 4193 EXPECT_EQ(2, fake_call_->GetNumCreatedSendStreams());
4194 4194
4195 // Verify that we still are not sending anything, due to the inactive 4195 // Verify that we still are not sending anything, due to the inactive
4196 // encoding. 4196 // encoding.
4197 EXPECT_FALSE(new_streams[0]->IsSending()); 4197 EXPECT_FALSE(new_streams[0]->IsSending());
4198 } 4198 }
4199 4199
4200 // Test that GetRtpSendParameters returns the currently configured codecs. 4200 // Test that GetRtpSendParameters returns the currently configured codecs.
4201 TEST_F(WebRtcVideoChannel2Test, GetRtpSendParametersCodecs) { 4201 TEST_F(WebRtcVideoChannelTest, GetRtpSendParametersCodecs) {
4202 AddSendStream(); 4202 AddSendStream();
4203 cricket::VideoSendParameters parameters; 4203 cricket::VideoSendParameters parameters;
4204 parameters.codecs.push_back(GetEngineCodec("VP8")); 4204 parameters.codecs.push_back(GetEngineCodec("VP8"));
4205 parameters.codecs.push_back(GetEngineCodec("VP9")); 4205 parameters.codecs.push_back(GetEngineCodec("VP9"));
4206 EXPECT_TRUE(channel_->SetSendParameters(parameters)); 4206 EXPECT_TRUE(channel_->SetSendParameters(parameters));
4207 4207
4208 webrtc::RtpParameters rtp_parameters = 4208 webrtc::RtpParameters rtp_parameters =
4209 channel_->GetRtpSendParameters(last_ssrc_); 4209 channel_->GetRtpSendParameters(last_ssrc_);
4210 ASSERT_EQ(2u, rtp_parameters.codecs.size()); 4210 ASSERT_EQ(2u, rtp_parameters.codecs.size());
4211 EXPECT_EQ(GetEngineCodec("VP8").ToCodecParameters(), 4211 EXPECT_EQ(GetEngineCodec("VP8").ToCodecParameters(),
4212 rtp_parameters.codecs[0]); 4212 rtp_parameters.codecs[0]);
4213 EXPECT_EQ(GetEngineCodec("VP9").ToCodecParameters(), 4213 EXPECT_EQ(GetEngineCodec("VP9").ToCodecParameters(),
4214 rtp_parameters.codecs[1]); 4214 rtp_parameters.codecs[1]);
4215 } 4215 }
4216 4216
4217 // Test that RtpParameters for send stream has one encoding and it has 4217 // Test that RtpParameters for send stream has one encoding and it has
4218 // the correct SSRC. 4218 // the correct SSRC.
4219 TEST_F(WebRtcVideoChannel2Test, GetRtpSendParametersSsrc) { 4219 TEST_F(WebRtcVideoChannelTest, GetRtpSendParametersSsrc) {
4220 AddSendStream(); 4220 AddSendStream();
4221 4221
4222 webrtc::RtpParameters rtp_parameters = 4222 webrtc::RtpParameters rtp_parameters =
4223 channel_->GetRtpSendParameters(last_ssrc_); 4223 channel_->GetRtpSendParameters(last_ssrc_);
4224 ASSERT_EQ(1u, rtp_parameters.encodings.size()); 4224 ASSERT_EQ(1u, rtp_parameters.encodings.size());
4225 EXPECT_EQ(rtc::Optional<uint32_t>(last_ssrc_), 4225 EXPECT_EQ(rtc::Optional<uint32_t>(last_ssrc_),
4226 rtp_parameters.encodings[0].ssrc); 4226 rtp_parameters.encodings[0].ssrc);
4227 } 4227 }
4228 4228
4229 // Test that if we set/get parameters multiple times, we get the same results. 4229 // Test that if we set/get parameters multiple times, we get the same results.
4230 TEST_F(WebRtcVideoChannel2Test, SetAndGetRtpSendParameters) { 4230 TEST_F(WebRtcVideoChannelTest, SetAndGetRtpSendParameters) {
4231 AddSendStream(); 4231 AddSendStream();
4232 cricket::VideoSendParameters parameters; 4232 cricket::VideoSendParameters parameters;
4233 parameters.codecs.push_back(GetEngineCodec("VP8")); 4233 parameters.codecs.push_back(GetEngineCodec("VP8"));
4234 parameters.codecs.push_back(GetEngineCodec("VP9")); 4234 parameters.codecs.push_back(GetEngineCodec("VP9"));
4235 EXPECT_TRUE(channel_->SetSendParameters(parameters)); 4235 EXPECT_TRUE(channel_->SetSendParameters(parameters));
4236 4236
4237 webrtc::RtpParameters initial_params = 4237 webrtc::RtpParameters initial_params =
4238 channel_->GetRtpSendParameters(last_ssrc_); 4238 channel_->GetRtpSendParameters(last_ssrc_);
4239 4239
4240 // We should be able to set the params we just got. 4240 // We should be able to set the params we just got.
4241 EXPECT_TRUE(channel_->SetRtpSendParameters(last_ssrc_, initial_params)); 4241 EXPECT_TRUE(channel_->SetRtpSendParameters(last_ssrc_, initial_params));
4242 4242
4243 // ... And this shouldn't change the params returned by GetRtpSendParameters. 4243 // ... And this shouldn't change the params returned by GetRtpSendParameters.
4244 EXPECT_EQ(initial_params, channel_->GetRtpSendParameters(last_ssrc_)); 4244 EXPECT_EQ(initial_params, channel_->GetRtpSendParameters(last_ssrc_));
4245 } 4245 }
4246 4246
4247 // Test that GetRtpReceiveParameters returns the currently configured codecs. 4247 // Test that GetRtpReceiveParameters returns the currently configured codecs.
4248 TEST_F(WebRtcVideoChannel2Test, GetRtpReceiveParametersCodecs) { 4248 TEST_F(WebRtcVideoChannelTest, GetRtpReceiveParametersCodecs) {
4249 AddRecvStream(); 4249 AddRecvStream();
4250 cricket::VideoRecvParameters parameters; 4250 cricket::VideoRecvParameters parameters;
4251 parameters.codecs.push_back(GetEngineCodec("VP8")); 4251 parameters.codecs.push_back(GetEngineCodec("VP8"));
4252 parameters.codecs.push_back(GetEngineCodec("VP9")); 4252 parameters.codecs.push_back(GetEngineCodec("VP9"));
4253 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); 4253 EXPECT_TRUE(channel_->SetRecvParameters(parameters));
4254 4254
4255 webrtc::RtpParameters rtp_parameters = 4255 webrtc::RtpParameters rtp_parameters =
4256 channel_->GetRtpReceiveParameters(last_ssrc_); 4256 channel_->GetRtpReceiveParameters(last_ssrc_);
4257 ASSERT_EQ(2u, rtp_parameters.codecs.size()); 4257 ASSERT_EQ(2u, rtp_parameters.codecs.size());
4258 EXPECT_EQ(GetEngineCodec("VP8").ToCodecParameters(), 4258 EXPECT_EQ(GetEngineCodec("VP8").ToCodecParameters(),
4259 rtp_parameters.codecs[0]); 4259 rtp_parameters.codecs[0]);
4260 EXPECT_EQ(GetEngineCodec("VP9").ToCodecParameters(), 4260 EXPECT_EQ(GetEngineCodec("VP9").ToCodecParameters(),
4261 rtp_parameters.codecs[1]); 4261 rtp_parameters.codecs[1]);
4262 } 4262 }
4263 4263
4264 #if defined(WEBRTC_USE_H264) 4264 #if defined(WEBRTC_USE_H264)
4265 TEST_F(WebRtcVideoChannel2Test, GetRtpReceiveFmtpSprop) { 4265 TEST_F(WebRtcVideoChannelTest, GetRtpReceiveFmtpSprop) {
4266 #else 4266 #else
4267 TEST_F(WebRtcVideoChannel2Test, DISABLED_GetRtpReceiveFmtpSprop) { 4267 TEST_F(WebRtcVideoChannelTest, DISABLED_GetRtpReceiveFmtpSprop) {
4268 #endif 4268 #endif
4269 cricket::VideoRecvParameters parameters; 4269 cricket::VideoRecvParameters parameters;
4270 cricket::VideoCodec kH264sprop1(101, "H264"); 4270 cricket::VideoCodec kH264sprop1(101, "H264");
4271 kH264sprop1.SetParam(kH264FmtpSpropParameterSets, "uvw"); 4271 kH264sprop1.SetParam(kH264FmtpSpropParameterSets, "uvw");
4272 parameters.codecs.push_back(kH264sprop1); 4272 parameters.codecs.push_back(kH264sprop1);
4273 cricket::VideoCodec kH264sprop2(102, "H264"); 4273 cricket::VideoCodec kH264sprop2(102, "H264");
4274 kH264sprop2.SetParam(kH264FmtpSpropParameterSets, "xyz"); 4274 kH264sprop2.SetParam(kH264FmtpSpropParameterSets, "xyz");
4275 parameters.codecs.push_back(kH264sprop2); 4275 parameters.codecs.push_back(kH264sprop2);
4276 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); 4276 EXPECT_TRUE(channel_->SetRecvParameters(parameters));
4277 4277
(...skipping 14 matching lines...) Expand all
4292 EXPECT_EQ(102, cfg.decoders[1].payload_type); 4292 EXPECT_EQ(102, cfg.decoders[1].payload_type);
4293 EXPECT_EQ("H264", cfg.decoders[1].payload_name); 4293 EXPECT_EQ("H264", cfg.decoders[1].payload_name);
4294 const auto it1 = 4294 const auto it1 =
4295 cfg.decoders[1].codec_params.find(kH264FmtpSpropParameterSets); 4295 cfg.decoders[1].codec_params.find(kH264FmtpSpropParameterSets);
4296 ASSERT_TRUE(it1 != cfg.decoders[1].codec_params.end()); 4296 ASSERT_TRUE(it1 != cfg.decoders[1].codec_params.end());
4297 EXPECT_EQ("xyz", it1->second); 4297 EXPECT_EQ("xyz", it1->second);
4298 } 4298 }
4299 4299
4300 // Test that RtpParameters for receive stream has one encoding and it has 4300 // Test that RtpParameters for receive stream has one encoding and it has
4301 // the correct SSRC. 4301 // the correct SSRC.
4302 TEST_F(WebRtcVideoChannel2Test, GetRtpReceiveParametersSsrc) { 4302 TEST_F(WebRtcVideoChannelTest, GetRtpReceiveParametersSsrc) {
4303 AddRecvStream(); 4303 AddRecvStream();
4304 4304
4305 webrtc::RtpParameters rtp_parameters = 4305 webrtc::RtpParameters rtp_parameters =
4306 channel_->GetRtpReceiveParameters(last_ssrc_); 4306 channel_->GetRtpReceiveParameters(last_ssrc_);
4307 ASSERT_EQ(1u, rtp_parameters.encodings.size()); 4307 ASSERT_EQ(1u, rtp_parameters.encodings.size());
4308 EXPECT_EQ(rtc::Optional<uint32_t>(last_ssrc_), 4308 EXPECT_EQ(rtc::Optional<uint32_t>(last_ssrc_),
4309 rtp_parameters.encodings[0].ssrc); 4309 rtp_parameters.encodings[0].ssrc);
4310 } 4310 }
4311 4311
4312 // Test that if we set/get parameters multiple times, we get the same results. 4312 // Test that if we set/get parameters multiple times, we get the same results.
4313 TEST_F(WebRtcVideoChannel2Test, SetAndGetRtpReceiveParameters) { 4313 TEST_F(WebRtcVideoChannelTest, SetAndGetRtpReceiveParameters) {
4314 AddRecvStream(); 4314 AddRecvStream();
4315 cricket::VideoRecvParameters parameters; 4315 cricket::VideoRecvParameters parameters;
4316 parameters.codecs.push_back(GetEngineCodec("VP8")); 4316 parameters.codecs.push_back(GetEngineCodec("VP8"));
4317 parameters.codecs.push_back(GetEngineCodec("VP9")); 4317 parameters.codecs.push_back(GetEngineCodec("VP9"));
4318 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); 4318 EXPECT_TRUE(channel_->SetRecvParameters(parameters));
4319 4319
4320 webrtc::RtpParameters initial_params = 4320 webrtc::RtpParameters initial_params =
4321 channel_->GetRtpReceiveParameters(last_ssrc_); 4321 channel_->GetRtpReceiveParameters(last_ssrc_);
4322 4322
4323 // We should be able to set the params we just got. 4323 // We should be able to set the params we just got.
4324 EXPECT_TRUE(channel_->SetRtpReceiveParameters(last_ssrc_, initial_params)); 4324 EXPECT_TRUE(channel_->SetRtpReceiveParameters(last_ssrc_, initial_params));
4325 4325
4326 // ... And this shouldn't change the params returned by 4326 // ... And this shouldn't change the params returned by
4327 // GetRtpReceiveParameters. 4327 // GetRtpReceiveParameters.
4328 EXPECT_EQ(initial_params, channel_->GetRtpReceiveParameters(last_ssrc_)); 4328 EXPECT_EQ(initial_params, channel_->GetRtpReceiveParameters(last_ssrc_));
4329 } 4329 }
4330 4330
4331 // Test that GetRtpReceiveParameters returns parameters correctly when SSRCs 4331 // Test that GetRtpReceiveParameters returns parameters correctly when SSRCs
4332 // aren't signaled. It should always return an empty "RtpEncodingParameters", 4332 // aren't signaled. It should always return an empty "RtpEncodingParameters",
4333 // even after a packet is received and the unsignaled SSRC is known. 4333 // even after a packet is received and the unsignaled SSRC is known.
4334 TEST_F(WebRtcVideoChannel2Test, GetRtpReceiveParametersWithUnsignaledSsrc) { 4334 TEST_F(WebRtcVideoChannelTest, GetRtpReceiveParametersWithUnsignaledSsrc) {
4335 // Call necessary methods to configure receiving a default stream as 4335 // Call necessary methods to configure receiving a default stream as
4336 // soon as it arrives. 4336 // soon as it arrives.
4337 cricket::VideoRecvParameters parameters; 4337 cricket::VideoRecvParameters parameters;
4338 parameters.codecs.push_back(GetEngineCodec("VP8")); 4338 parameters.codecs.push_back(GetEngineCodec("VP8"));
4339 parameters.codecs.push_back(GetEngineCodec("VP9")); 4339 parameters.codecs.push_back(GetEngineCodec("VP9"));
4340 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); 4340 EXPECT_TRUE(channel_->SetRecvParameters(parameters));
4341 4341
4342 // Call GetRtpReceiveParameters before configured to receive an unsignaled 4342 // Call GetRtpReceiveParameters before configured to receive an unsignaled
4343 // stream. Should return nothing. 4343 // stream. Should return nothing.
4344 EXPECT_EQ(webrtc::RtpParameters(), channel_->GetRtpReceiveParameters(0)); 4344 EXPECT_EQ(webrtc::RtpParameters(), channel_->GetRtpReceiveParameters(0));
(...skipping 19 matching lines...) Expand all
4364 rtc::CopyOnWriteBuffer packet(data, sizeof(data)); 4364 rtc::CopyOnWriteBuffer packet(data, sizeof(data));
4365 rtc::PacketTime packet_time; 4365 rtc::PacketTime packet_time;
4366 channel_->OnPacketReceived(&packet, packet_time); 4366 channel_->OnPacketReceived(&packet, packet_time);
4367 4367
4368 // The |ssrc| member should still be unset. 4368 // The |ssrc| member should still be unset.
4369 rtp_parameters = channel_->GetRtpReceiveParameters(0); 4369 rtp_parameters = channel_->GetRtpReceiveParameters(0);
4370 ASSERT_EQ(1u, rtp_parameters.encodings.size()); 4370 ASSERT_EQ(1u, rtp_parameters.encodings.size());
4371 EXPECT_FALSE(rtp_parameters.encodings[0].ssrc); 4371 EXPECT_FALSE(rtp_parameters.encodings[0].ssrc);
4372 } 4372 }
4373 4373
4374 void WebRtcVideoChannel2Test::TestReceiverLocalSsrcConfiguration( 4374 void WebRtcVideoChannelTest::TestReceiverLocalSsrcConfiguration(
4375 bool receiver_first) { 4375 bool receiver_first) {
4376 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); 4376 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
4377 4377
4378 const uint32_t kSenderSsrc = 0xC0FFEE; 4378 const uint32_t kSenderSsrc = 0xC0FFEE;
4379 const uint32_t kSecondSenderSsrc = 0xBADCAFE; 4379 const uint32_t kSecondSenderSsrc = 0xBADCAFE;
4380 const uint32_t kReceiverSsrc = 0x4711; 4380 const uint32_t kReceiverSsrc = 0x4711;
4381 const uint32_t kExpectedDefaultReceiverSsrc = 1; 4381 const uint32_t kExpectedDefaultReceiverSsrc = 1;
4382 4382
4383 if (receiver_first) { 4383 if (receiver_first) {
4384 AddRecvStream(StreamParams::CreateLegacy(kReceiverSsrc)); 4384 AddRecvStream(StreamParams::CreateLegacy(kReceiverSsrc));
(...skipping 23 matching lines...) Expand all
4408 4408
4409 // Removing the last sender should fall back to default local SSRC. 4409 // Removing the last sender should fall back to default local SSRC.
4410 ASSERT_TRUE(channel_->RemoveSendStream(kSecondSenderSsrc)); 4410 ASSERT_TRUE(channel_->RemoveSendStream(kSecondSenderSsrc));
4411 receive_streams = 4411 receive_streams =
4412 fake_call_->GetVideoReceiveStreams(); 4412 fake_call_->GetVideoReceiveStreams();
4413 ASSERT_EQ(1u, receive_streams.size()); 4413 ASSERT_EQ(1u, receive_streams.size());
4414 EXPECT_EQ(kExpectedDefaultReceiverSsrc, 4414 EXPECT_EQ(kExpectedDefaultReceiverSsrc,
4415 receive_streams[0]->GetConfig().rtp.local_ssrc); 4415 receive_streams[0]->GetConfig().rtp.local_ssrc);
4416 } 4416 }
4417 4417
4418 TEST_F(WebRtcVideoChannel2Test, ConfiguresLocalSsrc) { 4418 TEST_F(WebRtcVideoChannelTest, ConfiguresLocalSsrc) {
4419 TestReceiverLocalSsrcConfiguration(false); 4419 TestReceiverLocalSsrcConfiguration(false);
4420 } 4420 }
4421 4421
4422 TEST_F(WebRtcVideoChannel2Test, ConfiguresLocalSsrcOnExistingReceivers) { 4422 TEST_F(WebRtcVideoChannelTest, ConfiguresLocalSsrcOnExistingReceivers) {
4423 TestReceiverLocalSsrcConfiguration(true); 4423 TestReceiverLocalSsrcConfiguration(true);
4424 } 4424 }
4425 4425
4426 class WebRtcVideoChannel2SimulcastTest : public testing::Test { 4426 class WebRtcVideoChannelSimulcastTest : public testing::Test {
4427 public: 4427 public:
4428 WebRtcVideoChannel2SimulcastTest() 4428 WebRtcVideoChannelSimulcastTest()
4429 : fake_call_(webrtc::Call::Config(&event_log_)), last_ssrc_(0) {} 4429 : fake_call_(webrtc::Call::Config(&event_log_)), last_ssrc_(0) {}
4430 4430
4431 void SetUp() override { 4431 void SetUp() override {
4432 engine_.Init(); 4432 engine_.Init();
4433 channel_.reset( 4433 channel_.reset(
4434 engine_.CreateChannel(&fake_call_, GetMediaConfig(), VideoOptions())); 4434 engine_.CreateChannel(&fake_call_, GetMediaConfig(), VideoOptions()));
4435 channel_->OnReadyToSend(true); 4435 channel_->OnReadyToSend(true);
4436 last_ssrc_ = 123; 4436 last_ssrc_ = 123;
4437 } 4437 }
4438 4438
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
4578 fake_call_.GetVideoReceiveStreams().size(); 4578 fake_call_.GetVideoReceiveStreams().size();
4579 EXPECT_TRUE(channel_->AddRecvStream(sp)); 4579 EXPECT_TRUE(channel_->AddRecvStream(sp));
4580 std::vector<FakeVideoReceiveStream*> streams = 4580 std::vector<FakeVideoReceiveStream*> streams =
4581 fake_call_.GetVideoReceiveStreams(); 4581 fake_call_.GetVideoReceiveStreams();
4582 EXPECT_EQ(num_streams + 1, streams.size()); 4582 EXPECT_EQ(num_streams + 1, streams.size());
4583 return streams[streams.size() - 1]; 4583 return streams[streams.size() - 1];
4584 } 4584 }
4585 4585
4586 webrtc::RtcEventLogNullImpl event_log_; 4586 webrtc::RtcEventLogNullImpl event_log_;
4587 FakeCall fake_call_; 4587 FakeCall fake_call_;
4588 WebRtcVideoEngine2 engine_; 4588 WebRtcVideoEngine engine_;
4589 std::unique_ptr<VideoMediaChannel> channel_; 4589 std::unique_ptr<VideoMediaChannel> channel_;
4590 uint32_t last_ssrc_; 4590 uint32_t last_ssrc_;
4591 }; 4591 };
4592 4592
4593 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWith2SimulcastStreams) { 4593 TEST_F(WebRtcVideoChannelSimulcastTest, SetSendCodecsWith2SimulcastStreams) {
4594 VerifySimulcastSettings(cricket::VideoCodec("VP8"), 640, 360, 2, 2, false, 4594 VerifySimulcastSettings(cricket::VideoCodec("VP8"), 640, 360, 2, 2, false,
4595 true); 4595 true);
4596 } 4596 }
4597 4597
4598 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWith3SimulcastStreams) { 4598 TEST_F(WebRtcVideoChannelSimulcastTest, SetSendCodecsWith3SimulcastStreams) {
4599 VerifySimulcastSettings(cricket::VideoCodec("VP8"), 1280, 720, 3, 3, false, 4599 VerifySimulcastSettings(cricket::VideoCodec("VP8"), 1280, 720, 3, 3, false,
4600 true); 4600 true);
4601 } 4601 }
4602 4602
4603 // Test that we normalize send codec format size in simulcast. 4603 // Test that we normalize send codec format size in simulcast.
4604 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWithOddSizeInSimulcast) { 4604 TEST_F(WebRtcVideoChannelSimulcastTest, SetSendCodecsWithOddSizeInSimulcast) {
4605 VerifySimulcastSettings(cricket::VideoCodec("VP8"), 541, 271, 2, 2, false, 4605 VerifySimulcastSettings(cricket::VideoCodec("VP8"), 541, 271, 2, 2, false,
4606 true); 4606 true);
4607 } 4607 }
4608 4608
4609 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsForScreenshare) { 4609 TEST_F(WebRtcVideoChannelSimulcastTest, SetSendCodecsForScreenshare) {
4610 VerifySimulcastSettings(cricket::VideoCodec("VP8"), 1280, 720, 3, 1, true, 4610 VerifySimulcastSettings(cricket::VideoCodec("VP8"), 1280, 720, 3, 1, true,
4611 false); 4611 false);
4612 } 4612 }
4613 4613
4614 TEST_F(WebRtcVideoChannel2SimulcastTest, 4614 TEST_F(WebRtcVideoChannelSimulcastTest,
4615 SetSendCodecsForConferenceModeScreenshare) { 4615 SetSendCodecsForConferenceModeScreenshare) {
4616 VerifySimulcastSettings(cricket::VideoCodec("VP8"), 1280, 720, 3, 1, true, 4616 VerifySimulcastSettings(cricket::VideoCodec("VP8"), 1280, 720, 3, 1, true,
4617 true); 4617 true);
4618 } 4618 }
4619 4619
4620 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsForSimulcastScreenshare) { 4620 TEST_F(WebRtcVideoChannelSimulcastTest, SetSendCodecsForSimulcastScreenshare) {
4621 webrtc::test::ScopedFieldTrials override_field_trials_( 4621 webrtc::test::ScopedFieldTrials override_field_trials_(
4622 "WebRTC-SimulcastScreenshare/Enabled/"); 4622 "WebRTC-SimulcastScreenshare/Enabled/");
4623 VerifySimulcastSettings(cricket::VideoCodec("VP8"), 1280, 720, 3, 2, true, 4623 VerifySimulcastSettings(cricket::VideoCodec("VP8"), 1280, 720, 3, 2, true,
4624 true); 4624 true);
4625 } 4625 }
4626 4626
4627 TEST_F(WebRtcVideoChannel2SimulcastTest, 4627 TEST_F(WebRtcVideoChannelSimulcastTest,
4628 NoSimulcastScreenshareWithoutConference) { 4628 NoSimulcastScreenshareWithoutConference) {
4629 webrtc::test::ScopedFieldTrials override_field_trials_( 4629 webrtc::test::ScopedFieldTrials override_field_trials_(
4630 "WebRTC-SimulcastScreenshare/Enabled/"); 4630 "WebRTC-SimulcastScreenshare/Enabled/");
4631 VerifySimulcastSettings(cricket::VideoCodec("VP8"), 1280, 720, 3, 1, true, 4631 VerifySimulcastSettings(cricket::VideoCodec("VP8"), 1280, 720, 3, 1, true,
4632 false); 4632 false);
4633 } 4633 }
4634 4634
4635 } // namespace cricket 4635 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/media/engine/webrtcvideoengine2_unittest.cc ('k') | webrtc/pc/rtpreceiver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698