Moved the new OnData interface to AudioTranport, and expose the AudioTransport pointer via voe_base

R=tommi@webrtc.org

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

git-svn-id: http://webrtc.googlecode.com/svn/trunk@5472 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
xians@webrtc.org 2014-02-02 15:30:20 +00:00
parent 1af5ea0538
commit c1e28038ba
7 changed files with 41 additions and 18 deletions

View File

@ -85,8 +85,8 @@ public:
// will be ignored.
// The return value is the new microphone volume, in the range of |0, 255].
// When the volume does not need to be updated, it returns 0.
// TODO(xians): Make the interface pure virtual after libjingle has its
// implementation.
// TODO(xians): Remove this interface after Chrome and Libjingle switches
// to OnData().
virtual int OnDataAvailable(const int voe_channels[],
int number_of_voe_channels,
const int16_t* audio_data,
@ -98,6 +98,16 @@ public:
bool key_pressed,
bool need_audio_processing) { return 0; }
// Method to pass the captured audio data to the specific VoE channel.
// |voe_channel| is the id of the VoE channel which is the sink to the
// capture data.
// TODO(xians): Make the interface pure virtual after libjingle
// has its implementation.
virtual void OnData(int voe_channel, const void* audio_data,
int bits_per_sample, int sample_rate,
int number_of_channels,
int number_of_frames) {}
protected:
virtual ~AudioTransport() {}
};

View File

@ -142,6 +142,10 @@ class AudioTransportAPI: public AudioTransport {
return 0;
}
virtual void OnData(int voe_channel, const void* audio_data,
int bits_per_sample, int sample_rate,
int number_of_channels,
int number_of_frames) {}
private:
uint32_t rec_count_;
uint32_t play_count_;

View File

@ -542,6 +542,12 @@ int AudioTransportImpl::OnDataAvailable(const int voe_channels[],
return 0;
}
void AudioTransportImpl::OnData(int voe_channel,
const void* audio_data,
int bits_per_sample, int sample_rate,
int number_of_channels,
int number_of_frames) {}
FuncTestManager::FuncTestManager() :
_processThread(NULL),
_audioDevice(NULL),

View File

@ -131,6 +131,11 @@ public:
bool key_pressed,
bool need_audio_processing);
virtual void OnData(int voe_channel, const void* audio_data,
int bits_per_sample, int sample_rate,
int number_of_channels,
int number_of_frames);
AudioTransportImpl(AudioDeviceModule* audioDevice);
~AudioTransportImpl();

View File

@ -40,6 +40,7 @@ namespace webrtc {
class AudioDeviceModule;
class AudioProcessing;
class AudioTransport;
class Config;
const int kVoEDefault = -1;
@ -183,15 +184,10 @@ public:
// Gets the NetEQ playout mode for a specified |channel| number.
virtual int GetNetEQPlayoutMode(int channel, NetEqModes& mode) = 0;
// Method to pass the captured audio data to the specific VoE channel.
// |voe_channel| is the id of the VoE channel which is the sink to the
// capture data.
// TODO(xians): Make the interface pure virtual after libjingle
// implements the interface in its FakeWebRtcVoiceEngine.
virtual void CaptureCallback(int voe_channel, const void* audio_data,
int bits_per_sample, int sample_rate,
int number_of_channels,
int number_of_frames) {}
virtual AudioTransport* audio_transport() { return NULL; }
protected:
VoEBase() {}
virtual ~VoEBase() {}

View File

@ -224,18 +224,18 @@ int VoEBaseImpl::OnDataAvailable(const int voe_channels[],
// No need to go through the APM, demultiplex the data to each VoE channel,
// encode and send to the network.
for (int i = 0; i < number_of_voe_channels; ++i) {
CaptureCallback(voe_channels[i], audio_data, 16, sample_rate,
number_of_channels, number_of_frames);
OnData(voe_channels[i], audio_data, 16, sample_rate,
number_of_channels, number_of_frames);
}
// Return 0 to indicate no need to change the volume.
return 0;
}
void VoEBaseImpl::CaptureCallback(int voe_channel, const void* audio_data,
int bits_per_sample, int sample_rate,
int number_of_channels,
int number_of_frames) {
void VoEBaseImpl::OnData(int voe_channel, const void* audio_data,
int bits_per_sample, int sample_rate,
int number_of_channels,
int number_of_frames) {
voe::ChannelOwner ch = _shared->channel_manager().GetChannel(voe_channel);
voe::Channel* channel_ptr = ch.channel();
if (!channel_ptr)

View File

@ -69,9 +69,7 @@ public:
virtual int LastError();
virtual void CaptureCallback(int voe_channel, const void* audio_data,
int bits_per_sample, int sample_rate,
int number_of_channels, int number_of_frames);
virtual AudioTransport* audio_transport() { return this; }
// AudioTransport
virtual int32_t
@ -104,6 +102,10 @@ public:
bool key_pressed,
bool need_audio_processing);
virtual void OnData(int voe_channel, const void* audio_data,
int bits_per_sample, int sample_rate,
int number_of_channels, int number_of_frames);
// AudioDeviceObserver
virtual void OnErrorIsReported(ErrorCode error);
virtual void OnWarningIsReported(WarningCode warning);