From ed04912ccd6ec7b00584cf1a63ec49e7ae32929e Mon Sep 17 00:00:00 2001 From: Ivo Creusen Date: Mon, 15 Oct 2018 09:55:51 +0200 Subject: [PATCH] Stop simulations when a LOG_END event is reached. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a LOG_END event is reached, it makes no sense to continue simulating NetEq. Bug: webrtc:9667 Change-Id: Ie4f6811cdec0d0632f6e7906059e0e74e9f10438 Reviewed-on: https://webrtc-review.googlesource.com/c/105643 Reviewed-by: Björn Terelius Reviewed-by: Minyue Li Commit-Queue: Ivo Creusen Cr-Commit-Position: refs/heads/master@{#25176} --- .../neteq/tools/rtc_event_log_source.cc | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/modules/audio_coding/neteq/tools/rtc_event_log_source.cc b/modules/audio_coding/neteq/tools/rtc_event_log_source.cc index 9ba788996d..582c2f2f13 100644 --- a/modules/audio_coding/neteq/tools/rtc_event_log_source.cc +++ b/modules/audio_coding/neteq/tools/rtc_event_log_source.cc @@ -68,9 +68,16 @@ bool RtcEventLogSource::OpenFile(const std::string& file_name, if (!parsed_log.ParseFile(file_name)) return false; + const auto first_log_end_time_us = + parsed_log.stop_log_events().empty() + ? std::numeric_limits::max() + : parsed_log.stop_log_events().front().log_time_us(); + auto handle_rtp_packet = - [this](const webrtc::LoggedRtpPacketIncoming& incoming) { - if (!filter_.test(incoming.rtp.header.payloadType)) { + [this, + first_log_end_time_us](const webrtc::LoggedRtpPacketIncoming& incoming) { + if (!filter_.test(incoming.rtp.header.payloadType) && + incoming.log_time_us() < first_log_end_time_us) { rtp_packets_.emplace_back(absl::make_unique( incoming.rtp.header, incoming.rtp.total_length, incoming.rtp.total_length - incoming.rtp.header_length, @@ -79,8 +86,11 @@ bool RtcEventLogSource::OpenFile(const std::string& file_name, }; auto handle_audio_playout = - [this](const webrtc::LoggedAudioPlayoutEvent& audio_playout) { - audio_outputs_.emplace_back(audio_playout.log_time_ms()); + [this, first_log_end_time_us]( + const webrtc::LoggedAudioPlayoutEvent& audio_playout) { + if (audio_playout.log_time_us() < first_log_end_time_us) { + audio_outputs_.emplace_back(audio_playout.log_time_ms()); + } }; // This wouldn't be needed if we knew that there was at most one audio stream.