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

Side by Side Diff: media/cast/net/pacing/paced_sender_unittest.cc

Issue 399743002: Cast: Implement priority packets in PacedSender (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments Created 6 years, 5 months 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 | Annotate | Revision Log
« no previous file with comments | « media/cast/net/pacing/paced_sender.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include "base/big_endian.h" 7 #include "base/big_endian.h"
8 #include "base/test/simple_test_tick_clock.h" 8 #include "base/test/simple_test_tick_clock.h"
9 #include "media/cast/logging/logging_impl.h" 9 #include "media/cast/logging/logging_impl.h"
10 #include "media/cast/logging/simple_event_subscriber.h" 10 #include "media/cast/logging/simple_event_subscriber.h"
11 #include "media/cast/net/pacing/paced_sender.h" 11 #include "media/cast/net/pacing/paced_sender.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 "testing/gmock/include/gmock/gmock.h" 13 #include "testing/gmock/include/gmock/gmock.h"
14 14
15 using testing::_; 15 using testing::_;
16 16
17 namespace media { 17 namespace media {
18 namespace cast { 18 namespace cast {
19 namespace { 19 namespace {
20 20
21 static const uint8 kValue = 123; 21 static const uint8 kValue = 123;
22 static const size_t kSize1 = 100; 22 static const size_t kSize1 = 101;
23 static const size_t kSize2 = 101; 23 static const size_t kSize2 = 102;
24 static const size_t kSize3 = 102; 24 static const size_t kSize3 = 103;
25 static const size_t kSize4 = 103; 25 static const size_t kSize4 = 104;
26 static const size_t kNackSize = 104; 26 static const size_t kNackSize = 105;
27 static const int64 kStartMillisecond = INT64_C(12345678900000); 27 static const int64 kStartMillisecond = INT64_C(12345678900000);
28 static const uint32 kVideoSsrc = 0x1234; 28 static const uint32 kVideoSsrc = 0x1234;
29 static const uint32 kAudioSsrc = 0x5678; 29 static const uint32 kAudioSsrc = 0x5678;
30 30
31 class TestPacketSender : public PacketSender { 31 class TestPacketSender : public PacketSender {
32 public: 32 public:
33 TestPacketSender() {} 33 TestPacketSender() {}
34 34
35 virtual bool SendPacket(PacketRef packet, const base::Closure& cb) OVERRIDE { 35 virtual bool SendPacket(PacketRef packet, const base::Closure& cb) OVERRIDE {
36 EXPECT_FALSE(expected_packet_size_.empty()); 36 EXPECT_FALSE(expected_packet_size_.empty());
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 testing_clock_.Advance(timeout_10ms); 342 testing_clock_.Advance(timeout_10ms);
343 task_runner_->RunTasks(); 343 task_runner_->RunTasks();
344 344
345 testing_clock_.Advance(timeout_10ms); 345 testing_clock_.Advance(timeout_10ms);
346 task_runner_->RunTasks(); 346 task_runner_->RunTasks();
347 347
348 // No more packets. 348 // No more packets.
349 EXPECT_TRUE(RunUntilEmpty(5)); 349 EXPECT_TRUE(RunUntilEmpty(5));
350 } 350 }
351 351
352 TEST_F(PacedSenderTest, SendPriority) {
353 // Actual order to the network is:
354 // 1. Video packets x 10.
355 // 2. RTCP packet x 1.
356 // 3. Audio packet x 1.
357 // 4. Video retransmission packet x 10.
358 // 5. Video packet x 10.
359 mock_transport_.AddExpectedSize(kSize2, 10); // Normal video packets.
360 mock_transport_.AddExpectedSize(kSize3, 1); // RTCP packet.
361 mock_transport_.AddExpectedSize(kSize1, 1); // Audio packet.
362 mock_transport_.AddExpectedSize(kSize4, 10); // Resend video packets.
363 mock_transport_.AddExpectedSize(kSize2, 10); // Normal video packets.
364
365 paced_sender_->RegisterPrioritySsrc(kAudioSsrc);
366
367 // Retransmission packets with the earlier timestamp.
368 SendPacketVector resend_packets =
369 CreateSendPacketVector(kSize4, 10, false);
370 testing_clock_.Advance(base::TimeDelta::FromMilliseconds(10));
371
372 // Send 20 normal video packets. Only 10 will be sent in this
373 // call, the rest will be sitting in the queue waiting for pacing.
374 EXPECT_TRUE(paced_sender_->SendPackets(
375 CreateSendPacketVector(kSize2, 20, false)));
376
377 testing_clock_.Advance(base::TimeDelta::FromMilliseconds(10));
378
379 // Send normal audio packet. This is queued and will be sent
380 // earlier than video packets.
381 EXPECT_TRUE(paced_sender_->SendPackets(
382 CreateSendPacketVector(kSize1, 1, true)));
383
384 // Send RTCP packet. This is queued and will be sent first.
385 EXPECT_TRUE(paced_sender_->SendRtcpPacket(
386 kVideoSsrc,
387 new base::RefCountedData<Packet>(Packet(kSize3, kValue))));
388
389 // Resend video packets. This is queued and will be sent
390 // earlier than normal video packets.
391 EXPECT_TRUE(paced_sender_->ResendPackets(
392 resend_packets, base::TimeDelta()));
393
394 // Roll the clock. Queued packets will be sent in this order:
395 // 1. RTCP packet x 1.
396 // 2. Audio packet x 1.
397 // 3. Video retransmission packet x 10.
398 // 4. Video packet x 10.
399 task_runner_->RunTasks();
400 EXPECT_TRUE(RunUntilEmpty(4));
401 }
402
352 } // namespace cast 403 } // namespace cast
353 } // namespace media 404 } // namespace media
OLDNEW
« no previous file with comments | « media/cast/net/pacing/paced_sender.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698