(Auto)update libjingle 69568113-> 69587333

git-svn-id: http://webrtc.googlecode.com/svn/trunk/talk@6500 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/media/base/rtputils.cc b/media/base/rtputils.cc
index 5215c3b..221d949 100644
--- a/media/base/rtputils.cc
+++ b/media/base/rtputils.cc
@@ -223,4 +223,15 @@
           SetRtpSsrc(data, len, header.ssrc));
 }
 
+bool IsRtpPacket(const void* data, size_t len) {
+  if (len < kMinRtpPacketLen)
+    return false;
+
+  int version = 0;
+  if (!GetRtpVersion(data, len, &version))
+    return false;
+
+  return version == kRtpVersion;
+}
+
 }  // namespace cricket
diff --git a/media/base/rtputils.h b/media/base/rtputils.h
index 6f76866..f653e42 100644
--- a/media/base/rtputils.h
+++ b/media/base/rtputils.h
@@ -74,6 +74,7 @@
 // Assumes version 2, no padding, no extensions, no csrcs.
 bool SetRtpHeader(void* data, size_t len, const RtpHeader& header);
 
+bool IsRtpPacket(const void* data, size_t len);
 }  // namespace cricket
 
 #endif  // TALK_MEDIA_BASE_RTPUTILS_H_
diff --git a/session/media/bundlefilter.cc b/session/media/bundlefilter.cc
index 0d7927c..d3b51c4 100755
--- a/session/media/bundlefilter.cc
+++ b/session/media/bundlefilter.cc
@@ -47,6 +47,10 @@
   // |streams_| is empty, we will allow all rtcp packets pass through provided
   // that they are valid rtcp packets in case that they are for early media.
   if (!rtcp) {
+    // It may not be a RTP packet (e.g. SCTP).
+    if (!IsRtpPacket(data, len))
+      return false;
+
     int payload_type = 0;
     if (!GetRtpPayloadType(data, len, &payload_type)) {
       return false;
diff --git a/session/media/bundlefilter_unittest.cc b/session/media/bundlefilter_unittest.cc
index 0386666..a3e58c1 100755
--- a/session/media/bundlefilter_unittest.cc
+++ b/session/media/bundlefilter_unittest.cc
@@ -105,6 +105,15 @@
     0x81, 0xCE, 0x00, 0x0C, 0x00, 0x00, 0x11, 0x11, 0x00, 0x00, 0x11, 0x11,
 };
 
+// An SCTP packet.
+static const unsigned char kSctpPacket[] = {
+    0x00, 0x01, 0x00, 0x01,
+    0xff, 0xff, 0xff, 0xff,
+    0x00, 0x00, 0x00, 0x00,
+    0x03, 0x00, 0x00, 0x04,
+    0x00, 0x00, 0x00, 0x00,
+};
+
 TEST(BundleFilterTest, AddRemoveStreamTest) {
   cricket::BundleFilter bundle_filter;
   EXPECT_FALSE(bundle_filter.HasStreams());
@@ -194,3 +203,11 @@
       reinterpret_cast<const char*>(kRtcpPacketSrSsrc2),
       sizeof(kRtcpPacketSrSsrc2), true));
 }
+
+TEST(BundleFilterTest, InvalidRtpPacket) {
+  cricket::BundleFilter bundle_filter;
+  EXPECT_TRUE(bundle_filter.AddStream(StreamParams::CreateLegacy(kSsrc1)));
+  EXPECT_FALSE(bundle_filter.DemuxPacket(
+      reinterpret_cast<const char*>(kSctpPacket),
+      sizeof(kSctpPacket), false));
+}
diff --git a/session/media/channel.cc b/session/media/channel.cc
index 575c759..7bf853e 100644
--- a/session/media/channel.cc
+++ b/session/media/channel.cc
@@ -2168,21 +2168,11 @@
   return GetFirstDataContent(sdesc);
 }
 
-
-static bool IsRtpPacket(const talk_base::Buffer* packet) {
-  int version;
-  if (!GetRtpVersion(packet->data(), packet->length(), &version)) {
-    return false;
-  }
-
-  return version == 2;
-}
-
 bool DataChannel::WantsPacket(bool rtcp, talk_base::Buffer* packet) {
   if (data_channel_type_ == DCT_SCTP) {
     // TODO(pthatcher): Do this in a more robust way by checking for
     // SCTP or DTLS.
-    return !IsRtpPacket(packet);
+    return !IsRtpPacket(packet->data(), packet->length());
   } else if (data_channel_type_ == DCT_RTP) {
     return BaseChannel::WantsPacket(rtcp, packet);
   }