Chromium Code Reviews| 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "media/base/android/media_codec_bridge.h" | 10 #include "media/base/android/media_codec_bridge.h" |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 261 if (!MediaCodecBridge::IsAvailable()) | 261 if (!MediaCodecBridge::IsAvailable()) |
| 262 return; | 262 return; |
| 263 | 263 |
| 264 // Test decoder job will resend a ReadFromDemuxer request after seek. | 264 // Test decoder job will resend a ReadFromDemuxer request after seek. |
| 265 StartAudioDecoderJob(); | 265 StartAudioDecoderJob(); |
| 266 EXPECT_TRUE(NULL != GetMediaDecoderJob(true)); | 266 EXPECT_TRUE(NULL != GetMediaDecoderJob(true)); |
| 267 EXPECT_EQ(1, manager_->num_requests()); | 267 EXPECT_EQ(1, manager_->num_requests()); |
| 268 | 268 |
| 269 // Initiate a seek | 269 // Initiate a seek |
| 270 player_->SeekTo(base::TimeDelta()); | 270 player_->SeekTo(base::TimeDelta()); |
| 271 | |
| 272 // Verify that the seek does not occur until the initial prefetch | |
| 273 // completes. | |
| 274 EXPECT_EQ(0u, manager_->last_seek_request_id()); | |
| 275 | |
| 276 // Simulate aborted read caused by the seek. This aborts the initial | |
| 277 // prefetch. | |
| 278 DemuxerData data; | |
| 279 data.type = DemuxerStream::AUDIO; | |
| 280 data.access_units.resize(1); | |
| 281 data.access_units[0].status = DemuxerStream::kAborted; | |
| 282 player_->ReadFromDemuxerAck(data); | |
|
acolwell GONE FROM CHROMIUM
2013/08/30 18:27:38
The new implementation always expects to hear back
qinmin
2013/08/30 22:27:43
Previously, if a ReadFromDemuxerAck comes back whi
acolwell GONE FROM CHROMIUM
2013/09/06 00:34:55
Unfortunately, I can't remove the ID yet. Multiple
| |
| 283 | |
| 284 // Verify that the seek is requested now that the initial prefetch | |
| 285 // has completed. | |
| 271 EXPECT_EQ(1u, manager_->last_seek_request_id()); | 286 EXPECT_EQ(1u, manager_->last_seek_request_id()); |
| 287 | |
| 272 // Sending back the seek ACK, this should trigger the player to call | 288 // Sending back the seek ACK, this should trigger the player to call |
| 273 // OnReadFromDemuxer() again. | 289 // OnReadFromDemuxer() again. |
| 274 player_->OnSeekRequestAck(manager_->last_seek_request_id()); | 290 player_->OnSeekRequestAck(manager_->last_seek_request_id()); |
| 275 EXPECT_EQ(2, manager_->num_requests()); | 291 EXPECT_EQ(2, manager_->num_requests()); |
| 276 } | 292 } |
| 277 | 293 |
| 278 TEST_F(MediaSourcePlayerTest, SetSurfaceWhileSeeking) { | 294 TEST_F(MediaSourcePlayerTest, SetSurfaceWhileSeeking) { |
| 279 if (!MediaCodecBridge::IsAvailable()) | 295 if (!MediaCodecBridge::IsAvailable()) |
| 280 return; | 296 return; |
| 281 | 297 |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 420 // DECODE_FORMAT_CHANGED status instead of DECODE_SUCCEEDED status. Decode | 436 // DECODE_FORMAT_CHANGED status instead of DECODE_SUCCEEDED status. Decode |
| 421 // more frames to guarantee that DECODE_SUCCEEDED will be returned. | 437 // more frames to guarantee that DECODE_SUCCEEDED will be returned. |
| 422 for (int i = 0; i < 4; ++i) { | 438 for (int i = 0; i < 4; ++i) { |
| 423 player_->ReadFromDemuxerAck(CreateReadFromDemuxerAckForAudio(i)); | 439 player_->ReadFromDemuxerAck(CreateReadFromDemuxerAckForAudio(i)); |
| 424 EXPECT_TRUE(GetMediaDecoderJob(true)->is_decoding()); | 440 EXPECT_TRUE(GetMediaDecoderJob(true)->is_decoding()); |
| 425 manager_->message_loop()->Run(); | 441 manager_->message_loop()->Run(); |
| 426 } | 442 } |
| 427 | 443 |
| 428 // The decoder job should finish and a new request will be sent. | 444 // The decoder job should finish and a new request will be sent. |
| 429 EXPECT_EQ(5, manager_->num_requests()); | 445 EXPECT_EQ(5, manager_->num_requests()); |
| 430 EXPECT_FALSE(GetMediaDecoderJob(true)->is_decoding()); | 446 EXPECT_TRUE(GetMediaDecoderJob(true)->is_decoding()); |
| 431 base::TimeTicks previous = StartTimeTicks(); | 447 base::TimeTicks previous = StartTimeTicks(); |
| 432 | 448 |
| 433 // Let the decoder timeout and execute the OnDecoderStarved() callback. | 449 // Let the decoder timeout and execute the OnDecoderStarved() callback. |
| 434 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(100)); | 450 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(100)); |
| 451 | |
| 452 EXPECT_TRUE(GetMediaDecoderJob(true)->is_decoding()); | |
| 453 DCHECK(StartTimeTicks() != base::TimeTicks()); | |
|
qinmin
2013/08/30 22:27:43
EXPECT_TRUE? Same for all the DCHECKs below.
acolwell GONE FROM CHROMIUM
2013/09/06 00:34:55
Done.
| |
| 435 manager_->message_loop()->RunUntilIdle(); | 454 manager_->message_loop()->RunUntilIdle(); |
| 436 | 455 |
| 437 // Send new data to the decoder. This should reset the start time ticks. | 456 // Send new data to the decoder so it can finish the currently |
| 438 player_->ReadFromDemuxerAck(CreateEOSAck(true)); | 457 // pending decode. |
| 458 player_->ReadFromDemuxerAck(CreateReadFromDemuxerAckForAudio(3)); | |
|
acolwell GONE FROM CHROMIUM
2013/08/30 18:27:38
The new implementation has to complete the pending
| |
| 459 while(GetMediaDecoderJob(true)->is_decoding()) | |
| 460 manager_->message_loop()->RunUntilIdle(); | |
| 461 | |
| 462 // Verify the start time ticks is cleared at this point because the | |
| 463 // player is prefetching. | |
| 464 DCHECK(StartTimeTicks() == base::TimeTicks()); | |
| 465 | |
| 466 // Send new data to the decoder so it can finish prefetching. This should | |
| 467 // reset the start time ticks. | |
| 468 player_->ReadFromDemuxerAck(CreateReadFromDemuxerAckForAudio(3)); | |
| 469 DCHECK(StartTimeTicks() != base::TimeTicks()); | |
| 470 | |
| 439 base::TimeTicks current = StartTimeTicks(); | 471 base::TimeTicks current = StartTimeTicks(); |
| 440 EXPECT_LE(100.0, (current - previous).InMillisecondsF()); | 472 EXPECT_LE(100.0, (current - previous).InMillisecondsF()); |
| 441 } | 473 } |
| 442 | 474 |
| 443 TEST_F(MediaSourcePlayerTest, NoRequestForDataAfterInputEOS) { | 475 TEST_F(MediaSourcePlayerTest, NoRequestForDataAfterInputEOS) { |
| 444 if (!MediaCodecBridge::IsAvailable()) | 476 if (!MediaCodecBridge::IsAvailable()) |
| 445 return; | 477 return; |
| 446 | 478 |
| 447 // Test MediaSourcePlayer will not request for new data after input EOS is | 479 // Test MediaSourcePlayer will not request for new data after input EOS is |
| 448 // reached. | 480 // reached. |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 459 EXPECT_EQ(2, manager_->num_requests()); | 491 EXPECT_EQ(2, manager_->num_requests()); |
| 460 | 492 |
| 461 // Send EOS. | 493 // Send EOS. |
| 462 player_->ReadFromDemuxerAck(CreateEOSAck(false)); | 494 player_->ReadFromDemuxerAck(CreateEOSAck(false)); |
| 463 manager_->message_loop()->Run(); | 495 manager_->message_loop()->Run(); |
| 464 // No more request for data should be made. | 496 // No more request for data should be made. |
| 465 EXPECT_EQ(2, manager_->num_requests()); | 497 EXPECT_EQ(2, manager_->num_requests()); |
| 466 } | 498 } |
| 467 | 499 |
| 468 } // namespace media | 500 } // namespace media |
| OLD | NEW |