2011-07-07 08:21:25 +00:00
|
|
|
/*
|
2012-01-30 09:39:08 +00:00
|
|
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
2011-07-07 08:21:25 +00:00
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2012-01-30 09:39:08 +00:00
|
|
|
#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_CONTROL_MOBILE_IMPL_H_
|
|
|
|
|
#define WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_CONTROL_MOBILE_IMPL_H_
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2015-11-28 12:35:15 -08:00
|
|
|
#include "webrtc/base/criticalsection.h"
|
2015-11-16 16:27:42 -08:00
|
|
|
#include "webrtc/base/scoped_ptr.h"
|
|
|
|
|
#include "webrtc/common_audio/swap_queue.h"
|
2013-05-28 08:11:59 +00:00
|
|
|
#include "webrtc/modules/audio_processing/include/audio_processing.h"
|
|
|
|
|
#include "webrtc/modules/audio_processing/processing_component.h"
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
2014-02-27 22:23:17 +00:00
|
|
|
|
2011-07-07 08:21:25 +00:00
|
|
|
class AudioBuffer;
|
|
|
|
|
|
|
|
|
|
class EchoControlMobileImpl : public EchoControlMobile,
|
|
|
|
|
public ProcessingComponent {
|
|
|
|
|
public:
|
2014-02-27 22:23:17 +00:00
|
|
|
EchoControlMobileImpl(const AudioProcessing* apm,
|
2015-11-28 12:35:15 -08:00
|
|
|
rtc::CriticalSection* crit_render,
|
|
|
|
|
rtc::CriticalSection* crit_capture);
|
|
|
|
|
|
2011-07-07 08:21:25 +00:00
|
|
|
virtual ~EchoControlMobileImpl();
|
|
|
|
|
|
|
|
|
|
int ProcessRenderAudio(const AudioBuffer* audio);
|
|
|
|
|
int ProcessCaptureAudio(AudioBuffer* audio);
|
|
|
|
|
|
|
|
|
|
// EchoControlMobile implementation.
|
2015-03-04 12:58:35 +00:00
|
|
|
bool is_enabled() const override;
|
2015-10-03 00:39:14 +02:00
|
|
|
RoutingMode routing_mode() const override;
|
|
|
|
|
bool is_comfort_noise_enabled() const override;
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
// ProcessingComponent implementation.
|
2015-03-04 12:58:35 +00:00
|
|
|
int Initialize() override;
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2015-11-16 16:27:42 -08:00
|
|
|
// Reads render side data that has been queued on the render call.
|
|
|
|
|
void ReadQueuedRenderData();
|
|
|
|
|
|
2011-07-07 08:21:25 +00:00
|
|
|
private:
|
|
|
|
|
// EchoControlMobile implementation.
|
2015-03-04 12:58:35 +00:00
|
|
|
int Enable(bool enable) override;
|
|
|
|
|
int set_routing_mode(RoutingMode mode) override;
|
|
|
|
|
int enable_comfort_noise(bool enable) override;
|
|
|
|
|
int SetEchoPath(const void* echo_path, size_t size_bytes) override;
|
|
|
|
|
int GetEchoPath(void* echo_path, size_t size_bytes) const override;
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
// ProcessingComponent implementation.
|
2015-11-28 12:35:15 -08:00
|
|
|
// Called holding both the render and capture locks.
|
2015-03-04 12:58:35 +00:00
|
|
|
void* CreateHandle() const override;
|
|
|
|
|
int InitializeHandle(void* handle) const override;
|
|
|
|
|
int ConfigureHandle(void* handle) const override;
|
|
|
|
|
void DestroyHandle(void* handle) const override;
|
Convert channel counts to size_t.
IIRC, this was originally requested by ajm during review of the other size_t conversions I did over the past year, and I agreed it made sense, but wanted to do it separately since those changes were already gargantuan.
BUG=chromium:81439
TEST=none
R=henrik.lundin@webrtc.org, henrika@webrtc.org, kjellander@webrtc.org, minyue@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1316523002 .
Cr-Commit-Position: refs/heads/master@{#11229}
2016-01-12 16:26:35 -08:00
|
|
|
size_t num_handles_required() const override;
|
2015-03-04 12:58:35 +00:00
|
|
|
int GetHandleError(void* handle) const override;
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2015-11-16 16:27:42 -08:00
|
|
|
void AllocateRenderQueue();
|
|
|
|
|
|
2015-11-28 12:35:15 -08:00
|
|
|
// Not guarded as its public API is thread safe.
|
2014-02-27 22:23:17 +00:00
|
|
|
const AudioProcessing* apm_;
|
2015-11-28 12:35:15 -08:00
|
|
|
|
|
|
|
|
rtc::CriticalSection* const crit_render_ ACQUIRED_BEFORE(crit_capture_);
|
|
|
|
|
rtc::CriticalSection* const crit_capture_;
|
|
|
|
|
|
|
|
|
|
RoutingMode routing_mode_ GUARDED_BY(crit_capture_);
|
|
|
|
|
bool comfort_noise_enabled_ GUARDED_BY(crit_capture_);
|
|
|
|
|
unsigned char* external_echo_path_ GUARDED_BY(crit_render_)
|
|
|
|
|
GUARDED_BY(crit_capture_);
|
|
|
|
|
|
|
|
|
|
size_t render_queue_element_max_size_ GUARDED_BY(crit_render_)
|
|
|
|
|
GUARDED_BY(crit_capture_);
|
|
|
|
|
|
|
|
|
|
std::vector<int16_t> render_queue_buffer_ GUARDED_BY(crit_render_);
|
|
|
|
|
std::vector<int16_t> capture_queue_buffer_ GUARDED_BY(crit_capture_);
|
|
|
|
|
|
|
|
|
|
// Lock protection not needed.
|
2015-11-16 16:27:42 -08:00
|
|
|
rtc::scoped_ptr<
|
|
|
|
|
SwapQueue<std::vector<int16_t>, RenderQueueItemVerifier<int16_t>>>
|
|
|
|
|
render_signal_queue_;
|
2011-07-07 08:21:25 +00:00
|
|
|
};
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
|
2012-01-30 09:39:08 +00:00
|
|
|
#endif // WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_CONTROL_MOBILE_IMPL_H_
|