| 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 #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/simple_event_subscriber.h" | 9 #include "media/cast/logging/simple_event_subscriber.h" |
| 10 #include "media/cast/test/fake_single_thread_task_runner.h" | 10 #include "media/cast/test/fake_single_thread_task_runner.h" |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 // Check that we don't get any more packets. | 167 // Check that we don't get any more packets. |
| 168 EXPECT_TRUE(RunUntilEmpty(3)); | 168 EXPECT_TRUE(RunUntilEmpty(3)); |
| 169 | 169 |
| 170 std::vector<PacketEvent> packet_events; | 170 std::vector<PacketEvent> packet_events; |
| 171 subscriber_.GetPacketEventsAndReset(&packet_events); | 171 subscriber_.GetPacketEventsAndReset(&packet_events); |
| 172 EXPECT_EQ(num_of_packets, static_cast<int>(packet_events.size())); | 172 EXPECT_EQ(num_of_packets, static_cast<int>(packet_events.size())); |
| 173 int sent_to_network_event_count = 0; | 173 int sent_to_network_event_count = 0; |
| 174 for (std::vector<PacketEvent>::iterator it = packet_events.begin(); | 174 for (std::vector<PacketEvent>::iterator it = packet_events.begin(); |
| 175 it != packet_events.end(); | 175 it != packet_events.end(); |
| 176 ++it) { | 176 ++it) { |
| 177 if (it->type == kVideoPacketSentToNetwork) | 177 if (it->type == PACKET_SENT_TO_NETWORK) |
| 178 sent_to_network_event_count++; | 178 sent_to_network_event_count++; |
| 179 else | 179 else |
| 180 FAIL() << "Got unexpected event type " << CastLoggingToString(it->type); | 180 FAIL() << "Got unexpected event type " << CastLoggingToString(it->type); |
| 181 } | 181 } |
| 182 EXPECT_EQ(num_of_packets, sent_to_network_event_count); | 182 EXPECT_EQ(num_of_packets, sent_to_network_event_count); |
| 183 } | 183 } |
| 184 | 184 |
| 185 TEST_F(PacedSenderTest, PaceWithNack) { | 185 TEST_F(PacedSenderTest, PaceWithNack) { |
| 186 // Testing what happen when we get multiple NACK requests for a fully lost | 186 // Testing what happen when we get multiple NACK requests for a fully lost |
| 187 // frames just as we sent the first packets in a frame. | 187 // frames just as we sent the first packets in a frame. |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 EXPECT_EQ(expected_video_network_event_count + | 247 EXPECT_EQ(expected_video_network_event_count + |
| 248 expected_video_retransmitted_event_count + | 248 expected_video_retransmitted_event_count + |
| 249 expected_audio_network_event_count, | 249 expected_audio_network_event_count, |
| 250 static_cast<int>(packet_events.size())); | 250 static_cast<int>(packet_events.size())); |
| 251 int audio_network_event_count = 0; | 251 int audio_network_event_count = 0; |
| 252 int video_network_event_count = 0; | 252 int video_network_event_count = 0; |
| 253 int video_retransmitted_event_count = 0; | 253 int video_retransmitted_event_count = 0; |
| 254 for (std::vector<PacketEvent>::iterator it = packet_events.begin(); | 254 for (std::vector<PacketEvent>::iterator it = packet_events.begin(); |
| 255 it != packet_events.end(); | 255 it != packet_events.end(); |
| 256 ++it) { | 256 ++it) { |
| 257 if (it->type == kVideoPacketSentToNetwork) | 257 if (it->type == PACKET_SENT_TO_NETWORK) { |
| 258 video_network_event_count++; | 258 if (it->media_type == VIDEO_EVENT) |
| 259 else if (it->type == kVideoPacketRetransmitted) | 259 video_network_event_count++; |
| 260 video_retransmitted_event_count++; | 260 else |
| 261 else if (it->type == kAudioPacketSentToNetwork) | 261 audio_network_event_count++; |
| 262 audio_network_event_count++; | 262 } else if (it->type == PACKET_RETRANSMITTED) { |
| 263 else | 263 if (it->media_type == VIDEO_EVENT) |
| 264 video_retransmitted_event_count++; |
| 265 } else { |
| 264 FAIL() << "Got unexpected event type " << CastLoggingToString(it->type); | 266 FAIL() << "Got unexpected event type " << CastLoggingToString(it->type); |
| 267 } |
| 265 } | 268 } |
| 266 EXPECT_EQ(expected_audio_network_event_count, audio_network_event_count); | 269 EXPECT_EQ(expected_audio_network_event_count, audio_network_event_count); |
| 267 EXPECT_EQ(expected_video_network_event_count, video_network_event_count); | 270 EXPECT_EQ(expected_video_network_event_count, video_network_event_count); |
| 268 EXPECT_EQ(expected_video_retransmitted_event_count, | 271 EXPECT_EQ(expected_video_retransmitted_event_count, |
| 269 video_retransmitted_event_count); | 272 video_retransmitted_event_count); |
| 270 } | 273 } |
| 271 | 274 |
| 272 TEST_F(PacedSenderTest, PaceWith60fps) { | 275 TEST_F(PacedSenderTest, PaceWith60fps) { |
| 273 // Testing what happen when we get multiple NACK requests for a fully lost | 276 // Testing what happen when we get multiple NACK requests for a fully lost |
| 274 // frames just as we sent the first packets in a frame. | 277 // frames just as we sent the first packets in a frame. |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 testing_clock_.Advance(timeout_10ms); | 342 testing_clock_.Advance(timeout_10ms); |
| 340 task_runner_->RunTasks(); | 343 task_runner_->RunTasks(); |
| 341 | 344 |
| 342 // No more packets. | 345 // No more packets. |
| 343 EXPECT_TRUE(RunUntilEmpty(5)); | 346 EXPECT_TRUE(RunUntilEmpty(5)); |
| 344 } | 347 } |
| 345 | 348 |
| 346 } // namespace transport | 349 } // namespace transport |
| 347 } // namespace cast | 350 } // namespace cast |
| 348 } // namespace media | 351 } // namespace media |
| OLD | NEW |