Update libjingle to 57692857

R=wu@webrtc.org

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

git-svn-id: http://webrtc.googlecode.com/svn/trunk@5217 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/talk/media/webrtc/webrtcvoiceengine.cc b/talk/media/webrtc/webrtcvoiceengine.cc
index 4911c59..1b77671 100644
--- a/talk/media/webrtc/webrtcvoiceengine.cc
+++ b/talk/media/webrtc/webrtcvoiceengine.cc
@@ -230,6 +230,7 @@
   options.experimental_agc.Set(false);
   options.experimental_aec.Set(false);
   options.aec_dump.Set(false);
+  options.experimental_acm.Set(false);
   return options;
 }
 
@@ -260,7 +261,7 @@
     if (!engine_->voe_sc()) {
       return false;
     }
-    webrtc_channel_ = engine_->voe_sc()->base()->CreateChannel();
+    webrtc_channel_ = engine_->CreateSoundclipVoiceChannel();
     if (webrtc_channel_ == -1) {
       LOG_RTCERR0(CreateChannel);
       return false;
@@ -333,6 +334,7 @@
       log_filter_(SeverityToFilter(kDefaultLogSeverity)),
       is_dumping_aec_(false),
       desired_local_monitor_enable_(false),
+      use_experimental_acm_(false),
       tx_processor_ssrc_(0),
       rx_processor_ssrc_(0) {
   Construct();
@@ -350,6 +352,7 @@
       log_filter_(SeverityToFilter(kDefaultLogSeverity)),
       is_dumping_aec_(false),
       desired_local_monitor_enable_(false),
+      use_experimental_acm_(false),
       tx_processor_ssrc_(0),
       rx_processor_ssrc_(0) {
   Construct();
@@ -377,6 +380,10 @@
       RtpHeaderExtension(kRtpAudioLevelHeaderExtension,
                          kRtpAudioLevelHeaderExtensionId));
   options_ = GetDefaultEngineOptions();
+
+  // Initialize the VoE Configuration to the default ACM.
+  voe_config_.Set<webrtc::AudioCodingModuleFactory>(
+      new webrtc::AudioCodingModuleFactory);
 }
 
 static bool IsOpus(const AudioCodec& codec) {
@@ -714,6 +721,12 @@
 
   LOG(LS_INFO) << "Applying audio options: " << options.ToString();
 
+  // Configure whether ACM1 or ACM2 is used.
+  bool enable_acm2 = false;
+  if (options.experimental_acm.Get(&enable_acm2)) {
+    EnableExperimentalAcm(enable_acm2);
+  }
+
   webrtc::VoEAudioProcessing* voep = voe_wrapper_->processing();
 
   bool echo_cancellation;
@@ -940,7 +953,7 @@
   }
   if (ret) {
     if (voe_wrapper_->hw()->SetRecordingDevice(in_id) == -1) {
-      LOG_RTCERR2(SetRecordingDevice, in_device->name, in_id);
+      LOG_RTCERR2(SetRecordingDevice, in_name, in_id);
       ret = false;
     }
   }
@@ -952,7 +965,7 @@
   }
   if (ret) {
     if (voe_wrapper_->hw()->SetPlayoutDevice(out_id) == -1) {
-      LOG_RTCERR2(SetPlayoutDevice, out_device->name, out_id);
+      LOG_RTCERR2(SetPlayoutDevice, out_name, out_id);
       ret = false;
     }
   }
@@ -1248,6 +1261,21 @@
   return false;
 }
 
