Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(249)

Side by Side Diff: media/filters/ffmpeg_demuxer_unittest.cc

Issue 353563002: Fix corrupted audio and video at playback start in ogg containers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove file code. Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/filters/ffmpeg_demuxer.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 message_loop_.Run(); 482 message_loop_.Run();
483 EXPECT_EQ(base::TimeDelta(), demuxer_->start_time()); 483 EXPECT_EQ(base::TimeDelta(), demuxer_->start_time());
484 484
485 // Seek back to the beginning and repeat the test. 485 // Seek back to the beginning and repeat the test.
486 WaitableMessageLoopEvent event; 486 WaitableMessageLoopEvent event;
487 demuxer_->Seek(base::TimeDelta(), event.GetPipelineStatusCB()); 487 demuxer_->Seek(base::TimeDelta(), event.GetPipelineStatusCB());
488 event.RunAndWaitForStatus(PIPELINE_OK); 488 event.RunAndWaitForStatus(PIPELINE_OK);
489 } 489 }
490 } 490 }
491 491
492 TEST_F(FFmpegDemuxerTest, Read_AudioNegativeStartTimeAndOggDiscard) { 492 // TODO(dalecurtis): Test is disabled since FFmpeg does not currently guarantee
493 // the order of demuxed packets in OGG containers. Re-enable once we decide to
494 // either workaround it or attempt a fix upstream. See http://crbug.com/387996.
495 TEST_F(FFmpegDemuxerTest,
496 DISABLED_Read_AudioNegativeStartTimeAndOggDiscard_Bear) {
493 // Many ogg files have negative starting timestamps, so ensure demuxing and 497 // Many ogg files have negative starting timestamps, so ensure demuxing and
494 // seeking work correctly with a negative start time. 498 // seeking work correctly with a negative start time.
495 CreateDemuxer("bear.ogv"); 499 CreateDemuxer("bear.ogv");
496 InitializeDemuxer(); 500 InitializeDemuxer();
497 501
502 // Attempt a read from the video stream and run the message loop until done.
503 DemuxerStream* video = demuxer_->GetStream(DemuxerStream::VIDEO);
504 DemuxerStream* audio = demuxer_->GetStream(DemuxerStream::AUDIO);
505
498 // Run the test twice with a seek in between. 506 // Run the test twice with a seek in between.
499 for (int i = 0; i < 2; ++i) { 507 for (int i = 0; i < 2; ++i) {
500 demuxer_->GetStream(DemuxerStream::AUDIO)->Read( 508 audio->Read(
501 NewReadCBWithCheckedDiscard(FROM_HERE, 40, 0, kInfiniteDuration())); 509 NewReadCBWithCheckedDiscard(FROM_HERE, 40, 0, kInfiniteDuration()));
502 message_loop_.Run(); 510 message_loop_.Run();
503 demuxer_->GetStream(DemuxerStream::AUDIO)->Read( 511 audio->Read(
504 NewReadCBWithCheckedDiscard(FROM_HERE, 41, 2903, kInfiniteDuration())); 512 NewReadCBWithCheckedDiscard(FROM_HERE, 41, 2903, kInfiniteDuration()));
505 message_loop_.Run(); 513 message_loop_.Run();
506 demuxer_->GetStream(DemuxerStream::AUDIO)->Read(NewReadCBWithCheckedDiscard( 514 audio->Read(NewReadCBWithCheckedDiscard(
507 FROM_HERE, 173, 5805, base::TimeDelta::FromMicroseconds(10159))); 515 FROM_HERE, 173, 5805, base::TimeDelta::FromMicroseconds(10159)));
508 message_loop_.Run(); 516 message_loop_.Run();
509 517
510 demuxer_->GetStream(DemuxerStream::AUDIO) 518 audio->Read(NewReadCB(FROM_HERE, 148, 18866));
511 ->Read(NewReadCB(FROM_HERE, 148, 18866));
512 message_loop_.Run(); 519 message_loop_.Run();
513 EXPECT_EQ(base::TimeDelta::FromMicroseconds(-15964), 520 EXPECT_EQ(base::TimeDelta::FromMicroseconds(-15964),
514 demuxer_->start_time()); 521 demuxer_->start_time());
515 522
523 video->Read(NewReadCB(FROM_HERE, 5751, 0));
524 message_loop_.Run();
525
526 video->Read(NewReadCB(FROM_HERE, 846, 33367));
527 message_loop_.Run();
528
529 video->Read(NewReadCB(FROM_HERE, 1255, 66733));
530 message_loop_.Run();
531
516 // Seek back to the beginning and repeat the test. 532 // Seek back to the beginning and repeat the test.
517 WaitableMessageLoopEvent event; 533 WaitableMessageLoopEvent event;
518 demuxer_->Seek(base::TimeDelta(), event.GetPipelineStatusCB()); 534 demuxer_->Seek(base::TimeDelta(), event.GetPipelineStatusCB());
535 event.RunAndWaitForStatus(PIPELINE_OK);
536 }
537 }
538
539 // Same test above, but using sync2.ogv which has video stream muxed before the
540 // audio stream, so seeking based only on start time will fail since ffmpeg is
541 // essentially just seeking based on file position.
542 TEST_F(FFmpegDemuxerTest, Read_AudioNegativeStartTimeAndOggDiscard_Sync) {
543 // Many ogg files have negative starting timestamps, so ensure demuxing and
544 // seeking work correctly with a negative start time.
545 CreateDemuxer("sync2.ogv");
546 InitializeDemuxer();
547
548 // Attempt a read from the video stream and run the message loop until done.
549 DemuxerStream* video = demuxer_->GetStream(DemuxerStream::VIDEO);
550 DemuxerStream* audio = demuxer_->GetStream(DemuxerStream::AUDIO);
551
552 // Run the test twice with a seek in between.
553 for (int i = 0; i < 2; ++i) {
554 audio->Read(NewReadCBWithCheckedDiscard(
555 FROM_HERE, 1, 0, base::TimeDelta::FromMicroseconds(2902)));
556 message_loop_.Run();
557
558 audio->Read(NewReadCB(FROM_HERE, 1, 2902));
559 message_loop_.Run();
560 EXPECT_EQ(base::TimeDelta::FromMicroseconds(-2902),
561 demuxer_->start_time());
562
563 video->Read(NewReadCB(FROM_HERE, 9997, 0));
564 message_loop_.Run();
565
566 video->Read(NewReadCB(FROM_HERE, 16, 33241));
567 message_loop_.Run();
568
569 video->Read(NewReadCB(FROM_HERE, 631, 66482));
570 message_loop_.Run();
571
572 // Seek back to the beginning and repeat the test.
573 WaitableMessageLoopEvent event;
574 demuxer_->Seek(base::TimeDelta(), event.GetPipelineStatusCB());
519 event.RunAndWaitForStatus(PIPELINE_OK); 575 event.RunAndWaitForStatus(PIPELINE_OK);
520 } 576 }
521 } 577 }
522 578
523 TEST_F(FFmpegDemuxerTest, Read_EndOfStream) { 579 TEST_F(FFmpegDemuxerTest, Read_EndOfStream) {
524 // Verify that end of stream buffers are created. 580 // Verify that end of stream buffers are created.
525 CreateDemuxer("bear-320x240.webm"); 581 CreateDemuxer("bear-320x240.webm");
526 InitializeDemuxer(); 582 InitializeDemuxer();
527 ReadUntilEndOfStream(demuxer_->GetStream(DemuxerStream::AUDIO)); 583 ReadUntilEndOfStream(demuxer_->GetStream(DemuxerStream::AUDIO));
528 } 584 }
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 demuxer_->Stop(event.GetClosure()); 912 demuxer_->Stop(event.GetClosure());
857 event.RunAndWait(); 913 event.RunAndWait();
858 demuxer_.reset(); 914 demuxer_.reset();
859 data_source_.reset(); 915 data_source_.reset();
860 } 916 }
861 } 917 }
862 918
863 #endif 919 #endif
864 920
865 } // namespace media 921 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/ffmpeg_demuxer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698