Revert 5545 "Update libjingle to 61514460"

> Update libjingle to 61514460
> 
> TBR=tommi@webrtc.org
> 
> Review URL: https://webrtc-codereview.appspot.com/8649004

TBR=xians@webrtc.org

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

git-svn-id: http://webrtc.googlecode.com/svn/trunk@5547 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/talk/app/webrtc/mediastreamhandler.cc b/talk/app/webrtc/mediastreamhandler.cc
index ca8e105..a94eef3 100644
--- a/talk/app/webrtc/mediastreamhandler.cc
+++ b/talk/app/webrtc/mediastreamhandler.cc
@@ -106,8 +106,6 @@
 void LocalAudioTrackHandler::OnEnabledChanged() {
   cricket::AudioOptions options;
   if (audio_track_->enabled() && audio_track_->GetSource()) {
-    // TODO(xians): Remove this static_cast since we should be able to connect
-    // a remote audio track to peer connection.
     options = static_cast<LocalAudioSource*>(
         audio_track_->GetSource())->options();
   }
@@ -127,12 +125,10 @@
     : TrackHandler(track, ssrc),
       audio_track_(track),
       provider_(provider) {
-  track->GetSource()->RegisterAudioObserver(this);
   OnEnabledChanged();
 }
 
 RemoteAudioTrackHandler::~RemoteAudioTrackHandler() {
-  audio_track_->GetSource()->UnregisterAudioObserver(this);
 }
 
 void RemoteAudioTrackHandler::Stop() {
@@ -147,14 +143,6 @@
                              audio_track_->GetRenderer());
 }
 
-void RemoteAudioTrackHandler::OnSetVolume(double volume) {
-  // When the track is disabled, the volume of the source, which is the
-  // corresponding WebRtc Voice Engine channel will be 0. So we do not allow
-  // setting the volume to the source when the track is disabled.
-  if (audio_track_->enabled())
-    provider_->SetAudioPlayoutVolume(ssrc(), volume);
-}
-
 LocalVideoTrackHandler::LocalVideoTrackHandler(
     VideoTrackInterface* track,
     uint32 ssrc,
diff --git a/talk/app/webrtc/mediastreamhandler.h b/talk/app/webrtc/mediastreamhandler.h
index 53afd55..625de85 100644
--- a/talk/app/webrtc/mediastreamhandler.h
+++ b/talk/app/webrtc/mediastreamhandler.h
@@ -118,8 +118,7 @@
 // RemoteAudioTrackHandler listen to events on a remote AudioTrack instance
 // connected to a PeerConnection and orders the |provider| to executes the
 // requested change.
-class RemoteAudioTrackHandler : public AudioSourceInterface::AudioObserver,
-                                public TrackHandler {
+class RemoteAudioTrackHandler : public TrackHandler {
  public:
   RemoteAudioTrackHandler(AudioTrackInterface* track,
                           uint32 ssrc,
@@ -132,9 +131,6 @@
   virtual void OnEnabledChanged() OVERRIDE;
 
  private:
-  // AudioSourceInterface::AudioObserver implementation.
-  virtual void OnSetVolume(double volume) OVERRIDE;
-
   AudioTrackInterface* audio_track_;
   AudioProviderInterface* provider_;
 };
diff --git a/talk/app/webrtc/mediastreamhandler_unittest.cc b/talk/app/webrtc/mediastreamhandler_unittest.cc
index 6eedb7e..475258e 100644
--- a/talk/app/webrtc/mediastreamhandler_unittest.cc
+++ b/talk/app/webrtc/mediastreamhandler_unittest.cc
@@ -31,7 +31,6 @@
 
 #include "talk/app/webrtc/audiotrack.h"
 #include "talk/app/webrtc/mediastream.h"
-#include "talk/app/webrtc/remoteaudiosource.h"
 #include "talk/app/webrtc/streamcollection.h"
 #include "talk/app/webrtc/videosource.h"
 #include "talk/app/webrtc/videotrack.h"
@@ -60,7 +59,6 @@
   MOCK_METHOD4(SetAudioSend, void(uint32 ssrc, bool enable,
                                   const cricket::AudioOptions& options,
                                   cricket::AudioRenderer* renderer));
-  MOCK_METHOD2(SetAudioPlayoutVolume, void(uint32 ssrc, double volume));
 };
 
 // Helper class to test MediaStreamHandler.
@@ -112,11 +110,12 @@
         FakeVideoSource::Create());
     video_track_ = VideoTrack::Create(kVideoTrackId, source);
     EXPECT_TRUE(stream_->AddTrack(video_track_));
+    audio_track_ = AudioTrack::Create(kAudioTrackId,
+                                           NULL);
+    EXPECT_TRUE(stream_->AddTrack(audio_track_));
   }
 
   void AddLocalAudioTrack() {
-    audio_track_ = AudioTrack::Create(kAudioTrackId, NULL);
-    EXPECT_TRUE(stream_->AddTrack(audio_track_));
     EXPECT_CALL(audio_provider_, SetAudioSend(kAudioSsrc, true, _, _));
     handlers_.AddLocalAudioTrack(stream_, stream_->GetAudioTracks()[0],
                                  kAudioSsrc);
@@ -145,9 +144,6 @@
   }
 
   void AddRemoteAudioTrack() {
-    audio_track_ = AudioTrack::Create(kAudioTrackId,
-                                      RemoteAudioSource::Create().get());
-    EXPECT_TRUE(stream_->AddTrack(audio_track_));
     EXPECT_CALL(audio_provider_, SetAudioPlayout(kAudioSsrc, true, _));
     handlers_.AddRemoteAudioTrack(stream_, stream_->GetAudioTracks()[0],
                                   kAudioSsrc);
@@ -296,27 +292,4 @@
   handlers_.TearDown();
 }
 
