void SrsRtpFrameBuffer::ShiftSubsequentPackets(PacketIterator it,
int steps_toshift)
{
if (it != packets.end()) {
++it;
}
if (it == packets_.end()) {
return;
}
uint8_t* first_packet_ptr = const_cast<uint8_t*>((*it).dataPtr);
int shift_length = 0;
// Calculate the total move length and move the data pointers in advance.
for (; it != packets_.end(); ++it) {
shift_length += (*it).sizeBytes;
if ((*it).dataPtr != NULL) {
(*it).dataPtr += steps_to_shift;
}
}
memmove(first_packet_ptr + steps_to_shift, first_packet_ptr, shift_length);
修正如下:
void SrsRtpFrameBuffer::ShiftSubsequentPackets(PacketIterator it, int steps_toshift) { if (it != packets.end()) { ++it; } if (it == packets_.end()) { return; }
}