OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <deque> | 5 #include <deque> |
6 #include <utility> | 6 #include <utility> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 | 113 |
114 void FeedOneFrameIntoReceiver() { | 114 void FeedOneFrameIntoReceiver() { |
115 // Note: For testing purposes, a frame consists of only a single packet. | 115 // Note: For testing purposes, a frame consists of only a single packet. |
116 receiver_->ProcessParsedPacket( | 116 receiver_->ProcessParsedPacket( |
117 rtp_header_, &payload_[0], payload_.size()); | 117 rtp_header_, &payload_[0], payload_.size()); |
118 } | 118 } |
119 | 119 |
120 void FeedLipSyncInfoIntoReceiver() { | 120 void FeedLipSyncInfoIntoReceiver() { |
121 const base::TimeTicks now = testing_clock_->NowTicks(); | 121 const base::TimeTicks now = testing_clock_->NowTicks(); |
122 const int64 rtp_timestamp = (now - start_time_) * | 122 const int64 rtp_timestamp = (now - start_time_) * |
123 config_.frequency / base::TimeDelta::FromSeconds(1); | 123 config_.rtp_timebase / base::TimeDelta::FromSeconds(1); |
124 CHECK_LE(0, rtp_timestamp); | 124 CHECK_LE(0, rtp_timestamp); |
125 uint32 ntp_seconds; | 125 uint32 ntp_seconds; |
126 uint32 ntp_fraction; | 126 uint32 ntp_fraction; |
127 ConvertTimeTicksToNtp(now, &ntp_seconds, &ntp_fraction); | 127 ConvertTimeTicksToNtp(now, &ntp_seconds, &ntp_fraction); |
128 TestRtcpPacketBuilder rtcp_packet; | 128 TestRtcpPacketBuilder rtcp_packet; |
129 rtcp_packet.AddSrWithNtp(config_.incoming_ssrc, | 129 rtcp_packet.AddSrWithNtp(config_.incoming_ssrc, |
130 ntp_seconds, ntp_fraction, | 130 ntp_seconds, ntp_fraction, |
131 static_cast<uint32>(rtp_timestamp)); | 131 static_cast<uint32>(rtp_timestamp)); |
132 ASSERT_TRUE(receiver_->ProcessPacket(rtcp_packet.GetPacket().Pass())); | 132 ASSERT_TRUE(receiver_->ProcessPacket(rtcp_packet.GetPacket().Pass())); |
133 } | 133 } |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 TEST_F(FrameReceiverTest, ReceivesFramesSkippingWhenAppropriate) { | 210 TEST_F(FrameReceiverTest, ReceivesFramesSkippingWhenAppropriate) { |
211 CreateFrameReceiverOfAudio(); | 211 CreateFrameReceiverOfAudio(); |
212 | 212 |
213 SimpleEventSubscriber event_subscriber; | 213 SimpleEventSubscriber event_subscriber; |
214 cast_environment_->Logging()->AddRawEventSubscriber(&event_subscriber); | 214 cast_environment_->Logging()->AddRawEventSubscriber(&event_subscriber); |
215 | 215 |
216 EXPECT_CALL(mock_transport_, SendRtcpFromRtpReceiver(_, _, _, _, _, _, _)) | 216 EXPECT_CALL(mock_transport_, SendRtcpFromRtpReceiver(_, _, _, _, _, _, _)) |
217 .WillRepeatedly(testing::Return()); | 217 .WillRepeatedly(testing::Return()); |
218 | 218 |
219 const uint32 rtp_advance_per_frame = | 219 const uint32 rtp_advance_per_frame = |
220 config_.frequency / config_.target_frame_rate; | 220 config_.rtp_timebase / config_.target_frame_rate; |
221 const base::TimeDelta time_advance_per_frame = | 221 const base::TimeDelta time_advance_per_frame = |
222 base::TimeDelta::FromSeconds(1) / config_.target_frame_rate; | 222 base::TimeDelta::FromSeconds(1) / config_.target_frame_rate; |
223 | 223 |
224 // Feed and process lip sync in receiver. | 224 // Feed and process lip sync in receiver. |
225 FeedLipSyncInfoIntoReceiver(); | 225 FeedLipSyncInfoIntoReceiver(); |
226 task_runner_->RunTasks(); | 226 task_runner_->RunTasks(); |
227 const base::TimeTicks first_frame_capture_time = testing_clock_->NowTicks(); | 227 const base::TimeTicks first_frame_capture_time = testing_clock_->NowTicks(); |
228 | 228 |
229 // Enqueue a request for a frame. | 229 // Enqueue a request for a frame. |
230 const ReceiveEncodedFrameCallback frame_encoded_callback = | 230 const ReceiveEncodedFrameCallback frame_encoded_callback = |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 TEST_F(FrameReceiverTest, ReceivesFramesRefusingToSkipAny) { | 313 TEST_F(FrameReceiverTest, ReceivesFramesRefusingToSkipAny) { |
314 CreateFrameReceiverOfVideo(); | 314 CreateFrameReceiverOfVideo(); |
315 | 315 |
316 SimpleEventSubscriber event_subscriber; | 316 SimpleEventSubscriber event_subscriber; |
317 cast_environment_->Logging()->AddRawEventSubscriber(&event_subscriber); | 317 cast_environment_->Logging()->AddRawEventSubscriber(&event_subscriber); |
318 | 318 |
319 EXPECT_CALL(mock_transport_, SendRtcpFromRtpReceiver(_, _, _, _, _, _, _)) | 319 EXPECT_CALL(mock_transport_, SendRtcpFromRtpReceiver(_, _, _, _, _, _, _)) |
320 .WillRepeatedly(testing::Return()); | 320 .WillRepeatedly(testing::Return()); |
321 | 321 |
322 const uint32 rtp_advance_per_frame = | 322 const uint32 rtp_advance_per_frame = |
323 config_.frequency / config_.target_frame_rate; | 323 config_.rtp_timebase / config_.target_frame_rate; |
324 const base::TimeDelta time_advance_per_frame = | 324 const base::TimeDelta time_advance_per_frame = |
325 base::TimeDelta::FromSeconds(1) / config_.target_frame_rate; | 325 base::TimeDelta::FromSeconds(1) / config_.target_frame_rate; |
326 | 326 |
327 // Feed and process lip sync in receiver. | 327 // Feed and process lip sync in receiver. |
328 FeedLipSyncInfoIntoReceiver(); | 328 FeedLipSyncInfoIntoReceiver(); |
329 task_runner_->RunTasks(); | 329 task_runner_->RunTasks(); |
330 const base::TimeTicks first_frame_capture_time = testing_clock_->NowTicks(); | 330 const base::TimeTicks first_frame_capture_time = testing_clock_->NowTicks(); |
331 | 331 |
332 // Enqueue a request for a frame. | 332 // Enqueue a request for a frame. |
333 const ReceiveEncodedFrameCallback frame_encoded_callback = | 333 const ReceiveEncodedFrameCallback frame_encoded_callback = |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 EXPECT_GE(kFirstFrameId + 3, frame_events[i].frame_id); | 411 EXPECT_GE(kFirstFrameId + 3, frame_events[i].frame_id); |
412 const int frame_offset = frame_events[i].frame_id - kFirstFrameId; | 412 const int frame_offset = frame_events[i].frame_id - kFirstFrameId; |
413 EXPECT_EQ(frame_offset * rtp_advance_per_frame, | 413 EXPECT_EQ(frame_offset * rtp_advance_per_frame, |
414 frame_events[i].rtp_timestamp); | 414 frame_events[i].rtp_timestamp); |
415 } | 415 } |
416 cast_environment_->Logging()->RemoveRawEventSubscriber(&event_subscriber); | 416 cast_environment_->Logging()->RemoveRawEventSubscriber(&event_subscriber); |
417 } | 417 } |
418 | 418 |
419 } // namespace cast | 419 } // namespace cast |
420 } // namespace media | 420 } // namespace media |
OLD | NEW |