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 <stdint.h> | 5 #include <stdint.h> |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 } | 57 } |
58 | 58 |
59 class TestPacketSender : public PacketSender { | 59 class TestPacketSender : public PacketSender { |
60 public: | 60 public: |
61 TestPacketSender() | 61 TestPacketSender() |
62 : number_of_rtp_packets_(0), | 62 : number_of_rtp_packets_(0), |
63 number_of_rtcp_packets_(0), | 63 number_of_rtcp_packets_(0), |
64 paused_(false) {} | 64 paused_(false) {} |
65 | 65 |
66 // A singular packet implies a RTCP packet. | 66 // A singular packet implies a RTCP packet. |
67 virtual bool SendPacket(PacketRef packet, | 67 bool SendPacket(PacketRef packet, const base::Closure& cb) override { |
68 const base::Closure& cb) override { | |
69 if (paused_) { | 68 if (paused_) { |
70 stored_packet_ = packet; | 69 stored_packet_ = packet; |
71 callback_ = cb; | 70 callback_ = cb; |
72 return false; | 71 return false; |
73 } | 72 } |
74 if (Rtcp::IsRtcpPacket(&packet->data[0], packet->data.size())) { | 73 if (Rtcp::IsRtcpPacket(&packet->data[0], packet->data.size())) { |
75 ++number_of_rtcp_packets_; | 74 ++number_of_rtcp_packets_; |
76 } else { | 75 } else { |
77 // Check that at least one RTCP packet was sent before the first RTP | 76 // Check that at least one RTCP packet was sent before the first RTP |
78 // packet. This confirms that the receiver will have the necessary lip | 77 // packet. This confirms that the receiver will have the necessary lip |
79 // sync info before it has to calculate the playout time of the first | 78 // sync info before it has to calculate the playout time of the first |
80 // frame. | 79 // frame. |
81 if (number_of_rtp_packets_ == 0) | 80 if (number_of_rtp_packets_ == 0) |
82 EXPECT_LE(1, number_of_rtcp_packets_); | 81 EXPECT_LE(1, number_of_rtcp_packets_); |
83 ++number_of_rtp_packets_; | 82 ++number_of_rtp_packets_; |
84 } | 83 } |
85 return true; | 84 return true; |
86 } | 85 } |
87 | 86 |
88 virtual int64 GetBytesSent() override { | 87 int64 GetBytesSent() override { return 0; } |
89 return 0; | |
90 } | |
91 | 88 |
92 int number_of_rtp_packets() const { return number_of_rtp_packets_; } | 89 int number_of_rtp_packets() const { return number_of_rtp_packets_; } |
93 | 90 |
94 int number_of_rtcp_packets() const { return number_of_rtcp_packets_; } | 91 int number_of_rtcp_packets() const { return number_of_rtcp_packets_; } |
95 | 92 |
96 void SetPause(bool paused) { | 93 void SetPause(bool paused) { |
97 paused_ = paused; | 94 paused_ = paused; |
98 if (!paused && stored_packet_.get()) { | 95 if (!paused && stored_packet_.get()) { |
99 SendPacket(stored_packet_, callback_); | 96 SendPacket(stored_packet_, callback_); |
100 callback_.Run(); | 97 callback_.Run(); |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 cast_feedback.ack_frame_id = 0; | 531 cast_feedback.ack_frame_id = 0; |
535 video_sender_->OnReceivedCastFeedback(cast_feedback); | 532 video_sender_->OnReceivedCastFeedback(cast_feedback); |
536 | 533 |
537 transport_.SetPause(false); | 534 transport_.SetPause(false); |
538 RunTasks(33); | 535 RunTasks(33); |
539 EXPECT_EQ(0, transport_.number_of_rtp_packets()); | 536 EXPECT_EQ(0, transport_.number_of_rtp_packets()); |
540 } | 537 } |
541 | 538 |
542 } // namespace cast | 539 } // namespace cast |
543 } // namespace media | 540 } // namespace media |
OLD | NEW |