Update libjingle to 61514460

TBR=tommi@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/8649004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@5545 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/talk/base/asyncpacketsocket.h b/talk/base/asyncpacketsocket.h
index 29ab55f..d9e1bff 100644
--- a/talk/base/asyncpacketsocket.h
+++ b/talk/base/asyncpacketsocket.h
@@ -28,6 +28,7 @@
 #ifndef TALK_BASE_ASYNCPACKETSOCKET_H_
 #define TALK_BASE_ASYNCPACKETSOCKET_H_
 
+#include "talk/base/buffer.h"
 #include "talk/base/dscp.h"
 #include "talk/base/sigslot.h"
 #include "talk/base/socket.h"
@@ -35,6 +36,29 @@
 
 namespace talk_base {
 
+// This structure holds the info needed to update the packet send time header
+// extension, including the information needed to update the authentication tag
+// after changing the value.
+struct PacketTimeUpdateParams {
+  PacketTimeUpdateParams()
+      : rtp_sendtime_extension_id(-1), srtp_auth_tag_len(-1),
+        srtp_packet_index(-1) {
+  }
+
+  int rtp_sendtime_extension_id;  // extension header id present in packet.
+  Buffer srtp_auth_key;           // Authentication key.
+  int srtp_auth_tag_len;          // Authentication tag length.
+  int64 srtp_packet_index;        // Required for Rtp Packet authentication.
+};
+
+// This structure holds meta information for the packet which is about to send
+// over network.
+struct PacketOptions {
+  PacketOptions() : dscp(DSCP_NO_CHANGE) {}
+  DiffServCodePoint dscp;
+  PacketTimeUpdateParams packet_time_params;
+};
+
 // This structure will have the information about when packet is actually
 // received by socket.
 struct PacketTime {
diff --git a/talk/base/fakenetwork.h b/talk/base/fakenetwork.h
index 3bdc97f..497ff20 100644
--- a/talk/base/fakenetwork.h
+++ b/talk/base/fakenetwork.h
@@ -109,10 +109,12 @@
         prefix_length = kFakeIPv6NetworkPrefixLength;
       }
       IPAddress prefix = TruncateIP(it->ipaddr(), prefix_length);
+      std::string key = MakeNetworkKey(it->hostname(), prefix, prefix_length);
       scoped_ptr<Network> net(new Network(it->hostname(),
                                           it->hostname(),
                                           prefix,
-                                          prefix_length));
+                                          prefix_length,
+                                          key));
       net->AddIP(it->ipaddr());
       networks.push_back(net.release());
     }
