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 1210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1221 FakeVideoSendStream* send_stream = AddSendStream( | 1221 FakeVideoSendStream* send_stream = AddSendStream( |
1222 cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs)); | 1222 cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs)); |
1223 | 1223 |
1224 ASSERT_EQ(rtx_ssrcs.size(), send_stream->GetConfig().rtp.rtx.ssrcs.size()); | 1224 ASSERT_EQ(rtx_ssrcs.size(), send_stream->GetConfig().rtp.rtx.ssrcs.size()); |
1225 for (size_t i = 0; i < rtx_ssrcs.size(); ++i) | 1225 for (size_t i = 0; i < rtx_ssrcs.size(); ++i) |
1226 EXPECT_EQ(rtx_ssrcs[i], send_stream->GetConfig().rtp.rtx.ssrcs[i]); | 1226 EXPECT_EQ(rtx_ssrcs[i], send_stream->GetConfig().rtp.rtx.ssrcs[i]); |
1227 | 1227 |
1228 // Receiver side. | 1228 // Receiver side. |
1229 FakeVideoReceiveStream* recv_stream = AddRecvStream( | 1229 FakeVideoReceiveStream* recv_stream = AddRecvStream( |
1230 cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs)); | 1230 cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs)); |
1231 EXPECT_FALSE(recv_stream->GetConfig().rtp.rtx.empty()); | 1231 EXPECT_FALSE(recv_stream->GetConfig().rtp.rtx_payload_types.empty()); |
1232 EXPECT_EQ(recv_stream->GetConfig().decoders.size(), | 1232 EXPECT_EQ(recv_stream->GetConfig().decoders.size(), |
1233 recv_stream->GetConfig().rtp.rtx.size()) | 1233 recv_stream->GetConfig().rtp.rtx_payload_types.size()) |
1234 << "RTX should be mapped for all decoders/payload types."; | 1234 << "RTX should be mapped for all decoders/payload types."; |
1235 for (const auto& kv : recv_stream->GetConfig().rtp.rtx) { | 1235 EXPECT_EQ(rtx_ssrcs[0], recv_stream->GetConfig().rtp.rtx_ssrc); |
1236 EXPECT_EQ(rtx_ssrcs[0], kv.second.ssrc); | |
1237 } | |
1238 } | 1236 } |
1239 | 1237 |
1240 TEST_F(WebRtcVideoChannel2Test, RecvStreamWithRtx) { | 1238 TEST_F(WebRtcVideoChannel2Test, RecvStreamWithRtx) { |
1241 // Setup one channel with an associated RTX stream. | 1239 // Setup one channel with an associated RTX stream. |
1242 cricket::StreamParams params = | 1240 cricket::StreamParams params = |
1243 cricket::StreamParams::CreateLegacy(kSsrcs1[0]); | 1241 cricket::StreamParams::CreateLegacy(kSsrcs1[0]); |
1244 params.AddFidSsrc(kSsrcs1[0], kRtxSsrcs1[0]); | 1242 params.AddFidSsrc(kSsrcs1[0], kRtxSsrcs1[0]); |
1245 FakeVideoReceiveStream* recv_stream = AddRecvStream(params); | 1243 FakeVideoReceiveStream* recv_stream = AddRecvStream(params); |
1246 EXPECT_EQ(kRtxSsrcs1[0], | 1244 EXPECT_EQ(kRtxSsrcs1[0], recv_stream->GetConfig().rtp.rtx_ssrc); |
1247 recv_stream->GetConfig().rtp.rtx.begin()->second.ssrc); | |
1248 } | 1245 } |
1249 | 1246 |
1250 TEST_F(WebRtcVideoChannel2Test, RecvStreamNoRtx) { | 1247 TEST_F(WebRtcVideoChannel2Test, RecvStreamNoRtx) { |
1251 // Setup one channel without an associated RTX stream. | 1248 // Setup one channel without an associated RTX stream. |
1252 cricket::StreamParams params = | 1249 cricket::StreamParams params = |
1253 cricket::StreamParams::CreateLegacy(kSsrcs1[0]); | 1250 cricket::StreamParams::CreateLegacy(kSsrcs1[0]); |
1254 FakeVideoReceiveStream* recv_stream = AddRecvStream(params); | 1251 FakeVideoReceiveStream* recv_stream = AddRecvStream(params); |
1255 ASSERT_TRUE(recv_stream->GetConfig().rtp.rtx.empty()); | 1252 ASSERT_EQ(0U, recv_stream->GetConfig().rtp.rtx_ssrc); |
1256 } | 1253 } |
1257 | 1254 |
1258 TEST_F(WebRtcVideoChannel2Test, NoHeaderExtesionsByDefault) { | 1255 TEST_F(WebRtcVideoChannel2Test, NoHeaderExtesionsByDefault) { |
1259 FakeVideoSendStream* send_stream = | 1256 FakeVideoSendStream* send_stream = |
1260 AddSendStream(cricket::StreamParams::CreateLegacy(kSsrcs1[0])); | 1257 AddSendStream(cricket::StreamParams::CreateLegacy(kSsrcs1[0])); |
1261 ASSERT_TRUE(send_stream->GetConfig().rtp.extensions.empty()); | 1258 ASSERT_TRUE(send_stream->GetConfig().rtp.extensions.empty()); |
1262 | 1259 |
1263 FakeVideoReceiveStream* recv_stream = | 1260 FakeVideoReceiveStream* recv_stream = |
1264 AddRecvStream(cricket::StreamParams::CreateLegacy(kSsrcs1[0])); | 1261 AddRecvStream(cricket::StreamParams::CreateLegacy(kSsrcs1[0])); |
1265 ASSERT_TRUE(recv_stream->GetConfig().rtp.extensions.empty()); | 1262 ASSERT_TRUE(recv_stream->GetConfig().rtp.extensions.empty()); |
(...skipping 1209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2475 cricket::VideoCodec rtx_codec = cricket::VideoCodec::CreateRtxCodec( | 2472 cricket::VideoCodec rtx_codec = cricket::VideoCodec::CreateRtxCodec( |
2476 kUnusedPayloadType1, kUnusedPayloadType2); | 2473 kUnusedPayloadType1, kUnusedPayloadType2); |
2477 cricket::VideoSendParameters parameters; | 2474 cricket::VideoSendParameters parameters; |
2478 parameters.codecs.push_back(GetEngineCodec("VP8")); | 2475 parameters.codecs.push_back(GetEngineCodec("VP8")); |
2479 parameters.codecs.push_back(rtx_codec); | 2476 parameters.codecs.push_back(rtx_codec); |
2480 EXPECT_FALSE(channel_->SetSendParameters(parameters)) | 2477 EXPECT_FALSE(channel_->SetSendParameters(parameters)) |
2481 << "RTX without matching video codec should be rejected."; | 2478 << "RTX without matching video codec should be rejected."; |
2482 } | 2479 } |
2483 } | 2480 } |
2484 | 2481 |
| 2482 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithChangedRtxPayloadType) { |
| 2483 const int kUnusedPayloadType1 = 126; |
| 2484 const int kUnusedPayloadType2 = 127; |
| 2485 EXPECT_FALSE(FindCodecById(engine_.codecs(), kUnusedPayloadType1)); |
| 2486 EXPECT_FALSE(FindCodecById(engine_.codecs(), kUnusedPayloadType2)); |
| 2487 |
| 2488 // SSRCs for RTX. |
| 2489 cricket::StreamParams params = |
| 2490 cricket::StreamParams::CreateLegacy(kSsrcs1[0]); |
| 2491 params.AddFidSsrc(kSsrcs1[0], kRtxSsrcs1[0]); |
| 2492 AddSendStream(params); |
| 2493 |
| 2494 // Original payload type for RTX. |
| 2495 cricket::VideoSendParameters parameters; |
| 2496 parameters.codecs.push_back(GetEngineCodec("VP8")); |
| 2497 cricket::VideoCodec rtx_codec(kUnusedPayloadType1, "rtx"); |
| 2498 rtx_codec.SetParam("apt", GetEngineCodec("VP8").id); |
| 2499 parameters.codecs.push_back(rtx_codec); |
| 2500 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
| 2501 ASSERT_EQ(1U, fake_call_->GetVideoSendStreams().size()); |
| 2502 const webrtc::VideoSendStream::Config& config_before = |
| 2503 fake_call_->GetVideoSendStreams()[0]->GetConfig(); |
| 2504 EXPECT_EQ(kUnusedPayloadType1, config_before.rtp.rtx.payload_type); |
| 2505 ASSERT_EQ(1U, config_before.rtp.rtx.ssrcs.size()); |
| 2506 EXPECT_EQ(kRtxSsrcs1[0], config_before.rtp.rtx.ssrcs[0]); |
| 2507 |
| 2508 // Change payload type for RTX. |
| 2509 parameters.codecs[1].id = kUnusedPayloadType2; |
| 2510 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
| 2511 ASSERT_EQ(1U, fake_call_->GetVideoSendStreams().size()); |
| 2512 const webrtc::VideoSendStream::Config& config_after = |
| 2513 fake_call_->GetVideoSendStreams()[0]->GetConfig(); |
| 2514 EXPECT_EQ(kUnusedPayloadType2, config_after.rtp.rtx.payload_type); |
| 2515 ASSERT_EQ(1U, config_after.rtp.rtx.ssrcs.size()); |
| 2516 EXPECT_EQ(kRtxSsrcs1[0], config_after.rtp.rtx.ssrcs[0]); |
| 2517 } |
| 2518 |
2485 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithoutFecDisablesFec) { | 2519 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithoutFecDisablesFec) { |
2486 cricket::VideoSendParameters parameters; | 2520 cricket::VideoSendParameters parameters; |
2487 parameters.codecs.push_back(GetEngineCodec("VP8")); | 2521 parameters.codecs.push_back(GetEngineCodec("VP8")); |
2488 parameters.codecs.push_back(GetEngineCodec("ulpfec")); | 2522 parameters.codecs.push_back(GetEngineCodec("ulpfec")); |
2489 ASSERT_TRUE(channel_->SetSendParameters(parameters)); | 2523 ASSERT_TRUE(channel_->SetSendParameters(parameters)); |
2490 | 2524 |
2491 FakeVideoSendStream* stream = AddSendStream(); | 2525 FakeVideoSendStream* stream = AddSendStream(); |
2492 webrtc::VideoSendStream::Config config = stream->GetConfig().Copy(); | 2526 webrtc::VideoSendStream::Config config = stream->GetConfig().Copy(); |
2493 | 2527 |
2494 EXPECT_EQ(GetEngineCodec("ulpfec").id, config.rtp.ulpfec.ulpfec_payload_type); | 2528 EXPECT_EQ(GetEngineCodec("ulpfec").id, config.rtp.ulpfec.ulpfec_payload_type); |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2805 | 2839 |
2806 cricket::VideoCodec rtx_codec2(kUnusedPayloadType2, "rtx"); | 2840 cricket::VideoCodec rtx_codec2(kUnusedPayloadType2, "rtx"); |
2807 rtx_codec2.SetParam("apt", rtx_codec.id); | 2841 rtx_codec2.SetParam("apt", rtx_codec.id); |
2808 parameters.codecs.push_back(rtx_codec2); | 2842 parameters.codecs.push_back(rtx_codec2); |
2809 | 2843 |
2810 EXPECT_FALSE(channel_->SetRecvParameters(parameters)) << | 2844 EXPECT_FALSE(channel_->SetRecvParameters(parameters)) << |
2811 "RTX codec with another RTX as associated payload type should be " | 2845 "RTX codec with another RTX as associated payload type should be " |
2812 "rejected."; | 2846 "rejected."; |
2813 } | 2847 } |
2814 | 2848 |
| 2849 TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsWithChangedRtxPayloadType) { |
| 2850 const int kUnusedPayloadType1 = 126; |
| 2851 const int kUnusedPayloadType2 = 127; |
| 2852 EXPECT_FALSE(FindCodecById(engine_.codecs(), kUnusedPayloadType1)); |
| 2853 EXPECT_FALSE(FindCodecById(engine_.codecs(), kUnusedPayloadType2)); |
| 2854 |
| 2855 // SSRCs for RTX. |
| 2856 cricket::StreamParams params = |
| 2857 cricket::StreamParams::CreateLegacy(kSsrcs1[0]); |
| 2858 params.AddFidSsrc(kSsrcs1[0], kRtxSsrcs1[0]); |
| 2859 AddRecvStream(params); |
| 2860 |
| 2861 // Original payload type for RTX. |
| 2862 cricket::VideoRecvParameters parameters; |
| 2863 parameters.codecs.push_back(GetEngineCodec("VP8")); |
| 2864 cricket::VideoCodec rtx_codec(kUnusedPayloadType1, "rtx"); |
| 2865 rtx_codec.SetParam("apt", GetEngineCodec("VP8").id); |
| 2866 parameters.codecs.push_back(rtx_codec); |
| 2867 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
| 2868 ASSERT_EQ(1U, fake_call_->GetVideoReceiveStreams().size()); |
| 2869 const webrtc::VideoReceiveStream::Config& config_before = |
| 2870 fake_call_->GetVideoReceiveStreams()[0]->GetConfig(); |
| 2871 EXPECT_EQ(1U, config_before.rtp.rtx_payload_types.size()); |
| 2872 auto it_before = |
| 2873 config_before.rtp.rtx_payload_types.find(GetEngineCodec("VP8").id); |
| 2874 ASSERT_NE(it_before, config_before.rtp.rtx_payload_types.end()); |
| 2875 EXPECT_EQ(kUnusedPayloadType1, it_before->second); |
| 2876 EXPECT_EQ(kRtxSsrcs1[0], config_before.rtp.rtx_ssrc); |
| 2877 |
| 2878 // Change payload type for RTX. |
| 2879 parameters.codecs[1].id = kUnusedPayloadType2; |
| 2880 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
| 2881 ASSERT_EQ(1U, fake_call_->GetVideoReceiveStreams().size()); |
| 2882 const webrtc::VideoReceiveStream::Config& config_after = |
| 2883 fake_call_->GetVideoReceiveStreams()[0]->GetConfig(); |
| 2884 EXPECT_EQ(1U, config_after.rtp.rtx_payload_types.size()); |
| 2885 auto it_after = |
| 2886 config_after.rtp.rtx_payload_types.find(GetEngineCodec("VP8").id); |
| 2887 ASSERT_NE(it_after, config_after.rtp.rtx_payload_types.end()); |
| 2888 EXPECT_EQ(kUnusedPayloadType2, it_after->second); |
| 2889 EXPECT_EQ(kRtxSsrcs1[0], config_after.rtp.rtx_ssrc); |
| 2890 } |
| 2891 |
2815 TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsDifferentPayloadType) { | 2892 TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsDifferentPayloadType) { |
2816 cricket::VideoRecvParameters parameters; | 2893 cricket::VideoRecvParameters parameters; |
2817 parameters.codecs.push_back(GetEngineCodec("VP8")); | 2894 parameters.codecs.push_back(GetEngineCodec("VP8")); |
2818 parameters.codecs[0].id = 99; | 2895 parameters.codecs[0].id = 99; |
2819 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); | 2896 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
2820 } | 2897 } |
2821 | 2898 |
2822 TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsAcceptDefaultCodecs) { | 2899 TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsAcceptDefaultCodecs) { |
2823 cricket::VideoRecvParameters parameters; | 2900 cricket::VideoRecvParameters parameters; |
2824 parameters.codecs = engine_.codecs(); | 2901 parameters.codecs = engine_.codecs(); |
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3434 uint8_t data[kDataLength]; | 3511 uint8_t data[kDataLength]; |
3435 memset(data, 0, sizeof(data)); | 3512 memset(data, 0, sizeof(data)); |
3436 rtc::SetBE32(&data[8], ssrcs[0]); | 3513 rtc::SetBE32(&data[8], ssrcs[0]); |
3437 rtc::CopyOnWriteBuffer packet(data, kDataLength); | 3514 rtc::CopyOnWriteBuffer packet(data, kDataLength); |
3438 rtc::PacketTime packet_time; | 3515 rtc::PacketTime packet_time; |
3439 channel_->OnPacketReceived(&packet, packet_time); | 3516 channel_->OnPacketReceived(&packet, packet_time); |
3440 | 3517 |
3441 ASSERT_EQ(1u, fake_call_->GetVideoReceiveStreams().size()) | 3518 ASSERT_EQ(1u, fake_call_->GetVideoReceiveStreams().size()) |
3442 << "No default receive stream created."; | 3519 << "No default receive stream created."; |
3443 FakeVideoReceiveStream* recv_stream = fake_call_->GetVideoReceiveStreams()[0]; | 3520 FakeVideoReceiveStream* recv_stream = fake_call_->GetVideoReceiveStreams()[0]; |
3444 EXPECT_TRUE(recv_stream->GetConfig().rtp.rtx.empty()) | 3521 EXPECT_EQ(0u, recv_stream->GetConfig().rtp.rtx_ssrc) |
3445 << "Default receive stream should not have configured RTX"; | 3522 << "Default receive stream should not have configured RTX"; |
3446 | 3523 |
3447 EXPECT_TRUE(channel_->AddRecvStream( | 3524 EXPECT_TRUE(channel_->AddRecvStream( |
3448 cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs))); | 3525 cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs))); |
3449 ASSERT_EQ(1u, fake_call_->GetVideoReceiveStreams().size()) | 3526 ASSERT_EQ(1u, fake_call_->GetVideoReceiveStreams().size()) |
3450 << "AddRecvStream should've reconfigured, not added a new receiver."; | 3527 << "AddRecvStream should have reconfigured, not added a new receiver."; |
3451 recv_stream = fake_call_->GetVideoReceiveStreams()[0]; | 3528 recv_stream = fake_call_->GetVideoReceiveStreams()[0]; |
3452 EXPECT_FALSE(recv_stream->GetConfig().rtp.rtx.empty()); | 3529 EXPECT_FALSE(recv_stream->GetConfig().rtp.rtx_payload_types.empty()); |
3453 EXPECT_EQ(recv_stream->GetConfig().decoders.size(), | 3530 EXPECT_EQ(recv_stream->GetConfig().decoders.size(), |
3454 recv_stream->GetConfig().rtp.rtx.size()) | 3531 recv_stream->GetConfig().rtp.rtx_payload_types.size()) |
3455 << "RTX should be mapped for all decoders/payload types."; | 3532 << "RTX should be mapped for all decoders/payload types."; |
3456 for (const auto& kv : recv_stream->GetConfig().rtp.rtx) { | 3533 EXPECT_EQ(rtx_ssrcs[0], recv_stream->GetConfig().rtp.rtx_ssrc); |
3457 EXPECT_EQ(rtx_ssrcs[0], kv.second.ssrc); | |
3458 } | |
3459 } | 3534 } |
3460 | 3535 |
3461 TEST_F(WebRtcVideoChannel2Test, RejectsAddingStreamsWithMissingSsrcsForRtx) { | 3536 TEST_F(WebRtcVideoChannel2Test, RejectsAddingStreamsWithMissingSsrcsForRtx) { |
3462 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 3537 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
3463 | 3538 |
3464 const std::vector<uint32_t> ssrcs = MAKE_VECTOR(kSsrcs1); | 3539 const std::vector<uint32_t> ssrcs = MAKE_VECTOR(kSsrcs1); |
3465 const std::vector<uint32_t> rtx_ssrcs = MAKE_VECTOR(kRtxSsrcs1); | 3540 const std::vector<uint32_t> rtx_ssrcs = MAKE_VECTOR(kRtxSsrcs1); |
3466 | 3541 |
3467 StreamParams sp = | 3542 StreamParams sp = |
3468 cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs); | 3543 cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs); |
(...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4145 } | 4220 } |
4146 | 4221 |
4147 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsForSimulcastScreenshare) { | 4222 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsForSimulcastScreenshare) { |
4148 webrtc::test::ScopedFieldTrials override_field_trials_( | 4223 webrtc::test::ScopedFieldTrials override_field_trials_( |
4149 "WebRTC-SimulcastScreenshare/Enabled/"); | 4224 "WebRTC-SimulcastScreenshare/Enabled/"); |
4150 VerifySimulcastSettings(cricket::VideoCodec("VP8"), 1280, 720, 3, 2, true, | 4225 VerifySimulcastSettings(cricket::VideoCodec("VP8"), 1280, 720, 3, 2, true, |
4151 true); | 4226 true); |
4152 } | 4227 } |
4153 | 4228 |
4154 } // namespace cricket | 4229 } // namespace cricket |
OLD | NEW |