Added new capture callback interface to pass the capture callback to a specific voe channel from libjingle webrtcvoiceengine.cc.

The callback has to go through VoEBaseImpl since VoEChannel is internal to voice engine.

TEST=compile
R=tommi@webrtc.org

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

git-svn-id: http://webrtc.googlecode.com/svn/trunk@5458 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
xians@webrtc.org 2014-01-29 13:54:02 +00:00
parent 094ac39b5a
commit 07e5196414
3 changed files with 34 additions and 14 deletions

View File

@ -183,6 +183,15 @@ 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) {}
protected:
VoEBase() {}
virtual ~VoEBase() {}

View File

@ -224,26 +224,33 @@ 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) {
voe::ChannelOwner ch =
_shared->channel_manager().GetChannel(voe_channels[i]);
voe::Channel* channel_ptr = ch.channel();
if (!channel_ptr)
continue;
if (channel_ptr->InputIsOnHold()) {
channel_ptr->UpdateLocalTimeStamp();
} else if (channel_ptr->Sending()) {
channel_ptr->Demultiplex(audio_data, sample_rate, number_of_frames,
number_of_channels);
channel_ptr->PrepareEncodeAndSend(sample_rate);
channel_ptr->EncodeAndSend();
}
CaptureCallback(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) {
voe::ChannelOwner ch = _shared->channel_manager().GetChannel(voe_channel);
voe::Channel* channel_ptr = ch.channel();
if (!channel_ptr)
return;
if (channel_ptr->InputIsOnHold()) {
channel_ptr->UpdateLocalTimeStamp();
} else if (channel_ptr->Sending()) {
channel_ptr->Demultiplex(static_cast<const int16_t*>(audio_data),
sample_rate, number_of_frames, number_of_channels);
channel_ptr->PrepareEncodeAndSend(sample_rate);
channel_ptr->EncodeAndSend();
}
}
int VoEBaseImpl::RegisterVoiceEngineObserver(VoiceEngineObserver& observer)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),

View File

@ -69,6 +69,10 @@ 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);
// AudioTransport
virtual int32_t
RecordedDataIsAvailable(const void* audioSamples,