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/logging.h" | 7 #include "base/logging.h" |
8 #include "base/rand_util.h" | 8 #include "base/rand_util.h" |
9 #include "media/cast/transport/cast_transport_defines.h" | 9 #include "media/cast/transport/cast_transport_defines.h" |
10 #include "media/cast/transport/pacing/paced_sender.h" | 10 #include "media/cast/transport/pacing/paced_sender.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
66 // Iterate over all frames in the list. | 66 // Iterate over all frames in the list. |
67 for (MissingFramesAndPacketsMap::const_iterator it = | 67 for (MissingFramesAndPacketsMap::const_iterator it = |
68 missing_frames_and_packets.begin(); | 68 missing_frames_and_packets.begin(); |
69 it != missing_frames_and_packets.end(); | 69 it != missing_frames_and_packets.end(); |
70 ++it) { | 70 ++it) { |
71 SendPacketVector packets_to_resend; | 71 SendPacketVector packets_to_resend; |
72 uint8 frame_id = it->first; | 72 uint8 frame_id = it->first; |
73 const PacketIdSet& packets_set = it->second; | 73 const PacketIdSet& packets_set = it->second; |
74 bool success = false; | 74 bool success = false; |
75 | 75 |
76 if (packets_set.empty()) { | 76 for (uint16 packet_id = 0; ; packet_id++) { |
77 VLOG(3) << "Missing all packets in frame " << static_cast<int>(frame_id); | 77 // Get packet from storage. |
78 success = storage_->GetPacket(frame_id, packet_id, &packets_to_resend); | |
78 | 79 |
79 uint16 packet_id = 0; | 80 // Check that we got at least one packet. |
80 do { | 81 DCHECK(packet_id != 0 || success) |
81 // Get packet from storage. | 82 << "Failed to resend frame " << static_cast<int>(frame_id); |
82 success = storage_->GetPacket(frame_id, packet_id, &packets_to_resend); | |
83 | 83 |
84 // Check that we got at least one packet. | 84 if (!success) break; |
85 DCHECK(packet_id != 0 || success) | |
86 << "Failed to resend frame " << static_cast<int>(frame_id); | |
87 | 85 |
86 if (packets_set.find(packet_id) == packets_set.end()) { | |
87 transport_->CancelSendingPacket(packets_to_resend.back().first); | |
88 packets_to_resend.pop_back(); | |
89 } else { | |
88 // Resend packet to the network. | 90 // Resend packet to the network. |
89 if (success) { | 91 if (success) { |
miu
2014/05/29 06:20:37
You can remove this if-statement now. With your c
hubbe
2014/05/29 19:17:23
Done.
| |
90 VLOG(3) << "Resend " << static_cast<int>(frame_id) << ":" | 92 VLOG(3) << "Resend " << static_cast<int>(frame_id) << ":" |
91 << packet_id; | 93 << packet_id; |
92 // Set a unique incremental sequence number for every packet. | 94 // Set a unique incremental sequence number for every packet. |
93 PacketRef packet = packets_to_resend.back().second; | 95 PacketRef packet = packets_to_resend.back().second; |
94 UpdateSequenceNumber(&packet->data); | 96 UpdateSequenceNumber(&packet->data); |
95 // Set the size as correspond to each frame. | 97 // Set the size as correspond to each frame. |
miu
2014/05/29 06:20:37
I don't understand this comment. Should this LOC
hubbe
2014/05/29 19:17:23
I looked up the change that added this comment, I
| |
96 ++packet_id; | |
97 } | |
98 } while (success); | |
99 } else { | |
100 // Iterate over all of the packets in the frame. | |
101 for (PacketIdSet::const_iterator set_it = packets_set.begin(); | |
102 set_it != packets_set.end(); | |
103 ++set_it) { | |
104 uint16 packet_id = *set_it; | |
105 success = storage_->GetPacket(frame_id, packet_id, &packets_to_resend); | |
106 | |
107 // Check that we got at least one packet. | |
108 DCHECK(set_it != packets_set.begin() || success) | |
109 << "Failed to resend frame " << frame_id; | |
110 | |
111 // Resend packet to the network. | |
112 if (success) { | |
113 VLOG(3) << "Resend " << static_cast<int>(frame_id) << ":" | |
114 << packet_id; | |
115 PacketRef packet = packets_to_resend.back().second; | |
116 UpdateSequenceNumber(&packet->data); | |
117 } | 98 } |
118 } | 99 } |
119 } | 100 } |
120 transport_->ResendPackets(packets_to_resend); | 101 transport_->ResendPackets(packets_to_resend); |
121 } | 102 } |
122 } | 103 } |
123 | 104 |
124 void RtpSender::UpdateSequenceNumber(Packet* packet) { | 105 void RtpSender::UpdateSequenceNumber(Packet* packet) { |
125 uint16 new_sequence_number = packetizer_->NextSequenceNumber(); | 106 uint16 new_sequence_number = packetizer_->NextSequenceNumber(); |
126 int index = 2; | 107 int index = 2; |
127 (*packet)[index] = (static_cast<uint8>(new_sequence_number)); | 108 (*packet)[index] = (static_cast<uint8>(new_sequence_number)); |
128 (*packet)[index + 1] = (static_cast<uint8>(new_sequence_number >> 8)); | 109 (*packet)[index + 1] = (static_cast<uint8>(new_sequence_number >> 8)); |
129 } | 110 } |
130 | 111 |
131 } // namespace transport | 112 } // namespace transport |
132 } // namespace cast | 113 } // namespace cast |
133 } // namespace media | 114 } // namespace media |
OLD | NEW |