| Index: content/renderer/media/webrtc/peer_connection_dependency_factory.cc
|
| diff --git a/content/renderer/media/webrtc/peer_connection_dependency_factory.cc b/content/renderer/media/webrtc/peer_connection_dependency_factory.cc
|
| index a9652e797cc2303c4b9aa4702d17d951960f9dcd..f0c7d49b5bc1c12f24a93664f5ec3113ba3c8c6c 100644
|
| --- a/content/renderer/media/webrtc/peer_connection_dependency_factory.cc
|
| +++ b/content/renderer/media/webrtc/peer_connection_dependency_factory.cc
|
| @@ -168,10 +168,17 @@ PeerConnectionDependencyFactory::PeerConnectionDependencyFactory(
|
| signaling_thread_(NULL),
|
| worker_thread_(NULL),
|
| chrome_worker_thread_("Chrome_libJingle_WorkerThread") {
|
| + if (!MediaStreamAudioProcessor::IsAudioTrackProcessingEnabled()) {
|
| + aec_dump_message_filter_ = AecDumpMessageFilter::Get();
|
| + DCHECK(aec_dump_message_filter_);
|
| + aec_dump_message_filter_->SetObserver(this);
|
| + }
|
| }
|
|
|
| PeerConnectionDependencyFactory::~PeerConnectionDependencyFactory() {
|
| CleanupPeerConnectionFactory();
|
| + if (aec_dump_message_filter_)
|
| + aec_dump_message_filter_->SetObserver(NULL);
|
| }
|
|
|
| blink::WebRTCPeerConnectionHandler*
|
| @@ -347,9 +354,19 @@ void PeerConnectionDependencyFactory::CreatePeerConnectionFactory() {
|
| cmd_line->HasSwitch(switches::kDisableWebRtcEncryption);
|
| pc_factory_->SetOptions(factory_options);
|
|
|
| - // |aec_dump_file| will be invalid when dump is not enabled.
|
| - if (aec_dump_file_.IsValid())
|
| - StartAecDump(aec_dump_file_.Pass());
|
| + // TODO(xians): Remove the following code after kDisableAudioTrackProcessing
|
| + // is removed.
|
| + if (!MediaStreamAudioProcessor::IsAudioTrackProcessingEnabled() &&
|
| + aec_dump_message_filter_) {
|
| + // There's only one AEC dump if not using track processing, we use ID 0.
|
| + // PCDF lives as long as the renderer lives, so we don't need to unregister.
|
| + aec_dump_message_filter_->io_message_loop()->PostTask(
|
| + FROM_HERE,
|
| + base::Bind(
|
| + &AecDumpMessageFilter::RegisterAecDumpConsumer,
|
| + aec_dump_message_filter_,
|
| + 0));
|
| + }
|
| }
|
|
|
| bool PeerConnectionDependencyFactory::PeerConnectionFactoryCreated() {
|
| @@ -612,56 +629,32 @@ PeerConnectionDependencyFactory::GetWebRtcWorkerThread() const {
|
| return chrome_worker_thread_.message_loop_proxy();
|
| }
|
|
|
| -bool PeerConnectionDependencyFactory::OnControlMessageReceived(
|
| - const IPC::Message& message) {
|
| - bool handled = true;
|
| - IPC_BEGIN_MESSAGE_MAP(PeerConnectionDependencyFactory, message)
|
| - IPC_MESSAGE_HANDLER(MediaStreamMsg_EnableAecDump, OnAecDumpFile)
|
| - IPC_MESSAGE_HANDLER(MediaStreamMsg_DisableAecDump, OnDisableAecDump)
|
| - IPC_MESSAGE_UNHANDLED(handled = false)
|
| - IPC_END_MESSAGE_MAP()
|
| - return handled;
|
| -}
|
| -
|
| void PeerConnectionDependencyFactory::OnAecDumpFile(
|
| - IPC::PlatformFileForTransit file_handle) {
|
| - DCHECK(!aec_dump_file_.IsValid());
|
| + int id,
|
| + const IPC::PlatformFileForTransit& file_handle) {
|
| + DCHECK(CalledOnValidThread());
|
| + DCHECK(!MediaStreamAudioProcessor::IsAudioTrackProcessingEnabled());
|
| + DCHECK(PeerConnectionFactoryCreated());
|
| + DCHECK(id == 0) << id;
|
| +
|
| base::File file = IPC::PlatformFileForTransitToFile(file_handle);
|
| DCHECK(file.IsValid());
|
|
|
| - if (MediaStreamAudioProcessor::IsAudioTrackProcessingEnabled()) {
|
| - EnsureWebRtcAudioDeviceImpl();
|
| - GetWebRtcAudioDevice()->EnableAecDump(file.Pass());
|
| - return;
|
| - }
|
| -
|
| - // TODO(xians): Remove the following code after kDisableAudioTrackProcessing
|
| - // is removed.
|
| - if (PeerConnectionFactoryCreated())
|
| - StartAecDump(file.Pass());
|
| - else
|
| - aec_dump_file_ = file.Pass();
|
| + // |pc_factory_| always takes ownership of |aec_dump_file|. If StartAecDump()
|
| + // fails, |aec_dump_file| will be closed.
|
| + if (!GetPcFactory()->StartAecDump(file.TakePlatformFile()))
|
| + VLOG(1) << "Could not start AEC dump.";
|
| }
|
|
|
| void PeerConnectionDependencyFactory::OnDisableAecDump() {
|
| - if (MediaStreamAudioProcessor::IsAudioTrackProcessingEnabled()) {
|
| - // Do nothing if OnAecDumpFile() has never been called.
|
| - if (GetWebRtcAudioDevice())
|
| - GetWebRtcAudioDevice()->DisableAecDump();
|
| - return;
|
| - }
|
| -
|
| - // TODO(xians): Remove the following code after kDisableAudioTrackProcessing
|
| - // is removed.
|
| - if (aec_dump_file_.IsValid())
|
| - aec_dump_file_.Close();
|
| + DCHECK(CalledOnValidThread());
|
| + DCHECK(!MediaStreamAudioProcessor::IsAudioTrackProcessingEnabled());
|
| + // Do nothing. We never disable AEC dump for non-track-processing case.
|
| }
|
|
|
| -void PeerConnectionDependencyFactory::StartAecDump(base::File aec_dump_file) {
|
| - // |pc_factory_| always takes ownership of |aec_dump_file|. If StartAecDump()
|
| - // fails, |aec_dump_file| will be closed.
|
| - if (!GetPcFactory()->StartAecDump(aec_dump_file.TakePlatformFile()))
|
| - VLOG(1) << "Could not start AEC dump.";
|
| +void PeerConnectionDependencyFactory::OnIpcClosed() {
|
| + DCHECK(CalledOnValidThread());
|
| + aec_dump_message_filter_ = NULL;
|
| }
|
|
|
| void PeerConnectionDependencyFactory::EnsureWebRtcAudioDeviceImpl() {
|
|
|