-TEST_F(MediaStreamHandlerTest, RemoteAudioTrackSetVolume) {
-  AddRemoteAudioTrack();
-
-  double volume = 0.5;
-  EXPECT_CALL(audio_provider_, SetAudioPlayoutVolume(kAudioSsrc, volume));
-  audio_track_->GetSource()->SetVolume(volume);
-
-  // Disable the audio track, this should prevent setting the volume.
-  EXPECT_CALL(audio_provider_, SetAudioPlayout(kAudioSsrc, false, _));
-  audio_track_->set_enabled(false);
-  audio_track_->GetSource()->SetVolume(1.0);
-
-  EXPECT_CALL(audio_provider_, SetAudioPlayout(kAudioSsrc, true, _));
-  audio_track_->set_enabled(true);
-
-  double new_volume = 0.8;
-  EXPECT_CALL(audio_provider_, SetAudioPlayoutVolume(kAudioSsrc, new_volume));
-  audio_track_->GetSource()->SetVolume(new_volume);
-
-  RemoveRemoteAudioTrack();
-  handlers_.TearDown();
-}
-
 }  // namespace webrtc
diff --git a/talk/app/webrtc/mediastreaminterface.h b/talk/app/webrtc/mediastreaminterface.h
index fa0572e..96d0942 100644
--- a/talk/app/webrtc/mediastreaminterface.h
+++ b/talk/app/webrtc/mediastreaminterface.h
@@ -142,24 +142,9 @@
 
 // AudioSourceInterface is a reference counted source used for AudioTracks.
 // The same source can be used in multiple AudioTracks.
+// TODO(perkj): Extend this class with necessary methods to allow separate
+// sources for each audio track.
 class AudioSourceInterface : public MediaSourceInterface {
- public:
-  class AudioObserver {
-   public:
-    virtual void OnSetVolume(double volume) = 0;
-
-   protected:
-    virtual ~AudioObserver() {}
-  };
-
-  // TODO(xians): Makes all the interface pure virtual after Chrome has their
-  // implementations.
-  // Sets the volume to the source. |volume| is in  the range of [0, 10].
-  virtual void SetVolume(double volume) {}
-
-  // Registers/unregisters observer to the audio source.
-  virtual void RegisterAudioObserver(AudioObserver* observer) {}
-  virtual void UnregisterAudioObserver(AudioObserver* observer) {}
 };
 
 // Interface for receiving audio data from a AudioTrack.
diff --git a/talk/app/webrtc/mediastreamprovider.h b/talk/app/webrtc/mediastreamprovider.h
index 5cf0e27..ae00b1d 100644
--- a/talk/app/webrtc/mediastreamprovider.h
+++ b/talk/app/webrtc/mediastreamprovider.h
@@ -53,10 +53,6 @@
                             const cricket::AudioOptions& options,
                             cricket::AudioRenderer* renderer) = 0;
 
-  // Sets the audio playout volume of a remote audio track with |ssrc|.
-  // |volume| is in the range of [0, 10].
-  virtual void SetAudioPlayoutVolume(uint32 ssrc, double volume) = 0;
-
  protected:
   virtual ~AudioProviderInterface() {}
 };
diff --git a/talk/app/webrtc/mediastreamsignaling.cc b/talk/app/webrtc/mediastreamsignaling.cc
index 14648ee..610b3f8 100644
--- a/talk/app/webrtc/mediastreamsignaling.cc
+++ b/talk/app/webrtc/mediastreamsignaling.cc
@@ -33,7 +33,6 @@
 #include "talk/app/webrtc/mediastreamproxy.h"
 #include "talk/app/webrtc/mediaconstraintsinterface.h"
 #include "talk/app/webrtc/mediastreamtrackproxy.h"
-#include "talk/app/webrtc/remoteaudiosource.h"
 #include "talk/app/webrtc/remotevideocapturer.h"
 #include "talk/app/webrtc/sctputils.h"
 #include "talk/app/webrtc/videosource.h"
