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 <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 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 chunk_demuxer_->AppendData(kSourceId, pData, size, append_window_start, | 533 chunk_demuxer_->AppendData(kSourceId, pData, size, append_window_start, |
534 append_window_end, ×tamp_offset)); | 534 append_window_end, ×tamp_offset)); |
535 last_timestamp_offset_ = timestamp_offset; | 535 last_timestamp_offset_ = timestamp_offset; |
536 } | 536 } |
537 | 537 |
538 void SetMemoryLimits(size_t limit_bytes) { | 538 void SetMemoryLimits(size_t limit_bytes) { |
539 chunk_demuxer_->SetMemoryLimitsForTest(DemuxerStream::AUDIO, limit_bytes); | 539 chunk_demuxer_->SetMemoryLimitsForTest(DemuxerStream::AUDIO, limit_bytes); |
540 chunk_demuxer_->SetMemoryLimitsForTest(DemuxerStream::VIDEO, limit_bytes); | 540 chunk_demuxer_->SetMemoryLimitsForTest(DemuxerStream::VIDEO, limit_bytes); |
541 } | 541 } |
542 | 542 |
543 void EvictCodedFrames(base::TimeDelta currentMediaTime, size_t newDataSize) { | 543 bool EvictCodedFrames(base::TimeDelta currentMediaTime, size_t newDataSize) { |
544 chunk_demuxer_->EvictCodedFrames(kSourceId, currentMediaTime, newDataSize); | 544 return chunk_demuxer_->EvictCodedFrames(kSourceId, currentMediaTime, |
| 545 newDataSize); |
545 } | 546 } |
546 | 547 |
547 void RemoveRange(base::TimeDelta start, base::TimeDelta end) { | 548 void RemoveRange(base::TimeDelta start, base::TimeDelta end) { |
548 chunk_demuxer_->Remove(kSourceId, start, end); | 549 chunk_demuxer_->Remove(kSourceId, start, end); |
549 } | 550 } |
550 | 551 |
551 void EndOfStream() { chunk_demuxer_->MarkEndOfStream(PIPELINE_OK); } | 552 void EndOfStream() { chunk_demuxer_->MarkEndOfStream(PIPELINE_OK); } |
552 | 553 |
553 void Shutdown() { | 554 void Shutdown() { |
554 if (!chunk_demuxer_) | 555 if (!chunk_demuxer_) |
(...skipping 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1558 | 1559 |
1559 buffered_ranges = pipeline_->GetBufferedTimeRanges(); | 1560 buffered_ranges = pipeline_->GetBufferedTimeRanges(); |
1560 } while (buffered_ranges.size() == 1 && | 1561 } while (buffered_ranges.size() == 1 && |
1561 buffered_ranges.start(0) == base::TimeDelta::FromSeconds(0)); | 1562 buffered_ranges.start(0) == base::TimeDelta::FromSeconds(0)); |
1562 | 1563 |
1563 EXPECT_EQ(1u, buffered_ranges.size()); | 1564 EXPECT_EQ(1u, buffered_ranges.size()); |
1564 source.Shutdown(); | 1565 source.Shutdown(); |
1565 Stop(); | 1566 Stop(); |
1566 } | 1567 } |
1567 | 1568 |
| 1569 TEST_F(PipelineIntegrationTest, MediaSource_GCWithDisabledVideoStream) { |
| 1570 const char* input_filename = "bear-320x240.webm"; |
| 1571 MockMediaSource source(input_filename, kWebM, kAppendWholeFile); |
| 1572 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); |
| 1573 scoped_refptr<DecoderBuffer> file = ReadTestDataFile(input_filename); |
| 1574 // The input file contains audio + video data. Assuming video data size is |
| 1575 // larger than audio, so setting memory limits to half of file data_size will |
| 1576 // ensure that video SourceBuffer is above memory limit and the audio |
| 1577 // SourceBuffer is below the memory limit. |
| 1578 source.SetMemoryLimits(file->data_size() / 2); |
| 1579 |
| 1580 // Disable the video track and start playback. Renderer won't read from the |
| 1581 // disabled video stream, so the video stream read position should be 0. |
| 1582 pipeline_->OnSelectedVideoTrackChanged(base::nullopt); |
| 1583 Play(); |
| 1584 |
| 1585 // Wait until audio playback advances past 2 seconds and call MSE GC algorithm |
| 1586 // to prepare for more data to be appended. |
| 1587 base::TimeDelta media_time = base::TimeDelta::FromSeconds(2); |
| 1588 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(media_time)); |
| 1589 // At this point the video SourceBuffer is over the memory limit (see the |
| 1590 // SetMemoryLimits comment above), but MSE GC should be able to remove some |
| 1591 // of video data and return true indicating success, even though no data has |
| 1592 // been read from the disabled video stream and its read position is 0. |
| 1593 ASSERT_TRUE(source.EvictCodedFrames(media_time, 10)); |
| 1594 |
| 1595 source.Shutdown(); |
| 1596 Stop(); |
| 1597 } |
| 1598 |
1568 TEST_F(PipelineIntegrationTest, | 1599 TEST_F(PipelineIntegrationTest, |
1569 MAYBE_EME(MediaSource_ConfigChange_Encrypted_WebM)) { | 1600 MAYBE_EME(MediaSource_ConfigChange_Encrypted_WebM)) { |
1570 MockMediaSource source("bear-320x240-16x9-aspect-av_enc-av.webm", kWebM, | 1601 MockMediaSource source("bear-320x240-16x9-aspect-av_enc-av.webm", kWebM, |
1571 kAppendWholeFile); | 1602 kAppendWholeFile); |
1572 FakeEncryptedMedia encrypted_media(new KeyProvidingApp()); | 1603 FakeEncryptedMedia encrypted_media(new KeyProvidingApp()); |
1573 EXPECT_EQ(PIPELINE_OK, | 1604 EXPECT_EQ(PIPELINE_OK, |
1574 StartPipelineWithEncryptedMedia(&source, &encrypted_media)); | 1605 StartPipelineWithEncryptedMedia(&source, &encrypted_media)); |
1575 | 1606 |
1576 EXPECT_CALL(*this, OnVideoNaturalSizeChange(gfx::Size(640, 360))).Times(1); | 1607 EXPECT_CALL(*this, OnVideoNaturalSizeChange(gfx::Size(640, 360))).Times(1); |
1577 scoped_refptr<DecoderBuffer> second_file = | 1608 scoped_refptr<DecoderBuffer> second_file = |
(...skipping 1093 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2671 | 2702 |
2672 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) { | 2703 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) { |
2673 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm")); | 2704 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm")); |
2674 Play(); | 2705 Play(); |
2675 ASSERT_TRUE(WaitUntilOnEnded()); | 2706 ASSERT_TRUE(WaitUntilOnEnded()); |
2676 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000), | 2707 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000), |
2677 demuxer_->GetStartTime()); | 2708 demuxer_->GetStartTime()); |
2678 } | 2709 } |
2679 | 2710 |
2680 } // namespace media | 2711 } // namespace media |
OLD | NEW |