diff --git a/talk/base/fakesslidentity.h b/talk/base/fakesslidentity.h
index 203bb83..ee0e0a2 100644
--- a/talk/base/fakesslidentity.h
+++ b/talk/base/fakesslidentity.h
@@ -38,9 +38,12 @@
 
 class FakeSSLCertificate : public talk_base::SSLCertificate {
  public:
-  explicit FakeSSLCertificate(const std::string& data) : data_(data) {}
+  // SHA-1 is the default digest algorithm because it is available in all build
+  // configurations used for unit testing.
+  explicit FakeSSLCertificate(const std::string& data)
+      : data_(data), digest_algorithm_(DIGEST_SHA_1) {}
   explicit FakeSSLCertificate(const std::vector<std::string>& certs)
-      : data_(certs.front()) {
+      : data_(certs.front()), digest_algorithm_(DIGEST_SHA_1) {
     std::vector<std::string>::const_iterator it;
     // Skip certs[0].
     for (it = certs.begin() + 1; it != certs.end(); ++it) {
@@ -58,10 +61,11 @@
     VERIFY(SSLIdentity::PemToDer(kPemTypeCertificate, data_, &der_string));
     der_buffer->SetData(der_string.c_str(), der_string.size());
   }
+  void set_digest_algorithm(const std::string& algorithm) {
+    digest_algorithm_ = algorithm;
+  }
   virtual bool GetSignatureDigestAlgorithm(std::string* algorithm) const {
-    // SHA-1 is chosen because it is available in all build configurations
-    // used for unit testing.
-    *algorithm = DIGEST_SHA_1;
+    *algorithm = digest_algorithm_;
     return true;
   }
   virtual bool ComputeDigest(const std::string &algorithm,
@@ -86,6 +90,7 @@
   }
   std::string data_;
   std::vector<FakeSSLCertificate> certs_;
+  std::string digest_algorithm_;
 };
 
 class FakeSSLIdentity : public talk_base::SSLIdentity {
diff --git a/talk/base/network.cc b/talk/base/network.cc
index 00b04c9..95a2e4d 100644
--- a/talk/base/network.cc
+++ b/talk/base/network.cc
@@ -79,16 +79,7 @@
 // Fetch list of networks every two seconds.
 const int kNetworksUpdateIntervalMs = 2000;
 
-
-// Makes a string key for this network. Used in the network manager's maps.
-// Network objects are keyed on interface name, network prefix and the
-// length of that prefix.
-std::string MakeNetworkKey(const std::string& name, const IPAddress& prefix,
-                           int prefix_length) {
-  std::ostringstream ost;
-  ost << name << "%" << prefix.ToString() << "/" << prefix_length;
-  return ost.str();
-}
+const int kHighestNetworkPreference = 127;
 
 bool CompareNetworks(const Network* a, const Network* b) {
   if (a->prefix_length() == b->prefix_length()) {
@@ -99,9 +90,36 @@
   return a->name() < b->name();
 }
 
+bool SortNetworks(const Network* a, const Network* b) {
+  // Network types will be preferred above everything else while sorting
+  // Networks.
+
+  // Networks are sorted first by type.
+  if (a->type() != b->type()) {
+    return a->type() < b->type();
+  }
+
+  // After type, networks are sorted by IP address precedence values
+  // from RFC 3484-bis
+  if (IPAddressPrecedence(a->ip()) != IPAddressPrecedence(b->ip())) {
+    return IPAddressPrecedence(a->ip()) > IPAddressPrecedence(b->ip());
+  }
+
+  // TODO(mallinath) - Add VPN and Link speed conditions while sorting.
+
+  // Networks are sorted last by key.
+  return a->key() > b->key();
+}
 
 }  // namespace
 
+std::string MakeNetworkKey(const std::string& name, const IPAddress& prefix,
+                           int prefix_length) {
+  std::ostringstream ost;
+  ost << name << "%" << prefix.ToString() << "/" << prefix_length;
+  return ost.str();
+}
+
 NetworkManager::NetworkManager() {
 }
 
@@ -180,6 +198,29 @@
     }
   }
   networks_ = merged_list;
+
+  // If the network lists changes, we resort it.
+  if (changed) {
+    std::sort(networks_.begin(), networks_.end(), SortNetworks);
+    // Now network interfaces are sorted, we should set the preference value
+    // for each of the interfaces we are planning to use.
+    // Preference order of network interfaces might have changed from previous
+    // sorting due to addition of higher preference network interface.
+    // Since we have already sorted the network interfaces based on our
+    // requirements, we will just assign a preference value starting with 127,
+    // in decreasing order.
+    int pref = kHighestNetworkPreference;
+    for (NetworkList::const_iterator iter = networks_.begin();
+         iter != networks_.end(); ++iter) {
+      (*iter)->set_preference(pref);
+      if (pref > 0) {
+        --pref;
+      } else {
+        LOG(LS_ERROR) << "Too many network interfaces to handle!";
+        break;
+      }
+    }
+  }
 }
 
 BasicNetworkManager::BasicNetworkManager()
@@ -240,6 +281,7 @@
         continue;
       }
     }
