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

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

Issue 2511703002: Wire up FlexFEC in VideoEngine2. (Closed)
Patch Set: Created 4 years, 1 month 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
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 21 matching lines...) Expand all
32 32
33 namespace { 33 namespace {
34 static const int kDefaultQpMax = 56; 34 static const int kDefaultQpMax = 56;
35 35
36 static const cricket::VideoCodec kVp8Codec(100, "VP8"); 36 static const cricket::VideoCodec kVp8Codec(100, "VP8");
37 static const cricket::VideoCodec kVp9Codec(101, "VP9"); 37 static const cricket::VideoCodec kVp9Codec(101, "VP9");
38 static const cricket::VideoCodec kH264Codec(102, "H264"); 38 static const cricket::VideoCodec kH264Codec(102, "H264");
39 39
40 static const cricket::VideoCodec kRedCodec(116, "red"); 40 static const cricket::VideoCodec kRedCodec(116, "red");
41 static const cricket::VideoCodec kUlpfecCodec(117, "ulpfec"); 41 static const cricket::VideoCodec kUlpfecCodec(117, "ulpfec");
42 static const cricket::VideoCodec kFlexfecCodec(118, "flexfec-03");
42 43
43 static const uint8_t kRedRtxPayloadType = 125; 44 static const uint8_t kRedRtxPayloadType = 125;
44 45
45 static const uint32_t kSsrcs1[] = {1}; 46 static const uint32_t kSsrcs1[] = {1};
46 static const uint32_t kSsrcs3[] = {1, 2, 3}; 47 static const uint32_t kSsrcs3[] = {1, 2, 3};
47 static const uint32_t kRtxSsrcs1[] = {4}; 48 static const uint32_t kRtxSsrcs1[] = {4};
49 static const uint32_t kFlexfecSsrc = 5;
48 static const uint32_t kIncomingUnsignalledSsrc = 0xC0FFEE; 50 static const uint32_t kIncomingUnsignalledSsrc = 0xC0FFEE;
49 static const char kUnsupportedExtensionName[] = 51 static const char kUnsupportedExtensionName[] =
50 "urn:ietf:params:rtp-hdrext:unsupported"; 52 "urn:ietf:params:rtp-hdrext:unsupported";
51 53
52 void VerifyCodecHasDefaultFeedbackParams(const cricket::VideoCodec& codec) { 54 void VerifyCodecHasDefaultFeedbackParams(const cricket::VideoCodec& codec) {
53 EXPECT_TRUE(codec.HasFeedbackParam(cricket::FeedbackParam( 55 EXPECT_TRUE(codec.HasFeedbackParam(cricket::FeedbackParam(
54 cricket::kRtcpFbParamNack, cricket::kParamValueEmpty))); 56 cricket::kRtcpFbParamNack, cricket::kParamValueEmpty)));
55 EXPECT_TRUE(codec.HasFeedbackParam(cricket::FeedbackParam( 57 EXPECT_TRUE(codec.HasFeedbackParam(cricket::FeedbackParam(
56 cricket::kRtcpFbParamNack, cricket::kRtcpFbNackParamPli))); 58 cricket::kRtcpFbParamNack, cricket::kRtcpFbNackParamPli)));
57 EXPECT_TRUE(codec.HasFeedbackParam(cricket::FeedbackParam( 59 EXPECT_TRUE(codec.HasFeedbackParam(cricket::FeedbackParam(
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 call_(webrtc::Call::Create(webrtc::Call::Config(&event_log_))), 113 call_(webrtc::Call::Create(webrtc::Call::Config(&event_log_))),
112 engine_() { 114 engine_() {
113 std::vector<VideoCodec> engine_codecs = engine_.codecs(); 115 std::vector<VideoCodec> engine_codecs = engine_.codecs();
114 RTC_DCHECK(!engine_codecs.empty()); 116 RTC_DCHECK(!engine_codecs.empty());
115 bool codec_set = false; 117 bool codec_set = false;
116 for (size_t i = 0; i < engine_codecs.size(); ++i) { 118 for (size_t i = 0; i < engine_codecs.size(); ++i) {
117 if (engine_codecs[i].name == "red") { 119 if (engine_codecs[i].name == "red") {
118 default_red_codec_ = engine_codecs[i]; 120 default_red_codec_ = engine_codecs[i];
119 } else if (engine_codecs[i].name == "ulpfec") { 121 } else if (engine_codecs[i].name == "ulpfec") {
120 default_ulpfec_codec_ = engine_codecs[i]; 122 default_ulpfec_codec_ = engine_codecs[i];
123 } else if (engine_codecs[i].name == "flexfec-03") {
124 default_flexfec_codec_ = engine_codecs[i];
121 } else if (engine_codecs[i].name == "rtx") { 125 } else if (engine_codecs[i].name == "rtx") {
122 int associated_payload_type; 126 int associated_payload_type;
123 if (engine_codecs[i].GetParam(kCodecParamAssociatedPayloadType, 127 if (engine_codecs[i].GetParam(kCodecParamAssociatedPayloadType,
124 &associated_payload_type)) { 128 &associated_payload_type)) {
125 default_apt_rtx_types_[associated_payload_type] = engine_codecs[i].id; 129 default_apt_rtx_types_[associated_payload_type] = engine_codecs[i].id;
126 } 130 }
127 } else if (!codec_set) { 131 } else if (!codec_set) {
128 default_codec_ = engine_codecs[i]; 132 default_codec_ = engine_codecs[i];
129 codec_set = true; 133 codec_set = true;
130 } 134 }
(...skipping 15 matching lines...) Expand all
146 150
147 webrtc::test::ScopedFieldTrials override_field_trials_; 151 webrtc::test::ScopedFieldTrials override_field_trials_;
148 webrtc::RtcEventLogNullImpl event_log_; 152 webrtc::RtcEventLogNullImpl event_log_;
149 // Used in WebRtcVideoEngine2VoiceTest, but defined here so it's properly 153 // Used in WebRtcVideoEngine2VoiceTest, but defined here so it's properly
150 // initialized when the constructor is called. 154 // initialized when the constructor is called.
151 std::unique_ptr<webrtc::Call> call_; 155 std::unique_ptr<webrtc::Call> call_;
152 WebRtcVideoEngine2 engine_; 156 WebRtcVideoEngine2 engine_;
153 VideoCodec default_codec_; 157 VideoCodec default_codec_;
154 VideoCodec default_red_codec_; 158 VideoCodec default_red_codec_;
155 VideoCodec default_ulpfec_codec_; 159 VideoCodec default_ulpfec_codec_;
160 VideoCodec default_flexfec_codec_;
156 std::map<int, int> default_apt_rtx_types_; 161 std::map<int, int> default_apt_rtx_types_;
157 }; 162 };
158 163
159 TEST_F(WebRtcVideoEngine2Test, AnnouncesVp9AccordingToBuildFlags) { 164 TEST_F(WebRtcVideoEngine2Test, AnnouncesVp9AccordingToBuildFlags) {
160 bool claims_vp9_support = false; 165 bool claims_vp9_support = false;
161 for (const cricket::VideoCodec& codec : engine_.codecs()) { 166 for (const cricket::VideoCodec& codec : engine_.codecs()) {
162 if (codec.name == "VP9") { 167 if (codec.name == "VP9") {
163 claims_vp9_support = true; 168 claims_vp9_support = true;
164 break; 169 break;
165 } 170 }
(...skipping 952 matching lines...) Expand 10 before | Expand all | Expand 10 after
1118 EXPECT_EQ(expected_encoder_bitrate, GetMaxEncoderBitrate()); 1123 EXPECT_EQ(expected_encoder_bitrate, GetMaxEncoderBitrate());
1119 } 1124 }
1120 1125
1121 std::unique_ptr<FakeCall> fake_call_; 1126 std::unique_ptr<FakeCall> fake_call_;
1122 std::unique_ptr<VideoMediaChannel> channel_; 1127 std::unique_ptr<VideoMediaChannel> channel_;
1123 cricket::VideoSendParameters send_parameters_; 1128 cricket::VideoSendParameters send_parameters_;
1124 cricket::VideoRecvParameters recv_parameters_; 1129 cricket::VideoRecvParameters recv_parameters_;
1125 uint32_t last_ssrc_; 1130 uint32_t last_ssrc_;
1126 }; 1131 };
1127 1132
1133 // TODO(brandtr): When FlexFEC is no longer behind a field trial, merge all
1134 // tests that use this test fixture into the corresponding "non-field trial"
1135 // tests.
1136 class WebRtcVideoChannel2FlexfecTest : public WebRtcVideoChannel2Test {
stefan-webrtc 2016/11/17 12:48:59 Move this down to where it's used.
brandtr 2016/11/17 13:23:36 Done.
1137 public:
1138 WebRtcVideoChannel2FlexfecTest()
1139 : WebRtcVideoChannel2Test("WebRTC-FlexFEC-03/Enabled/") {}
1140 };
1141
1128 TEST_F(WebRtcVideoChannel2Test, SetsSyncGroupFromSyncLabel) { 1142 TEST_F(WebRtcVideoChannel2Test, SetsSyncGroupFromSyncLabel) {
1129 const uint32_t kVideoSsrc = 123; 1143 const uint32_t kVideoSsrc = 123;
1130 const std::string kSyncLabel = "AvSyncLabel"; 1144 const std::string kSyncLabel = "AvSyncLabel";
1131 1145
1132 cricket::StreamParams sp = cricket::StreamParams::CreateLegacy(kVideoSsrc); 1146 cricket::StreamParams sp = cricket::StreamParams::CreateLegacy(kVideoSsrc);
1133 sp.sync_label = kSyncLabel; 1147 sp.sync_label = kSyncLabel;
1134 EXPECT_TRUE(channel_->AddRecvStream(sp)); 1148 EXPECT_TRUE(channel_->AddRecvStream(sp));
1135 1149
1136 EXPECT_EQ(1, fake_call_->GetVideoReceiveStreams().size()); 1150 EXPECT_EQ(1, fake_call_->GetVideoReceiveStreams().size());
1137 EXPECT_EQ(kSyncLabel, 1151 EXPECT_EQ(kSyncLabel,
(...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after
1914 1928
1915 ASSERT_TRUE(stream->GetVp9Settings(&vp9_settings)) << "No VP9 config set."; 1929 ASSERT_TRUE(stream->GetVp9Settings(&vp9_settings)) << "No VP9 config set.";
1916 EXPECT_FALSE(vp9_settings.denoisingOn); 1930 EXPECT_FALSE(vp9_settings.denoisingOn);
1917 EXPECT_FALSE(vp9_settings.frameDroppingOn); 1931 EXPECT_FALSE(vp9_settings.frameDroppingOn);
1918 1932
1919 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); 1933 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr));
1920 } 1934 }
1921 1935
1922 class Vp9SettingsTestWithFieldTrial : public Vp9SettingsTest { 1936 class Vp9SettingsTestWithFieldTrial : public Vp9SettingsTest {
1923 public: 1937 public:
1924 Vp9SettingsTestWithFieldTrial(const char* field_trials) 1938 explicit Vp9SettingsTestWithFieldTrial(const char* field_trials)
1925 : Vp9SettingsTest(field_trials) {} 1939 : Vp9SettingsTest(field_trials) {}
1926 1940
1927 protected: 1941 protected:
1928 void VerifySettings(int num_spatial_layers, int num_temporal_layers) { 1942 void VerifySettings(int num_spatial_layers, int num_temporal_layers) {
1929 cricket::VideoSendParameters parameters; 1943 cricket::VideoSendParameters parameters;
1930 parameters.codecs.push_back(kVp9Codec); 1944 parameters.codecs.push_back(kVp9Codec);
1931 ASSERT_TRUE(channel_->SetSendParameters(parameters)); 1945 ASSERT_TRUE(channel_->SetSendParameters(parameters));
1932 1946
1933 FakeVideoSendStream* stream = SetUpSimulcast(false, false); 1947 FakeVideoSendStream* stream = SetUpSimulcast(false, false);
1934 1948
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
2262 EXPECT_EQ(1000, config.rtp.nack.rtp_history_ms); 2276 EXPECT_EQ(1000, config.rtp.nack.rtp_history_ms);
2263 EXPECT_EQ(default_ulpfec_codec_.id, config.rtp.ulpfec.ulpfec_payload_type); 2277 EXPECT_EQ(default_ulpfec_codec_.id, config.rtp.ulpfec.ulpfec_payload_type);
2264 EXPECT_EQ(default_red_codec_.id, config.rtp.ulpfec.red_payload_type); 2278 EXPECT_EQ(default_red_codec_.id, config.rtp.ulpfec.red_payload_type);
2265 2279
2266 EXPECT_EQ(1u, config.rtp.rtx.ssrcs.size()); 2280 EXPECT_EQ(1u, config.rtp.rtx.ssrcs.size());
2267 EXPECT_EQ(kRtxSsrcs1[0], config.rtp.rtx.ssrcs[0]); 2281 EXPECT_EQ(kRtxSsrcs1[0], config.rtp.rtx.ssrcs[0]);
2268 VerifySendStreamHasRtxTypes(config, default_apt_rtx_types_); 2282 VerifySendStreamHasRtxTypes(config, default_apt_rtx_types_);
2269 // TODO(juberti): Check RTCP, PLI, TMMBR. 2283 // TODO(juberti): Check RTCP, PLI, TMMBR.
2270 } 2284 }
2271 2285
2286 // TODO(brandtr): Remove when FlexFEC _is_ exposed by default.
2287 TEST_F(WebRtcVideoChannel2Test, FlexfecCodecWithoutSsrcNotExposedByDefault) {
2288 FakeVideoSendStream* stream = AddSendStream();
2289 webrtc::VideoSendStream::Config config = stream->GetConfig().Copy();
2290
2291 EXPECT_EQ(-1, config.rtp.flexfec.flexfec_payload_type);
2292 }
2293
2294 // TODO(brandtr): Remove when FlexFEC _is_ exposed by default.
2295 TEST_F(WebRtcVideoChannel2Test, FlexfecCodecWithSsrcNotExposedByDefault) {
2296 FakeVideoSendStream* stream = AddSendStream(
2297 CreatePrimaryWithFecFrStreamParams("cname", kSsrcs1[0], kFlexfecSsrc));
2298 webrtc::VideoSendStream::Config config = stream->GetConfig().Copy();
2299
2300 EXPECT_EQ(-1, config.rtp.flexfec.flexfec_payload_type);
2301 }
2302
2303 // TODO(brandtr): Merge into "non-field trial" test when FlexFEC is enabled
2304 // by default.
2305 TEST_F(WebRtcVideoChannel2FlexfecTest, SetDefaultSendCodecsWithoutSsrc) {
2306 FakeVideoSendStream* stream = AddSendStream();
2307 webrtc::VideoSendStream::Config config = stream->GetConfig().Copy();
2308
2309 EXPECT_EQ(default_flexfec_codec_.id, config.rtp.flexfec.flexfec_payload_type);
2310 EXPECT_FALSE(config.rtp.flexfec.IsValid());
2311 }
2312
2313 // TODO(brandtr): Merge into "non-field trial" test when FlexFEC is enabled
2314 // by default.
2315 TEST_F(WebRtcVideoChannel2FlexfecTest, SetDefaultSendCodecsWithSsrc) {
2316 FakeVideoSendStream* stream = AddSendStream(
2317 CreatePrimaryWithFecFrStreamParams("cname", kSsrcs1[0], kFlexfecSsrc));
2318 webrtc::VideoSendStream::Config config = stream->GetConfig().Copy();
2319
2320 EXPECT_EQ(default_flexfec_codec_.id, config.rtp.flexfec.flexfec_payload_type);
2321 EXPECT_TRUE(config.rtp.flexfec.IsValid());
2322 }
2323
2272 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithoutFec) { 2324 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithoutFec) {
2273 cricket::VideoSendParameters parameters; 2325 cricket::VideoSendParameters parameters;
2274 parameters.codecs.push_back(kVp8Codec); 2326 parameters.codecs.push_back(kVp8Codec);
2275 ASSERT_TRUE(channel_->SetSendParameters(parameters)); 2327 ASSERT_TRUE(channel_->SetSendParameters(parameters));
2276 2328
2277 FakeVideoSendStream* stream = AddSendStream(); 2329 FakeVideoSendStream* stream = AddSendStream();
2278 webrtc::VideoSendStream::Config config = stream->GetConfig().Copy(); 2330 webrtc::VideoSendStream::Config config = stream->GetConfig().Copy();
2279 2331
2280 EXPECT_EQ(-1, config.rtp.ulpfec.ulpfec_payload_type); 2332 EXPECT_EQ(-1, config.rtp.ulpfec.ulpfec_payload_type);
2281 EXPECT_EQ(-1, config.rtp.ulpfec.red_payload_type); 2333 EXPECT_EQ(-1, config.rtp.ulpfec.red_payload_type);
2282 } 2334 }
2283 2335
2336 // TODO(brandtr): Merge into "non-field trial" test when FlexFEC is enabled
2337 // by default.
2338 TEST_F(WebRtcVideoChannel2FlexfecTest, SetSendCodecsWithoutFec) {
2339 cricket::VideoSendParameters parameters;
2340 parameters.codecs.push_back(kVp8Codec);
2341 ASSERT_TRUE(channel_->SetSendParameters(parameters));
2342
2343 FakeVideoSendStream* stream = AddSendStream();
2344 webrtc::VideoSendStream::Config config = stream->GetConfig().Copy();
2345
2346 EXPECT_EQ(-1, config.rtp.flexfec.flexfec_payload_type);
2347 }
2348
2284 TEST_F(WebRtcVideoChannel2Test, 2349 TEST_F(WebRtcVideoChannel2Test,
2285 SetSendCodecRejectsRtxWithoutAssociatedPayloadType) { 2350 SetSendCodecRejectsRtxWithoutAssociatedPayloadType) {
2286 cricket::VideoSendParameters parameters; 2351 cricket::VideoSendParameters parameters;
2287 cricket::VideoCodec rtx_codec(96, "rtx"); 2352 cricket::VideoCodec rtx_codec(96, "rtx");
2288 parameters.codecs.push_back(rtx_codec); 2353 parameters.codecs.push_back(rtx_codec);
2289 EXPECT_FALSE(channel_->SetSendParameters(parameters)) 2354 EXPECT_FALSE(channel_->SetSendParameters(parameters))
2290 << "RTX codec without associated payload type should be rejected."; 2355 << "RTX codec without associated payload type should be rejected.";
2291 } 2356 }
2292 2357
2293 TEST_F(WebRtcVideoChannel2Test, 2358 TEST_F(WebRtcVideoChannel2Test,
(...skipping 20 matching lines...) Expand all
2314 ASSERT_TRUE(channel_->SetSendParameters(parameters)); 2379 ASSERT_TRUE(channel_->SetSendParameters(parameters));
2315 2380
2316 FakeVideoSendStream* stream = AddSendStream(); 2381 FakeVideoSendStream* stream = AddSendStream();
2317 webrtc::VideoSendStream::Config config = stream->GetConfig().Copy(); 2382 webrtc::VideoSendStream::Config config = stream->GetConfig().Copy();
2318 2383
2319 EXPECT_EQ(kUlpfecCodec.id, config.rtp.ulpfec.ulpfec_payload_type); 2384 EXPECT_EQ(kUlpfecCodec.id, config.rtp.ulpfec.ulpfec_payload_type);
2320 2385
2321 parameters.codecs.pop_back(); 2386 parameters.codecs.pop_back();
2322 ASSERT_TRUE(channel_->SetSendParameters(parameters)); 2387 ASSERT_TRUE(channel_->SetSendParameters(parameters));
2323 stream = fake_call_->GetVideoSendStreams()[0]; 2388 stream = fake_call_->GetVideoSendStreams()[0];
2324 ASSERT_TRUE(stream != NULL); 2389 ASSERT_TRUE(stream != nullptr);
2325 config = stream->GetConfig().Copy(); 2390 config = stream->GetConfig().Copy();
2326 EXPECT_EQ(-1, config.rtp.ulpfec.ulpfec_payload_type) 2391 EXPECT_EQ(-1, config.rtp.ulpfec.ulpfec_payload_type)
2327 << "SetSendCodec without FEC should disable current FEC."; 2392 << "SetSendCodec without ULPFEC should disable current ULPFEC.";
2393 }
2394
2395 // TODO(brandtr): Merge into "non-field trial" test when FlexFEC is enabled
2396 // by default.
2397 TEST_F(WebRtcVideoChannel2FlexfecTest, SetSendCodecsWithoutFecDisablesFec) {
2398 cricket::VideoSendParameters parameters;
2399 parameters.codecs.push_back(kVp8Codec);
2400 parameters.codecs.push_back(kFlexfecCodec);
2401 ASSERT_TRUE(channel_->SetSendParameters(parameters));
2402
2403 FakeVideoSendStream* stream = AddSendStream(
2404 CreatePrimaryWithFecFrStreamParams("cname", kSsrcs1[0], kFlexfecSsrc));
2405 webrtc::VideoSendStream::Config config = stream->GetConfig().Copy();
2406
2407 EXPECT_EQ(kFlexfecCodec.id, config.rtp.flexfec.flexfec_payload_type);
2408 EXPECT_EQ(kFlexfecSsrc, config.rtp.flexfec.flexfec_ssrc);
2409 ASSERT_EQ(1U, config.rtp.flexfec.protected_media_ssrcs.size());
2410 EXPECT_EQ(kSsrcs1[0], config.rtp.flexfec.protected_media_ssrcs[0]);
2411
2412 parameters.codecs.pop_back();
2413 ASSERT_TRUE(channel_->SetSendParameters(parameters));
2414 stream = fake_call_->GetVideoSendStreams()[0];
2415 ASSERT_TRUE(stream != nullptr);
2416 config = stream->GetConfig().Copy();
2417 EXPECT_EQ(-1, config.rtp.flexfec.flexfec_payload_type)
2418 << "SetSendCodec without FlexFEC should disable current FlexFEC.";
2328 } 2419 }
2329 2420
2330 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsChangesExistingStreams) { 2421 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsChangesExistingStreams) {
2331 cricket::VideoSendParameters parameters; 2422 cricket::VideoSendParameters parameters;
2332 cricket::VideoCodec codec(100, "VP8"); 2423 cricket::VideoCodec codec(100, "VP8");
2333 codec.SetParam(kCodecParamMaxQuantization, kDefaultQpMax); 2424 codec.SetParam(kCodecParamMaxQuantization, kDefaultQpMax);
2334 parameters.codecs.push_back(codec); 2425 parameters.codecs.push_back(codec);
2335 2426
2336 ASSERT_TRUE(channel_->SetSendParameters(parameters)); 2427 ASSERT_TRUE(channel_->SetSendParameters(parameters));
2337 channel_->SetSend(true); 2428 channel_->SetSend(true);
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
2659 2750
2660 FakeVideoReceiveStream* stream = AddRecvStream(); 2751 FakeVideoReceiveStream* stream = AddRecvStream();
2661 2752
2662 EXPECT_EQ(kUlpfecCodec.id, 2753 EXPECT_EQ(kUlpfecCodec.id,
2663 stream->GetConfig().rtp.ulpfec.ulpfec_payload_type); 2754 stream->GetConfig().rtp.ulpfec.ulpfec_payload_type);
2664 2755
2665 cricket::VideoRecvParameters recv_parameters; 2756 cricket::VideoRecvParameters recv_parameters;
2666 recv_parameters.codecs.push_back(kVp8Codec); 2757 recv_parameters.codecs.push_back(kVp8Codec);
2667 ASSERT_TRUE(channel_->SetRecvParameters(recv_parameters)); 2758 ASSERT_TRUE(channel_->SetRecvParameters(recv_parameters));
2668 stream = fake_call_->GetVideoReceiveStreams()[0]; 2759 stream = fake_call_->GetVideoReceiveStreams()[0];
2669 ASSERT_TRUE(stream != NULL); 2760 ASSERT_TRUE(stream != nullptr);
2670 EXPECT_EQ(-1, stream->GetConfig().rtp.ulpfec.ulpfec_payload_type) 2761 EXPECT_EQ(-1, stream->GetConfig().rtp.ulpfec.ulpfec_payload_type)
2671 << "SetSendCodec without FEC should disable current FEC."; 2762 << "SetSendCodec without ULPFEC should disable current ULPFEC.";
2763 }
2764
2765 // TODO(brandtr): Merge into "non-field trial" test when FlexFEC is enabled
2766 // by default.
2767 TEST_F(WebRtcVideoChannel2FlexfecTest, SetRecvParamsWithoutFecDisablesFec) {
2768 cricket::VideoSendParameters send_parameters;
2769 send_parameters.codecs.push_back(kVp8Codec);
2770 send_parameters.codecs.push_back(kFlexfecCodec);
2771 ASSERT_TRUE(channel_->SetSendParameters(send_parameters));
2772
2773 AddRecvStream(
2774 CreatePrimaryWithFecFrStreamParams("cname", kSsrcs1[0], kFlexfecSsrc));
2775 const std::vector<FakeFlexfecReceiveStream*>& streams =
2776 fake_call_->GetFlexfecReceiveStreams();
2777
2778 EXPECT_EQ(1U, streams.size());
2779 EXPECT_EQ(kFlexfecCodec.id, streams[0]->GetConfig().flexfec_payload_type);
2780 EXPECT_EQ(kFlexfecSsrc, streams[0]->GetConfig().flexfec_ssrc);
2781 ASSERT_EQ(1U, streams[0]->GetConfig().protected_media_ssrcs.size());
2782 EXPECT_EQ(kSsrcs1[0], streams[0]->GetConfig().protected_media_ssrcs[0]);
2783
2784 cricket::VideoRecvParameters recv_parameters;
2785 recv_parameters.codecs.push_back(kVp8Codec);
2786 ASSERT_TRUE(channel_->SetRecvParameters(recv_parameters));
2787 EXPECT_TRUE(streams.empty())
2788 << "SetSendCodec without FlexFEC should disable current FlexFEC.";
2672 } 2789 }
2673 2790
2674 TEST_F(WebRtcVideoChannel2Test, SetSendParamsWithFecEnablesFec) { 2791 TEST_F(WebRtcVideoChannel2Test, SetSendParamsWithFecEnablesFec) {
2675 FakeVideoReceiveStream* stream = AddRecvStream(); 2792 FakeVideoReceiveStream* stream = AddRecvStream();
2676 EXPECT_EQ(kUlpfecCodec.id, 2793 EXPECT_EQ(kUlpfecCodec.id,
2677 stream->GetConfig().rtp.ulpfec.ulpfec_payload_type); 2794 stream->GetConfig().rtp.ulpfec.ulpfec_payload_type);
2678 2795
2679 cricket::VideoRecvParameters recv_parameters; 2796 cricket::VideoRecvParameters recv_parameters;
2680 recv_parameters.codecs.push_back(kVp8Codec); 2797 recv_parameters.codecs.push_back(kVp8Codec);
2681 recv_parameters.codecs.push_back(kRedCodec); 2798 recv_parameters.codecs.push_back(kRedCodec);
2682 recv_parameters.codecs.push_back(kUlpfecCodec); 2799 recv_parameters.codecs.push_back(kUlpfecCodec);
2683 ASSERT_TRUE(channel_->SetRecvParameters(recv_parameters)); 2800 ASSERT_TRUE(channel_->SetRecvParameters(recv_parameters));
2684 stream = fake_call_->GetVideoReceiveStreams()[0]; 2801 stream = fake_call_->GetVideoReceiveStreams()[0];
2685 ASSERT_TRUE(stream != NULL); 2802 ASSERT_TRUE(stream != nullptr);
2686 EXPECT_EQ(kUlpfecCodec.id, stream->GetConfig().rtp.ulpfec.ulpfec_payload_type) 2803 EXPECT_EQ(kUlpfecCodec.id, stream->GetConfig().rtp.ulpfec.ulpfec_payload_type)
2687 << "FEC should be enabled on the receive stream."; 2804 << "ULPFEC should be enabled on the receive stream.";
2688 2805
2689 cricket::VideoSendParameters send_parameters; 2806 cricket::VideoSendParameters send_parameters;
2690 send_parameters.codecs.push_back(kVp8Codec); 2807 send_parameters.codecs.push_back(kVp8Codec);
2691 send_parameters.codecs.push_back(kRedCodec); 2808 send_parameters.codecs.push_back(kRedCodec);
2692 send_parameters.codecs.push_back(kUlpfecCodec); 2809 send_parameters.codecs.push_back(kUlpfecCodec);
2693 ASSERT_TRUE(channel_->SetSendParameters(send_parameters)); 2810 ASSERT_TRUE(channel_->SetSendParameters(send_parameters));
2694 stream = fake_call_->GetVideoReceiveStreams()[0]; 2811 stream = fake_call_->GetVideoReceiveStreams()[0];
2695 EXPECT_EQ(kUlpfecCodec.id, stream->GetConfig().rtp.ulpfec.ulpfec_payload_type) 2812 EXPECT_EQ(kUlpfecCodec.id, stream->GetConfig().rtp.ulpfec.ulpfec_payload_type)
2696 << "FEC should be enabled on the receive stream."; 2813 << "ULPFEC should be enabled on the receive stream.";
2814 }
2815
2816 // TODO(brandtr): Merge into "non-field trial" test when FlexFEC is enabled
2817 // by default.
2818 TEST_F(WebRtcVideoChannel2FlexfecTest, SetSendParamsWithFecEnablesFec) {
2819 AddRecvStream(
2820 CreatePrimaryWithFecFrStreamParams("cname", kSsrcs1[0], kFlexfecSsrc));
2821 const std::vector<FakeFlexfecReceiveStream*>& streams =
2822 fake_call_->GetFlexfecReceiveStreams();
2823
2824 cricket::VideoRecvParameters recv_parameters;
2825 recv_parameters.codecs.push_back(kVp8Codec);
2826 recv_parameters.codecs.push_back(kFlexfecCodec);
2827 ASSERT_TRUE(channel_->SetRecvParameters(recv_parameters));
2828 EXPECT_EQ(1U, streams.size());
2829 EXPECT_EQ(kFlexfecCodec.id, streams[0]->GetConfig().flexfec_payload_type);
2830 EXPECT_EQ(kFlexfecSsrc, streams[0]->GetConfig().flexfec_ssrc);
2831 EXPECT_EQ(1U, streams[0]->GetConfig().protected_media_ssrcs.size());
2832 EXPECT_EQ(kSsrcs1[0], streams[0]->GetConfig().protected_media_ssrcs[0]);
2833
2834 cricket::VideoSendParameters send_parameters;
2835 send_parameters.codecs.push_back(kVp8Codec);
2836 send_parameters.codecs.push_back(kFlexfecCodec);
2837 EXPECT_EQ(1U, streams.size());
2838 EXPECT_EQ(kFlexfecCodec.id, streams[0]->GetConfig().flexfec_payload_type);
2839 EXPECT_EQ(kFlexfecSsrc, streams[0]->GetConfig().flexfec_ssrc);
2840 EXPECT_EQ(1U, streams[0]->GetConfig().protected_media_ssrcs.size());
2841 EXPECT_EQ(kSsrcs1[0], streams[0]->GetConfig().protected_media_ssrcs[0]);
2697 } 2842 }
2698 2843
2699 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsRejectDuplicateFecPayloads) { 2844 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsRejectDuplicateFecPayloads) {
2700 cricket::VideoRecvParameters parameters; 2845 cricket::VideoRecvParameters parameters;
2701 parameters.codecs.push_back(kVp8Codec); 2846 parameters.codecs.push_back(kVp8Codec);
2702 parameters.codecs.push_back(kRedCodec); 2847 parameters.codecs.push_back(kRedCodec);
2703 parameters.codecs[1].id = parameters.codecs[0].id; 2848 parameters.codecs[1].id = parameters.codecs[0].id;
2704 EXPECT_FALSE(channel_->SetRecvParameters(parameters)); 2849 EXPECT_FALSE(channel_->SetRecvParameters(parameters));
2705 } 2850 }
2706 2851
2852 // TODO(brandtr): Merge into "non-field trial" test when FlexFEC is enabled
2853 // by default.
2854 TEST_F(WebRtcVideoChannel2FlexfecTest,
2855 SetSendCodecsRejectDuplicateFecPayloads) {
2856 cricket::VideoRecvParameters parameters;
2857 parameters.codecs.push_back(kVp8Codec);
2858 parameters.codecs.push_back(kFlexfecCodec);
2859 parameters.codecs[1].id = parameters.codecs[0].id;
2860 EXPECT_FALSE(channel_->SetRecvParameters(parameters));
2861 }
2862
2707 TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsRejectDuplicateCodecPayloads) { 2863 TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsRejectDuplicateCodecPayloads) {
2708 cricket::VideoRecvParameters parameters; 2864 cricket::VideoRecvParameters parameters;
2709 parameters.codecs.push_back(kVp8Codec); 2865 parameters.codecs.push_back(kVp8Codec);
2710 parameters.codecs.push_back(kVp9Codec); 2866 parameters.codecs.push_back(kVp9Codec);
2711 parameters.codecs[1].id = parameters.codecs[0].id; 2867 parameters.codecs[1].id = parameters.codecs[0].id;
2712 EXPECT_FALSE(channel_->SetRecvParameters(parameters)); 2868 EXPECT_FALSE(channel_->SetRecvParameters(parameters));
2713 } 2869 }
2714 2870
2715 TEST_F(WebRtcVideoChannel2Test, 2871 TEST_F(WebRtcVideoChannel2Test,
2716 SetRecvCodecsAcceptSameCodecOnMultiplePayloadTypes) { 2872 SetRecvCodecsAcceptSameCodecOnMultiplePayloadTypes) {
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after
3327 } 3483 }
3328 3484
3329 TEST_F(WebRtcVideoChannel2Test, RtxPacketDoesntCreateUnsignalledStream) { 3485 TEST_F(WebRtcVideoChannel2Test, RtxPacketDoesntCreateUnsignalledStream) {
3330 TestReceiveUnsignalledSsrcPacket(kDefaultRtxVp8PlType, false); 3486 TestReceiveUnsignalledSsrcPacket(kDefaultRtxVp8PlType, false);
3331 } 3487 }
3332 3488
3333 TEST_F(WebRtcVideoChannel2Test, UlpfecPacketDoesntCreateUnsignalledStream) { 3489 TEST_F(WebRtcVideoChannel2Test, UlpfecPacketDoesntCreateUnsignalledStream) {
3334 TestReceiveUnsignalledSsrcPacket(kDefaultUlpfecType, false); 3490 TestReceiveUnsignalledSsrcPacket(kDefaultUlpfecType, false);
3335 } 3491 }
3336 3492
3493 // TODO(brandtr): Change to "non-field trial" test when FlexFEC is enabled
3494 // by default.
3495 TEST_F(WebRtcVideoChannel2FlexfecTest,
3496 FlexfecPacketDoesntCreateUnsignalledStream) {
3497 TestReceiveUnsignalledSsrcPacket(kDefaultFlexfecPlType, false);
3498 }
3499
3337 TEST_F(WebRtcVideoChannel2Test, RedRtxPacketDoesntCreateUnsignalledStream) { 3500 TEST_F(WebRtcVideoChannel2Test, RedRtxPacketDoesntCreateUnsignalledStream) {
3338 TestReceiveUnsignalledSsrcPacket(kRedRtxPayloadType, false); 3501 TestReceiveUnsignalledSsrcPacket(kRedRtxPayloadType, false);
3339 } 3502 }
3340 3503
3341 TEST_F(WebRtcVideoChannel2Test, CanSentMaxBitrateForExistingStream) { 3504 TEST_F(WebRtcVideoChannel2Test, CanSentMaxBitrateForExistingStream) {
3342 AddSendStream(); 3505 AddSendStream();
3343 3506
3344 cricket::FakeVideoCapturer capturer; 3507 cricket::FakeVideoCapturer capturer;
3345 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, &capturer)); 3508 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, &capturer));
3346 cricket::VideoFormat capture_format_hd = 3509 cricket::VideoFormat capture_format_hd =
3347 capturer.GetSupportedFormats()->front(); 3510 capturer.GetSupportedFormats()->front();
3348 EXPECT_EQ(1280, capture_format_hd.width); 3511 EXPECT_EQ(1280, capture_format_hd.width);
3349 EXPECT_EQ(720, capture_format_hd.height); 3512 EXPECT_EQ(720, capture_format_hd.height);
3350 EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(capture_format_hd)); 3513 EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(capture_format_hd));
3351 EXPECT_TRUE(channel_->SetSend(true)); 3514 EXPECT_TRUE(channel_->SetSend(true));
3352 capturer.CaptureFrame(); 3515 capturer.CaptureFrame();
3353 3516
3354 int default_encoder_bitrate = GetMaxEncoderBitrate(); 3517 int default_encoder_bitrate = GetMaxEncoderBitrate();
3355 EXPECT_TRUE(default_encoder_bitrate > 1000); 3518 EXPECT_GT(default_encoder_bitrate, 1000);
3356 3519
3357 // TODO(skvlad): Resolve the inconsistency between the interpretation 3520 // TODO(skvlad): Resolve the inconsistency between the interpretation
3358 // of the global bitrate limit for audio and video: 3521 // of the global bitrate limit for audio and video:
3359 // - Audio: max_bandwidth_bps = 0 - fail the operation, 3522 // - Audio: max_bandwidth_bps = 0 - fail the operation,
3360 // max_bandwidth_bps = -1 - remove the bandwidth limit 3523 // max_bandwidth_bps = -1 - remove the bandwidth limit
3361 // - Video: max_bandwidth_bps = 0 - remove the bandwidth limit, 3524 // - Video: max_bandwidth_bps = 0 - remove the bandwidth limit,
3362 // max_bandwidth_bps = -1 - do not change the previously set 3525 // max_bandwidth_bps = -1 - do not change the previously set
3363 // limit. 3526 // limit.
3364 3527
3365 SetAndExpectMaxBitrate(1000, 0, 1000); 3528 SetAndExpectMaxBitrate(1000, 0, 1000);
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
3767 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWith3SimulcastStreams) { 3930 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWith3SimulcastStreams) {
3768 VerifySimulcastSettings(kVp8Codec, 1280, 720, 3, 3); 3931 VerifySimulcastSettings(kVp8Codec, 1280, 720, 3, 3);
3769 } 3932 }
3770 3933
3771 // Test that we normalize send codec format size in simulcast. 3934 // Test that we normalize send codec format size in simulcast.
3772 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWithOddSizeInSimulcast) { 3935 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWithOddSizeInSimulcast) {
3773 cricket::VideoCodec codec(kVp8Codec); 3936 cricket::VideoCodec codec(kVp8Codec);
3774 VerifySimulcastSettings(codec, 541, 271, 2, 2); 3937 VerifySimulcastSettings(codec, 541, 271, 2, 2);
3775 } 3938 }
3776 } // namespace cricket 3939 } // namespace cricket
OLDNEW
« webrtc/media/engine/webrtcvideoengine2.cc ('K') | « webrtc/media/engine/webrtcvideoengine2.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698