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

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

Issue 2246313002: If encoding is inactive, don't start sending when stream is reconfigured. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Making a test assertion better (don't compare pointer addresses). Created 4 years, 3 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.cc ('k') | no next file » | 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 3441 matching lines...) Expand 10 before | Expand all | Expand 10 after
3452 parameters.encodings.clear(); 3452 parameters.encodings.clear();
3453 EXPECT_FALSE(channel_->SetRtpSendParameters(last_ssrc_, parameters)); 3453 EXPECT_FALSE(channel_->SetRtpSendParameters(last_ssrc_, parameters));
3454 // Setting RtpParameters with exactly one encoding should succeed. 3454 // Setting RtpParameters with exactly one encoding should succeed.
3455 parameters.encodings.push_back(webrtc::RtpEncodingParameters()); 3455 parameters.encodings.push_back(webrtc::RtpEncodingParameters());
3456 EXPECT_TRUE(channel_->SetRtpSendParameters(last_ssrc_, parameters)); 3456 EXPECT_TRUE(channel_->SetRtpSendParameters(last_ssrc_, parameters));
3457 // Two or more encodings should result in failure. 3457 // Two or more encodings should result in failure.
3458 parameters.encodings.push_back(webrtc::RtpEncodingParameters()); 3458 parameters.encodings.push_back(webrtc::RtpEncodingParameters());
3459 EXPECT_FALSE(channel_->SetRtpSendParameters(last_ssrc_, parameters)); 3459 EXPECT_FALSE(channel_->SetRtpSendParameters(last_ssrc_, parameters));
3460 } 3460 }
3461 3461
3462 // Test that a stream will not be sending if its encoding is made 3462 // Test that a stream will not be sending if its encoding is made inactive
3463 // inactive through SetRtpSendParameters. 3463 // through SetRtpSendParameters.
3464 // TODO(deadbeef): Update this test when we start supporting setting parameters 3464 // TODO(deadbeef): Update this test when we start supporting setting parameters
3465 // for each encoding individually. 3465 // for each encoding individually.
3466 TEST_F(WebRtcVideoChannel2Test, SetRtpSendParametersEncodingsActive) { 3466 TEST_F(WebRtcVideoChannel2Test, SetRtpSendParametersEncodingsActive) {
3467 FakeVideoSendStream* stream = AddSendStream(); 3467 FakeVideoSendStream* stream = AddSendStream();
3468 EXPECT_TRUE(channel_->SetSend(true)); 3468 EXPECT_TRUE(channel_->SetSend(true));
3469 EXPECT_TRUE(stream->IsSending()); 3469 EXPECT_TRUE(stream->IsSending());
3470 3470
3471 // Get current parameters and change "active" to false. 3471 // Get current parameters and change "active" to false.
3472 webrtc::RtpParameters parameters = channel_->GetRtpSendParameters(last_ssrc_); 3472 webrtc::RtpParameters parameters = channel_->GetRtpSendParameters(last_ssrc_);
3473 ASSERT_EQ(1u, parameters.encodings.size()); 3473 ASSERT_EQ(1u, parameters.encodings.size());
3474 ASSERT_TRUE(parameters.encodings[0].active); 3474 ASSERT_TRUE(parameters.encodings[0].active);
3475 parameters.encodings[0].active = false; 3475 parameters.encodings[0].active = false;
3476 EXPECT_TRUE(channel_->SetRtpSendParameters(last_ssrc_, parameters)); 3476 EXPECT_TRUE(channel_->SetRtpSendParameters(last_ssrc_, parameters));
3477 EXPECT_FALSE(stream->IsSending()); 3477 EXPECT_FALSE(stream->IsSending());
3478 3478
3479 // Now change it back to active and verify we resume sending. 3479 // Now change it back to active and verify we resume sending.
3480 parameters.encodings[0].active = true; 3480 parameters.encodings[0].active = true;
3481 EXPECT_TRUE(channel_->SetRtpSendParameters(last_ssrc_, parameters)); 3481 EXPECT_TRUE(channel_->SetRtpSendParameters(last_ssrc_, parameters));
3482 EXPECT_TRUE(stream->IsSending()); 3482 EXPECT_TRUE(stream->IsSending());
3483 } 3483 }
3484 3484
3485 // Test that if a stream is reconfigured (due to a codec change or other
3486 // change) while its encoding is still inactive, it doesn't start sending.
3487 TEST_F(WebRtcVideoChannel2Test,
3488 InactiveStreamDoesntStartSendingWhenReconfigured) {
3489 // Set an initial codec list, which will be modified later.
3490 cricket::VideoSendParameters parameters1;
3491 parameters1.codecs.push_back(kVp8Codec);
3492 parameters1.codecs.push_back(kVp9Codec);
3493 EXPECT_TRUE(channel_->SetSendParameters(parameters1));
3494
3495 FakeVideoSendStream* stream = AddSendStream();
3496 EXPECT_TRUE(channel_->SetSend(true));
3497 EXPECT_TRUE(stream->IsSending());
3498
3499 // Get current parameters and change "active" to false.
3500 webrtc::RtpParameters parameters = channel_->GetRtpSendParameters(last_ssrc_);
3501 ASSERT_EQ(1u, parameters.encodings.size());
3502 ASSERT_TRUE(parameters.encodings[0].active);
3503 parameters.encodings[0].active = false;
3504 EXPECT_EQ(1u, GetFakeSendStreams().size());
3505 EXPECT_EQ(1, fake_call_->GetNumCreatedSendStreams());
3506 EXPECT_TRUE(channel_->SetRtpSendParameters(last_ssrc_, parameters));
3507 EXPECT_FALSE(stream->IsSending());
3508
3509 // Reorder the codec list, causing the stream to be reconfigured.
3510 cricket::VideoSendParameters parameters2;
3511 parameters2.codecs.push_back(kVp9Codec);
3512 parameters2.codecs.push_back(kVp8Codec);
3513 EXPECT_TRUE(channel_->SetSendParameters(parameters2));
3514 auto new_streams = GetFakeSendStreams();
3515 // Assert that a new underlying stream was created due to the codec change.
3516 // Otherwise, this test isn't testing what it set out to test.
3517 EXPECT_EQ(1u, GetFakeSendStreams().size());
3518 EXPECT_EQ(2, fake_call_->GetNumCreatedSendStreams());
3519
3520 // Verify that we still are not sending anything, due to the inactive
3521 // encoding.
3522 EXPECT_FALSE(new_streams[0]->IsSending());
3523 }
3524
3485 // Test that GetRtpSendParameters returns the currently configured codecs. 3525 // Test that GetRtpSendParameters returns the currently configured codecs.
3486 TEST_F(WebRtcVideoChannel2Test, GetRtpSendParametersCodecs) { 3526 TEST_F(WebRtcVideoChannel2Test, GetRtpSendParametersCodecs) {
3487 AddSendStream(); 3527 AddSendStream();
3488 cricket::VideoSendParameters parameters; 3528 cricket::VideoSendParameters parameters;
3489 parameters.codecs.push_back(kVp8Codec); 3529 parameters.codecs.push_back(kVp8Codec);
3490 parameters.codecs.push_back(kVp9Codec); 3530 parameters.codecs.push_back(kVp9Codec);
3491 EXPECT_TRUE(channel_->SetSendParameters(parameters)); 3531 EXPECT_TRUE(channel_->SetSendParameters(parameters));
3492 3532
3493 webrtc::RtpParameters rtp_parameters = 3533 webrtc::RtpParameters rtp_parameters =
3494 channel_->GetRtpSendParameters(last_ssrc_); 3534 channel_->GetRtpSendParameters(last_ssrc_);
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
3787 } 3827 }
3788 3828
3789 // Test that we normalize send codec format size in simulcast. 3829 // Test that we normalize send codec format size in simulcast.
3790 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWithOddSizeInSimulcast) { 3830 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWithOddSizeInSimulcast) {
3791 cricket::VideoCodec codec(kVp8Codec270p); 3831 cricket::VideoCodec codec(kVp8Codec270p);
3792 codec.width += 1; 3832 codec.width += 1;
3793 codec.height += 1; 3833 codec.height += 1;
3794 VerifySimulcastSettings(codec, 2, 2); 3834 VerifySimulcastSettings(codec, 2, 2);
3795 } 3835 }
3796 } // namespace cricket 3836 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/media/engine/webrtcvideoengine2.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698