1 /* 2 * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #include "modules/audio_coding/neteq/tools/neteq_event_log_input.h" 12 13 #include <limits> 14 #include <memory> 15 16 #include "modules/audio_coding/neteq/tools/rtc_event_log_source.h" 17 #include "rtc_base/checks.h" 18 19 namespace webrtc { 20 namespace test { 21 CreateFromFile(const std::string & file_name,absl::optional<uint32_t> ssrc_filter)22NetEqEventLogInput* NetEqEventLogInput::CreateFromFile( 23 const std::string& file_name, 24 absl::optional<uint32_t> ssrc_filter) { 25 auto event_log_src = 26 RtcEventLogSource::CreateFromFile(file_name, ssrc_filter); 27 if (!event_log_src) { 28 return nullptr; 29 } 30 return new NetEqEventLogInput(std::move(event_log_src)); 31 } 32 CreateFromString(const std::string & file_contents,absl::optional<uint32_t> ssrc_filter)33NetEqEventLogInput* NetEqEventLogInput::CreateFromString( 34 const std::string& file_contents, 35 absl::optional<uint32_t> ssrc_filter) { 36 auto event_log_src = 37 RtcEventLogSource::CreateFromString(file_contents, ssrc_filter); 38 if (!event_log_src) { 39 return nullptr; 40 } 41 return new NetEqEventLogInput(std::move(event_log_src)); 42 } 43 NextOutputEventTime() const44absl::optional<int64_t> NetEqEventLogInput::NextOutputEventTime() const { 45 return next_output_event_ms_; 46 } 47 AdvanceOutputEvent()48void NetEqEventLogInput::AdvanceOutputEvent() { 49 next_output_event_ms_ = source_->NextAudioOutputEventMs(); 50 if (*next_output_event_ms_ == std::numeric_limits<int64_t>::max()) { 51 next_output_event_ms_ = absl::nullopt; 52 } 53 } 54 source()55PacketSource* NetEqEventLogInput::source() { 56 return source_.get(); 57 } 58 NetEqEventLogInput(std::unique_ptr<RtcEventLogSource> source)59NetEqEventLogInput::NetEqEventLogInput( 60 std::unique_ptr<RtcEventLogSource> source) 61 : source_(std::move(source)) { 62 LoadNextPacket(); 63 AdvanceOutputEvent(); 64 } 65 66 } // namespace test 67 } // namespace webrtc 68