(Auto)update libjingle 72847605-> 72850595

git-svn-id: http://webrtc.googlecode.com/svn/trunk/talk@6855 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/app/webrtc/mediaconstraintsinterface.cc b/app/webrtc/mediaconstraintsinterface.cc
index 874ce64..74f6542 100644
--- a/app/webrtc/mediaconstraintsinterface.cc
+++ b/app/webrtc/mediaconstraintsinterface.cc
@@ -95,6 +95,8 @@
     "googSuspendBelowMinBitrate";
 const char MediaConstraintsInterface::kImprovedWifiBwe[] =
     "googImprovedWifiBwe";
+const char MediaConstraintsInterface::kNumUnsignalledRecvStreams[] =
+    "googNumUnsignalledRecvStreams";
 const char MediaConstraintsInterface::kScreencastMinBitrate[] =
     "googScreencastMinBitrate";
 // TODO(ronghuawu): Remove once cpu overuse detection is stable.
diff --git a/app/webrtc/mediaconstraintsinterface.h b/app/webrtc/mediaconstraintsinterface.h
index 1304d88..b3efbb3 100644
--- a/app/webrtc/mediaconstraintsinterface.h
+++ b/app/webrtc/mediaconstraintsinterface.h
@@ -116,6 +116,8 @@
   static const char kEnableVideoSuspendBelowMinBitrate[];
       // googSuspendBelowMinBitrate
   static const char kImprovedWifiBwe[];  // googImprovedWifiBwe
+  static const char kNumUnsignalledRecvStreams[];
+      // googNumUnsignalledRecvStreams
   static const char kScreencastMinBitrate[];  // googScreencastMinBitrate
   static const char kCpuOveruseDetection[];  // googCpuOveruseDetection
   static const char kCpuUnderuseThreshold[];  // googCpuUnderuseThreshold
diff --git a/app/webrtc/webrtcsession.cc b/app/webrtc/webrtcsession.cc
index 3add7e1..7357a61 100644
--- a/app/webrtc/webrtcsession.cc
+++ b/app/webrtc/webrtcsession.cc
@@ -38,6 +38,7 @@
 #include "talk/app/webrtc/mediastreamsignaling.h"
 #include "talk/app/webrtc/peerconnectioninterface.h"
 #include "talk/app/webrtc/webrtcsessiondescriptionfactory.h"
+#include "webrtc/base/basictypes.h"
 #include "webrtc/base/helpers.h"
 #include "webrtc/base/logging.h"
 #include "webrtc/base/stringencode.h"
@@ -74,6 +75,7 @@
     "Called with SDP without ice-ufrag and ice-pwd.";
 const char kSessionError[] = "Session error code: ";
 const char kSessionErrorDesc[] = "Session error description: ";
+const int kMaxUnsignalledRecvStreams = 20;
 
 // Compares |answer| against |offer|. Comparision is done
 // for number of m-lines in answer against offer. If matches true will be
@@ -590,6 +592,17 @@
   }
 
   SetOptionFromOptionalConstraint(constraints,
+      MediaConstraintsInterface::kNumUnsignalledRecvStreams,
+      &video_options_.unsignalled_recv_stream_limit);
+  if (video_options_.unsignalled_recv_stream_limit.IsSet()) {
+    int stream_limit;
+    video_options_.unsignalled_recv_stream_limit.Get(&stream_limit);
+    stream_limit = rtc::_min(kMaxUnsignalledRecvStreams, stream_limit);
+    stream_limit = rtc::_max(0, stream_limit);
+    video_options_.unsignalled_recv_stream_limit.Set(stream_limit);
+  }
+
+  SetOptionFromOptionalConstraint(constraints,
       MediaConstraintsInterface::kHighStartBitrate,
       &video_options_.video_start_bitrate);
 
diff --git a/app/webrtc/webrtcsession.h b/app/webrtc/webrtcsession.h
index f5de979..564676d 100644
--- a/app/webrtc/webrtcsession.h
+++ b/app/webrtc/webrtcsession.h
@@ -73,6 +73,9 @@
 extern const char kSdpWithoutSdesAndDtlsDisabled[];
 extern const char kSessionError[];
 extern const char kSessionErrorDesc[];
+// Maximum number of received video streams that will be processed by webrtc
+// even if they are not signalled beforehand.
+extern const int kMaxUnsignalledRecvStreams;
 
 // ICE state callback interface.
 class IceObserver {
diff --git a/app/webrtc/webrtcsession_unittest.cc b/app/webrtc/webrtcsession_unittest.cc
index b5e1dda..8bc8e8d 100644
--- a/app/webrtc/webrtcsession_unittest.cc
+++ b/app/webrtc/webrtcsession_unittest.cc
@@ -98,6 +98,7 @@
 using webrtc::kSdpWithoutSdesCrypto;
 using webrtc::kSessionError;
 using webrtc::kSessionErrorDesc;
+using webrtc::kMaxUnsignalledRecvStreams;
 
 typedef PeerConnectionInterface::RTCOfferAnswerOptions RTCOfferAnswerOptions;
 
@@ -537,6 +538,28 @@
     VerifyCryptoParams(answer->description());
   }
 
+  void SetAndVerifyNumUnsignalledRecvStreams(
+      int value_set, int value_expected) {
+    constraints_.reset(new FakeConstraints());
+    constraints_->AddOptional(
+        webrtc::MediaConstraintsInterface::kNumUnsignalledRecvStreams,
+        value_set);
+    session_.reset();
+    Init(NULL);
+    mediastream_signaling_.SendAudioVideoStream1();
+    SessionDescriptionInterface* offer = CreateOffer();
+
+    SetLocalDescriptionWithoutError(offer);
+
+    video_channel_ = media_engine_->GetVideoChannel(0);
+
+    ASSERT_TRUE(video_channel_ != NULL);
+    cricket::VideoOptions video_options;
+    EXPECT_TRUE(video_channel_->GetOptions(&video_options));
+    EXPECT_EQ(value_expected,
+        video_options.unsignalled_recv_stream_limit.GetWithDefaultIfUnset(-1));
+  }
+
   void CompareIceUfragAndPassword(const cricket::SessionDescription* desc1,
                                   const cricket::SessionDescription* desc2,
                                   bool expect_equal) {
@@ -3279,6 +3302,15 @@
       video_options.suspend_below_min_bitrate.GetWithDefaultIfUnset(false));
 }
 
+TEST_F(WebRtcSessionTest, TestNumUnsignalledRecvStreamsConstraint) {
+  // Number of unsignalled receiving streams should be between 0 and
+  // kMaxUnsignalledRecvStreams.
+  SetAndVerifyNumUnsignalledRecvStreams(10, 10);
+  SetAndVerifyNumUnsignalledRecvStreams(kMaxUnsignalledRecvStreams + 1,
+                                        kMaxUnsignalledRecvStreams);
+  SetAndVerifyNumUnsignalledRecvStreams(-1, 0);
+}
+
 // Tests that we can renegotiate new media content with ICE candidates in the
 // new remote SDP.
 TEST_F(WebRtcSessionTest, TestRenegotiateNewMediaWithCandidatesInSdp) {