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

Side by Side Diff: webrtc/api/peerconnection_unittest.cc

Issue 1811373002: Fix broken CVO header extension (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | webrtc/api/test/fakevideotrackrenderer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2012 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 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 offer_answer_constraints_.SetMandatoryReceiveVideo(video); 380 offer_answer_constraints_.SetMandatoryReceiveVideo(video);
381 offer_answer_options_.offer_to_receive_video = video ? 1 : 0; 381 offer_answer_options_.offer_to_receive_video = video ? 1 : 0;
382 } 382 }
383 383
384 void RemoveMsidFromReceivedSdp(bool remove) { remove_msid_ = remove; } 384 void RemoveMsidFromReceivedSdp(bool remove) { remove_msid_ = remove; }
385 385
386 void RemoveSdesCryptoFromReceivedSdp(bool remove) { remove_sdes_ = remove; } 386 void RemoveSdesCryptoFromReceivedSdp(bool remove) { remove_sdes_ = remove; }
387 387
388 void RemoveBundleFromReceivedSdp(bool remove) { remove_bundle_ = remove; } 388 void RemoveBundleFromReceivedSdp(bool remove) { remove_bundle_ = remove; }
389 389
390 void RemoveCvoFromReceivedSdp(bool remove) { remove_cvo_ = remove; }
391
390 bool can_receive_audio() { 392 bool can_receive_audio() {
391 bool value; 393 bool value;
392 if (prefer_constraint_apis_) { 394 if (prefer_constraint_apis_) {
393 if (webrtc::FindConstraint( 395 if (webrtc::FindConstraint(
394 &offer_answer_constraints_, 396 &offer_answer_constraints_,
395 MediaConstraintsInterface::kOfferToReceiveAudio, &value, 397 MediaConstraintsInterface::kOfferToReceiveAudio, &value,
396 nullptr)) { 398 nullptr)) {
397 return value; 399 return value;
398 } 400 }
399 return true; 401 return true;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 } 447 }
446 448
447 rtc::scoped_refptr<webrtc::VideoTrackInterface> CreateLocalVideoTrack( 449 rtc::scoped_refptr<webrtc::VideoTrackInterface> CreateLocalVideoTrack(
448 const std::string& stream_label) { 450 const std::string& stream_label) {
449 // Set max frame rate to 10fps to reduce the risk of the tests to be flaky. 451 // Set max frame rate to 10fps to reduce the risk of the tests to be flaky.
450 FakeConstraints source_constraints = video_constraints_; 452 FakeConstraints source_constraints = video_constraints_;
451 source_constraints.SetMandatoryMaxFrameRate(10); 453 source_constraints.SetMandatoryMaxFrameRate(10);
452 454
453 cricket::FakeVideoCapturer* fake_capturer = 455 cricket::FakeVideoCapturer* fake_capturer =
454 new webrtc::FakePeriodicVideoCapturer(); 456 new webrtc::FakePeriodicVideoCapturer();
457 fake_capturer->SetRotation(capture_rotation_);
455 video_capturers_.push_back(fake_capturer); 458 video_capturers_.push_back(fake_capturer);
456 rtc::scoped_refptr<webrtc::VideoTrackSourceInterface> source = 459 rtc::scoped_refptr<webrtc::VideoTrackSourceInterface> source =
457 peer_connection_factory_->CreateVideoSource(fake_capturer, 460 peer_connection_factory_->CreateVideoSource(fake_capturer,
458 &source_constraints); 461 &source_constraints);
459 std::string label = stream_label + kVideoTrackLabelBase; 462 std::string label = stream_label + kVideoTrackLabelBase;
460 return peer_connection_factory_->CreateVideoTrack(label, source); 463
464 rtc::scoped_refptr<webrtc::VideoTrackInterface> track(
465 peer_connection_factory_->CreateVideoTrack(label, source));
466 if (!local_video_renderer_) {
467 local_video_renderer_.reset(new webrtc::FakeVideoTrackRenderer(track));
468 }
469 return track;
461 } 470 }
462 471
463 DataChannelInterface* data_channel() { return data_channel_; } 472 DataChannelInterface* data_channel() { return data_channel_; }
464 const MockDataChannelObserver* data_observer() const { 473 const MockDataChannelObserver* data_observer() const {
465 return data_observer_.get(); 474 return data_observer_.get();
466 } 475 }
467 476
468 webrtc::PeerConnectionInterface* pc() const { return peer_connection_.get(); } 477 webrtc::PeerConnectionInterface* pc() const { return peer_connection_.get(); }
469 478
470 void StopVideoCapturers() { 479 void StopVideoCapturers() {
471 for (std::vector<cricket::VideoCapturer*>::iterator it = 480 for (auto* capturer : video_capturers_) {
472 video_capturers_.begin(); 481 capturer->Stop();
473 it != video_capturers_.end(); ++it) {
474 (*it)->Stop();
475 } 482 }
476 } 483 }
477 484
485 void SetCaptureRotation(webrtc::VideoRotation rotation) {
486 ASSERT_TRUE(video_capturers_.empty());
487 capture_rotation_ = rotation;
488 }
489
478 bool AudioFramesReceivedCheck(int number_of_frames) const { 490 bool AudioFramesReceivedCheck(int number_of_frames) const {
479 return number_of_frames <= fake_audio_capture_module_->frames_received(); 491 return number_of_frames <= fake_audio_capture_module_->frames_received();
480 } 492 }
481 493
482 int audio_frames_received() const { 494 int audio_frames_received() const {
483 return fake_audio_capture_module_->frames_received(); 495 return fake_audio_capture_module_->frames_received();
484 } 496 }
485 497
486 bool VideoFramesReceivedCheck(int number_of_frames) { 498 bool VideoFramesReceivedCheck(int number_of_frames) {
487 if (video_decoder_factory_enabled_) { 499 if (video_decoder_factory_enabled_) {
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 return fake_video_renderers_.empty() ? 1 : 710 return fake_video_renderers_.empty() ? 1 :
699 fake_video_renderers_.begin()->second->width(); 711 fake_video_renderers_.begin()->second->width();
700 } 712 }
701 713
702 int rendered_height() { 714 int rendered_height() {
703 EXPECT_FALSE(fake_video_renderers_.empty()); 715 EXPECT_FALSE(fake_video_renderers_.empty());
704 return fake_video_renderers_.empty() ? 1 : 716 return fake_video_renderers_.empty() ? 1 :
705 fake_video_renderers_.begin()->second->height(); 717 fake_video_renderers_.begin()->second->height();
706 } 718 }
707 719
720 webrtc::VideoRotation rendered_rotation() {
721 EXPECT_FALSE(fake_video_renderers_.empty());
722 return fake_video_renderers_.empty()
723 ? webrtc::kVideoRotation_0
724 : fake_video_renderers_.begin()->second->rotation();
725 }
726
727 int local_rendered_width() {
728 return local_video_renderer_ ? local_video_renderer_->width() : 1;
729 }
730
731 int local_rendered_height() {
732 return local_video_renderer_ ? local_video_renderer_->height() : 1;
733 }
734
708 size_t number_of_remote_streams() { 735 size_t number_of_remote_streams() {
709 if (!pc()) 736 if (!pc())
710 return 0; 737 return 0;
711 return pc()->remote_streams()->count(); 738 return pc()->remote_streams()->count();
712 } 739 }
713 740
714 StreamCollectionInterface* remote_streams() const { 741 StreamCollectionInterface* remote_streams() const {
715 if (!pc()) { 742 if (!pc()) {
716 ADD_FAILURE(); 743 ADD_FAILURE();
717 return nullptr; 744 return nullptr;
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
922 RemoveLinesFromSdp(kSdpMsidSupportedAttribute, sdp); 949 RemoveLinesFromSdp(kSdpMsidSupportedAttribute, sdp);
923 } 950 }
924 if (remove_bundle_) { 951 if (remove_bundle_) {
925 const char kSdpBundleAttribute[] = "a=group:BUNDLE"; 952 const char kSdpBundleAttribute[] = "a=group:BUNDLE";
926 RemoveLinesFromSdp(kSdpBundleAttribute, sdp); 953 RemoveLinesFromSdp(kSdpBundleAttribute, sdp);
927 } 954 }
928 if (remove_sdes_) { 955 if (remove_sdes_) {
929 const char kSdpSdesCryptoAttribute[] = "a=crypto"; 956 const char kSdpSdesCryptoAttribute[] = "a=crypto";
930 RemoveLinesFromSdp(kSdpSdesCryptoAttribute, sdp); 957 RemoveLinesFromSdp(kSdpSdesCryptoAttribute, sdp);
931 } 958 }
959 if (remove_cvo_) {
960 const char kSdpCvoExtenstion[] = "urn:3gpp:video-orientation";
961 RemoveLinesFromSdp(kSdpCvoExtenstion, sdp);
962 }
932 } 963 }
933 964
934 std::string id_; 965 std::string id_;
935 966
936 rtc::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection_; 967 rtc::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection_;
937 rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> 968 rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface>
938 peer_connection_factory_; 969 peer_connection_factory_;
939 970
940 bool prefer_constraint_apis_ = true; 971 bool prefer_constraint_apis_ = true;
941 bool auto_add_stream_ = true; 972 bool auto_add_stream_ = true;
(...skipping 15 matching lines...) Expand all
957 FakeWebRtcVideoDecoderFactory* fake_video_decoder_factory_ = nullptr; 988 FakeWebRtcVideoDecoderFactory* fake_video_decoder_factory_ = nullptr;
958 FakeWebRtcVideoEncoderFactory* fake_video_encoder_factory_ = nullptr; 989 FakeWebRtcVideoEncoderFactory* fake_video_encoder_factory_ = nullptr;
959 bool video_decoder_factory_enabled_ = false; 990 bool video_decoder_factory_enabled_ = false;
960 webrtc::FakeConstraints video_constraints_; 991 webrtc::FakeConstraints video_constraints_;
961 992
962 // For remote peer communication. 993 // For remote peer communication.
963 SignalingMessageReceiver* signaling_message_receiver_ = nullptr; 994 SignalingMessageReceiver* signaling_message_receiver_ = nullptr;
964 995
965 // Store references to the video capturers we've created, so that we can stop 996 // Store references to the video capturers we've created, so that we can stop
966 // them, if required. 997 // them, if required.
967 std::vector<cricket::VideoCapturer*> video_capturers_; 998 std::vector<cricket::FakeVideoCapturer*> video_capturers_;
999 webrtc::VideoRotation capture_rotation_ = webrtc::kVideoRotation_0;
1000 // |local_video_renderer_| attached to the first created local video track.
1001 rtc::scoped_ptr<webrtc::FakeVideoTrackRenderer> local_video_renderer_;
968 1002
969 webrtc::FakeConstraints offer_answer_constraints_; 1003 webrtc::FakeConstraints offer_answer_constraints_;
970 PeerConnectionInterface::RTCOfferAnswerOptions offer_answer_options_; 1004 PeerConnectionInterface::RTCOfferAnswerOptions offer_answer_options_;
971 bool remove_msid_ = false; // True if MSID should be removed in received SDP. 1005 bool remove_msid_ = false; // True if MSID should be removed in received SDP.
972 bool remove_bundle_ = 1006 bool remove_bundle_ =
973 false; // True if bundle should be removed in received SDP. 1007 false; // True if bundle should be removed in received SDP.
974 bool remove_sdes_ = 1008 bool remove_sdes_ =
975 false; // True if a=crypto should be removed in received SDP. 1009 false; // True if a=crypto should be removed in received SDP.
1010 // |remove_cvo_| is true if extension urn:3gpp:video-orientation should be
1011 // removed in the received SDP.
1012 bool remove_cvo_ = false;
976 1013
977 rtc::scoped_refptr<DataChannelInterface> data_channel_; 1014 rtc::scoped_refptr<DataChannelInterface> data_channel_;
978 rtc::scoped_ptr<MockDataChannelObserver> data_observer_; 1015 rtc::scoped_ptr<MockDataChannelObserver> data_observer_;
979 }; 1016 };
980 1017
981 class P2PTestConductor : public testing::Test { 1018 class P2PTestConductor : public testing::Test {
982 public: 1019 public:
983 P2PTestConductor() 1020 P2PTestConductor()
984 : pss_(new rtc::PhysicalSocketServer), 1021 : pss_(new rtc::PhysicalSocketServer),
985 ss_(new rtc::VirtualSocketServer(pss_.get())), 1022 ss_(new rtc::VirtualSocketServer(pss_.get())),
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1040 pc2_audio_received + kEndAudioFrameCount), 1077 pc2_audio_received + kEndAudioFrameCount),
1041 kMaxWaitForFramesMs); 1078 kMaxWaitForFramesMs);
1042 1079
1043 // During this time, we shouldn't have received any additional video frames 1080 // During this time, we shouldn't have received any additional video frames
1044 // for the rejected video tracks. 1081 // for the rejected video tracks.
1045 EXPECT_EQ(pc1_video_received, initiating_client_->video_frames_received()); 1082 EXPECT_EQ(pc1_video_received, initiating_client_->video_frames_received());
1046 EXPECT_EQ(pc2_video_received, receiving_client_->video_frames_received()); 1083 EXPECT_EQ(pc2_video_received, receiving_client_->video_frames_received());
1047 } 1084 }
1048 1085
1049 void VerifyRenderedSize(int width, int height) { 1086 void VerifyRenderedSize(int width, int height) {
1087 VerifyRenderedSize(width, height, webrtc::kVideoRotation_0);
1088 }
1089
1090 void VerifyRenderedSize(int width,
1091 int height,
1092 webrtc::VideoRotation rotation) {
1050 EXPECT_EQ(width, receiving_client()->rendered_width()); 1093 EXPECT_EQ(width, receiving_client()->rendered_width());
1051 EXPECT_EQ(height, receiving_client()->rendered_height()); 1094 EXPECT_EQ(height, receiving_client()->rendered_height());
1095 EXPECT_EQ(rotation, receiving_client()->rendered_rotation());
1052 EXPECT_EQ(width, initializing_client()->rendered_width()); 1096 EXPECT_EQ(width, initializing_client()->rendered_width());
1053 EXPECT_EQ(height, initializing_client()->rendered_height()); 1097 EXPECT_EQ(height, initializing_client()->rendered_height());
1098 EXPECT_EQ(rotation, initializing_client()->rendered_rotation());
1099
1100 // Verify size of the local preview.
1101 EXPECT_EQ(width, initializing_client()->local_rendered_width());
1102 EXPECT_EQ(height, initializing_client()->local_rendered_height());
1054 } 1103 }
1055 1104
1056 void VerifySessionDescriptions() { 1105 void VerifySessionDescriptions() {
1057 initiating_client_->VerifyRejectedMediaInSessionDescription(); 1106 initiating_client_->VerifyRejectedMediaInSessionDescription();
1058 receiving_client_->VerifyRejectedMediaInSessionDescription(); 1107 receiving_client_->VerifyRejectedMediaInSessionDescription();
1059 initiating_client_->VerifyLocalIceUfragAndPassword(); 1108 initiating_client_->VerifyLocalIceUfragAndPassword();
1060 receiving_client_->VerifyLocalIceUfragAndPassword(); 1109 receiving_client_->VerifyLocalIceUfragAndPassword();
1061 } 1110 }
1062 1111
1063 ~P2PTestConductor() { 1112 ~P2PTestConductor() {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1112 SetSignalingReceivers(); 1161 SetSignalingReceivers();
1113 return true; 1162 return true;
1114 } 1163 }
1115 1164
1116 void SetVideoConstraints(const webrtc::FakeConstraints& init_constraints, 1165 void SetVideoConstraints(const webrtc::FakeConstraints& init_constraints,
1117 const webrtc::FakeConstraints& recv_constraints) { 1166 const webrtc::FakeConstraints& recv_constraints) {
1118 initiating_client_->SetVideoConstraints(init_constraints); 1167 initiating_client_->SetVideoConstraints(init_constraints);
1119 receiving_client_->SetVideoConstraints(recv_constraints); 1168 receiving_client_->SetVideoConstraints(recv_constraints);
1120 } 1169 }
1121 1170
1171 void SetCaptureRotation(webrtc::VideoRotation rotation) {
1172 initiating_client_->SetCaptureRotation(rotation);
1173 receiving_client_->SetCaptureRotation(rotation);
1174 }
1175
1122 void EnableVideoDecoderFactory() { 1176 void EnableVideoDecoderFactory() {
1123 initiating_client_->EnableVideoDecoderFactory(); 1177 initiating_client_->EnableVideoDecoderFactory();
1124 receiving_client_->EnableVideoDecoderFactory(); 1178 receiving_client_->EnableVideoDecoderFactory();
1125 } 1179 }
1126 1180
1127 // This test sets up a call between two parties. Both parties send static 1181 // This test sets up a call between two parties. Both parties send static
1128 // frames to each other. Once the test is finished the number of sent frames 1182 // frames to each other. Once the test is finished the number of sent frames
1129 // is compared to the number of received frames. 1183 // is compared to the number of received frames.
1130 void LocalP2PTest() { 1184 void LocalP2PTest() {
1131 if (initiating_client_->NumberOfLocalMediaStreams() == 0) { 1185 if (initiating_client_->NumberOfLocalMediaStreams() == 0) {
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
1382 rtc::scoped_ptr<PeerConnectionTestClient> original_peer( 1436 rtc::scoped_ptr<PeerConnectionTestClient> original_peer(
1383 set_receiving_client(CreateDtlsClientWithAlternateKey())); 1437 set_receiving_client(CreateDtlsClientWithAlternateKey()));
1384 original_peer->pc()->Close(); 1438 original_peer->pc()->Close();
1385 1439
1386 SetSignalingReceivers(); 1440 SetSignalingReceivers();
1387 initializing_client()->IceRestart(); 1441 initializing_client()->IceRestart();
1388 LocalP2PTest(); 1442 LocalP2PTest();
1389 VerifyRenderedSize(640, 480); 1443 VerifyRenderedSize(640, 480);
1390 } 1444 }
1391 1445
1446 TEST_F(P2PTestConductor, LocalP2PTestCVO) {
1447 ASSERT_TRUE(CreateTestClients());
1448 SetCaptureRotation(webrtc::kVideoRotation_90);
1449 LocalP2PTest();
1450 VerifyRenderedSize(640, 480, webrtc::kVideoRotation_90);
1451 }
1452
1453 TEST_F(P2PTestConductor, LocalP2PTestReceiverDoesntSupportCVO) {
1454 ASSERT_TRUE(CreateTestClients());
1455 SetCaptureRotation(webrtc::kVideoRotation_90);
1456 receiving_client()->RemoveCvoFromReceivedSdp(true);
1457 LocalP2PTest();
1458 VerifyRenderedSize(480, 640, webrtc::kVideoRotation_0);
1459 }
1460
1392 // This test sets up a call between two endpoints that are configured to use 1461 // This test sets up a call between two endpoints that are configured to use
1393 // DTLS key agreement. The offerer don't support SDES. As a result, DTLS is 1462 // DTLS key agreement. The offerer don't support SDES. As a result, DTLS is
1394 // negotiated and used for transport. 1463 // negotiated and used for transport.
1395 TEST_F(P2PTestConductor, LocalP2PTestOfferDtlsButNotSdes) { 1464 TEST_F(P2PTestConductor, LocalP2PTestOfferDtlsButNotSdes) {
1396 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); 1465 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp);
1397 FakeConstraints setup_constraints; 1466 FakeConstraints setup_constraints;
1398 setup_constraints.AddMandatory(MediaConstraintsInterface::kEnableDtlsSrtp, 1467 setup_constraints.AddMandatory(MediaConstraintsInterface::kEnableDtlsSrtp,
1399 true); 1468 true);
1400 ASSERT_TRUE(CreateTestClients(&setup_constraints, &setup_constraints)); 1469 ASSERT_TRUE(CreateTestClients(&setup_constraints, &setup_constraints));
1401 receiving_client()->RemoveSdesCryptoFromReceivedSdp(true); 1470 receiving_client()->RemoveSdesCryptoFromReceivedSdp(true);
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after
2094 server.urls.push_back("turn:hostname2"); 2163 server.urls.push_back("turn:hostname2");
2095 servers.push_back(server); 2164 servers.push_back(server);
2096 EXPECT_TRUE(webrtc::ParseIceServers(servers, &stun_servers_, &turn_servers_)); 2165 EXPECT_TRUE(webrtc::ParseIceServers(servers, &stun_servers_, &turn_servers_));
2097 EXPECT_EQ(2U, turn_servers_.size()); 2166 EXPECT_EQ(2U, turn_servers_.size());
2098 EXPECT_NE(turn_servers_[0].priority, turn_servers_[1].priority); 2167 EXPECT_NE(turn_servers_[0].priority, turn_servers_[1].priority);
2099 } 2168 }
2100 2169
2101 #endif // if !defined(THREAD_SANITIZER) 2170 #endif // if !defined(THREAD_SANITIZER)
2102 2171
2103 } // namespace 2172 } // namespace
OLDNEW
« no previous file with comments | « no previous file | webrtc/api/test/fakevideotrackrenderer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698