OLD | NEW |
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 Loading... |
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 2279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3407 SetAndExpectMaxBitrate(capturer, 1000, 800, 800); | 3408 SetAndExpectMaxBitrate(capturer, 1000, 800, 800); |
3408 SetAndExpectMaxBitrate(capturer, 600, 800, 600); | 3409 SetAndExpectMaxBitrate(capturer, 600, 800, 600); |
3409 SetAndExpectMaxBitrate(capturer, 0, 800, 800); | 3410 SetAndExpectMaxBitrate(capturer, 0, 800, 800); |
3410 SetAndExpectMaxBitrate(capturer, 0, 0, default_encoder_bitrate); | 3411 SetAndExpectMaxBitrate(capturer, 0, 0, default_encoder_bitrate); |
3411 | 3412 |
3412 channel_->SetSource(last_ssrc_, NULL); | 3413 channel_->SetSource(last_ssrc_, NULL); |
3413 } | 3414 } |
3414 | 3415 |
3415 TEST_F(WebRtcVideoChannel2Test, CannotSetMaxBitrateForNonexistentStream) { | 3416 TEST_F(WebRtcVideoChannel2Test, CannotSetMaxBitrateForNonexistentStream) { |
3416 webrtc::RtpParameters nonexistent_parameters = | 3417 webrtc::RtpParameters nonexistent_parameters = |
3417 channel_->GetRtpParameters(last_ssrc_); | 3418 channel_->GetRtpSendParameters(last_ssrc_); |
3418 EXPECT_EQ(0, nonexistent_parameters.encodings.size()); | 3419 EXPECT_EQ(0, nonexistent_parameters.encodings.size()); |
3419 | 3420 |
3420 nonexistent_parameters.encodings.push_back(webrtc::RtpEncodingParameters()); | 3421 nonexistent_parameters.encodings.push_back(webrtc::RtpEncodingParameters()); |
3421 EXPECT_FALSE(channel_->SetRtpParameters(last_ssrc_, nonexistent_parameters)); | 3422 EXPECT_FALSE( |
| 3423 channel_->SetRtpSendParameters(last_ssrc_, nonexistent_parameters)); |
3422 } | 3424 } |
3423 | 3425 |
3424 TEST_F(WebRtcVideoChannel2Test, | 3426 TEST_F(WebRtcVideoChannel2Test, |
3425 CannotSetRtpParametersWithIncorrectNumberOfEncodings) { | 3427 CannotSetRtpSendParametersWithIncorrectNumberOfEncodings) { |
3426 // This test verifies that setting RtpParameters succeeds only if | 3428 // This test verifies that setting RtpParameters succeeds only if |
3427 // the structure contains exactly one encoding. | 3429 // the structure contains exactly one encoding. |
3428 // TODO(skvlad): Update this test when we start supporting setting parameters | 3430 // TODO(skvlad): Update this test when we start supporting setting parameters |
3429 // for each encoding individually. | 3431 // for each encoding individually. |
3430 | 3432 |
3431 AddSendStream(); | 3433 AddSendStream(); |
3432 // Setting RtpParameters with no encoding is expected to fail. | 3434 // Setting RtpParameters with no encoding is expected to fail. |
3433 webrtc::RtpParameters parameters; | 3435 webrtc::RtpParameters parameters = channel_->GetRtpSendParameters(last_ssrc_); |
3434 EXPECT_FALSE(channel_->SetRtpParameters(last_ssrc_, parameters)); | 3436 parameters.encodings.clear(); |
| 3437 EXPECT_FALSE(channel_->SetRtpSendParameters(last_ssrc_, parameters)); |
3435 // Setting RtpParameters with exactly one encoding should succeed. | 3438 // Setting RtpParameters with exactly one encoding should succeed. |
3436 parameters.encodings.push_back(webrtc::RtpEncodingParameters()); | 3439 parameters.encodings.push_back(webrtc::RtpEncodingParameters()); |
3437 EXPECT_TRUE(channel_->SetRtpParameters(last_ssrc_, parameters)); | 3440 EXPECT_TRUE(channel_->SetRtpSendParameters(last_ssrc_, parameters)); |
3438 // Two or more encodings should result in failure. | 3441 // Two or more encodings should result in failure. |
3439 parameters.encodings.push_back(webrtc::RtpEncodingParameters()); | 3442 parameters.encodings.push_back(webrtc::RtpEncodingParameters()); |
3440 EXPECT_FALSE(channel_->SetRtpParameters(last_ssrc_, parameters)); | 3443 EXPECT_FALSE(channel_->SetRtpSendParameters(last_ssrc_, parameters)); |
3441 } | 3444 } |
3442 | 3445 |
3443 // Test that a stream will not be sending if its encoding is made | 3446 // Test that a stream will not be sending if its encoding is made |
3444 // inactive through SetRtpParameters. | 3447 // inactive through SetRtpSendParameters. |
3445 // TODO(deadbeef): Update this test when we start supporting setting parameters | 3448 // TODO(deadbeef): Update this test when we start supporting setting parameters |
3446 // for each encoding individually. | 3449 // for each encoding individually. |
3447 TEST_F(WebRtcVideoChannel2Test, SetRtpParametersEncodingsActive) { | 3450 TEST_F(WebRtcVideoChannel2Test, SetRtpSendParametersEncodingsActive) { |
3448 FakeVideoSendStream* stream = AddSendStream(); | 3451 FakeVideoSendStream* stream = AddSendStream(); |
3449 EXPECT_TRUE(channel_->SetSend(true)); | 3452 EXPECT_TRUE(channel_->SetSend(true)); |
3450 EXPECT_TRUE(stream->IsSending()); | 3453 EXPECT_TRUE(stream->IsSending()); |
3451 | 3454 |
3452 // Get current parameters and change "active" to false. | 3455 // Get current parameters and change "active" to false. |
3453 webrtc::RtpParameters parameters = channel_->GetRtpParameters(last_ssrc_); | 3456 webrtc::RtpParameters parameters = channel_->GetRtpSendParameters(last_ssrc_); |
3454 ASSERT_EQ(1u, parameters.encodings.size()); | 3457 ASSERT_EQ(1u, parameters.encodings.size()); |
3455 ASSERT_TRUE(parameters.encodings[0].active); | 3458 ASSERT_TRUE(parameters.encodings[0].active); |
3456 parameters.encodings[0].active = false; | 3459 parameters.encodings[0].active = false; |
3457 EXPECT_TRUE(channel_->SetRtpParameters(last_ssrc_, parameters)); | 3460 EXPECT_TRUE(channel_->SetRtpSendParameters(last_ssrc_, parameters)); |
3458 EXPECT_FALSE(stream->IsSending()); | 3461 EXPECT_FALSE(stream->IsSending()); |
3459 | 3462 |
3460 // Now change it back to active and verify we resume sending. | 3463 // Now change it back to active and verify we resume sending. |
3461 parameters.encodings[0].active = true; | 3464 parameters.encodings[0].active = true; |
3462 EXPECT_TRUE(channel_->SetRtpParameters(last_ssrc_, parameters)); | 3465 EXPECT_TRUE(channel_->SetRtpSendParameters(last_ssrc_, parameters)); |
3463 EXPECT_TRUE(stream->IsSending()); | 3466 EXPECT_TRUE(stream->IsSending()); |
3464 } | 3467 } |
3465 | 3468 |
3466 // Test that GetRtpParameters returns the currently configured codecs. | 3469 // Test that GetRtpSendParameters returns the currently configured codecs. |
3467 TEST_F(WebRtcVideoChannel2Test, GetRtpParametersCodecs) { | 3470 TEST_F(WebRtcVideoChannel2Test, GetRtpSendParametersCodecs) { |
3468 AddSendStream(); | 3471 AddSendStream(); |
3469 cricket::VideoSendParameters parameters; | 3472 cricket::VideoSendParameters parameters; |
3470 parameters.codecs.push_back(kVp8Codec); | 3473 parameters.codecs.push_back(kVp8Codec); |
3471 parameters.codecs.push_back(kVp9Codec); | 3474 parameters.codecs.push_back(kVp9Codec); |
3472 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 3475 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
3473 | 3476 |
3474 webrtc::RtpParameters rtp_parameters = channel_->GetRtpParameters(last_ssrc_); | 3477 webrtc::RtpParameters rtp_parameters = |
| 3478 channel_->GetRtpSendParameters(last_ssrc_); |
3475 ASSERT_EQ(2u, rtp_parameters.codecs.size()); | 3479 ASSERT_EQ(2u, rtp_parameters.codecs.size()); |
3476 EXPECT_EQ(kVp8Codec.id, rtp_parameters.codecs[0].payload_type); | 3480 EXPECT_EQ(kVp8Codec.ToCodecParameters(), rtp_parameters.codecs[0]); |
3477 EXPECT_EQ(kVp8Codec.name, rtp_parameters.codecs[0].mime_type); | 3481 EXPECT_EQ(kVp9Codec.ToCodecParameters(), rtp_parameters.codecs[1]); |
3478 EXPECT_EQ(kVp8Codec.clockrate, rtp_parameters.codecs[0].clock_rate); | |
3479 EXPECT_EQ(1, rtp_parameters.codecs[0].channels); | |
3480 EXPECT_EQ(kVp9Codec.id, rtp_parameters.codecs[1].payload_type); | |
3481 EXPECT_EQ(kVp9Codec.name, rtp_parameters.codecs[1].mime_type); | |
3482 EXPECT_EQ(kVp9Codec.clockrate, rtp_parameters.codecs[1].clock_rate); | |
3483 EXPECT_EQ(1, rtp_parameters.codecs[1].channels); | |
3484 } | 3482 } |
3485 | 3483 |
3486 // Test that if we set/get parameters multiple times, we get the same results. | 3484 // Test that if we set/get parameters multiple times, we get the same results. |
3487 TEST_F(WebRtcVideoChannel2Test, SetAndGetRtpParameters) { | 3485 TEST_F(WebRtcVideoChannel2Test, SetAndGetRtpSendParameters) { |
3488 AddSendStream(); | 3486 AddSendStream(); |
3489 cricket::VideoSendParameters parameters; | 3487 cricket::VideoSendParameters parameters; |
3490 parameters.codecs.push_back(kVp8Codec); | 3488 parameters.codecs.push_back(kVp8Codec); |
3491 parameters.codecs.push_back(kVp9Codec); | 3489 parameters.codecs.push_back(kVp9Codec); |
3492 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 3490 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
3493 | 3491 |
3494 webrtc::RtpParameters initial_params = channel_->GetRtpParameters(last_ssrc_); | 3492 webrtc::RtpParameters initial_params = |
| 3493 channel_->GetRtpSendParameters(last_ssrc_); |
3495 | 3494 |
3496 // We should be able to set the params we just got. | 3495 // We should be able to set the params we just got. |
3497 EXPECT_TRUE(channel_->SetRtpParameters(last_ssrc_, initial_params)); | 3496 EXPECT_TRUE(channel_->SetRtpSendParameters(last_ssrc_, initial_params)); |
3498 | 3497 |
3499 // ... And this shouldn't change the params returned by GetRtpParameters. | 3498 // ... And this shouldn't change the params returned by GetRtpSendParameters. |
3500 EXPECT_EQ(initial_params, channel_->GetRtpParameters(last_ssrc_)); | 3499 EXPECT_EQ(initial_params, channel_->GetRtpSendParameters(last_ssrc_)); |
| 3500 } |
| 3501 |
| 3502 // Test that GetRtpReceiveParameters returns the currently configured codecs. |
| 3503 TEST_F(WebRtcVideoChannel2Test, GetRtpReceiveParametersCodecs) { |
| 3504 AddRecvStream(); |
| 3505 cricket::VideoRecvParameters parameters; |
| 3506 parameters.codecs.push_back(kVp8Codec); |
| 3507 parameters.codecs.push_back(kVp9Codec); |
| 3508 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
| 3509 |
| 3510 webrtc::RtpParameters rtp_parameters = |
| 3511 channel_->GetRtpReceiveParameters(last_ssrc_); |
| 3512 ASSERT_EQ(2u, rtp_parameters.codecs.size()); |
| 3513 EXPECT_EQ(kVp8Codec.ToCodecParameters(), rtp_parameters.codecs[0]); |
| 3514 EXPECT_EQ(kVp9Codec.ToCodecParameters(), rtp_parameters.codecs[1]); |
| 3515 } |
| 3516 |
| 3517 // Test that if we set/get parameters multiple times, we get the same results. |
| 3518 TEST_F(WebRtcVideoChannel2Test, SetAndGetRtpReceiveParameters) { |
| 3519 AddRecvStream(); |
| 3520 cricket::VideoRecvParameters parameters; |
| 3521 parameters.codecs.push_back(kVp8Codec); |
| 3522 parameters.codecs.push_back(kVp9Codec); |
| 3523 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
| 3524 |
| 3525 webrtc::RtpParameters initial_params = |
| 3526 channel_->GetRtpReceiveParameters(last_ssrc_); |
| 3527 |
| 3528 // We should be able to set the params we just got. |
| 3529 EXPECT_TRUE(channel_->SetRtpReceiveParameters(last_ssrc_, initial_params)); |
| 3530 |
| 3531 // ... And this shouldn't change the params returned by |
| 3532 // GetRtpReceiveParameters. |
| 3533 EXPECT_EQ(initial_params, channel_->GetRtpReceiveParameters(last_ssrc_)); |
3501 } | 3534 } |
3502 | 3535 |
3503 void WebRtcVideoChannel2Test::TestReceiverLocalSsrcConfiguration( | 3536 void WebRtcVideoChannel2Test::TestReceiverLocalSsrcConfiguration( |
3504 bool receiver_first) { | 3537 bool receiver_first) { |
3505 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 3538 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
3506 | 3539 |
3507 const uint32_t kSenderSsrc = 0xC0FFEE; | 3540 const uint32_t kSenderSsrc = 0xC0FFEE; |
3508 const uint32_t kSecondSenderSsrc = 0xBADCAFE; | 3541 const uint32_t kSecondSenderSsrc = 0xBADCAFE; |
3509 const uint32_t kReceiverSsrc = 0x4711; | 3542 const uint32_t kReceiverSsrc = 0x4711; |
3510 const uint32_t kExpectedDefaultReceiverSsrc = 1; | 3543 const uint32_t kExpectedDefaultReceiverSsrc = 1; |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3687 } | 3720 } |
3688 | 3721 |
3689 // Test that we normalize send codec format size in simulcast. | 3722 // Test that we normalize send codec format size in simulcast. |
3690 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWithOddSizeInSimulcast) { | 3723 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWithOddSizeInSimulcast) { |
3691 cricket::VideoCodec codec(kVp8Codec270p); | 3724 cricket::VideoCodec codec(kVp8Codec270p); |
3692 codec.width += 1; | 3725 codec.width += 1; |
3693 codec.height += 1; | 3726 codec.height += 1; |
3694 VerifySimulcastSettings(codec, 2, 2); | 3727 VerifySimulcastSettings(codec, 2, 2); |
3695 } | 3728 } |
3696 } // namespace cricket | 3729 } // namespace cricket |
OLD | NEW |