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

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

Issue 2737653002: Buffer 2 seconds of data in the ffmpeg demuxer. (Closed)
Patch Set: clear error on read abort Created 3 years, 9 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
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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <algorithm> 8 #include <algorithm>
9 #include <deque> 9 #include <deque>
10 #include <string> 10 #include <string>
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 475
476 // Attempt a read from the audio stream and run the message loop until done. 476 // Attempt a read from the audio stream and run the message loop until done.
477 DemuxerStream* audio = GetStream(DemuxerStream::AUDIO); 477 DemuxerStream* audio = GetStream(DemuxerStream::AUDIO);
478 478
479 audio->Read(NewReadCB(FROM_HERE, 29, 0, true)); 479 audio->Read(NewReadCB(FROM_HERE, 29, 0, true));
480 base::RunLoop().Run(); 480 base::RunLoop().Run();
481 481
482 audio->Read(NewReadCB(FROM_HERE, 27, 3000, true)); 482 audio->Read(NewReadCB(FROM_HERE, 27, 3000, true));
483 base::RunLoop().Run(); 483 base::RunLoop().Run();
484 484
485 EXPECT_EQ(22084, demuxer_->GetMemoryUsage()); 485 EXPECT_EQ(166866, demuxer_->GetMemoryUsage());
486 } 486 }
487 487
488 TEST_F(FFmpegDemuxerTest, Read_Video) { 488 TEST_F(FFmpegDemuxerTest, Read_Video) {
489 // We test that on a successful video packet read. 489 // We test that on a successful video packet read.
490 CreateDemuxer("bear-320x240.webm"); 490 CreateDemuxer("bear-320x240.webm");
491 InitializeDemuxer(); 491 InitializeDemuxer();
492 492
493 // Attempt a read from the video stream and run the message loop until done. 493 // Attempt a read from the video stream and run the message loop until done.
494 DemuxerStream* video = GetStream(DemuxerStream::VIDEO); 494 DemuxerStream* video = GetStream(DemuxerStream::VIDEO);
495 495
496 video->Read(NewReadCB(FROM_HERE, 22084, 0, true)); 496 video->Read(NewReadCB(FROM_HERE, 22084, 0, true));
497 base::RunLoop().Run(); 497 base::RunLoop().Run();
498 498
499 video->Read(NewReadCB(FROM_HERE, 1057, 33000, false)); 499 video->Read(NewReadCB(FROM_HERE, 1057, 33000, false));
500 base::RunLoop().Run(); 500 base::RunLoop().Run();
501 501
502 EXPECT_EQ(323, demuxer_->GetMemoryUsage()); 502 EXPECT_EQ(148778, demuxer_->GetMemoryUsage());
503 } 503 }
504 504
505 TEST_F(FFmpegDemuxerTest, Read_Text) { 505 TEST_F(FFmpegDemuxerTest, Read_Text) {
506 // We test that on a successful text packet read. 506 // We test that on a successful text packet read.
507 CreateDemuxer("bear-vp8-webvtt.webm"); 507 CreateDemuxer("bear-vp8-webvtt.webm");
508 DemuxerStream* text_stream = NULL; 508 DemuxerStream* text_stream = NULL;
509 EXPECT_CALL(host_, AddTextStream(_, _)) 509 EXPECT_CALL(host_, AddTextStream(_, _))
510 .WillOnce(SaveArg<0>(&text_stream)); 510 .WillOnce(SaveArg<0>(&text_stream));
511 InitializeDemuxerWithText(); 511 InitializeDemuxerWithText();
512 ASSERT_TRUE(text_stream); 512 ASSERT_TRUE(text_stream);
(...skipping 1079 matching lines...) Expand 10 before | Expand all | Expand 10 after
1592 EXPECT_EQ(astream, preferred_seeking_stream(base::TimeDelta())); 1592 EXPECT_EQ(astream, preferred_seeking_stream(base::TimeDelta()));
1593 1593
1594 // Now pretend that audio stream got disabled. 1594 // Now pretend that audio stream got disabled.
1595 astream->set_enabled(false, base::TimeDelta()); 1595 astream->set_enabled(false, base::TimeDelta());
1596 // Since there's no other enabled streams, the preferred seeking stream should 1596 // Since there's no other enabled streams, the preferred seeking stream should
1597 // still be the audio stream. 1597 // still be the audio stream.
1598 EXPECT_EQ(astream, preferred_seeking_stream(base::TimeDelta())); 1598 EXPECT_EQ(astream, preferred_seeking_stream(base::TimeDelta()));
1599 } 1599 }
1600 1600
1601 } // namespace media 1601 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698