| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #include <map> | 11 #include <map> |
| 12 #include <memory> | 12 #include <memory> |
| 13 | 13 |
| 14 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h" | 14 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h" |
| 15 #include "webrtc/test/gtest.h" | 15 #include "webrtc/test/gtest.h" |
| 16 #include "webrtc/test/rtp_file_reader.h" | 16 #include "webrtc/test/rtp_file_reader.h" |
| 17 #include "webrtc/test/testsupport/fileutils.h" | 17 #include "webrtc/test/testsupport/fileutils.h" |
| 18 | 18 |
| 19 namespace webrtc { | 19 namespace webrtc { |
| 20 | 20 |
| 21 class TestRtpFileReader : public ::testing::Test { | 21 class TestRtpFileReader : public ::testing::Test { |
| 22 public: | 22 public: |
| 23 void Init(const std::string& filename, bool headers_only_file) { | 23 void Init(const std::string& filename, bool headers_only_file) { |
| 24 std::string filepath = | 24 std::string filepath = |
| 25 test::ResourcePath("video_coding/" + filename, "rtp"); | 25 test::ResourcePath("video_coding/" + filename, "rtp"); |
| 26 rtp_packet_source_.reset( | 26 rtp_packet_source_.reset( |
| 27 test::RtpFileReader::Create(test::RtpFileReader::kRtpDump, filepath)); | 27 test::RtpFileReader::Create(test::RtpFileReader::kRtpDump, filepath)); |
| 28 ASSERT_TRUE(rtp_packet_source_.get() != NULL); | 28 ASSERT_TRUE(rtp_packet_source_.get() != nullptr); |
| 29 headers_only_file_ = headers_only_file; | 29 headers_only_file_ = headers_only_file; |
| 30 } | 30 } |
| 31 | 31 |
| 32 int CountRtpPackets() { | 32 int CountRtpPackets() { |
| 33 test::RtpPacket packet; | 33 test::RtpPacket packet; |
| 34 int c = 0; | 34 int c = 0; |
| 35 while (rtp_packet_source_->NextPacket(&packet)) { | 35 while (rtp_packet_source_->NextPacket(&packet)) { |
| 36 if (headers_only_file_) | 36 if (headers_only_file_) |
| 37 EXPECT_LT(packet.length, packet.original_length); | 37 EXPECT_LT(packet.length, packet.original_length); |
| 38 else | 38 else |
| (...skipping 20 matching lines...) Expand all Loading... |
| 59 | 59 |
| 60 typedef std::map<uint32_t, int> PacketsPerSsrc; | 60 typedef std::map<uint32_t, int> PacketsPerSsrc; |
| 61 | 61 |
| 62 class TestPcapFileReader : public ::testing::Test { | 62 class TestPcapFileReader : public ::testing::Test { |
| 63 public: | 63 public: |
| 64 void Init(const std::string& filename) { | 64 void Init(const std::string& filename) { |
| 65 std::string filepath = | 65 std::string filepath = |
| 66 test::ResourcePath("video_coding/" + filename, "pcap"); | 66 test::ResourcePath("video_coding/" + filename, "pcap"); |
| 67 rtp_packet_source_.reset( | 67 rtp_packet_source_.reset( |
| 68 test::RtpFileReader::Create(test::RtpFileReader::kPcap, filepath)); | 68 test::RtpFileReader::Create(test::RtpFileReader::kPcap, filepath)); |
| 69 ASSERT_TRUE(rtp_packet_source_.get() != NULL); | 69 ASSERT_TRUE(rtp_packet_source_.get() != nullptr); |
| 70 } | 70 } |
| 71 | 71 |
| 72 int CountRtpPackets() { | 72 int CountRtpPackets() { |
| 73 int c = 0; | 73 int c = 0; |
| 74 test::RtpPacket packet; | 74 test::RtpPacket packet; |
| 75 while (rtp_packet_source_->NextPacket(&packet)) { | 75 while (rtp_packet_source_->NextPacket(&packet)) { |
| 76 EXPECT_EQ(packet.length, packet.original_length); | 76 EXPECT_EQ(packet.length, packet.original_length); |
| 77 c++; | 77 c++; |
| 78 } | 78 } |
| 79 return c; | 79 return c; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 | 117 |
| 118 TEST_F(TestPcapFileReader, TestThreeSsrc) { | 118 TEST_F(TestPcapFileReader, TestThreeSsrc) { |
| 119 Init("ssrcs-3"); | 119 Init("ssrcs-3"); |
| 120 PacketsPerSsrc pps = CountRtpPacketsPerSsrc(); | 120 PacketsPerSsrc pps = CountRtpPacketsPerSsrc(); |
| 121 EXPECT_EQ(3UL, pps.size()); | 121 EXPECT_EQ(3UL, pps.size()); |
| 122 EXPECT_EQ(162, pps[0x938c5eaa]); | 122 EXPECT_EQ(162, pps[0x938c5eaa]); |
| 123 EXPECT_EQ(113, pps[0x59fe6ef0]); | 123 EXPECT_EQ(113, pps[0x59fe6ef0]); |
| 124 EXPECT_EQ(61, pps[0xed2bd2ac]); | 124 EXPECT_EQ(61, pps[0xed2bd2ac]); |
| 125 } | 125 } |
| 126 } // namespace webrtc | 126 } // namespace webrtc |
| OLD | NEW |