Add a NeededFrequency() method to the AudioMixer::Source interface.

This change will allow for a audio source to report its sampling rate
to the audio mixer. It is needed in order to mix at a lower sampling
rate. Mixing at a lower sampling rate can in many cases lead to big
efficiency improvements, as reported by experiments.

The code affected is all implementations of the Source interface:
AudioReceiveStream and a mock class. The AudioReceiveStream now
queries its underlying voe::Channel object for the needed frequency.

Note that the changes to the mixing algorithm are done in a later CL.

BUG=webrtc:6346
NOTRY=True
TBR=solenberg@webrtc.org

Review-Url: https://codereview.webrtc.org/2448113009
Cr-Commit-Position: refs/heads/master@{#14839}
This commit is contained in:
aleloi 2016-10-31 03:26:40 -07:00 committed by Commit bot
parent 9aa78832f9
commit 051f678808
6 changed files with 20 additions and 4 deletions

View File

@ -42,7 +42,11 @@ class AudioMixer : public rtc::RefCountInterface {
AudioFrame* audio_frame) = 0;
// A way for a mixer implementation to distinguish participants.
virtual int Ssrc() = 0;
virtual int Ssrc() const = 0;
// A way for this source to say that GetAudioFrameWithInfo called
// with this sample rate or higher will not cause quality loss.
virtual int PreferredSampleRate() const = 0;
virtual ~Source() {}
};

View File

@ -278,7 +278,11 @@ AudioMixer::Source::AudioFrameInfo AudioReceiveStream::GetAudioFrameWithInfo(
return channel_proxy_->GetAudioFrameWithInfo(sample_rate_hz, audio_frame);
}
int AudioReceiveStream::Ssrc() {
int AudioReceiveStream::PreferredSampleRate() const {
return channel_proxy_->NeededFrequency();
}
int AudioReceiveStream::Ssrc() const {
return config_.rtp.local_ssrc;
}

View File

@ -57,7 +57,8 @@ class AudioReceiveStream final : public webrtc::AudioReceiveStream,
// AudioMixer::Source
AudioFrameInfo GetAudioFrameWithInfo(int sample_rate_hz,
AudioFrame* audio_frame) override;
int Ssrc() override;
int PreferredSampleRate() const override;
int Ssrc() const override;
private:
VoiceEngine* voice_engine() const;

View File

@ -61,7 +61,8 @@ class MockMixerAudioSource : public AudioMixer::Source {
MOCK_METHOD2(GetAudioFrameWithInfo,
AudioFrameInfo(int sample_rate_hz, AudioFrame* audio_frame));
MOCK_METHOD0(Ssrc, int());
MOCK_CONST_METHOD0(PreferredSampleRate, int());
MOCK_CONST_METHOD0(Ssrc, int());
AudioFrame* fake_frame() { return &fake_frame_; }
AudioFrameInfo fake_info() { return fake_audio_frame_info_; }

View File

@ -221,6 +221,10 @@ AudioMixer::Source::AudioFrameInfo ChannelProxy::GetAudioFrameWithInfo(
return channel()->GetAudioFrameWithInfo(sample_rate_hz, audio_frame);
}
int ChannelProxy::NeededFrequency() const {
return static_cast<int>(channel()->NeededFrequency(-1));
}
Channel* ChannelProxy::channel() const {
RTC_DCHECK(channel_owner_.channel());
return channel_owner_.channel();

View File

@ -97,6 +97,8 @@ class ChannelProxy {
int sample_rate_hz,
AudioFrame* audio_frame);
virtual int NeededFrequency() const;
private:
Channel* channel() const;