Fix broken AEC dump in Chrome M33.

Reverts P4 CL 58093675.

R=tommi@webrtc.org
TBR=wu@webrtc.org

BUG= https://code.google.com/p/chromium/issues/detail?id=336171

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

git-svn-id: http://webrtc.googlecode.com/svn/branches/3.48/talk@5412 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/app/webrtc/localaudiosource.cc b/app/webrtc/localaudiosource.cc
index 3dc5c6c..2cd472a 100644
--- a/app/webrtc/localaudiosource.cc
+++ b/app/webrtc/localaudiosource.cc
@@ -54,6 +54,8 @@
 const char MediaConstraintsInterface::kTypingNoiseDetection[] =
     "googTypingNoiseDetection";
 const char MediaConstraintsInterface::kAudioMirroring[] = "googAudioMirroring";
+// TODO(perkj): Remove kInternalAecDump once its not used by Chrome.
+const char MediaConstraintsInterface::kInternalAecDump[] = "deprecatedAecDump";
 
 namespace {
 
@@ -127,6 +129,8 @@
     return;
   }
   options_.SetAll(audio_options);
+  if (options.enable_aec_dump)
+    options_.aec_dump.Set(true);
   source_state_ = kLive;
 }
 
diff --git a/app/webrtc/mediaconstraintsinterface.h b/app/webrtc/mediaconstraintsinterface.h
index 5cf2184..ba6b09b 100644
--- a/app/webrtc/mediaconstraintsinterface.h
+++ b/app/webrtc/mediaconstraintsinterface.h
@@ -117,6 +117,13 @@
   // stripped by Chrome before passed down to Libjingle.
   static const char kInternalConstraintPrefix[];
 
+  // These constraints are for internal use only, representing Chrome command
+  // line flags. So they are prefixed with "internal" so JS values will be
+  // removed.
+  // Used by a local audio source.
+  // TODO(perkj): Remove once Chrome use PeerConnectionFactory::SetOptions.
+  static const char kInternalAecDump[];  // internalAecDump
+
  protected:
   // Dtor protected as objects shouldn't be deleted via this interface
   virtual ~MediaConstraintsInterface() {}
diff --git a/app/webrtc/peerconnectionfactory.cc b/app/webrtc/peerconnectionfactory.cc
index ee15b5d..e8b8f63 100644
--- a/app/webrtc/peerconnectionfactory.cc
+++ b/app/webrtc/peerconnectionfactory.cc
@@ -105,21 +105,12 @@
   scoped_refptr<webrtc::VideoSourceInterface> source;
 };
 
-struct StartAecDumpParams : public talk_base::MessageData {
-  explicit StartAecDumpParams(FILE* aec_dump_file)
-      : aec_dump_file(aec_dump_file) {
-  }
-  FILE* aec_dump_file;
-  bool result;
-};
-
 enum {
   MSG_INIT_FACTORY = 1,
   MSG_TERMINATE_FACTORY,
   MSG_CREATE_PEERCONNECTION,
   MSG_CREATE_AUDIOSOURCE,
   MSG_CREATE_VIDEOSOURCE,
-  MSG_START_AEC_DUMP,
 };
 
 }  // namespace
@@ -232,12 +223,6 @@
       pdata->source = CreateVideoSource_s(pdata->capturer, pdata->constraints);
       break;
     }
-    case MSG_START_AEC_DUMP: {
-      StartAecDumpParams* pdata =
-          static_cast<StartAecDumpParams*>(msg->pdata);
-      pdata->result = StartAecDump_s(pdata->aec_dump_file);
-      break;
-    }
   }
 }
 
@@ -289,10 +274,6 @@
   return VideoSourceProxy::Create(signaling_thread_, source);
 }
 
-bool PeerConnectionFactory::StartAecDump_s(FILE* file) {
-  return channel_manager_->StartAecDump(file);
-}
-
 scoped_refptr<PeerConnectionInterface>
 PeerConnectionFactory::CreatePeerConnection(
     const PeerConnectionInterface::IceServers& configuration,
@@ -380,12 +361,6 @@
   return AudioTrackProxy::Create(signaling_thread_, track);
 }
 
