Index: talk/app/webrtc/peerconnection_unittest.cc |
diff --git a/talk/app/webrtc/peerconnection_unittest.cc b/talk/app/webrtc/peerconnection_unittest.cc |
index 3cf66d64d8827b3c4e71887306844904409a3cdb..7e4454301b7f3c8ea320bc0185c2f1f61ecd66ab 100644 |
--- a/talk/app/webrtc/peerconnection_unittest.cc |
+++ b/talk/app/webrtc/peerconnection_unittest.cc |
@@ -276,6 +276,12 @@ class PeerConnectionTestClient : public webrtc::PeerConnectionObserver, |
return pc()->signaling_state() == webrtc::PeerConnectionInterface::kStable; |
} |
+ // Automatically add a stream when receiving in offer, if we don't have one. |
+ // Defaults to true. |
pthatcher1
2015/11/11 00:45:02
in offer => an offer?
Taylor Brandstetter
2015/11/11 01:33:30
Done.
|
+ void set_auto_add_stream(bool auto_add_stream) { |
+ auto_add_stream_ = auto_add_stream; |
+ } |
+ |
void set_signaling_message_receiver( |
SignalingMessageReceiver* signaling_message_receiver) { |
signaling_message_receiver_ = signaling_message_receiver; |
@@ -705,7 +711,7 @@ class PeerConnectionTestClient : public webrtc::PeerConnectionObserver, |
void HandleIncomingOffer(const std::string& msg) { |
LOG(INFO) << id_ << "HandleIncomingOffer "; |
- if (NumberOfLocalMediaStreams() == 0) { |
+ if (NumberOfLocalMediaStreams() == 0 && auto_add_stream_) { |
// If we are not sending any streams ourselves it is time to add some. |
AddMediaStream(true, true); |
} |
@@ -812,6 +818,8 @@ class PeerConnectionTestClient : public webrtc::PeerConnectionObserver, |
rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> |
peer_connection_factory_; |
+ bool auto_add_stream_ = true; |
+ |
typedef std::pair<std::string, std::string> IceUfragPwdPair; |
std::map<int, IceUfragPwdPair> ice_ufrag_pwd_; |
bool expect_ice_restart_ = false; |
@@ -963,7 +971,6 @@ class JsepPeerConnectionP2PTestClient : public testing::Test { |
ASSERT_TRUE_WAIT(SessionActive(), kMaxWaitForActivationMs); |
VerifySessionDescriptions(); |
- |
int audio_frame_count = kEndAudioFrameCount; |
// TODO(ronghuawu): Add test to cover the case of sendonly and recvonly. |
if (!initiating_client_->can_receive_audio() || |
@@ -1562,6 +1569,29 @@ TEST_F(JsepPeerConnectionP2PTestClient, IceRestart) { |
EXPECT_NE(receiver_candidate, receiver_candidate_restart); |
} |
+// This test sets up a call between two parties with audio, and video. |
+// It then renegotiates setting the video m-line to "port 0", then later |
+// renegotiates again, enabling video. |
+TEST_F(JsepPeerConnectionP2PTestClient, LocalP2PTestVideoDisableEnable) { |
+ ASSERT_TRUE(CreateTestClients()); |
+ |
+ // Do initial negotiation. Will result in video and audio sendonly m-lines. |
+ receiving_client()->set_auto_add_stream(false); |
+ initializing_client()->AddMediaStream(true, true); |
+ initializing_client()->Negotiate(); |
+ |
+ // Negotiate again, disabling the video m-line (receiving client will |
+ // set port to 0 due to mandatory "OfferToReceiveVideo: false" constraint). |
+ receiving_client()->SetReceiveVideo(false); |
+ initializing_client()->Negotiate(); |
+ |
+ // Enable video and do negotiation again, making sure video is received |
+ // end-to-end. |
+ receiving_client()->SetReceiveVideo(true); |
+ receiving_client()->AddMediaStream(true, true); |
+ LocalP2PTest(); |
+} |
+ |
// This test sets up a Jsep call between two parties with external |
// VideoDecoderFactory. |
// TODO(holmer): Disabled due to sometimes crashing on buildbots. |