@@ -141,7 +140,7 @@
   AudioTrackInterface* AddAudioTrack(webrtc::MediaStreamInterface* stream,
                                      const std::string& track_id) {
     return AddTrack<AudioTrackInterface, AudioTrack, AudioTrackProxy>(
-        stream, track_id, RemoteAudioSource::Create().get());
+        stream, track_id, static_cast<AudioSourceInterface*>(NULL));
   }
 
   VideoTrackInterface* AddVideoTrack(webrtc::MediaStreamInterface* stream,
diff --git a/talk/app/webrtc/remoteaudiosource.cc b/talk/app/webrtc/remoteaudiosource.cc
deleted file mode 100644
index 1c275c7..0000000
--- a/talk/app/webrtc/remoteaudiosource.cc
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * libjingle
- * Copyright 2014, 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.
- */
-
-#include "talk/app/webrtc/remoteaudiosource.h"
-
-#include <algorithm>
-#include <functional>
-
-#include "talk/base/logging.h"
-
-namespace webrtc {
-
-talk_base::scoped_refptr<RemoteAudioSource> RemoteAudioSource::Create() {
-  return new talk_base::RefCountedObject<RemoteAudioSource>();
-}
-
-RemoteAudioSource::RemoteAudioSource() {
-}
-
-RemoteAudioSource::~RemoteAudioSource() {
-  ASSERT(audio_observers_.empty());
-}
-
-MediaSourceInterface::SourceState RemoteAudioSource::state() const {
-  return MediaSourceInterface::kLive;
-}
-
-void RemoteAudioSource::SetVolume(double volume) {
-  ASSERT(volume >= 0 && volume <= 10);
-  for (AudioObserverList::iterator it = audio_observers_.begin();
-       it != audio_observers_.end(); ++it) {
-    (*it)->OnSetVolume(volume);
-  }
-}
-
-void RemoteAudioSource::RegisterAudioObserver(AudioObserver* observer) {
-  ASSERT(observer != NULL);
-  ASSERT(std::find(audio_observers_.begin(), audio_observers_.end(),
-                   observer) == audio_observers_.end());
-  audio_observers_.push_back(observer);
-}
-
-void RemoteAudioSource::UnregisterAudioObserver(AudioObserver* observer) {
-  ASSERT(observer != NULL);
-  audio_observers_.remove(observer);
-}
-
-}  // namespace webrtc
diff --git a/talk/app/webrtc/remoteaudiosource.h b/talk/app/webrtc/remoteaudiosource.h
deleted file mode 100644
index ed24214..0000000
--- a/talk/app/webrtc/remoteaudiosource.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * libjingle
- * Copyright 2014, 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_APP_WEBRTC_REMOTEAUDIOSOURCE_H_
-#define TALK_APP_WEBRTC_REMOTEAUDIOSOURCE_H_
-
-#include <list>
-
-#include "talk/app/webrtc/mediastreaminterface.h"
-#include "talk/app/webrtc/notifier.h"
-
-namespace webrtc {
-
-using webrtc::AudioSourceInterface;
-
-// This class implements the audio source used by the remote audio track.
-class RemoteAudioSource : public Notifier<AudioSourceInterface> {
- public:
-  // Creates an instance of RemoteAudioSource.
-  static talk_base::scoped_refptr<RemoteAudioSource> Create();
-
- protected:
-  RemoteAudioSource();
-  virtual ~RemoteAudioSource();
-
- private:
-  typedef std::list<AudioObserver*> AudioObserverList;
-
-  // MediaSourceInterface implementation.
-  virtual MediaSourceInterface::SourceState state() const OVERRIDE;
-
-  // AudioSourceInterface implementation.
-  virtual void SetVolume(double volume) OVERRIDE;
-  virtual void RegisterAudioObserver(AudioObserver* observer) OVERRIDE;
-  virtual void UnregisterAudioObserver(AudioObserver* observer) OVERRIDE;
-
-  AudioObserverList audio_observers_;
-};
-
-}  // namespace webrtc
-
-#endif  // TALK_APP_WEBRTC_REMOTEAUDIOSOURCE_H_
diff --git a/talk/app/webrtc/statscollector.cc b/talk/app/webrtc/statscollector.cc
index ae02830..2efc11b 100644
--- a/talk/app/webrtc/statscollector.cc
+++ b/talk/app/webrtc/statscollector.cc
@@ -78,7 +78,6 @@
 
 const char StatsReport::kStatsValueNameEncodeUsagePercent[] =
     "googEncodeUsagePercent";
-const char StatsReport::kStatsValueNameExpandRate[] = "googExpandRate";
 const char StatsReport::kStatsValueNameFingerprint[] = "googFingerprint";
 const char StatsReport::kStatsValueNameFingerprintAlgorithm[] =
     "googFingerprintAlgorithm";
@@ -222,7 +221,7 @@
                    info.bytes_rcvd);
   report->AddValue(StatsReport::kStatsValueNameJitterReceived,
                    info.jitter_ms);
-  report->AddValue(StatsReport::kStatsValueNameExpandRate,
+  report->AddValue(StatsReport::kStatsValueNameNetEqExpandRate,
                    talk_base::ToString<float>(info.expand_rate));
   report->AddValue(StatsReport::kStatsValueNamePacketsReceived,
                    info.packets_rcvd);
@@ -570,14 +569,6 @@
 
   talk_base::scoped_ptr<talk_base::SSLFingerprint> ssl_fingerprint(
       talk_base::SSLFingerprint::Create(digest_algorithm, cert));
-
-  // SSLFingerprint::Create can fail if the algorithm returned by
-  // SSLCertificate::GetSignatureDigestAlgorithm is not supported by the
-  // implementation of SSLCertificate::ComputeDigest.  This currently happens
-  // with MD5- and SHA-224-signed certificates when linked to libNSS.
-  if (!ssl_fingerprint)
-    return std::string();
-
   std::string fingerprint = ssl_fingerprint->GetRfc4572Fingerprint();
 
   talk_base::Buffer der_buffer;
diff --git a/talk/app/webrtc/statscollector_unittest.cc b/talk/app/webrtc/statscollector_unittest.cc
index 49560ea..1adcb0e 100644
--- a/talk/app/webrtc/statscollector_unittest.cc
+++ b/talk/app/webrtc/statscollector_unittest.cc
@@ -302,24 +302,16 @@
         webrtc::StatsReport::kStatsReportTypeComponent,
         reports,
         webrtc::StatsReport::kStatsValueNameLocalCertificateId);
-    if (local_ders.size() > 0) {
-      EXPECT_NE(kNotFound, local_certificate_id);
-      CheckCertChainReports(reports, local_ders, local_certificate_id);
-    } else {
-      EXPECT_EQ(kNotFound, local_certificate_id);
-    }
+    EXPECT_NE(kNotFound, local_certificate_id);
+    CheckCertChainReports(reports, local_ders, local_certificate_id);
 
     // Check remote certificate chain.
     std::string remote_certificate_id = ExtractStatsValue(
         webrtc::StatsReport::kStatsReportTypeComponent,
         reports,
         webrtc::StatsReport::kStatsValueNameRemoteCertificateId);
-    if (remote_ders.size() > 0) {
-      EXPECT_NE(kNotFound, remote_certificate_id);
-      CheckCertChainReports(reports, remote_ders, remote_certificate_id);
-    } else {
-      EXPECT_EQ(kNotFound, remote_certificate_id);
-    }
+    EXPECT_NE(kNotFound, remote_certificate_id);
+    CheckCertChainReports(reports, remote_ders, remote_certificate_id);
   }
 
   cricket::FakeMediaEngine* media_engine_;
@@ -782,21 +774,4 @@
   ASSERT_EQ(kNotFound, remote_certificate_id);
 }
 
-// This test verifies that a remote certificate with an unsupported digest
-// algorithm is correctly ignored.
-TEST_F(StatsCollectorTest, UnsupportedDigestIgnored) {
-  // Build a local certificate.
-  std::string local_der = "This is the local der.";
-  talk_base::FakeSSLCertificate local_cert(DerToPem(local_der));
-
-  // Build a remote certificate with an unsupported digest algorithm.
-  std::string remote_der = "This is somebody else's der.";
-  talk_base::FakeSSLCertificate remote_cert(DerToPem(remote_der));
-  remote_cert.set_digest_algorithm("foobar");
-
-  TestCertificateReports(local_cert, std::vector<std::string>(1, local_der),
-                         remote_cert, std::vector<std::string>());
-}
-
-
 }  // namespace
