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

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

Issue 1269863005: MediaController/Call instantiation. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase+comments Created 5 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
OLDNEW
1 /* 1 /*
2 * libjingle 2 * libjingle
3 * Copyright 2004 Google Inc. 3 * Copyright 2004 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 it->second == config.rtp.fec.red_rtx_payload_type); 103 it->second == config.rtp.fec.red_rtx_payload_type);
104 } 104 }
105 } 105 }
106 } // namespace 106 } // namespace
107 107
108 namespace cricket { 108 namespace cricket {
109 class WebRtcVideoEngine2Test : public ::testing::Test { 109 class WebRtcVideoEngine2Test : public ::testing::Test {
110 public: 110 public:
111 WebRtcVideoEngine2Test() : WebRtcVideoEngine2Test(nullptr) {} 111 WebRtcVideoEngine2Test() : WebRtcVideoEngine2Test(nullptr) {}
112 WebRtcVideoEngine2Test(WebRtcVoiceEngine* voice_engine) 112 WebRtcVideoEngine2Test(WebRtcVoiceEngine* voice_engine)
113 : engine_(voice_engine) { 113 : call_(webrtc::Call::Create(webrtc::Call::Config())),
114 engine_() {
114 std::vector<VideoCodec> engine_codecs = engine_.codecs(); 115 std::vector<VideoCodec> engine_codecs = engine_.codecs();
115 DCHECK(!engine_codecs.empty()); 116 DCHECK(!engine_codecs.empty());
116 bool codec_set = false; 117 bool codec_set = false;
117 for (size_t i = 0; i < engine_codecs.size(); ++i) { 118 for (size_t i = 0; i < engine_codecs.size(); ++i) {
118 if (engine_codecs[i].name == "red") { 119 if (engine_codecs[i].name == "red") {
119 default_red_codec_ = engine_codecs[i]; 120 default_red_codec_ = engine_codecs[i];
120 } else if (engine_codecs[i].name == "ulpfec") { 121 } else if (engine_codecs[i].name == "ulpfec") {
121 default_ulpfec_codec_ = engine_codecs[i]; 122 default_ulpfec_codec_ = engine_codecs[i];
122 } else if (engine_codecs[i].name == "rtx") { 123 } else if (engine_codecs[i].name == "rtx") {
123 int associated_payload_type; 124 int associated_payload_type;
124 if (engine_codecs[i].GetParam(kCodecParamAssociatedPayloadType, 125 if (engine_codecs[i].GetParam(kCodecParamAssociatedPayloadType,
125 &associated_payload_type)) { 126 &associated_payload_type)) {
126 default_apt_rtx_types_[associated_payload_type] = engine_codecs[i].id; 127 default_apt_rtx_types_[associated_payload_type] = engine_codecs[i].id;
127 } 128 }
128 } else if (!codec_set) { 129 } else if (!codec_set) {
129 default_codec_ = engine_codecs[i]; 130 default_codec_ = engine_codecs[i];
130 codec_set = true; 131 codec_set = true;
131 } 132 }
132 } 133 }
133 134
134 DCHECK(codec_set); 135 DCHECK(codec_set);
135 } 136 }
136 137
137 protected: 138 protected:
138 class FakeCallFactory : public WebRtcCallFactory {
139 public:
140 FakeCallFactory() : fake_call_(NULL) {}
141 FakeCall* GetCall() { return fake_call_; }
142
143 private:
144 webrtc::Call* CreateCall(const webrtc::Call::Config& config) override {
145 DCHECK(fake_call_ == NULL);
146 fake_call_ = new FakeCall(config);
147 return fake_call_;
148 }
149
150 FakeCall* fake_call_;
151 };
152
153 VideoMediaChannel* SetUpForExternalEncoderFactory( 139 VideoMediaChannel* SetUpForExternalEncoderFactory(
154 cricket::WebRtcVideoEncoderFactory* encoder_factory, 140 cricket::WebRtcVideoEncoderFactory* encoder_factory,
155 const std::vector<VideoCodec>& codecs); 141 const std::vector<VideoCodec>& codecs);
156 142
157 VideoMediaChannel* SetUpForExternalDecoderFactory( 143 VideoMediaChannel* SetUpForExternalDecoderFactory(
158 cricket::WebRtcVideoDecoderFactory* decoder_factory, 144 cricket::WebRtcVideoDecoderFactory* decoder_factory,
159 const std::vector<VideoCodec>& codecs); 145 const std::vector<VideoCodec>& codecs);
160 146
161 // Used in WebRtcVideoEngine2VoiceTest, but defined here so it's properly 147 // Used in WebRtcVideoEngine2VoiceTest, but defined here so it's properly
162 // initialized when the constructor is called. 148 // initialized when the constructor is called.
149 rtc::scoped_ptr<webrtc::Call> call_;
163 WebRtcVoiceEngine voice_engine_; 150 WebRtcVoiceEngine voice_engine_;
164 WebRtcVideoEngine2 engine_; 151 WebRtcVideoEngine2 engine_;
165 VideoCodec default_codec_; 152 VideoCodec default_codec_;
166 VideoCodec default_red_codec_; 153 VideoCodec default_red_codec_;
167 VideoCodec default_ulpfec_codec_; 154 VideoCodec default_ulpfec_codec_;
168 std::map<int, int> default_apt_rtx_types_; 155 std::map<int, int> default_apt_rtx_types_;
169 }; 156 };
170 157
171 TEST_F(WebRtcVideoEngine2Test, FindCodec) { 158 TEST_F(WebRtcVideoEngine2Test, FindCodec) {
172 const std::vector<cricket::VideoCodec>& c = engine_.codecs(); 159 const std::vector<cricket::VideoCodec>& c = engine_.codecs();
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 330
344 // Verify removing header extension turns on applying rotation. 331 // Verify removing header extension turns on applying rotation.
345 extensions.clear(); 332 extensions.clear();
346 EXPECT_TRUE(channel->SetSendRtpHeaderExtensions(extensions)); 333 EXPECT_TRUE(channel->SetSendRtpHeaderExtensions(extensions));
347 EXPECT_TRUE(capturer.GetApplyRotation()); 334 EXPECT_TRUE(capturer.GetApplyRotation());
348 } 335 }
349 336
350 TEST_F(WebRtcVideoEngine2Test, SetSendFailsBeforeSettingCodecs) { 337 TEST_F(WebRtcVideoEngine2Test, SetSendFailsBeforeSettingCodecs) {
351 engine_.Init(); 338 engine_.Init();
352 rtc::scoped_ptr<VideoMediaChannel> channel( 339 rtc::scoped_ptr<VideoMediaChannel> channel(
353 engine_.CreateChannel(cricket::VideoOptions(), NULL)); 340 engine_.CreateChannel(call_.get(), cricket::VideoOptions()));
354 341
355 EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(123))); 342 EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(123)));
356 343
357 EXPECT_FALSE(channel->SetSend(true)) 344 EXPECT_FALSE(channel->SetSend(true))
358 << "Channel should not start without codecs."; 345 << "Channel should not start without codecs.";
359 EXPECT_TRUE(channel->SetSend(false)) 346 EXPECT_TRUE(channel->SetSend(false))
360 << "Channel should be stoppable even without set codecs."; 347 << "Channel should be stoppable even without set codecs.";
361 } 348 }
362 349
363 TEST_F(WebRtcVideoEngine2Test, GetStatsWithoutSendCodecsSetDoesNotCrash) { 350 TEST_F(WebRtcVideoEngine2Test, GetStatsWithoutSendCodecsSetDoesNotCrash) {
364 engine_.Init(); 351 engine_.Init();
365 rtc::scoped_ptr<VideoMediaChannel> channel( 352 rtc::scoped_ptr<VideoMediaChannel> channel(
366 engine_.CreateChannel(cricket::VideoOptions(), NULL)); 353 engine_.CreateChannel(call_.get(), cricket::VideoOptions()));
367 EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(123))); 354 EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(123)));
368 VideoMediaInfo info; 355 VideoMediaInfo info;
369 channel->GetStats(&info); 356 channel->GetStats(&info);
370 } 357 }
371 358
372 TEST_F(WebRtcVideoEngine2Test, UseExternalFactoryForVp8WhenSupported) { 359 TEST_F(WebRtcVideoEngine2Test, UseExternalFactoryForVp8WhenSupported) {
373 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; 360 cricket::FakeWebRtcVideoEncoderFactory encoder_factory;
374 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8"); 361 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8");
375 std::vector<cricket::VideoCodec> codecs; 362 std::vector<cricket::VideoCodec> codecs;
376 codecs.push_back(kVp8Codec); 363 codecs.push_back(kVp8Codec);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 EXPECT_TRUE( 405 EXPECT_TRUE(
419 channel->AddRecvStream(cricket::StreamParams::CreateLegacy(kSsrc))); 406 channel->AddRecvStream(cricket::StreamParams::CreateLegacy(kSsrc)));
420 } 407 }
421 408
422 TEST_F(WebRtcVideoEngine2Test, PropagatesInputFrameTimestamp) { 409 TEST_F(WebRtcVideoEngine2Test, PropagatesInputFrameTimestamp) {
423 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; 410 cricket::FakeWebRtcVideoEncoderFactory encoder_factory;
424 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8"); 411 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8");
425 std::vector<cricket::VideoCodec> codecs; 412 std::vector<cricket::VideoCodec> codecs;
426 codecs.push_back(kVp8Codec); 413 codecs.push_back(kVp8Codec);
427 414
428 FakeCallFactory factory; 415 FakeCall* fake_call = new FakeCall(webrtc::Call::Config());
429 engine_.SetCallFactory(&factory); 416 call_.reset(fake_call);
430 rtc::scoped_ptr<VideoMediaChannel> channel( 417 rtc::scoped_ptr<VideoMediaChannel> channel(
431 SetUpForExternalEncoderFactory(&encoder_factory, codecs)); 418 SetUpForExternalEncoderFactory(&encoder_factory, codecs));
432 419
433 EXPECT_TRUE( 420 EXPECT_TRUE(
434 channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc))); 421 channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc)));
435 422
436 FakeVideoCapturer capturer; 423 FakeVideoCapturer capturer;
437 EXPECT_TRUE(channel->SetCapturer(kSsrc, &capturer)); 424 EXPECT_TRUE(channel->SetCapturer(kSsrc, &capturer));
438 capturer.Start(cricket::VideoFormat(1280, 720, 425 capturer.Start(cricket::VideoFormat(1280, 720,
439 cricket::VideoFormat::FpsToInterval(60), 426 cricket::VideoFormat::FpsToInterval(60),
440 cricket::FOURCC_I420)); 427 cricket::FOURCC_I420));
441 channel->SetSend(true); 428 channel->SetSend(true);
442 429
443 FakeCall* call = factory.GetCall(); 430 std::vector<FakeVideoSendStream*> streams = fake_call->GetVideoSendStreams();
444 std::vector<FakeVideoSendStream*> streams = call->GetVideoSendStreams();
445 FakeVideoSendStream* stream = streams[0]; 431 FakeVideoSendStream* stream = streams[0];
446 432
447 int64_t timestamp; 433 int64_t timestamp;
448 int64_t last_timestamp; 434 int64_t last_timestamp;
449 435
450 EXPECT_TRUE(capturer.CaptureFrame()); 436 EXPECT_TRUE(capturer.CaptureFrame());
451 last_timestamp = stream->GetLastTimestamp(); 437 last_timestamp = stream->GetLastTimestamp();
452 for (int i = 0; i < 10; i++) { 438 for (int i = 0; i < 10; i++) {
453 EXPECT_TRUE(capturer.CaptureFrame()); 439 EXPECT_TRUE(capturer.CaptureFrame());
454 timestamp = stream->GetLastTimestamp(); 440 timestamp = stream->GetLastTimestamp();
(...skipping 28 matching lines...) Expand all
483 EXPECT_TRUE(channel->RemoveSendStream(kSsrc)); 469 EXPECT_TRUE(channel->RemoveSendStream(kSsrc));
484 } 470 }
485 471
486 VideoMediaChannel* WebRtcVideoEngine2Test::SetUpForExternalEncoderFactory( 472 VideoMediaChannel* WebRtcVideoEngine2Test::SetUpForExternalEncoderFactory(
487 cricket::WebRtcVideoEncoderFactory* encoder_factory, 473 cricket::WebRtcVideoEncoderFactory* encoder_factory,
488 const std::vector<VideoCodec>& codecs) { 474 const std::vector<VideoCodec>& codecs) {
489 engine_.SetExternalEncoderFactory(encoder_factory); 475 engine_.SetExternalEncoderFactory(encoder_factory);
490 engine_.Init(); 476 engine_.Init();
491 477
492 VideoMediaChannel* channel = 478 VideoMediaChannel* channel =
493 engine_.CreateChannel(cricket::VideoOptions(), NULL); 479 engine_.CreateChannel(call_.get(), cricket::VideoOptions());
494 EXPECT_TRUE(channel->SetSendCodecs(codecs)); 480 EXPECT_TRUE(channel->SetSendCodecs(codecs));
495 481
496 return channel; 482 return channel;
497 } 483 }
498 484
499 VideoMediaChannel* WebRtcVideoEngine2Test::SetUpForExternalDecoderFactory( 485 VideoMediaChannel* WebRtcVideoEngine2Test::SetUpForExternalDecoderFactory(
500 cricket::WebRtcVideoDecoderFactory* decoder_factory, 486 cricket::WebRtcVideoDecoderFactory* decoder_factory,
501 const std::vector<VideoCodec>& codecs) { 487 const std::vector<VideoCodec>& codecs) {
502 engine_.SetExternalDecoderFactory(decoder_factory); 488 engine_.SetExternalDecoderFactory(decoder_factory);
503 engine_.Init(); 489 engine_.Init();
504 490
505 VideoMediaChannel* channel = 491 VideoMediaChannel* channel =
506 engine_.CreateChannel(cricket::VideoOptions(), NULL); 492 engine_.CreateChannel(call_.get(), cricket::VideoOptions());
507 EXPECT_TRUE(channel->SetRecvCodecs(codecs)); 493 EXPECT_TRUE(channel->SetRecvCodecs(codecs));
508 494
509 return channel; 495 return channel;
510 } 496 }
511 497
512 TEST_F(WebRtcVideoEngine2Test, UsesSimulcastAdapterForVp8Factories) { 498 TEST_F(WebRtcVideoEngine2Test, UsesSimulcastAdapterForVp8Factories) {
513 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; 499 cricket::FakeWebRtcVideoEncoderFactory encoder_factory;
514 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8"); 500 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8");
515 std::vector<cricket::VideoCodec> codecs; 501 std::vector<cricket::VideoCodec> codecs;
516 codecs.push_back(kVp8Codec); 502 codecs.push_back(kVp8Codec);
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 EXPECT_TRUE(SetOneCodec(codec)); 833 EXPECT_TRUE(SetOneCodec(codec));
848 codec.width /= 2; 834 codec.width /= 2;
849 codec.height /= 2; 835 codec.height /= 2;
850 EXPECT_TRUE(SetSend(true)); 836 EXPECT_TRUE(SetSend(true));
851 EXPECT_TRUE(channel_->SetRender(true)); 837 EXPECT_TRUE(channel_->SetRender(true));
852 EXPECT_EQ(0, renderer_.num_rendered_frames()); 838 EXPECT_EQ(0, renderer_.num_rendered_frames());
853 EXPECT_TRUE(SendFrame()); 839 EXPECT_TRUE(SendFrame());
854 EXPECT_FRAME_WAIT(1, codec.width, codec.height, kTimeout); 840 EXPECT_FRAME_WAIT(1, codec.width, codec.height, kTimeout);
855 } 841 }
856 842
857 class WebRtcVideoChannel2Test : public WebRtcVideoEngine2Test, 843 class WebRtcVideoChannel2Test : public WebRtcVideoEngine2Test {
858 public WebRtcCallFactory {
859 public: 844 public:
860 WebRtcVideoChannel2Test() : fake_call_(NULL), last_ssrc_(0) {} 845 WebRtcVideoChannel2Test() : last_ssrc_(0) {}
861 void SetUp() override { 846 void SetUp() override {
862 engine_.SetCallFactory(this); 847 fake_call_.reset(new FakeCall(webrtc::Call::Config()));
863 engine_.Init(); 848 engine_.Init();
864 channel_.reset(engine_.CreateChannel(cricket::VideoOptions(), NULL)); 849 channel_.reset(
865 ASSERT_TRUE(fake_call_ != NULL) << "Call not created through factory."; 850 engine_.CreateChannel(fake_call_.get(), cricket::VideoOptions()));
866 last_ssrc_ = 123; 851 last_ssrc_ = 123;
867 ASSERT_TRUE(channel_->SetSendCodecs(engine_.codecs())); 852 ASSERT_TRUE(channel_->SetSendCodecs(engine_.codecs()));
868 } 853 }
869 854
870 protected: 855 protected:
871 virtual std::vector<cricket::VideoCodec> GetCodecs() { 856 virtual std::vector<cricket::VideoCodec> GetCodecs() {
872 return engine_.codecs(); 857 return engine_.codecs();
873 } 858 }
874 859
875 webrtc::Call* CreateCall(const webrtc::Call::Config& config) override {
876 DCHECK(fake_call_ == NULL);
877 fake_call_ = new FakeCall(config);
878 return fake_call_;
879 }
880
881 FakeVideoSendStream* AddSendStream() { 860 FakeVideoSendStream* AddSendStream() {
882 return AddSendStream(StreamParams::CreateLegacy(++last_ssrc_)); 861 return AddSendStream(StreamParams::CreateLegacy(++last_ssrc_));
883 } 862 }
884 863
885 FakeVideoSendStream* AddSendStream(const StreamParams& sp) { 864 FakeVideoSendStream* AddSendStream(const StreamParams& sp) {
886 size_t num_streams = fake_call_->GetVideoSendStreams().size(); 865 size_t num_streams = fake_call_->GetVideoSendStreams().size();
887 EXPECT_TRUE(channel_->AddSendStream(sp)); 866 EXPECT_TRUE(channel_->AddSendStream(sp));
888 std::vector<FakeVideoSendStream*> streams = 867 std::vector<FakeVideoSendStream*> streams =
889 fake_call_->GetVideoSendStreams(); 868 fake_call_->GetVideoSendStreams();
890 EXPECT_EQ(num_streams + 1, streams.size()); 869 EXPECT_EQ(num_streams + 1, streams.size());
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
924 EXPECT_EQ(expected_min_bitrate_bps, 903 EXPECT_EQ(expected_min_bitrate_bps,
925 fake_call_->GetConfig().bitrate_config.min_bitrate_bps); 904 fake_call_->GetConfig().bitrate_config.min_bitrate_bps);
926 EXPECT_EQ(expected_start_bitrate_bps, 905 EXPECT_EQ(expected_start_bitrate_bps,
927 fake_call_->GetConfig().bitrate_config.start_bitrate_bps); 906 fake_call_->GetConfig().bitrate_config.start_bitrate_bps);
928 EXPECT_EQ(expected_max_bitrate_bps, 907 EXPECT_EQ(expected_max_bitrate_bps,
929 fake_call_->GetConfig().bitrate_config.max_bitrate_bps); 908 fake_call_->GetConfig().bitrate_config.max_bitrate_bps);
930 } 909 }
931 910
932 void TestSetSendRtpHeaderExtensions(const std::string& cricket_ext, 911 void TestSetSendRtpHeaderExtensions(const std::string& cricket_ext,
933 const std::string& webrtc_ext) { 912 const std::string& webrtc_ext) {
934 FakeCall* call = fake_call_;
935 // Enable extension. 913 // Enable extension.
936 const int id = 1; 914 const int id = 1;
937 std::vector<cricket::RtpHeaderExtension> extensions; 915 std::vector<cricket::RtpHeaderExtension> extensions;
938 extensions.push_back(cricket::RtpHeaderExtension(cricket_ext, id)); 916 extensions.push_back(cricket::RtpHeaderExtension(cricket_ext, id));
939 EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(extensions)); 917 EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(extensions));
940 918
941 FakeVideoSendStream* send_stream = 919 FakeVideoSendStream* send_stream =
942 AddSendStream(cricket::StreamParams::CreateLegacy(123)); 920 AddSendStream(cricket::StreamParams::CreateLegacy(123));
943 921
944 // Verify the send extension id. 922 // Verify the send extension id.
945 ASSERT_EQ(1u, send_stream->GetConfig().rtp.extensions.size()); 923 ASSERT_EQ(1u, send_stream->GetConfig().rtp.extensions.size());
946 EXPECT_EQ(id, send_stream->GetConfig().rtp.extensions[0].id); 924 EXPECT_EQ(id, send_stream->GetConfig().rtp.extensions[0].id);
947 EXPECT_EQ(webrtc_ext, send_stream->GetConfig().rtp.extensions[0].name); 925 EXPECT_EQ(webrtc_ext, send_stream->GetConfig().rtp.extensions[0].name);
948 // Verify call with same set of extensions returns true. 926 // Verify call with same set of extensions returns true.
949 EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(extensions)); 927 EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(extensions));
950 // Verify that SetSendRtpHeaderExtensions doesn't implicitly add them for 928 // Verify that SetSendRtpHeaderExtensions doesn't implicitly add them for
951 // receivers. 929 // receivers.
952 EXPECT_TRUE(AddRecvStream(cricket::StreamParams::CreateLegacy(123)) 930 EXPECT_TRUE(AddRecvStream(cricket::StreamParams::CreateLegacy(123))
953 ->GetConfig() 931 ->GetConfig()
954 .rtp.extensions.empty()); 932 .rtp.extensions.empty());
955 933
956 // Verify that existing RTP header extensions can be removed. 934 // Verify that existing RTP header extensions can be removed.
957 std::vector<cricket::RtpHeaderExtension> empty_extensions; 935 std::vector<cricket::RtpHeaderExtension> empty_extensions;
958 EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(empty_extensions)); 936 EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(empty_extensions));
959 ASSERT_EQ(1u, call->GetVideoSendStreams().size()); 937 ASSERT_EQ(1u, fake_call_->GetVideoSendStreams().size());
960 send_stream = call->GetVideoSendStreams()[0]; 938 send_stream = fake_call_->GetVideoSendStreams()[0];
961 EXPECT_TRUE(send_stream->GetConfig().rtp.extensions.empty()); 939 EXPECT_TRUE(send_stream->GetConfig().rtp.extensions.empty());
962 940
963 // Verify that adding receive RTP header extensions adds them for existing 941 // Verify that adding receive RTP header extensions adds them for existing
964 // streams. 942 // streams.
965 EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(extensions)); 943 EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(extensions));
966 send_stream = call->GetVideoSendStreams()[0]; 944 send_stream = fake_call_->GetVideoSendStreams()[0];
967 ASSERT_EQ(1u, send_stream->GetConfig().rtp.extensions.size()); 945 ASSERT_EQ(1u, send_stream->GetConfig().rtp.extensions.size());
968 EXPECT_EQ(id, send_stream->GetConfig().rtp.extensions[0].id); 946 EXPECT_EQ(id, send_stream->GetConfig().rtp.extensions[0].id);
969 EXPECT_EQ(webrtc_ext, send_stream->GetConfig().rtp.extensions[0].name); 947 EXPECT_EQ(webrtc_ext, send_stream->GetConfig().rtp.extensions[0].name);
970 } 948 }
971 949
972 void TestSetRecvRtpHeaderExtensions(const std::string& cricket_ext, 950 void TestSetRecvRtpHeaderExtensions(const std::string& cricket_ext,
973 const std::string& webrtc_ext) { 951 const std::string& webrtc_ext) {
974 FakeCall* call = fake_call_;
975 // Enable extension. 952 // Enable extension.
976 const int id = 1; 953 const int id = 1;
977 std::vector<cricket::RtpHeaderExtension> extensions; 954 std::vector<cricket::RtpHeaderExtension> extensions;
978 extensions.push_back(cricket::RtpHeaderExtension(cricket_ext, id)); 955 extensions.push_back(cricket::RtpHeaderExtension(cricket_ext, id));
979 EXPECT_TRUE(channel_->SetRecvRtpHeaderExtensions(extensions)); 956 EXPECT_TRUE(channel_->SetRecvRtpHeaderExtensions(extensions));
980 957
981 FakeVideoReceiveStream* recv_stream = 958 FakeVideoReceiveStream* recv_stream =
982 AddRecvStream(cricket::StreamParams::CreateLegacy(123)); 959 AddRecvStream(cricket::StreamParams::CreateLegacy(123));
983 960
984 // Verify the recv extension id. 961 // Verify the recv extension id.
985 ASSERT_EQ(1u, recv_stream->GetConfig().rtp.extensions.size()); 962 ASSERT_EQ(1u, recv_stream->GetConfig().rtp.extensions.size());
986 EXPECT_EQ(id, recv_stream->GetConfig().rtp.extensions[0].id); 963 EXPECT_EQ(id, recv_stream->GetConfig().rtp.extensions[0].id);
987 EXPECT_EQ(webrtc_ext, recv_stream->GetConfig().rtp.extensions[0].name); 964 EXPECT_EQ(webrtc_ext, recv_stream->GetConfig().rtp.extensions[0].name);
988 // Verify call with same set of extensions returns true. 965 // Verify call with same set of extensions returns true.
989 EXPECT_TRUE(channel_->SetRecvRtpHeaderExtensions(extensions)); 966 EXPECT_TRUE(channel_->SetRecvRtpHeaderExtensions(extensions));
990 967
991 // Verify that SetRecvRtpHeaderExtensions doesn't implicitly add them for 968 // Verify that SetRecvRtpHeaderExtensions doesn't implicitly add them for
992 // senders. 969 // senders.
993 EXPECT_TRUE(AddSendStream(cricket::StreamParams::CreateLegacy(123)) 970 EXPECT_TRUE(AddSendStream(cricket::StreamParams::CreateLegacy(123))
994 ->GetConfig() 971 ->GetConfig()
995 .rtp.extensions.empty()); 972 .rtp.extensions.empty());
996 973
997 // Verify that existing RTP header extensions can be removed. 974 // Verify that existing RTP header extensions can be removed.
998 std::vector<cricket::RtpHeaderExtension> empty_extensions; 975 std::vector<cricket::RtpHeaderExtension> empty_extensions;
999 EXPECT_TRUE(channel_->SetRecvRtpHeaderExtensions(empty_extensions)); 976 EXPECT_TRUE(channel_->SetRecvRtpHeaderExtensions(empty_extensions));
1000 ASSERT_EQ(1u, call->GetVideoReceiveStreams().size()); 977 ASSERT_EQ(1u, fake_call_->GetVideoReceiveStreams().size());
1001 recv_stream = call->GetVideoReceiveStreams()[0]; 978 recv_stream = fake_call_->GetVideoReceiveStreams()[0];
1002 EXPECT_TRUE(recv_stream->GetConfig().rtp.extensions.empty()); 979 EXPECT_TRUE(recv_stream->GetConfig().rtp.extensions.empty());
1003 980
1004 // Verify that adding receive RTP header extensions adds them for existing 981 // Verify that adding receive RTP header extensions adds them for existing
1005 // streams. 982 // streams.
1006 EXPECT_TRUE(channel_->SetRecvRtpHeaderExtensions(extensions)); 983 EXPECT_TRUE(channel_->SetRecvRtpHeaderExtensions(extensions));
1007 recv_stream = call->GetVideoReceiveStreams()[0]; 984 recv_stream = fake_call_->GetVideoReceiveStreams()[0];
1008 ASSERT_EQ(1u, recv_stream->GetConfig().rtp.extensions.size()); 985 ASSERT_EQ(1u, recv_stream->GetConfig().rtp.extensions.size());
1009 EXPECT_EQ(id, recv_stream->GetConfig().rtp.extensions[0].id); 986 EXPECT_EQ(id, recv_stream->GetConfig().rtp.extensions[0].id);
1010 EXPECT_EQ(webrtc_ext, recv_stream->GetConfig().rtp.extensions[0].name); 987 EXPECT_EQ(webrtc_ext, recv_stream->GetConfig().rtp.extensions[0].name);
1011 } 988 }
1012 989
1013 void TestCpuAdaptation(bool enable_overuse, bool is_screenshare); 990 void TestCpuAdaptation(bool enable_overuse, bool is_screenshare);
1014 void TestReceiverLocalSsrcConfiguration(bool receiver_first); 991 void TestReceiverLocalSsrcConfiguration(bool receiver_first);
1015 void TestReceiveUnsignalledSsrcPacket(uint8_t payload_type, 992 void TestReceiveUnsignalledSsrcPacket(uint8_t payload_type,
1016 bool expect_created_receive_stream); 993 bool expect_created_receive_stream);
1017 994
(...skipping 10 matching lines...) Expand all
1028 std::vector<uint32_t> ssrcs; 1005 std::vector<uint32_t> ssrcs;
1029 ssrcs.push_back(last_ssrc_); 1006 ssrcs.push_back(last_ssrc_);
1030 ssrcs.push_back(last_ssrc_ + 1); 1007 ssrcs.push_back(last_ssrc_ + 1);
1031 ssrcs.push_back(last_ssrc_ + 2); 1008 ssrcs.push_back(last_ssrc_ + 2);
1032 return AddSendStream(CreateSimStreamParams("cname", ssrcs)); 1009 return AddSendStream(CreateSimStreamParams("cname", ssrcs));
1033 } else { 1010 } else {
1034 return AddSendStream(StreamParams::CreateLegacy(last_ssrc_)); 1011 return AddSendStream(StreamParams::CreateLegacy(last_ssrc_));
1035 } 1012 }
1036 } 1013 }
1037 1014
1038 FakeCall* fake_call_; 1015 rtc::scoped_ptr<FakeCall> fake_call_;
1039 rtc::scoped_ptr<VideoMediaChannel> channel_; 1016 rtc::scoped_ptr<VideoMediaChannel> channel_;
1040 uint32 last_ssrc_; 1017 uint32 last_ssrc_;
1041 }; 1018 };
1042 1019
1043 TEST_F(WebRtcVideoChannel2Test, SetsSyncGroupFromSyncLabel) { 1020 TEST_F(WebRtcVideoChannel2Test, SetsSyncGroupFromSyncLabel) {
1044 const uint32 kVideoSsrc = 123; 1021 const uint32 kVideoSsrc = 123;
1045 const std::string kSyncLabel = "AvSyncLabel"; 1022 const std::string kSyncLabel = "AvSyncLabel";
1046 1023
1047 cricket::StreamParams sp = cricket::StreamParams::CreateLegacy(kVideoSsrc); 1024 cricket::StreamParams sp = cricket::StreamParams::CreateLegacy(kVideoSsrc);
1048 sp.sync_label = kSyncLabel; 1025 sp.sync_label = kSyncLabel;
(...skipping 1715 matching lines...) Expand 10 before | Expand all | Expand 10 after
2764 TEST_F(WebRtcVideoChannel2Test, ConfiguresLocalSsrc) { 2741 TEST_F(WebRtcVideoChannel2Test, ConfiguresLocalSsrc) {
2765 TestReceiverLocalSsrcConfiguration(false); 2742 TestReceiverLocalSsrcConfiguration(false);
2766 } 2743 }
2767 2744
2768 TEST_F(WebRtcVideoChannel2Test, ConfiguresLocalSsrcOnExistingReceivers) { 2745 TEST_F(WebRtcVideoChannel2Test, ConfiguresLocalSsrcOnExistingReceivers) {
2769 TestReceiverLocalSsrcConfiguration(true); 2746 TestReceiverLocalSsrcConfiguration(true);
2770 } 2747 }
2771 2748
2772 class WebRtcVideoEngine2SimulcastTest : public testing::Test { 2749 class WebRtcVideoEngine2SimulcastTest : public testing::Test {
2773 public: 2750 public:
2774 WebRtcVideoEngine2SimulcastTest() : engine_(nullptr) {} 2751 WebRtcVideoEngine2SimulcastTest() {}
pbos-webrtc 2015/09/08 14:47:41 Remove ctor.
the sun 2015/09/08 15:21:35 Done.
2775 2752
2776 protected: 2753 protected:
2777 WebRtcVideoEngine2 engine_; 2754 WebRtcVideoEngine2 engine_;
pbos-webrtc 2015/09/08 14:47:41 If this is unused now then this should just be an
the sun 2015/09/08 15:21:35 Done.
2778 }; 2755 };
2779 2756
2780 // Test that if we add a stream with RTX SSRC's, SSRC's get set correctly. 2757 // Test that if we add a stream with RTX SSRC's, SSRC's get set correctly.
2781 TEST_F(WebRtcVideoEngine2SimulcastTest, DISABLED_TestStreamWithRtx) { 2758 TEST_F(WebRtcVideoEngine2SimulcastTest, DISABLED_TestStreamWithRtx) {
2782 // TODO(pbos): Implement. 2759 // TODO(pbos): Implement.
2783 FAIL() << "Not implemented."; 2760 FAIL() << "Not implemented.";
2784 } 2761 }
2785 2762
2786 // Test that if we get too few ssrcs are given in AddSendStream(), 2763 // Test that if we get too few ssrcs are given in AddSendStream(),
2787 // only supported sub-streams will be added. 2764 // only supported sub-streams will be added.
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
2915 // TODO(pbos): Implement. 2892 // TODO(pbos): Implement.
2916 FAIL() << "Not implemented."; 2893 FAIL() << "Not implemented.";
2917 } 2894 }
2918 2895
2919 TEST_F(WebRtcVideoEngine2SimulcastTest, 2896 TEST_F(WebRtcVideoEngine2SimulcastTest,
2920 DISABLED_DontUseSimulcastAdapterOnNonVp8Factory) { 2897 DISABLED_DontUseSimulcastAdapterOnNonVp8Factory) {
2921 // TODO(pbos): Implement. 2898 // TODO(pbos): Implement.
2922 FAIL() << "Not implemented."; 2899 FAIL() << "Not implemented.";
2923 } 2900 }
2924 2901
2925 class WebRtcVideoChannel2SimulcastTest : public WebRtcVideoEngine2SimulcastTest, 2902 class WebRtcVideoChannel2SimulcastTest : public testing::Test {
2926 public WebRtcCallFactory {
2927 public: 2903 public:
2928 WebRtcVideoChannel2SimulcastTest() : fake_call_(NULL) {} 2904 WebRtcVideoChannel2SimulcastTest() : fake_call_(webrtc::Call::Config()) {}
2929 2905
2930 void SetUp() override { 2906 void SetUp() override {
2931 engine_.SetCallFactory(this);
2932 engine_.Init(); 2907 engine_.Init();
2933 channel_.reset(engine_.CreateChannel(VideoOptions(), NULL)); 2908 channel_.reset(engine_.CreateChannel(&fake_call_, VideoOptions()));
2934 ASSERT_TRUE(fake_call_ != NULL) << "Call not created through factory.";
2935 last_ssrc_ = 123; 2909 last_ssrc_ = 123;
2936 } 2910 }
2937 2911
2938 protected: 2912 protected:
2939 webrtc::Call* CreateCall(const webrtc::Call::Config& config) override {
2940 DCHECK(fake_call_ == NULL);
2941 fake_call_ = new FakeCall(config);
2942 return fake_call_;
2943 }
2944
2945 void VerifySimulcastSettings(const VideoCodec& codec, 2913 void VerifySimulcastSettings(const VideoCodec& codec,
2946 VideoOptions::HighestBitrate bitrate_mode, 2914 VideoOptions::HighestBitrate bitrate_mode,
2947 size_t num_configured_streams, 2915 size_t num_configured_streams,
2948 size_t expected_num_streams, 2916 size_t expected_num_streams,
2949 SimulcastBitrateMode simulcast_bitrate_mode) { 2917 SimulcastBitrateMode simulcast_bitrate_mode) {
2950 cricket::VideoOptions options; 2918 cricket::VideoOptions options;
2951 options.video_highest_bitrate.Set(bitrate_mode); 2919 options.video_highest_bitrate.Set(bitrate_mode);
2952 EXPECT_TRUE(channel_->SetOptions(options)); 2920 EXPECT_TRUE(channel_->SetOptions(options));
2953 2921
2954 std::vector<VideoCodec> codecs; 2922 std::vector<VideoCodec> codecs;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
3028 2996
3029 EXPECT_TRUE(channel_->SetCapturer(ssrcs.front(), NULL)); 2997 EXPECT_TRUE(channel_->SetCapturer(ssrcs.front(), NULL));
3030 } 2998 }
3031 2999
3032 FakeVideoSendStream* AddSendStream() { 3000 FakeVideoSendStream* AddSendStream() {
3033 return AddSendStream(StreamParams::CreateLegacy(last_ssrc_++)); 3001 return AddSendStream(StreamParams::CreateLegacy(last_ssrc_++));
3034 } 3002 }
3035 3003
3036 FakeVideoSendStream* AddSendStream(const StreamParams& sp) { 3004 FakeVideoSendStream* AddSendStream(const StreamParams& sp) {
3037 size_t num_streams = 3005 size_t num_streams =
3038 fake_call_->GetVideoSendStreams().size(); 3006 fake_call_.GetVideoSendStreams().size();
3039 EXPECT_TRUE(channel_->AddSendStream(sp)); 3007 EXPECT_TRUE(channel_->AddSendStream(sp));
3040 std::vector<FakeVideoSendStream*> streams = 3008 std::vector<FakeVideoSendStream*> streams =
3041 fake_call_->GetVideoSendStreams(); 3009 fake_call_.GetVideoSendStreams();
3042 EXPECT_EQ(num_streams + 1, streams.size()); 3010 EXPECT_EQ(num_streams + 1, streams.size());
3043 return streams[streams.size() - 1]; 3011 return streams[streams.size() - 1];
3044 } 3012 }
3045 3013
3046 std::vector<FakeVideoSendStream*> GetFakeSendStreams() { 3014 std::vector<FakeVideoSendStream*> GetFakeSendStreams() {
3047 return fake_call_->GetVideoSendStreams(); 3015 return fake_call_.GetVideoSendStreams();
3048 } 3016 }
3049 3017
3050 FakeVideoReceiveStream* AddRecvStream() { 3018 FakeVideoReceiveStream* AddRecvStream() {
3051 return AddRecvStream(StreamParams::CreateLegacy(last_ssrc_++)); 3019 return AddRecvStream(StreamParams::CreateLegacy(last_ssrc_++));
3052 } 3020 }
3053 3021
3054 FakeVideoReceiveStream* AddRecvStream(const StreamParams& sp) { 3022 FakeVideoReceiveStream* AddRecvStream(const StreamParams& sp) {
3055 size_t num_streams = 3023 size_t num_streams =
3056 fake_call_->GetVideoReceiveStreams().size(); 3024 fake_call_.GetVideoReceiveStreams().size();
3057 EXPECT_TRUE(channel_->AddRecvStream(sp)); 3025 EXPECT_TRUE(channel_->AddRecvStream(sp));
3058 std::vector<FakeVideoReceiveStream*> streams = 3026 std::vector<FakeVideoReceiveStream*> streams =
3059 fake_call_->GetVideoReceiveStreams(); 3027 fake_call_.GetVideoReceiveStreams();
3060 EXPECT_EQ(num_streams + 1, streams.size()); 3028 EXPECT_EQ(num_streams + 1, streams.size());
3061 return streams[streams.size() - 1]; 3029 return streams[streams.size() - 1];
3062 } 3030 }
3063 3031
3064 FakeCall* fake_call_; 3032 FakeCall fake_call_;
3033 WebRtcVideoEngine2 engine_;
3065 rtc::scoped_ptr<VideoMediaChannel> channel_; 3034 rtc::scoped_ptr<VideoMediaChannel> channel_;
3066 uint32 last_ssrc_; 3035 uint32 last_ssrc_;
3067 }; 3036 };
3068 3037
3069 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWith2SimulcastStreams) { 3038 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWith2SimulcastStreams) {
3070 VerifySimulcastSettings(kVp8Codec, VideoOptions::NORMAL, 2, 2, SBM_NORMAL); 3039 VerifySimulcastSettings(kVp8Codec, VideoOptions::NORMAL, 2, 2, SBM_NORMAL);
3071 } 3040 }
3072 3041
3073 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWith3SimulcastStreams) { 3042 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWith3SimulcastStreams) {
3074 VerifySimulcastSettings( 3043 VerifySimulcastSettings(
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
3180 // Ensures that the correct settings are applied to the codec when two temporal 3149 // Ensures that the correct settings are applied to the codec when two temporal
3181 // layer screencasting is enabled, and that the correct simulcast settings are 3150 // layer screencasting is enabled, and that the correct simulcast settings are
3182 // reapplied when disabling screencasting. 3151 // reapplied when disabling screencasting.
3183 TEST_F(WebRtcVideoChannel2SimulcastTest, 3152 TEST_F(WebRtcVideoChannel2SimulcastTest,
3184 DISABLED_TwoTemporalLayerScreencastSettings) { 3153 DISABLED_TwoTemporalLayerScreencastSettings) {
3185 // TODO(pbos): Implement. 3154 // TODO(pbos): Implement.
3186 FAIL() << "Not implemented."; 3155 FAIL() << "Not implemented.";
3187 } 3156 }
3188 3157
3189 } // namespace cricket 3158 } // namespace cricket
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698