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

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

Issue 545593002: [Cast] Track audio queued in encoder; account for it in ShouldDropNextFrame(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase + MERGE (post-hubbe's refactoring changes) 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
« no previous file with comments | « media/cast/sender/frame_sender.h ('k') | media/cast/sender/video_sender.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/frame_sender.h" 5 #include "media/cast/sender/frame_sender.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 8
9 namespace media { 9 namespace media {
10 namespace cast { 10 namespace cast {
(...skipping 11 matching lines...) Expand all
22 int rtp_timebase, 22 int rtp_timebase,
23 uint32 ssrc, 23 uint32 ssrc,
24 double max_frame_rate, 24 double max_frame_rate,
25 base::TimeDelta playout_delay, 25 base::TimeDelta playout_delay,
26 CongestionControl* congestion_control) 26 CongestionControl* congestion_control)
27 : cast_environment_(cast_environment), 27 : cast_environment_(cast_environment),
28 transport_sender_(transport_sender), 28 transport_sender_(transport_sender),
29 ssrc_(ssrc), 29 ssrc_(ssrc),
30 rtcp_interval_(rtcp_interval), 30 rtcp_interval_(rtcp_interval),
31 max_frame_rate_(max_frame_rate), 31 max_frame_rate_(max_frame_rate),
32 frames_in_encoder_(0),
33 num_aggressive_rtcp_reports_sent_(0), 32 num_aggressive_rtcp_reports_sent_(0),
34 last_sent_frame_id_(0), 33 last_sent_frame_id_(0),
35 latest_acked_frame_id_(0), 34 latest_acked_frame_id_(0),
36 duplicate_ack_counter_(0), 35 duplicate_ack_counter_(0),
37 rtp_timebase_(rtp_timebase), 36 rtp_timebase_(rtp_timebase),
38 congestion_control_(congestion_control), 37 congestion_control_(congestion_control),
39 is_audio_(is_audio), 38 is_audio_(is_audio),
40 weak_factory_(this) { 39 weak_factory_(this) {
41 DCHECK(transport_sender_); 40 DCHECK(transport_sender_);
42 DCHECK_GT(rtp_timebase_, 0); 41 DCHECK_GT(rtp_timebase_, 0);
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 } 155 }
157 156
158 base::TimeTicks FrameSender::GetRecordedReferenceTime(uint32 frame_id) const { 157 base::TimeTicks FrameSender::GetRecordedReferenceTime(uint32 frame_id) const {
159 return frame_reference_times_[frame_id % arraysize(frame_reference_times_)]; 158 return frame_reference_times_[frame_id % arraysize(frame_reference_times_)];
160 } 159 }
161 160
162 RtpTimestamp FrameSender::GetRecordedRtpTimestamp(uint32 frame_id) const { 161 RtpTimestamp FrameSender::GetRecordedRtpTimestamp(uint32 frame_id) const {
163 return frame_rtp_timestamps_[frame_id % arraysize(frame_rtp_timestamps_)]; 162 return frame_rtp_timestamps_[frame_id % arraysize(frame_rtp_timestamps_)];
164 } 163 }
165 164
166
167 void FrameSender::SendEncodedFrame( 165 void FrameSender::SendEncodedFrame(
168 int requested_bitrate_before_encode, 166 int requested_bitrate_before_encode,
169 scoped_ptr<EncodedFrame> encoded_frame) { 167 scoped_ptr<EncodedFrame> encoded_frame) {
170 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); 168 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN));
171 169
172 DCHECK_GT(frames_in_encoder_, 0) << " is_audio: " << is_audio_;
173 frames_in_encoder_--;
174
175 const uint32 frame_id = encoded_frame->frame_id; 170 const uint32 frame_id = encoded_frame->frame_id;
176 171
177 const bool is_first_frame_to_be_sent = last_send_time_.is_null(); 172 const bool is_first_frame_to_be_sent = last_send_time_.is_null();
178 last_send_time_ = cast_environment_->Clock()->NowTicks(); 173 last_send_time_ = cast_environment_->Clock()->NowTicks();
179 last_sent_frame_id_ = frame_id; 174 last_sent_frame_id_ = frame_id;
180 // If this is the first frame about to be sent, fake the value of 175 // If this is the first frame about to be sent, fake the value of
181 // |latest_acked_frame_id_| to indicate the receiver starts out all caught up. 176 // |latest_acked_frame_id_| to indicate the receiver starts out all caught up.
182 // Also, schedule the periodic frame re-send checks. 177 // Also, schedule the periodic frame re-send checks.
183 if (is_first_frame_to_be_sent) { 178 if (is_first_frame_to_be_sent) {
184 latest_acked_frame_id_ = frame_id - 1; 179 latest_acked_frame_id_ = frame_id - 1;
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 base::TimeDelta duration_in_flight; 303 base::TimeDelta duration_in_flight;
309 if (!last_send_time_.is_null()) { 304 if (!last_send_time_.is_null()) {
310 frames_in_flight = 305 frames_in_flight =
311 static_cast<int32>(last_sent_frame_id_ - latest_acked_frame_id_); 306 static_cast<int32>(last_sent_frame_id_ - latest_acked_frame_id_);
312 if (frames_in_flight > 0) { 307 if (frames_in_flight > 0) {
313 const uint32 oldest_unacked_frame_id = latest_acked_frame_id_ + 1; 308 const uint32 oldest_unacked_frame_id = latest_acked_frame_id_ + 1;
314 duration_in_flight = 309 duration_in_flight =
315 capture_time - GetRecordedReferenceTime(oldest_unacked_frame_id); 310 capture_time - GetRecordedReferenceTime(oldest_unacked_frame_id);
316 } 311 }
317 } 312 }
318 frames_in_flight += frames_in_encoder_; 313 frames_in_flight += GetNumberOfFramesInEncoder();
319 VLOG(2) << frames_in_flight 314 VLOG(2) << frames_in_flight
320 << " frames in flight; last sent: " << last_sent_frame_id_ 315 << " frames in flight; last sent: " << last_sent_frame_id_
321 << "; latest acked: " << latest_acked_frame_id_ 316 << "; latest acked: " << latest_acked_frame_id_
322 << "; frames in encoder: " << frames_in_encoder_ 317 << "; frames in encoder: " << GetNumberOfFramesInEncoder()
323 << "; duration in flight: " 318 << "; duration in flight: "
324 << duration_in_flight.InMicroseconds() << " usec (" 319 << duration_in_flight.InMicroseconds() << " usec ("
325 << (target_playout_delay_ > base::TimeDelta() ? 320 << (target_playout_delay_ > base::TimeDelta() ?
326 100 * duration_in_flight / target_playout_delay_ : 321 100 * duration_in_flight / target_playout_delay_ :
327 kint64max) << "%)"; 322 kint64max) << "%)";
328 return frames_in_flight >= max_unacked_frames_ || 323 return frames_in_flight >= max_unacked_frames_ ||
329 duration_in_flight >= target_playout_delay_; 324 duration_in_flight >= target_playout_delay_;
330 } 325 }
331 326
332 } // namespace cast 327 } // namespace cast
333 } // namespace media 328 } // namespace media
OLDNEW
« no previous file with comments | « media/cast/sender/frame_sender.h ('k') | media/cast/sender/video_sender.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698