+
     int prefix_length = CountIPMaskBits(mask);
     prefix = TruncateIP(ip, prefix_length);
     std::string key = MakeNetworkKey(std::string(cursor->ifa_name),
@@ -249,7 +291,8 @@
       scoped_ptr<Network> network(new Network(cursor->ifa_name,
                                               cursor->ifa_name,
                                               prefix,
-                                              prefix_length));
+                                              prefix_length,
+                                              key));
       network->set_scope_id(scope_id);
       network->AddIP(ip);
       bool ignored = ((cursor->ifa_flags & IFF_LOOPBACK) ||
@@ -386,6 +429,7 @@
             continue;
           }
         }
+
         IPAddress prefix;
         int prefix_length = GetPrefix(prefixlist, ip, &prefix);
         std::string key = MakeNetworkKey(name, prefix, prefix_length);
@@ -394,7 +438,8 @@
           scoped_ptr<Network> network(new Network(name,
                                                   description,
                                                   prefix,
-                                                  prefix_length));
+                                                  prefix_length,
+                                                  key));
           network->set_scope_id(scope_id);
           network->AddIP(ip);
           bool ignore = ((adapter_addrs->IfType == IF_TYPE_SOFTWARE_LOOPBACK) ||
@@ -562,11 +607,20 @@
 }
 
 Network::Network(const std::string& name, const std::string& desc,
+                 const IPAddress& prefix, int prefix_length,
+                 const std::string& key)
+    : name_(name), description_(desc), prefix_(prefix),
+      prefix_length_(prefix_length), key_(key), scope_id_(0), ignored_(false),
+      uniform_numerator_(0), uniform_denominator_(0), exponential_numerator_(0),
+      exponential_denominator_(0), type_(ADAPTER_TYPE_UNKNOWN), preference_(0) {
+}
+
+Network::Network(const std::string& name, const std::string& desc,
                  const IPAddress& prefix, int prefix_length)
     : name_(name), description_(desc), prefix_(prefix),
       prefix_length_(prefix_length), scope_id_(0), ignored_(false),
       uniform_numerator_(0), uniform_denominator_(0), exponential_numerator_(0),
-      exponential_denominator_(0) {
+      exponential_denominator_(0), type_(ADAPTER_TYPE_UNKNOWN), preference_(0) {
 }
 
 std::string Network::ToString() const {
@@ -600,4 +654,5 @@
   ips_ = ips;
   return changed;
 }
+
 }  // namespace talk_base
