From 2c599d663d45dd760aac8f0b37c1d65d52c19698 Mon Sep 17 00:00:00 2001 From: Tommi Date: Thu, 15 Feb 2018 11:08:36 +0100 Subject: [PATCH] Allow native aec to be used in peerconnection_client if available on windows. Change-Id: Ia0e2e8b5f755602e58c6be75b7ff57ab1e0528fb Bug: webrtc:8891 Reviewed-on: https://webrtc-review.googlesource.com/53740 Commit-Queue: Tommi Reviewed-by: Oskar Sundbom Cr-Commit-Position: refs/heads/master@{#22032} --- examples/peerconnection/client/conductor.cc | 22 +++++++++++++------ .../audio_device/win/audio_device_core_win.cc | 4 ++++ .../audio_device/win/audio_device_core_win.h | 2 ++ 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/examples/peerconnection/client/conductor.cc b/examples/peerconnection/client/conductor.cc index f15e221d4f..214ccfabec 100644 --- a/examples/peerconnection/client/conductor.cc +++ b/examples/peerconnection/client/conductor.cc @@ -415,18 +415,26 @@ void Conductor::AddStreams() { peer_connection_factory_->CreateAudioTrack( kAudioLabel, peer_connection_factory_->CreateAudioSource(NULL))); - rtc::scoped_refptr video_track( - peer_connection_factory_->CreateVideoTrack( - kVideoLabel, - peer_connection_factory_->CreateVideoSource(OpenVideoCaptureDevice(), - NULL))); - main_wnd_->StartLocalRenderer(video_track); + rtc::scoped_refptr video_track; + auto video_device(OpenVideoCaptureDevice()); + if (video_device) { + video_track = + peer_connection_factory_->CreateVideoTrack( + kVideoLabel, + peer_connection_factory_->CreateVideoSource(std::move(video_device), + NULL)); + main_wnd_->StartLocalRenderer(video_track); + } else { + RTC_LOG(LS_ERROR) << "OpenVideoCaptureDevice failed"; + } rtc::scoped_refptr stream = peer_connection_factory_->CreateLocalMediaStream(kStreamLabel); stream->AddTrack(audio_track); - stream->AddTrack(video_track); + if (video_track) + stream->AddTrack(video_track); + if (!peer_connection_->AddStream(stream)) { RTC_LOG(LS_ERROR) << "Adding stream to PeerConnection failed"; } diff --git a/modules/audio_device/win/audio_device_core_win.cc b/modules/audio_device/win/audio_device_core_win.cc index 834fa4ed25..4aaefc91a4 100644 --- a/modules/audio_device/win/audio_device_core_win.cc +++ b/modules/audio_device/win/audio_device_core_win.cc @@ -2634,6 +2634,10 @@ int32_t AudioDeviceWindowsCore::PlayoutDelay(uint16_t& delayMS) const { return 0; } +bool AudioDeviceWindowsCore::BuiltInAECIsAvailable() const { + return _dmo != nullptr; +} + // ---------------------------------------------------------------------------- // Playing // ---------------------------------------------------------------------------- diff --git a/modules/audio_device/win/audio_device_core_win.h b/modules/audio_device/win/audio_device_core_win.h index b5c2b72d30..a11849da77 100644 --- a/modules/audio_device/win/audio_device_core_win.h +++ b/modules/audio_device/win/audio_device_core_win.h @@ -170,6 +170,8 @@ public: // Delay information and control virtual int32_t PlayoutDelay(uint16_t& delayMS) const; + virtual bool BuiltInAECIsAvailable() const; + virtual int32_t EnableBuiltInAEC(bool enable); public: