Re-enable PCAP reading in neteq_rtpplay

Reading of PCAP (Wireshark) files was not possible due to a bug in the
parsing of files. This change fixes that by adding new validator methods
to RtpFileSource that can be used to determine the input file type.

R=ivoc@webrtc.org

Review URL: https://codereview.webrtc.org/1427923003

Cr-Commit-Position: refs/heads/master@{#10490}
This commit is contained in:
henrik.lundin
2015-11-03 00:32:09 -08:00
committed by Commit bot
parent 32a6eae610
commit 5eb9d57883
3 changed files with 19 additions and 14 deletions

View File

@ -399,23 +399,12 @@ int main(int argc, char* argv[]) {
printf("Input file: %s\n", argv[1]);
// TODO(ivoc): Modify the RtpFileSource::Create and RtcEventLogSource::Create
// functions to return a nullptr on failure instead of crashing
// the program.
// This temporary solution uses a RtpFileReader directly to check if the file
// is a valid RtpDump file.
bool is_rtp_dump = false;
{
rtc::scoped_ptr<webrtc::test::RtpFileReader> rtp_reader(
webrtc::test::RtpFileReader::Create(
webrtc::test::RtpFileReader::kRtpDump, argv[1]));
if (rtp_reader)
is_rtp_dump = true;
}
rtc::scoped_ptr<webrtc::test::PacketSource> file_source;
webrtc::test::RtcEventLogSource* event_log_source = nullptr;
if (is_rtp_dump) {
if (webrtc::test::RtpFileSource::ValidRtpDump(argv[1]) ||
webrtc::test::RtpFileSource::ValidPcap(argv[1])) {
is_rtp_dump = true;
file_source.reset(webrtc::test::RtpFileSource::Create(argv[1]));
} else {
event_log_source = webrtc::test::RtcEventLogSource::Create(argv[1]);

View File

@ -32,6 +32,18 @@ RtpFileSource* RtpFileSource::Create(const std::string& file_name) {
return source;
}
bool RtpFileSource::ValidRtpDump(const std::string& file_name) {
rtc::scoped_ptr<RtpFileReader> temp_file(
RtpFileReader::Create(RtpFileReader::kRtpDump, file_name));
return !!temp_file;
}
bool RtpFileSource::ValidPcap(const std::string& file_name) {
rtc::scoped_ptr<RtpFileReader> temp_file(
RtpFileReader::Create(RtpFileReader::kPcap, file_name));
return !!temp_file;
}
RtpFileSource::~RtpFileSource() {
}

View File

@ -34,6 +34,10 @@ class RtpFileSource : public PacketSource {
// opened, or has the wrong format, NULL will be returned.
static RtpFileSource* Create(const std::string& file_name);
// Checks whether a files is a valid RTP dump or PCAP (Wireshark) file.
static bool ValidRtpDump(const std::string& file_name);
static bool ValidPcap(const std::string& file_name);
virtual ~RtpFileSource();
// Registers an RTP header extension and binds it to |id|.