OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/video_sender/video_sender.h" | 5 #include "media/cast/video_sender/video_sender.h" |
6 | 6 |
7 #include <cstring> | 7 #include <cstring> |
8 #include <list> | 8 #include <list> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 last_skip_count_(0), | 110 last_skip_count_(0), |
111 congestion_control_(cast_environment->Clock(), | 111 congestion_control_(cast_environment->Clock(), |
112 video_config.congestion_control_back_off, | 112 video_config.congestion_control_back_off, |
113 video_config.max_bitrate, | 113 video_config.max_bitrate, |
114 video_config.min_bitrate, | 114 video_config.min_bitrate, |
115 video_config.start_bitrate), | 115 video_config.start_bitrate), |
116 initialized_(false), | 116 initialized_(false), |
117 active_session_(false), | 117 active_session_(false), |
118 weak_factory_(this) { | 118 weak_factory_(this) { |
119 max_unacked_frames_ = | 119 max_unacked_frames_ = |
120 static_cast<uint8>(video_config.rtp_config.max_delay_ms * | 120 1 + static_cast<uint8>(video_config.rtp_config.max_delay_ms * |
121 video_config.max_frame_rate / 1000) + | 121 max_frame_rate_ / 1000); |
122 1; | |
123 VLOG(1) << "max_unacked_frames " << static_cast<int>(max_unacked_frames_); | 122 VLOG(1) << "max_unacked_frames " << static_cast<int>(max_unacked_frames_); |
124 DCHECK_GT(max_unacked_frames_, 0) << "Invalid argument"; | 123 DCHECK_GT(max_unacked_frames_, 0) << "Invalid argument"; |
125 | 124 |
126 rtp_video_sender_statistics_.reset( | 125 rtp_video_sender_statistics_.reset( |
127 new LocalRtpVideoSenderStatistics(transport_sender)); | 126 new LocalRtpVideoSenderStatistics(transport_sender)); |
128 | 127 |
129 if (video_config.use_external_encoder) { | 128 if (video_config.use_external_encoder) { |
130 CHECK(gpu_factories); | 129 CHECK(gpu_factories); |
131 video_encoder_.reset(new ExternalVideoEncoder( | 130 video_encoder_.reset(new ExternalVideoEncoder( |
132 cast_environment, video_config, gpu_factories)); | 131 cast_environment, video_config, gpu_factories)); |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 } | 374 } |
376 | 375 |
377 void VideoSender::OnReceivedCastFeedback(const RtcpCastMessage& cast_feedback) { | 376 void VideoSender::OnReceivedCastFeedback(const RtcpCastMessage& cast_feedback) { |
378 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); | 377 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); |
379 base::TimeDelta rtt; | 378 base::TimeDelta rtt; |
380 base::TimeDelta avg_rtt; | 379 base::TimeDelta avg_rtt; |
381 base::TimeDelta min_rtt; | 380 base::TimeDelta min_rtt; |
382 base::TimeDelta max_rtt; | 381 base::TimeDelta max_rtt; |
383 base::TimeTicks now = cast_environment_->Clock()->NowTicks(); | 382 base::TimeTicks now = cast_environment_->Clock()->NowTicks(); |
384 | 383 |
| 384 // Update delay and max number of frames in flight based on the the new |
| 385 // received target delay. |
| 386 rtp_max_delay_ = |
| 387 base::TimeDelta::FromMilliseconds(cast_feedback.target_delay_ms_); |
| 388 max_unacked_frames_ = 1 + static_cast<uint8>(cast_feedback.target_delay_ms_ * |
| 389 max_frame_rate_ / 1000); |
385 if (rtcp_->Rtt(&rtt, &avg_rtt, &min_rtt, &max_rtt)) { | 390 if (rtcp_->Rtt(&rtt, &avg_rtt, &min_rtt, &max_rtt)) { |
386 cast_environment_->Logging()->InsertGenericEvent( | 391 cast_environment_->Logging()->InsertGenericEvent( |
387 now, kRttMs, rtt.InMilliseconds()); | 392 now, kRttMs, rtt.InMilliseconds()); |
388 // Don't use a RTT lower than our average. | 393 // Don't use a RTT lower than our average. |
389 rtt = std::max(rtt, avg_rtt); | 394 rtt = std::max(rtt, avg_rtt); |
390 } else { | 395 } else { |
391 // We have no measured value use default. | 396 // We have no measured value use default. |
392 rtt = base::TimeDelta::FromMilliseconds(kStartRttMs); | 397 rtt = base::TimeDelta::FromMilliseconds(kStartRttMs); |
393 } | 398 } |
394 if (cast_feedback.missing_frames_and_packets_.empty()) { | 399 if (cast_feedback.missing_frames_and_packets_.empty()) { |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 | 500 |
496 void VideoSender::ResendPacketsOnTransportThread( | 501 void VideoSender::ResendPacketsOnTransportThread( |
497 const transport::MissingFramesAndPacketsMap& missing_packets) { | 502 const transport::MissingFramesAndPacketsMap& missing_packets) { |
498 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::TRANSPORT)); | 503 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::TRANSPORT)); |
499 last_send_time_ = cast_environment_->Clock()->NowTicks(); | 504 last_send_time_ = cast_environment_->Clock()->NowTicks(); |
500 transport_sender_->ResendPackets(false, missing_packets); | 505 transport_sender_->ResendPackets(false, missing_packets); |
501 } | 506 } |
502 | 507 |
503 } // namespace cast | 508 } // namespace cast |
504 } // namespace media | 509 } // namespace media |
OLD | NEW |