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
diff --git a/webrtc/modules/audio_device/include/audio_device_defines.h b/webrtc/modules/audio_device/include/audio_device_defines.h
index c37c4b13..9f3e24b 100644
--- a/webrtc/modules/audio_device/include/audio_device_defines.h
+++ b/webrtc/modules/audio_device/include/audio_device_defines.h
@@ -85,8 +85,8 @@
// 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 @@
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() {}
};
diff --git a/webrtc/modules/audio_device/test/audio_device_test_api.cc b/webrtc/modules/audio_device/test/audio_device_test_api.cc
index fb25cdd..485c103 100644
--- a/webrtc/modules/audio_device/test/audio_device_test_api.cc
+++ b/webrtc/modules/audio_device/test/audio_device_test_api.cc
@@ -142,6 +142,10 @@
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_;
diff --git a/webrtc/modules/audio_device/test/func_test_manager.cc b/webrtc/modules/audio_device/test/func_test_manager.cc
index ccbcc2a..082b4c2 100644
--- a/webrtc/modules/audio_device/test/func_test_manager.cc
+++ b/webrtc/modules/audio_device/test/func_test_manager.cc
@@ -542,6 +542,12 @@
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),
diff --git a/webrtc/modules/audio_device/test/func_test_manager.h b/webrtc/modules/audio_device/test/func_test_manager.h
index f7a150b..6e21466 100644
--- a/webrtc/modules/audio_device/test/func_test_manager.h
+++ b/webrtc/modules/audio_device/test/func_test_manager.h
@@ -131,6 +131,11 @@
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();
diff --git a/webrtc/voice_engine/include/voe_base.h b/webrtc/voice_engine/include/voe_base.h
index 4a4788d..c8db8c6 100644
--- a/webrtc/voice_engine/include/voe_base.h
+++ b/webrtc/voice_engine/include/voe_base.h
@@ -40,6 +40,7 @@
class AudioDeviceModule;
class AudioProcessing;
+class AudioTransport;
class Config;
const int kVoEDefault = -1;
@@ -183,15 +184,10 @@
// 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() {}
diff --git a/webrtc/voice_engine/voe_base_impl.cc b/webrtc/voice_engine/voe_base_impl.cc
index a84d0c1..4f3e23a 100644
--- a/webrtc/voice_engine/voe_base_impl.cc
+++ b/webrtc/voice_engine/voe_base_impl.cc
@@ -224,18 +224,18 @@
// 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)
diff --git a/webrtc/voice_engine/voe_base_impl.h b/webrtc/voice_engine/voe_base_impl.h
index aff1a2e..00e116e 100644
--- a/webrtc/voice_engine/voe_base_impl.h
+++ b/webrtc/voice_engine/voe_base_impl.h
@@ -69,9 +69,7 @@
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 @@
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);