+void WebRtcVoiceEngine::EnableExperimentalAcm(bool enable) {
+  if (enable == use_experimental_acm_)
+    return;
+  if (enable) {
+    LOG(LS_INFO) << "VoiceEngine is set to use new ACM (ACM2 + NetEq4).";
+    voe_config_.Set<webrtc::AudioCodingModuleFactory>(
+        new webrtc::NewAudioCodingModuleFactory());
+  } else {
+    LOG(LS_INFO) << "VoiceEngine is set to use legacy ACM (ACM1 + Neteq3).";
+    voe_config_.Set<webrtc::AudioCodingModuleFactory>(
+        new webrtc::AudioCodingModuleFactory());
+  }
+  use_experimental_acm_ = enable;
+}
+
 void WebRtcVoiceEngine::Print(webrtc::TraceLevel level, const char* trace,
                               int length) {
   talk_base::LoggingSeverity sev = talk_base::LS_VERBOSE;
@@ -1580,6 +1608,22 @@
   }
 }
 
+int WebRtcVoiceEngine::CreateVoiceChannel(VoEWrapper* voice_engine_wrapper) {
+#ifdef USE_WEBRTC_DEV_BRANCH
+  return voice_engine_wrapper->base()->CreateChannel(voe_config_);
+#else
+  return voice_engine_wrapper->base()->CreateChannel();
+#endif
+}
+
+int WebRtcVoiceEngine::CreateMediaVoiceChannel() {
+  return CreateVoiceChannel(voe_wrapper_.get());
+}
+
+int WebRtcVoiceEngine::CreateSoundclipVoiceChannel() {
+  return CreateVoiceChannel(voe_wrapper_sc_.get());
+}
+
 // This struct relies on the generated copy constructor and assignment operator
 // since it is used in an stl::map.
 struct WebRtcVoiceMediaChannel::WebRtcVoiceChannelInfo {
@@ -1597,7 +1641,7 @@
 WebRtcVoiceMediaChannel::WebRtcVoiceMediaChannel(WebRtcVoiceEngine *engine)
     : WebRtcMediaChannel<VoiceMediaChannel, WebRtcVoiceEngine>(
           engine,
-          engine->voe()->base()->CreateChannel()),
+          engine->CreateMediaVoiceChannel()),
       send_bw_setting_(false),
       send_autobw_(false),
       send_bw_bps_(0),
@@ -2231,7 +2275,7 @@
     channel = voe_channel();
   } else {
     // Create a new channel for sending audio data.
-    channel = engine()->voe()->base()->CreateChannel();
+    channel = engine()->CreateMediaVoiceChannel();
     if (channel == -1) {
       LOG_RTCERR0(CreateChannel);
       return false;
@@ -2346,7 +2390,7 @@
   }
 
   // Create a new channel for receiving audio data.
-  int channel = engine()->voe()->base()->CreateChannel();
+  int channel = engine()->CreateMediaVoiceChannel();
   if (channel == -1) {
     LOG_RTCERR0(CreateChannel);
     return false;
@@ -2966,7 +3010,7 @@
       continue;
     }
 
-    sinfo.ssrc = ssrc;
+    sinfo.add_ssrc(ssrc);
     sinfo.codec_name = send_codec_.get() ? send_codec_->plname : "";
     sinfo.bytes_sent = cs.bytesSent;
     sinfo.packets_sent = cs.packetsSent;
@@ -2988,7 +3032,7 @@
       for (iter = receive_blocks.begin(); iter != receive_blocks.end();
            ++iter) {
         // Lookup report for send ssrc only.
-        if (iter->source_SSRC == sinfo.ssrc) {
+        if (iter->source_SSRC == sinfo.ssrc()) {
           // Convert Q8 to floating point.
           sinfo.fraction_lost = static_cast<float>(iter->fraction_lost) / 256;
           // Convert samples to milliseconds.
@@ -3041,7 +3085,7 @@
         engine()->voe()->rtp()->GetRTCPStatistics(*it, cs) != -1 &&
         engine()->voe()->codec()->GetRecCodec(*it, codec) != -1) {
       VoiceReceiverInfo rinfo;
-      rinfo.ssrc = ssrc;
+      rinfo.add_ssrc(ssrc);
       rinfo.bytes_rcvd = cs.bytesReceived;
       rinfo.packets_rcvd = cs.packetsReceived;
       // The next four fields are from the most recently sent RTCP report.