| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "media/cast/rtp_sender/rtp_packetizer/rtp_packetizer.h" | 5 #include "media/cast/rtp_sender/rtp_packetizer/rtp_packetizer.h" |
| 6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/test/simple_test_tick_clock.h" | 8 #include "base/test/simple_test_tick_clock.h" |
| 9 #include "media/cast/cast_config.h" | 9 #include "media/cast/cast_config.h" |
| 10 #include "media/cast/pacing/paced_sender.h" | 10 #include "media/cast/pacing/paced_sender.h" |
| 11 #include "media/cast/rtp_common/rtp_defines.h" | 11 #include "media/cast/rtp_common/rtp_defines.h" |
| 12 #include "media/cast/rtp_sender/packet_storage/packet_storage.h" | 12 #include "media/cast/rtp_sender/packet_storage/packet_storage.h" |
| 13 #include "media/cast/rtp_sender/rtp_packetizer/test/rtp_header_parser.h" | 13 #include "media/cast/rtp_sender/rtp_packetizer/test/rtp_header_parser.h" |
| 14 #include "testing/gmock/include/gmock/gmock.h" | 14 #include "testing/gmock/include/gmock/gmock.h" |
| 15 | 15 |
| 16 namespace media { | 16 namespace media { |
| 17 namespace cast { | 17 namespace cast { |
| 18 | 18 |
| 19 static const int kPayload = 127; | 19 static const int kPayload = 127; |
| 20 static const uint32 kTimestampMs = 10; | 20 static const uint32 kTimestampMs = 10; |
| 21 static const uint16 kSeqNum = 33; | 21 static const uint16 kSeqNum = 33; |
| 22 static const int kMaxPacketLength = 1500; | 22 static const int kMaxPacketLength = 1500; |
| 23 static const int kSsrc = 0x12345; | 23 static const int kSsrc = 0x12345; |
| 24 static const unsigned int kFrameSize = 5000; | 24 static const unsigned int kFrameSize = 5000; |
| 25 static const int kMaxPacketStorageTimeMs = 300; | 25 static const int kMaxPacketStorageTimeMs = 300; |
| 26 static const int64 kStartMillisecond = 0; | |
| 27 | 26 |
| 28 class TestRtpPacketTransport : public PacedPacketSender { | 27 class TestRtpPacketTransport : public PacedPacketSender { |
| 29 public: | 28 public: |
| 30 explicit TestRtpPacketTransport(RtpPacketizerConfig config) | 29 explicit TestRtpPacketTransport(RtpPacketizerConfig config) |
| 31 : config_(config), | 30 : config_(config), |
| 32 sequence_number_(kSeqNum), | 31 sequence_number_(kSeqNum), |
| 33 packets_sent_(0), | 32 packets_sent_(0), |
| 34 expected_number_of_packets_(0), | 33 expected_number_of_packets_(0), |
| 35 expected_packet_id_(0), | 34 expected_packet_id_(0), |
| 36 expected_frame_id_(0) {} | 35 expected_frame_id_(0) {} |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 class RtpPacketizerTest : public ::testing::Test { | 100 class RtpPacketizerTest : public ::testing::Test { |
| 102 protected: | 101 protected: |
| 103 RtpPacketizerTest() | 102 RtpPacketizerTest() |
| 104 :video_frame_(), | 103 :video_frame_(), |
| 105 packet_storage_(&testing_clock_, kMaxPacketStorageTimeMs) { | 104 packet_storage_(&testing_clock_, kMaxPacketStorageTimeMs) { |
| 106 config_.sequence_number = kSeqNum; | 105 config_.sequence_number = kSeqNum; |
| 107 config_.ssrc = kSsrc; | 106 config_.ssrc = kSsrc; |
| 108 config_.payload_type = kPayload; | 107 config_.payload_type = kPayload; |
| 109 config_.max_payload_length = kMaxPacketLength; | 108 config_.max_payload_length = kMaxPacketLength; |
| 110 transport_.reset(new TestRtpPacketTransport(config_)); | 109 transport_.reset(new TestRtpPacketTransport(config_)); |
| 111 testing_clock_.Advance( | |
| 112 base::TimeDelta::FromMilliseconds(kStartMillisecond)); | |
| 113 rtp_packetizer_.reset( | 110 rtp_packetizer_.reset( |
| 114 new RtpPacketizer(transport_.get(), &packet_storage_, config_)); | 111 new RtpPacketizer(transport_.get(), &packet_storage_, config_)); |
| 115 } | 112 } |
| 116 | 113 |
| 117 virtual ~RtpPacketizerTest() {} | 114 virtual ~RtpPacketizerTest() {} |
| 118 | 115 |
| 119 virtual void SetUp() { | 116 virtual void SetUp() { |
| 120 video_frame_.key_frame = false; | 117 video_frame_.key_frame = false; |
| 121 video_frame_.last_referenced_frame_id = 255; | 118 video_frame_.last_referenced_frame_id = 255; |
| 122 video_frame_.data.assign(kFrameSize, 123); | 119 video_frame_.data.assign(kFrameSize, 123); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 148 | 145 |
| 149 testing_clock_.Advance(base::TimeDelta::FromMilliseconds(kTimestampMs)); | 146 testing_clock_.Advance(base::TimeDelta::FromMilliseconds(kTimestampMs)); |
| 150 rtp_packetizer_->IncomingEncodedVideoFrame(&video_frame_, | 147 rtp_packetizer_->IncomingEncodedVideoFrame(&video_frame_, |
| 151 testing_clock_.NowTicks()); | 148 testing_clock_.NowTicks()); |
| 152 EXPECT_EQ(expected_num_of_packets, rtp_packetizer_->send_packets_count()); | 149 EXPECT_EQ(expected_num_of_packets, rtp_packetizer_->send_packets_count()); |
| 153 EXPECT_EQ(kFrameSize, rtp_packetizer_->send_octet_count()); | 150 EXPECT_EQ(kFrameSize, rtp_packetizer_->send_octet_count()); |
| 154 } | 151 } |
| 155 | 152 |
| 156 } // namespace cast | 153 } // namespace cast |
| 157 } // namespace media | 154 } // namespace media |
| OLD | NEW |