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

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

Issue 1917193008: Adding getParameters/setParameters APIs to RtpReceiver. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: objc compile errors Created 4 years, 7 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') | webrtc/media/engine/webrtcvoiceengine.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 1091 matching lines...) Expand 10 before | Expand all | Expand 10 after
1102 return encoder_config.streams[0].max_bitrate_bps; 1102 return encoder_config.streams[0].max_bitrate_bps;
1103 } 1103 }
1104 1104
1105 void SetAndExpectMaxBitrate(cricket::FakeVideoCapturer& capturer, 1105 void SetAndExpectMaxBitrate(cricket::FakeVideoCapturer& capturer,
1106 int global_max, 1106 int global_max,
1107 int stream_max, 1107 int stream_max,
1108 int expected_encoder_bitrate) { 1108 int expected_encoder_bitrate) {
1109 VideoSendParameters limited_send_params = send_parameters_; 1109 VideoSendParameters limited_send_params = send_parameters_;
1110 limited_send_params.max_bandwidth_bps = global_max; 1110 limited_send_params.max_bandwidth_bps = global_max;
1111 EXPECT_TRUE(channel_->SetSendParameters(limited_send_params)); 1111 EXPECT_TRUE(channel_->SetSendParameters(limited_send_params));
1112 webrtc::RtpParameters parameters = channel_->GetRtpParameters(last_ssrc_); 1112 webrtc::RtpParameters parameters =
1113 channel_->GetRtpSendParameters(last_ssrc_);
1113 EXPECT_EQ(1UL, parameters.encodings.size()); 1114 EXPECT_EQ(1UL, parameters.encodings.size());
1114 parameters.encodings[0].max_bitrate_bps = stream_max; 1115 parameters.encodings[0].max_bitrate_bps = stream_max;
1115 EXPECT_TRUE(channel_->SetRtpParameters(last_ssrc_, parameters)); 1116 EXPECT_TRUE(channel_->SetRtpSendParameters(last_ssrc_, parameters));
1116 // Read back the parameteres and verify they have the correct value 1117 // Read back the parameteres and verify they have the correct value
1117 parameters = channel_->GetRtpParameters(last_ssrc_); 1118 parameters = channel_->GetRtpSendParameters(last_ssrc_);
1118 EXPECT_EQ(1UL, parameters.encodings.size()); 1119 EXPECT_EQ(1UL, parameters.encodings.size());
1119 EXPECT_EQ(stream_max, parameters.encodings[0].max_bitrate_bps); 1120 EXPECT_EQ(stream_max, parameters.encodings[0].max_bitrate_bps);
1120 // Verify that the new value propagated down to the encoder 1121 // Verify that the new value propagated down to the encoder
1121 EXPECT_EQ(expected_encoder_bitrate, GetMaxEncoderBitrate(capturer)); 1122 EXPECT_EQ(expected_encoder_bitrate, GetMaxEncoderBitrate(capturer));
1122 } 1123 }
1123 1124
1124 std::unique_ptr<FakeCall> fake_call_; 1125 std::unique_ptr<FakeCall> fake_call_;
1125 std::unique_ptr<VideoMediaChannel> channel_; 1126 std::unique_ptr<VideoMediaChannel> channel_;
1126 cricket::VideoSendParameters send_parameters_; 1127 cricket::VideoSendParameters send_parameters_;
1127 cricket::VideoRecvParameters recv_parameters_; 1128 cricket::VideoRecvParameters recv_parameters_;
(...skipping 2285 matching lines...) Expand 10 before | Expand all | Expand 10 after
3413 SetAndExpectMaxBitrate(capturer, 1000, 800, 800); 3414 SetAndExpectMaxBitrate(capturer, 1000, 800, 800);
3414 SetAndExpectMaxBitrate(capturer, 600, 800, 600); 3415 SetAndExpectMaxBitrate(capturer, 600, 800, 600);
3415 SetAndExpectMaxBitrate(capturer, 0, 800, 800); 3416 SetAndExpectMaxBitrate(capturer, 0, 800, 800);
3416 SetAndExpectMaxBitrate(capturer, 0, 0, default_encoder_bitrate); 3417 SetAndExpectMaxBitrate(capturer, 0, 0, default_encoder_bitrate);
3417 3418
3418 channel_->SetSource(last_ssrc_, NULL); 3419 channel_->SetSource(last_ssrc_, NULL);
3419 } 3420 }
3420 3421
3421 TEST_F(WebRtcVideoChannel2Test, CannotSetMaxBitrateForNonexistentStream) { 3422 TEST_F(WebRtcVideoChannel2Test, CannotSetMaxBitrateForNonexistentStream) {
3422 webrtc::RtpParameters nonexistent_parameters = 3423 webrtc::RtpParameters nonexistent_parameters =
3423 channel_->GetRtpParameters(last_ssrc_); 3424 channel_->GetRtpSendParameters(last_ssrc_);
3424 EXPECT_EQ(0, nonexistent_parameters.encodings.size()); 3425 EXPECT_EQ(0, nonexistent_parameters.encodings.size());
3425 3426
3426 nonexistent_parameters.encodings.push_back(webrtc::RtpEncodingParameters()); 3427 nonexistent_parameters.encodings.push_back(webrtc::RtpEncodingParameters());
3427 EXPECT_FALSE(channel_->SetRtpParameters(last_ssrc_, nonexistent_parameters)); 3428 EXPECT_FALSE(
3429 channel_->SetRtpSendParameters(last_ssrc_, nonexistent_parameters));
3428 } 3430 }
3429 3431
3430 TEST_F(WebRtcVideoChannel2Test, 3432 TEST_F(WebRtcVideoChannel2Test,
3431 CannotSetRtpParametersWithIncorrectNumberOfEncodings) { 3433 CannotSetRtpSendParametersWithIncorrectNumberOfEncodings) {
3432 // This test verifies that setting RtpParameters succeeds only if 3434 // This test verifies that setting RtpParameters succeeds only if
3433 // the structure contains exactly one encoding. 3435 // the structure contains exactly one encoding.
3434 // TODO(skvlad): Update this test when we start supporting setting parameters 3436 // TODO(skvlad): Update this test when we start supporting setting parameters
3435 // for each encoding individually. 3437 // for each encoding individually.
3436 3438
3437 AddSendStream(); 3439 AddSendStream();
3438 // Setting RtpParameters with no encoding is expected to fail. 3440 // Setting RtpParameters with no encoding is expected to fail.
3439 webrtc::RtpParameters parameters; 3441 webrtc::RtpParameters parameters = channel_->GetRtpSendParameters(last_ssrc_);
3440 EXPECT_FALSE(channel_->SetRtpParameters(last_ssrc_, parameters)); 3442 parameters.encodings.clear();
3443 EXPECT_FALSE(channel_->SetRtpSendParameters(last_ssrc_, parameters));
3441 // Setting RtpParameters with exactly one encoding should succeed. 3444 // Setting RtpParameters with exactly one encoding should succeed.
3442 parameters.encodings.push_back(webrtc::RtpEncodingParameters()); 3445 parameters.encodings.push_back(webrtc::RtpEncodingParameters());
3443 EXPECT_TRUE(channel_->SetRtpParameters(last_ssrc_, parameters)); 3446 EXPECT_TRUE(channel_->SetRtpSendParameters(last_ssrc_, parameters));
3444 // Two or more encodings should result in failure. 3447 // Two or more encodings should result in failure.
3445 parameters.encodings.push_back(webrtc::RtpEncodingParameters()); 3448 parameters.encodings.push_back(webrtc::RtpEncodingParameters());
3446 EXPECT_FALSE(channel_->SetRtpParameters(last_ssrc_, parameters)); 3449 EXPECT_FALSE(channel_->SetRtpSendParameters(last_ssrc_, parameters));
3447 } 3450 }
3448 3451
3449 // Test that a stream will not be sending if its encoding is made 3452 // Test that a stream will not be sending if its encoding is made
3450 // inactive through SetRtpParameters. 3453 // inactive through SetRtpSendParameters.
3451 // TODO(deadbeef): Update this test when we start supporting setting parameters 3454 // TODO(deadbeef): Update this test when we start supporting setting parameters
3452 // for each encoding individually. 3455 // for each encoding individually.
3453 TEST_F(WebRtcVideoChannel2Test, SetRtpParametersEncodingsActive) { 3456 TEST_F(WebRtcVideoChannel2Test, SetRtpSendParametersEncodingsActive) {
3454 FakeVideoSendStream* stream = AddSendStream(); 3457 FakeVideoSendStream* stream = AddSendStream();
3455 EXPECT_TRUE(channel_->SetSend(true)); 3458 EXPECT_TRUE(channel_->SetSend(true));
3456 EXPECT_TRUE(stream->IsSending()); 3459 EXPECT_TRUE(stream->IsSending());
3457 3460
3458 // Get current parameters and change "active" to false. 3461 // Get current parameters and change "active" to false.
3459 webrtc::RtpParameters parameters = channel_->GetRtpParameters(last_ssrc_); 3462 webrtc::RtpParameters parameters = channel_->GetRtpSendParameters(last_ssrc_);
3460 ASSERT_EQ(1u, parameters.encodings.size()); 3463 ASSERT_EQ(1u, parameters.encodings.size());
3461 ASSERT_TRUE(parameters.encodings[0].active); 3464 ASSERT_TRUE(parameters.encodings[0].active);
3462 parameters.encodings[0].active = false; 3465 parameters.encodings[0].active = false;
3463 EXPECT_TRUE(channel_->SetRtpParameters(last_ssrc_, parameters)); 3466 EXPECT_TRUE(channel_->SetRtpSendParameters(last_ssrc_, parameters));
3464 EXPECT_FALSE(stream->IsSending()); 3467 EXPECT_FALSE(stream->IsSending());
3465 3468
3466 // Now change it back to active and verify we resume sending. 3469 // Now change it back to active and verify we resume sending.
3467 parameters.encodings[0].active = true; 3470 parameters.encodings[0].active = true;
3468 EXPECT_TRUE(channel_->SetRtpParameters(last_ssrc_, parameters)); 3471 EXPECT_TRUE(channel_->SetRtpSendParameters(last_ssrc_, parameters));
3469 EXPECT_TRUE(stream->IsSending()); 3472 EXPECT_TRUE(stream->IsSending());
3470 } 3473 }
3471 3474
3472 // Test that GetRtpParameters returns the currently configured codecs. 3475 // Test that GetRtpSendParameters returns the currently configured codecs.
3473 TEST_F(WebRtcVideoChannel2Test, GetRtpParametersCodecs) { 3476 TEST_F(WebRtcVideoChannel2Test, GetRtpSendParametersCodecs) {
3474 AddSendStream(); 3477 AddSendStream();
3475 cricket::VideoSendParameters parameters; 3478 cricket::VideoSendParameters parameters;
3476 parameters.codecs.push_back(kVp8Codec); 3479 parameters.codecs.push_back(kVp8Codec);
3477 parameters.codecs.push_back(kVp9Codec); 3480 parameters.codecs.push_back(kVp9Codec);
3478 EXPECT_TRUE(channel_->SetSendParameters(parameters)); 3481 EXPECT_TRUE(channel_->SetSendParameters(parameters));
3479 3482
3480 webrtc::RtpParameters rtp_parameters = channel_->GetRtpParameters(last_ssrc_); 3483 webrtc::RtpParameters rtp_parameters =
3484 channel_->GetRtpSendParameters(last_ssrc_);
3481 ASSERT_EQ(2u, rtp_parameters.codecs.size()); 3485 ASSERT_EQ(2u, rtp_parameters.codecs.size());
3482 EXPECT_EQ(kVp8Codec.id, rtp_parameters.codecs[0].payload_type); 3486 EXPECT_EQ(kVp8Codec.ToCodecParameters(), rtp_parameters.codecs[0]);
3483 EXPECT_EQ(kVp8Codec.name, rtp_parameters.codecs[0].mime_type); 3487 EXPECT_EQ(kVp9Codec.ToCodecParameters(), rtp_parameters.codecs[1]);
3484 EXPECT_EQ(kVp8Codec.clockrate, rtp_parameters.codecs[0].clock_rate);
3485 EXPECT_EQ(1, rtp_parameters.codecs[0].channels);
3486 EXPECT_EQ(kVp9Codec.id, rtp_parameters.codecs[1].payload_type);
3487 EXPECT_EQ(kVp9Codec.name, rtp_parameters.codecs[1].mime_type);
3488 EXPECT_EQ(kVp9Codec.clockrate, rtp_parameters.codecs[1].clock_rate);
3489 EXPECT_EQ(1, rtp_parameters.codecs[1].channels);
3490 } 3488 }
3491 3489
3492 // Test that if we set/get parameters multiple times, we get the same results. 3490 // Test that if we set/get parameters multiple times, we get the same results.
3493 TEST_F(WebRtcVideoChannel2Test, SetAndGetRtpParameters) { 3491 TEST_F(WebRtcVideoChannel2Test, SetAndGetRtpSendParameters) {
3494 AddSendStream(); 3492 AddSendStream();
3495 cricket::VideoSendParameters parameters; 3493 cricket::VideoSendParameters parameters;
3496 parameters.codecs.push_back(kVp8Codec); 3494 parameters.codecs.push_back(kVp8Codec);
3497 parameters.codecs.push_back(kVp9Codec); 3495 parameters.codecs.push_back(kVp9Codec);
3498 EXPECT_TRUE(channel_->SetSendParameters(parameters)); 3496 EXPECT_TRUE(channel_->SetSendParameters(parameters));
3499 3497
3500 webrtc::RtpParameters initial_params = channel_->GetRtpParameters(last_ssrc_); 3498 webrtc::RtpParameters initial_params =
3499 channel_->GetRtpSendParameters(last_ssrc_);
3501 3500
3502 // We should be able to set the params we just got. 3501 // We should be able to set the params we just got.
3503 EXPECT_TRUE(channel_->SetRtpParameters(last_ssrc_, initial_params)); 3502 EXPECT_TRUE(channel_->SetRtpSendParameters(last_ssrc_, initial_params));
3504 3503
3505 // ... And this shouldn't change the params returned by GetRtpParameters. 3504 // ... And this shouldn't change the params returned by GetRtpSendParameters.
3506 EXPECT_EQ(initial_params, channel_->GetRtpParameters(last_ssrc_)); 3505 EXPECT_EQ(initial_params, channel_->GetRtpSendParameters(last_ssrc_));
3506 }
3507
3508 // Test that GetRtpReceiveParameters returns the currently configured codecs.
3509 TEST_F(WebRtcVideoChannel2Test, GetRtpReceiveParametersCodecs) {
3510 AddRecvStream();
3511 cricket::VideoRecvParameters parameters;
3512 parameters.codecs.push_back(kVp8Codec);
3513 parameters.codecs.push_back(kVp9Codec);
3514 EXPECT_TRUE(channel_->SetRecvParameters(parameters));
3515
3516 webrtc::RtpParameters rtp_parameters =
3517 channel_->GetRtpReceiveParameters(last_ssrc_);
3518 ASSERT_EQ(2u, rtp_parameters.codecs.size());
3519 EXPECT_EQ(kVp8Codec.ToCodecParameters(), rtp_parameters.codecs[0]);
3520 EXPECT_EQ(kVp9Codec.ToCodecParameters(), rtp_parameters.codecs[1]);
3521 }
3522
3523 // Test that if we set/get parameters multiple times, we get the same results.
3524 TEST_F(WebRtcVideoChannel2Test, SetAndGetRtpReceiveParameters) {
3525 AddRecvStream();
3526 cricket::VideoRecvParameters parameters;
3527 parameters.codecs.push_back(kVp8Codec);
3528 parameters.codecs.push_back(kVp9Codec);
3529 EXPECT_TRUE(channel_->SetRecvParameters(parameters));
3530
3531 webrtc::RtpParameters initial_params =
3532 channel_->GetRtpReceiveParameters(last_ssrc_);
3533
3534 // We should be able to set the params we just got.
3535 EXPECT_TRUE(channel_->SetRtpReceiveParameters(last_ssrc_, initial_params));
3536
3537 // ... And this shouldn't change the params returned by
3538 // GetRtpReceiveParameters.
3539 EXPECT_EQ(initial_params, channel_->GetRtpReceiveParameters(last_ssrc_));
3507 } 3540 }
3508 3541
3509 void WebRtcVideoChannel2Test::TestReceiverLocalSsrcConfiguration( 3542 void WebRtcVideoChannel2Test::TestReceiverLocalSsrcConfiguration(
3510 bool receiver_first) { 3543 bool receiver_first) {
3511 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); 3544 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
3512 3545
3513 const uint32_t kSenderSsrc = 0xC0FFEE; 3546 const uint32_t kSenderSsrc = 0xC0FFEE;
3514 const uint32_t kSecondSenderSsrc = 0xBADCAFE; 3547 const uint32_t kSecondSenderSsrc = 0xBADCAFE;
3515 const uint32_t kReceiverSsrc = 0x4711; 3548 const uint32_t kReceiverSsrc = 0x4711;
3516 const uint32_t kExpectedDefaultReceiverSsrc = 1; 3549 const uint32_t kExpectedDefaultReceiverSsrc = 1;
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
3693 } 3726 }
3694 3727
3695 // Test that we normalize send codec format size in simulcast. 3728 // Test that we normalize send codec format size in simulcast.
3696 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWithOddSizeInSimulcast) { 3729 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWithOddSizeInSimulcast) {
3697 cricket::VideoCodec codec(kVp8Codec270p); 3730 cricket::VideoCodec codec(kVp8Codec270p);
3698 codec.width += 1; 3731 codec.width += 1;
3699 codec.height += 1; 3732 codec.height += 1;
3700 VerifySimulcastSettings(codec, 2, 2); 3733 VerifySimulcastSettings(codec, 2, 2);
3701 } 3734 }
3702 } // namespace cricket 3735 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/media/engine/webrtcvideoengine2.cc ('k') | webrtc/media/engine/webrtcvoiceengine.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698