diff --git a/talk/app/webrtc/statstypes.h b/talk/app/webrtc/statstypes.h
index 76ae32c..9110da3 100644
--- a/talk/app/webrtc/statstypes.h
+++ b/talk/app/webrtc/statstypes.h
@@ -141,7 +141,6 @@
   static const char kStatsValueNameEchoDelayStdDev[];
   static const char kStatsValueNameEchoReturnLoss[];
   static const char kStatsValueNameEchoReturnLossEnhancement[];
-  static const char kStatsValueNameExpandRate[];
   static const char kStatsValueNameFirsReceived[];
   static const char kStatsValueNameFirsSent[];
   static const char kStatsValueNameFrameHeightInput[];
diff --git a/talk/app/webrtc/webrtc.scons b/talk/app/webrtc/webrtc.scons
index dd4bea0..9b1af3c 100644
--- a/talk/app/webrtc/webrtc.scons
+++ b/talk/app/webrtc/webrtc.scons
@@ -31,7 +31,6 @@
       'peerconnectionfactory.cc',
       'peerconnection.cc',
       'portallocatorfactory.cc',
-      'remoteaudiosource.cc',
       'roapmessages.cc',
       'roapsession.cc',
       'roapsignaling.cc',
diff --git a/talk/app/webrtc/webrtcsession.cc b/talk/app/webrtc/webrtcsession.cc
index ef6af49..59d7270 100644
--- a/talk/app/webrtc/webrtcsession.cc
+++ b/talk/app/webrtc/webrtcsession.cc
@@ -866,18 +866,6 @@
     voice_channel_->SetChannelOptions(options);
 }
 
-void WebRtcSession::SetAudioPlayoutVolume(uint32 ssrc, double volume) {
-  ASSERT(signaling_thread()->IsCurrent());
-  ASSERT(volume >= 0 && volume <= 10);
-  if (!voice_channel_) {
-    LOG(LS_ERROR) << "SetAudioPlayoutVolume: No audio channel exists.";
-    return;
-  }
-
-  if (!voice_channel_->SetOutputScaling(ssrc, volume, volume))
-    ASSERT(false);
-}
-
 bool WebRtcSession::SetCaptureDevice(uint32 ssrc,
                                      cricket::VideoCapturer* camera) {
   ASSERT(signaling_thread()->IsCurrent());
diff --git a/talk/app/webrtc/webrtcsession.h b/talk/app/webrtc/webrtcsession.h
index 628aa1e..384ac47 100644
--- a/talk/app/webrtc/webrtcsession.h
+++ b/talk/app/webrtc/webrtcsession.h
@@ -165,7 +165,6 @@
   virtual void SetAudioSend(uint32 ssrc, bool enable,
                             const cricket::AudioOptions& options,
                             cricket::AudioRenderer* renderer) OVERRIDE;
-  virtual void SetAudioPlayoutVolume(uint32 ssrc, double volume) OVERRIDE;
 
   // Implements VideoMediaProviderInterface.
   virtual bool SetCaptureDevice(uint32 ssrc,
diff --git a/talk/base/asyncpacketsocket.h b/talk/base/asyncpacketsocket.h
index d9e1bff..29ab55f 100644
--- a/talk/base/asyncpacketsocket.h
+++ b/talk/base/asyncpacketsocket.h
@@ -28,7 +28,6 @@
 #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"
@@ -36,29 +35,6 @@
 
 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 497ff20..3bdc97f 100644
--- a/talk/base/fakenetwork.h
+++ b/talk/base/fakenetwork.h
@@ -109,12 +109,10 @@
         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,
-                                          key));
+                                          prefix_length));
       net->AddIP(it->ipaddr());
       networks.push_back(net.release());
     }
diff --git a/talk/base/fakesslidentity.h b/talk/base/fakesslidentity.h
index ee0e0a2..203bb83 100644
--- a/talk/base/fakesslidentity.h
+++ b/talk/base/fakesslidentity.h
@@ -38,12 +38,9 @@
 
 class FakeSSLCertificate : public talk_base::SSLCertificate {
  public:
-  // 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::string& data) : data_(data) {}
   explicit FakeSSLCertificate(const std::vector<std::string>& certs)
-      : data_(certs.front()), digest_algorithm_(DIGEST_SHA_1) {
+      : data_(certs.front()) {
     std::vector<std::string>::const_iterator it;
     // Skip certs[0].
     for (it = certs.begin() + 1; it != certs.end(); ++it) {
@@ -61,11 +58,10 @@
     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 {
-    *algorithm = digest_algorithm_;
+    // SHA-1 is chosen because it is available in all build configurations
+    // used for unit testing.
+    *algorithm = DIGEST_SHA_1;
     return true;
   }
   virtual bool ComputeDigest(const std::string &algorithm,
@@ -90,7 +86,6 @@
   }
   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 95a2e4d..00b04c9 100644
--- a/talk/base/network.cc
+++ b/talk/base/network.cc
@@ -79,7 +79,16 @@
 // Fetch list of networks every two seconds.
 const int kNetworksUpdateIntervalMs = 2000;
 
-const int kHighestNetworkPreference = 127;
+
+// 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();
+}
 
 bool CompareNetworks(const Network* a, const Network* b) {
   if (a->prefix_length() == b->prefix_length()) {
@@ -90,36 +99,9 @@
   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() {
 }
 
@@ -198,29 +180,6 @@
     }
   }
   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()
@@ -281,7 +240,6 @@
         continue;
       }
     }
-
     int prefix_length = CountIPMaskBits(mask);
     prefix = TruncateIP(ip, prefix_length);
     std::string key = MakeNetworkKey(std::string(cursor->ifa_name),
@@ -291,8 +249,7 @@
       scoped_ptr<Network> network(new Network(cursor->ifa_name,
                                               cursor->ifa_name,
                                               prefix,
-                                              prefix_length,
-                                              key));
+                                              prefix_length));
       network->set_scope_id(scope_id);
       network->AddIP(ip);
       bool ignored = ((cursor->ifa_flags & IFF_LOOPBACK) ||
@@ -429,7 +386,6 @@
             continue;
           }
         }
