Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1079)

Unified Diff: webrtc/modules/audio_coding/neteq/tools/rtc_event_log_source.cc

Issue 2005873002: Let PacketSource::NextPacket() return an std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/audio_coding/neteq/tools/rtc_event_log_source.cc
diff --git a/webrtc/modules/audio_coding/neteq/tools/rtc_event_log_source.cc b/webrtc/modules/audio_coding/neteq/tools/rtc_event_log_source.cc
index 9192839be30566f5ffe2d295cc005e57cb5e182a..517458bf9448e8429863be3755f0eb5ab6c65346 100644
--- a/webrtc/modules/audio_coding/neteq/tools/rtc_event_log_source.cc
+++ b/webrtc/modules/audio_coding/neteq/tools/rtc_event_log_source.cc
@@ -39,7 +39,7 @@ bool RtcEventLogSource::RegisterRtpHeaderExtension(RTPExtensionType type,
return parser_->RegisterRtpHeaderExtension(type, id);
}
-Packet* RtcEventLogSource::NextPacket() {
+std::unique_ptr<Packet> RtcEventLogSource::NextPacket() {
while (rtp_packet_index_ < parsed_stream_.GetNumberOfEvents()) {
if (parsed_stream_.GetEventType(rtp_packet_index_) ==
ParsedRtcEventLog::RTP_EVENT) {
@@ -54,9 +54,9 @@ Packet* RtcEventLogSource::NextPacket() {
uint8_t* packet_header = new uint8_t[header_length];
parsed_stream_.GetRtpHeader(rtp_packet_index_, nullptr, nullptr,
packet_header, nullptr, nullptr);
- Packet* packet = new Packet(packet_header, header_length, packet_length,
- static_cast<double>(timestamp_us) / 1000,
- *parser_.get());
+ std::unique_ptr<Packet> packet(new Packet(
+ packet_header, header_length, packet_length,
+ static_cast<double>(timestamp_us) / 1000, *parser_.get()));
if (packet->valid_header()) {
// Check if the packet should not be filtered out.
if (!filter_.test(packet->header().payloadType) &&
@@ -69,9 +69,6 @@ Packet* RtcEventLogSource::NextPacket() {
<< " has an invalid header and will be ignored."
<< std::endl;
}
- // The packet has either an invalid header or needs to be filtered out,
- // so it can be deleted.
- delete packet;
}
}
rtp_packet_index_++;
« no previous file with comments | « webrtc/modules/audio_coding/neteq/tools/rtc_event_log_source.h ('k') | webrtc/modules/audio_coding/neteq/tools/rtp_analyze.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698