| 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 const char kMP3[] = "audio/mpeg"; | 113 const char kMP3[] = "audio/mpeg"; |
| 114 const char kMP2AudioSBR[] = "video/mp2t; codecs=\"avc1.4D4041,mp4a.40.5\""; | 114 const char kMP2AudioSBR[] = "video/mp2t; codecs=\"avc1.4D4041,mp4a.40.5\""; |
| 115 #endif // BUILDFLAG(USE_PROPRIETARY_CODECS) | 115 #endif // BUILDFLAG(USE_PROPRIETARY_CODECS) |
| 116 | 116 |
| 117 const size_t kAppendWholeFile = std::numeric_limits<size_t>::max(); | 117 const size_t kAppendWholeFile = std::numeric_limits<size_t>::max(); |
| 118 | 118 |
| 119 // Constants for the Media Source config change tests. | 119 // Constants for the Media Source config change tests. |
| 120 const int kAppendTimeSec = 1; | 120 const int kAppendTimeSec = 1; |
| 121 const int kAppendTimeMs = kAppendTimeSec * 1000; | 121 const int kAppendTimeMs = kAppendTimeSec * 1000; |
| 122 const int k320WebMFileDurationMs = 2736; | 122 const int k320WebMFileDurationMs = 2736; |
| 123 const int k320EncWebMFileDurationMs = 2737; | |
| 124 const int k640WebMFileDurationMs = 2749; | 123 const int k640WebMFileDurationMs = 2749; |
| 125 const int kOpusEndTrimmingWebMFileDurationMs = 2741; | 124 const int kOpusEndTrimmingWebMFileDurationMs = 2741; |
| 126 const int kVP9WebMFileDurationMs = 2736; | 125 const int kVP9WebMFileDurationMs = 2736; |
| 127 const int kVP8AWebMFileDurationMs = 2734; | 126 const int kVP8AWebMFileDurationMs = 2734; |
| 128 | 127 |
| 129 #if !defined(MOJO_RENDERER) | 128 #if !defined(MOJO_RENDERER) |
| 130 #if defined(OPUS_FIXED_POINT) | 129 #if defined(OPUS_FIXED_POINT) |
| 131 // NOTE: Hashes are specific to ARM devices. x86 will not match. | 130 // NOTE: Hashes are specific to ARM devices. x86 will not match. |
| 132 static const char kOpusEndTrimmingHash_1[] = | 131 static const char kOpusEndTrimmingHash_1[] = |
| 133 "-4.57,-5.66,-6.52,-6.30,-4.37,-3.61,"; | 132 "-4.57,-5.66,-6.52,-6.30,-4.37,-3.61,"; |
| (...skipping 1391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1525 | 1524 |
| 1526 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); | 1525 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); |
| 1527 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); | 1526 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); |
| 1528 EXPECT_EQ(kAppendTimeMs + k640WebMFileDurationMs, | 1527 EXPECT_EQ(kAppendTimeMs + k640WebMFileDurationMs, |
| 1529 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); | 1528 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); |
| 1530 | 1529 |
| 1531 source.Shutdown(); | 1530 source.Shutdown(); |
| 1532 Stop(); | 1531 Stop(); |
| 1533 } | 1532 } |
| 1534 | 1533 |
| 1535 // Config changes from encrypted to clear are not currently supported. | 1534 // TODO(xhwang): Config change from clear to encrypted is allowed by the |
| 1535 // demuxer, but is not currently supported by the Renderer. See |
| 1536 // http://crbug.com/597443 |
| 1536 TEST_F(PipelineIntegrationTest, | 1537 TEST_F(PipelineIntegrationTest, |
| 1537 MAYBE_EME(MediaSource_ConfigChange_ClearThenEncrypted_WebM)) { | 1538 MAYBE_EME(MediaSource_ConfigChange_ClearThenEncrypted_WebM)) { |
| 1538 MockMediaSource source("bear-320x240-16x9-aspect.webm", kWebM, | 1539 MockMediaSource source("bear-320x240-16x9-aspect.webm", kWebM, |
| 1539 kAppendWholeFile); | 1540 kAppendWholeFile); |
| 1540 FakeEncryptedMedia encrypted_media(new KeyProvidingApp()); | 1541 FakeEncryptedMedia encrypted_media(new KeyProvidingApp()); |
| 1541 EXPECT_EQ(PIPELINE_OK, | 1542 EXPECT_EQ(PIPELINE_OK, |
| 1542 StartPipelineWithEncryptedMedia(&source, &encrypted_media)); | 1543 StartPipelineWithEncryptedMedia(&source, &encrypted_media)); |
| 1543 | 1544 |
| 1544 scoped_refptr<DecoderBuffer> second_file = | 1545 scoped_refptr<DecoderBuffer> second_file = |
| 1545 ReadTestDataFile("bear-640x360-av_enc-av.webm"); | 1546 ReadTestDataFile("bear-640x360-av_enc-av.webm"); |
| 1546 | 1547 |
| 1547 ASSERT_FALSE(source.AppendAtTime(base::TimeDelta::FromSeconds(kAppendTimeSec), | 1548 EXPECT_TRUE(source.AppendAtTime(base::TimeDelta::FromSeconds(kAppendTimeSec), |
| 1548 second_file->data(), | 1549 second_file->data(), |
| 1549 second_file->data_size())); | 1550 second_file->data_size())); |
| 1550 | |
| 1551 source.EndOfStream(); | 1551 source.EndOfStream(); |
| 1552 | 1552 |
| 1553 base::RunLoop().Run(); | 1553 Play(); |
| 1554 EXPECT_EQ(CHUNK_DEMUXER_ERROR_APPEND_FAILED, pipeline_status_); | 1554 |
| 1555 EXPECT_EQ(PIPELINE_ERROR_DECODE, WaitUntilEndedOrError()); |
| 1555 | 1556 |
| 1556 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); | 1557 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); |
| 1557 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); | 1558 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); |
| 1558 // The second video was not added, so its time has not been added. | 1559 EXPECT_EQ(kAppendTimeMs + k640WebMFileDurationMs, |
| 1559 EXPECT_EQ(k320WebMFileDurationMs, | |
| 1560 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); | 1560 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); |
| 1561 | 1561 |
| 1562 Play(); | |
| 1563 | |
| 1564 EXPECT_EQ(CHUNK_DEMUXER_ERROR_APPEND_FAILED, WaitUntilEndedOrError()); | |
| 1565 source.Shutdown(); | 1562 source.Shutdown(); |
| 1566 } | 1563 } |
| 1567 | 1564 |
| 1568 // Config changes from clear to encrypted are not currently supported. | 1565 // Config change from encrypted to clear is allowed by the demuxer, and is |
| 1566 // supported by the Renderer. |
| 1569 TEST_F(PipelineIntegrationTest, | 1567 TEST_F(PipelineIntegrationTest, |
| 1570 MAYBE_EME(MediaSource_ConfigChange_EncryptedThenClear_WebM)) { | 1568 MAYBE_EME(MediaSource_ConfigChange_EncryptedThenClear_WebM)) { |
| 1571 MockMediaSource source("bear-320x240-16x9-aspect-av_enc-av.webm", kWebM, | 1569 MockMediaSource source("bear-320x240-16x9-aspect-av_enc-av.webm", kWebM, |
| 1572 kAppendWholeFile); | 1570 kAppendWholeFile); |
| 1573 FakeEncryptedMedia encrypted_media(new KeyProvidingApp()); | 1571 FakeEncryptedMedia encrypted_media(new KeyProvidingApp()); |
| 1574 EXPECT_EQ(PIPELINE_OK, | 1572 EXPECT_EQ(PIPELINE_OK, |
| 1575 StartPipelineWithEncryptedMedia(&source, &encrypted_media)); | 1573 StartPipelineWithEncryptedMedia(&source, &encrypted_media)); |
| 1576 | 1574 |
| 1575 EXPECT_CALL(*this, OnVideoNaturalSizeChange(gfx::Size(640, 360))).Times(1); |
| 1577 scoped_refptr<DecoderBuffer> second_file = | 1576 scoped_refptr<DecoderBuffer> second_file = |
| 1578 ReadTestDataFile("bear-640x360.webm"); | 1577 ReadTestDataFile("bear-640x360.webm"); |
| 1579 | 1578 |
| 1580 ASSERT_FALSE(source.AppendAtTime(base::TimeDelta::FromSeconds(kAppendTimeSec), | 1579 ASSERT_TRUE(source.AppendAtTime(base::TimeDelta::FromSeconds(kAppendTimeSec), |
| 1581 second_file->data(), | 1580 second_file->data(), |
| 1582 second_file->data_size())); | 1581 second_file->data_size())); |
| 1582 source.EndOfStream(); |
| 1583 | 1583 |
| 1584 source.EndOfStream(); | 1584 Play(); |
| 1585 ASSERT_TRUE(WaitUntilOnEnded()); |
| 1585 | 1586 |
| 1586 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); | 1587 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); |
| 1587 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); | 1588 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); |
| 1588 // The second video was not added, so its time has not been added. | 1589 EXPECT_EQ(kAppendTimeMs + k640WebMFileDurationMs, |
| 1589 EXPECT_EQ(k320EncWebMFileDurationMs, | |
| 1590 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); | 1590 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); |
| 1591 | 1591 |
| 1592 Play(); | |
| 1593 | |
| 1594 EXPECT_EQ(CHUNK_DEMUXER_ERROR_APPEND_FAILED, WaitUntilEndedOrError()); | |
| 1595 source.Shutdown(); | 1592 source.Shutdown(); |
| 1593 Stop(); |
| 1596 } | 1594 } |
| 1597 | 1595 |
| 1598 #if defined(ARCH_CPU_X86_FAMILY) && !defined(OS_ANDROID) | 1596 #if defined(ARCH_CPU_X86_FAMILY) && !defined(OS_ANDROID) |
| 1599 TEST_F(PipelineIntegrationTest, BasicPlaybackHi10PVP9) { | 1597 TEST_F(PipelineIntegrationTest, BasicPlaybackHi10PVP9) { |
| 1600 ASSERT_EQ(PIPELINE_OK, Start("bear-320x180-hi10p-vp9.webm", kClockless)); | 1598 ASSERT_EQ(PIPELINE_OK, Start("bear-320x180-hi10p-vp9.webm", kClockless)); |
| 1601 | 1599 |
| 1602 Play(); | 1600 Play(); |
| 1603 | 1601 |
| 1604 ASSERT_TRUE(WaitUntilOnEnded()); | 1602 ASSERT_TRUE(WaitUntilOnEnded()); |
| 1605 } | 1603 } |
| (...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2584 | 2582 |
| 2585 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) { | 2583 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) { |
| 2586 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm")); | 2584 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm")); |
| 2587 Play(); | 2585 Play(); |
| 2588 ASSERT_TRUE(WaitUntilOnEnded()); | 2586 ASSERT_TRUE(WaitUntilOnEnded()); |
| 2589 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000), | 2587 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000), |
| 2590 demuxer_->GetStartTime()); | 2588 demuxer_->GetStartTime()); |
| 2591 } | 2589 } |
| 2592 | 2590 |
| 2593 } // namespace media | 2591 } // namespace media |
| OLD | NEW |