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 <algorithm> | 7 #include <algorithm> |
8 #include <cstring> | 8 #include <cstring> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 } | 311 } |
312 // TODO(miu): The values "2" and "3" should be derived from configuration. | 312 // TODO(miu): The values "2" and "3" should be derived from configuration. |
313 if (duplicate_ack_counter_ >= 2 && duplicate_ack_counter_ % 3 == 2) { | 313 if (duplicate_ack_counter_ >= 2 && duplicate_ack_counter_ % 3 == 2) { |
314 VLOG(1) << "Received duplicate ACK for frame " << latest_acked_frame_id_; | 314 VLOG(1) << "Received duplicate ACK for frame " << latest_acked_frame_id_; |
315 ResendForKickstart(); | 315 ResendForKickstart(); |
316 } | 316 } |
317 } else { | 317 } else { |
318 // Only count duplicated ACKs if there is no NACK request in between. | 318 // Only count duplicated ACKs if there is no NACK request in between. |
319 // This is to avoid aggresive resend. | 319 // This is to avoid aggresive resend. |
320 duplicate_ack_counter_ = 0; | 320 duplicate_ack_counter_ = 0; |
| 321 |
| 322 // A NACK is also used to cancel pending re-transmissions. |
321 transport_sender_->ResendPackets( | 323 transport_sender_->ResendPackets( |
322 false, cast_feedback.missing_frames_and_packets_); | 324 false, cast_feedback.missing_frames_and_packets_, true); |
323 } | 325 } |
324 | 326 |
325 base::TimeTicks now = cast_environment_->Clock()->NowTicks(); | 327 base::TimeTicks now = cast_environment_->Clock()->NowTicks(); |
326 congestion_control_.AckFrame(cast_feedback.ack_frame_id_, now); | 328 congestion_control_.AckFrame(cast_feedback.ack_frame_id_, now); |
327 | 329 |
328 RtpTimestamp rtp_timestamp = | 330 RtpTimestamp rtp_timestamp = |
329 frame_id_to_rtp_timestamp_[cast_feedback.ack_frame_id_ & 0xff]; | 331 frame_id_to_rtp_timestamp_[cast_feedback.ack_frame_id_ & 0xff]; |
330 cast_environment_->Logging()->InsertFrameEvent(now, | 332 cast_environment_->Logging()->InsertFrameEvent(now, |
331 FRAME_ACK_RECEIVED, | 333 FRAME_ACK_RECEIVED, |
332 VIDEO_EVENT, | 334 VIDEO_EVENT, |
(...skipping 30 matching lines...) Expand all Loading... |
363 << " to kick-start."; | 365 << " to kick-start."; |
364 // Send the first packet of the last encoded frame to kick start | 366 // Send the first packet of the last encoded frame to kick start |
365 // retransmission. This gives enough information to the receiver what | 367 // retransmission. This gives enough information to the receiver what |
366 // packets and frames are missing. | 368 // packets and frames are missing. |
367 MissingFramesAndPacketsMap missing_frames_and_packets; | 369 MissingFramesAndPacketsMap missing_frames_and_packets; |
368 PacketIdSet missing; | 370 PacketIdSet missing; |
369 missing.insert(0); | 371 missing.insert(0); |
370 missing_frames_and_packets.insert( | 372 missing_frames_and_packets.insert( |
371 std::make_pair(last_sent_frame_id_, missing)); | 373 std::make_pair(last_sent_frame_id_, missing)); |
372 last_send_time_ = cast_environment_->Clock()->NowTicks(); | 374 last_send_time_ = cast_environment_->Clock()->NowTicks(); |
373 transport_sender_->ResendPackets(false, missing_frames_and_packets); | 375 |
| 376 // Sending this extra packet is to kick-start the session. There is |
| 377 // no need to optimize re-transmission for this case. |
| 378 transport_sender_->ResendPackets(false, missing_frames_and_packets, |
| 379 false); |
374 } | 380 } |
375 | 381 |
376 } // namespace cast | 382 } // namespace cast |
377 } // namespace media | 383 } // namespace media |
OLD | NEW |