diff --git a/talk/base/network.h b/talk/base/network.h
index 63f3e73..75a443b 100644
--- a/talk/base/network.h
+++ b/talk/base/network.h
@@ -45,9 +45,23 @@
 namespace talk_base {
 
 class Network;
-class NetworkSession;
 class Thread;
 
+enum AdapterType {
+  // This enum resembles the one in Chromium net::ConnectionType.
+  ADAPTER_TYPE_UNKNOWN = 0,
+  ADAPTER_TYPE_ETHERNET = 1,
+  ADAPTER_TYPE_WIFI = 2,
+  ADAPTER_TYPE_CELLULAR = 3,
+  ADAPTER_TYPE_VPN = 4
+};
+
+// Makes a string key for this network. Used in the network manager's maps.
+// Network objects are keyed on interface name, network prefix and the
+// length of that prefix.
+std::string MakeNetworkKey(const std::string& name, const IPAddress& prefix,
+                           int prefix_length);
+
 // Generic network manager interface. It provides list of local
 // networks.
 class NetworkManager {
@@ -168,7 +182,12 @@
 // Represents a Unix-type network interface, with a name and single address.
 class Network {
  public:
-  Network() : prefix_(INADDR_ANY), scope_id_(0) {}
+  Network() : prefix_(INADDR_ANY), scope_id_(0),
+              type_(ADAPTER_TYPE_UNKNOWN) {}
+  Network(const std::string& name, const std::string& description,
+          const IPAddress& prefix, int prefix_length,
+          const std::string& key);
+
   Network(const std::string& name, const std::string& description,
           const IPAddress& prefix, int prefix_length);
 
@@ -184,6 +203,10 @@
   // Returns the length, in bits, of this network's prefix.
   int prefix_length() const { return prefix_length_; }
 
+  // |key_| has unique value per network interface. Used in sorting network
+  // interfaces. Key is derived from interface name and it's prefix.
+  std::string key() const { return key_; }
+
   // Returns the Network's current idea of the 'best' IP it has.
   // 'Best' currently means the first one added.
   // TODO: We should be preferring temporary addresses.
@@ -215,27 +238,32 @@
   bool ignored() const { return ignored_; }
   void set_ignored(bool ignored) { ignored_ = ignored; }
 
+  AdapterType type() const { return type_; }
+  int preference() const { return preference_; }
+  void set_preference(int preference) { preference_ = preference; }
+
   // Debugging description of this network
   std::string ToString() const;
 
  private:
-  typedef std::vector<NetworkSession*> SessionList;
-
   std::string name_;
   std::string description_;
   IPAddress prefix_;
   int prefix_length_;
+  std::string key_;
   std::vector<IPAddress> ips_;
   int scope_id_;
   bool ignored_;
-  SessionList sessions_;
   double uniform_numerator_;
   double uniform_denominator_;
   double exponential_numerator_;
   double exponential_denominator_;
+  AdapterType type_;
+  int preference_;
 
   friend class NetworkManager;
 };
+
 }  // namespace talk_base
 
 #endif  // TALK_BASE_NETWORK_H_
diff --git a/talk/base/network_unittest.cc b/talk/base/network_unittest.cc
index e11e78d..85aa2f8 100644
--- a/talk/base/network_unittest.cc
+++ b/talk/base/network_unittest.cc
@@ -527,6 +527,33 @@
   }
 }
 
