| 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/transport/rtp_sender/rtp_sender.h" | 5 #include "media/cast/transport/rtp_sender/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/transport/cast_transport_defines.h" | 10 #include "media/cast/transport/cast_transport_defines.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 return true; | 69 return true; |
| 70 } | 70 } |
| 71 | 71 |
| 72 void RtpSender::SendFrame(const EncodedFrame& frame) { | 72 void RtpSender::SendFrame(const EncodedFrame& frame) { |
| 73 DCHECK(packetizer_); | 73 DCHECK(packetizer_); |
| 74 packetizer_->SendFrameAsPackets(frame); | 74 packetizer_->SendFrameAsPackets(frame); |
| 75 } | 75 } |
| 76 | 76 |
| 77 void RtpSender::ResendPackets( | 77 void RtpSender::ResendPackets( |
| 78 const MissingFramesAndPacketsMap& missing_frames_and_packets, | 78 const MissingFramesAndPacketsMap& missing_frames_and_packets, |
| 79 bool cancel_rtx_if_not_in_list) { | 79 bool cancel_rtx_if_not_in_list, |
| 80 base::TimeDelta dedupe_window) { |
| 80 DCHECK(storage_); | 81 DCHECK(storage_); |
| 81 // Iterate over all frames in the list. | 82 // Iterate over all frames in the list. |
| 82 for (MissingFramesAndPacketsMap::const_iterator it = | 83 for (MissingFramesAndPacketsMap::const_iterator it = |
| 83 missing_frames_and_packets.begin(); | 84 missing_frames_and_packets.begin(); |
| 84 it != missing_frames_and_packets.end(); | 85 it != missing_frames_and_packets.end(); |
| 85 ++it) { | 86 ++it) { |
| 86 SendPacketVector packets_to_resend; | 87 SendPacketVector packets_to_resend; |
| 87 uint8 frame_id = it->first; | 88 uint8 frame_id = it->first; |
| 88 // Set of packets that the receiver wants us to re-send. | 89 // Set of packets that the receiver wants us to re-send. |
| 89 // If empty, we need to re-send all packets for this frame. | 90 // If empty, we need to re-send all packets for this frame. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 VLOG(3) << "Resend " << static_cast<int>(frame_id) << ":" | 124 VLOG(3) << "Resend " << static_cast<int>(frame_id) << ":" |
| 124 << packet_id; | 125 << packet_id; |
| 125 // Set a unique incremental sequence number for every packet. | 126 // Set a unique incremental sequence number for every packet. |
| 126 PacketRef packet_copy = FastCopyPacket(it->second); | 127 PacketRef packet_copy = FastCopyPacket(it->second); |
| 127 UpdateSequenceNumber(&packet_copy->data); | 128 UpdateSequenceNumber(&packet_copy->data); |
| 128 packets_to_resend.push_back(std::make_pair(packet_key, packet_copy)); | 129 packets_to_resend.push_back(std::make_pair(packet_key, packet_copy)); |
| 129 } else if (cancel_rtx_if_not_in_list) { | 130 } else if (cancel_rtx_if_not_in_list) { |
| 130 transport_->CancelSendingPacket(it->first); | 131 transport_->CancelSendingPacket(it->first); |
| 131 } | 132 } |
| 132 } | 133 } |
| 133 transport_->ResendPackets(packets_to_resend); | 134 transport_->ResendPackets(packets_to_resend, dedupe_window); |
| 134 } | 135 } |
| 135 } | 136 } |
| 136 | 137 |
| 137 void RtpSender::UpdateSequenceNumber(Packet* packet) { | 138 void RtpSender::UpdateSequenceNumber(Packet* packet) { |
| 138 // TODO(miu): This is an abstraction violation. This needs to be a part of | 139 // TODO(miu): This is an abstraction violation. This needs to be a part of |
| 139 // the overall packet (de)serialization consolidation. | 140 // the overall packet (de)serialization consolidation. |
| 140 static const int kByteOffsetToSequenceNumber = 2; | 141 static const int kByteOffsetToSequenceNumber = 2; |
| 141 base::BigEndianWriter big_endian_writer( | 142 base::BigEndianWriter big_endian_writer( |
| 142 reinterpret_cast<char*>((&packet->front()) + kByteOffsetToSequenceNumber), | 143 reinterpret_cast<char*>((&packet->front()) + kByteOffsetToSequenceNumber), |
| 143 sizeof(uint16)); | 144 sizeof(uint16)); |
| 144 big_endian_writer.WriteU16(packetizer_->NextSequenceNumber()); | 145 big_endian_writer.WriteU16(packetizer_->NextSequenceNumber()); |
| 145 } | 146 } |
| 146 | 147 |
| 147 } // namespace transport | 148 } // namespace transport |
| 148 } // namespace cast | 149 } // namespace cast |
| 149 } // namespace media | 150 } // namespace media |
| OLD | NEW |