-
         IPAddress prefix;
         int prefix_length = GetPrefix(prefixlist, ip, &prefix);
         std::string key = MakeNetworkKey(name, prefix, prefix_length);
@@ -438,8 +394,7 @@
           scoped_ptr<Network> network(new Network(name,
                                                   description,
                                                   prefix,
-                                                  prefix_length,
-                                                  key));
+                                                  prefix_length));
           network->set_scope_id(scope_id);
           network->AddIP(ip);
           bool ignore = ((adapter_addrs->IfType == IF_TYPE_SOFTWARE_LOOPBACK) ||
@@ -607,20 +562,11 @@
 }
 
 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), type_(ADAPTER_TYPE_UNKNOWN), preference_(0) {
+      exponential_denominator_(0) {
 }
 
 std::string Network::ToString() const {
@@ -654,5 +600,4 @@
   ips_ = ips;
   return changed;
 }
-
 }  // namespace talk_base
diff --git a/talk/base/network.h b/talk/base/network.h
index 75a443b..63f3e73 100644
--- a/talk/base/network.h
+++ b/talk/base/network.h
@@ -45,23 +45,9 @@
 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 {
@@ -182,12 +168,7 @@
 // Represents a Unix-type network interface, with a name and single address.
 class Network {
  public:
-  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() : prefix_(INADDR_ANY), scope_id_(0) {}
   Network(const std::string& name, const std::string& description,
           const IPAddress& prefix, int prefix_length);
 
@@ -203,10 +184,6 @@
   // 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.
@@ -238,32 +215,27 @@
   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 85aa2f8..e11e78d 100644
--- a/talk/base/network_unittest.cc
+++ b/talk/base/network_unittest.cc
@@ -527,33 +527,6 @@
   }
 }
 
-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
deleted file mode 100644
index e2cfd2b..0000000
--- a/talk/base/openssl.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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 9e6fe72..95d5a1a 100644
--- a/talk/base/openssladapter.cc
+++ b/talk/base/openssladapter.cc
@@ -41,6 +41,7 @@
 #include <openssl/err.h>
 #include <openssl/opensslv.h>
 #include <openssl/rand.h>
+#include <openssl/ssl.h>
 #include <openssl/x509v3.h>
 
 #if HAVE_CONFIG_H
@@ -49,7 +50,6 @@
 
 #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,7 +688,11 @@
     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;
 
@@ -699,8 +703,12 @@
       // 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 3d0d227..3d9276d 100644
--- a/talk/base/openssldigest.cc
+++ b/talk/base/openssldigest.cc
@@ -30,7 +30,6 @@
 #include "talk/base/openssldigest.h"
 
 #include "talk/base/common.h"
-#include "talk/base/openssl.h"
 
 namespace talk_base {
 
@@ -79,6 +78,7 @@
     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,6 +87,7 @@
     md = EVP_sha384();
   } else if (algorithm == DIGEST_SHA_512) {
     md = EVP_sha512();
+#endif
   } else {
     return false;
   }
@@ -107,6 +108,7 @@
     *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) {
@@ -115,6 +117,7 @@
     *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 bd361d1..33b02dd 100644
--- a/talk/base/opensslidentity.cc
+++ b/talk/base/opensslidentity.cc
@@ -32,6 +32,7 @@
 // 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>
@@ -42,7 +43,6 @@
 #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,6 +66,15 @@
 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();
@@ -80,6 +89,7 @@
   }
   // 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 cafef92..576b4245 100644
--- a/talk/base/opensslstreamadapter.cc
+++ b/talk/base/opensslstreamadapter.cc
@@ -37,6 +37,7 @@
 #include <openssl/crypto.h>
 #include <openssl/err.h>
 #include <openssl/rand.h>
+#include <openssl/ssl.h>
 #include <openssl/x509v3.h>
 
 #include <vector>
@@ -44,7 +45,6 @@
 #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,6 +53,15 @@
 
 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;
@@ -65,6 +74,7 @@
   {"AES_CM_128_HMAC_SHA1_32", "SRTP_AES128_CM_SHA1_32"},
   {NULL, NULL}
 };
+#endif
 
 //////////////////////////////////////////////////////////////////////
 // StreamBIO
@@ -238,6 +248,7 @@
                                                 bool use_context,
                                                 uint8* result,
                                                 size_t result_len) {
+#ifdef HAVE_DTLS_SRTP
   int i;
 
   i = SSL_export_keying_material(ssl_, result, result_len,
@@ -249,6 +260,9 @@
     return false;
 
   return true;
+#else
+  return false;
+#endif
 }
 
 bool OpenSSLStreamAdapter::SetDtlsSrtpCiphers(
@@ -258,6 +272,7 @@
   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;
@@ -283,9 +298,13 @@
 
   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;
@@ -307,6 +326,9 @@
   ASSERT(false);  // This should never happen
 
   return false;
+#else
+  return false;
+#endif
 }
 
 int OpenSSLStreamAdapter::StartSSLWithServer(const char* server_name) {
@@ -643,12 +665,14 @@
 
     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;
 
@@ -703,7 +727,9 @@
   // 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);
@@ -714,11 +740,19 @@
   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;
@@ -737,12 +771,14 @@
   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;
 }
@@ -816,15 +852,27 @@
 }
 
 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 07a9d4b..d4a4b1a 100644
--- a/talk/base/physicalsocketserver.cc
+++ b/talk/base/physicalsocketserver.cc
@@ -541,8 +541,6 @@
       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 590645f..47f5522 100644
