Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1689)

Side by Side Diff: media/cast/sender/audio_sender.cc

Issue 532373003: [Cast] RTT clean-up to the max! (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/cast/sender/audio_sender.h" 5 #include "media/cast/sender/audio_sender.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "media/cast/cast_defines.h" 10 #include "media/cast/cast_defines.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 // TODO(miu): AudioSender needs to be like VideoSender in providing an upper 63 // TODO(miu): AudioSender needs to be like VideoSender in providing an upper
64 // limit on the number of in-flight frames. 64 // limit on the number of in-flight frames.
65 transport_config.stored_frames = max_unacked_frames_; 65 transport_config.stored_frames = max_unacked_frames_;
66 transport_config.aes_key = audio_config.aes_key; 66 transport_config.aes_key = audio_config.aes_key;
67 transport_config.aes_iv_mask = audio_config.aes_iv_mask; 67 transport_config.aes_iv_mask = audio_config.aes_iv_mask;
68 68
69 transport_sender->InitializeAudio( 69 transport_sender->InitializeAudio(
70 transport_config, 70 transport_config,
71 base::Bind(&AudioSender::OnReceivedCastFeedback, 71 base::Bind(&AudioSender::OnReceivedCastFeedback,
72 weak_factory_.GetWeakPtr()), 72 weak_factory_.GetWeakPtr()),
73 base::Bind(&AudioSender::OnReceivedRtt, weak_factory_.GetWeakPtr())); 73 base::Bind(&AudioSender::OnMeasuredRoundTripTime,
74 weak_factory_.GetWeakPtr()));
74 } 75 }
75 76
76 AudioSender::~AudioSender() {} 77 AudioSender::~AudioSender() {}
77 78
78 void AudioSender::InsertAudio(scoped_ptr<AudioBus> audio_bus, 79 void AudioSender::InsertAudio(scoped_ptr<AudioBus> audio_bus,
79 const base::TimeTicks& recorded_time) { 80 const base::TimeTicks& recorded_time) {
80 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); 81 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN));
81 if (cast_initialization_status_ != STATUS_AUDIO_INITIALIZED) { 82 if (cast_initialization_status_ != STATUS_AUDIO_INITIALIZED) {
82 NOTREACHED(); 83 NOTREACHED();
83 return; 84 return;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 encoded_frame->new_playout_delay_ms = 139 encoded_frame->new_playout_delay_ms =
139 target_playout_delay_.InMilliseconds(); 140 target_playout_delay_.InMilliseconds();
140 } 141 }
141 transport_sender_->InsertCodedAudioFrame(*encoded_frame); 142 transport_sender_->InsertCodedAudioFrame(*encoded_frame);
142 } 143 }
143 144
144 void AudioSender::OnReceivedCastFeedback(const RtcpCastMessage& cast_feedback) { 145 void AudioSender::OnReceivedCastFeedback(const RtcpCastMessage& cast_feedback) {
145 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); 146 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN));
146 147
147 if (is_rtt_available()) { 148 if (is_rtt_available()) {
148 // Having the RTT values implies the receiver sent back a receiver report 149 // Having the RTT value implies the receiver sent back a receiver report
149 // based on it having received a report from here. Therefore, ensure this 150 // based on it having received a report from here. Therefore, ensure this
150 // sender stops aggressively sending reports. 151 // sender stops aggressively sending reports.
151 if (num_aggressive_rtcp_reports_sent_ < kNumAggressiveReportsSentAtStart) { 152 if (num_aggressive_rtcp_reports_sent_ < kNumAggressiveReportsSentAtStart) {
152 VLOG(1) << "No longer a need to send reports aggressively (sent " 153 VLOG(1) << "No longer a need to send reports aggressively (sent "
153 << num_aggressive_rtcp_reports_sent_ << ")."; 154 << num_aggressive_rtcp_reports_sent_ << ").";
154 num_aggressive_rtcp_reports_sent_ = kNumAggressiveReportsSentAtStart; 155 num_aggressive_rtcp_reports_sent_ = kNumAggressiveReportsSentAtStart;
155 ScheduleNextRtcpReport(); 156 ScheduleNextRtcpReport();
156 } 157 }
157 } 158 }
158 159
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 << duration_in_flight.InMicroseconds() << " usec (" 223 << duration_in_flight.InMicroseconds() << " usec ("
223 << (target_playout_delay_ > base::TimeDelta() ? 224 << (target_playout_delay_ > base::TimeDelta() ?
224 100 * duration_in_flight / target_playout_delay_ : 225 100 * duration_in_flight / target_playout_delay_ :
225 kint64max) << "%)"; 226 kint64max) << "%)";
226 return frames_in_flight >= max_unacked_frames_ || 227 return frames_in_flight >= max_unacked_frames_ ||
227 duration_in_flight >= target_playout_delay_; 228 duration_in_flight >= target_playout_delay_;
228 } 229 }
229 230
230 } // namespace cast 231 } // namespace cast
231 } // namespace media 232 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698