OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <algorithm> | 5 #include <algorithm> |
6 #include <deque> | 6 #include <deque> |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 for (int i = 0; i < 2; ++i) { | 440 for (int i = 0; i < 2; ++i) { |
441 video->Read(NewReadCB(FROM_HERE, 5636, video_start_time.InMicroseconds())); | 441 video->Read(NewReadCB(FROM_HERE, 5636, video_start_time.InMicroseconds())); |
442 message_loop_.Run(); | 442 message_loop_.Run(); |
443 audio->Read(NewReadCB(FROM_HERE, 165, audio_start_time.InMicroseconds())); | 443 audio->Read(NewReadCB(FROM_HERE, 165, audio_start_time.InMicroseconds())); |
444 message_loop_.Run(); | 444 message_loop_.Run(); |
445 | 445 |
446 // Verify that the start time is equal to the lowest timestamp (ie the | 446 // Verify that the start time is equal to the lowest timestamp (ie the |
447 // audio). | 447 // audio). |
448 EXPECT_EQ(audio_start_time, demuxer_->start_time()); | 448 EXPECT_EQ(audio_start_time, demuxer_->start_time()); |
449 | 449 |
450 // Verify that the timeline offset has been adjusted by the start time. | 450 // Verify that the timeline offset has not been adjusted by the start time. |
451 EXPECT_EQ(kTimelineOffsetMs + audio_start_time.InMilliseconds(), | 451 EXPECT_EQ(kTimelineOffsetMs, demuxer_->GetTimelineOffset().ToJavaTime()); |
452 demuxer_->GetTimelineOffset().ToJavaTime()); | |
453 | 452 |
454 // Seek back to the beginning and repeat the test. | 453 // Seek back to the beginning and repeat the test. |
455 WaitableMessageLoopEvent event; | 454 WaitableMessageLoopEvent event; |
456 demuxer_->Seek(base::TimeDelta(), event.GetPipelineStatusCB()); | 455 demuxer_->Seek(base::TimeDelta(), event.GetPipelineStatusCB()); |
457 event.RunAndWaitForStatus(PIPELINE_OK); | 456 event.RunAndWaitForStatus(PIPELINE_OK); |
458 } | 457 } |
459 } | 458 } |
460 | 459 |
461 TEST_F(FFmpegDemuxerTest, Read_AudioNoStartTime) { | 460 TEST_F(FFmpegDemuxerTest, Read_AudioNoStartTime) { |
462 // FFmpeg does not set timestamps when demuxing wave files. Ensure that the | 461 // FFmpeg does not set timestamps when demuxing wave files. Ensure that the |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 for (int i = 0; i < 2; ++i) { | 541 for (int i = 0; i < 2; ++i) { |
543 audio->Read(NewReadCBWithCheckedDiscard( | 542 audio->Read(NewReadCBWithCheckedDiscard( |
544 FROM_HERE, 1, 0, base::TimeDelta::FromMicroseconds(2902))); | 543 FROM_HERE, 1, 0, base::TimeDelta::FromMicroseconds(2902))); |
545 message_loop_.Run(); | 544 message_loop_.Run(); |
546 | 545 |
547 audio->Read(NewReadCB(FROM_HERE, 1, 2902)); | 546 audio->Read(NewReadCB(FROM_HERE, 1, 2902)); |
548 message_loop_.Run(); | 547 message_loop_.Run(); |
549 EXPECT_EQ(base::TimeDelta::FromMicroseconds(-2902), | 548 EXPECT_EQ(base::TimeDelta::FromMicroseconds(-2902), |
550 demuxer_->start_time()); | 549 demuxer_->start_time()); |
551 | 550 |
| 551 // Though the internal start time may be below zero, the exposed media time |
| 552 // must always be greater than zero. |
| 553 EXPECT_EQ(base::TimeDelta(), demuxer_->GetStartTime()); |
| 554 |
552 video->Read(NewReadCB(FROM_HERE, 9997, 0)); | 555 video->Read(NewReadCB(FROM_HERE, 9997, 0)); |
553 message_loop_.Run(); | 556 message_loop_.Run(); |
554 | 557 |
555 video->Read(NewReadCB(FROM_HERE, 16, 33241)); | 558 video->Read(NewReadCB(FROM_HERE, 16, 33241)); |
556 message_loop_.Run(); | 559 message_loop_.Run(); |
557 | 560 |
558 video->Read(NewReadCB(FROM_HERE, 631, 66482)); | 561 video->Read(NewReadCB(FROM_HERE, 631, 66482)); |
559 message_loop_.Run(); | 562 message_loop_.Run(); |
560 | 563 |
561 // Seek back to the beginning and repeat the test. | 564 // Seek back to the beginning and repeat the test. |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
939 InitializeDemuxer(); | 942 InitializeDemuxer(); |
940 | 943 |
941 DemuxerStream* stream = demuxer_->GetStream(DemuxerStream::VIDEO); | 944 DemuxerStream* stream = demuxer_->GetStream(DemuxerStream::VIDEO); |
942 ASSERT_TRUE(stream); | 945 ASSERT_TRUE(stream); |
943 ASSERT_EQ(VIDEO_ROTATION_270, stream->video_rotation()); | 946 ASSERT_EQ(VIDEO_ROTATION_270, stream->video_rotation()); |
944 } | 947 } |
945 | 948 |
946 #endif | 949 #endif |
947 | 950 |
948 } // namespace media | 951 } // namespace media |
OLD | NEW |