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

Side by Side Diff: media/test/pipeline_integration_test.cc

Issue 2158923004: Convert media constants to constexpr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
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 <memory> 8 #include <memory>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 void set_demuxer_failure_cb(const PipelineStatusCB& demuxer_failure_cb) { 529 void set_demuxer_failure_cb(const PipelineStatusCB& demuxer_failure_cb) {
530 demuxer_failure_cb_ = demuxer_failure_cb; 530 demuxer_failure_cb_ = demuxer_failure_cb;
531 } 531 }
532 532
533 void Seek(base::TimeDelta seek_time, 533 void Seek(base::TimeDelta seek_time,
534 size_t new_position, 534 size_t new_position,
535 size_t seek_append_size) { 535 size_t seek_append_size) {
536 chunk_demuxer_->StartWaitingForSeek(seek_time); 536 chunk_demuxer_->StartWaitingForSeek(seek_time);
537 537
538 chunk_demuxer_->ResetParserState(kSourceId, base::TimeDelta(), 538 chunk_demuxer_->ResetParserState(kSourceId, base::TimeDelta(),
539 kInfiniteDuration(), 539 kInfiniteDuration,
540 &last_timestamp_offset_); 540 &last_timestamp_offset_);
541 541
542 DCHECK_LT(new_position, file_data_->data_size()); 542 DCHECK_LT(new_position, file_data_->data_size());
543 current_position_ = new_position; 543 current_position_ = new_position;
544 544
545 AppendData(seek_append_size); 545 AppendData(seek_append_size);
546 } 546 }
547 547
548 void Seek(base::TimeDelta seek_time) { 548 void Seek(base::TimeDelta seek_time) {
549 chunk_demuxer_->StartWaitingForSeek(seek_time); 549 chunk_demuxer_->StartWaitingForSeek(seek_time);
550 } 550 }
551 551
552 void AppendData(size_t size) { 552 void AppendData(size_t size) {
553 DCHECK(chunk_demuxer_); 553 DCHECK(chunk_demuxer_);
554 DCHECK_LT(current_position_, file_data_->data_size()); 554 DCHECK_LT(current_position_, file_data_->data_size());
555 DCHECK_LE(current_position_ + size, file_data_->data_size()); 555 DCHECK_LE(current_position_ + size, file_data_->data_size());
556 556
557 ASSERT_TRUE(chunk_demuxer_->AppendData( 557 ASSERT_TRUE(chunk_demuxer_->AppendData(
558 kSourceId, file_data_->data() + current_position_, size, 558 kSourceId, file_data_->data() + current_position_, size,
559 base::TimeDelta(), kInfiniteDuration(), &last_timestamp_offset_)); 559 base::TimeDelta(), kInfiniteDuration, &last_timestamp_offset_));
560 current_position_ += size; 560 current_position_ += size;
561 } 561 }
562 562
563 bool AppendAtTime(base::TimeDelta timestamp_offset, 563 bool AppendAtTime(base::TimeDelta timestamp_offset,
564 const uint8_t* pData, 564 const uint8_t* pData,
565 int size) { 565 int size) {
566 CHECK(!chunk_demuxer_->IsParsingMediaSegment(kSourceId)); 566 CHECK(!chunk_demuxer_->IsParsingMediaSegment(kSourceId));
567 bool success = 567 bool success =
568 chunk_demuxer_->AppendData(kSourceId, pData, size, base::TimeDelta(), 568 chunk_demuxer_->AppendData(kSourceId, pData, size, base::TimeDelta(),
569 kInfiniteDuration(), &timestamp_offset); 569 kInfiniteDuration, &timestamp_offset);
570 last_timestamp_offset_ = timestamp_offset; 570 last_timestamp_offset_ = timestamp_offset;
571 return success; 571 return success;
572 } 572 }
573 573
574 void AppendAtTimeWithWindow(base::TimeDelta timestamp_offset, 574 void AppendAtTimeWithWindow(base::TimeDelta timestamp_offset,
575 base::TimeDelta append_window_start, 575 base::TimeDelta append_window_start,
576 base::TimeDelta append_window_end, 576 base::TimeDelta append_window_end,
577 const uint8_t* pData, 577 const uint8_t* pData,
578 int size) { 578 int size) {
579 CHECK(!chunk_demuxer_->IsParsingMediaSegment(kSourceId)); 579 CHECK(!chunk_demuxer_->IsParsingMediaSegment(kSourceId));
(...skipping 15 matching lines...) Expand all
595 void RemoveRange(base::TimeDelta start, base::TimeDelta end) { 595 void RemoveRange(base::TimeDelta start, base::TimeDelta end) {
596 chunk_demuxer_->Remove(kSourceId, start, end); 596 chunk_demuxer_->Remove(kSourceId, start, end);
597 } 597 }
598 598
599 void EndOfStream() { chunk_demuxer_->MarkEndOfStream(PIPELINE_OK); } 599 void EndOfStream() { chunk_demuxer_->MarkEndOfStream(PIPELINE_OK); }
600 600
601 void Shutdown() { 601 void Shutdown() {
602 if (!chunk_demuxer_) 602 if (!chunk_demuxer_)
603 return; 603 return;
604 chunk_demuxer_->ResetParserState(kSourceId, base::TimeDelta(), 604 chunk_demuxer_->ResetParserState(kSourceId, base::TimeDelta(),
605 kInfiniteDuration(), 605 kInfiniteDuration,
606 &last_timestamp_offset_); 606 &last_timestamp_offset_);
607 chunk_demuxer_->Shutdown(); 607 chunk_demuxer_->Shutdown();
608 chunk_demuxer_ = NULL; 608 chunk_demuxer_ = NULL;
609 } 609 }
610 610
611 void DemuxerOpened() { 611 void DemuxerOpened() {
612 base::ThreadTaskRunnerHandle::Get()->PostTask( 612 base::ThreadTaskRunnerHandle::Get()->PostTask(
613 FROM_HERE, base::Bind(&MockMediaSource::DemuxerOpenedTask, 613 FROM_HERE, base::Bind(&MockMediaSource::DemuxerOpenedTask,
614 base::Unretained(this))); 614 base::Unretained(this)));
615 } 615 }
(...skipping 883 matching lines...) Expand 10 before | Expand all | Expand 10 after
1499 1499
1500 // Trim off multiple frames off the beginning of the segment which will cause 1500 // Trim off multiple frames off the beginning of the segment which will cause
1501 // the first decoded frame to be incorrect if preroll isn't implemented. 1501 // the first decoded frame to be incorrect if preroll isn't implemented.
1502 const base::TimeDelta adts_preroll_duration = 1502 const base::TimeDelta adts_preroll_duration =
1503 base::TimeDelta::FromSecondsD(2.5 * 1024 / 44100); 1503 base::TimeDelta::FromSecondsD(2.5 * 1024 / 44100);
1504 const base::TimeDelta append_time = 1504 const base::TimeDelta append_time =
1505 source.last_timestamp_offset() - adts_preroll_duration; 1505 source.last_timestamp_offset() - adts_preroll_duration;
1506 1506
1507 scoped_refptr<DecoderBuffer> second_file = ReadTestDataFile("sfx.adts"); 1507 scoped_refptr<DecoderBuffer> second_file = ReadTestDataFile("sfx.adts");
1508 source.AppendAtTimeWithWindow( 1508 source.AppendAtTimeWithWindow(
1509 append_time, append_time + adts_preroll_duration, kInfiniteDuration(), 1509 append_time, append_time + adts_preroll_duration, kInfiniteDuration,
1510 second_file->data(), second_file->data_size()); 1510 second_file->data(), second_file->data_size());
1511 source.EndOfStream(); 1511 source.EndOfStream();
1512 1512
1513 Play(); 1513 Play();
1514 EXPECT_TRUE(WaitUntilOnEnded()); 1514 EXPECT_TRUE(WaitUntilOnEnded());
1515 1515
1516 EXPECT_EQ(592, source.last_timestamp_offset().InMilliseconds()); 1516 EXPECT_EQ(592, source.last_timestamp_offset().InMilliseconds());
1517 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); 1517 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size());
1518 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); 1518 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds());
1519 EXPECT_EQ(592, pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); 1519 EXPECT_EQ(592, pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds());
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1631 1631
1632 // There are 576 silent frames at the start of this mp3. The second append 1632 // There are 576 silent frames at the start of this mp3. The second append
1633 // should trim them off. 1633 // should trim them off.
1634 const base::TimeDelta mp3_preroll_duration = 1634 const base::TimeDelta mp3_preroll_duration =
1635 base::TimeDelta::FromSecondsD(576.0 / 44100); 1635 base::TimeDelta::FromSecondsD(576.0 / 44100);
1636 const base::TimeDelta append_time = 1636 const base::TimeDelta append_time =
1637 source.last_timestamp_offset() - mp3_preroll_duration; 1637 source.last_timestamp_offset() - mp3_preroll_duration;
1638 1638
1639 scoped_refptr<DecoderBuffer> second_file = ReadTestDataFile("sfx.mp3"); 1639 scoped_refptr<DecoderBuffer> second_file = ReadTestDataFile("sfx.mp3");
1640 source.AppendAtTimeWithWindow(append_time, append_time + mp3_preroll_duration, 1640 source.AppendAtTimeWithWindow(append_time, append_time + mp3_preroll_duration,
1641 kInfiniteDuration(), second_file->data(), 1641 kInfiniteDuration, second_file->data(),
1642 second_file->data_size()); 1642 second_file->data_size());
1643 source.EndOfStream(); 1643 source.EndOfStream();
1644 1644
1645 Play(); 1645 Play();
1646 EXPECT_TRUE(WaitUntilOnEnded()); 1646 EXPECT_TRUE(WaitUntilOnEnded());
1647 1647
1648 EXPECT_EQ(613, source.last_timestamp_offset().InMilliseconds()); 1648 EXPECT_EQ(613, source.last_timestamp_offset().InMilliseconds());
1649 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); 1649 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size());
1650 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); 1650 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds());
1651 EXPECT_EQ(613, pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); 1651 EXPECT_EQ(613, pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds());
(...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after
2400 2400
2401 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) { 2401 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) {
2402 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm")); 2402 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm"));
2403 Play(); 2403 Play();
2404 ASSERT_TRUE(WaitUntilOnEnded()); 2404 ASSERT_TRUE(WaitUntilOnEnded());
2405 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000), 2405 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000),
2406 demuxer_->GetStartTime()); 2406 demuxer_->GetStartTime());
2407 } 2407 }
2408 2408
2409 } // namespace media 2409 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698