Break out NetEqEventLogInput to separate source files

Building NetEqEventLogInput requires protobuf support, while building
NetEqRtpDumpInput located in the same file does not. This makes both
classes unusable when protobuf support is lacking. With this CL, the
NetEqEventLogInput is broken out into separate files, to allow usage
of NetEqRtpDumpInput even when protobufs are not supported.

Bug: webrtc:9421
Change-Id: I55efec4ec259713654566cdaa00d2e34c5e9a60f
Reviewed-on: https://webrtc-review.googlesource.com/84587
Commit-Queue: Henrik Lundin <henrik.lundin@webrtc.org>
Reviewed-by: Ivo Creusen <ivoc@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23803}
This commit is contained in:
Henrik Lundin 2018-07-02 14:05:37 +02:00 committed by Commit Bot
parent 64cb83bbd9
commit 9f2e624024
7 changed files with 97 additions and 51 deletions

View File

@ -1209,6 +1209,8 @@ rtc_source_set("neteq_test_tools") {
"neteq/tools/audio_loop.h", "neteq/tools/audio_loop.h",
"neteq/tools/constant_pcm_packet_source.cc", "neteq/tools/constant_pcm_packet_source.cc",
"neteq/tools/constant_pcm_packet_source.h", "neteq/tools/constant_pcm_packet_source.h",
"neteq/tools/neteq_packet_source_input.cc",
"neteq/tools/neteq_packet_source_input.h",
"neteq/tools/output_audio_file.h", "neteq/tools/output_audio_file.h",
"neteq/tools/output_wav_file.h", "neteq/tools/output_wav_file.h",
"neteq/tools/rtp_file_source.cc", "neteq/tools/rtp_file_source.cc",
@ -1247,8 +1249,8 @@ rtc_source_set("neteq_test_tools") {
if (rtc_enable_protobuf) { if (rtc_enable_protobuf) {
sources += [ sources += [
"neteq/tools/neteq_packet_source_input.cc", "neteq/tools/neteq_event_log_input.cc",
"neteq/tools/neteq_packet_source_input.h", "neteq/tools/neteq_event_log_input.h",
] ]
deps += [ ":rtc_event_log_source" ] deps += [ ":rtc_event_log_source" ]
} }

View File

@ -1726,10 +1726,6 @@ TEST_F(NetEqDecodingTestFaxMode, TestJitterBufferDelayWithLoss) {
} }
namespace test { namespace test {
// TODO(henrik.lundin) NetEqRtpDumpInput requires protobuf support. It shouldn't
// need it, but because it is bundled with NetEqEventLogInput, it is neded.
// This should be refactored.
#if WEBRTC_ENABLE_PROTOBUF
TEST(NetEqNoTimeStretchingMode, RunTest) { TEST(NetEqNoTimeStretchingMode, RunTest) {
NetEq::Config config; NetEq::Config config;
config.for_test_no_time_stretching = true; config.for_test_no_time_stretching = true;
@ -1755,7 +1751,6 @@ TEST(NetEqNoTimeStretchingMode, RunTest) {
EXPECT_EQ(0, stats.accelerate_rate); EXPECT_EQ(0, stats.accelerate_rate);
EXPECT_EQ(0, stats.preemptive_rate); EXPECT_EQ(0, stats.preemptive_rate);
} }
#endif
} // namespace test } // namespace test
} // namespace webrtc } // namespace webrtc

View File

@ -0,0 +1,47 @@
/*
* Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "modules/audio_coding/neteq/tools/neteq_event_log_input.h"
#include <limits>
#include "modules/audio_coding/neteq/tools/rtc_event_log_source.h"
#include "rtc_base/checks.h"
namespace webrtc {
namespace test {
NetEqEventLogInput::NetEqEventLogInput(const std::string& file_name,
const RtpHeaderExtensionMap& hdr_ext_map)
: source_(RtcEventLogSource::Create(file_name)) {
for (const auto& ext_pair : hdr_ext_map) {
source_->RegisterRtpHeaderExtension(ext_pair.second, ext_pair.first);
}
LoadNextPacket();
AdvanceOutputEvent();
}
absl::optional<int64_t> NetEqEventLogInput::NextOutputEventTime() const {
return next_output_event_ms_;
}
void NetEqEventLogInput::AdvanceOutputEvent() {
next_output_event_ms_ = source_->NextAudioOutputEventMs();
if (*next_output_event_ms_ == std::numeric_limits<int64_t>::max()) {
next_output_event_ms_ = absl::nullopt;
}
}
PacketSource* NetEqEventLogInput::source() {
return source_.get();
}
} // namespace test
} // namespace webrtc

View File

@ -0,0 +1,45 @@
/*
* Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef MODULES_AUDIO_CODING_NETEQ_TOOLS_NETEQ_EVENT_LOG_INPUT_H_
#define MODULES_AUDIO_CODING_NETEQ_TOOLS_NETEQ_EVENT_LOG_INPUT_H_
#include <map>
#include <memory>
#include <string>
#include "modules/audio_coding/neteq/tools/neteq_packet_source_input.h"
#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
namespace webrtc {
namespace test {
class RtcEventLogSource;
// Implementation of NetEqPacketSourceInput to be used with an
// RtcEventLogSource.
class NetEqEventLogInput final : public NetEqPacketSourceInput {
public:
NetEqEventLogInput(const std::string& file_name,
const RtpHeaderExtensionMap& hdr_ext_map);
absl::optional<int64_t> NextOutputEventTime() const override;
void AdvanceOutputEvent() override;
protected:
PacketSource* source() override;
private:
std::unique_ptr<RtcEventLogSource> source_;
};
} // namespace test
} // namespace webrtc
#endif // MODULES_AUDIO_CODING_NETEQ_TOOLS_NETEQ_EVENT_LOG_INPUT_H_

View File

@ -13,7 +13,6 @@
#include <algorithm> #include <algorithm>
#include <limits> #include <limits>
#include "modules/audio_coding/neteq/tools/rtc_event_log_source.h"
#include "modules/audio_coding/neteq/tools/rtp_file_source.h" #include "modules/audio_coding/neteq/tools/rtp_file_source.h"
#include "rtc_base/checks.h" #include "rtc_base/checks.h"
@ -91,30 +90,5 @@ PacketSource* NetEqRtpDumpInput::source() {
return source_.get(); return source_.get();
} }
NetEqEventLogInput::NetEqEventLogInput(const std::string& file_name,
const RtpHeaderExtensionMap& hdr_ext_map)
: source_(RtcEventLogSource::Create(file_name)) {
for (const auto& ext_pair : hdr_ext_map) {
source_->RegisterRtpHeaderExtension(ext_pair.second, ext_pair.first);
}
LoadNextPacket();
AdvanceOutputEvent();
}
absl::optional<int64_t> NetEqEventLogInput::NextOutputEventTime() const {
return next_output_event_ms_;
}
void NetEqEventLogInput::AdvanceOutputEvent() {
next_output_event_ms_ = source_->NextAudioOutputEventMs();
if (*next_output_event_ms_ == std::numeric_limits<int64_t>::max()) {
next_output_event_ms_ = absl::nullopt;
}
}
PacketSource* NetEqEventLogInput::source() {
return source_.get();
}
} // namespace test } // namespace test
} // namespace webrtc } // namespace webrtc

View File

@ -21,7 +21,6 @@ namespace webrtc {
namespace test { namespace test {
class RtpFileSource; class RtpFileSource;
class RtcEventLogSource;
// An adapter class to dress up a PacketSource object as a NetEqInput. // An adapter class to dress up a PacketSource object as a NetEqInput.
class NetEqPacketSourceInput : public NetEqInput { class NetEqPacketSourceInput : public NetEqInput {
@ -63,23 +62,6 @@ class NetEqRtpDumpInput final : public NetEqPacketSourceInput {
std::unique_ptr<RtpFileSource> source_; std::unique_ptr<RtpFileSource> source_;
}; };
// Implementation of NetEqPacketSourceInput to be used with an
// RtcEventLogSource.
class NetEqEventLogInput final : public NetEqPacketSourceInput {
public:
NetEqEventLogInput(const std::string& file_name,
const RtpHeaderExtensionMap& hdr_ext_map);
absl::optional<int64_t> NextOutputEventTime() const override;
void AdvanceOutputEvent() override;
protected:
PacketSource* source() override;
private:
std::unique_ptr<RtcEventLogSource> source_;
};
} // namespace test } // namespace test
} // namespace webrtc } // namespace webrtc
#endif // MODULES_AUDIO_CODING_NETEQ_TOOLS_NETEQ_PACKET_SOURCE_INPUT_H_ #endif // MODULES_AUDIO_CODING_NETEQ_TOOLS_NETEQ_PACKET_SOURCE_INPUT_H_

View File

@ -21,6 +21,7 @@
#include "modules/audio_coding/neteq/tools/fake_decode_from_file.h" #include "modules/audio_coding/neteq/tools/fake_decode_from_file.h"
#include "modules/audio_coding/neteq/tools/input_audio_file.h" #include "modules/audio_coding/neteq/tools/input_audio_file.h"
#include "modules/audio_coding/neteq/tools/neteq_delay_analyzer.h" #include "modules/audio_coding/neteq/tools/neteq_delay_analyzer.h"
#include "modules/audio_coding/neteq/tools/neteq_event_log_input.h"
#include "modules/audio_coding/neteq/tools/neteq_packet_source_input.h" #include "modules/audio_coding/neteq/tools/neteq_packet_source_input.h"
#include "modules/audio_coding/neteq/tools/neteq_replacement_input.h" #include "modules/audio_coding/neteq/tools/neteq_replacement_input.h"
#include "modules/audio_coding/neteq/tools/neteq_stats_getter.h" #include "modules/audio_coding/neteq/tools/neteq_stats_getter.h"