Add error logs to RtpPacketHistory::GetBestFittingPacket when no packet is found.
Make sure nullptr is returned if the packet is not in history. Bug: webrtc:9863 Change-Id: I9658b1b271071a4bd38f062ed68c60cc04c63123 Reviewed-on: https://webrtc-review.googlesource.com/c/105300 Commit-Queue: Erik Språng <sprang@webrtc.org> Reviewed-by: Erik Språng <sprang@webrtc.org> Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Cr-Commit-Position: refs/heads/master@{#25114}
This commit is contained in:
parent
ade98c928b
commit
f81170b48f
@ -97,6 +97,15 @@ void RtpPacketHistory::PutRtpPacket(std::unique_ptr<RtpPacketToSend> packet,
|
||||
const uint16_t rtp_seq_no = packet->SequenceNumber();
|
||||
StoredPacket& stored_packet = packet_history_[rtp_seq_no];
|
||||
RTC_DCHECK(stored_packet.packet == nullptr);
|
||||
if (stored_packet.packet) {
|
||||
// It is an error if this happen. But it can happen if the sequence numbers
|
||||
// for some reason restart without that the history has been reset.
|
||||
auto size_iterator = packet_size_.find(stored_packet.packet->size());
|
||||
if (size_iterator != packet_size_.end() &&
|
||||
size_iterator->second == stored_packet.packet->SequenceNumber()) {
|
||||
packet_size_.erase(size_iterator);
|
||||
}
|
||||
}
|
||||
stored_packet.packet = std::move(packet);
|
||||
|
||||
if (stored_packet.packet->capture_time_ms() <= 0) {
|
||||
@ -209,8 +218,19 @@ std::unique_ptr<RtpPacketToSend> RtpPacketHistory::GetBestFittingPacket(
|
||||
const uint16_t seq_no = upper_bound_diff < lower_bound_diff
|
||||
? size_iter_upper->second
|
||||
: size_iter_lower->second;
|
||||
RtpPacketToSend* best_packet =
|
||||
packet_history_.find(seq_no)->second.packet.get();
|
||||
auto history_it = packet_history_.find(seq_no);
|
||||
if (history_it == packet_history_.end()) {
|
||||
RTC_LOG(LS_ERROR) << "Can't find packet in history with seq_no" << seq_no;
|
||||
RTC_DCHECK(false);
|
||||
return nullptr;
|
||||
}
|
||||
if (!history_it->second.packet) {
|
||||
RTC_LOG(LS_ERROR) << "Packet pointer is null in history for seq_no"
|
||||
<< seq_no;
|
||||
RTC_DCHECK(false);
|
||||
return nullptr;
|
||||
}
|
||||
RtpPacketToSend* best_packet = history_it->second.packet.get();
|
||||
return absl::make_unique<RtpPacketToSend>(*best_packet);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user