Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(48)

Side by Side Diff: media/cast/rtp_sender/rtp_packetizer/rtp_packetizer_unittest.cc

Issue 34623008: Change to calculate the real NTP in TimeTicks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changed to use a LazyInstance instead of a Singleton Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 kTimeOffset = 22222; 22 static const int kTimeOffset = 22222;
23 static const int kMaxPacketLength = 1500; 23 static const int kMaxPacketLength = 1500;
24 static const bool kMarkerBit = true; 24 static const bool kMarkerBit = true;
25 static const int kSsrc = 0x12345; 25 static const int kSsrc = 0x12345;
26 static const unsigned int kFrameSize = 5000; 26 static const unsigned int kFrameSize = 5000;
27 static const int kTotalHeaderLength = 19; 27 static const int kTotalHeaderLength = 19;
28 static const int kMaxPacketStorageTimeMs = 300; 28 static const int kMaxPacketStorageTimeMs = 300;
29 static const int64 kStartMillisecond = 0;
30 29
31 class TestRtpPacketTransport : public PacedPacketSender { 30 class TestRtpPacketTransport : public PacedPacketSender {
32 public: 31 public:
33 explicit TestRtpPacketTransport(RtpPacketizerConfig config) 32 explicit TestRtpPacketTransport(RtpPacketizerConfig config)
34 : config_(config), 33 : config_(config),
35 sequence_number_(kSeqNum), 34 sequence_number_(kSeqNum),
36 packets_sent_(0), 35 packets_sent_(0),
37 expected_number_of_packets_(0), 36 expected_number_of_packets_(0),
38 expected_packet_id_(0), 37 expected_packet_id_(0),
39 expected_frame_id_(0) {} 38 expected_frame_id_(0) {}
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 class RtpPacketizerTest : public ::testing::Test { 103 class RtpPacketizerTest : public ::testing::Test {
105 protected: 104 protected:
106 RtpPacketizerTest() 105 RtpPacketizerTest()
107 :video_frame_(), 106 :video_frame_(),
108 packet_storage_(&testing_clock_, kMaxPacketStorageTimeMs) { 107 packet_storage_(&testing_clock_, kMaxPacketStorageTimeMs) {
109 config_.sequence_number = kSeqNum; 108 config_.sequence_number = kSeqNum;
110 config_.ssrc = kSsrc; 109 config_.ssrc = kSsrc;
111 config_.payload_type = kPayload; 110 config_.payload_type = kPayload;
112 config_.max_payload_length = kMaxPacketLength; 111 config_.max_payload_length = kMaxPacketLength;
113 transport_.reset(new TestRtpPacketTransport(config_)); 112 transport_.reset(new TestRtpPacketTransport(config_));
114 testing_clock_.Advance(
115 base::TimeDelta::FromMilliseconds(kStartMillisecond));
116 rtp_packetizer_.reset( 113 rtp_packetizer_.reset(
117 new RtpPacketizer(transport_.get(), &packet_storage_, config_)); 114 new RtpPacketizer(transport_.get(), &packet_storage_, config_));
118 } 115 }
119 116
120 virtual ~RtpPacketizerTest() {} 117 virtual ~RtpPacketizerTest() {}
121 118
122 virtual void SetUp() { 119 virtual void SetUp() {
123 video_frame_.key_frame = false; 120 video_frame_.key_frame = false;
124 video_frame_.last_referenced_frame_id = 255; 121 video_frame_.last_referenced_frame_id = 255;
125 video_frame_.data.assign(kFrameSize, 123); 122 video_frame_.data.assign(kFrameSize, 123);
(...skipping 25 matching lines...) Expand all
151 148
152 testing_clock_.Advance(base::TimeDelta::FromMilliseconds(kTimestampMs)); 149 testing_clock_.Advance(base::TimeDelta::FromMilliseconds(kTimestampMs));
153 rtp_packetizer_->IncomingEncodedVideoFrame(&video_frame_, 150 rtp_packetizer_->IncomingEncodedVideoFrame(&video_frame_,
154 testing_clock_.NowTicks()); 151 testing_clock_.NowTicks());
155 EXPECT_EQ(expected_num_of_packets, rtp_packetizer_->send_packets_count()); 152 EXPECT_EQ(expected_num_of_packets, rtp_packetizer_->send_packets_count());
156 EXPECT_EQ(kFrameSize, rtp_packetizer_->send_octet_count()); 153 EXPECT_EQ(kFrameSize, rtp_packetizer_->send_octet_count());
157 } 154 }
158 155
159 } // namespace cast 156 } // namespace cast
160 } // namespace media 157 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698