Chromium Code Reviews| 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/net/rtp/rtp_sender.h" | 5 #include "media/cast/net/rtp/rtp_sender.h" |
| 6 | 6 |
| 7 #include "base/big_endian.h" | 7 #include "base/big_endian.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/rand_util.h" | 9 #include "base/rand_util.h" |
| 10 #include "media/cast/net/cast_transport_defines.h" | 10 #include "media/cast/net/cast_transport_defines.h" |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 110 UpdateSequenceNumber(&packet_copy->data); | 110 UpdateSequenceNumber(&packet_copy->data); |
| 111 packets_to_resend.push_back(std::make_pair(packet_key, packet_copy)); | 111 packets_to_resend.push_back(std::make_pair(packet_key, packet_copy)); |
| 112 } else if (cancel_rtx_if_not_in_list) { | 112 } else if (cancel_rtx_if_not_in_list) { |
| 113 transport_->CancelSendingPacket(it->first); | 113 transport_->CancelSendingPacket(it->first); |
| 114 } | 114 } |
| 115 } | 115 } |
| 116 transport_->ResendPackets(packets_to_resend, dedupe_window); | 116 transport_->ResendPackets(packets_to_resend, dedupe_window); |
| 117 } | 117 } |
| 118 } | 118 } |
| 119 | 119 |
| 120 void RtpSender::CancelSendingFrames(const std::set<uint32>& frame_ids) { | |
| 121 // Cancel resends of acked frames. | |
| 122 MissingFramesAndPacketsMap missing_frames_and_packets; | |
| 123 PacketIdSet missing; | |
| 124 for (std::set<uint32>::const_iterator it = frame_ids.begin(); | |
| 125 it != frame_ids.end(); ++it) { | |
| 126 missing_frames_and_packets[*it] = missing; | |
| 127 } | |
| 128 ResendPackets(missing_frames_and_packets, true, base::TimeDelta()); | |
|
hubbe
2014/08/12 18:24:11
Why go through ResendPackets()?
Seems like you jus
Alpha Left Google
2014/08/12 23:57:39
Done.
| |
| 129 } | |
| 130 | |
| 131 void RtpSender::ResendFrameForKickstart(uint32 frame_id, | |
| 132 base::TimeDelta dedupe_window) { | |
| 133 // Send the last packet of the encoded frame to kick start | |
| 134 // retransmission. This gives enough information to the receiver what | |
| 135 // packets and frames are missing. | |
| 136 MissingFramesAndPacketsMap missing_frames_and_packets; | |
| 137 PacketIdSet missing; | |
| 138 missing.insert(kRtcpCastLastPacket); | |
| 139 missing_frames_and_packets.insert(std::make_pair(frame_id, missing)); | |
| 140 | |
| 141 // Sending this extra packet is to kick-start the session. There is | |
| 142 // no need to optimize re-transmission for this case. | |
| 143 ResendPackets(missing_frames_and_packets, false, dedupe_window); | |
| 144 } | |
| 145 | |
| 120 void RtpSender::UpdateSequenceNumber(Packet* packet) { | 146 void RtpSender::UpdateSequenceNumber(Packet* packet) { |
| 121 // TODO(miu): This is an abstraction violation. This needs to be a part of | 147 // TODO(miu): This is an abstraction violation. This needs to be a part of |
| 122 // the overall packet (de)serialization consolidation. | 148 // the overall packet (de)serialization consolidation. |
| 123 static const int kByteOffsetToSequenceNumber = 2; | 149 static const int kByteOffsetToSequenceNumber = 2; |
| 124 base::BigEndianWriter big_endian_writer( | 150 base::BigEndianWriter big_endian_writer( |
| 125 reinterpret_cast<char*>((&packet->front()) + kByteOffsetToSequenceNumber), | 151 reinterpret_cast<char*>((&packet->front()) + kByteOffsetToSequenceNumber), |
| 126 sizeof(uint16)); | 152 sizeof(uint16)); |
| 127 big_endian_writer.WriteU16(packetizer_->NextSequenceNumber()); | 153 big_endian_writer.WriteU16(packetizer_->NextSequenceNumber()); |
| 128 } | 154 } |
| 129 | 155 |
| 130 } // namespace cast | 156 } // namespace cast |
| 131 } // namespace media | 157 } // namespace media |
| OLD | NEW |