+TEST_F(NetworkTest, TestNetworkListSorting) {
+  BasicNetworkManager manager;
+  Network ipv4_network1("test_eth0", "Test Network Adapter 1",
+                        IPAddress(0x12345600U), 24);
+  ipv4_network1.AddIP(IPAddress(0x12345600U));
+
+  IPAddress ip;
+  IPAddress prefix;
+  EXPECT_TRUE(IPFromString("2400:4030:1:2c00:be30:abcd:efab:cdef", &ip));
+  prefix = TruncateIP(ip, 64);
+  Network ipv6_eth1_publicnetwork1_ip1("test_eth1", "Test NetworkAdapter 2",
+                                       prefix, 64);
+  ipv6_eth1_publicnetwork1_ip1.AddIP(ip);
+
+  NetworkManager::NetworkList list;
+  list.push_back(new Network(ipv4_network1));
+  list.push_back(new Network(ipv6_eth1_publicnetwork1_ip1));
+  Network* net1 = list[0];
+  Network* net2 = list[1];
+
+  bool changed = false;
+  MergeNetworkList(manager, list, &changed);
+  ASSERT_TRUE(changed);
+  // After sorting IPv6 network should be higher order than IPv4 networks.
+  EXPECT_TRUE(net1->preference() < net2->preference());
+}
+
 #if defined(POSIX)
 // Verify that we correctly handle interfaces with no address.
 TEST_F(NetworkTest, TestConvertIfAddrsNoAddress) {
diff --git a/talk/base/openssl.h b/talk/base/openssl.h
new file mode 100644
index 0000000..e2cfd2b
--- /dev/null
+++ b/talk/base/openssl.h
@@ -0,0 +1,37 @@
+/*
+ * libjingle
+ * Copyright 2013, Google Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ *  1. Redistributions of source code must retain the above copyright notice,
+ *     this list of conditions and the following disclaimer.
+ *  2. Redistributions in binary form must reproduce the above copyright notice,
+ *     this list of conditions and the following disclaimer in the documentation
+ *     and/or other materials provided with the distribution.
+ *  3. The name of the author may not be used to endorse or promote products
+ *     derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+ * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef TALK_BASE_OPENSSL_H_
+#define TALK_BASE_OPENSSL_H_
+
+#include <openssl/ssl.h>
+
+#if (OPENSSL_VERSION_NUMBER < 0x10001000L)
+#error OpenSSL is older than 1.0.1, which is the minimum supported version.
+#endif
+
+#endif  // TALK_BASE_OPENSSL_H_
diff --git a/talk/base/openssladapter.cc b/talk/base/openssladapter.cc
index 95d5a1a..9e6fe72 100644
--- a/talk/base/openssladapter.cc
+++ b/talk/base/openssladapter.cc
@@ -41,7 +41,6 @@
 #include <openssl/err.h>
 #include <openssl/opensslv.h>
 #include <openssl/rand.h>
-#include <openssl/ssl.h>
 #include <openssl/x509v3.h>
 
 #if HAVE_CONFIG_H
@@ -50,6 +49,7 @@
 
 #include "talk/base/common.h"
 #include "talk/base/logging.h"
+#include "talk/base/openssl.h"
 #include "talk/base/sslroots.h"
 #include "talk/base/stringutils.h"
 
@@ -688,11 +688,7 @@
     int extension_nid = OBJ_obj2nid(X509_EXTENSION_get_object(extension));
 
     if (extension_nid == NID_subject_alt_name) {
-#if OPENSSL_VERSION_NUMBER >= 0x10000000L
       const X509V3_EXT_METHOD* meth = X509V3_EXT_get(extension);
-#else
-      X509V3_EXT_METHOD* meth = X509V3_EXT_get(extension);
-#endif
       if (!meth)
         break;
 
@@ -703,12 +699,8 @@
       // See http://readlist.com/lists/openssl.org/openssl-users/0/4761.html.
       unsigned char* ext_value_data = extension->value->data;
 
-#if OPENSSL_VERSION_NUMBER >= 0x0090800fL
       const unsigned char **ext_value_data_ptr =
           (const_cast<const unsigned char **>(&ext_value_data));
-#else
-      unsigned char **ext_value_data_ptr = &ext_value_data;
-#endif
 
       if (meth->it) {
         ext_str = ASN1_item_d2i(NULL, ext_value_data_ptr,
diff --git a/talk/base/openssldigest.cc b/talk/base/openssldigest.cc
index 3d9276d..3d0d227 100644
--- a/talk/base/openssldigest.cc
+++ b/talk/base/openssldigest.cc
@@ -30,6 +30,7 @@
 #include "talk/base/openssldigest.h"
 
 #include "talk/base/common.h"
+#include "talk/base/openssl.h"
 
 namespace talk_base {
 
@@ -78,7 +79,6 @@
     md = EVP_md5();
   } else if (algorithm == DIGEST_SHA_1) {
     md = EVP_sha1();
-#if OPENSSL_VERSION_NUMBER >= 0x00908000L
   } else if (algorithm == DIGEST_SHA_224) {
     md = EVP_sha224();
   } else if (algorithm == DIGEST_SHA_256) {
@@ -87,7 +87,6 @@
     md = EVP_sha384();
   } else if (algorithm == DIGEST_SHA_512) {
     md = EVP_sha512();
-#endif
   } else {
     return false;
   }
@@ -108,7 +107,6 @@
     *algorithm = DIGEST_MD5;
   } else if (md_type == NID_sha1) {
     *algorithm = DIGEST_SHA_1;
-#if OPENSSL_VERSION_NUMBER >= 0x00908000L
   } else if (md_type == NID_sha224) {
     *algorithm = DIGEST_SHA_224;
   } else if (md_type == NID_sha256) {
@@ -117,7 +115,6 @@
     *algorithm = DIGEST_SHA_384;
   } else if (md_type == NID_sha512) {
     *algorithm = DIGEST_SHA_512;
-#endif
   } else {
     algorithm->clear();
     return false;
diff --git a/talk/base/opensslidentity.cc b/talk/base/opensslidentity.cc
index 33b02dd..bd361d1 100644
--- a/talk/base/opensslidentity.cc
+++ b/talk/base/opensslidentity.cc
@@ -32,7 +32,6 @@
 // Must be included first before openssl headers.
 #include "talk/base/win32.h"  // NOLINT
 
-#include <openssl/ssl.h>
 #include <openssl/bio.h>
 #include <openssl/err.h>
 #include <openssl/pem.h>
@@ -43,6 +42,7 @@
 #include "talk/base/checks.h"
 #include "talk/base/helpers.h"
 #include "talk/base/logging.h"
+#include "talk/base/openssl.h"
 #include "talk/base/openssldigest.h"
 
 namespace talk_base {
@@ -66,15 +66,6 @@
 static EVP_PKEY* MakeKey() {
   LOG(LS_INFO) << "Making key pair";
   EVP_PKEY* pkey = EVP_PKEY_new();
-#if OPENSSL_VERSION_NUMBER < 0x00908000l
-  // Only RSA_generate_key is available. Use that.
-  RSA* rsa = RSA_generate_key(KEY_LENGTH, 0x10001, NULL, NULL);
-  if (!EVP_PKEY_assign_RSA(pkey, rsa)) {
-    EVP_PKEY_free(pkey);
-    RSA_free(rsa);
-    return NULL;
-  }
-#else
   // RSA_generate_key is deprecated. Use _ex version.
   BIGNUM* exponent = BN_new();
   RSA* rsa = RSA_new();
@@ -89,7 +80,6 @@
   }
   // ownership of rsa struct was assigned, don't free it.
   BN_free(exponent);
-#endif
   LOG(LS_INFO) << "Returning key pair";
   return pkey;
 }
diff --git a/talk/base/opensslstreamadapter.cc b/talk/base/opensslstreamadapter.cc
index 576b4245..cafef92 100644
--- a/talk/base/opensslstreamadapter.cc
+++ b/talk/base/opensslstreamadapter.cc
@@ -37,7 +37,6 @@
 #include <openssl/crypto.h>
 #include <openssl/err.h>
 #include <openssl/rand.h>
-#include <openssl/ssl.h>
 #include <openssl/x509v3.h>
 
 #include <vector>
@@ -45,6 +44,7 @@
 #include "talk/base/common.h"
 #include "talk/base/logging.h"
 #include "talk/base/stream.h"
+#include "talk/base/openssl.h"
 #include "talk/base/openssladapter.h"
 #include "talk/base/openssldigest.h"
 #include "talk/base/opensslidentity.h"
@@ -53,15 +53,6 @@
 
 namespace talk_base {
 
-#if (OPENSSL_VERSION_NUMBER >= 0x10001000L)
-#define HAVE_DTLS_SRTP
-#endif
-
-#if (OPENSSL_VERSION_NUMBER >= 0x10000000L)
-#define HAVE_DTLS
-#endif
-
-#ifdef HAVE_DTLS_SRTP
 // SRTP cipher suite table
 struct SrtpCipherMapEntry {
   const char* external_name;
@@ -74,7 +65,6 @@
   {"AES_CM_128_HMAC_SHA1_32", "SRTP_AES128_CM_SHA1_32"},
   {NULL, NULL}
 };
-#endif
 
 //////////////////////////////////////////////////////////////////////
 // StreamBIO
@@ -248,7 +238,6 @@
                                                 bool use_context,
                                                 uint8* result,
                                                 size_t result_len) {
-#ifdef HAVE_DTLS_SRTP
   int i;
 
   i = SSL_export_keying_material(ssl_, result, result_len,
@@ -260,9 +249,6 @@
     return false;
 
   return true;
-#else
-  return false;
-#endif
 }
 
 bool OpenSSLStreamAdapter::SetDtlsSrtpCiphers(
@@ -272,7 +258,6 @@
   if (state_ != SSL_NONE)
     return false;
 
-#ifdef HAVE_DTLS_SRTP
   for (std::vector<std::string>::const_iterator cipher = ciphers.begin();
        cipher != ciphers.end(); ++cipher) {
     bool found = false;
@@ -298,13 +283,9 @@
 
   srtp_ciphers_ = internal_ciphers;
   return true;
-#else
-  return false;
-#endif
 }
 
 bool OpenSSLStreamAdapter::GetDtlsSrtpCipher(std::string* cipher) {
-#ifdef HAVE_DTLS_SRTP
   ASSERT(state_ == SSL_CONNECTED);
   if (state_ != SSL_CONNECTED)
     return false;
@@ -326,9 +307,6 @@
   ASSERT(false);  // This should never happen
 
   return false;
-#else
-  return false;
-#endif
 }
 
 int OpenSSLStreamAdapter::StartSSLWithServer(const char* server_name) {
@@ -665,14 +643,12 @@
 
     case SSL_ERROR_WANT_READ: {
         LOG(LS_VERBOSE) << " -- error want read";
-#ifdef HAVE_DTLS
         struct timeval timeout;
         if (DTLSv1_get_timeout(ssl_, &timeout)) {
           int delay = timeout.tv_sec * 1000 + timeout.tv_usec/1000;
 
           Thread::Current()->PostDelayed(delay, this, MSG_TIMEOUT, 0);
         }
-#endif
       }
       break;
 
@@ -727,9 +703,7 @@
   // Process our own messages and then pass others to the superclass
   if (MSG_TIMEOUT == msg->message_id) {
     LOG(LS_INFO) << "DTLS timeout expired";
-#ifdef HAVE_DTLS
     DTLSv1_handle_timeout(ssl_);
-#endif
     ContinueSSL();
   } else {
     StreamInterface::OnMessage(msg);
@@ -740,19 +714,11 @@
   SSL_CTX *ctx = NULL;
 
   if (role_ == SSL_CLIENT) {
-#ifdef HAVE_DTLS
     ctx = SSL_CTX_new(ssl_mode_ == SSL_MODE_DTLS ?
         DTLSv1_client_method() : TLSv1_client_method());
-#else
-    ctx = SSL_CTX_new(TLSv1_client_method());
-#endif
   } else {
-#ifdef HAVE_DTLS
     ctx = SSL_CTX_new(ssl_mode_ == SSL_MODE_DTLS ?
         DTLSv1_server_method() : TLSv1_server_method());
-#else
-    ctx = SSL_CTX_new(TLSv1_server_method());
-#endif
   }
   if (ctx == NULL)
     return NULL;
@@ -771,14 +737,12 @@
   SSL_CTX_set_verify_depth(ctx, 4);
   SSL_CTX_set_cipher_list(ctx, "ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH");
 
-#ifdef HAVE_DTLS_SRTP
   if (!srtp_ciphers_.empty()) {
     if (SSL_CTX_set_tlsext_use_srtp(ctx, srtp_ciphers_.c_str())) {
       SSL_CTX_free(ctx);
       return NULL;
     }
   }
-#endif
 
   return ctx;
 }
@@ -852,27 +816,15 @@
 }
 
 bool OpenSSLStreamAdapter::HaveDtls() {
-#ifdef HAVE_DTLS
   return true;
-#else
-  return false;
-#endif
 }
 
 bool OpenSSLStreamAdapter::HaveDtlsSrtp() {
-#ifdef HAVE_DTLS_SRTP
   return true;
-#else
-  return false;
-#endif
 }
 
 bool OpenSSLStreamAdapter::HaveExporter() {
-#ifdef HAVE_DTLS_SRTP
   return true;
-#else
-  return false;
-#endif
 }
 
 }  // namespace talk_base
diff --git a/talk/base/physicalsocketserver.cc b/talk/base/physicalsocketserver.cc
index d4a4b1a..07a9d4b 100644
--- a/talk/base/physicalsocketserver.cc
+++ b/talk/base/physicalsocketserver.cc
@@ -541,6 +541,8 @@
       case OPT_DSCP:
         LOG(LS_WARNING) << "Socket::OPT_DSCP not supported.";
         return -1;
+      case OPT_RTP_SENDTIME_EXTN_ID:
+        return -1;  // No logging is necessary as this not a OS socket option.
       default:
         ASSERT(false);
         return -1;
diff --git a/talk/base/socket.h b/talk/base/socket.h
index 47f5522..590645f 100644
--- a/talk/base/socket.h
+++ b/talk/base/socket.h
@@ -185,7 +185,10 @@
     OPT_SNDBUF,      // send buffer size
     OPT_NODELAY,     // whether Nagle algorithm is enabled
     OPT_IPV6_V6ONLY, // Whether the socket is IPv6 only.
-    OPT_DSCP         // DSCP code
+    OPT_DSCP,        // DSCP code
+    OPT_RTP_SENDTIME_EXTN_ID,  // This is a non-traditional socket option param.
+                               // This is specific to libjingle and will be used
+                               // if SendTime option is needed at socket level.
   };
   virtual int GetOption(Option opt, int* value) = 0;
   virtual int SetOption(Option opt, int value) = 0;
diff --git a/talk/base/thread_unittest.cc b/talk/base/thread_unittest.cc
index 3a9103f..728e321 100644
--- a/talk/base/thread_unittest.cc
+++ b/talk/base/thread_unittest.cc
@@ -339,7 +339,7 @@
   Thread* expected_thread_;
 };
 
-TEST_F(AsyncInvokeTest, FireAndForget) {
+TEST_F(AsyncInvokeTest, DISABLED_FireAndForget) {
   AsyncInvoker invoker;
   // Create and start the thread.
   Thread thread;
@@ -350,7 +350,7 @@
   EXPECT_TRUE_WAIT(called, kWaitTimeout);
 }
 
-TEST_F(AsyncInvokeTest, WithCallback) {
+TEST_F(AsyncInvokeTest, DISABLED_WithCallback) {
   AsyncInvoker invoker;
   // Create and start the thread.
   Thread thread;
@@ -379,7 +379,7 @@
   EXPECT_EQ(0, int_value_);
 }
 
-TEST_F(AsyncInvokeTest, CancelCallingThread) {
+TEST_F(AsyncInvokeTest, DISABLED_CancelCallingThread) {
   AsyncInvoker invoker;
   { // Create and start the thread.
     Thread thread;
@@ -396,7 +396,7 @@
   EXPECT_EQ(0, int_value_);
 }
 
-TEST_F(AsyncInvokeTest, KillInvokerBeforeExecute) {
+TEST_F(AsyncInvokeTest, DISABLED_KillInvokerBeforeExecute) {
   Thread thread;
   thread.Start();
   {
@@ -413,7 +413,7 @@
   EXPECT_EQ(0, int_value_);
 }
 
-TEST_F(AsyncInvokeTest, Flush) {
+TEST_F(AsyncInvokeTest, DISABLED_Flush) {
   AsyncInvoker invoker;
   bool flag1 = false;
   bool flag2 = false;
@@ -431,7 +431,7 @@
   EXPECT_TRUE(flag2);
 }
 
-TEST_F(AsyncInvokeTest, FlushWithIds) {
+TEST_F(AsyncInvokeTest, DISABLED_FlushWithIds) {
   AsyncInvoker invoker;
   bool flag1 = false;
   bool flag2 = false;