| OLD | NEW |
| 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/video_sender.h" | 5 #include "media/cast/sender/video_sender.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cstring> | 8 #include <cstring> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 CastTransportSender* const transport_sender) | 43 CastTransportSender* const transport_sender) |
| 44 : FrameSender( | 44 : FrameSender( |
| 45 cast_environment, | 45 cast_environment, |
| 46 transport_sender, | 46 transport_sender, |
| 47 base::TimeDelta::FromMilliseconds(video_config.rtcp_interval), | 47 base::TimeDelta::FromMilliseconds(video_config.rtcp_interval), |
| 48 kVideoFrequency, | 48 kVideoFrequency, |
| 49 video_config.ssrc, | 49 video_config.ssrc, |
| 50 video_config.max_frame_rate, | 50 video_config.max_frame_rate, |
| 51 video_config.target_playout_delay), | 51 video_config.target_playout_delay), |
| 52 fixed_bitrate_(GetFixedBitrate(video_config)), | 52 fixed_bitrate_(GetFixedBitrate(video_config)), |
| 53 frames_in_encoder_(0), | |
| 54 congestion_control_(cast_environment->Clock(), | 53 congestion_control_(cast_environment->Clock(), |
| 55 video_config.max_bitrate, | 54 video_config.max_bitrate, |
| 56 video_config.min_bitrate, | 55 video_config.min_bitrate, |
| 57 max_unacked_frames_), | 56 max_unacked_frames_), |
| 58 weak_factory_(this) { | 57 weak_factory_(this) { |
| 59 cast_initialization_status_ = STATUS_VIDEO_UNINITIALIZED; | 58 cast_initialization_status_ = STATUS_VIDEO_UNINITIALIZED; |
| 60 VLOG(1) << "max_unacked_frames is " << max_unacked_frames_ | 59 VLOG(1) << "max_unacked_frames is " << max_unacked_frames_ |
| 61 << " for target_playout_delay=" | 60 << " for target_playout_delay=" |
| 62 << target_playout_delay_.InMilliseconds() << " ms" | 61 << target_playout_delay_.InMilliseconds() << " ms" |
| 63 << " and max_frame_rate=" << video_config.max_frame_rate; | 62 << " and max_frame_rate=" << video_config.max_frame_rate; |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 std::vector<uint32> cancel_sending_frames; | 289 std::vector<uint32> cancel_sending_frames; |
| 291 while (latest_acked_frame_id_ != cast_feedback.ack_frame_id) { | 290 while (latest_acked_frame_id_ != cast_feedback.ack_frame_id) { |
| 292 latest_acked_frame_id_++; | 291 latest_acked_frame_id_++; |
| 293 cancel_sending_frames.push_back(latest_acked_frame_id_); | 292 cancel_sending_frames.push_back(latest_acked_frame_id_); |
| 294 } | 293 } |
| 295 transport_sender_->CancelSendingFrames(ssrc_, cancel_sending_frames); | 294 transport_sender_->CancelSendingFrames(ssrc_, cancel_sending_frames); |
| 296 latest_acked_frame_id_ = cast_feedback.ack_frame_id; | 295 latest_acked_frame_id_ = cast_feedback.ack_frame_id; |
| 297 } | 296 } |
| 298 } | 297 } |
| 299 | 298 |
| 300 bool VideoSender::ShouldDropNextFrame(base::TimeTicks capture_time) const { | |
| 301 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); | |
| 302 int frames_in_flight = 0; | |
| 303 base::TimeDelta duration_in_flight; | |
| 304 if (!last_send_time_.is_null()) { | |
| 305 frames_in_flight = | |
| 306 static_cast<int32>(last_sent_frame_id_ - latest_acked_frame_id_); | |
| 307 if (frames_in_flight > 0) { | |
| 308 const uint32 oldest_unacked_frame_id = latest_acked_frame_id_ + 1; | |
| 309 duration_in_flight = | |
| 310 capture_time - GetRecordedReferenceTime(oldest_unacked_frame_id); | |
| 311 } | |
| 312 } | |
| 313 frames_in_flight += frames_in_encoder_; | |
| 314 VLOG(2) << frames_in_flight | |
| 315 << " frames in flight; last sent: " << last_sent_frame_id_ | |
| 316 << "; latest acked: " << latest_acked_frame_id_ | |
| 317 << "; frames in encoder: " << frames_in_encoder_ | |
| 318 << "; duration in flight: " | |
| 319 << duration_in_flight.InMicroseconds() << " usec (" | |
| 320 << (target_playout_delay_ > base::TimeDelta() ? | |
| 321 100 * duration_in_flight / target_playout_delay_ : | |
| 322 kint64max) << "%)"; | |
| 323 return frames_in_flight >= max_unacked_frames_ || | |
| 324 duration_in_flight >= target_playout_delay_; | |
| 325 } | |
| 326 | |
| 327 } // namespace cast | 299 } // namespace cast |
| 328 } // namespace media | 300 } // namespace media |
| OLD | NEW |