OLD | NEW |
---|---|
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 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 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
269 | 269 |
270 EXPECT_TRUE(pc()->AddStream(stream)); | 270 EXPECT_TRUE(pc()->AddStream(stream)); |
271 } | 271 } |
272 | 272 |
273 size_t NumberOfLocalMediaStreams() { return pc()->local_streams()->count(); } | 273 size_t NumberOfLocalMediaStreams() { return pc()->local_streams()->count(); } |
274 | 274 |
275 bool SessionActive() { | 275 bool SessionActive() { |
276 return pc()->signaling_state() == webrtc::PeerConnectionInterface::kStable; | 276 return pc()->signaling_state() == webrtc::PeerConnectionInterface::kStable; |
277 } | 277 } |
278 | 278 |
279 // Automatically add a stream when receiving in offer, if we don't have one. | |
280 // Defaults to true. | |
pthatcher1
2015/11/11 00:45:02
in offer => an offer?
Taylor Brandstetter
2015/11/11 01:33:30
Done.
| |
281 void set_auto_add_stream(bool auto_add_stream) { | |
282 auto_add_stream_ = auto_add_stream; | |
283 } | |
284 | |
279 void set_signaling_message_receiver( | 285 void set_signaling_message_receiver( |
280 SignalingMessageReceiver* signaling_message_receiver) { | 286 SignalingMessageReceiver* signaling_message_receiver) { |
281 signaling_message_receiver_ = signaling_message_receiver; | 287 signaling_message_receiver_ = signaling_message_receiver; |
282 } | 288 } |
283 | 289 |
284 void EnableVideoDecoderFactory() { | 290 void EnableVideoDecoderFactory() { |
285 video_decoder_factory_enabled_ = true; | 291 video_decoder_factory_enabled_ = true; |
286 fake_video_decoder_factory_->AddSupportedVideoCodecType( | 292 fake_video_decoder_factory_->AddSupportedVideoCodecType( |
287 webrtc::kVideoCodecVP8); | 293 webrtc::kVideoCodecVP8); |
288 } | 294 } |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
698 | 704 |
699 rtc::scoped_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store( | 705 rtc::scoped_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store( |
700 rtc::SSLStreamAdapter::HaveDtlsSrtp() ? new FakeDtlsIdentityStore() | 706 rtc::SSLStreamAdapter::HaveDtlsSrtp() ? new FakeDtlsIdentityStore() |
701 : nullptr); | 707 : nullptr); |
702 return peer_connection_factory_->CreatePeerConnection( | 708 return peer_connection_factory_->CreatePeerConnection( |
703 ice_servers, constraints, factory, dtls_identity_store.Pass(), this); | 709 ice_servers, constraints, factory, dtls_identity_store.Pass(), this); |
704 } | 710 } |
705 | 711 |
706 void HandleIncomingOffer(const std::string& msg) { | 712 void HandleIncomingOffer(const std::string& msg) { |
707 LOG(INFO) << id_ << "HandleIncomingOffer "; | 713 LOG(INFO) << id_ << "HandleIncomingOffer "; |
708 if (NumberOfLocalMediaStreams() == 0) { | 714 if (NumberOfLocalMediaStreams() == 0 && auto_add_stream_) { |
709 // If we are not sending any streams ourselves it is time to add some. | 715 // If we are not sending any streams ourselves it is time to add some. |
710 AddMediaStream(true, true); | 716 AddMediaStream(true, true); |
711 } | 717 } |
712 rtc::scoped_ptr<SessionDescriptionInterface> desc( | 718 rtc::scoped_ptr<SessionDescriptionInterface> desc( |
713 webrtc::CreateSessionDescription("offer", msg, nullptr)); | 719 webrtc::CreateSessionDescription("offer", msg, nullptr)); |
714 EXPECT_TRUE(DoSetRemoteDescription(desc.release())); | 720 EXPECT_TRUE(DoSetRemoteDescription(desc.release())); |
715 rtc::scoped_ptr<SessionDescriptionInterface> answer; | 721 rtc::scoped_ptr<SessionDescriptionInterface> answer; |
716 EXPECT_TRUE(DoCreateAnswer(answer.use())); | 722 EXPECT_TRUE(DoCreateAnswer(answer.use())); |
717 std::string sdp; | 723 std::string sdp; |
718 EXPECT_TRUE(answer->ToString(&sdp)); | 724 EXPECT_TRUE(answer->ToString(&sdp)); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
805 } | 811 } |
806 } | 812 } |
807 | 813 |
808 std::string id_; | 814 std::string id_; |
809 | 815 |
810 rtc::scoped_refptr<webrtc::PortAllocatorFactoryInterface> allocator_factory_; | 816 rtc::scoped_refptr<webrtc::PortAllocatorFactoryInterface> allocator_factory_; |
811 rtc::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection_; | 817 rtc::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection_; |
812 rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> | 818 rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> |
813 peer_connection_factory_; | 819 peer_connection_factory_; |
814 | 820 |
821 bool auto_add_stream_ = true; | |
822 | |
815 typedef std::pair<std::string, std::string> IceUfragPwdPair; | 823 typedef std::pair<std::string, std::string> IceUfragPwdPair; |
816 std::map<int, IceUfragPwdPair> ice_ufrag_pwd_; | 824 std::map<int, IceUfragPwdPair> ice_ufrag_pwd_; |
817 bool expect_ice_restart_ = false; | 825 bool expect_ice_restart_ = false; |
818 | 826 |
819 // Needed to keep track of number of frames send. | 827 // Needed to keep track of number of frames send. |
820 rtc::scoped_refptr<FakeAudioCaptureModule> fake_audio_capture_module_; | 828 rtc::scoped_refptr<FakeAudioCaptureModule> fake_audio_capture_module_; |
821 // Needed to keep track of number of frames received. | 829 // Needed to keep track of number of frames received. |
822 typedef std::map<std::string, webrtc::FakeVideoTrackRenderer*> RenderMap; | 830 typedef std::map<std::string, webrtc::FakeVideoTrackRenderer*> RenderMap; |
823 RenderMap fake_video_renderers_; | 831 RenderMap fake_video_renderers_; |
824 // Needed to keep track of number of frames received when external decoder | 832 // Needed to keep track of number of frames received when external decoder |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
956 if (initiating_client_->NumberOfLocalMediaStreams() == 0) { | 964 if (initiating_client_->NumberOfLocalMediaStreams() == 0) { |
957 initiating_client_->AddMediaStream(true, true); | 965 initiating_client_->AddMediaStream(true, true); |
958 } | 966 } |
959 initiating_client_->Negotiate(); | 967 initiating_client_->Negotiate(); |
960 const int kMaxWaitForActivationMs = 5000; | 968 const int kMaxWaitForActivationMs = 5000; |
961 // Assert true is used here since next tests are guaranteed to fail and | 969 // Assert true is used here since next tests are guaranteed to fail and |
962 // would eat up 5 seconds. | 970 // would eat up 5 seconds. |
963 ASSERT_TRUE_WAIT(SessionActive(), kMaxWaitForActivationMs); | 971 ASSERT_TRUE_WAIT(SessionActive(), kMaxWaitForActivationMs); |
964 VerifySessionDescriptions(); | 972 VerifySessionDescriptions(); |
965 | 973 |
966 | |
967 int audio_frame_count = kEndAudioFrameCount; | 974 int audio_frame_count = kEndAudioFrameCount; |
968 // TODO(ronghuawu): Add test to cover the case of sendonly and recvonly. | 975 // TODO(ronghuawu): Add test to cover the case of sendonly and recvonly. |
969 if (!initiating_client_->can_receive_audio() || | 976 if (!initiating_client_->can_receive_audio() || |
970 !receiving_client_->can_receive_audio()) { | 977 !receiving_client_->can_receive_audio()) { |
971 audio_frame_count = -1; | 978 audio_frame_count = -1; |
972 } | 979 } |
973 int video_frame_count = kEndVideoFrameCount; | 980 int video_frame_count = kEndVideoFrameCount; |
974 if (!initiating_client_->can_receive_video() || | 981 if (!initiating_client_->can_receive_video() || |
975 !receiving_client_->can_receive_video()) { | 982 !receiving_client_->can_receive_video()) { |
976 video_frame_count = -1; | 983 video_frame_count = -1; |
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1555 std::string receiver_candidate_restart; | 1562 std::string receiver_candidate_restart; |
1556 EXPECT_TRUE(audio_candidates_reciever_restart->at(0)->ToString( | 1563 EXPECT_TRUE(audio_candidates_reciever_restart->at(0)->ToString( |
1557 &receiver_candidate_restart)); | 1564 &receiver_candidate_restart)); |
1558 | 1565 |
1559 // Verify that the first candidates in the local session descriptions has | 1566 // Verify that the first candidates in the local session descriptions has |
1560 // changed. | 1567 // changed. |
1561 EXPECT_NE(initiator_candidate, initiator_candidate_restart); | 1568 EXPECT_NE(initiator_candidate, initiator_candidate_restart); |
1562 EXPECT_NE(receiver_candidate, receiver_candidate_restart); | 1569 EXPECT_NE(receiver_candidate, receiver_candidate_restart); |
1563 } | 1570 } |
1564 | 1571 |
1572 // This test sets up a call between two parties with audio, and video. | |
1573 // It then renegotiates setting the video m-line to "port 0", then later | |
1574 // renegotiates again, enabling video. | |
1575 TEST_F(JsepPeerConnectionP2PTestClient, LocalP2PTestVideoDisableEnable) { | |
1576 ASSERT_TRUE(CreateTestClients()); | |
1577 | |
1578 // Do initial negotiation. Will result in video and audio sendonly m-lines. | |
1579 receiving_client()->set_auto_add_stream(false); | |
1580 initializing_client()->AddMediaStream(true, true); | |
1581 initializing_client()->Negotiate(); | |
1582 | |
1583 // Negotiate again, disabling the video m-line (receiving client will | |
1584 // set port to 0 due to mandatory "OfferToReceiveVideo: false" constraint). | |
1585 receiving_client()->SetReceiveVideo(false); | |
1586 initializing_client()->Negotiate(); | |
1587 | |
1588 // Enable video and do negotiation again, making sure video is received | |
1589 // end-to-end. | |
1590 receiving_client()->SetReceiveVideo(true); | |
1591 receiving_client()->AddMediaStream(true, true); | |
1592 LocalP2PTest(); | |
1593 } | |
1594 | |
1565 // This test sets up a Jsep call between two parties with external | 1595 // This test sets up a Jsep call between two parties with external |
1566 // VideoDecoderFactory. | 1596 // VideoDecoderFactory. |
1567 // TODO(holmer): Disabled due to sometimes crashing on buildbots. | 1597 // TODO(holmer): Disabled due to sometimes crashing on buildbots. |
1568 // See issue webrtc/2378. | 1598 // See issue webrtc/2378. |
1569 TEST_F(JsepPeerConnectionP2PTestClient, | 1599 TEST_F(JsepPeerConnectionP2PTestClient, |
1570 DISABLED_LocalP2PTestWithVideoDecoderFactory) { | 1600 DISABLED_LocalP2PTestWithVideoDecoderFactory) { |
1571 ASSERT_TRUE(CreateTestClients()); | 1601 ASSERT_TRUE(CreateTestClients()); |
1572 EnableVideoDecoderFactory(); | 1602 EnableVideoDecoderFactory(); |
1573 LocalP2PTest(); | 1603 LocalP2PTest(); |
1574 } | 1604 } |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1743 server.urls.push_back("stun:hostname"); | 1773 server.urls.push_back("stun:hostname"); |
1744 server.urls.push_back("turn:hostname"); | 1774 server.urls.push_back("turn:hostname"); |
1745 servers.push_back(server); | 1775 servers.push_back(server); |
1746 EXPECT_TRUE(webrtc::ParseIceServers(servers, &stun_configurations_, | 1776 EXPECT_TRUE(webrtc::ParseIceServers(servers, &stun_configurations_, |
1747 &turn_configurations_)); | 1777 &turn_configurations_)); |
1748 EXPECT_EQ(1U, stun_configurations_.size()); | 1778 EXPECT_EQ(1U, stun_configurations_.size()); |
1749 EXPECT_EQ(1U, turn_configurations_.size()); | 1779 EXPECT_EQ(1U, turn_configurations_.size()); |
1750 } | 1780 } |
1751 | 1781 |
1752 #endif // if !defined(THREAD_SANITIZER) | 1782 #endif // if !defined(THREAD_SANITIZER) |
OLD | NEW |