| 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 <algorithm> | 5 #include <algorithm> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/string_split.h" | 10 #include "base/strings/string_split.h" |
| (...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 660 }; | 660 }; |
| 661 | 661 |
| 662 bool InitDemuxer(int stream_flags) { | 662 bool InitDemuxer(int stream_flags) { |
| 663 return InitDemuxerWithEncryptionInfo(stream_flags, false, false); | 663 return InitDemuxerWithEncryptionInfo(stream_flags, false, false); |
| 664 } | 664 } |
| 665 | 665 |
| 666 bool InitDemuxerWithEncryptionInfo( | 666 bool InitDemuxerWithEncryptionInfo( |
| 667 int stream_flags, bool is_audio_encrypted, bool is_video_encrypted) { | 667 int stream_flags, bool is_audio_encrypted, bool is_video_encrypted) { |
| 668 | 668 |
| 669 PipelineStatus expected_status = | 669 PipelineStatus expected_status = |
| 670 (stream_flags != 0) ? PIPELINE_OK : DEMUXER_ERROR_COULD_NOT_OPEN; | 670 (stream_flags != 0) ? PIPELINE_OK : PIPELINE_ERROR_DECODE; |
| 671 | 671 |
| 672 base::TimeDelta expected_duration = kNoTimestamp(); | 672 base::TimeDelta expected_duration = kNoTimestamp(); |
| 673 if (expected_status == PIPELINE_OK) | 673 if (expected_status == PIPELINE_OK) |
| 674 expected_duration = kDefaultDuration(); | 674 expected_duration = kDefaultDuration(); |
| 675 | 675 |
| 676 EXPECT_CALL(*this, DemuxerOpened()); | 676 EXPECT_CALL(*this, DemuxerOpened()); |
| 677 | 677 |
| 678 // Adding expectation prior to CreateInitDoneCB() here because InSequence | 678 // Adding expectation prior to CreateInitDoneCB() here because InSequence |
| 679 // tests require init segment received before duration set. Also, only | 679 // tests require init segment received before duration set. Also, only |
| 680 // expect an init segment received callback if there is actually a track in | 680 // expect an init segment received callback if there is actually a track in |
| (...skipping 999 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1680 | 1680 |
| 1681 EXPECT_CALL(host_, OnDemuxerError(PIPELINE_ERROR_DECODE)); | 1681 EXPECT_CALL(host_, OnDemuxerError(PIPELINE_ERROR_DECODE)); |
| 1682 AppendCluster(cb.Finish()); | 1682 AppendCluster(cb.Finish()); |
| 1683 } | 1683 } |
| 1684 | 1684 |
| 1685 // Test the case where a cluster is passed to AppendCluster() before | 1685 // Test the case where a cluster is passed to AppendCluster() before |
| 1686 // INFO & TRACKS data. | 1686 // INFO & TRACKS data. |
| 1687 TEST_F(ChunkDemuxerTest, ClusterBeforeInitSegment) { | 1687 TEST_F(ChunkDemuxerTest, ClusterBeforeInitSegment) { |
| 1688 EXPECT_CALL(*this, DemuxerOpened()); | 1688 EXPECT_CALL(*this, DemuxerOpened()); |
| 1689 demuxer_->Initialize( | 1689 demuxer_->Initialize( |
| 1690 &host_, NewExpectedStatusCB(DEMUXER_ERROR_COULD_NOT_OPEN), true); | 1690 &host_, NewExpectedStatusCB(PIPELINE_ERROR_DECODE), true); |
| 1691 | 1691 |
| 1692 ASSERT_EQ(AddId(), ChunkDemuxer::kOk); | 1692 ASSERT_EQ(AddId(), ChunkDemuxer::kOk); |
| 1693 | 1693 |
| 1694 AppendCluster(GenerateCluster(0, 1)); | 1694 AppendCluster(GenerateCluster(0, 1)); |
| 1695 } | 1695 } |
| 1696 | 1696 |
| 1697 // Test cases where we get an MarkEndOfStream() call during initialization. | 1697 // Test cases where we get an MarkEndOfStream() call during initialization. |
| 1698 TEST_F(ChunkDemuxerTest, EOSDuringInit) { | 1698 TEST_F(ChunkDemuxerTest, EOSDuringInit) { |
| 1699 EXPECT_CALL(*this, DemuxerOpened()); | 1699 EXPECT_CALL(*this, DemuxerOpened()); |
| 1700 demuxer_->Initialize( | 1700 demuxer_->Initialize( |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2120 message_loop_.RunUntilIdle(); | 2120 message_loop_.RunUntilIdle(); |
| 2121 | 2121 |
| 2122 EXPECT_TRUE(audio_read_done); | 2122 EXPECT_TRUE(audio_read_done); |
| 2123 EXPECT_TRUE(video_read_done); | 2123 EXPECT_TRUE(video_read_done); |
| 2124 } | 2124 } |
| 2125 | 2125 |
| 2126 TEST_F(ChunkDemuxerTest, ParseErrorDuringInit) { | 2126 TEST_F(ChunkDemuxerTest, ParseErrorDuringInit) { |
| 2127 EXPECT_CALL(*this, DemuxerOpened()); | 2127 EXPECT_CALL(*this, DemuxerOpened()); |
| 2128 demuxer_->Initialize( | 2128 demuxer_->Initialize( |
| 2129 &host_, CreateInitDoneCB( | 2129 &host_, CreateInitDoneCB( |
| 2130 kNoTimestamp(), DEMUXER_ERROR_COULD_NOT_OPEN), true); | 2130 kNoTimestamp(), PIPELINE_ERROR_DECODE), true); |
| 2131 | 2131 |
| 2132 ASSERT_EQ(AddId(), ChunkDemuxer::kOk); | 2132 ASSERT_EQ(AddId(), ChunkDemuxer::kOk); |
| 2133 | 2133 |
| 2134 uint8 tmp = 0; | 2134 uint8 tmp = 0; |
| 2135 demuxer_->AppendData(kSourceId, &tmp, 1, | 2135 demuxer_->AppendData(kSourceId, &tmp, 1, |
| 2136 append_window_start_for_next_append_, | 2136 append_window_start_for_next_append_, |
| 2137 append_window_end_for_next_append_, | 2137 append_window_end_for_next_append_, |
| 2138 ×tamp_offset_map_[kSourceId], | 2138 ×tamp_offset_map_[kSourceId], |
| 2139 init_segment_received_cb_); | 2139 init_segment_received_cb_); |
| 2140 } | 2140 } |
| 2141 | 2141 |
| 2142 TEST_F(ChunkDemuxerTest, AVHeadersWithAudioOnlyType) { | 2142 TEST_F(ChunkDemuxerTest, AVHeadersWithAudioOnlyType) { |
| 2143 EXPECT_CALL(*this, DemuxerOpened()); | 2143 EXPECT_CALL(*this, DemuxerOpened()); |
| 2144 demuxer_->Initialize( | 2144 demuxer_->Initialize( |
| 2145 &host_, CreateInitDoneCB(kNoTimestamp(), | 2145 &host_, CreateInitDoneCB(kNoTimestamp(), |
| 2146 DEMUXER_ERROR_COULD_NOT_OPEN), true); | 2146 PIPELINE_ERROR_DECODE), true); |
| 2147 | 2147 |
| 2148 std::vector<std::string> codecs(1); | 2148 std::vector<std::string> codecs(1); |
| 2149 codecs[0] = "vorbis"; | 2149 codecs[0] = "vorbis"; |
| 2150 ASSERT_EQ(demuxer_->AddId(kSourceId, "audio/webm", codecs), | 2150 ASSERT_EQ(demuxer_->AddId(kSourceId, "audio/webm", codecs), |
| 2151 ChunkDemuxer::kOk); | 2151 ChunkDemuxer::kOk); |
| 2152 | 2152 |
| 2153 AppendInitSegment(HAS_AUDIO | HAS_VIDEO); | 2153 AppendInitSegment(HAS_AUDIO | HAS_VIDEO); |
| 2154 } | 2154 } |
| 2155 | 2155 |
| 2156 TEST_F(ChunkDemuxerTest, AVHeadersWithVideoOnlyType) { | 2156 TEST_F(ChunkDemuxerTest, AVHeadersWithVideoOnlyType) { |
| 2157 EXPECT_CALL(*this, DemuxerOpened()); | 2157 EXPECT_CALL(*this, DemuxerOpened()); |
| 2158 demuxer_->Initialize( | 2158 demuxer_->Initialize( |
| 2159 &host_, CreateInitDoneCB(kNoTimestamp(), | 2159 &host_, CreateInitDoneCB(kNoTimestamp(), |
| 2160 DEMUXER_ERROR_COULD_NOT_OPEN), true); | 2160 PIPELINE_ERROR_DECODE), true); |
| 2161 | 2161 |
| 2162 std::vector<std::string> codecs(1); | 2162 std::vector<std::string> codecs(1); |
| 2163 codecs[0] = "vp8"; | 2163 codecs[0] = "vp8"; |
| 2164 ASSERT_EQ(demuxer_->AddId(kSourceId, "video/webm", codecs), | 2164 ASSERT_EQ(demuxer_->AddId(kSourceId, "video/webm", codecs), |
| 2165 ChunkDemuxer::kOk); | 2165 ChunkDemuxer::kOk); |
| 2166 | 2166 |
| 2167 AppendInitSegment(HAS_AUDIO | HAS_VIDEO); | 2167 AppendInitSegment(HAS_AUDIO | HAS_VIDEO); |
| 2168 } | 2168 } |
| 2169 | 2169 |
| 2170 TEST_F(ChunkDemuxerTest, MultipleHeaders) { | 2170 TEST_F(ChunkDemuxerTest, MultipleHeaders) { |
| (...skipping 1579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3750 TEST_F(ChunkDemuxerTest, CuesBetweenClusters) { | 3750 TEST_F(ChunkDemuxerTest, CuesBetweenClusters) { |
| 3751 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); | 3751 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); |
| 3752 | 3752 |
| 3753 AppendCluster(GenerateCluster(0, 0, 4)); | 3753 AppendCluster(GenerateCluster(0, 0, 4)); |
| 3754 AppendData(kCuesHeader, sizeof(kCuesHeader)); | 3754 AppendData(kCuesHeader, sizeof(kCuesHeader)); |
| 3755 AppendCluster(GenerateCluster(46, 66, 5)); | 3755 AppendCluster(GenerateCluster(46, 66, 5)); |
| 3756 CheckExpectedRanges(kSourceId, "{ [0,115) }"); | 3756 CheckExpectedRanges(kSourceId, "{ [0,115) }"); |
| 3757 } | 3757 } |
| 3758 | 3758 |
| 3759 } // namespace media | 3759 } // namespace media |
| OLD | NEW |