mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-16 07:10:38 +01:00

This is a reland of68007e97ec
Original change's description: > Reland "Remove WEBRTC_TRACE." > > This is a reland of2209b90449
> Original change's description: > > Remove WEBRTC_TRACE. > > > > Bug: webrtc:5118 > > Change-Id: I0af0f8845ee016fa61d7cecc526e2a672ec8732d > > Reviewed-on: https://webrtc-review.googlesource.com/5382 > > Reviewed-by: Niels Moller <nisse@webrtc.org> > > Reviewed-by: Sami Kalliomäki <sakal@webrtc.org> > > Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> > > Commit-Queue: Fredrik Solenberg <solenberg@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#20114} > > Bug: webrtc:5118 > Change-Id: I2d93fd40fcaa251c363bdcfb1c04b834a3a7f0e9 > Reviewed-on: https://webrtc-review.googlesource.com/6000 > Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> > Reviewed-by: Niels Moller <nisse@webrtc.org> > Commit-Queue: Fredrik Solenberg <solenberg@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#20132} Bug: webrtc:5118 Change-Id: I3b46406899d043c3260fc3195b524138324f7313 Reviewed-on: https://webrtc-review.googlesource.com/6301 Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Reviewed-by: Niels Moller <nisse@webrtc.org> Reviewed-by: Sami Kalliomäki <sakal@webrtc.org> Commit-Queue: Fredrik Solenberg <solenberg@webrtc.org> Cr-Commit-Position: refs/heads/master@{#20144}
132 lines
3.9 KiB
C++
132 lines
3.9 KiB
C++
/*
|
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
|
*
|
|
* 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.
|
|
*/
|
|
|
|
#ifndef VOICE_ENGINE_TRANSMIT_MIXER_H_
|
|
#define VOICE_ENGINE_TRANSMIT_MIXER_H_
|
|
|
|
#include <memory>
|
|
|
|
#include "common_audio/resampler/include/push_resampler.h"
|
|
#include "common_types.h" // NOLINT(build/include)
|
|
#include "modules/audio_processing/typing_detection.h"
|
|
#include "modules/include/module_common_types.h"
|
|
#include "rtc_base/criticalsection.h"
|
|
#include "voice_engine/audio_level.h"
|
|
#include "voice_engine/include/voe_base.h"
|
|
#include "voice_engine/voice_engine_defines.h"
|
|
|
|
#if !defined(WEBRTC_ANDROID) && !defined(WEBRTC_IOS)
|
|
#define WEBRTC_VOICE_ENGINE_TYPING_DETECTION 1
|
|
#else
|
|
#define WEBRTC_VOICE_ENGINE_TYPING_DETECTION 0
|
|
#endif
|
|
|
|
namespace webrtc {
|
|
class AudioProcessing;
|
|
class ProcessThread;
|
|
|
|
namespace voe {
|
|
|
|
class ChannelManager;
|
|
class MixedAudio;
|
|
|
|
class TransmitMixer {
|
|
public:
|
|
static int32_t Create(TransmitMixer*& mixer);
|
|
|
|
static void Destroy(TransmitMixer*& mixer);
|
|
|
|
void SetEngineInformation(ChannelManager* channelManager);
|
|
|
|
int32_t SetAudioProcessingModule(AudioProcessing* audioProcessingModule);
|
|
|
|
int32_t PrepareDemux(const void* audioSamples,
|
|
size_t nSamples,
|
|
size_t nChannels,
|
|
uint32_t samplesPerSec,
|
|
uint16_t totalDelayMS,
|
|
int32_t clockDrift,
|
|
uint16_t currentMicLevel,
|
|
bool keyPressed);
|
|
|
|
void ProcessAndEncodeAudio();
|
|
|
|
// Must be called on the same thread as PrepareDemux().
|
|
uint32_t CaptureLevel() const;
|
|
|
|
int32_t StopSend();
|
|
|
|
// TODO(solenberg): Remove, once AudioMonitor is gone.
|
|
int8_t AudioLevel() const;
|
|
|
|
// 'virtual' to allow mocking.
|
|
virtual int16_t AudioLevelFullRange() const;
|
|
|
|
// See description of "totalAudioEnergy" in the WebRTC stats spec:
|
|
// https://w3c.github.io/webrtc-stats/#dom-rtcmediastreamtrackstats-totalaudioenergy
|
|
// 'virtual' to allow mocking.
|
|
virtual double GetTotalInputEnergy() const;
|
|
|
|
// 'virtual' to allow mocking.
|
|
virtual double GetTotalInputDuration() const;
|
|
|
|
virtual ~TransmitMixer();
|
|
|
|
// Virtual to allow mocking.
|
|
virtual void EnableStereoChannelSwapping(bool enable);
|
|
bool IsStereoChannelSwappingEnabled();
|
|
|
|
// Virtual to allow mocking.
|
|
virtual bool typing_noise_detected() const;
|
|
|
|
protected:
|
|
TransmitMixer() = default;
|
|
|
|
private:
|
|
// Gets the maximum sample rate and number of channels over all currently
|
|
// sending codecs.
|
|
void GetSendCodecInfo(int* max_sample_rate, size_t* max_channels);
|
|
|
|
void GenerateAudioFrame(const int16_t audioSamples[],
|
|
size_t nSamples,
|
|
size_t nChannels,
|
|
int samplesPerSec);
|
|
|
|
void ProcessAudio(int delay_ms, int clock_drift, int current_mic_level,
|
|
bool key_pressed);
|
|
|
|
#if WEBRTC_VOICE_ENGINE_TYPING_DETECTION
|
|
void TypingDetection(bool key_pressed);
|
|
#endif
|
|
|
|
// uses
|
|
ChannelManager* _channelManagerPtr = nullptr;
|
|
AudioProcessing* audioproc_ = nullptr;
|
|
|
|
// owns
|
|
AudioFrame _audioFrame;
|
|
PushResampler<int16_t> resampler_; // ADM sample rate -> mixing rate
|
|
voe::AudioLevel _audioLevel;
|
|
|
|
#if WEBRTC_VOICE_ENGINE_TYPING_DETECTION
|
|
webrtc::TypingDetection typing_detection_;
|
|
#endif
|
|
|
|
rtc::CriticalSection lock_;
|
|
bool typing_noise_detected_ RTC_GUARDED_BY(lock_) = false;
|
|
|
|
uint32_t _captureLevel = 0;
|
|
bool stereo_codec_ = false;
|
|
bool swap_stereo_channels_ = false;
|
|
};
|
|
} // namespace voe
|
|
} // namespace webrtc
|
|
|
|
#endif // VOICE_ENGINE_TRANSMIT_MIXER_H_
|