OLD | NEW |
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 // This test generate synthetic data. For audio it's a sinusoid waveform with | 5 // This test generate synthetic data. For audio it's a sinusoid waveform with |
6 // frequency kSoundFrequency and different amplitudes. For video it's a pattern | 6 // frequency kSoundFrequency and different amplitudes. For video it's a pattern |
7 // that is shifting by one pixel per frame, each pixels neighbors right and down | 7 // that is shifting by one pixel per frame, each pixels neighbors right and down |
8 // is this pixels value +1, since the pixel value is 8 bit it will wrap | 8 // is this pixels value +1, since the pixel value is 8 bit it will wrap |
9 // frequently within the image. Visually this will create diagonally color bands | 9 // frequently within the image. Visually this will create diagonally color bands |
10 // that moves across the screen | 10 // that moves across the screen |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 // Shim that turns forwards packets from a test::PacketPipe to a | 167 // Shim that turns forwards packets from a test::PacketPipe to a |
168 // PacketReceiverCallback. | 168 // PacketReceiverCallback. |
169 class LoopBackPacketPipe : public test::PacketPipe { | 169 class LoopBackPacketPipe : public test::PacketPipe { |
170 public: | 170 public: |
171 LoopBackPacketPipe(const PacketReceiverCallback& packet_receiver) | 171 LoopBackPacketPipe(const PacketReceiverCallback& packet_receiver) |
172 : packet_receiver_(packet_receiver) {} | 172 : packet_receiver_(packet_receiver) {} |
173 | 173 |
174 virtual ~LoopBackPacketPipe() {} | 174 virtual ~LoopBackPacketPipe() {} |
175 | 175 |
176 // PacketPipe implementations. | 176 // PacketPipe implementations. |
177 virtual void Send(scoped_ptr<Packet> packet) OVERRIDE { | 177 virtual void Send(scoped_ptr<Packet> packet) override { |
178 packet_receiver_.Run(packet.Pass()); | 178 packet_receiver_.Run(packet.Pass()); |
179 } | 179 } |
180 | 180 |
181 private: | 181 private: |
182 PacketReceiverCallback packet_receiver_; | 182 PacketReceiverCallback packet_receiver_; |
183 }; | 183 }; |
184 | 184 |
185 // Class that sends the packet direct from sender into the receiver with the | 185 // Class that sends the packet direct from sender into the receiver with the |
186 // ability to drop packets between the two. | 186 // ability to drop packets between the two. |
187 class LoopBackTransport : public PacketSender { | 187 class LoopBackTransport : public PacketSender { |
(...skipping 12 matching lines...) Expand all Loading... |
200 new LoopBackPacketPipe(packet_receiver)); | 200 new LoopBackPacketPipe(packet_receiver)); |
201 if (packet_pipe_) { | 201 if (packet_pipe_) { |
202 packet_pipe_->AppendToPipe(loopback_pipe.Pass()); | 202 packet_pipe_->AppendToPipe(loopback_pipe.Pass()); |
203 } else { | 203 } else { |
204 packet_pipe_ = loopback_pipe.Pass(); | 204 packet_pipe_ = loopback_pipe.Pass(); |
205 } | 205 } |
206 packet_pipe_->InitOnIOThread(task_runner, clock); | 206 packet_pipe_->InitOnIOThread(task_runner, clock); |
207 } | 207 } |
208 | 208 |
209 virtual bool SendPacket(PacketRef packet, | 209 virtual bool SendPacket(PacketRef packet, |
210 const base::Closure& cb) OVERRIDE { | 210 const base::Closure& cb) override { |
211 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); | 211 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); |
212 if (!send_packets_) | 212 if (!send_packets_) |
213 return true; | 213 return true; |
214 | 214 |
215 bytes_sent_ += packet->data.size(); | 215 bytes_sent_ += packet->data.size(); |
216 if (drop_packets_belonging_to_odd_frames_) { | 216 if (drop_packets_belonging_to_odd_frames_) { |
217 uint32 frame_id = packet->data[13]; | 217 uint32 frame_id = packet->data[13]; |
218 if (frame_id % 2 == 1) | 218 if (frame_id % 2 == 1) |
219 return true; | 219 return true; |
220 } | 220 } |
221 | 221 |
222 scoped_ptr<Packet> packet_copy(new Packet(packet->data)); | 222 scoped_ptr<Packet> packet_copy(new Packet(packet->data)); |
223 packet_pipe_->Send(packet_copy.Pass()); | 223 packet_pipe_->Send(packet_copy.Pass()); |
224 return true; | 224 return true; |
225 } | 225 } |
226 | 226 |
227 virtual int64 GetBytesSent() OVERRIDE { | 227 virtual int64 GetBytesSent() override { |
228 return bytes_sent_; | 228 return bytes_sent_; |
229 } | 229 } |
230 | 230 |
231 void SetSendPackets(bool send_packets) { send_packets_ = send_packets; } | 231 void SetSendPackets(bool send_packets) { send_packets_ = send_packets; } |
232 | 232 |
233 void DropAllPacketsBelongingToOddFrames() { | 233 void DropAllPacketsBelongingToOddFrames() { |
234 drop_packets_belonging_to_odd_frames_ = true; | 234 drop_packets_belonging_to_odd_frames_ = true; |
235 } | 235 } |
236 | 236 |
237 void SetPacketPipe(scoped_ptr<test::PacketPipe> pipe) { | 237 void SetPacketPipe(scoped_ptr<test::PacketPipe> pipe) { |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
631 audio_sender_config_.frequency, | 631 audio_sender_config_.frequency, |
632 kSoundFrequency, | 632 kSoundFrequency, |
633 kSoundVolume)); | 633 kSoundVolume)); |
634 } | 634 } |
635 | 635 |
636 virtual ~End2EndTest() { | 636 virtual ~End2EndTest() { |
637 cast_environment_sender_->Logging()->RemoveRawEventSubscriber( | 637 cast_environment_sender_->Logging()->RemoveRawEventSubscriber( |
638 &event_subscriber_sender_); | 638 &event_subscriber_sender_); |
639 } | 639 } |
640 | 640 |
641 virtual void TearDown() OVERRIDE { | 641 virtual void TearDown() override { |
642 cast_sender_.reset(); | 642 cast_sender_.reset(); |
643 cast_receiver_.reset(); | 643 cast_receiver_.reset(); |
644 task_runner_->RunTasks(); | 644 task_runner_->RunTasks(); |
645 } | 645 } |
646 | 646 |
647 void SendVideoFrame(int start_value, const base::TimeTicks& capture_time) { | 647 void SendVideoFrame(int start_value, const base::TimeTicks& capture_time) { |
648 if (start_time_.is_null()) | 648 if (start_time_.is_null()) |
649 start_time_ = capture_time; | 649 start_time_ = capture_time; |
650 base::TimeDelta time_diff = capture_time - start_time_; | 650 base::TimeDelta time_diff = capture_time - start_time_; |
651 gfx::Size size(video_sender_config_.width, video_sender_config_.height); | 651 gfx::Size size(video_sender_config_.width, video_sender_config_.height); |
(...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1498 EXPECT_LT(jump, 220u); | 1498 EXPECT_LT(jump, 220u); |
1499 } | 1499 } |
1500 | 1500 |
1501 // TODO(pwestin): Add repeatable packet loss test. | 1501 // TODO(pwestin): Add repeatable packet loss test. |
1502 // TODO(pwestin): Add test for misaligned send get calls. | 1502 // TODO(pwestin): Add test for misaligned send get calls. |
1503 // TODO(pwestin): Add more tests that does not resample. | 1503 // TODO(pwestin): Add more tests that does not resample. |
1504 // TODO(pwestin): Add test when we have starvation for our RunTask. | 1504 // TODO(pwestin): Add test when we have starvation for our RunTask. |
1505 | 1505 |
1506 } // namespace cast | 1506 } // namespace cast |
1507 } // namespace media | 1507 } // namespace media |
OLD | NEW |