Made AudioReceiveStream a mixer participant.

Methods to facilitate this are added to ChannelProxy and voe::Channel.

BUG=webrtc:6346

Review-Url: https://codereview.webrtc.org/2378143004
Cr-Commit-Position: refs/heads/master@{#14707}
This commit is contained in:
aleloi 2016-10-20 06:32:39 -07:00 committed by Commit bot
parent 5f70d3b559
commit aed581a4f3
10 changed files with 60 additions and 1 deletions

View File

@ -27,6 +27,7 @@ rtc_static_library("audio") {
deps = [
"..:webrtc_common",
"../api:audio_mixer_api",
"../api:call_api",
"../system_wrappers",
"../voice_engine",

View File

@ -272,6 +272,15 @@ bool AudioReceiveStream::DeliverRtp(const uint8_t* packet,
return channel_proxy_->ReceivedRTPPacket(packet, length, packet_time);
}
AudioMixer::Source::AudioFrameWithInfo
AudioReceiveStream::GetAudioFrameWithInfo(int sample_rate_hz) {
return channel_proxy_->GetAudioFrameWithInfo(sample_rate_hz);
}
int AudioReceiveStream::Ssrc() {
return config_.rtp.local_ssrc;
}
VoiceEngine* AudioReceiveStream::voice_engine() const {
internal::AudioState* audio_state =
static_cast<internal::AudioState*>(audio_state_.get());

View File

@ -13,6 +13,7 @@
#include <memory>
#include "webrtc/api/audio/audio_mixer.h"
#include "webrtc/api/call/audio_receive_stream.h"
#include "webrtc/api/call/audio_state.h"
#include "webrtc/base/constructormagic.h"
@ -30,7 +31,8 @@ class ChannelProxy;
namespace internal {
class AudioReceiveStream final : public webrtc::AudioReceiveStream {
class AudioReceiveStream final : public webrtc::AudioReceiveStream,
public AudioMixer::Source {
public:
AudioReceiveStream(CongestionController* congestion_controller,
const webrtc::AudioReceiveStream::Config& config,
@ -52,6 +54,10 @@ class AudioReceiveStream final : public webrtc::AudioReceiveStream {
const PacketTime& packet_time);
const webrtc::AudioReceiveStream::Config& config() const;
// AudioMixer::Source
AudioFrameWithInfo GetAudioFrameWithInfo(int sample_rate_hz) override;
int Ssrc() override;
private:
VoiceEngine* voice_engine() const;

View File

@ -8,6 +8,7 @@
{
'variables': {
'webrtc_audio_dependencies': [
'<(webrtc_root)/api/api.gyp:audio_mixer_api',
'<(webrtc_root)/api/api.gyp:call_api',
'<(webrtc_root)/common.gyp:webrtc_common',
'<(webrtc_root)/system_wrappers/system_wrappers.gyp:system_wrappers',

View File

@ -87,6 +87,7 @@ rtc_static_library("voice_engine") {
deps = [
":level_indicator",
"..:webrtc_common",
"../api:audio_mixer_api",
"../api:call_api",
"../base:rtc_base_approved",
"../common_audio",

View File

@ -712,6 +712,28 @@ MixerParticipant::AudioFrameInfo Channel::GetAudioFrameWithMuted(
: MixerParticipant::AudioFrameInfo::kNormal;
}
AudioMixer::Source::AudioFrameWithInfo Channel::GetAudioFrameWithInfo(
int sample_rate_hz) {
mix_audio_frame_.sample_rate_hz_ = sample_rate_hz;
const auto frame_info = GetAudioFrameWithMuted(-1, &mix_audio_frame_);
using FrameInfo = AudioMixer::Source::AudioFrameInfo;
FrameInfo new_audio_frame_info = FrameInfo::kError;
switch (frame_info) {
case MixerParticipant::AudioFrameInfo::kNormal:
new_audio_frame_info = FrameInfo::kNormal;
break;
case MixerParticipant::AudioFrameInfo::kMuted:
new_audio_frame_info = FrameInfo::kMuted;
break;
case MixerParticipant::AudioFrameInfo::kError:
new_audio_frame_info = FrameInfo::kError;
break;
}
return {&mix_audio_frame_, new_audio_frame_info};
}
int32_t Channel::NeededFrequency(int32_t id) const {
WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId, _channelId),
"Channel::NeededFrequency(id=%d)", id);

View File

@ -13,6 +13,7 @@
#include <memory>
#include "webrtc/api/audio/audio_mixer.h"
#include "webrtc/api/call/audio_sink.h"
#include "webrtc/base/criticalsection.h"
#include "webrtc/base/optional.h"
@ -377,6 +378,10 @@ class Channel
AudioFrame* audioFrame) override;
int32_t NeededFrequency(int32_t id) const override;
// From AudioMixer::Source.
AudioMixer::Source::AudioFrameWithInfo GetAudioFrameWithInfo(
int sample_rate_hz);
// From FileCallback
void PlayNotification(int32_t id, uint32_t durationMs) override;
void RecordNotification(int32_t id, uint32_t durationMs) override;
@ -470,6 +475,7 @@ class Channel
AudioLevel _outputAudioLevel;
bool _externalTransport;
AudioFrame _audioFrame;
AudioFrame mix_audio_frame_;
// Downsamples to the codec rate if necessary.
PushResampler<int16_t> input_resampler_;
std::unique_ptr<FilePlayer> input_file_player_;

View File

@ -214,6 +214,12 @@ void ChannelProxy::SetRtcEventLog(RtcEventLog* event_log) {
channel()->SetRtcEventLog(event_log);
}
AudioMixer::Source::AudioFrameWithInfo ChannelProxy::GetAudioFrameWithInfo(
int sample_rate_hz) {
RTC_DCHECK_RUNS_SERIALIZED(&race_checker_);
return channel()->GetAudioFrameWithInfo(sample_rate_hz);
}
Channel* ChannelProxy::channel() const {
RTC_DCHECK(channel_owner_.channel());
return channel_owner_.channel();

View File

@ -11,7 +11,9 @@
#ifndef WEBRTC_VOICE_ENGINE_CHANNEL_PROXY_H_
#define WEBRTC_VOICE_ENGINE_CHANNEL_PROXY_H_
#include "webrtc/api/audio/audio_mixer.h"
#include "webrtc/base/constructormagic.h"
#include "webrtc/base/race_checker.h"
#include "webrtc/base/thread_checker.h"
#include "webrtc/voice_engine/channel_manager.h"
#include "webrtc/voice_engine/include/voe_rtp_rtcp.h"
@ -91,10 +93,14 @@ class ChannelProxy {
virtual void SetRtcEventLog(RtcEventLog* event_log);
virtual AudioMixer::Source::AudioFrameWithInfo GetAudioFrameWithInfo(
int sample_rate_hz);
private:
Channel* channel() const;
rtc::ThreadChecker thread_checker_;
rtc::RaceChecker race_checker_;
ChannelOwner channel_owner_;
RTC_DISALLOW_COPY_AND_ASSIGN(ChannelProxy);

View File

@ -15,6 +15,7 @@
'target_name': 'voice_engine',
'type': 'static_library',
'dependencies': [
'<(webrtc_root)/api/api.gyp:audio_mixer_api',
'<(webrtc_root)/api/api.gyp:call_api',
'<(webrtc_root)/base/base.gyp:rtc_base_approved',
'<(webrtc_root)/common.gyp:webrtc_common',