| 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 29 matching lines...) Expand all Loading... |
| 40 scoped_refptr<CastEnvironment> cast_environment, | 40 scoped_refptr<CastEnvironment> cast_environment, |
| 41 const VideoSenderConfig& video_config, | 41 const VideoSenderConfig& video_config, |
| 42 const CreateVideoEncodeAcceleratorCallback& create_vea_cb, | 42 const CreateVideoEncodeAcceleratorCallback& create_vea_cb, |
| 43 const CreateVideoEncodeMemoryCallback& create_video_encode_mem_cb, | 43 const CreateVideoEncodeMemoryCallback& create_video_encode_mem_cb, |
| 44 CastTransportSender* const transport_sender) | 44 CastTransportSender* const transport_sender) |
| 45 : FrameSender( | 45 : FrameSender( |
| 46 cast_environment, | 46 cast_environment, |
| 47 transport_sender, | 47 transport_sender, |
| 48 base::TimeDelta::FromMilliseconds(video_config.rtcp_interval), | 48 base::TimeDelta::FromMilliseconds(video_config.rtcp_interval), |
| 49 kVideoFrequency, | 49 kVideoFrequency, |
| 50 video_config.ssrc), | 50 video_config.ssrc, |
| 51 target_playout_delay_(video_config.target_playout_delay), | 51 video_config.max_frame_rate, |
| 52 max_unacked_frames_( | 52 video_config.target_playout_delay), |
| 53 std::min(kMaxUnackedFrames, | |
| 54 1 + static_cast<int>(target_playout_delay_ * | |
| 55 video_config.max_frame_rate / | |
| 56 base::TimeDelta::FromSeconds(1)))), | |
| 57 fixed_bitrate_(GetFixedBitrate(video_config)), | 53 fixed_bitrate_(GetFixedBitrate(video_config)), |
| 58 num_aggressive_rtcp_reports_sent_(0), | 54 num_aggressive_rtcp_reports_sent_(0), |
| 59 frames_in_encoder_(0), | 55 frames_in_encoder_(0), |
| 60 last_sent_frame_id_(0), | 56 last_sent_frame_id_(0), |
| 61 latest_acked_frame_id_(0), | 57 latest_acked_frame_id_(0), |
| 62 duplicate_ack_counter_(0), | 58 duplicate_ack_counter_(0), |
| 63 congestion_control_(cast_environment->Clock(), | 59 congestion_control_(cast_environment->Clock(), |
| 64 video_config.max_bitrate, | 60 video_config.max_bitrate, |
| 65 video_config.min_bitrate, | 61 video_config.min_bitrate, |
| 66 max_unacked_frames_), | 62 max_unacked_frames_), |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 ++num_aggressive_rtcp_reports_sent_; | 209 ++num_aggressive_rtcp_reports_sent_; |
| 214 const bool is_last_aggressive_report = | 210 const bool is_last_aggressive_report = |
| 215 (num_aggressive_rtcp_reports_sent_ == kNumAggressiveReportsSentAtStart); | 211 (num_aggressive_rtcp_reports_sent_ == kNumAggressiveReportsSentAtStart); |
| 216 VLOG_IF(1, is_last_aggressive_report) << "Sending last aggressive report."; | 212 VLOG_IF(1, is_last_aggressive_report) << "Sending last aggressive report."; |
| 217 SendRtcpReport(is_last_aggressive_report); | 213 SendRtcpReport(is_last_aggressive_report); |
| 218 } | 214 } |
| 219 | 215 |
| 220 congestion_control_.SendFrameToTransport( | 216 congestion_control_.SendFrameToTransport( |
| 221 frame_id, encoded_frame->data.size() * 8, last_send_time_); | 217 frame_id, encoded_frame->data.size() * 8, last_send_time_); |
| 222 | 218 |
| 219 if (send_target_playout_delay_) { |
| 220 encoded_frame->new_playout_delay_ms = |
| 221 target_playout_delay_.InMilliseconds(); |
| 222 } |
| 223 transport_sender_->InsertCodedVideoFrame(*encoded_frame); | 223 transport_sender_->InsertCodedVideoFrame(*encoded_frame); |
| 224 } | 224 } |
| 225 | 225 |
| 226 void VideoSender::ResendCheck() { | 226 void VideoSender::ResendCheck() { |
| 227 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); | 227 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); |
| 228 DCHECK(!last_send_time_.is_null()); | 228 DCHECK(!last_send_time_.is_null()); |
| 229 const base::TimeDelta time_since_last_send = | 229 const base::TimeDelta time_since_last_send = |
| 230 cast_environment_->Clock()->NowTicks() - last_send_time_; | 230 cast_environment_->Clock()->NowTicks() - last_send_time_; |
| 231 if (time_since_last_send > target_playout_delay_) { | 231 if (time_since_last_send > target_playout_delay_) { |
| 232 if (latest_acked_frame_id_ == last_sent_frame_id_) { | 232 if (latest_acked_frame_id_ == last_sent_frame_id_) { |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); | 356 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); |
| 357 DCHECK(!last_send_time_.is_null()); | 357 DCHECK(!last_send_time_.is_null()); |
| 358 VLOG(1) << "Resending last packet of frame " << last_sent_frame_id_ | 358 VLOG(1) << "Resending last packet of frame " << last_sent_frame_id_ |
| 359 << " to kick-start."; | 359 << " to kick-start."; |
| 360 last_send_time_ = cast_environment_->Clock()->NowTicks(); | 360 last_send_time_ = cast_environment_->Clock()->NowTicks(); |
| 361 transport_sender_->ResendFrameForKickstart(ssrc_, last_sent_frame_id_); | 361 transport_sender_->ResendFrameForKickstart(ssrc_, last_sent_frame_id_); |
| 362 } | 362 } |
| 363 | 363 |
| 364 } // namespace cast | 364 } // namespace cast |
| 365 } // namespace media | 365 } // namespace media |
| OLD | NEW |