diff options
author | pwestin@google.com <pwestin@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-31 11:00:15 +0000 |
---|---|---|
committer | pwestin@google.com <pwestin@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-31 11:00:15 +0000 |
commit | 3092a58482a743d3c56e8d079b216a0e159814d0 (patch) | |
tree | a39f14b3d2aa1234fa3516ad98f1351db58d4b14 /media/cast | |
parent | 206c513b94a67884c1574a9419bb18fbb1e8b92a (diff) | |
download | chromium_src-3092a58482a743d3c56e8d079b216a0e159814d0.zip chromium_src-3092a58482a743d3c56e8d079b216a0e159814d0.tar.gz chromium_src-3092a58482a743d3c56e8d079b216a0e159814d0.tar.bz2 |
Cast: fix resending audio ACKs.
Review URL: https://codereview.chromium.org/53513002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@232083 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/cast')
-rw-r--r-- | media/cast/audio_receiver/audio_receiver.cc | 26 | ||||
-rw-r--r-- | media/cast/audio_receiver/audio_receiver.h | 6 |
2 files changed, 32 insertions, 0 deletions
diff --git a/media/cast/audio_receiver/audio_receiver.cc b/media/cast/audio_receiver/audio_receiver.cc index 1a1c8e7..c3dc393 100644 --- a/media/cast/audio_receiver/audio_receiver.cc +++ b/media/cast/audio_receiver/audio_receiver.cc @@ -119,6 +119,7 @@ AudioReceiver::AudioReceiver(scoped_refptr<CastEnvironment> cast_environment, audio_config.rtcp_c_name)); rtcp_->SetRemoteSSRC(audio_config.incoming_ssrc); ScheduleNextRtcpReport(); + ScheduleNextCastMessage(); } AudioReceiver::~AudioReceiver() {} @@ -190,6 +191,7 @@ void AudioReceiver::DecodeAudioFrameThread( } void AudioReceiver::PlayoutTimeout() { + DCHECK(audio_buffer_) << "Invalid function call in this configuration"; if (queued_encoded_callbacks_.empty()) { // Already released by incoming packet. return; @@ -242,6 +244,7 @@ bool AudioReceiver::PostEncodedAudioFrame( uint32 rtp_timestamp, bool next_frame, scoped_ptr<EncodedAudioFrame>* encoded_frame) { + DCHECK(audio_buffer_) << "Invalid function call in this configuration"; base::TimeTicks now = cast_environment_->Clock()->NowTicks(); base::TimeTicks playout_time = GetPlayoutTime(now, rtp_timestamp); base::TimeDelta time_until_playout = playout_time - now; @@ -328,5 +331,28 @@ void AudioReceiver::SendNextRtcpReport() { ScheduleNextRtcpReport(); } +// Cast messages should be sent within a maximum interval. Schedule a call +// if not triggered elsewhere, e.g. by the cast message_builder. +void AudioReceiver::ScheduleNextCastMessage() { + if (audio_buffer_) { + base::TimeTicks send_time; + audio_buffer_->TimeToSendNextCastMessage(&send_time); + + base::TimeDelta time_to_send = send_time - + cast_environment_->Clock()->NowTicks(); + time_to_send = std::max(time_to_send, + base::TimeDelta::FromMilliseconds(kMinSchedulingDelayMs)); + cast_environment_->PostDelayedTask(CastEnvironment::MAIN, FROM_HERE, + base::Bind(&AudioReceiver::SendNextCastMessage, + weak_factory_.GetWeakPtr()), time_to_send); + } +} + +void AudioReceiver::SendNextCastMessage() { + DCHECK(audio_buffer_) << "Invalid function call in this configuration"; + audio_buffer_->SendCastMessage(); // Will only send a message if it is time. + ScheduleNextCastMessage(); +} + } // namespace cast } // namespace media diff --git a/media/cast/audio_receiver/audio_receiver.h b/media/cast/audio_receiver/audio_receiver.h index 742d343..2044e16 100644 --- a/media/cast/audio_receiver/audio_receiver.h +++ b/media/cast/audio_receiver/audio_receiver.h @@ -87,6 +87,12 @@ class AudioReceiver : public base::NonThreadSafe, // Actually send the next RTCP report. void SendNextRtcpReport(); + // Schedule timing for the next cast message. + void ScheduleNextCastMessage(); + + // Actually send the next cast message. + void SendNextCastMessage(); + scoped_refptr<CastEnvironment> cast_environment_; base::WeakPtrFactory<AudioReceiver> weak_factory_; |