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
|
|
|
|
2016-02-19 07:04:49 -08:00
|
|
|
#include <memory>
|
|
|
|
|
|
2016-03-10 12:54:25 -08:00
|
|
|
#include "webrtc/base/constructormagic.h"
|
2015-11-28 12:35:15 -08:00
|
|
|
#include "webrtc/base/criticalsection.h"
|
2015-11-16 16:27:42 -08:00
|
|
|
#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;
|
|
|
|
|
|
2016-03-10 12:54:25 -08:00
|
|
|
class EchoControlMobileImpl : public EchoControlMobile {
|
2011-07-07 08:21:25 +00:00
|
|
|
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
|
|
|
|
2016-03-10 12:54:25 -08:00
|
|
|
void Initialize();
|
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:
|
2016-03-10 12:54:25 -08:00
|
|
|
class Canceller;
|
|
|
|
|
|
2011-07-07 08:21:25 +00:00
|
|
|
// 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
|
|
|
|
2016-03-10 12:54:25 -08:00
|
|
|
size_t num_handles_required() const;
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2015-11-16 16:27:42 -08:00
|
|
|
void AllocateRenderQueue();
|
2016-03-10 12:54:25 -08:00
|
|
|
int Configure();
|
2015-11-16 16:27:42 -08:00
|
|
|
|
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_;
|
|
|
|
|
|
2016-03-10 12:54:25 -08:00
|
|
|
bool enabled_ = false;
|
|
|
|
|
|
2015-11-28 12:35:15 -08:00
|
|
|
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.
|
2016-02-19 07:04:49 -08:00
|
|
|
std::unique_ptr<
|
2015-11-16 16:27:42 -08:00
|
|
|
SwapQueue<std::vector<int16_t>, RenderQueueItemVerifier<int16_t>>>
|
|
|
|
|
render_signal_queue_;
|
2016-03-10 12:54:25 -08:00
|
|
|
|
|
|
|
|
std::vector<std::unique_ptr<Canceller>> cancellers_;
|
|
|
|
|
RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(EchoControlMobileImpl);
|
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_
|