Minor modifications to test::RtpFileReader
Adding original_length to the Packet struct. This is populated with
the plen value from the RTP dump file. In the case of reading a
pcap file, original_length will be equal to length.
Also increasing the maximum packet size to 3500 bytes. This is to
accomodate some test files that contain PCM16b audio encoding.
R=pbos@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/28609004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@7333 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/webrtc/test/rtp_file_reader_unittest.cc b/webrtc/test/rtp_file_reader_unittest.cc
index b5fa260..54fb874 100644
--- a/webrtc/test/rtp_file_reader_unittest.cc
+++ b/webrtc/test/rtp_file_reader_unittest.cc
@@ -20,28 +20,40 @@
class TestRtpFileReader : public ::testing::Test {
public:
- void Init(const std::string& filename) {
+ void Init(const std::string& filename, bool headers_only_file) {
std::string filepath =
test::ResourcePath("video_coding/" + filename, "rtp");
rtp_packet_source_.reset(
test::RtpFileReader::Create(test::RtpFileReader::kRtpDump, filepath));
ASSERT_TRUE(rtp_packet_source_.get() != NULL);
+ headers_only_file_ = headers_only_file;
}
int CountRtpPackets() {
test::RtpFileReader::Packet packet;
int c = 0;
- while (rtp_packet_source_->NextPacket(&packet))
+ while (rtp_packet_source_->NextPacket(&packet)) {
+ if (headers_only_file_)
+ EXPECT_LT(packet.length, packet.original_length);
+ else
+ EXPECT_EQ(packet.length, packet.original_length);
c++;
+ }
return c;
}
private:
scoped_ptr<test::RtpFileReader> rtp_packet_source_;
+ bool headers_only_file_;
};
TEST_F(TestRtpFileReader, Test60Packets) {
- Init("pltype103");
+ Init("pltype103", false);
+ EXPECT_EQ(60, CountRtpPackets());
+}
+
+TEST_F(TestRtpFileReader, Test60PacketsHeaderOnly) {
+ Init("pltype103_header_only", true);
EXPECT_EQ(60, CountRtpPackets());
}
@@ -60,8 +72,10 @@
int CountRtpPackets() {
int c = 0;
test::RtpFileReader::Packet packet;
- while (rtp_packet_source_->NextPacket(&packet))
+ while (rtp_packet_source_->NextPacket(&packet)) {
+ EXPECT_EQ(packet.length, packet.original_length);
c++;
+ }
return c;
}