-bool PeerConnectionFactory::StartAecDump(FILE* file) {
-  StartAecDumpParams params(file);
-  signaling_thread_->Send(this, MSG_START_AEC_DUMP, &params);
-  return params.result;
-}
-
 cricket::ChannelManager* PeerConnectionFactory::channel_manager() {
   return channel_manager_.get();
 }
diff --git a/app/webrtc/peerconnectionfactory.h b/app/webrtc/peerconnectionfactory.h
index 63d37f0..dff885d 100644
--- a/app/webrtc/peerconnectionfactory.h
+++ b/app/webrtc/peerconnectionfactory.h
@@ -78,8 +78,6 @@
       CreateAudioTrack(const std::string& id,
                        AudioSourceInterface* audio_source);
 
-  virtual bool StartAecDump(FILE* file);
-
   virtual cricket::ChannelManager* channel_manager();
   virtual talk_base::Thread* signaling_thread();
   virtual talk_base::Thread* worker_thread();
@@ -95,6 +93,7 @@
       cricket::WebRtcVideoDecoderFactory* video_decoder_factory);
   virtual ~PeerConnectionFactory();
 
+
  private:
   bool Initialize_s();
   void Terminate_s();
@@ -109,8 +108,6 @@
       PortAllocatorFactoryInterface* allocator_factory,
       DTLSIdentityServiceInterface* dtls_identity_service,
       PeerConnectionObserver* observer);
-  bool StartAecDump_s(FILE* file);
-
   // Implements talk_base::MessageHandler.
   void OnMessage(talk_base::Message* msg);
 
diff --git a/app/webrtc/peerconnectioninterface.h b/app/webrtc/peerconnectioninterface.h
index 01f1e1c..a127dad 100644
--- a/app/webrtc/peerconnectioninterface.h
+++ b/app/webrtc/peerconnectioninterface.h
@@ -393,9 +393,11 @@
   class Options {
    public:
     Options() :
+      enable_aec_dump(false),
       disable_encryption(false),
       disable_sctp_data_channels(false) {
     }
+    bool enable_aec_dump;
     bool disable_encryption;
     bool disable_sctp_data_channels;
   };
@@ -440,12 +442,6 @@
       CreateAudioTrack(const std::string& label,
                        AudioSourceInterface* source) = 0;
 
-  // Starts AEC dump using existing file. Takes ownership of |file| and passes
-  // it on to VoiceEngine (via other objects) immediately, which will take
-  // the ownerhip.
-  // TODO(grunell): Remove when Chromium has started to use AEC in each source.
-  virtual bool StartAecDump(FILE* file) = 0;
-
  protected:
   // Dtor and ctor protected as objects shouldn't be created or deleted via
   // this interface.
diff --git a/media/base/fakemediaengine.h b/media/base/fakemediaengine.h
index d71c660..1a4e8ab 100644
--- a/media/base/fakemediaengine.h
+++ b/media/base/fakemediaengine.h
@@ -778,8 +778,6 @@
 
   bool SetLocalMonitor(bool enable) { return true; }
 
