andrew@webrtc.org 50b2efef6e Add a wrapper around PushSincResampler and the old Resampler.
The old resampler is used whenever it supports the requested rates. Otherwise
the sinc resampler is enabled.

Integrated with output_mixer in order to test the change through
output_mixer_unittest. The sinc resampler will not yet be used, since we don't
feed VoE with any rates that trigger it.

BUG=webrtc:1395
R=bjornv@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/1355004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@3915 4adac7df-926f-26a2-2b94-8c16560cd09d
2013-04-29 17:27:29 +00:00

155 lines
4.7 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 WEBRTC_VOICE_ENGINE_OUTPUT_MIXER_H_
#define WEBRTC_VOICE_ENGINE_OUTPUT_MIXER_H_
#include "webrtc/common_audio/resampler/include/push_resampler.h"
#include "webrtc/common_types.h"
#include "webrtc/modules/audio_conference_mixer/interface/audio_conference_mixer.h"
#include "webrtc/modules/audio_conference_mixer/interface/audio_conference_mixer_defines.h"
#include "webrtc/modules/utility/interface/file_recorder.h"
#include "webrtc/voice_engine/dtmf_inband.h"
#include "webrtc/voice_engine/level_indicator.h"
#include "webrtc/voice_engine/voice_engine_defines.h"
namespace webrtc {
class AudioProcessing;
class CriticalSectionWrapper;
class FileWrapper;
class VoEMediaProcess;
namespace voe {
class Statistics;
class OutputMixer : public AudioMixerOutputReceiver,
public AudioMixerStatusReceiver,
public FileCallback
{
public:
static int32_t Create(OutputMixer*& mixer, const uint32_t instanceId);
static void Destroy(OutputMixer*& mixer);
int32_t SetEngineInformation(Statistics& engineStatistics);
int32_t SetAudioProcessingModule(
AudioProcessing* audioProcessingModule);
// VoEExternalMedia
int RegisterExternalMediaProcessing(
VoEMediaProcess& proccess_object);
int DeRegisterExternalMediaProcessing();
// VoEDtmf
int PlayDtmfTone(uint8_t eventCode, int lengthMs, int attenuationDb);
int StartPlayingDtmfTone(uint8_t eventCode, int attenuationDb);
int StopPlayingDtmfTone();
int32_t MixActiveChannels();
int32_t DoOperationsOnCombinedSignal();
int32_t SetMixabilityStatus(MixerParticipant& participant,
const bool mixable);
int32_t SetAnonymousMixabilityStatus(MixerParticipant& participant,
const bool mixable);
int GetMixedAudio(int sample_rate_hz, int num_channels,
AudioFrame* audioFrame);
// VoEVolumeControl
int GetSpeechOutputLevel(uint32_t& level);
int GetSpeechOutputLevelFullRange(uint32_t& level);
int SetOutputVolumePan(float left, float right);
int GetOutputVolumePan(float& left, float& right);
// VoEFile
int StartRecordingPlayout(const char* fileName,
const CodecInst* codecInst);
int StartRecordingPlayout(OutStream* stream,
const CodecInst* codecInst);
int StopRecordingPlayout();
virtual ~OutputMixer();
// from AudioMixerOutputReceiver
virtual void NewMixedAudio(
const int32_t id,
const AudioFrame& generalAudioFrame,
const AudioFrame** uniqueAudioFrames,
const uint32_t size);
// from AudioMixerStatusReceiver
virtual void MixedParticipants(
const int32_t id,
const ParticipantStatistics* participantStatistics,
const uint32_t size);
virtual void VADPositiveParticipants(
const int32_t id,
const ParticipantStatistics* participantStatistics,
const uint32_t size);
virtual void MixedAudioLevel(const int32_t id, const uint32_t level);
// For file recording
void PlayNotification(const int32_t id, const uint32_t durationMs);
void RecordNotification(const int32_t id, const uint32_t durationMs);
void PlayFileEnded(const int32_t id);
void RecordFileEnded(const int32_t id);
private:
OutputMixer(const uint32_t instanceId);
void APMAnalyzeReverseStream();
int InsertInbandDtmfTone();
// uses
Statistics* _engineStatisticsPtr;
AudioProcessing* _audioProcessingModulePtr;
// owns
CriticalSectionWrapper& _callbackCritSect;
// protect the _outputFileRecorderPtr and _outputFileRecording
CriticalSectionWrapper& _fileCritSect;
AudioConferenceMixer& _mixerModule;
AudioFrame _audioFrame;
PushResampler resampler_; // converts mixed audio to fit ADM format
PushResampler audioproc_resampler_; // converts mixed audio to fit APM rate
AudioLevel _audioLevel; // measures audio level for the combined signal
DtmfInband _dtmfGenerator;
int _instanceId;
VoEMediaProcess* _externalMediaCallbackPtr;
bool _externalMedia;
float _panLeft;
float _panRight;
int _mixingFrequencyHz;
FileRecorder* _outputFileRecorderPtr;
bool _outputFileRecording;
};
} // namespace voe
} // namespace werbtc
#endif // VOICE_ENGINE_OUTPUT_MIXER_H_