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/transport/rtp_sender/rtp_packetizer/rtp_packetizer.h" | 5 #include "media/cast/transport/rtp_sender/rtp_packetizer/rtp_packetizer.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/test/simple_test_tick_clock.h" | 10 #include "base/test/simple_test_tick_clock.h" |
11 #include "media/cast/logging/simple_event_subscriber.h" | 11 #include "media/cast/logging/simple_event_subscriber.h" |
12 #include "media/cast/test/fake_single_thread_task_runner.h" | 12 #include "media/cast/test/fake_single_thread_task_runner.h" |
13 #include "media/cast/transport/pacing/paced_sender.h" | 13 #include "media/cast/transport/pacing/paced_sender.h" |
14 #include "media/cast/transport/rtp_sender/packet_storage/packet_storage.h" | 14 #include "media/cast/transport/rtp_sender/packet_storage/packet_storage.h" |
15 #include "media/cast/transport/rtp_sender/rtp_packetizer/test/rtp_header_parser.
h" | 15 #include "media/cast/transport/rtp_sender/rtp_packetizer/test/rtp_header_parser.
h" |
16 #include "testing/gmock/include/gmock/gmock.h" | 16 #include "testing/gmock/include/gmock/gmock.h" |
17 | 17 |
18 namespace media { | 18 namespace media { |
19 namespace cast { | 19 namespace cast { |
20 namespace transport { | 20 namespace transport { |
21 | 21 |
22 namespace { | 22 namespace { |
23 static const int kPayload = 127; | 23 static const int kPayload = 127; |
24 static const uint32 kTimestampMs = 10; | 24 static const uint32 kTimestampMs = 10; |
25 static const uint16 kSeqNum = 33; | 25 static const uint16 kSeqNum = 33; |
26 static const int kMaxPacketLength = 1500; | 26 static const int kMaxPacketLength = 1500; |
27 static const int kSsrc = 0x12345; | 27 static const int kSsrc = 0x12345; |
28 static const unsigned int kFrameSize = 5000; | 28 static const unsigned int kFrameSize = 5000; |
29 static const int kMaxPacketStorageTimeMs = 300; | |
30 static const uint32 kStartFrameId = UINT32_C(0xffffffff); | 29 static const uint32 kStartFrameId = UINT32_C(0xffffffff); |
31 } | 30 } |
32 | 31 |
33 class TestRtpPacketTransport : public PacketSender { | 32 class TestRtpPacketTransport : public PacketSender { |
34 public: | 33 public: |
35 explicit TestRtpPacketTransport(RtpPacketizerConfig config) | 34 explicit TestRtpPacketTransport(RtpPacketizerConfig config) |
36 : config_(config), | 35 : config_(config), |
37 sequence_number_(kSeqNum), | 36 sequence_number_(kSeqNum), |
38 packets_sent_(0), | 37 packets_sent_(0), |
39 expected_number_of_packets_(0), | 38 expected_number_of_packets_(0), |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 uint32 expectd_rtp_timestamp_; | 94 uint32 expectd_rtp_timestamp_; |
96 | 95 |
97 DISALLOW_COPY_AND_ASSIGN(TestRtpPacketTransport); | 96 DISALLOW_COPY_AND_ASSIGN(TestRtpPacketTransport); |
98 }; | 97 }; |
99 | 98 |
100 class RtpPacketizerTest : public ::testing::Test { | 99 class RtpPacketizerTest : public ::testing::Test { |
101 protected: | 100 protected: |
102 RtpPacketizerTest() | 101 RtpPacketizerTest() |
103 : task_runner_(new test::FakeSingleThreadTaskRunner(&testing_clock_)), | 102 : task_runner_(new test::FakeSingleThreadTaskRunner(&testing_clock_)), |
104 video_frame_(), | 103 video_frame_(), |
105 packet_storage_(&testing_clock_, kMaxPacketStorageTimeMs) { | 104 packet_storage_(200) { |
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 pacer_.reset(new PacedSender( | 110 pacer_.reset(new PacedSender( |
112 &testing_clock_, &logging_, transport_.get(), task_runner_)); | 111 &testing_clock_, &logging_, transport_.get(), task_runner_)); |
113 pacer_->RegisterVideoSsrc(config_.ssrc); | 112 pacer_->RegisterVideoSsrc(config_.ssrc); |
114 rtp_packetizer_.reset(new RtpPacketizer( | 113 rtp_packetizer_.reset(new RtpPacketizer( |
115 pacer_.get(), &packet_storage_, config_)); | 114 pacer_.get(), &packet_storage_, config_)); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 testing_clock_.NowTicks()); | 166 testing_clock_.NowTicks()); |
168 RunTasks(33 + 1); | 167 RunTasks(33 + 1); |
169 EXPECT_EQ(expected_num_of_packets, rtp_packetizer_->send_packets_count()); | 168 EXPECT_EQ(expected_num_of_packets, rtp_packetizer_->send_packets_count()); |
170 EXPECT_EQ(kFrameSize, rtp_packetizer_->send_octet_count()); | 169 EXPECT_EQ(kFrameSize, rtp_packetizer_->send_octet_count()); |
171 EXPECT_EQ(expected_num_of_packets, transport_->number_of_packets_received()); | 170 EXPECT_EQ(expected_num_of_packets, transport_->number_of_packets_received()); |
172 } | 171 } |
173 | 172 |
174 } // namespace transport | 173 } // namespace transport |
175 } // namespace cast | 174 } // namespace cast |
176 } // namespace media | 175 } // namespace media |
OLD | NEW |