1 /* 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 3 * 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 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #include "testing/gtest/include/gtest/gtest.h" 12 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h" 13 #include "webrtc/modules/video_coding/main/test/rtp_file_reader.h" 14 #include "webrtc/modules/video_coding/main/test/rtp_player.h" 15 #include "webrtc/system_wrappers/interface/scoped_ptr.h" 16 #include "webrtc/test/testsupport/fileutils.h" 17 18 namespace webrtc { 19 namespace rtpplayer { 20 21 class TestRtpFileReader : public ::testing::Test { 22 public: 23 void Init(const std::string& filename) { 24 std::string filepath = 25 test::ResourcePath("video_coding/" + filename, "rtp"); 26 rtp_packet_source_.reset(CreateRtpFileReader(filepath)); 27 ASSERT_TRUE(rtp_packet_source_.get() != NULL); 28 } 29 30 int CountRtpPackets() { 31 const uint32_t kBufferSize = 4096; 32 uint8_t data[kBufferSize]; 33 uint32_t length = kBufferSize; 34 uint32_t dummy_time_ms = 0; 35 int c = 0; 36 while (rtp_packet_source_->NextPacket(data, &length, &dummy_time_ms) == 0) { 37 EXPECT_GE(kBufferSize, length); 38 length = kBufferSize; 39 c++; 40 } 41 return c; 42 } 43 44 private: 45 scoped_ptr<RtpPacketSourceInterface> rtp_packet_source_; 46 }; 47 48 TEST_F(TestRtpFileReader, Test60Packets) { 49 Init("pltype103"); 50 EXPECT_EQ(60, CountRtpPackets()); 51 } 52 53 } // namespace rtpplayer 54 } // namespace webrtc 55