-  bool StartAecDump(FILE* file) { return false; }
-
   bool RegisterProcessor(uint32 ssrc, VoiceProcessor* voice_processor,
                          MediaProcessorDirection direction) {
     if (direction == MPD_RX) {
diff --git a/media/base/filemediaengine.h b/media/base/filemediaengine.h
index 843806b..dfdb037 100644
--- a/media/base/filemediaengine.h
+++ b/media/base/filemediaengine.h
@@ -133,7 +133,6 @@
   virtual bool FindVideoCodec(const VideoCodec& codec) { return true; }
   virtual void SetVoiceLogging(int min_sev, const char* filter) {}
   virtual void SetVideoLogging(int min_sev, const char* filter) {}
-  virtual bool StartAecDump(FILE* file) { return false; }
 
   virtual bool RegisterVideoProcessor(VideoProcessor* processor) {
     return true;
diff --git a/media/base/mediaengine.h b/media/base/mediaengine.h
index c04df9f..f916572 100644
--- a/media/base/mediaengine.h
+++ b/media/base/mediaengine.h
@@ -135,9 +135,6 @@
   virtual void SetVoiceLogging(int min_sev, const char* filter) = 0;
   virtual void SetVideoLogging(int min_sev, const char* filter) = 0;
 
-  // Starts AEC dump using existing file.
-  virtual bool StartAecDump(FILE* file) = 0;
-
   // Voice processors for effects.
   virtual bool RegisterVoiceProcessor(uint32 ssrc,
                                       VoiceProcessor* video_processor,
@@ -256,10 +253,6 @@
     video_.SetLogging(min_sev, filter);
   }
 
-  virtual bool StartAecDump(FILE* file) {
-    return voice_.StartAecDump(file);
-  }
-
   virtual bool RegisterVoiceProcessor(uint32 ssrc,
                                       VoiceProcessor* processor,
                                       MediaProcessorDirection direction) {
diff --git a/media/webrtc/webrtcvoiceengine.cc b/media/webrtc/webrtcvoiceengine.cc
index 2aa6b8c..51da9ac 100644
--- a/media/webrtc/webrtcvoiceengine.cc
+++ b/media/webrtc/webrtcvoiceengine.cc
@@ -1433,22 +1433,6 @@
   return true;
 }
 
-bool WebRtcVoiceEngine::StartAecDump(FILE* file) {
-#ifdef USE_WEBRTC_DEV_BRANCH
-  StopAecDump();
-  if (voe_wrapper_->processing()->StartDebugRecording(file) !=
-      webrtc::AudioProcessing::kNoError) {
-    LOG_RTCERR1(StartDebugRecording, "FILE*");
-    fclose(file);
-    return false;
-  }
-  is_dumping_aec_ = true;
-  return true;
-#else
-  return false;
-#endif
-}
-
 bool WebRtcVoiceEngine::RegisterProcessor(
     uint32 ssrc,
     VoiceProcessor* voice_processor,
@@ -1606,7 +1590,7 @@
     // Start dumping AEC when we are not dumping.
     if (voe_wrapper_->processing()->StartDebugRecording(
         filename.c_str()) != webrtc::AudioProcessing::kNoError) {
-      LOG_RTCERR1(StartDebugRecording, filename.c_str());
+      LOG_RTCERR0(StartDebugRecording);
     } else {
       is_dumping_aec_ = true;
     }
diff --git a/media/webrtc/webrtcvoiceengine.h b/media/webrtc/webrtcvoiceengine.h
index adf4853..23d97f5 100644
--- a/media/webrtc/webrtcvoiceengine.h
+++ b/media/webrtc/webrtcvoiceengine.h
@@ -174,9 +174,6 @@
   bool SetAudioDeviceModule(webrtc::AudioDeviceModule* adm,
                             webrtc::AudioDeviceModule* adm_sc);
 
-  // Starts AEC dump using existing file.
-  bool StartAecDump(FILE* file);
-
   // Check whether the supplied trace should be ignored.
   bool ShouldIgnoreTrace(const std::string& trace);
 
diff --git a/session/media/channelmanager.cc b/session/media/channelmanager.cc
index 4d5d8fc..d4fcc79 100644
--- a/session/media/channelmanager.cc
+++ b/session/media/channelmanager.cc
@@ -947,9 +947,4 @@
   return true;
 }
 
-bool ChannelManager::StartAecDump(FILE* file) {
-  return worker_thread_->Invoke<bool>(
-      Bind(&MediaEngineInterface::StartAecDump, media_engine_.get(), file));
-}
-
 }  // namespace cricket
diff --git a/session/media/channelmanager.h b/session/media/channelmanager.h
index f19d3d0..fdb8f73 100644
--- a/session/media/channelmanager.h
+++ b/session/media/channelmanager.h
@@ -214,9 +214,6 @@
   void SetVideoCaptureDeviceMaxFormat(const std::string& usb_id,
                                       const VideoFormat& max_format);
 
-  // Starts AEC dump using existing file.
-  bool StartAecDump(FILE* file);
-
   sigslot::repeater0<> SignalDevicesChange;
   sigslot::signal2<VideoCapturer*, CaptureState> SignalVideoCaptureStateChange;