| 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 | 13 |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 14 #include "webrtc/base/scoped_ptr.h" | |
| 15 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h" | 15 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.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 = |
| (...skipping 11 matching lines...) Expand all Loading... |
| 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 |
| 39 EXPECT_EQ(packet.length, packet.original_length); | 39 EXPECT_EQ(packet.length, packet.original_length); |
| 40 c++; | 40 c++; |
| 41 } | 41 } |
| 42 return c; | 42 return c; |
| 43 } | 43 } |
| 44 | 44 |
| 45 private: | 45 private: |
| 46 rtc::scoped_ptr<test::RtpFileReader> rtp_packet_source_; | 46 std::unique_ptr<test::RtpFileReader> rtp_packet_source_; |
| 47 bool headers_only_file_; | 47 bool headers_only_file_; |
| 48 }; | 48 }; |
| 49 | 49 |
| 50 TEST_F(TestRtpFileReader, Test60Packets) { | 50 TEST_F(TestRtpFileReader, Test60Packets) { |
| 51 Init("pltype103", false); | 51 Init("pltype103", false); |
| 52 EXPECT_EQ(60, CountRtpPackets()); | 52 EXPECT_EQ(60, CountRtpPackets()); |
| 53 } | 53 } |
| 54 | 54 |
| 55 TEST_F(TestRtpFileReader, Test60PacketsHeaderOnly) { | 55 TEST_F(TestRtpFileReader, Test60PacketsHeaderOnly) { |
| 56 Init("pltype103_header_only", true); | 56 Init("pltype103_header_only", true); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 87 webrtc::RTPHeader header; | 87 webrtc::RTPHeader header; |
| 88 if (!rtp_header_parser.RTCP() && | 88 if (!rtp_header_parser.RTCP() && |
| 89 rtp_header_parser.Parse(&header, nullptr)) { | 89 rtp_header_parser.Parse(&header, nullptr)) { |
| 90 pps[header.ssrc]++; | 90 pps[header.ssrc]++; |
| 91 } | 91 } |
| 92 } | 92 } |
| 93 return pps; | 93 return pps; |
| 94 } | 94 } |
| 95 | 95 |
| 96 private: | 96 private: |
| 97 rtc::scoped_ptr<test::RtpFileReader> rtp_packet_source_; | 97 std::unique_ptr<test::RtpFileReader> rtp_packet_source_; |
| 98 }; | 98 }; |
| 99 | 99 |
| 100 TEST_F(TestPcapFileReader, TestEthernetIIFrame) { | 100 TEST_F(TestPcapFileReader, TestEthernetIIFrame) { |
| 101 Init("frame-ethernet-ii"); | 101 Init("frame-ethernet-ii"); |
| 102 EXPECT_EQ(368, CountRtpPackets()); | 102 EXPECT_EQ(368, CountRtpPackets()); |
| 103 } | 103 } |
| 104 | 104 |
| 105 TEST_F(TestPcapFileReader, TestLoopbackFrame) { | 105 TEST_F(TestPcapFileReader, TestLoopbackFrame) { |
| 106 Init("frame-loopback"); | 106 Init("frame-loopback"); |
| 107 EXPECT_EQ(491, CountRtpPackets()); | 107 EXPECT_EQ(491, CountRtpPackets()); |
| 108 } | 108 } |
| 109 | 109 |
| 110 TEST_F(TestPcapFileReader, TestTwoSsrc) { | 110 TEST_F(TestPcapFileReader, TestTwoSsrc) { |
| 111 Init("ssrcs-2"); | 111 Init("ssrcs-2"); |
| 112 PacketsPerSsrc pps = CountRtpPacketsPerSsrc(); | 112 PacketsPerSsrc pps = CountRtpPacketsPerSsrc(); |
| 113 EXPECT_EQ(2UL, pps.size()); | 113 EXPECT_EQ(2UL, pps.size()); |
| 114 EXPECT_EQ(370, pps[0x78d48f61]); | 114 EXPECT_EQ(370, pps[0x78d48f61]); |
| 115 EXPECT_EQ(60, pps[0xae94130b]); | 115 EXPECT_EQ(60, pps[0xae94130b]); |
| 116 } | 116 } |
| 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 |