--- a/talk/base/socket.h
+++ b/talk/base/socket.h
@@ -185,10 +185,7 @@
     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_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.
+    OPT_DSCP         // DSCP code
   };
   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 728e321..3a9103f 100644
--- a/talk/base/thread_unittest.cc
+++ b/talk/base/thread_unittest.cc
@@ -339,7 +339,7 @@
   Thread* expected_thread_;
 };
 
-TEST_F(AsyncInvokeTest, DISABLED_FireAndForget) {
+TEST_F(AsyncInvokeTest, FireAndForget) {
   AsyncInvoker invoker;
   // Create and start the thread.
   Thread thread;
@@ -350,7 +350,7 @@
   EXPECT_TRUE_WAIT(called, kWaitTimeout);
 }
 
-TEST_F(AsyncInvokeTest, DISABLED_WithCallback) {
+TEST_F(AsyncInvokeTest, WithCallback) {
   AsyncInvoker invoker;
   // Create and start the thread.
   Thread thread;
@@ -379,7 +379,7 @@
   EXPECT_EQ(0, int_value_);
 }
 
-TEST_F(AsyncInvokeTest, DISABLED_CancelCallingThread) {
+TEST_F(AsyncInvokeTest, CancelCallingThread) {
   AsyncInvoker invoker;
   { // Create and start the thread.
     Thread thread;
@@ -396,7 +396,7 @@
   EXPECT_EQ(0, int_value_);
 }
 
-TEST_F(AsyncInvokeTest, DISABLED_KillInvokerBeforeExecute) {
+TEST_F(AsyncInvokeTest, KillInvokerBeforeExecute) {
   Thread thread;
   thread.Start();
   {
@@ -413,7 +413,7 @@
   EXPECT_EQ(0, int_value_);
 }
 
-TEST_F(AsyncInvokeTest, DISABLED_Flush) {
+TEST_F(AsyncInvokeTest, Flush) {
   AsyncInvoker invoker;
   bool flag1 = false;
   bool flag2 = false;
@@ -431,7 +431,7 @@
   EXPECT_TRUE(flag2);
 }
 
-TEST_F(AsyncInvokeTest, DISABLED_FlushWithIds) {
+TEST_F(AsyncInvokeTest, FlushWithIds) {
   AsyncInvoker invoker;
   bool flag1 = false;
   bool flag2 = false;
diff --git a/talk/libjingle.gyp b/talk/libjingle.gyp
index 73c8a04..0ed5c64 100755
--- a/talk/libjingle.gyp
+++ b/talk/libjingle.gyp
@@ -715,7 +715,6 @@
           'conditions': [
             ['OS!="ios"', {
               'sources': [
-                'base/openssl.h',
                 'base/openssladapter.cc',
                 'base/openssladapter.h',
                 'base/openssldigest.cc',
@@ -1176,8 +1175,6 @@
         'app/webrtc/portallocatorfactory.cc',
         'app/webrtc/portallocatorfactory.h',
         'app/webrtc/proxy.h',
-        'app/webrtc/remoteaudiosource.cc',
-        'app/webrtc/remoteaudiosource.h',
         'app/webrtc/remotevideocapturer.cc',
         'app/webrtc/remotevideocapturer.h',
         'app/webrtc/sctputils.cc',
diff --git a/talk/media/base/videoadapter.cc b/talk/media/base/videoadapter.cc
index 5b53d07..29be805 100644
--- a/talk/media/base/videoadapter.cc
+++ b/talk/media/base/videoadapter.cc
@@ -183,8 +183,7 @@
   output_format_.interval = talk_base::_max(
       output_format_.interval, input_format_.interval);
   if (old_input_interval != input_format_.interval) {
-    LOG(LS_INFO) << "VAdapt input interval changed from "
-      << old_input_interval << " to " << input_format_.interval;
+    LOG(LS_INFO) << "VAdapt Input Interval: " << input_format_.interval;
   }
 }
 
@@ -219,8 +218,7 @@
   output_format_.interval = talk_base::_max(
       output_format_.interval, input_format_.interval);
   if (old_output_interval != output_format_.interval) {
-    LOG(LS_INFO) << "VAdapt output interval changed from "
-      << old_output_interval << " to " << output_format_.interval;
+    LOG(LS_INFO) << "VAdapt Output Interval: " << output_format_.interval;
   }
 }
 
@@ -285,12 +283,16 @@
   }
   if (should_drop) {
     // Show VAdapt log every 90 frames dropped. (3 seconds)
-    if ((frames_in_ - frames_out_) % 90 == 0) {
+    // TODO(fbarchard): Consider GetLogSeverity() to change interval to less
+    // for LS_VERBOSE and more for LS_INFO.
+    bool show = (frames_in_ - frames_out_) % 90 == 0;
+
+    if (show) {
       // TODO(fbarchard): Reduce to LS_VERBOSE when adapter info is not needed
       // in default calls.
-      LOG(LS_INFO) << "VAdapt Drop Frame: scaled " << frames_scaled_
-                   << " / out " << frames_out_
-                   << " / in " << frames_in_
+      LOG(LS_INFO) << "VAdapt Drop Frame: " << frames_scaled_
+                   << " / " << frames_out_
+                   << " / " << frames_in_
                    << " Changes: " << adaption_changes_
                    << " Input: " << in_frame->GetWidth()
                    << "x" << in_frame->GetHeight()
@@ -342,9 +344,9 @@
   if (show) {
     // TODO(fbarchard): Reduce to LS_VERBOSE when adapter info is not needed
     // in default calls.
-    LOG(LS_INFO) << "VAdapt Frame: scaled " << frames_scaled_
-                 << " / out " << frames_out_
-                 << " / in " << frames_in_
+    LOG(LS_INFO) << "VAdapt Frame: " << frames_scaled_
+                 << " / " << frames_out_
+                 << " / " << frames_in_
                  << " Changes: " << adaption_changes_
                  << " Input: " << in_frame->GetWidth()
                  << "x" << in_frame->GetHeight()
diff --git a/talk/media/sctp/sctpdataengine.cc b/talk/media/sctp/sctpdataengine.cc
index aae3d93..59e252a 100644
--- a/talk/media/sctp/sctpdataengine.cc
+++ b/talk/media/sctp/sctpdataengine.cc
@@ -237,10 +237,8 @@
 // Set the initial value of the static SCTP Data Engines reference count.
 int SctpDataEngine::usrsctp_engines_count = 0;
 
-void SctpDataEngine::AddRefEngine() {
-  LOG(LS_VERBOSE) << "usrsctp_engines_count:" << usrsctp_engines_count;
+SctpDataEngine::SctpDataEngine() {
   if (usrsctp_engines_count == 0) {
-    LOG(LS_INFO) << "SctpDataEngine: Initializing usrsctp";
     // First argument is udp_encapsulation_port, which is not releveant for our
     // AF_CONN use of sctp.
     usrsctp_init(0, cricket::OnSctpOutboundPacket, debug_sctp_printf);
@@ -278,25 +276,26 @@
         cricket::kMaxSctpSid);
   }
   usrsctp_engines_count++;
-}
 
-void SctpDataEngine::ReleaseEngine() {
-  usrsctp_engines_count--;
-  if (usrsctp_engines_count == 0) {
-    LOG(LS_INFO) << "SctpDataEngine: Shutting down";
-    if (usrsctp_finish() != 0) {
-      LOG_ERRNO(LS_ERROR) << "SctpDataEngine: usrsctp_finish failed: ";
-    }
-  }
-  LOG(LS_VERBOSE) << "usrsctp_engines_count:" << usrsctp_engines_count;
-}
-
-SctpDataEngine::SctpDataEngine() {
-  AddRefEngine();
+  // We don't put in a codec because we don't want one offered when we
+  // use the hybrid data engine.
+  // codecs_.push_back(cricket::DataCodec( kGoogleSctpDataCodecId,
+  // kGoogleSctpDataCodecName, 0));
 }
 
 SctpDataEngine::~SctpDataEngine() {
-  ReleaseEngine();
+  // TODO(ldixon): There is currently a bug in teardown of usrsctp that blocks
+  // indefintely if a finish call made too soon after close calls. So teardown
+  // has been skipped. Once the bug is fixed, retest and enable teardown.
+  // Tracked in webrtc issue 2749.
+  //
+  // usrsctp_engines_count--;
+  // LOG(LS_VERBOSE) << "usrsctp_engines_count:" << usrsctp_engines_count;
+  // if (usrsctp_engines_count == 0) {
+  //   if (usrsctp_finish() != 0) {
+  //     LOG(LS_WARNING) << "usrsctp_finish.";
+  //   }
+  // }
 }
 
 DataMediaChannel* SctpDataEngine::CreateChannel(
@@ -315,12 +314,10 @@
       sending_(false),
       receiving_(false),
       debug_name_("SctpDataMediaChannel") {
-  SctpDataEngine::AddRefEngine();
 }
 
 SctpDataMediaChannel::~SctpDataMediaChannel() {
   CloseSctpSocket();
-  SctpDataEngine::ReleaseEngine();
 }
 
 sockaddr_conn SctpDataMediaChannel::GetSctpSockAddr(int port) {
diff --git a/talk/media/sctp/sctpdataengine.h b/talk/media/sctp/sctpdataengine.h
index b03a25e..f2322ab 100644
--- a/talk/media/sctp/sctpdataengine.h
+++ b/talk/media/sctp/sctpdataengine.h
@@ -91,12 +91,6 @@
 
   virtual const std::vector<DataCodec>& data_codecs() { return codecs_; }
 
-  // Manages the lifetime of the usrsctp library data.  Each SctpDataEngine
-  // and SctpDataMediaChannel AddRefEngine the library at construction, and
-  // ReleaseEngine at shutdown.
-  static void AddRefEngine();
-  static void ReleaseEngine();
-
  private:
   static int usrsctp_engines_count;
   std::vector<DataCodec> codecs_;
diff --git a/talk/media/webrtc/webrtcvideoengine.cc b/talk/media/webrtc/webrtcvideoengine.cc
index ce5be90..d2e73ea 100644
--- a/talk/media/webrtc/webrtcvideoengine.cc
+++ b/talk/media/webrtc/webrtcvideoengine.cc
@@ -2632,15 +2632,6 @@
       return false;
     }
   }
-
-  if (send_time_extension) {
-    // For video RTP packets, we would like to update AbsoluteSendTimeHeader
-    // Extension closer to the network, @ socket level before sending.
-    // Pushing the extension id to socket layer.
-    MediaChannel::SetOption(NetworkInterface::ST_RTP,
-                            talk_base::Socket::OPT_RTP_SENDTIME_EXTN_ID,
-                            send_time_extension->id);
-  }
   return true;
 }
 
diff --git a/talk/p2p/base/candidate.h b/talk/p2p/base/candidate.h
index 0fa9f0e..19eed8c 100644
--- a/talk/p2p/base/candidate.h
+++ b/talk/p2p/base/candidate.h
@@ -33,7 +33,6 @@
 #include <string>
 #include <sstream>
 #include <iomanip>
-
 #include "talk/base/basictypes.h"
 #include "talk/base/socketaddress.h"
 #include "talk/p2p/base/constants.h"
@@ -164,30 +163,13 @@
     return ToStringInternal(true);
   }
 
-  uint32 GetPriority(uint32 type_preference,
-                     int network_adapter_preference) const {
+  uint32 GetPriority(uint32 type_preference) const {
     // RFC 5245 - 4.1.2.1.
     // priority = (2^24)*(type preference) +
     //            (2^8)*(local preference) +
     //            (2^0)*(256 - component ID)
-
-    // |local_preference| length is 2 bytes, 0-65535 inclusive.
-    // In our implemenation we will partion local_preference into
-    //              0                 1
-    //       0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
-    //      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-    //      |  NIC Pref     |    Addr Pref  |
-    //      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-    // NIC Type - Type of the network adapter e.g. 3G/Wifi/Wired.
-    // Addr Pref - Address preference value as per RFC 3484.
-    // local preference is calculated as - NIC Type << 8 | Addr_Pref.
-
     int addr_pref = IPAddressPrecedence(address_.ipaddr());
-    int local_preference = (network_adapter_preference << 8) | addr_pref;
-
-    return (type_preference << 24) |
-           (local_preference << 8) |
-           (256 - component_);
+    return (type_preference << 24) | (addr_pref << 8) | (256 - component_);
   }
 
  private:
@@ -195,9 +177,9 @@
     std::ostringstream ost;
     std::string address = sensitive ? address_.ToSensitiveString() :
                                       address_.ToString();
-    ost << "Cand[" << foundation_ << ":" << component_ << ":"
-        << protocol_ << ":" << priority_ << ":"
-        << address << ":" << type_ << ":" << related_address_ << ":"
+    ost << "Cand[" << id_ << ":" << component_ << ":"
+        << type_ << ":" << protocol_ << ":"
+        << network_name_ << ":" << address << ":"
         << username_ << ":" << password_ << "]";
     return ost.str();
   }
diff --git a/talk/p2p/base/p2ptransportchannel.cc b/talk/p2p/base/p2ptransportchannel.cc
index 1f53874..104b5e6 100644
--- a/talk/p2p/base/p2ptransportchannel.cc
+++ b/talk/p2p/base/p2ptransportchannel.cc
@@ -493,8 +493,7 @@
         port->Network()->name(), 0U,
         talk_base::ToString<uint32>(talk_base::ComputeCrc32(id)));
     new_remote_candidate.set_priority(
-        new_remote_candidate.GetPriority(ICE_TYPE_PREFERENCE_SRFLX,
-                                         port->Network()->preference()));
+        new_remote_candidate.GetPriority(ICE_TYPE_PREFERENCE_SRFLX));
   }
 
   if (port->IceProtocol() == ICEPROTO_RFC5245) {
diff --git a/talk/p2p/base/p2ptransportchannel_unittest.cc b/talk/p2p/base/p2ptransportchannel_unittest.cc
index 53a39c2..7fff3da 100644
--- a/talk/p2p/base/p2ptransportchannel_unittest.cc
+++ b/talk/p2p/base/p2ptransportchannel_unittest.cc
@@ -1559,11 +1559,8 @@
 // Test that we can quickly switch links if an interface goes down.
 TEST_F(P2PTransportChannelMultihomedTest, TestFailover) {
   AddAddress(0, kPublicAddrs[0]);
-  // Adding alternate address will make sure |kPublicAddrs| has the higher
-  // priority than others. This is due to FakeNetwork::AddInterface method.
-  AddAddress(1, kAlternateAddrs[1]);
   AddAddress(1, kPublicAddrs[1]);
-
+  AddAddress(1, kAlternateAddrs[1]);
   // Use only local ports for simplicity.
   SetAllocatorFlags(0, kOnlyLocalPorts);
   SetAllocatorFlags(1, kOnlyLocalPorts);
diff --git a/talk/p2p/base/port.cc b/talk/p2p/base/port.cc
index 38031cb..b6421ad 100644
--- a/talk/p2p/base/port.cc
+++ b/talk/p2p/base/port.cc
@@ -258,7 +258,7 @@
   c.set_type(type);
   c.set_protocol(protocol);
   c.set_address(address);
-  c.set_priority(c.GetPriority(type_preference, network_->preference()));
+  c.set_priority(c.GetPriority(type_preference));
   c.set_username(username_fragment());
   c.set_password(password_);
   c.set_network_name(network_->name());
diff --git a/talk/p2p/client/portallocator_unittest.cc b/talk/p2p/client/portallocator_unittest.cc
index 0ea8fb5..1417707 100644
--- a/talk/p2p/client/portallocator_unittest.cc
+++ b/talk/p2p/client/portallocator_unittest.cc
@@ -53,8 +53,8 @@
 static const SocketAddress kClientAddr("11.11.11.11", 0);
 static const SocketAddress kClientIPv6Addr(
     "2401:fa00:4:1000:be30:5bff:fee5:c3", 0);
-static const SocketAddress kClientAddr2("22.22.22.22", 0);
 static const SocketAddress kNatAddr("77.77.77.77", talk_base::NAT_SERVER_PORT);
+static const SocketAddress kRemoteClientAddr("22.22.22.22", 0);
 static const SocketAddress kStunAddr("99.99.99.1", cricket::STUN_SERVER_PORT);
 static const SocketAddress kRelayUdpIntAddr("99.99.99.2", 5000);
 static const SocketAddress kRelayUdpExtAddr("99.99.99.3", 5001);
@@ -492,23 +492,6 @@
   EXPECT_TRUE_WAIT(candidate_allocation_done_, 9000);
 }
 
-TEST_F(PortAllocatorTest, TestCandidatePriorityOfMultipleInterfaces) {
-  AddInterface(kClientAddr);
-  AddInterface(kClientAddr2);
-  // Allocating only host UDP ports. This is done purely for testing
-  // convenience.
-  allocator().set_flags(cricket::PORTALLOCATOR_DISABLE_TCP |
-                        cricket::PORTALLOCATOR_DISABLE_STUN |
-                        cricket::PORTALLOCATOR_DISABLE_RELAY);
-  EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP));
-  session_->StartGettingPorts();
-  EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout);
-  ASSERT_EQ(2U, candidates_.size());
-  EXPECT_EQ(2U, ports_.size());
-  // Candidates priorities should be different.
-  EXPECT_NE(candidates_[0].priority(), candidates_[1].priority());
-}
-
 // Test to verify ICE restart process.
 TEST_F(PortAllocatorTest, TestGetAllPortsRestarts) {
   AddInterface(kClientAddr);