Chromium Code Reviews| Index: webrtc/audio/audio_receive_stream.cc |
| diff --git a/webrtc/audio/audio_receive_stream.cc b/webrtc/audio/audio_receive_stream.cc |
| index f46337afd139e8e1175693e90820058ba6d90c00..f156bac51bf531d73d8d4ddb307a151c0261a266 100644 |
| --- a/webrtc/audio/audio_receive_stream.cc |
| +++ b/webrtc/audio/audio_receive_stream.cc |
| @@ -21,6 +21,8 @@ |
| #include "webrtc/base/logging.h" |
| #include "webrtc/base/timeutils.h" |
| #include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h" |
| +#include "webrtc/modules/rtp_rtcp/include/rtp_receiver.h" |
| +#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" |
| #include "webrtc/voice_engine/channel_proxy.h" |
| #include "webrtc/voice_engine/include/voe_base.h" |
| #include "webrtc/voice_engine/include/voe_codec.h" |
| @@ -225,13 +227,64 @@ void AudioReceiveStream::SetGain(float gain) { |
| channel_proxy_->SetChannelOutputVolumeScaling(gain); |
| } |
| -const webrtc::AudioReceiveStream::Config& AudioReceiveStream::config() const { |
| +AudioMixer::Source::AudioFrameInfo AudioReceiveStream::GetAudioFrameWithInfo( |
| + int sample_rate_hz, |
| + AudioFrame* audio_frame) { |
| + return channel_proxy_->GetAudioFrameWithInfo(sample_rate_hz, audio_frame); |
| +} |
| + |
| +int AudioReceiveStream::Ssrc() const { |
| + return config_.rtp.remote_ssrc; |
| +} |
| + |
| +int AudioReceiveStream::PreferredSampleRate() const { |
| + return channel_proxy_->NeededFrequency(); |
| +} |
| + |
| +int AudioReceiveStream::id() const { |
| RTC_DCHECK_RUN_ON(&thread_checker_); |
| - return config_; |
| + return config_.rtp.remote_ssrc; |
| +} |
| + |
| +rtc::Optional<Syncable::Info> AudioReceiveStream::GetInfo() const { |
|
stefan-webrtc
2017/01/19 11:59:59
Should you make sure this runs on the right thread
the sun
2017/01/19 13:15:36
id() is called when sync is set up, part of stream
|
| + // Called on Call's module_process_thread_. |
| + Syncable::Info info; |
| + |
| + RtpRtcp* rtp_rtcp = nullptr; |
| + RtpReceiver* rtp_receiver = nullptr; |
| + channel_proxy_->GetRtpRtcp(&rtp_rtcp, &rtp_receiver); |
| + RTC_DCHECK(rtp_rtcp); |
| + RTC_DCHECK(rtp_receiver); |
| + |
| + if (!rtp_receiver->Timestamp(&info.latest_timestamp)) |
| + return rtc::Optional<Syncable::Info>(); |
| + if (!rtp_receiver->LastReceivedTimeMs(&info.latest_receive_time_ms)) |
| + return rtc::Optional<Syncable::Info>(); |
| + if (rtp_rtcp->RemoteNTP(&info.ntp_secs, &info.ntp_frac, nullptr, nullptr, |
| + &info.rtp_timestamp) != 0) { |
| + return rtc::Optional<Syncable::Info>(); |
| + } |
| + |
| + int jitter_buffer_delay_ms = 0; |
| + int playout_buffer_delay_ms = 0; |
| + channel_proxy_->GetDelayEstimate(&jitter_buffer_delay_ms, |
| + &playout_buffer_delay_ms); |
| + info.current_delay_ms = jitter_buffer_delay_ms + playout_buffer_delay_ms; |
| + return rtc::Optional<Syncable::Info>(info); |
| +} |
| + |
| +uint32_t AudioReceiveStream::GetPlayoutTimestamp() const { |
| + // Called on video capture thread. |
| + return channel_proxy_->GetPlayoutTimestamp(); |
| +} |
| + |
| +void AudioReceiveStream::SetMinimumPlayoutDelay(int delay_ms) { |
| + // Called on Call's module_process_thread_. |
| + return channel_proxy_->SetMinimumPlayoutDelay(delay_ms); |
| } |
| void AudioReceiveStream::AssociateSendStream(AudioSendStream* send_stream) { |
| - RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| + RTC_DCHECK_RUN_ON(&thread_checker_); |
| if (send_stream) { |
| VoiceEngineImpl* voe_impl = static_cast<VoiceEngineImpl*>(voice_engine()); |
| std::unique_ptr<voe::ChannelProxy> send_channel_proxy = |
| @@ -282,18 +335,15 @@ bool AudioReceiveStream::DeliverRtp(const uint8_t* packet, |
| return channel_proxy_->ReceivedRTPPacket(packet, length, packet_time); |
| } |
| -AudioMixer::Source::AudioFrameInfo AudioReceiveStream::GetAudioFrameWithInfo( |
| - int sample_rate_hz, |
| - AudioFrame* audio_frame) { |
| - return channel_proxy_->GetAudioFrameWithInfo(sample_rate_hz, audio_frame); |
| -} |
| - |
| -int AudioReceiveStream::PreferredSampleRate() const { |
| - return channel_proxy_->NeededFrequency(); |
| +const webrtc::AudioReceiveStream::Config& AudioReceiveStream::config() const { |
| + RTC_DCHECK_RUN_ON(&thread_checker_); |
| + return config_; |
| } |
| -int AudioReceiveStream::Ssrc() const { |
| - return config_.rtp.remote_ssrc; |
| +VoiceEngine* AudioReceiveStream::voice_engine() const { |
| + auto* voice_engine = audio_state()->voice_engine(); |
| + RTC_DCHECK(voice_engine); |
| + return voice_engine; |
| } |
| internal::AudioState* AudioReceiveStream::audio_state() const { |
| @@ -302,12 +352,6 @@ internal::AudioState* AudioReceiveStream::audio_state() const { |
| return audio_state; |
| } |
| -VoiceEngine* AudioReceiveStream::voice_engine() const { |
| - auto* voice_engine = audio_state()->voice_engine(); |
| - RTC_DCHECK(voice_engine); |
| - return voice_engine; |
| -} |
| - |
| int AudioReceiveStream::SetVoiceEnginePlayout(bool playout) { |
| ScopedVoEInterface<VoEBase> base(voice_engine()); |
| if (playout) { |
| @@ -316,6 +360,5 @@ int AudioReceiveStream::SetVoiceEnginePlayout(bool playout) { |
| return base->StopPlayout(config_.voe_channel_id); |
| } |
| } |
| - |
| } // namespace internal |
| } // namespace webrtc |