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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 virtual bool SendPacket(PacketRef packet, |
68 const base::Closure& cb) OVERRIDE { | 68 const base::Closure& cb) override { |
69 if (paused_) { | 69 if (paused_) { |
70 stored_packet_ = packet; | 70 stored_packet_ = packet; |
71 callback_ = cb; | 71 callback_ = cb; |
72 return false; | 72 return false; |
73 } | 73 } |
74 if (Rtcp::IsRtcpPacket(&packet->data[0], packet->data.size())) { | 74 if (Rtcp::IsRtcpPacket(&packet->data[0], packet->data.size())) { |
75 ++number_of_rtcp_packets_; | 75 ++number_of_rtcp_packets_; |
76 } else { | 76 } else { |
77 // Check that at least one RTCP packet was sent before the first RTP | 77 // 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 | 78 // 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 | 79 // sync info before it has to calculate the playout time of the first |
80 // frame. | 80 // frame. |
81 if (number_of_rtp_packets_ == 0) | 81 if (number_of_rtp_packets_ == 0) |
82 EXPECT_LE(1, number_of_rtcp_packets_); | 82 EXPECT_LE(1, number_of_rtcp_packets_); |
83 ++number_of_rtp_packets_; | 83 ++number_of_rtp_packets_; |
84 } | 84 } |
85 return true; | 85 return true; |
86 } | 86 } |
87 | 87 |
88 virtual int64 GetBytesSent() OVERRIDE { | 88 virtual int64 GetBytesSent() override { |
89 return 0; | 89 return 0; |
90 } | 90 } |
91 | 91 |
92 int number_of_rtp_packets() const { return number_of_rtp_packets_; } | 92 int number_of_rtp_packets() const { return number_of_rtp_packets_; } |
93 | 93 |
94 int number_of_rtcp_packets() const { return number_of_rtcp_packets_; } | 94 int number_of_rtcp_packets() const { return number_of_rtcp_packets_; } |
95 | 95 |
96 void SetPause(bool paused) { | 96 void SetPause(bool paused) { |
97 paused_ = paused; | 97 paused_ = paused; |
98 if (!paused && stored_packet_.get()) { | 98 if (!paused && stored_packet_.get()) { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 make_scoped_ptr(new base::DictionaryValue), | 153 make_scoped_ptr(new base::DictionaryValue), |
154 base::Bind(&UpdateCastTransportStatus), | 154 base::Bind(&UpdateCastTransportStatus), |
155 BulkRawEventsCallback(), | 155 BulkRawEventsCallback(), |
156 base::TimeDelta(), | 156 base::TimeDelta(), |
157 task_runner_, | 157 task_runner_, |
158 &transport_)); | 158 &transport_)); |
159 } | 159 } |
160 | 160 |
161 virtual ~VideoSenderTest() {} | 161 virtual ~VideoSenderTest() {} |
162 | 162 |
163 virtual void TearDown() OVERRIDE { | 163 virtual void TearDown() override { |
164 video_sender_.reset(); | 164 video_sender_.reset(); |
165 task_runner_->RunTasks(); | 165 task_runner_->RunTasks(); |
166 } | 166 } |
167 | 167 |
168 static void UpdateCastTransportStatus(CastTransportStatus status) { | 168 static void UpdateCastTransportStatus(CastTransportStatus status) { |
169 EXPECT_EQ(TRANSPORT_VIDEO_INITIALIZED, status); | 169 EXPECT_EQ(TRANSPORT_VIDEO_INITIALIZED, status); |
170 } | 170 } |
171 | 171 |
172 // If |external| is true then external video encoder (VEA) is used. | 172 // If |external| is true then external video encoder (VEA) is used. |
173 // |expect_init_sucess| is true if initialization is expected to succeed. | 173 // |expect_init_sucess| is true if initialization is expected to succeed. |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 cast_feedback.ack_frame_id = 0; | 527 cast_feedback.ack_frame_id = 0; |
528 video_sender_->OnReceivedCastFeedback(cast_feedback); | 528 video_sender_->OnReceivedCastFeedback(cast_feedback); |
529 | 529 |
530 transport_.SetPause(false); | 530 transport_.SetPause(false); |
531 RunTasks(33); | 531 RunTasks(33); |
532 EXPECT_EQ(0, transport_.number_of_rtp_packets()); | 532 EXPECT_EQ(0, transport_.number_of_rtp_packets()); |
533 } | 533 } |
534 | 534 |
535 } // namespace cast | 535 } // namespace cast |
536 } // namespace media | 536 } // namespace media |
OLD | NEW |