| 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 10 matching lines...) Expand all Loading... |
| 21 #include "media/formats/webm/webm_crypto_helpers.h" | 21 #include "media/formats/webm/webm_crypto_helpers.h" |
| 22 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
| 23 | 23 |
| 24 using ::testing::AnyNumber; | 24 using ::testing::AnyNumber; |
| 25 using ::testing::Exactly; | 25 using ::testing::Exactly; |
| 26 using ::testing::InSequence; | 26 using ::testing::InSequence; |
| 27 using ::testing::NotNull; | 27 using ::testing::NotNull; |
| 28 using ::testing::Return; | 28 using ::testing::Return; |
| 29 using ::testing::SaveArg; | 29 using ::testing::SaveArg; |
| 30 using ::testing::SetArgumentPointee; | 30 using ::testing::SetArgumentPointee; |
| 31 using ::testing::Values; | |
| 32 using ::testing::_; | 31 using ::testing::_; |
| 33 | 32 |
| 34 namespace media { | 33 namespace media { |
| 35 | 34 |
| 36 const uint8 kTracksHeader[] = { | 35 const uint8 kTracksHeader[] = { |
| 37 0x16, 0x54, 0xAE, 0x6B, // Tracks ID | 36 0x16, 0x54, 0xAE, 0x6B, // Tracks ID |
| 38 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // tracks(size = 0) | 37 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // tracks(size = 0) |
| 39 }; | 38 }; |
| 40 | 39 |
| 41 // WebM Block bytes that represent a VP8 keyframe. | 40 // WebM Block bytes that represent a VP8 keyframe. |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 *called = true; | 125 *called = true; |
| 127 } | 126 } |
| 128 | 127 |
| 129 static void OnSeekDone_OKExpected(bool* called, PipelineStatus status) { | 128 static void OnSeekDone_OKExpected(bool* called, PipelineStatus status) { |
| 130 EXPECT_EQ(status, PIPELINE_OK); | 129 EXPECT_EQ(status, PIPELINE_OK); |
| 131 *called = true; | 130 *called = true; |
| 132 } | 131 } |
| 133 | 132 |
| 134 static void LogFunc(const std::string& str) { DVLOG(1) << str; } | 133 static void LogFunc(const std::string& str) { DVLOG(1) << str; } |
| 135 | 134 |
| 136 // Test parameter determines which coded frame processor is used to process | 135 class ChunkDemuxerTest : public ::testing::Test { |
| 137 // appended data. If true, LegacyFrameProcessor is used. Otherwise, the new | |
| 138 // FrameProcessor is used. | |
| 139 class ChunkDemuxerTest : public ::testing::TestWithParam<bool> { | |
| 140 protected: | 136 protected: |
| 141 enum CodecsIndex { | 137 enum CodecsIndex { |
| 142 AUDIO, | 138 AUDIO, |
| 143 VIDEO, | 139 VIDEO, |
| 144 MAX_CODECS_INDEX | 140 MAX_CODECS_INDEX |
| 145 }; | 141 }; |
| 146 | 142 |
| 147 // Default cluster to append first for simple tests. | 143 // Default cluster to append first for simple tests. |
| 148 scoped_ptr<Cluster> kDefaultFirstCluster() { | 144 scoped_ptr<Cluster> kDefaultFirstCluster() { |
| 149 return GenerateCluster(0, 4); | 145 return GenerateCluster(0, 4); |
| 150 } | 146 } |
| 151 | 147 |
| 152 // Default cluster to append after kDefaultFirstCluster() | 148 // Default cluster to append after kDefaultFirstCluster() |
| 153 // has been appended. This cluster starts with blocks that | 149 // has been appended. This cluster starts with blocks that |
| 154 // have timestamps consistent with the end times of the blocks | 150 // have timestamps consistent with the end times of the blocks |
| 155 // in kDefaultFirstCluster() so that these two clusters represent | 151 // in kDefaultFirstCluster() so that these two clusters represent |
| 156 // a continuous region. | 152 // a continuous region. |
| 157 scoped_ptr<Cluster> kDefaultSecondCluster() { | 153 scoped_ptr<Cluster> kDefaultSecondCluster() { |
| 158 return GenerateCluster(46, 66, 5); | 154 return GenerateCluster(46, 66, 5); |
| 159 } | 155 } |
| 160 | 156 |
| 161 ChunkDemuxerTest() | 157 ChunkDemuxerTest() |
| 162 : append_window_end_for_next_append_(kInfiniteDuration()) { | 158 : append_window_end_for_next_append_(kInfiniteDuration()) { |
| 163 use_legacy_frame_processor_ = GetParam(); | |
| 164 CreateNewDemuxer(); | 159 CreateNewDemuxer(); |
| 165 } | 160 } |
| 166 | 161 |
| 167 void CreateNewDemuxer() { | 162 void CreateNewDemuxer() { |
| 168 base::Closure open_cb = | 163 base::Closure open_cb = |
| 169 base::Bind(&ChunkDemuxerTest::DemuxerOpened, base::Unretained(this)); | 164 base::Bind(&ChunkDemuxerTest::DemuxerOpened, base::Unretained(this)); |
| 170 Demuxer::NeedKeyCB need_key_cb = | 165 Demuxer::NeedKeyCB need_key_cb = |
| 171 base::Bind(&ChunkDemuxerTest::DemuxerNeedKey, base::Unretained(this)); | 166 base::Bind(&ChunkDemuxerTest::DemuxerNeedKey, base::Unretained(this)); |
| 172 demuxer_.reset( | 167 demuxer_.reset( |
| 173 new ChunkDemuxer(open_cb, need_key_cb, base::Bind(&LogFunc), true)); | 168 new ChunkDemuxer(open_cb, need_key_cb, base::Bind(&LogFunc), true)); |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 | 306 |
| 312 if (has_video) { | 307 if (has_video) { |
| 313 codecs.push_back("vp8"); | 308 codecs.push_back("vp8"); |
| 314 type = "video/webm"; | 309 type = "video/webm"; |
| 315 } | 310 } |
| 316 | 311 |
| 317 if (!has_audio && !has_video) { | 312 if (!has_audio && !has_video) { |
| 318 return AddId(kSourceId, HAS_AUDIO | HAS_VIDEO); | 313 return AddId(kSourceId, HAS_AUDIO | HAS_VIDEO); |
| 319 } | 314 } |
| 320 | 315 |
| 321 return demuxer_->AddId(source_id, type, codecs, | 316 return demuxer_->AddId(source_id, type, codecs); |
| 322 use_legacy_frame_processor_); | |
| 323 } | 317 } |
| 324 | 318 |
| 325 ChunkDemuxer::Status AddIdForMp2tSource(const std::string& source_id) { | 319 ChunkDemuxer::Status AddIdForMp2tSource(const std::string& source_id) { |
| 326 std::vector<std::string> codecs; | 320 std::vector<std::string> codecs; |
| 327 std::string type = "video/mp2t"; | 321 std::string type = "video/mp2t"; |
| 328 codecs.push_back("mp4a.40.2"); | 322 codecs.push_back("mp4a.40.2"); |
| 329 codecs.push_back("avc1.640028"); | 323 codecs.push_back("avc1.640028"); |
| 330 return demuxer_->AddId(source_id, type, codecs, | 324 return demuxer_->AddId(source_id, type, codecs); |
| 331 use_legacy_frame_processor_); | |
| 332 } | 325 } |
| 333 | 326 |
| 334 void AppendData(const uint8* data, size_t length) { | 327 void AppendData(const uint8* data, size_t length) { |
| 335 AppendData(kSourceId, data, length); | 328 AppendData(kSourceId, data, length); |
| 336 } | 329 } |
| 337 | 330 |
| 338 void AppendCluster(const std::string& source_id, | 331 void AppendCluster(const std::string& source_id, |
| 339 scoped_ptr<Cluster> cluster) { | 332 scoped_ptr<Cluster> cluster) { |
| 340 AppendData(source_id, cluster->data(), cluster->size()); | 333 AppendData(source_id, cluster->data(), cluster->size()); |
| 341 } | 334 } |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 &data[0], data.size()); | 397 &data[0], data.size()); |
| 405 } | 398 } |
| 406 } | 399 } |
| 407 AppendCluster(source_id, cb.Finish()); | 400 AppendCluster(source_id, cb.Finish()); |
| 408 } | 401 } |
| 409 | 402 |
| 410 void AppendData(const std::string& source_id, | 403 void AppendData(const std::string& source_id, |
| 411 const uint8* data, size_t length) { | 404 const uint8* data, size_t length) { |
| 412 EXPECT_CALL(host_, AddBufferedTimeRange(_, _)).Times(AnyNumber()); | 405 EXPECT_CALL(host_, AddBufferedTimeRange(_, _)).Times(AnyNumber()); |
| 413 | 406 |
| 414 // TODO(wolenetz): Test timestamp offset updating once "sequence" append | |
| 415 // mode processing is implemented. See http://crbug.com/249422. | |
| 416 demuxer_->AppendData(source_id, data, length, | 407 demuxer_->AppendData(source_id, data, length, |
| 417 append_window_start_for_next_append_, | 408 append_window_start_for_next_append_, |
| 418 append_window_end_for_next_append_, | 409 append_window_end_for_next_append_, |
| 419 ×tamp_offset_map_[source_id]); | 410 ×tamp_offset_map_[source_id]); |
| 420 } | 411 } |
| 421 | 412 |
| 422 void AppendDataInPieces(const uint8* data, size_t length) { | 413 void AppendDataInPieces(const uint8* data, size_t length) { |
| 423 AppendDataInPieces(data, length, 7); | 414 AppendDataInPieces(data, length, 7); |
| 424 } | 415 } |
| 425 | 416 |
| (...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 986 return false; | 977 return false; |
| 987 | 978 |
| 988 timestamp_offset_map_[id] = timestamp_offset; | 979 timestamp_offset_map_[id] = timestamp_offset; |
| 989 return true; | 980 return true; |
| 990 } | 981 } |
| 991 | 982 |
| 992 base::MessageLoop message_loop_; | 983 base::MessageLoop message_loop_; |
| 993 MockDemuxerHost host_; | 984 MockDemuxerHost host_; |
| 994 | 985 |
| 995 scoped_ptr<ChunkDemuxer> demuxer_; | 986 scoped_ptr<ChunkDemuxer> demuxer_; |
| 996 bool use_legacy_frame_processor_; | |
| 997 | 987 |
| 998 base::TimeDelta append_window_start_for_next_append_; | 988 base::TimeDelta append_window_start_for_next_append_; |
| 999 base::TimeDelta append_window_end_for_next_append_; | 989 base::TimeDelta append_window_end_for_next_append_; |
| 1000 | 990 |
| 1001 // Map of source id to timestamp offset to use for the next AppendData() | 991 // Map of source id to timestamp offset to use for the next AppendData() |
| 1002 // operation for that source id. | 992 // operation for that source id. |
| 1003 std::map<std::string, base::TimeDelta> timestamp_offset_map_; | 993 std::map<std::string, base::TimeDelta> timestamp_offset_map_; |
| 1004 | 994 |
| 1005 private: | 995 private: |
| 1006 DISALLOW_COPY_AND_ASSIGN(ChunkDemuxerTest); | 996 DISALLOW_COPY_AND_ASSIGN(ChunkDemuxerTest); |
| 1007 }; | 997 }; |
| 1008 | 998 |
| 1009 TEST_P(ChunkDemuxerTest, Init) { | 999 TEST_F(ChunkDemuxerTest, Init) { |
| 1010 // Test no streams, audio-only, video-only, and audio & video scenarios. | 1000 // Test no streams, audio-only, video-only, and audio & video scenarios. |
| 1011 // Audio and video streams can be encrypted or not encrypted. | 1001 // Audio and video streams can be encrypted or not encrypted. |
| 1012 for (int i = 0; i < 16; i++) { | 1002 for (int i = 0; i < 16; i++) { |
| 1013 bool has_audio = (i & 0x1) != 0; | 1003 bool has_audio = (i & 0x1) != 0; |
| 1014 bool has_video = (i & 0x2) != 0; | 1004 bool has_video = (i & 0x2) != 0; |
| 1015 bool is_audio_encrypted = (i & 0x4) != 0; | 1005 bool is_audio_encrypted = (i & 0x4) != 0; |
| 1016 bool is_video_encrypted = (i & 0x8) != 0; | 1006 bool is_video_encrypted = (i & 0x8) != 0; |
| 1017 | 1007 |
| 1018 // No test on invalid combination. | 1008 // No test on invalid combination. |
| 1019 if ((!has_audio && is_audio_encrypted) || | 1009 if ((!has_audio && is_audio_encrypted) || |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1072 EXPECT_FALSE(video_stream); | 1062 EXPECT_FALSE(video_stream); |
| 1073 } | 1063 } |
| 1074 | 1064 |
| 1075 ShutdownDemuxer(); | 1065 ShutdownDemuxer(); |
| 1076 demuxer_.reset(); | 1066 demuxer_.reset(); |
| 1077 } | 1067 } |
| 1078 } | 1068 } |
| 1079 | 1069 |
| 1080 // TODO(acolwell): Fold this test into Init tests since the tests are | 1070 // TODO(acolwell): Fold this test into Init tests since the tests are |
| 1081 // almost identical. | 1071 // almost identical. |
| 1082 TEST_P(ChunkDemuxerTest, InitText) { | 1072 TEST_F(ChunkDemuxerTest, InitText) { |
| 1083 // Test with 1 video stream and 1 text streams, and 0 or 1 audio streams. | 1073 // Test with 1 video stream and 1 text streams, and 0 or 1 audio streams. |
| 1084 // No encryption cases handled here. | 1074 // No encryption cases handled here. |
| 1085 bool has_video = true; | 1075 bool has_video = true; |
| 1086 bool is_audio_encrypted = false; | 1076 bool is_audio_encrypted = false; |
| 1087 bool is_video_encrypted = false; | 1077 bool is_video_encrypted = false; |
| 1088 for (int i = 0; i < 2; i++) { | 1078 for (int i = 0; i < 2; i++) { |
| 1089 bool has_audio = (i & 0x1) != 0; | 1079 bool has_audio = (i & 0x1) != 0; |
| 1090 | 1080 |
| 1091 CreateNewDemuxer(); | 1081 CreateNewDemuxer(); |
| 1092 | 1082 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1142 EXPECT_FALSE(video_stream); | 1132 EXPECT_FALSE(video_stream); |
| 1143 } | 1133 } |
| 1144 | 1134 |
| 1145 ShutdownDemuxer(); | 1135 ShutdownDemuxer(); |
| 1146 demuxer_.reset(); | 1136 demuxer_.reset(); |
| 1147 } | 1137 } |
| 1148 } | 1138 } |
| 1149 | 1139 |
| 1150 // Make sure that the demuxer reports an error if Shutdown() | 1140 // Make sure that the demuxer reports an error if Shutdown() |
| 1151 // is called before all the initialization segments are appended. | 1141 // is called before all the initialization segments are appended. |
| 1152 TEST_P(ChunkDemuxerTest, Shutdown_BeforeAllInitSegmentsAppended) { | 1142 TEST_F(ChunkDemuxerTest, Shutdown_BeforeAllInitSegmentsAppended) { |
| 1153 EXPECT_CALL(*this, DemuxerOpened()); | 1143 EXPECT_CALL(*this, DemuxerOpened()); |
| 1154 demuxer_->Initialize( | 1144 demuxer_->Initialize( |
| 1155 &host_, CreateInitDoneCB( | 1145 &host_, CreateInitDoneCB( |
| 1156 kDefaultDuration(), DEMUXER_ERROR_COULD_NOT_OPEN), true); | 1146 kDefaultDuration(), DEMUXER_ERROR_COULD_NOT_OPEN), true); |
| 1157 | 1147 |
| 1158 EXPECT_EQ(AddId("audio", HAS_AUDIO), ChunkDemuxer::kOk); | 1148 EXPECT_EQ(AddId("audio", HAS_AUDIO), ChunkDemuxer::kOk); |
| 1159 EXPECT_EQ(AddId("video", HAS_VIDEO), ChunkDemuxer::kOk); | 1149 EXPECT_EQ(AddId("video", HAS_VIDEO), ChunkDemuxer::kOk); |
| 1160 | 1150 |
| 1161 AppendInitSegmentWithSourceId("audio", HAS_AUDIO); | 1151 AppendInitSegmentWithSourceId("audio", HAS_AUDIO); |
| 1162 | 1152 |
| 1163 ShutdownDemuxer(); | 1153 ShutdownDemuxer(); |
| 1164 } | 1154 } |
| 1165 | 1155 |
| 1166 TEST_P(ChunkDemuxerTest, Shutdown_BeforeAllInitSegmentsAppendedText) { | 1156 TEST_F(ChunkDemuxerTest, Shutdown_BeforeAllInitSegmentsAppendedText) { |
| 1167 EXPECT_CALL(*this, DemuxerOpened()); | 1157 EXPECT_CALL(*this, DemuxerOpened()); |
| 1168 demuxer_->Initialize( | 1158 demuxer_->Initialize( |
| 1169 &host_, CreateInitDoneCB( | 1159 &host_, CreateInitDoneCB( |
| 1170 kDefaultDuration(), DEMUXER_ERROR_COULD_NOT_OPEN), true); | 1160 kDefaultDuration(), DEMUXER_ERROR_COULD_NOT_OPEN), true); |
| 1171 | 1161 |
| 1172 EXPECT_EQ(AddId("audio", HAS_AUDIO), ChunkDemuxer::kOk); | 1162 EXPECT_EQ(AddId("audio", HAS_AUDIO), ChunkDemuxer::kOk); |
| 1173 EXPECT_EQ(AddId("video_and_text", HAS_VIDEO), ChunkDemuxer::kOk); | 1163 EXPECT_EQ(AddId("video_and_text", HAS_VIDEO), ChunkDemuxer::kOk); |
| 1174 | 1164 |
| 1175 EXPECT_CALL(host_, AddTextStream(_, _)) | 1165 EXPECT_CALL(host_, AddTextStream(_, _)) |
| 1176 .Times(Exactly(1)); | 1166 .Times(Exactly(1)); |
| 1177 | 1167 |
| 1178 AppendInitSegmentWithSourceId("video_and_text", HAS_VIDEO | HAS_TEXT); | 1168 AppendInitSegmentWithSourceId("video_and_text", HAS_VIDEO | HAS_TEXT); |
| 1179 | 1169 |
| 1180 ShutdownDemuxer(); | 1170 ShutdownDemuxer(); |
| 1181 } | 1171 } |
| 1182 | 1172 |
| 1183 // Verifies that all streams waiting for data receive an end of stream | 1173 // Verifies that all streams waiting for data receive an end of stream |
| 1184 // buffer when Shutdown() is called. | 1174 // buffer when Shutdown() is called. |
| 1185 TEST_P(ChunkDemuxerTest, Shutdown_EndOfStreamWhileWaitingForData) { | 1175 TEST_F(ChunkDemuxerTest, Shutdown_EndOfStreamWhileWaitingForData) { |
| 1186 DemuxerStream* text_stream = NULL; | 1176 DemuxerStream* text_stream = NULL; |
| 1187 EXPECT_CALL(host_, AddTextStream(_, _)) | 1177 EXPECT_CALL(host_, AddTextStream(_, _)) |
| 1188 .WillOnce(SaveArg<0>(&text_stream)); | 1178 .WillOnce(SaveArg<0>(&text_stream)); |
| 1189 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO | HAS_TEXT)); | 1179 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO | HAS_TEXT)); |
| 1190 | 1180 |
| 1191 DemuxerStream* audio_stream = demuxer_->GetStream(DemuxerStream::AUDIO); | 1181 DemuxerStream* audio_stream = demuxer_->GetStream(DemuxerStream::AUDIO); |
| 1192 DemuxerStream* video_stream = demuxer_->GetStream(DemuxerStream::VIDEO); | 1182 DemuxerStream* video_stream = demuxer_->GetStream(DemuxerStream::VIDEO); |
| 1193 | 1183 |
| 1194 bool audio_read_done = false; | 1184 bool audio_read_done = false; |
| 1195 bool video_read_done = false; | 1185 bool video_read_done = false; |
| 1196 bool text_read_done = false; | 1186 bool text_read_done = false; |
| 1197 audio_stream->Read(base::Bind(&OnReadDone_EOSExpected, &audio_read_done)); | 1187 audio_stream->Read(base::Bind(&OnReadDone_EOSExpected, &audio_read_done)); |
| 1198 video_stream->Read(base::Bind(&OnReadDone_EOSExpected, &video_read_done)); | 1188 video_stream->Read(base::Bind(&OnReadDone_EOSExpected, &video_read_done)); |
| 1199 text_stream->Read(base::Bind(&OnReadDone_EOSExpected, &text_read_done)); | 1189 text_stream->Read(base::Bind(&OnReadDone_EOSExpected, &text_read_done)); |
| 1200 message_loop_.RunUntilIdle(); | 1190 message_loop_.RunUntilIdle(); |
| 1201 | 1191 |
| 1202 EXPECT_FALSE(audio_read_done); | 1192 EXPECT_FALSE(audio_read_done); |
| 1203 EXPECT_FALSE(video_read_done); | 1193 EXPECT_FALSE(video_read_done); |
| 1204 EXPECT_FALSE(text_read_done); | 1194 EXPECT_FALSE(text_read_done); |
| 1205 | 1195 |
| 1206 ShutdownDemuxer(); | 1196 ShutdownDemuxer(); |
| 1207 | 1197 |
| 1208 EXPECT_TRUE(audio_read_done); | 1198 EXPECT_TRUE(audio_read_done); |
| 1209 EXPECT_TRUE(video_read_done); | 1199 EXPECT_TRUE(video_read_done); |
| 1210 EXPECT_TRUE(text_read_done); | 1200 EXPECT_TRUE(text_read_done); |
| 1211 } | 1201 } |
| 1212 | 1202 |
| 1213 // Test that Seek() completes successfully when the first cluster | 1203 // Test that Seek() completes successfully when the first cluster |
| 1214 // arrives. | 1204 // arrives. |
| 1215 TEST_P(ChunkDemuxerTest, AppendDataAfterSeek) { | 1205 TEST_F(ChunkDemuxerTest, AppendDataAfterSeek) { |
| 1216 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); | 1206 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); |
| 1217 AppendCluster(kDefaultFirstCluster()); | 1207 AppendCluster(kDefaultFirstCluster()); |
| 1218 | 1208 |
| 1219 InSequence s; | 1209 InSequence s; |
| 1220 | 1210 |
| 1221 EXPECT_CALL(*this, Checkpoint(1)); | 1211 EXPECT_CALL(*this, Checkpoint(1)); |
| 1222 | 1212 |
| 1223 Seek(base::TimeDelta::FromMilliseconds(46)); | 1213 Seek(base::TimeDelta::FromMilliseconds(46)); |
| 1224 | 1214 |
| 1225 EXPECT_CALL(*this, Checkpoint(2)); | 1215 EXPECT_CALL(*this, Checkpoint(2)); |
| 1226 | 1216 |
| 1227 Checkpoint(1); | 1217 Checkpoint(1); |
| 1228 | 1218 |
| 1229 AppendCluster(kDefaultSecondCluster()); | 1219 AppendCluster(kDefaultSecondCluster()); |
| 1230 | 1220 |
| 1231 message_loop_.RunUntilIdle(); | 1221 message_loop_.RunUntilIdle(); |
| 1232 | 1222 |
| 1233 Checkpoint(2); | 1223 Checkpoint(2); |
| 1234 } | 1224 } |
| 1235 | 1225 |
| 1236 // Test that parsing errors are handled for clusters appended after init. | 1226 // Test that parsing errors are handled for clusters appended after init. |
| 1237 TEST_P(ChunkDemuxerTest, ErrorWhileParsingClusterAfterInit) { | 1227 TEST_F(ChunkDemuxerTest, ErrorWhileParsingClusterAfterInit) { |
| 1238 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); | 1228 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); |
| 1239 AppendCluster(kDefaultFirstCluster()); | 1229 AppendCluster(kDefaultFirstCluster()); |
| 1240 | 1230 |
| 1241 EXPECT_CALL(host_, OnDemuxerError(PIPELINE_ERROR_DECODE)); | 1231 EXPECT_CALL(host_, OnDemuxerError(PIPELINE_ERROR_DECODE)); |
| 1242 AppendGarbage(); | 1232 AppendGarbage(); |
| 1243 } | 1233 } |
| 1244 | 1234 |
| 1245 // Test the case where a Seek() is requested while the parser | 1235 // Test the case where a Seek() is requested while the parser |
| 1246 // is in the middle of cluster. This is to verify that the parser | 1236 // is in the middle of cluster. This is to verify that the parser |
| 1247 // does not reset itself on a seek. | 1237 // does not reset itself on a seek. |
| 1248 TEST_P(ChunkDemuxerTest, SeekWhileParsingCluster) { | 1238 TEST_F(ChunkDemuxerTest, SeekWhileParsingCluster) { |
| 1249 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); | 1239 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); |
| 1250 | 1240 |
| 1251 InSequence s; | 1241 InSequence s; |
| 1252 | 1242 |
| 1253 scoped_ptr<Cluster> cluster_a(GenerateCluster(0, 6)); | 1243 scoped_ptr<Cluster> cluster_a(GenerateCluster(0, 6)); |
| 1254 | 1244 |
| 1255 // Split the cluster into two appends at an arbitrary point near the end. | 1245 // Split the cluster into two appends at an arbitrary point near the end. |
| 1256 int first_append_size = cluster_a->size() - 11; | 1246 int first_append_size = cluster_a->size() - 11; |
| 1257 int second_append_size = cluster_a->size() - first_append_size; | 1247 int second_append_size = cluster_a->size() - first_append_size; |
| 1258 | 1248 |
| 1259 // Append the first part of the cluster. | 1249 // Append the first part of the cluster. |
| 1260 AppendData(cluster_a->data(), first_append_size); | 1250 AppendData(cluster_a->data(), first_append_size); |
| 1261 | 1251 |
| 1262 ExpectRead(DemuxerStream::AUDIO, 0); | 1252 ExpectRead(DemuxerStream::AUDIO, 0); |
| 1263 ExpectRead(DemuxerStream::VIDEO, 0); | 1253 ExpectRead(DemuxerStream::VIDEO, 0); |
| 1264 ExpectRead(DemuxerStream::AUDIO, kAudioBlockDuration); | 1254 ExpectRead(DemuxerStream::AUDIO, kAudioBlockDuration); |
| 1265 | 1255 |
| 1266 Seek(base::TimeDelta::FromSeconds(5)); | 1256 Seek(base::TimeDelta::FromSeconds(5)); |
| 1267 | 1257 |
| 1268 // Append the rest of the cluster. | 1258 // Append the rest of the cluster. |
| 1269 AppendData(cluster_a->data() + first_append_size, second_append_size); | 1259 AppendData(cluster_a->data() + first_append_size, second_append_size); |
| 1270 | 1260 |
| 1271 // Append the new cluster and verify that only the blocks | 1261 // Append the new cluster and verify that only the blocks |
| 1272 // in the new cluster are returned. | 1262 // in the new cluster are returned. |
| 1273 AppendCluster(GenerateCluster(5000, 6)); | 1263 AppendCluster(GenerateCluster(5000, 6)); |
| 1274 GenerateExpectedReads(5000, 6); | 1264 GenerateExpectedReads(5000, 6); |
| 1275 } | 1265 } |
| 1276 | 1266 |
| 1277 // Test the case where AppendData() is called before Init(). | 1267 // Test the case where AppendData() is called before Init(). |
| 1278 TEST_P(ChunkDemuxerTest, AppendDataBeforeInit) { | 1268 TEST_F(ChunkDemuxerTest, AppendDataBeforeInit) { |
| 1279 scoped_ptr<uint8[]> info_tracks; | 1269 scoped_ptr<uint8[]> info_tracks; |
| 1280 int info_tracks_size = 0; | 1270 int info_tracks_size = 0; |
| 1281 CreateInitSegment(HAS_AUDIO | HAS_VIDEO, | 1271 CreateInitSegment(HAS_AUDIO | HAS_VIDEO, |
| 1282 false, false, &info_tracks, &info_tracks_size); | 1272 false, false, &info_tracks, &info_tracks_size); |
| 1283 demuxer_->AppendData(kSourceId, info_tracks.get(), info_tracks_size, | 1273 demuxer_->AppendData(kSourceId, info_tracks.get(), info_tracks_size, |
| 1284 append_window_start_for_next_append_, | 1274 append_window_start_for_next_append_, |
| 1285 append_window_end_for_next_append_, | 1275 append_window_end_for_next_append_, |
| 1286 ×tamp_offset_map_[kSourceId]); | 1276 ×tamp_offset_map_[kSourceId]); |
| 1287 } | 1277 } |
| 1288 | 1278 |
| 1289 // Make sure Read() callbacks are dispatched with the proper data. | 1279 // Make sure Read() callbacks are dispatched with the proper data. |
| 1290 TEST_P(ChunkDemuxerTest, Read) { | 1280 TEST_F(ChunkDemuxerTest, Read) { |
| 1291 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); | 1281 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); |
| 1292 | 1282 |
| 1293 AppendCluster(kDefaultFirstCluster()); | 1283 AppendCluster(kDefaultFirstCluster()); |
| 1294 | 1284 |
| 1295 bool audio_read_done = false; | 1285 bool audio_read_done = false; |
| 1296 bool video_read_done = false; | 1286 bool video_read_done = false; |
| 1297 ReadAudio(base::Bind(&OnReadDone, | 1287 ReadAudio(base::Bind(&OnReadDone, |
| 1298 base::TimeDelta::FromMilliseconds(0), | 1288 base::TimeDelta::FromMilliseconds(0), |
| 1299 &audio_read_done)); | 1289 &audio_read_done)); |
| 1300 ReadVideo(base::Bind(&OnReadDone, | 1290 ReadVideo(base::Bind(&OnReadDone, |
| 1301 base::TimeDelta::FromMilliseconds(0), | 1291 base::TimeDelta::FromMilliseconds(0), |
| 1302 &video_read_done)); | 1292 &video_read_done)); |
| 1303 | 1293 |
| 1304 EXPECT_TRUE(audio_read_done); | 1294 EXPECT_TRUE(audio_read_done); |
| 1305 EXPECT_TRUE(video_read_done); | 1295 EXPECT_TRUE(video_read_done); |
| 1306 } | 1296 } |
| 1307 | 1297 |
| 1308 TEST_P(ChunkDemuxerTest, OutOfOrderClusters) { | 1298 TEST_F(ChunkDemuxerTest, OutOfOrderClusters) { |
| 1309 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); | 1299 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); |
| 1310 AppendCluster(kDefaultFirstCluster()); | 1300 AppendCluster(kDefaultFirstCluster()); |
| 1311 AppendCluster(GenerateCluster(10, 4)); | 1301 AppendCluster(GenerateCluster(10, 4)); |
| 1312 | 1302 |
| 1313 // Make sure that AppendCluster() does not fail with a cluster that has | 1303 // Make sure that AppendCluster() does not fail with a cluster that has |
| 1314 // overlaps with the previously appended cluster. | 1304 // overlaps with the previously appended cluster. |
| 1315 AppendCluster(GenerateCluster(5, 4)); | 1305 AppendCluster(GenerateCluster(5, 4)); |
| 1316 | 1306 |
| 1317 // Verify that AppendData() can still accept more data. | 1307 // Verify that AppendData() can still accept more data. |
| 1318 scoped_ptr<Cluster> cluster_c(GenerateCluster(45, 2)); | 1308 scoped_ptr<Cluster> cluster_c(GenerateCluster(45, 2)); |
| 1319 demuxer_->AppendData(kSourceId, cluster_c->data(), cluster_c->size(), | 1309 demuxer_->AppendData(kSourceId, cluster_c->data(), cluster_c->size(), |
| 1320 append_window_start_for_next_append_, | 1310 append_window_start_for_next_append_, |
| 1321 append_window_end_for_next_append_, | 1311 append_window_end_for_next_append_, |
| 1322 ×tamp_offset_map_[kSourceId]); | 1312 ×tamp_offset_map_[kSourceId]); |
| 1323 } | 1313 } |
| 1324 | 1314 |
| 1325 TEST_P(ChunkDemuxerTest, NonMonotonicButAboveClusterTimecode) { | 1315 TEST_F(ChunkDemuxerTest, NonMonotonicButAboveClusterTimecode) { |
| 1326 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); | 1316 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); |
| 1327 AppendCluster(kDefaultFirstCluster()); | 1317 AppendCluster(kDefaultFirstCluster()); |
| 1328 | 1318 |
| 1329 ClusterBuilder cb; | 1319 ClusterBuilder cb; |
| 1330 | 1320 |
| 1331 // Test the case where block timecodes are not monotonically | 1321 // Test the case where block timecodes are not monotonically |
| 1332 // increasing but stay above the cluster timecode. | 1322 // increasing but stay above the cluster timecode. |
| 1333 cb.SetClusterTimecode(5); | 1323 cb.SetClusterTimecode(5); |
| 1334 AddSimpleBlock(&cb, kAudioTrackNum, 5); | 1324 AddSimpleBlock(&cb, kAudioTrackNum, 5); |
| 1335 AddSimpleBlock(&cb, kVideoTrackNum, 10); | 1325 AddSimpleBlock(&cb, kVideoTrackNum, 10); |
| 1336 AddSimpleBlock(&cb, kAudioTrackNum, 7); | 1326 AddSimpleBlock(&cb, kAudioTrackNum, 7); |
| 1337 AddSimpleBlock(&cb, kVideoTrackNum, 15); | 1327 AddSimpleBlock(&cb, kVideoTrackNum, 15); |
| 1338 | 1328 |
| 1339 EXPECT_CALL(host_, OnDemuxerError(PIPELINE_ERROR_DECODE)); | 1329 EXPECT_CALL(host_, OnDemuxerError(PIPELINE_ERROR_DECODE)); |
| 1340 AppendCluster(cb.Finish()); | 1330 AppendCluster(cb.Finish()); |
| 1341 | 1331 |
| 1342 // Verify that AppendData() ignores data after the error. | 1332 // Verify that AppendData() ignores data after the error. |
| 1343 scoped_ptr<Cluster> cluster_b(GenerateCluster(20, 2)); | 1333 scoped_ptr<Cluster> cluster_b(GenerateCluster(20, 2)); |
| 1344 demuxer_->AppendData(kSourceId, cluster_b->data(), cluster_b->size(), | 1334 demuxer_->AppendData(kSourceId, cluster_b->data(), cluster_b->size(), |
| 1345 append_window_start_for_next_append_, | 1335 append_window_start_for_next_append_, |
| 1346 append_window_end_for_next_append_, | 1336 append_window_end_for_next_append_, |
| 1347 ×tamp_offset_map_[kSourceId]); | 1337 ×tamp_offset_map_[kSourceId]); |
| 1348 } | 1338 } |
| 1349 | 1339 |
| 1350 TEST_P(ChunkDemuxerTest, BackwardsAndBeforeClusterTimecode) { | 1340 TEST_F(ChunkDemuxerTest, BackwardsAndBeforeClusterTimecode) { |
| 1351 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); | 1341 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); |
| 1352 AppendCluster(kDefaultFirstCluster()); | 1342 AppendCluster(kDefaultFirstCluster()); |
| 1353 | 1343 |
| 1354 ClusterBuilder cb; | 1344 ClusterBuilder cb; |
| 1355 | 1345 |
| 1356 // Test timecodes going backwards and including values less than the cluster | 1346 // Test timecodes going backwards and including values less than the cluster |
| 1357 // timecode. | 1347 // timecode. |
| 1358 cb.SetClusterTimecode(5); | 1348 cb.SetClusterTimecode(5); |
| 1359 AddSimpleBlock(&cb, kAudioTrackNum, 5); | 1349 AddSimpleBlock(&cb, kAudioTrackNum, 5); |
| 1360 AddSimpleBlock(&cb, kVideoTrackNum, 5); | 1350 AddSimpleBlock(&cb, kVideoTrackNum, 5); |
| 1361 AddSimpleBlock(&cb, kAudioTrackNum, 3); | 1351 AddSimpleBlock(&cb, kAudioTrackNum, 3); |
| 1362 AddSimpleBlock(&cb, kVideoTrackNum, 3); | 1352 AddSimpleBlock(&cb, kVideoTrackNum, 3); |
| 1363 | 1353 |
| 1364 EXPECT_CALL(host_, OnDemuxerError(PIPELINE_ERROR_DECODE)); | 1354 EXPECT_CALL(host_, OnDemuxerError(PIPELINE_ERROR_DECODE)); |
| 1365 AppendCluster(cb.Finish()); | 1355 AppendCluster(cb.Finish()); |
| 1366 | 1356 |
| 1367 // Verify that AppendData() ignores data after the error. | 1357 // Verify that AppendData() ignores data after the error. |
| 1368 scoped_ptr<Cluster> cluster_b(GenerateCluster(6, 2)); | 1358 scoped_ptr<Cluster> cluster_b(GenerateCluster(6, 2)); |
| 1369 demuxer_->AppendData(kSourceId, cluster_b->data(), cluster_b->size(), | 1359 demuxer_->AppendData(kSourceId, cluster_b->data(), cluster_b->size(), |
| 1370 append_window_start_for_next_append_, | 1360 append_window_start_for_next_append_, |
| 1371 append_window_end_for_next_append_, | 1361 append_window_end_for_next_append_, |
| 1372 ×tamp_offset_map_[kSourceId]); | 1362 ×tamp_offset_map_[kSourceId]); |
| 1373 } | 1363 } |
| 1374 | 1364 |
| 1375 | 1365 |
| 1376 TEST_P(ChunkDemuxerTest, PerStreamMonotonicallyIncreasingTimestamps) { | 1366 TEST_F(ChunkDemuxerTest, PerStreamMonotonicallyIncreasingTimestamps) { |
| 1377 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); | 1367 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); |
| 1378 AppendCluster(kDefaultFirstCluster()); | 1368 AppendCluster(kDefaultFirstCluster()); |
| 1379 | 1369 |
| 1380 ClusterBuilder cb; | 1370 ClusterBuilder cb; |
| 1381 | 1371 |
| 1382 // Test monotonic increasing timestamps on a per stream | 1372 // Test monotonic increasing timestamps on a per stream |
| 1383 // basis. | 1373 // basis. |
| 1384 cb.SetClusterTimecode(5); | 1374 cb.SetClusterTimecode(5); |
| 1385 AddSimpleBlock(&cb, kAudioTrackNum, 5); | 1375 AddSimpleBlock(&cb, kAudioTrackNum, 5); |
| 1386 AddSimpleBlock(&cb, kVideoTrackNum, 5); | 1376 AddSimpleBlock(&cb, kVideoTrackNum, 5); |
| 1387 AddSimpleBlock(&cb, kAudioTrackNum, 4); | 1377 AddSimpleBlock(&cb, kAudioTrackNum, 4); |
| 1388 AddSimpleBlock(&cb, kVideoTrackNum, 7); | 1378 AddSimpleBlock(&cb, kVideoTrackNum, 7); |
| 1389 | 1379 |
| 1390 EXPECT_CALL(host_, OnDemuxerError(PIPELINE_ERROR_DECODE)); | 1380 EXPECT_CALL(host_, OnDemuxerError(PIPELINE_ERROR_DECODE)); |
| 1391 AppendCluster(cb.Finish()); | 1381 AppendCluster(cb.Finish()); |
| 1392 } | 1382 } |
| 1393 | 1383 |
| 1394 // Test the case where a cluster is passed to AppendCluster() before | 1384 // Test the case where a cluster is passed to AppendCluster() before |
| 1395 // INFO & TRACKS data. | 1385 // INFO & TRACKS data. |
| 1396 TEST_P(ChunkDemuxerTest, ClusterBeforeInitSegment) { | 1386 TEST_F(ChunkDemuxerTest, ClusterBeforeInitSegment) { |
| 1397 EXPECT_CALL(*this, DemuxerOpened()); | 1387 EXPECT_CALL(*this, DemuxerOpened()); |
| 1398 demuxer_->Initialize( | 1388 demuxer_->Initialize( |
| 1399 &host_, NewExpectedStatusCB(DEMUXER_ERROR_COULD_NOT_OPEN), true); | 1389 &host_, NewExpectedStatusCB(DEMUXER_ERROR_COULD_NOT_OPEN), true); |
| 1400 | 1390 |
| 1401 ASSERT_EQ(AddId(), ChunkDemuxer::kOk); | 1391 ASSERT_EQ(AddId(), ChunkDemuxer::kOk); |
| 1402 | 1392 |
| 1403 AppendCluster(GenerateCluster(0, 1)); | 1393 AppendCluster(GenerateCluster(0, 1)); |
| 1404 } | 1394 } |
| 1405 | 1395 |
| 1406 // Test cases where we get an MarkEndOfStream() call during initialization. | 1396 // Test cases where we get an MarkEndOfStream() call during initialization. |
| 1407 TEST_P(ChunkDemuxerTest, EOSDuringInit) { | 1397 TEST_F(ChunkDemuxerTest, EOSDuringInit) { |
| 1408 EXPECT_CALL(*this, DemuxerOpened()); | 1398 EXPECT_CALL(*this, DemuxerOpened()); |
| 1409 demuxer_->Initialize( | 1399 demuxer_->Initialize( |
| 1410 &host_, NewExpectedStatusCB(DEMUXER_ERROR_COULD_NOT_OPEN), true); | 1400 &host_, NewExpectedStatusCB(DEMUXER_ERROR_COULD_NOT_OPEN), true); |
| 1411 MarkEndOfStream(PIPELINE_OK); | 1401 MarkEndOfStream(PIPELINE_OK); |
| 1412 } | 1402 } |
| 1413 | 1403 |
| 1414 TEST_P(ChunkDemuxerTest, EndOfStreamWithNoAppend) { | 1404 TEST_F(ChunkDemuxerTest, EndOfStreamWithNoAppend) { |
| 1415 EXPECT_CALL(*this, DemuxerOpened()); | 1405 EXPECT_CALL(*this, DemuxerOpened()); |
| 1416 demuxer_->Initialize( | 1406 demuxer_->Initialize( |
| 1417 &host_, NewExpectedStatusCB(DEMUXER_ERROR_COULD_NOT_OPEN), true); | 1407 &host_, NewExpectedStatusCB(DEMUXER_ERROR_COULD_NOT_OPEN), true); |
| 1418 | 1408 |
| 1419 ASSERT_EQ(AddId(), ChunkDemuxer::kOk); | 1409 ASSERT_EQ(AddId(), ChunkDemuxer::kOk); |
| 1420 | 1410 |
| 1421 CheckExpectedRanges("{ }"); | 1411 CheckExpectedRanges("{ }"); |
| 1422 MarkEndOfStream(PIPELINE_OK); | 1412 MarkEndOfStream(PIPELINE_OK); |
| 1423 ShutdownDemuxer(); | 1413 ShutdownDemuxer(); |
| 1424 CheckExpectedRanges("{ }"); | 1414 CheckExpectedRanges("{ }"); |
| 1425 demuxer_->RemoveId(kSourceId); | 1415 demuxer_->RemoveId(kSourceId); |
| 1426 demuxer_.reset(); | 1416 demuxer_.reset(); |
| 1427 } | 1417 } |
| 1428 | 1418 |
| 1429 TEST_P(ChunkDemuxerTest, EndOfStreamWithNoMediaAppend) { | 1419 TEST_F(ChunkDemuxerTest, EndOfStreamWithNoMediaAppend) { |
| 1430 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); | 1420 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); |
| 1431 | 1421 |
| 1432 CheckExpectedRanges("{ }"); | 1422 CheckExpectedRanges("{ }"); |
| 1433 MarkEndOfStream(PIPELINE_OK); | 1423 MarkEndOfStream(PIPELINE_OK); |
| 1434 CheckExpectedRanges("{ }"); | 1424 CheckExpectedRanges("{ }"); |
| 1435 } | 1425 } |
| 1436 | 1426 |
| 1437 TEST_P(ChunkDemuxerTest, DecodeErrorEndOfStream) { | 1427 TEST_F(ChunkDemuxerTest, DecodeErrorEndOfStream) { |
| 1438 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); | 1428 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); |
| 1439 | 1429 |
| 1440 AppendCluster(kDefaultFirstCluster()); | 1430 AppendCluster(kDefaultFirstCluster()); |
| 1441 CheckExpectedRanges(kDefaultFirstClusterRange); | 1431 CheckExpectedRanges(kDefaultFirstClusterRange); |
| 1442 | 1432 |
| 1443 EXPECT_CALL(host_, OnDemuxerError(PIPELINE_ERROR_DECODE)); | 1433 EXPECT_CALL(host_, OnDemuxerError(PIPELINE_ERROR_DECODE)); |
| 1444 MarkEndOfStream(PIPELINE_ERROR_DECODE); | 1434 MarkEndOfStream(PIPELINE_ERROR_DECODE); |
| 1445 CheckExpectedRanges(kDefaultFirstClusterRange); | 1435 CheckExpectedRanges(kDefaultFirstClusterRange); |
| 1446 } | 1436 } |
| 1447 | 1437 |
| 1448 TEST_P(ChunkDemuxerTest, NetworkErrorEndOfStream) { | 1438 TEST_F(ChunkDemuxerTest, NetworkErrorEndOfStream) { |
| 1449 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); | 1439 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); |
| 1450 | 1440 |
| 1451 AppendCluster(kDefaultFirstCluster()); | 1441 AppendCluster(kDefaultFirstCluster()); |
| 1452 CheckExpectedRanges(kDefaultFirstClusterRange); | 1442 CheckExpectedRanges(kDefaultFirstClusterRange); |
| 1453 | 1443 |
| 1454 EXPECT_CALL(host_, OnDemuxerError(PIPELINE_ERROR_NETWORK)); | 1444 EXPECT_CALL(host_, OnDemuxerError(PIPELINE_ERROR_NETWORK)); |
| 1455 MarkEndOfStream(PIPELINE_ERROR_NETWORK); | 1445 MarkEndOfStream(PIPELINE_ERROR_NETWORK); |
| 1456 } | 1446 } |
| 1457 | 1447 |
| 1458 // Helper class to reduce duplicate code when testing end of stream | 1448 // Helper class to reduce duplicate code when testing end of stream |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1498 | 1488 |
| 1499 Demuxer* demuxer_; | 1489 Demuxer* demuxer_; |
| 1500 bool audio_read_done_; | 1490 bool audio_read_done_; |
| 1501 bool video_read_done_; | 1491 bool video_read_done_; |
| 1502 | 1492 |
| 1503 DISALLOW_COPY_AND_ASSIGN(EndOfStreamHelper); | 1493 DISALLOW_COPY_AND_ASSIGN(EndOfStreamHelper); |
| 1504 }; | 1494 }; |
| 1505 | 1495 |
| 1506 // Make sure that all pending reads that we don't have media data for get an | 1496 // Make sure that all pending reads that we don't have media data for get an |
| 1507 // "end of stream" buffer when MarkEndOfStream() is called. | 1497 // "end of stream" buffer when MarkEndOfStream() is called. |
| 1508 TEST_P(ChunkDemuxerTest, EndOfStreamWithPendingReads) { | 1498 TEST_F(ChunkDemuxerTest, EndOfStreamWithPendingReads) { |
| 1509 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); | 1499 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); |
| 1510 | 1500 |
| 1511 AppendCluster(GenerateCluster(0, 2)); | 1501 AppendCluster(GenerateCluster(0, 2)); |
| 1512 | 1502 |
| 1513 bool audio_read_done_1 = false; | 1503 bool audio_read_done_1 = false; |
| 1514 bool video_read_done_1 = false; | 1504 bool video_read_done_1 = false; |
| 1515 EndOfStreamHelper end_of_stream_helper_1(demuxer_.get()); | 1505 EndOfStreamHelper end_of_stream_helper_1(demuxer_.get()); |
| 1516 EndOfStreamHelper end_of_stream_helper_2(demuxer_.get()); | 1506 EndOfStreamHelper end_of_stream_helper_2(demuxer_.get()); |
| 1517 | 1507 |
| 1518 ReadAudio(base::Bind(&OnReadDone, | 1508 ReadAudio(base::Bind(&OnReadDone, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1533 MarkEndOfStream(PIPELINE_OK); | 1523 MarkEndOfStream(PIPELINE_OK); |
| 1534 | 1524 |
| 1535 end_of_stream_helper_1.CheckIfReadDonesWereCalled(true); | 1525 end_of_stream_helper_1.CheckIfReadDonesWereCalled(true); |
| 1536 | 1526 |
| 1537 end_of_stream_helper_2.RequestReads(); | 1527 end_of_stream_helper_2.RequestReads(); |
| 1538 end_of_stream_helper_2.CheckIfReadDonesWereCalled(true); | 1528 end_of_stream_helper_2.CheckIfReadDonesWereCalled(true); |
| 1539 } | 1529 } |
| 1540 | 1530 |
| 1541 // Make sure that all Read() calls after we get an MarkEndOfStream() | 1531 // Make sure that all Read() calls after we get an MarkEndOfStream() |
| 1542 // call return an "end of stream" buffer. | 1532 // call return an "end of stream" buffer. |
| 1543 TEST_P(ChunkDemuxerTest, ReadsAfterEndOfStream) { | 1533 TEST_F(ChunkDemuxerTest, ReadsAfterEndOfStream) { |
| 1544 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); | 1534 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); |
| 1545 | 1535 |
| 1546 AppendCluster(GenerateCluster(0, 2)); | 1536 AppendCluster(GenerateCluster(0, 2)); |
| 1547 | 1537 |
| 1548 bool audio_read_done_1 = false; | 1538 bool audio_read_done_1 = false; |
| 1549 bool video_read_done_1 = false; | 1539 bool video_read_done_1 = false; |
| 1550 EndOfStreamHelper end_of_stream_helper_1(demuxer_.get()); | 1540 EndOfStreamHelper end_of_stream_helper_1(demuxer_.get()); |
| 1551 EndOfStreamHelper end_of_stream_helper_2(demuxer_.get()); | 1541 EndOfStreamHelper end_of_stream_helper_2(demuxer_.get()); |
| 1552 EndOfStreamHelper end_of_stream_helper_3(demuxer_.get()); | 1542 EndOfStreamHelper end_of_stream_helper_3(demuxer_.get()); |
| 1553 | 1543 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1572 | 1562 |
| 1573 // Request a few more reads and make sure we immediately get | 1563 // Request a few more reads and make sure we immediately get |
| 1574 // end of stream buffers. | 1564 // end of stream buffers. |
| 1575 end_of_stream_helper_2.RequestReads(); | 1565 end_of_stream_helper_2.RequestReads(); |
| 1576 end_of_stream_helper_2.CheckIfReadDonesWereCalled(true); | 1566 end_of_stream_helper_2.CheckIfReadDonesWereCalled(true); |
| 1577 | 1567 |
| 1578 end_of_stream_helper_3.RequestReads(); | 1568 end_of_stream_helper_3.RequestReads(); |
| 1579 end_of_stream_helper_3.CheckIfReadDonesWereCalled(true); | 1569 end_of_stream_helper_3.CheckIfReadDonesWereCalled(true); |
| 1580 } | 1570 } |
| 1581 | 1571 |
| 1582 TEST_P(ChunkDemuxerTest, EndOfStreamDuringCanceledSeek) { | 1572 TEST_F(ChunkDemuxerTest, EndOfStreamDuringCanceledSeek) { |
| 1583 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); | 1573 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); |
| 1584 | 1574 |
| 1585 AppendCluster(0, 10); | 1575 AppendCluster(0, 10); |
| 1586 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(138))); | 1576 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(138))); |
| 1587 MarkEndOfStream(PIPELINE_OK); | 1577 MarkEndOfStream(PIPELINE_OK); |
| 1588 | 1578 |
| 1589 // Start the first seek. | 1579 // Start the first seek. |
| 1590 Seek(base::TimeDelta::FromMilliseconds(20)); | 1580 Seek(base::TimeDelta::FromMilliseconds(20)); |
| 1591 | 1581 |
| 1592 // Simulate another seek being requested before the first | 1582 // Simulate another seek being requested before the first |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1603 // Make sure audio can reach end of stream. | 1593 // Make sure audio can reach end of stream. |
| 1604 ReadUntilNotOkOrEndOfStream(DemuxerStream::AUDIO, &status, &last_timestamp); | 1594 ReadUntilNotOkOrEndOfStream(DemuxerStream::AUDIO, &status, &last_timestamp); |
| 1605 ASSERT_EQ(status, DemuxerStream::kOk); | 1595 ASSERT_EQ(status, DemuxerStream::kOk); |
| 1606 | 1596 |
| 1607 // Make sure video can reach end of stream. | 1597 // Make sure video can reach end of stream. |
| 1608 ReadUntilNotOkOrEndOfStream(DemuxerStream::VIDEO, &status, &last_timestamp); | 1598 ReadUntilNotOkOrEndOfStream(DemuxerStream::VIDEO, &status, &last_timestamp); |
| 1609 ASSERT_EQ(status, DemuxerStream::kOk); | 1599 ASSERT_EQ(status, DemuxerStream::kOk); |
| 1610 } | 1600 } |
| 1611 | 1601 |
| 1612 // Verify buffered range change behavior for audio/video/text tracks. | 1602 // Verify buffered range change behavior for audio/video/text tracks. |
| 1613 TEST_P(ChunkDemuxerTest, EndOfStreamRangeChanges) { | 1603 TEST_F(ChunkDemuxerTest, EndOfStreamRangeChanges) { |
| 1614 DemuxerStream* text_stream = NULL; | 1604 DemuxerStream* text_stream = NULL; |
| 1615 | 1605 |
| 1616 EXPECT_CALL(host_, AddTextStream(_, _)) | 1606 EXPECT_CALL(host_, AddTextStream(_, _)) |
| 1617 .WillOnce(SaveArg<0>(&text_stream)); | 1607 .WillOnce(SaveArg<0>(&text_stream)); |
| 1618 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO | HAS_TEXT)); | 1608 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO | HAS_TEXT)); |
| 1619 | 1609 |
| 1620 AppendSingleStreamCluster(kSourceId, kVideoTrackNum, "0K 33"); | 1610 AppendSingleStreamCluster(kSourceId, kVideoTrackNum, "0K 33"); |
| 1621 AppendSingleStreamCluster(kSourceId, kAudioTrackNum, "0K 23K"); | 1611 AppendSingleStreamCluster(kSourceId, kAudioTrackNum, "0K 23K"); |
| 1622 | 1612 |
| 1623 // Check expected ranges and verify that an empty text track does not | 1613 // Check expected ranges and verify that an empty text track does not |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1642 AppendSingleStreamCluster(kSourceId, kTextTrackNum, "0K 100K"); | 1632 AppendSingleStreamCluster(kSourceId, kTextTrackNum, "0K 100K"); |
| 1643 CheckExpectedRanges(kSourceId, "{ [0,46) }"); | 1633 CheckExpectedRanges(kSourceId, "{ [0,46) }"); |
| 1644 | 1634 |
| 1645 // Mark end of stream and verify that text track data is reflected in | 1635 // Mark end of stream and verify that text track data is reflected in |
| 1646 // the new range. | 1636 // the new range. |
| 1647 MarkEndOfStream(PIPELINE_OK); | 1637 MarkEndOfStream(PIPELINE_OK); |
| 1648 CheckExpectedRanges(kSourceId, "{ [0,200) }"); | 1638 CheckExpectedRanges(kSourceId, "{ [0,200) }"); |
| 1649 } | 1639 } |
| 1650 | 1640 |
| 1651 // Make sure AppendData() will accept elements that span multiple calls. | 1641 // Make sure AppendData() will accept elements that span multiple calls. |
| 1652 TEST_P(ChunkDemuxerTest, AppendingInPieces) { | 1642 TEST_F(ChunkDemuxerTest, AppendingInPieces) { |
| 1653 EXPECT_CALL(*this, DemuxerOpened()); | 1643 EXPECT_CALL(*this, DemuxerOpened()); |
| 1654 demuxer_->Initialize( | 1644 demuxer_->Initialize( |
| 1655 &host_, CreateInitDoneCB(kDefaultDuration(), PIPELINE_OK), true); | 1645 &host_, CreateInitDoneCB(kDefaultDuration(), PIPELINE_OK), true); |
| 1656 | 1646 |
| 1657 ASSERT_EQ(AddId(), ChunkDemuxer::kOk); | 1647 ASSERT_EQ(AddId(), ChunkDemuxer::kOk); |
| 1658 | 1648 |
| 1659 scoped_ptr<uint8[]> info_tracks; | 1649 scoped_ptr<uint8[]> info_tracks; |
| 1660 int info_tracks_size = 0; | 1650 int info_tracks_size = 0; |
| 1661 CreateInitSegment(HAS_AUDIO | HAS_VIDEO, | 1651 CreateInitSegment(HAS_AUDIO | HAS_VIDEO, |
| 1662 false, false, &info_tracks, &info_tracks_size); | 1652 false, false, &info_tracks, &info_tracks_size); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1674 dst += cluster_a->size(); | 1664 dst += cluster_a->size(); |
| 1675 | 1665 |
| 1676 memcpy(dst, cluster_b->data(), cluster_b->size()); | 1666 memcpy(dst, cluster_b->data(), cluster_b->size()); |
| 1677 dst += cluster_b->size(); | 1667 dst += cluster_b->size(); |
| 1678 | 1668 |
| 1679 AppendDataInPieces(buffer.get(), buffer_size); | 1669 AppendDataInPieces(buffer.get(), buffer_size); |
| 1680 | 1670 |
| 1681 GenerateExpectedReads(0, 9); | 1671 GenerateExpectedReads(0, 9); |
| 1682 } | 1672 } |
| 1683 | 1673 |
| 1684 TEST_P(ChunkDemuxerTest, WebMFile_AudioAndVideo) { | 1674 TEST_F(ChunkDemuxerTest, WebMFile_AudioAndVideo) { |
| 1685 struct BufferTimestamps buffer_timestamps[] = { | 1675 struct BufferTimestamps buffer_timestamps[] = { |
| 1686 {0, 0}, | 1676 {0, 0}, |
| 1687 {33, 3}, | 1677 {33, 3}, |
| 1688 {67, 6}, | 1678 {67, 6}, |
| 1689 {100, 9}, | 1679 {100, 9}, |
| 1690 {133, 12}, | 1680 {133, 12}, |
| 1691 {kSkip, kSkip}, | 1681 {kSkip, kSkip}, |
| 1692 }; | 1682 }; |
| 1693 | 1683 |
| 1694 // TODO(wolenetz/acolwell): Remove this SetDuration expectation and update the | 1684 // TODO(wolenetz/acolwell): Remove this SetDuration expectation and update the |
| 1695 // ParseWebMFile() call's expected duration, below, once the file is fixed to | 1685 // ParseWebMFile() call's expected duration, below, once the file is fixed to |
| 1696 // have the correct duration in the init segment. See http://crbug.com/354284. | 1686 // have the correct duration in the init segment. See http://crbug.com/354284. |
| 1697 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(2746))); | 1687 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(2746))); |
| 1698 | 1688 |
| 1699 ASSERT_TRUE(ParseWebMFile("bear-320x240.webm", buffer_timestamps, | 1689 ASSERT_TRUE(ParseWebMFile("bear-320x240.webm", buffer_timestamps, |
| 1700 base::TimeDelta::FromMilliseconds(2744))); | 1690 base::TimeDelta::FromMilliseconds(2744))); |
| 1701 } | 1691 } |
| 1702 | 1692 |
| 1703 TEST_P(ChunkDemuxerTest, WebMFile_LiveAudioAndVideo) { | 1693 TEST_F(ChunkDemuxerTest, WebMFile_LiveAudioAndVideo) { |
| 1704 struct BufferTimestamps buffer_timestamps[] = { | 1694 struct BufferTimestamps buffer_timestamps[] = { |
| 1705 {0, 0}, | 1695 {0, 0}, |
| 1706 {33, 3}, | 1696 {33, 3}, |
| 1707 {67, 6}, | 1697 {67, 6}, |
| 1708 {100, 9}, | 1698 {100, 9}, |
| 1709 {133, 12}, | 1699 {133, 12}, |
| 1710 {kSkip, kSkip}, | 1700 {kSkip, kSkip}, |
| 1711 }; | 1701 }; |
| 1712 | 1702 |
| 1713 ASSERT_TRUE(ParseWebMFile("bear-320x240-live.webm", buffer_timestamps, | 1703 ASSERT_TRUE(ParseWebMFile("bear-320x240-live.webm", buffer_timestamps, |
| 1714 kInfiniteDuration())); | 1704 kInfiniteDuration())); |
| 1715 } | 1705 } |
| 1716 | 1706 |
| 1717 TEST_P(ChunkDemuxerTest, WebMFile_AudioOnly) { | 1707 TEST_F(ChunkDemuxerTest, WebMFile_AudioOnly) { |
| 1718 struct BufferTimestamps buffer_timestamps[] = { | 1708 struct BufferTimestamps buffer_timestamps[] = { |
| 1719 {kSkip, 0}, | 1709 {kSkip, 0}, |
| 1720 {kSkip, 3}, | 1710 {kSkip, 3}, |
| 1721 {kSkip, 6}, | 1711 {kSkip, 6}, |
| 1722 {kSkip, 9}, | 1712 {kSkip, 9}, |
| 1723 {kSkip, 12}, | 1713 {kSkip, 12}, |
| 1724 {kSkip, kSkip}, | 1714 {kSkip, kSkip}, |
| 1725 }; | 1715 }; |
| 1726 | 1716 |
| 1727 // TODO(wolenetz/acolwell): Remove this SetDuration expectation and update the | 1717 // TODO(wolenetz/acolwell): Remove this SetDuration expectation and update the |
| 1728 // ParseWebMFile() call's expected duration, below, once the file is fixed to | 1718 // ParseWebMFile() call's expected duration, below, once the file is fixed to |
| 1729 // have the correct duration in the init segment. See http://crbug.com/354284. | 1719 // have the correct duration in the init segment. See http://crbug.com/354284. |
| 1730 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(2746))); | 1720 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(2746))); |
| 1731 | 1721 |
| 1732 ASSERT_TRUE(ParseWebMFile("bear-320x240-audio-only.webm", buffer_timestamps, | 1722 ASSERT_TRUE(ParseWebMFile("bear-320x240-audio-only.webm", buffer_timestamps, |
| 1733 base::TimeDelta::FromMilliseconds(2744), | 1723 base::TimeDelta::FromMilliseconds(2744), |
| 1734 HAS_AUDIO)); | 1724 HAS_AUDIO)); |
| 1735 } | 1725 } |
| 1736 | 1726 |
| 1737 TEST_P(ChunkDemuxerTest, WebMFile_VideoOnly) { | 1727 TEST_F(ChunkDemuxerTest, WebMFile_VideoOnly) { |
| 1738 struct BufferTimestamps buffer_timestamps[] = { | 1728 struct BufferTimestamps buffer_timestamps[] = { |
| 1739 {0, kSkip}, | 1729 {0, kSkip}, |
| 1740 {33, kSkip}, | 1730 {33, kSkip}, |
| 1741 {67, kSkip}, | 1731 {67, kSkip}, |
| 1742 {100, kSkip}, | 1732 {100, kSkip}, |
| 1743 {133, kSkip}, | 1733 {133, kSkip}, |
| 1744 {kSkip, kSkip}, | 1734 {kSkip, kSkip}, |
| 1745 }; | 1735 }; |
| 1746 | 1736 |
| 1747 // TODO(wolenetz/acolwell): Remove this SetDuration expectation and update the | 1737 // TODO(wolenetz/acolwell): Remove this SetDuration expectation and update the |
| 1748 // ParseWebMFile() call's expected duration, below, once the file is fixed to | 1738 // ParseWebMFile() call's expected duration, below, once the file is fixed to |
| 1749 // have the correct duration in the init segment. See http://crbug.com/354284. | 1739 // have the correct duration in the init segment. See http://crbug.com/354284. |
| 1750 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(2736))); | 1740 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(2736))); |
| 1751 | 1741 |
| 1752 ASSERT_TRUE(ParseWebMFile("bear-320x240-video-only.webm", buffer_timestamps, | 1742 ASSERT_TRUE(ParseWebMFile("bear-320x240-video-only.webm", buffer_timestamps, |
| 1753 base::TimeDelta::FromMilliseconds(2703), | 1743 base::TimeDelta::FromMilliseconds(2703), |
| 1754 HAS_VIDEO)); | 1744 HAS_VIDEO)); |
| 1755 } | 1745 } |
| 1756 | 1746 |
| 1757 TEST_P(ChunkDemuxerTest, WebMFile_AltRefFrames) { | 1747 TEST_F(ChunkDemuxerTest, WebMFile_AltRefFrames) { |
| 1758 struct BufferTimestamps buffer_timestamps[] = { | 1748 struct BufferTimestamps buffer_timestamps[] = { |
| 1759 {0, 0}, | 1749 {0, 0}, |
| 1760 {33, 3}, | 1750 {33, 3}, |
| 1761 {33, 6}, | 1751 {33, 6}, |
| 1762 {67, 9}, | 1752 {67, 9}, |
| 1763 {100, 12}, | 1753 {100, 12}, |
| 1764 {kSkip, kSkip}, | 1754 {kSkip, kSkip}, |
| 1765 }; | 1755 }; |
| 1766 | 1756 |
| 1767 ASSERT_TRUE(ParseWebMFile("bear-320x240-altref.webm", buffer_timestamps, | 1757 ASSERT_TRUE(ParseWebMFile("bear-320x240-altref.webm", buffer_timestamps, |
| 1768 base::TimeDelta::FromMilliseconds(2767))); | 1758 base::TimeDelta::FromMilliseconds(2767))); |
| 1769 } | 1759 } |
| 1770 | 1760 |
| 1771 // Verify that we output buffers before the entire cluster has been parsed. | 1761 // Verify that we output buffers before the entire cluster has been parsed. |
| 1772 TEST_P(ChunkDemuxerTest, IncrementalClusterParsing) { | 1762 TEST_F(ChunkDemuxerTest, IncrementalClusterParsing) { |
| 1773 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); | 1763 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); |
| 1774 AppendEmptyCluster(0); | 1764 AppendEmptyCluster(0); |
| 1775 | 1765 |
| 1776 scoped_ptr<Cluster> cluster(GenerateCluster(0, 6)); | 1766 scoped_ptr<Cluster> cluster(GenerateCluster(0, 6)); |
| 1777 | 1767 |
| 1778 bool audio_read_done = false; | 1768 bool audio_read_done = false; |
| 1779 bool video_read_done = false; | 1769 bool video_read_done = false; |
| 1780 ReadAudio(base::Bind(&OnReadDone, | 1770 ReadAudio(base::Bind(&OnReadDone, |
| 1781 base::TimeDelta::FromMilliseconds(0), | 1771 base::TimeDelta::FromMilliseconds(0), |
| 1782 &audio_read_done)); | 1772 &audio_read_done)); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1815 // Append the remaining data. | 1805 // Append the remaining data. |
| 1816 ASSERT_LT(i, cluster->size()); | 1806 ASSERT_LT(i, cluster->size()); |
| 1817 AppendData(cluster->data() + i, cluster->size() - i); | 1807 AppendData(cluster->data() + i, cluster->size() - i); |
| 1818 | 1808 |
| 1819 message_loop_.RunUntilIdle(); | 1809 message_loop_.RunUntilIdle(); |
| 1820 | 1810 |
| 1821 EXPECT_TRUE(audio_read_done); | 1811 EXPECT_TRUE(audio_read_done); |
| 1822 EXPECT_TRUE(video_read_done); | 1812 EXPECT_TRUE(video_read_done); |
| 1823 } | 1813 } |
| 1824 | 1814 |
| 1825 TEST_P(ChunkDemuxerTest, ParseErrorDuringInit) { | 1815 TEST_F(ChunkDemuxerTest, ParseErrorDuringInit) { |
| 1826 EXPECT_CALL(*this, DemuxerOpened()); | 1816 EXPECT_CALL(*this, DemuxerOpened()); |
| 1827 demuxer_->Initialize( | 1817 demuxer_->Initialize( |
| 1828 &host_, CreateInitDoneCB( | 1818 &host_, CreateInitDoneCB( |
| 1829 kNoTimestamp(), DEMUXER_ERROR_COULD_NOT_OPEN), true); | 1819 kNoTimestamp(), DEMUXER_ERROR_COULD_NOT_OPEN), true); |
| 1830 | 1820 |
| 1831 ASSERT_EQ(AddId(), ChunkDemuxer::kOk); | 1821 ASSERT_EQ(AddId(), ChunkDemuxer::kOk); |
| 1832 | 1822 |
| 1833 uint8 tmp = 0; | 1823 uint8 tmp = 0; |
| 1834 demuxer_->AppendData(kSourceId, &tmp, 1, | 1824 demuxer_->AppendData(kSourceId, &tmp, 1, |
| 1835 append_window_start_for_next_append_, | 1825 append_window_start_for_next_append_, |
| 1836 append_window_end_for_next_append_, | 1826 append_window_end_for_next_append_, |
| 1837 ×tamp_offset_map_[kSourceId]); | 1827 ×tamp_offset_map_[kSourceId]); |
| 1838 } | 1828 } |
| 1839 | 1829 |
| 1840 TEST_P(ChunkDemuxerTest, AVHeadersWithAudioOnlyType) { | 1830 TEST_F(ChunkDemuxerTest, AVHeadersWithAudioOnlyType) { |
| 1841 EXPECT_CALL(*this, DemuxerOpened()); | 1831 EXPECT_CALL(*this, DemuxerOpened()); |
| 1842 demuxer_->Initialize( | 1832 demuxer_->Initialize( |
| 1843 &host_, CreateInitDoneCB(kNoTimestamp(), | 1833 &host_, CreateInitDoneCB(kNoTimestamp(), |
| 1844 DEMUXER_ERROR_COULD_NOT_OPEN), true); | 1834 DEMUXER_ERROR_COULD_NOT_OPEN), true); |
| 1845 | 1835 |
| 1846 std::vector<std::string> codecs(1); | 1836 std::vector<std::string> codecs(1); |
| 1847 codecs[0] = "vorbis"; | 1837 codecs[0] = "vorbis"; |
| 1848 ASSERT_EQ(demuxer_->AddId(kSourceId, "audio/webm", codecs, | 1838 ASSERT_EQ(demuxer_->AddId(kSourceId, "audio/webm", codecs), |
| 1849 use_legacy_frame_processor_), | |
| 1850 ChunkDemuxer::kOk); | 1839 ChunkDemuxer::kOk); |
| 1851 | 1840 |
| 1852 AppendInitSegment(HAS_AUDIO | HAS_VIDEO); | 1841 AppendInitSegment(HAS_AUDIO | HAS_VIDEO); |
| 1853 } | 1842 } |
| 1854 | 1843 |
| 1855 TEST_P(ChunkDemuxerTest, AVHeadersWithVideoOnlyType) { | 1844 TEST_F(ChunkDemuxerTest, AVHeadersWithVideoOnlyType) { |
| 1856 EXPECT_CALL(*this, DemuxerOpened()); | 1845 EXPECT_CALL(*this, DemuxerOpened()); |
| 1857 demuxer_->Initialize( | 1846 demuxer_->Initialize( |
| 1858 &host_, CreateInitDoneCB(kNoTimestamp(), | 1847 &host_, CreateInitDoneCB(kNoTimestamp(), |
| 1859 DEMUXER_ERROR_COULD_NOT_OPEN), true); | 1848 DEMUXER_ERROR_COULD_NOT_OPEN), true); |
| 1860 | 1849 |
| 1861 std::vector<std::string> codecs(1); | 1850 std::vector<std::string> codecs(1); |
| 1862 codecs[0] = "vp8"; | 1851 codecs[0] = "vp8"; |
| 1863 ASSERT_EQ(demuxer_->AddId(kSourceId, "video/webm", codecs, | 1852 ASSERT_EQ(demuxer_->AddId(kSourceId, "video/webm", codecs), |
| 1864 use_legacy_frame_processor_), | |
| 1865 ChunkDemuxer::kOk); | 1853 ChunkDemuxer::kOk); |
| 1866 | 1854 |
| 1867 AppendInitSegment(HAS_AUDIO | HAS_VIDEO); | 1855 AppendInitSegment(HAS_AUDIO | HAS_VIDEO); |
| 1868 } | 1856 } |
| 1869 | 1857 |
| 1870 TEST_P(ChunkDemuxerTest, MultipleHeaders) { | 1858 TEST_F(ChunkDemuxerTest, MultipleHeaders) { |
| 1871 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); | 1859 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); |
| 1872 | 1860 |
| 1873 AppendCluster(kDefaultFirstCluster()); | 1861 AppendCluster(kDefaultFirstCluster()); |
| 1874 | 1862 |
| 1875 // Append another identical initialization segment. | 1863 // Append another identical initialization segment. |
| 1876 AppendInitSegment(HAS_AUDIO | HAS_VIDEO); | 1864 AppendInitSegment(HAS_AUDIO | HAS_VIDEO); |
| 1877 | 1865 |
| 1878 AppendCluster(kDefaultSecondCluster()); | 1866 AppendCluster(kDefaultSecondCluster()); |
| 1879 | 1867 |
| 1880 GenerateExpectedReads(0, 9); | 1868 GenerateExpectedReads(0, 9); |
| 1881 } | 1869 } |
| 1882 | 1870 |
| 1883 TEST_P(ChunkDemuxerTest, AddSeparateSourcesForAudioAndVideo) { | 1871 TEST_F(ChunkDemuxerTest, AddSeparateSourcesForAudioAndVideo) { |
| 1884 std::string audio_id = "audio1"; | 1872 std::string audio_id = "audio1"; |
| 1885 std::string video_id = "video1"; | 1873 std::string video_id = "video1"; |
| 1886 ASSERT_TRUE(InitDemuxerAudioAndVideoSources(audio_id, video_id)); | 1874 ASSERT_TRUE(InitDemuxerAudioAndVideoSources(audio_id, video_id)); |
| 1887 | 1875 |
| 1888 // Append audio and video data into separate source ids. | 1876 // Append audio and video data into separate source ids. |
| 1889 AppendCluster(audio_id, | 1877 AppendCluster(audio_id, |
| 1890 GenerateSingleStreamCluster(0, 92, kAudioTrackNum, kAudioBlockDuration)); | 1878 GenerateSingleStreamCluster(0, 92, kAudioTrackNum, kAudioBlockDuration)); |
| 1891 GenerateAudioStreamExpectedReads(0, 4); | 1879 GenerateAudioStreamExpectedReads(0, 4); |
| 1892 AppendCluster(video_id, | 1880 AppendCluster(video_id, |
| 1893 GenerateSingleStreamCluster(0, 132, kVideoTrackNum, kVideoBlockDuration)); | 1881 GenerateSingleStreamCluster(0, 132, kVideoTrackNum, kVideoBlockDuration)); |
| 1894 GenerateVideoStreamExpectedReads(0, 4); | 1882 GenerateVideoStreamExpectedReads(0, 4); |
| 1895 } | 1883 } |
| 1896 | 1884 |
| 1897 TEST_P(ChunkDemuxerTest, AddSeparateSourcesForAudioAndVideoText) { | 1885 TEST_F(ChunkDemuxerTest, AddSeparateSourcesForAudioAndVideoText) { |
| 1898 // TODO(matthewjheaney): Here and elsewhere, we need more tests | 1886 // TODO(matthewjheaney): Here and elsewhere, we need more tests |
| 1899 // for inband text tracks (http://crbug/321455). | 1887 // for inband text tracks (http://crbug/321455). |
| 1900 | 1888 |
| 1901 std::string audio_id = "audio1"; | 1889 std::string audio_id = "audio1"; |
| 1902 std::string video_id = "video1"; | 1890 std::string video_id = "video1"; |
| 1903 | 1891 |
| 1904 EXPECT_CALL(host_, AddTextStream(_, _)) | 1892 EXPECT_CALL(host_, AddTextStream(_, _)) |
| 1905 .Times(Exactly(2)); | 1893 .Times(Exactly(2)); |
| 1906 ASSERT_TRUE(InitDemuxerAudioAndVideoSourcesText(audio_id, video_id, true)); | 1894 ASSERT_TRUE(InitDemuxerAudioAndVideoSourcesText(audio_id, video_id, true)); |
| 1907 | 1895 |
| 1908 // Append audio and video data into separate source ids. | 1896 // Append audio and video data into separate source ids. |
| 1909 AppendCluster(audio_id, | 1897 AppendCluster(audio_id, |
| 1910 GenerateSingleStreamCluster(0, 92, kAudioTrackNum, kAudioBlockDuration)); | 1898 GenerateSingleStreamCluster(0, 92, kAudioTrackNum, kAudioBlockDuration)); |
| 1911 GenerateAudioStreamExpectedReads(0, 4); | 1899 GenerateAudioStreamExpectedReads(0, 4); |
| 1912 AppendCluster(video_id, | 1900 AppendCluster(video_id, |
| 1913 GenerateSingleStreamCluster(0, 132, kVideoTrackNum, kVideoBlockDuration)); | 1901 GenerateSingleStreamCluster(0, 132, kVideoTrackNum, kVideoBlockDuration)); |
| 1914 GenerateVideoStreamExpectedReads(0, 4); | 1902 GenerateVideoStreamExpectedReads(0, 4); |
| 1915 } | 1903 } |
| 1916 | 1904 |
| 1917 TEST_P(ChunkDemuxerTest, AddIdFailures) { | 1905 TEST_F(ChunkDemuxerTest, AddIdFailures) { |
| 1918 EXPECT_CALL(*this, DemuxerOpened()); | 1906 EXPECT_CALL(*this, DemuxerOpened()); |
| 1919 demuxer_->Initialize( | 1907 demuxer_->Initialize( |
| 1920 &host_, CreateInitDoneCB(kDefaultDuration(), PIPELINE_OK), true); | 1908 &host_, CreateInitDoneCB(kDefaultDuration(), PIPELINE_OK), true); |
| 1921 | 1909 |
| 1922 std::string audio_id = "audio1"; | 1910 std::string audio_id = "audio1"; |
| 1923 std::string video_id = "video1"; | 1911 std::string video_id = "video1"; |
| 1924 | 1912 |
| 1925 ASSERT_EQ(AddId(audio_id, HAS_AUDIO), ChunkDemuxer::kOk); | 1913 ASSERT_EQ(AddId(audio_id, HAS_AUDIO), ChunkDemuxer::kOk); |
| 1926 | 1914 |
| 1927 // Adding an id with audio/video should fail because we already added audio. | 1915 // Adding an id with audio/video should fail because we already added audio. |
| 1928 ASSERT_EQ(AddId(), ChunkDemuxer::kReachedIdLimit); | 1916 ASSERT_EQ(AddId(), ChunkDemuxer::kReachedIdLimit); |
| 1929 | 1917 |
| 1930 AppendInitSegmentWithSourceId(audio_id, HAS_AUDIO); | 1918 AppendInitSegmentWithSourceId(audio_id, HAS_AUDIO); |
| 1931 | 1919 |
| 1932 // Adding an id after append should fail. | 1920 // Adding an id after append should fail. |
| 1933 ASSERT_EQ(AddId(video_id, HAS_VIDEO), ChunkDemuxer::kReachedIdLimit); | 1921 ASSERT_EQ(AddId(video_id, HAS_VIDEO), ChunkDemuxer::kReachedIdLimit); |
| 1934 } | 1922 } |
| 1935 | 1923 |
| 1936 // Test that Read() calls after a RemoveId() return "end of stream" buffers. | 1924 // Test that Read() calls after a RemoveId() return "end of stream" buffers. |
| 1937 TEST_P(ChunkDemuxerTest, RemoveId) { | 1925 TEST_F(ChunkDemuxerTest, RemoveId) { |
| 1938 std::string audio_id = "audio1"; | 1926 std::string audio_id = "audio1"; |
| 1939 std::string video_id = "video1"; | 1927 std::string video_id = "video1"; |
| 1940 ASSERT_TRUE(InitDemuxerAudioAndVideoSources(audio_id, video_id)); | 1928 ASSERT_TRUE(InitDemuxerAudioAndVideoSources(audio_id, video_id)); |
| 1941 | 1929 |
| 1942 // Append audio and video data into separate source ids. | 1930 // Append audio and video data into separate source ids. |
| 1943 AppendCluster(audio_id, | 1931 AppendCluster(audio_id, |
| 1944 GenerateSingleStreamCluster(0, 92, kAudioTrackNum, kAudioBlockDuration)); | 1932 GenerateSingleStreamCluster(0, 92, kAudioTrackNum, kAudioBlockDuration)); |
| 1945 AppendCluster(video_id, | 1933 AppendCluster(video_id, |
| 1946 GenerateSingleStreamCluster(0, 132, kVideoTrackNum, kVideoBlockDuration)); | 1934 GenerateSingleStreamCluster(0, 132, kVideoTrackNum, kVideoBlockDuration)); |
| 1947 | 1935 |
| 1948 // Read() from audio should return normal buffers. | 1936 // Read() from audio should return normal buffers. |
| 1949 GenerateAudioStreamExpectedReads(0, 4); | 1937 GenerateAudioStreamExpectedReads(0, 4); |
| 1950 | 1938 |
| 1951 // Remove the audio id. | 1939 // Remove the audio id. |
| 1952 demuxer_->RemoveId(audio_id); | 1940 demuxer_->RemoveId(audio_id); |
| 1953 | 1941 |
| 1954 // Read() from audio should return "end of stream" buffers. | 1942 // Read() from audio should return "end of stream" buffers. |
| 1955 bool audio_read_done = false; | 1943 bool audio_read_done = false; |
| 1956 ReadAudio(base::Bind(&OnReadDone_EOSExpected, &audio_read_done)); | 1944 ReadAudio(base::Bind(&OnReadDone_EOSExpected, &audio_read_done)); |
| 1957 message_loop_.RunUntilIdle(); | 1945 message_loop_.RunUntilIdle(); |
| 1958 EXPECT_TRUE(audio_read_done); | 1946 EXPECT_TRUE(audio_read_done); |
| 1959 | 1947 |
| 1960 // Read() from video should still return normal buffers. | 1948 // Read() from video should still return normal buffers. |
| 1961 GenerateVideoStreamExpectedReads(0, 4); | 1949 GenerateVideoStreamExpectedReads(0, 4); |
| 1962 } | 1950 } |
| 1963 | 1951 |
| 1964 // Test that removing an ID immediately after adding it does not interfere with | 1952 // Test that removing an ID immediately after adding it does not interfere with |
| 1965 // quota for new IDs in the future. | 1953 // quota for new IDs in the future. |
| 1966 TEST_P(ChunkDemuxerTest, RemoveAndAddId) { | 1954 TEST_F(ChunkDemuxerTest, RemoveAndAddId) { |
| 1967 std::string audio_id_1 = "audio1"; | 1955 std::string audio_id_1 = "audio1"; |
| 1968 ASSERT_TRUE(AddId(audio_id_1, HAS_AUDIO) == ChunkDemuxer::kOk); | 1956 ASSERT_TRUE(AddId(audio_id_1, HAS_AUDIO) == ChunkDemuxer::kOk); |
| 1969 demuxer_->RemoveId(audio_id_1); | 1957 demuxer_->RemoveId(audio_id_1); |
| 1970 | 1958 |
| 1971 std::string audio_id_2 = "audio2"; | 1959 std::string audio_id_2 = "audio2"; |
| 1972 ASSERT_TRUE(AddId(audio_id_2, HAS_AUDIO) == ChunkDemuxer::kOk); | 1960 ASSERT_TRUE(AddId(audio_id_2, HAS_AUDIO) == ChunkDemuxer::kOk); |
| 1973 } | 1961 } |
| 1974 | 1962 |
| 1975 TEST_P(ChunkDemuxerTest, SeekCanceled) { | 1963 TEST_F(ChunkDemuxerTest, SeekCanceled) { |
| 1976 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); | 1964 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); |
| 1977 | 1965 |
| 1978 // Append cluster at the beginning of the stream. | 1966 // Append cluster at the beginning of the stream. |
| 1979 AppendCluster(GenerateCluster(0, 4)); | 1967 AppendCluster(GenerateCluster(0, 4)); |
| 1980 | 1968 |
| 1981 // Seek to an unbuffered region. | 1969 // Seek to an unbuffered region. |
| 1982 Seek(base::TimeDelta::FromSeconds(50)); | 1970 Seek(base::TimeDelta::FromSeconds(50)); |
| 1983 | 1971 |
| 1984 // Attempt to read in unbuffered area; should not fulfill the read. | 1972 // Attempt to read in unbuffered area; should not fulfill the read. |
| 1985 bool audio_read_done = false; | 1973 bool audio_read_done = false; |
| 1986 bool video_read_done = false; | 1974 bool video_read_done = false; |
| 1987 ReadAudio(base::Bind(&OnReadDone_AbortExpected, &audio_read_done)); | 1975 ReadAudio(base::Bind(&OnReadDone_AbortExpected, &audio_read_done)); |
| 1988 ReadVideo(base::Bind(&OnReadDone_AbortExpected, &video_read_done)); | 1976 ReadVideo(base::Bind(&OnReadDone_AbortExpected, &video_read_done)); |
| 1989 EXPECT_FALSE(audio_read_done); | 1977 EXPECT_FALSE(audio_read_done); |
| 1990 EXPECT_FALSE(video_read_done); | 1978 EXPECT_FALSE(video_read_done); |
| 1991 | 1979 |
| 1992 // Now cancel the pending seek, which should flush the reads with empty | 1980 // Now cancel the pending seek, which should flush the reads with empty |
| 1993 // buffers. | 1981 // buffers. |
| 1994 base::TimeDelta seek_time = base::TimeDelta::FromSeconds(0); | 1982 base::TimeDelta seek_time = base::TimeDelta::FromSeconds(0); |
| 1995 demuxer_->CancelPendingSeek(seek_time); | 1983 demuxer_->CancelPendingSeek(seek_time); |
| 1996 message_loop_.RunUntilIdle(); | 1984 message_loop_.RunUntilIdle(); |
| 1997 EXPECT_TRUE(audio_read_done); | 1985 EXPECT_TRUE(audio_read_done); |
| 1998 EXPECT_TRUE(video_read_done); | 1986 EXPECT_TRUE(video_read_done); |
| 1999 | 1987 |
| 2000 // A seek back to the buffered region should succeed. | 1988 // A seek back to the buffered region should succeed. |
| 2001 Seek(seek_time); | 1989 Seek(seek_time); |
| 2002 GenerateExpectedReads(0, 4); | 1990 GenerateExpectedReads(0, 4); |
| 2003 } | 1991 } |
| 2004 | 1992 |
| 2005 TEST_P(ChunkDemuxerTest, SeekCanceledWhileWaitingForSeek) { | 1993 TEST_F(ChunkDemuxerTest, SeekCanceledWhileWaitingForSeek) { |
| 2006 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); | 1994 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); |
| 2007 | 1995 |
| 2008 // Append cluster at the beginning of the stream. | 1996 // Append cluster at the beginning of the stream. |
| 2009 AppendCluster(GenerateCluster(0, 4)); | 1997 AppendCluster(GenerateCluster(0, 4)); |
| 2010 | 1998 |
| 2011 // Start waiting for a seek. | 1999 // Start waiting for a seek. |
| 2012 base::TimeDelta seek_time1 = base::TimeDelta::FromSeconds(50); | 2000 base::TimeDelta seek_time1 = base::TimeDelta::FromSeconds(50); |
| 2013 base::TimeDelta seek_time2 = base::TimeDelta::FromSeconds(0); | 2001 base::TimeDelta seek_time2 = base::TimeDelta::FromSeconds(0); |
| 2014 demuxer_->StartWaitingForSeek(seek_time1); | 2002 demuxer_->StartWaitingForSeek(seek_time1); |
| 2015 | 2003 |
| 2016 // Now cancel the upcoming seek to an unbuffered region. | 2004 // Now cancel the upcoming seek to an unbuffered region. |
| 2017 demuxer_->CancelPendingSeek(seek_time2); | 2005 demuxer_->CancelPendingSeek(seek_time2); |
| 2018 demuxer_->Seek(seek_time1, NewExpectedStatusCB(PIPELINE_OK)); | 2006 demuxer_->Seek(seek_time1, NewExpectedStatusCB(PIPELINE_OK)); |
| 2019 | 2007 |
| 2020 // Read requests should be fulfilled with empty buffers. | 2008 // Read requests should be fulfilled with empty buffers. |
| 2021 bool audio_read_done = false; | 2009 bool audio_read_done = false; |
| 2022 bool video_read_done = false; | 2010 bool video_read_done = false; |
| 2023 ReadAudio(base::Bind(&OnReadDone_AbortExpected, &audio_read_done)); | 2011 ReadAudio(base::Bind(&OnReadDone_AbortExpected, &audio_read_done)); |
| 2024 ReadVideo(base::Bind(&OnReadDone_AbortExpected, &video_read_done)); | 2012 ReadVideo(base::Bind(&OnReadDone_AbortExpected, &video_read_done)); |
| 2025 EXPECT_TRUE(audio_read_done); | 2013 EXPECT_TRUE(audio_read_done); |
| 2026 EXPECT_TRUE(video_read_done); | 2014 EXPECT_TRUE(video_read_done); |
| 2027 | 2015 |
| 2028 // A seek back to the buffered region should succeed. | 2016 // A seek back to the buffered region should succeed. |
| 2029 Seek(seek_time2); | 2017 Seek(seek_time2); |
| 2030 GenerateExpectedReads(0, 4); | 2018 GenerateExpectedReads(0, 4); |
| 2031 } | 2019 } |
| 2032 | 2020 |
| 2033 // Test that Seek() successfully seeks to all source IDs. | 2021 // Test that Seek() successfully seeks to all source IDs. |
| 2034 TEST_P(ChunkDemuxerTest, SeekAudioAndVideoSources) { | 2022 TEST_F(ChunkDemuxerTest, SeekAudioAndVideoSources) { |
| 2035 std::string audio_id = "audio1"; | 2023 std::string audio_id = "audio1"; |
| 2036 std::string video_id = "video1"; | 2024 std::string video_id = "video1"; |
| 2037 ASSERT_TRUE(InitDemuxerAudioAndVideoSources(audio_id, video_id)); | 2025 ASSERT_TRUE(InitDemuxerAudioAndVideoSources(audio_id, video_id)); |
| 2038 | 2026 |
| 2039 AppendCluster( | 2027 AppendCluster( |
| 2040 audio_id, | 2028 audio_id, |
| 2041 GenerateSingleStreamCluster(0, 92, kAudioTrackNum, kAudioBlockDuration)); | 2029 GenerateSingleStreamCluster(0, 92, kAudioTrackNum, kAudioBlockDuration)); |
| 2042 AppendCluster( | 2030 AppendCluster( |
| 2043 video_id, | 2031 video_id, |
| 2044 GenerateSingleStreamCluster(0, 132, kVideoTrackNum, kVideoBlockDuration)); | 2032 GenerateSingleStreamCluster(0, 132, kVideoTrackNum, kVideoBlockDuration)); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2081 | 2069 |
| 2082 // Read() should return buffers at 3. | 2070 // Read() should return buffers at 3. |
| 2083 EXPECT_TRUE(audio_read_done); | 2071 EXPECT_TRUE(audio_read_done); |
| 2084 EXPECT_TRUE(video_read_done); | 2072 EXPECT_TRUE(video_read_done); |
| 2085 } | 2073 } |
| 2086 | 2074 |
| 2087 // Test that Seek() completes successfully when EndOfStream | 2075 // Test that Seek() completes successfully when EndOfStream |
| 2088 // is called before data is available for that seek point. | 2076 // is called before data is available for that seek point. |
| 2089 // This scenario might be useful if seeking past the end of stream | 2077 // This scenario might be useful if seeking past the end of stream |
| 2090 // of either audio or video (or both). | 2078 // of either audio or video (or both). |
| 2091 TEST_P(ChunkDemuxerTest, EndOfStreamAfterPastEosSeek) { | 2079 TEST_F(ChunkDemuxerTest, EndOfStreamAfterPastEosSeek) { |
| 2092 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); | 2080 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); |
| 2093 | 2081 |
| 2094 AppendCluster(GenerateSingleStreamCluster(0, 120, kAudioTrackNum, 10)); | 2082 AppendCluster(GenerateSingleStreamCluster(0, 120, kAudioTrackNum, 10)); |
| 2095 AppendCluster(GenerateSingleStreamCluster(0, 100, kVideoTrackNum, 5)); | 2083 AppendCluster(GenerateSingleStreamCluster(0, 100, kVideoTrackNum, 5)); |
| 2096 | 2084 |
| 2097 // Seeking past the end of video. | 2085 // Seeking past the end of video. |
| 2098 // Note: audio data is available for that seek point. | 2086 // Note: audio data is available for that seek point. |
| 2099 bool seek_cb_was_called = false; | 2087 bool seek_cb_was_called = false; |
| 2100 base::TimeDelta seek_time = base::TimeDelta::FromMilliseconds(110); | 2088 base::TimeDelta seek_time = base::TimeDelta::FromMilliseconds(110); |
| 2101 demuxer_->StartWaitingForSeek(seek_time); | 2089 demuxer_->StartWaitingForSeek(seek_time); |
| 2102 demuxer_->Seek(seek_time, | 2090 demuxer_->Seek(seek_time, |
| 2103 base::Bind(OnSeekDone_OKExpected, &seek_cb_was_called)); | 2091 base::Bind(OnSeekDone_OKExpected, &seek_cb_was_called)); |
| 2104 message_loop_.RunUntilIdle(); | 2092 message_loop_.RunUntilIdle(); |
| 2105 | 2093 |
| 2106 EXPECT_FALSE(seek_cb_was_called); | 2094 EXPECT_FALSE(seek_cb_was_called); |
| 2107 | 2095 |
| 2108 EXPECT_CALL(host_, SetDuration( | 2096 EXPECT_CALL(host_, SetDuration( |
| 2109 base::TimeDelta::FromMilliseconds(120))); | 2097 base::TimeDelta::FromMilliseconds(120))); |
| 2110 MarkEndOfStream(PIPELINE_OK); | 2098 MarkEndOfStream(PIPELINE_OK); |
| 2111 message_loop_.RunUntilIdle(); | 2099 message_loop_.RunUntilIdle(); |
| 2112 | 2100 |
| 2113 EXPECT_TRUE(seek_cb_was_called); | 2101 EXPECT_TRUE(seek_cb_was_called); |
| 2114 | 2102 |
| 2115 ShutdownDemuxer(); | 2103 ShutdownDemuxer(); |
| 2116 } | 2104 } |
| 2117 | 2105 |
| 2118 // Test that EndOfStream is ignored if coming during a pending seek | 2106 // Test that EndOfStream is ignored if coming during a pending seek |
| 2119 // whose seek time is before some existing ranges. | 2107 // whose seek time is before some existing ranges. |
| 2120 TEST_P(ChunkDemuxerTest, EndOfStreamDuringPendingSeek) { | 2108 TEST_F(ChunkDemuxerTest, EndOfStreamDuringPendingSeek) { |
| 2121 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); | 2109 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); |
| 2122 | 2110 |
| 2123 AppendCluster(GenerateSingleStreamCluster(0, 120, kAudioTrackNum, 10)); | 2111 AppendCluster(GenerateSingleStreamCluster(0, 120, kAudioTrackNum, 10)); |
| 2124 AppendCluster(GenerateSingleStreamCluster(0, 100, kVideoTrackNum, 5)); | 2112 AppendCluster(GenerateSingleStreamCluster(0, 100, kVideoTrackNum, 5)); |
| 2125 AppendCluster(GenerateSingleStreamCluster(200, 300, kAudioTrackNum, 10)); | 2113 AppendCluster(GenerateSingleStreamCluster(200, 300, kAudioTrackNum, 10)); |
| 2126 AppendCluster(GenerateSingleStreamCluster(200, 300, kVideoTrackNum, 5)); | 2114 AppendCluster(GenerateSingleStreamCluster(200, 300, kVideoTrackNum, 5)); |
| 2127 | 2115 |
| 2128 bool seek_cb_was_called = false; | 2116 bool seek_cb_was_called = false; |
| 2129 base::TimeDelta seek_time = base::TimeDelta::FromMilliseconds(160); | 2117 base::TimeDelta seek_time = base::TimeDelta::FromMilliseconds(160); |
| 2130 demuxer_->StartWaitingForSeek(seek_time); | 2118 demuxer_->StartWaitingForSeek(seek_time); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2146 AppendCluster(GenerateSingleStreamCluster(140, 180, kVideoTrackNum, 5)); | 2134 AppendCluster(GenerateSingleStreamCluster(140, 180, kVideoTrackNum, 5)); |
| 2147 | 2135 |
| 2148 message_loop_.RunUntilIdle(); | 2136 message_loop_.RunUntilIdle(); |
| 2149 | 2137 |
| 2150 EXPECT_TRUE(seek_cb_was_called); | 2138 EXPECT_TRUE(seek_cb_was_called); |
| 2151 | 2139 |
| 2152 ShutdownDemuxer(); | 2140 ShutdownDemuxer(); |
| 2153 } | 2141 } |
| 2154 | 2142 |
| 2155 // Test ranges in an audio-only stream. | 2143 // Test ranges in an audio-only stream. |
| 2156 TEST_P(ChunkDemuxerTest, GetBufferedRanges_AudioIdOnly) { | 2144 TEST_F(ChunkDemuxerTest, GetBufferedRanges_AudioIdOnly) { |
| 2157 EXPECT_CALL(*this, DemuxerOpened()); | 2145 EXPECT_CALL(*this, DemuxerOpened()); |
| 2158 demuxer_->Initialize( | 2146 demuxer_->Initialize( |
| 2159 &host_, CreateInitDoneCB(kDefaultDuration(), PIPELINE_OK), true); | 2147 &host_, CreateInitDoneCB(kDefaultDuration(), PIPELINE_OK), true); |
| 2160 | 2148 |
| 2161 ASSERT_EQ(AddId(kSourceId, HAS_AUDIO), ChunkDemuxer::kOk); | 2149 ASSERT_EQ(AddId(kSourceId, HAS_AUDIO), ChunkDemuxer::kOk); |
| 2162 AppendInitSegment(HAS_AUDIO); | 2150 AppendInitSegment(HAS_AUDIO); |
| 2163 | 2151 |
| 2164 // Test a simple cluster. | 2152 // Test a simple cluster. |
| 2165 AppendCluster( | 2153 AppendCluster( |
| 2166 GenerateSingleStreamCluster(0, 92, kAudioTrackNum, kAudioBlockDuration)); | 2154 GenerateSingleStreamCluster(0, 92, kAudioTrackNum, kAudioBlockDuration)); |
| 2167 | 2155 |
| 2168 CheckExpectedRanges("{ [0,92) }"); | 2156 CheckExpectedRanges("{ [0,92) }"); |
| 2169 | 2157 |
| 2170 // Append a disjoint cluster to check for two separate ranges. | 2158 // Append a disjoint cluster to check for two separate ranges. |
| 2171 AppendCluster(GenerateSingleStreamCluster( | 2159 AppendCluster(GenerateSingleStreamCluster( |
| 2172 150, 219, kAudioTrackNum, kAudioBlockDuration)); | 2160 150, 219, kAudioTrackNum, kAudioBlockDuration)); |
| 2173 | 2161 |
| 2174 CheckExpectedRanges("{ [0,92) [150,219) }"); | 2162 CheckExpectedRanges("{ [0,92) [150,219) }"); |
| 2175 } | 2163 } |
| 2176 | 2164 |
| 2177 // Test ranges in a video-only stream. | 2165 // Test ranges in a video-only stream. |
| 2178 TEST_P(ChunkDemuxerTest, GetBufferedRanges_VideoIdOnly) { | 2166 TEST_F(ChunkDemuxerTest, GetBufferedRanges_VideoIdOnly) { |
| 2179 EXPECT_CALL(*this, DemuxerOpened()); | 2167 EXPECT_CALL(*this, DemuxerOpened()); |
| 2180 demuxer_->Initialize( | 2168 demuxer_->Initialize( |
| 2181 &host_, CreateInitDoneCB(kDefaultDuration(), PIPELINE_OK), true); | 2169 &host_, CreateInitDoneCB(kDefaultDuration(), PIPELINE_OK), true); |
| 2182 | 2170 |
| 2183 ASSERT_EQ(AddId(kSourceId, HAS_VIDEO), ChunkDemuxer::kOk); | 2171 ASSERT_EQ(AddId(kSourceId, HAS_VIDEO), ChunkDemuxer::kOk); |
| 2184 AppendInitSegment(HAS_VIDEO); | 2172 AppendInitSegment(HAS_VIDEO); |
| 2185 | 2173 |
| 2186 // Test a simple cluster. | 2174 // Test a simple cluster. |
| 2187 AppendCluster( | 2175 AppendCluster( |
| 2188 GenerateSingleStreamCluster(0, 132, kVideoTrackNum, kVideoBlockDuration)); | 2176 GenerateSingleStreamCluster(0, 132, kVideoTrackNum, kVideoBlockDuration)); |
| 2189 | 2177 |
| 2190 CheckExpectedRanges("{ [0,132) }"); | 2178 CheckExpectedRanges("{ [0,132) }"); |
| 2191 | 2179 |
| 2192 // Append a disjoint cluster to check for two separate ranges. | 2180 // Append a disjoint cluster to check for two separate ranges. |
| 2193 AppendCluster(GenerateSingleStreamCluster( | 2181 AppendCluster(GenerateSingleStreamCluster( |
| 2194 200, 299, kVideoTrackNum, kVideoBlockDuration)); | 2182 200, 299, kVideoTrackNum, kVideoBlockDuration)); |
| 2195 | 2183 |
| 2196 CheckExpectedRanges("{ [0,132) [200,299) }"); | 2184 CheckExpectedRanges("{ [0,132) [200,299) }"); |
| 2197 } | 2185 } |
| 2198 | 2186 |
| 2199 TEST_P(ChunkDemuxerTest, GetBufferedRanges_AudioVideo) { | 2187 TEST_F(ChunkDemuxerTest, GetBufferedRanges_AudioVideo) { |
| 2200 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); | 2188 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); |
| 2201 | 2189 |
| 2202 // Audio: 0 -> 23 | 2190 // Audio: 0 -> 23 |
| 2203 // Video: 0 -> 33 | 2191 // Video: 0 -> 33 |
| 2204 // Buffered Range: 0 -> 23 | 2192 // Buffered Range: 0 -> 23 |
| 2205 // Audio block duration is smaller than video block duration, | 2193 // Audio block duration is smaller than video block duration, |
| 2206 // so the buffered ranges should correspond to the audio blocks. | 2194 // so the buffered ranges should correspond to the audio blocks. |
| 2207 AppendCluster(GenerateSingleStreamCluster( | 2195 AppendCluster(GenerateSingleStreamCluster( |
| 2208 0, kAudioBlockDuration, kAudioTrackNum, kAudioBlockDuration)); | 2196 0, kAudioBlockDuration, kAudioTrackNum, kAudioBlockDuration)); |
| 2209 AppendCluster(GenerateSingleStreamCluster( | 2197 AppendCluster(GenerateSingleStreamCluster( |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2246 // Appending within buffered range should not affect buffered ranges. | 2234 // Appending within buffered range should not affect buffered ranges. |
| 2247 AppendCluster(GenerateSingleStreamCluster(930, 950, kAudioTrackNum, 20)); | 2235 AppendCluster(GenerateSingleStreamCluster(930, 950, kAudioTrackNum, 20)); |
| 2248 CheckExpectedRanges("{ [0,23) [320,400) [520,570) [720,750) [920,950) }"); | 2236 CheckExpectedRanges("{ [0,23) [320,400) [520,570) [720,750) [920,950) }"); |
| 2249 | 2237 |
| 2250 // Appending to single stream outside buffered ranges should not affect | 2238 // Appending to single stream outside buffered ranges should not affect |
| 2251 // buffered ranges. | 2239 // buffered ranges. |
| 2252 AppendCluster(GenerateSingleStreamCluster(1230, 1240, kVideoTrackNum, 10)); | 2240 AppendCluster(GenerateSingleStreamCluster(1230, 1240, kVideoTrackNum, 10)); |
| 2253 CheckExpectedRanges("{ [0,23) [320,400) [520,570) [720,750) [920,950) }"); | 2241 CheckExpectedRanges("{ [0,23) [320,400) [520,570) [720,750) [920,950) }"); |
| 2254 } | 2242 } |
| 2255 | 2243 |
| 2256 TEST_P(ChunkDemuxerTest, GetBufferedRanges_AudioVideoText) { | 2244 TEST_F(ChunkDemuxerTest, GetBufferedRanges_AudioVideoText) { |
| 2257 EXPECT_CALL(host_, AddTextStream(_, _)); | 2245 EXPECT_CALL(host_, AddTextStream(_, _)); |
| 2258 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO | HAS_TEXT)); | 2246 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO | HAS_TEXT)); |
| 2259 | 2247 |
| 2260 // Append audio & video data | 2248 // Append audio & video data |
| 2261 AppendSingleStreamCluster(kSourceId, kAudioTrackNum, "0K 23"); | 2249 AppendSingleStreamCluster(kSourceId, kAudioTrackNum, "0K 23"); |
| 2262 AppendSingleStreamCluster(kSourceId, kVideoTrackNum, "0K 33"); | 2250 AppendSingleStreamCluster(kSourceId, kVideoTrackNum, "0K 33"); |
| 2263 | 2251 |
| 2264 // Verify that a text track with no cues does not result in an empty buffered | 2252 // Verify that a text track with no cues does not result in an empty buffered |
| 2265 // range. | 2253 // range. |
| 2266 CheckExpectedRanges("{ [0,46) }"); | 2254 CheckExpectedRanges("{ [0,46) }"); |
| 2267 | 2255 |
| 2268 // Add some text cues. | 2256 // Add some text cues. |
| 2269 AppendSingleStreamCluster(kSourceId, kTextTrackNum, "0K 100K"); | 2257 AppendSingleStreamCluster(kSourceId, kTextTrackNum, "0K 100K"); |
| 2270 | 2258 |
| 2271 // Verify that the new cues did not affect the buffered ranges. | 2259 // Verify that the new cues did not affect the buffered ranges. |
| 2272 CheckExpectedRanges("{ [0,46) }"); | 2260 CheckExpectedRanges("{ [0,46) }"); |
| 2273 | 2261 |
| 2274 // Remove the buffered range. | 2262 // Remove the buffered range. |
| 2275 demuxer_->Remove(kSourceId, base::TimeDelta(), | 2263 demuxer_->Remove(kSourceId, base::TimeDelta(), |
| 2276 base::TimeDelta::FromMilliseconds(46)); | 2264 base::TimeDelta::FromMilliseconds(46)); |
| 2277 CheckExpectedRanges("{ }"); | 2265 CheckExpectedRanges("{ }"); |
| 2278 } | 2266 } |
| 2279 | 2267 |
| 2280 // Once MarkEndOfStream() is called, GetBufferedRanges should not cut off any | 2268 // Once MarkEndOfStream() is called, GetBufferedRanges should not cut off any |
| 2281 // over-hanging tails at the end of the ranges as this is likely due to block | 2269 // over-hanging tails at the end of the ranges as this is likely due to block |
| 2282 // duration differences. | 2270 // duration differences. |
| 2283 TEST_P(ChunkDemuxerTest, GetBufferedRanges_EndOfStream) { | 2271 TEST_F(ChunkDemuxerTest, GetBufferedRanges_EndOfStream) { |
| 2284 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); | 2272 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); |
| 2285 | 2273 |
| 2286 AppendSingleStreamCluster(kSourceId, kAudioTrackNum, "0K 23K"); | 2274 AppendSingleStreamCluster(kSourceId, kAudioTrackNum, "0K 23K"); |
| 2287 AppendSingleStreamCluster(kSourceId, kVideoTrackNum, "0K 33"); | 2275 AppendSingleStreamCluster(kSourceId, kVideoTrackNum, "0K 33"); |
| 2288 | 2276 |
| 2289 CheckExpectedRanges("{ [0,46) }"); | 2277 CheckExpectedRanges("{ [0,46) }"); |
| 2290 | 2278 |
| 2291 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(66))); | 2279 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(66))); |
| 2292 MarkEndOfStream(PIPELINE_OK); | 2280 MarkEndOfStream(PIPELINE_OK); |
| 2293 | 2281 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2331 | 2319 |
| 2332 MarkEndOfStream(PIPELINE_OK); | 2320 MarkEndOfStream(PIPELINE_OK); |
| 2333 | 2321 |
| 2334 // NOTE: The last range on each stream gets extended to the highest | 2322 // NOTE: The last range on each stream gets extended to the highest |
| 2335 // end timestamp according to the spec. The last audio range gets extended | 2323 // end timestamp according to the spec. The last audio range gets extended |
| 2336 // from [200,246) to [200,398) which is why the intersection results in the | 2324 // from [200,246) to [200,398) which is why the intersection results in the |
| 2337 // middle range getting larger AND the new range appearing. | 2325 // middle range getting larger AND the new range appearing. |
| 2338 CheckExpectedRanges("{ [0,46) [200,266) [332,398) }"); | 2326 CheckExpectedRanges("{ [0,46) [200,266) [332,398) }"); |
| 2339 } | 2327 } |
| 2340 | 2328 |
| 2341 TEST_P(ChunkDemuxerTest, DifferentStreamTimecodes) { | 2329 TEST_F(ChunkDemuxerTest, DifferentStreamTimecodes) { |
| 2342 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); | 2330 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); |
| 2343 | 2331 |
| 2344 // Create a cluster where the video timecode begins 25ms after the audio. | 2332 // Create a cluster where the video timecode begins 25ms after the audio. |
| 2345 AppendCluster(GenerateCluster(0, 25, 8)); | 2333 AppendCluster(GenerateCluster(0, 25, 8)); |
| 2346 | 2334 |
| 2347 Seek(base::TimeDelta::FromSeconds(0)); | 2335 Seek(base::TimeDelta::FromSeconds(0)); |
| 2348 GenerateExpectedReads(0, 25, 8); | 2336 GenerateExpectedReads(0, 25, 8); |
| 2349 | 2337 |
| 2350 // Seek to 5 seconds. | 2338 // Seek to 5 seconds. |
| 2351 Seek(base::TimeDelta::FromSeconds(5)); | 2339 Seek(base::TimeDelta::FromSeconds(5)); |
| 2352 | 2340 |
| 2353 // Generate a cluster to fulfill this seek, where audio timecode begins 25ms | 2341 // Generate a cluster to fulfill this seek, where audio timecode begins 25ms |
| 2354 // after the video. | 2342 // after the video. |
| 2355 AppendCluster(GenerateCluster(5025, 5000, 8)); | 2343 AppendCluster(GenerateCluster(5025, 5000, 8)); |
| 2356 GenerateExpectedReads(5025, 5000, 8); | 2344 GenerateExpectedReads(5025, 5000, 8); |
| 2357 } | 2345 } |
| 2358 | 2346 |
| 2359 TEST_P(ChunkDemuxerTest, DifferentStreamTimecodesSeparateSources) { | 2347 TEST_F(ChunkDemuxerTest, DifferentStreamTimecodesSeparateSources) { |
| 2360 std::string audio_id = "audio1"; | 2348 std::string audio_id = "audio1"; |
| 2361 std::string video_id = "video1"; | 2349 std::string video_id = "video1"; |
| 2362 ASSERT_TRUE(InitDemuxerAudioAndVideoSources(audio_id, video_id)); | 2350 ASSERT_TRUE(InitDemuxerAudioAndVideoSources(audio_id, video_id)); |
| 2363 | 2351 |
| 2364 // Generate two streams where the video stream starts 5ms after the audio | 2352 // Generate two streams where the video stream starts 5ms after the audio |
| 2365 // stream and append them. | 2353 // stream and append them. |
| 2366 AppendCluster(audio_id, GenerateSingleStreamCluster( | 2354 AppendCluster(audio_id, GenerateSingleStreamCluster( |
| 2367 25, 4 * kAudioBlockDuration + 25, kAudioTrackNum, kAudioBlockDuration)); | 2355 25, 4 * kAudioBlockDuration + 25, kAudioTrackNum, kAudioBlockDuration)); |
| 2368 AppendCluster(video_id, GenerateSingleStreamCluster( | 2356 AppendCluster(video_id, GenerateSingleStreamCluster( |
| 2369 30, 4 * kVideoBlockDuration + 30, kVideoTrackNum, kVideoBlockDuration)); | 2357 30, 4 * kVideoBlockDuration + 30, kVideoTrackNum, kVideoBlockDuration)); |
| 2370 | 2358 |
| 2371 // Both streams should be able to fulfill a seek to 25. | 2359 // Both streams should be able to fulfill a seek to 25. |
| 2372 Seek(base::TimeDelta::FromMilliseconds(25)); | 2360 Seek(base::TimeDelta::FromMilliseconds(25)); |
| 2373 GenerateAudioStreamExpectedReads(25, 4); | 2361 GenerateAudioStreamExpectedReads(25, 4); |
| 2374 GenerateVideoStreamExpectedReads(30, 4); | 2362 GenerateVideoStreamExpectedReads(30, 4); |
| 2375 } | 2363 } |
| 2376 | 2364 |
| 2377 TEST_P(ChunkDemuxerTest, DifferentStreamTimecodesOutOfRange) { | 2365 TEST_F(ChunkDemuxerTest, DifferentStreamTimecodesOutOfRange) { |
| 2378 std::string audio_id = "audio1"; | 2366 std::string audio_id = "audio1"; |
| 2379 std::string video_id = "video1"; | 2367 std::string video_id = "video1"; |
| 2380 ASSERT_TRUE(InitDemuxerAudioAndVideoSources(audio_id, video_id)); | 2368 ASSERT_TRUE(InitDemuxerAudioAndVideoSources(audio_id, video_id)); |
| 2381 | 2369 |
| 2382 // Generate two streams where the video stream starts 10s after the audio | 2370 // Generate two streams where the video stream starts 10s after the audio |
| 2383 // stream and append them. | 2371 // stream and append them. |
| 2384 AppendCluster(audio_id, GenerateSingleStreamCluster(0, | 2372 AppendCluster(audio_id, GenerateSingleStreamCluster(0, |
| 2385 4 * kAudioBlockDuration + 0, kAudioTrackNum, kAudioBlockDuration)); | 2373 4 * kAudioBlockDuration + 0, kAudioTrackNum, kAudioBlockDuration)); |
| 2386 AppendCluster(video_id, GenerateSingleStreamCluster(10000, | 2374 AppendCluster(video_id, GenerateSingleStreamCluster(10000, |
| 2387 4 * kVideoBlockDuration + 10000, kVideoTrackNum, kVideoBlockDuration)); | 2375 4 * kVideoBlockDuration + 10000, kVideoTrackNum, kVideoBlockDuration)); |
| 2388 | 2376 |
| 2389 // Should not be able to fulfill a seek to 0. | 2377 // Should not be able to fulfill a seek to 0. |
| 2390 base::TimeDelta seek_time = base::TimeDelta::FromMilliseconds(0); | 2378 base::TimeDelta seek_time = base::TimeDelta::FromMilliseconds(0); |
| 2391 demuxer_->StartWaitingForSeek(seek_time); | 2379 demuxer_->StartWaitingForSeek(seek_time); |
| 2392 demuxer_->Seek(seek_time, | 2380 demuxer_->Seek(seek_time, |
| 2393 NewExpectedStatusCB(PIPELINE_ERROR_ABORT)); | 2381 NewExpectedStatusCB(PIPELINE_ERROR_ABORT)); |
| 2394 ExpectRead(DemuxerStream::AUDIO, 0); | 2382 ExpectRead(DemuxerStream::AUDIO, 0); |
| 2395 ExpectEndOfStream(DemuxerStream::VIDEO); | 2383 ExpectEndOfStream(DemuxerStream::VIDEO); |
| 2396 } | 2384 } |
| 2397 | 2385 |
| 2398 TEST_P(ChunkDemuxerTest, ClusterWithNoBuffers) { | 2386 TEST_F(ChunkDemuxerTest, ClusterWithNoBuffers) { |
| 2399 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); | 2387 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); |
| 2400 | 2388 |
| 2401 // Generate and append an empty cluster beginning at 0. | 2389 // Generate and append an empty cluster beginning at 0. |
| 2402 AppendEmptyCluster(0); | 2390 AppendEmptyCluster(0); |
| 2403 | 2391 |
| 2404 // Sanity check that data can be appended after this cluster correctly. | 2392 // Sanity check that data can be appended after this cluster correctly. |
| 2405 AppendCluster(GenerateCluster(0, 2)); | 2393 AppendCluster(GenerateCluster(0, 2)); |
| 2406 ExpectRead(DemuxerStream::AUDIO, 0); | 2394 ExpectRead(DemuxerStream::AUDIO, 0); |
| 2407 ExpectRead(DemuxerStream::VIDEO, 0); | 2395 ExpectRead(DemuxerStream::VIDEO, 0); |
| 2408 } | 2396 } |
| 2409 | 2397 |
| 2410 TEST_P(ChunkDemuxerTest, CodecPrefixMatching) { | 2398 TEST_F(ChunkDemuxerTest, CodecPrefixMatching) { |
| 2411 ChunkDemuxer::Status expected = ChunkDemuxer::kNotSupported; | 2399 ChunkDemuxer::Status expected = ChunkDemuxer::kNotSupported; |
| 2412 | 2400 |
| 2413 #if defined(USE_PROPRIETARY_CODECS) | 2401 #if defined(USE_PROPRIETARY_CODECS) |
| 2414 expected = ChunkDemuxer::kOk; | 2402 expected = ChunkDemuxer::kOk; |
| 2415 #endif | 2403 #endif |
| 2416 | 2404 |
| 2417 std::vector<std::string> codecs; | 2405 std::vector<std::string> codecs; |
| 2418 codecs.push_back("avc1.4D4041"); | 2406 codecs.push_back("avc1.4D4041"); |
| 2419 | 2407 |
| 2420 EXPECT_EQ(demuxer_->AddId("source_id", "video/mp4", codecs, | 2408 EXPECT_EQ(demuxer_->AddId("source_id", "video/mp4", codecs), expected); |
| 2421 use_legacy_frame_processor_), | |
| 2422 expected); | |
| 2423 } | 2409 } |
| 2424 | 2410 |
| 2425 // Test codec ID's that are not compliant with RFC6381, but have been | 2411 // Test codec ID's that are not compliant with RFC6381, but have been |
| 2426 // seen in the wild. | 2412 // seen in the wild. |
| 2427 TEST_P(ChunkDemuxerTest, CodecIDsThatAreNotRFC6381Compliant) { | 2413 TEST_F(ChunkDemuxerTest, CodecIDsThatAreNotRFC6381Compliant) { |
| 2428 ChunkDemuxer::Status expected = ChunkDemuxer::kNotSupported; | 2414 ChunkDemuxer::Status expected = ChunkDemuxer::kNotSupported; |
| 2429 | 2415 |
| 2430 #if defined(USE_PROPRIETARY_CODECS) | 2416 #if defined(USE_PROPRIETARY_CODECS) |
| 2431 expected = ChunkDemuxer::kOk; | 2417 expected = ChunkDemuxer::kOk; |
| 2432 #endif | 2418 #endif |
| 2433 const char* codec_ids[] = { | 2419 const char* codec_ids[] = { |
| 2434 // GPAC places leading zeros on the audio object type. | 2420 // GPAC places leading zeros on the audio object type. |
| 2435 "mp4a.40.02", | 2421 "mp4a.40.02", |
| 2436 "mp4a.40.05" | 2422 "mp4a.40.05" |
| 2437 }; | 2423 }; |
| 2438 | 2424 |
| 2439 for (size_t i = 0; i < arraysize(codec_ids); ++i) { | 2425 for (size_t i = 0; i < arraysize(codec_ids); ++i) { |
| 2440 std::vector<std::string> codecs; | 2426 std::vector<std::string> codecs; |
| 2441 codecs.push_back(codec_ids[i]); | 2427 codecs.push_back(codec_ids[i]); |
| 2442 | 2428 |
| 2443 ChunkDemuxer::Status result = | 2429 ChunkDemuxer::Status result = |
| 2444 demuxer_->AddId("source_id", "audio/mp4", codecs, | 2430 demuxer_->AddId("source_id", "audio/mp4", codecs); |
| 2445 use_legacy_frame_processor_); | |
| 2446 | 2431 |
| 2447 EXPECT_EQ(result, expected) | 2432 EXPECT_EQ(result, expected) |
| 2448 << "Fail to add codec_id '" << codec_ids[i] << "'"; | 2433 << "Fail to add codec_id '" << codec_ids[i] << "'"; |
| 2449 | 2434 |
| 2450 if (result == ChunkDemuxer::kOk) | 2435 if (result == ChunkDemuxer::kOk) |
| 2451 demuxer_->RemoveId("source_id"); | 2436 demuxer_->RemoveId("source_id"); |
| 2452 } | 2437 } |
| 2453 } | 2438 } |
| 2454 | 2439 |
| 2455 TEST_P(ChunkDemuxerTest, EndOfStreamStillSetAfterSeek) { | 2440 TEST_F(ChunkDemuxerTest, EndOfStreamStillSetAfterSeek) { |
| 2456 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); | 2441 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); |
| 2457 | 2442 |
| 2458 EXPECT_CALL(host_, SetDuration(_)) | 2443 EXPECT_CALL(host_, SetDuration(_)) |
| 2459 .Times(AnyNumber()); | 2444 .Times(AnyNumber()); |
| 2460 | 2445 |
| 2461 base::TimeDelta kLastAudioTimestamp = base::TimeDelta::FromMilliseconds(92); | 2446 base::TimeDelta kLastAudioTimestamp = base::TimeDelta::FromMilliseconds(92); |
| 2462 base::TimeDelta kLastVideoTimestamp = base::TimeDelta::FromMilliseconds(99); | 2447 base::TimeDelta kLastVideoTimestamp = base::TimeDelta::FromMilliseconds(99); |
| 2463 | 2448 |
| 2464 AppendCluster(kDefaultFirstCluster()); | 2449 AppendCluster(kDefaultFirstCluster()); |
| 2465 AppendCluster(kDefaultSecondCluster()); | 2450 AppendCluster(kDefaultSecondCluster()); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2482 | 2467 |
| 2483 ReadUntilNotOkOrEndOfStream(DemuxerStream::AUDIO, &status, &last_timestamp); | 2468 ReadUntilNotOkOrEndOfStream(DemuxerStream::AUDIO, &status, &last_timestamp); |
| 2484 EXPECT_EQ(DemuxerStream::kOk, status); | 2469 EXPECT_EQ(DemuxerStream::kOk, status); |
| 2485 EXPECT_EQ(kLastAudioTimestamp, last_timestamp); | 2470 EXPECT_EQ(kLastAudioTimestamp, last_timestamp); |
| 2486 | 2471 |
| 2487 ReadUntilNotOkOrEndOfStream(DemuxerStream::VIDEO, &status, &last_timestamp); | 2472 ReadUntilNotOkOrEndOfStream(DemuxerStream::VIDEO, &status, &last_timestamp); |
| 2488 EXPECT_EQ(DemuxerStream::kOk, status); | 2473 EXPECT_EQ(DemuxerStream::kOk, status); |
| 2489 EXPECT_EQ(kLastVideoTimestamp, last_timestamp); | 2474 EXPECT_EQ(kLastVideoTimestamp, last_timestamp); |
| 2490 } | 2475 } |
| 2491 | 2476 |
| 2492 TEST_P(ChunkDemuxerTest, GetBufferedRangesBeforeInitSegment) { | 2477 TEST_F(ChunkDemuxerTest, GetBufferedRangesBeforeInitSegment) { |
| 2493 EXPECT_CALL(*this, DemuxerOpened()); | 2478 EXPECT_CALL(*this, DemuxerOpened()); |
| 2494 demuxer_->Initialize(&host_, CreateInitDoneCB(PIPELINE_OK), true); | 2479 demuxer_->Initialize(&host_, CreateInitDoneCB(PIPELINE_OK), true); |
| 2495 ASSERT_EQ(AddId("audio", HAS_AUDIO), ChunkDemuxer::kOk); | 2480 ASSERT_EQ(AddId("audio", HAS_AUDIO), ChunkDemuxer::kOk); |
| 2496 ASSERT_EQ(AddId("video", HAS_VIDEO), ChunkDemuxer::kOk); | 2481 ASSERT_EQ(AddId("video", HAS_VIDEO), ChunkDemuxer::kOk); |
| 2497 | 2482 |
| 2498 CheckExpectedRanges("audio", "{ }"); | 2483 CheckExpectedRanges("audio", "{ }"); |
| 2499 CheckExpectedRanges("video", "{ }"); | 2484 CheckExpectedRanges("video", "{ }"); |
| 2500 } | 2485 } |
| 2501 | 2486 |
| 2502 // Test that Seek() completes successfully when the first cluster | 2487 // Test that Seek() completes successfully when the first cluster |
| 2503 // arrives. | 2488 // arrives. |
| 2504 TEST_P(ChunkDemuxerTest, EndOfStreamDuringSeek) { | 2489 TEST_F(ChunkDemuxerTest, EndOfStreamDuringSeek) { |
| 2505 InSequence s; | 2490 InSequence s; |
| 2506 | 2491 |
| 2507 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); | 2492 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); |
| 2508 | 2493 |
| 2509 AppendCluster(kDefaultFirstCluster()); | 2494 AppendCluster(kDefaultFirstCluster()); |
| 2510 | 2495 |
| 2511 base::TimeDelta seek_time = base::TimeDelta::FromSeconds(0); | 2496 base::TimeDelta seek_time = base::TimeDelta::FromSeconds(0); |
| 2512 demuxer_->StartWaitingForSeek(seek_time); | 2497 demuxer_->StartWaitingForSeek(seek_time); |
| 2513 | 2498 |
| 2514 AppendCluster(kDefaultSecondCluster()); | 2499 AppendCluster(kDefaultSecondCluster()); |
| 2515 EXPECT_CALL(host_, SetDuration( | 2500 EXPECT_CALL(host_, SetDuration( |
| 2516 base::TimeDelta::FromMilliseconds(kDefaultSecondClusterEndTimestamp))); | 2501 base::TimeDelta::FromMilliseconds(kDefaultSecondClusterEndTimestamp))); |
| 2517 MarkEndOfStream(PIPELINE_OK); | 2502 MarkEndOfStream(PIPELINE_OK); |
| 2518 | 2503 |
| 2519 demuxer_->Seek(seek_time, NewExpectedStatusCB(PIPELINE_OK)); | 2504 demuxer_->Seek(seek_time, NewExpectedStatusCB(PIPELINE_OK)); |
| 2520 | 2505 |
| 2521 GenerateExpectedReads(0, 4); | 2506 GenerateExpectedReads(0, 4); |
| 2522 GenerateExpectedReads(46, 66, 5); | 2507 GenerateExpectedReads(46, 66, 5); |
| 2523 | 2508 |
| 2524 EndOfStreamHelper end_of_stream_helper(demuxer_.get()); | 2509 EndOfStreamHelper end_of_stream_helper(demuxer_.get()); |
| 2525 end_of_stream_helper.RequestReads(); | 2510 end_of_stream_helper.RequestReads(); |
| 2526 end_of_stream_helper.CheckIfReadDonesWereCalled(true); | 2511 end_of_stream_helper.CheckIfReadDonesWereCalled(true); |
| 2527 } | 2512 } |
| 2528 | 2513 |
| 2529 TEST_P(ChunkDemuxerTest, ConfigChange_Video) { | 2514 TEST_F(ChunkDemuxerTest, ConfigChange_Video) { |
| 2530 InSequence s; | 2515 InSequence s; |
| 2531 | 2516 |
| 2532 ASSERT_TRUE(InitDemuxerWithConfigChangeData()); | 2517 ASSERT_TRUE(InitDemuxerWithConfigChangeData()); |
| 2533 | 2518 |
| 2534 DemuxerStream::Status status; | 2519 DemuxerStream::Status status; |
| 2535 base::TimeDelta last_timestamp; | 2520 base::TimeDelta last_timestamp; |
| 2536 | 2521 |
| 2537 DemuxerStream* video = demuxer_->GetStream(DemuxerStream::VIDEO); | 2522 DemuxerStream* video = demuxer_->GetStream(DemuxerStream::VIDEO); |
| 2538 | 2523 |
| 2539 // Fetch initial video config and verify it matches what we expect. | 2524 // Fetch initial video config and verify it matches what we expect. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 2566 ASSERT_TRUE(video_config_1.Matches(video->video_decoder_config())); | 2551 ASSERT_TRUE(video_config_1.Matches(video->video_decoder_config())); |
| 2567 | 2552 |
| 2568 ExpectRead(DemuxerStream::VIDEO, 801); | 2553 ExpectRead(DemuxerStream::VIDEO, 801); |
| 2569 | 2554 |
| 2570 // Read until the end of the stream just to make sure there aren't any other | 2555 // Read until the end of the stream just to make sure there aren't any other |
| 2571 // config changes. | 2556 // config changes. |
| 2572 ReadUntilNotOkOrEndOfStream(DemuxerStream::VIDEO, &status, &last_timestamp); | 2557 ReadUntilNotOkOrEndOfStream(DemuxerStream::VIDEO, &status, &last_timestamp); |
| 2573 ASSERT_EQ(status, DemuxerStream::kOk); | 2558 ASSERT_EQ(status, DemuxerStream::kOk); |
| 2574 } | 2559 } |
| 2575 | 2560 |
| 2576 TEST_P(ChunkDemuxerTest, ConfigChange_Audio) { | 2561 TEST_F(ChunkDemuxerTest, ConfigChange_Audio) { |
| 2577 InSequence s; | 2562 InSequence s; |
| 2578 | 2563 |
| 2579 ASSERT_TRUE(InitDemuxerWithConfigChangeData()); | 2564 ASSERT_TRUE(InitDemuxerWithConfigChangeData()); |
| 2580 | 2565 |
| 2581 DemuxerStream::Status status; | 2566 DemuxerStream::Status status; |
| 2582 base::TimeDelta last_timestamp; | 2567 base::TimeDelta last_timestamp; |
| 2583 | 2568 |
| 2584 DemuxerStream* audio = demuxer_->GetStream(DemuxerStream::AUDIO); | 2569 DemuxerStream* audio = demuxer_->GetStream(DemuxerStream::AUDIO); |
| 2585 | 2570 |
| 2586 // Fetch initial audio config and verify it matches what we expect. | 2571 // Fetch initial audio config and verify it matches what we expect. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 2610 EXPECT_EQ(last_timestamp.InMilliseconds(), 782); | 2595 EXPECT_EQ(last_timestamp.InMilliseconds(), 782); |
| 2611 ASSERT_TRUE(audio_config_1.Matches(audio->audio_decoder_config())); | 2596 ASSERT_TRUE(audio_config_1.Matches(audio->audio_decoder_config())); |
| 2612 | 2597 |
| 2613 // Read until the end of the stream just to make sure there aren't any other | 2598 // Read until the end of the stream just to make sure there aren't any other |
| 2614 // config changes. | 2599 // config changes. |
| 2615 ReadUntilNotOkOrEndOfStream(DemuxerStream::AUDIO, &status, &last_timestamp); | 2600 ReadUntilNotOkOrEndOfStream(DemuxerStream::AUDIO, &status, &last_timestamp); |
| 2616 ASSERT_EQ(status, DemuxerStream::kOk); | 2601 ASSERT_EQ(status, DemuxerStream::kOk); |
| 2617 EXPECT_EQ(last_timestamp.InMilliseconds(), 2744); | 2602 EXPECT_EQ(last_timestamp.InMilliseconds(), 2744); |
| 2618 } | 2603 } |
| 2619 | 2604 |
| 2620 TEST_P(ChunkDemuxerTest, ConfigChange_Seek) { | 2605 TEST_F(ChunkDemuxerTest, ConfigChange_Seek) { |
| 2621 InSequence s; | 2606 InSequence s; |
| 2622 | 2607 |
| 2623 ASSERT_TRUE(InitDemuxerWithConfigChangeData()); | 2608 ASSERT_TRUE(InitDemuxerWithConfigChangeData()); |
| 2624 | 2609 |
| 2625 DemuxerStream* video = demuxer_->GetStream(DemuxerStream::VIDEO); | 2610 DemuxerStream* video = demuxer_->GetStream(DemuxerStream::VIDEO); |
| 2626 | 2611 |
| 2627 // Fetch initial video config and verify it matches what we expect. | 2612 // Fetch initial video config and verify it matches what we expect. |
| 2628 const VideoDecoderConfig& video_config_1 = video->video_decoder_config(); | 2613 const VideoDecoderConfig& video_config_1 = video->video_decoder_config(); |
| 2629 ASSERT_TRUE(video_config_1.IsValidConfig()); | 2614 ASSERT_TRUE(video_config_1.IsValidConfig()); |
| 2630 EXPECT_EQ(video_config_1.natural_size().width(), 320); | 2615 EXPECT_EQ(video_config_1.natural_size().width(), 320); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 2657 // seek to a new location that has the same configuration as | 2642 // seek to a new location that has the same configuration as |
| 2658 // the start of the file without a Read() in the middle. | 2643 // the start of the file without a Read() in the middle. |
| 2659 Seek(base::TimeDelta::FromMilliseconds(527)); | 2644 Seek(base::TimeDelta::FromMilliseconds(527)); |
| 2660 Seek(base::TimeDelta::FromMilliseconds(801)); | 2645 Seek(base::TimeDelta::FromMilliseconds(801)); |
| 2661 | 2646 |
| 2662 // Verify that no config change is signalled. | 2647 // Verify that no config change is signalled. |
| 2663 ExpectRead(DemuxerStream::VIDEO, 801); | 2648 ExpectRead(DemuxerStream::VIDEO, 801); |
| 2664 ASSERT_TRUE(video_config_1.Matches(video->video_decoder_config())); | 2649 ASSERT_TRUE(video_config_1.Matches(video->video_decoder_config())); |
| 2665 } | 2650 } |
| 2666 | 2651 |
| 2667 TEST_P(ChunkDemuxerTest, TimestampPositiveOffset) { | 2652 TEST_F(ChunkDemuxerTest, TimestampPositiveOffset) { |
| 2668 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); | 2653 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); |
| 2669 | 2654 |
| 2670 ASSERT_TRUE(SetTimestampOffset(kSourceId, base::TimeDelta::FromSeconds(30))); | 2655 ASSERT_TRUE(SetTimestampOffset(kSourceId, base::TimeDelta::FromSeconds(30))); |
| 2671 AppendCluster(GenerateCluster(0, 2)); | 2656 AppendCluster(GenerateCluster(0, 2)); |
| 2672 | 2657 |
| 2673 Seek(base::TimeDelta::FromMilliseconds(30000)); | 2658 Seek(base::TimeDelta::FromMilliseconds(30000)); |
| 2674 | 2659 |
| 2675 GenerateExpectedReads(30000, 2); | 2660 GenerateExpectedReads(30000, 2); |
| 2676 } | 2661 } |
| 2677 | 2662 |
| 2678 TEST_P(ChunkDemuxerTest, TimestampNegativeOffset) { | 2663 TEST_F(ChunkDemuxerTest, TimestampNegativeOffset) { |
| 2679 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); | 2664 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); |
| 2680 | 2665 |
| 2681 ASSERT_TRUE(SetTimestampOffset(kSourceId, base::TimeDelta::FromSeconds(-1))); | 2666 ASSERT_TRUE(SetTimestampOffset(kSourceId, base::TimeDelta::FromSeconds(-1))); |
| 2682 AppendCluster(GenerateCluster(1000, 2)); | 2667 AppendCluster(GenerateCluster(1000, 2)); |
| 2683 | 2668 |
| 2684 GenerateExpectedReads(0, 2); | 2669 GenerateExpectedReads(0, 2); |
| 2685 } | 2670 } |
| 2686 | 2671 |
| 2687 TEST_P(ChunkDemuxerTest, TimestampOffsetSeparateStreams) { | 2672 TEST_F(ChunkDemuxerTest, TimestampOffsetSeparateStreams) { |
| 2688 std::string audio_id = "audio1"; | 2673 std::string audio_id = "audio1"; |
| 2689 std::string video_id = "video1"; | 2674 std::string video_id = "video1"; |
| 2690 ASSERT_TRUE(InitDemuxerAudioAndVideoSources(audio_id, video_id)); | 2675 ASSERT_TRUE(InitDemuxerAudioAndVideoSources(audio_id, video_id)); |
| 2691 | 2676 |
| 2692 ASSERT_TRUE(SetTimestampOffset( | 2677 ASSERT_TRUE(SetTimestampOffset( |
| 2693 audio_id, base::TimeDelta::FromMilliseconds(-2500))); | 2678 audio_id, base::TimeDelta::FromMilliseconds(-2500))); |
| 2694 ASSERT_TRUE(SetTimestampOffset( | 2679 ASSERT_TRUE(SetTimestampOffset( |
| 2695 video_id, base::TimeDelta::FromMilliseconds(-2500))); | 2680 video_id, base::TimeDelta::FromMilliseconds(-2500))); |
| 2696 AppendCluster(audio_id, GenerateSingleStreamCluster(2500, | 2681 AppendCluster(audio_id, GenerateSingleStreamCluster(2500, |
| 2697 2500 + kAudioBlockDuration * 4, kAudioTrackNum, kAudioBlockDuration)); | 2682 2500 + kAudioBlockDuration * 4, kAudioTrackNum, kAudioBlockDuration)); |
| 2698 AppendCluster(video_id, GenerateSingleStreamCluster(2500, | 2683 AppendCluster(video_id, GenerateSingleStreamCluster(2500, |
| 2699 2500 + kVideoBlockDuration * 4, kVideoTrackNum, kVideoBlockDuration)); | 2684 2500 + kVideoBlockDuration * 4, kVideoTrackNum, kVideoBlockDuration)); |
| 2700 GenerateAudioStreamExpectedReads(0, 4); | 2685 GenerateAudioStreamExpectedReads(0, 4); |
| 2701 GenerateVideoStreamExpectedReads(0, 4); | 2686 GenerateVideoStreamExpectedReads(0, 4); |
| 2702 | 2687 |
| 2703 Seek(base::TimeDelta::FromMilliseconds(27300)); | 2688 Seek(base::TimeDelta::FromMilliseconds(27300)); |
| 2704 | 2689 |
| 2705 ASSERT_TRUE(SetTimestampOffset( | 2690 ASSERT_TRUE(SetTimestampOffset( |
| 2706 audio_id, base::TimeDelta::FromMilliseconds(27300))); | 2691 audio_id, base::TimeDelta::FromMilliseconds(27300))); |
| 2707 ASSERT_TRUE(SetTimestampOffset( | 2692 ASSERT_TRUE(SetTimestampOffset( |
| 2708 video_id, base::TimeDelta::FromMilliseconds(27300))); | 2693 video_id, base::TimeDelta::FromMilliseconds(27300))); |
| 2709 AppendCluster(audio_id, GenerateSingleStreamCluster( | 2694 AppendCluster(audio_id, GenerateSingleStreamCluster( |
| 2710 0, kAudioBlockDuration * 4, kAudioTrackNum, kAudioBlockDuration)); | 2695 0, kAudioBlockDuration * 4, kAudioTrackNum, kAudioBlockDuration)); |
| 2711 AppendCluster(video_id, GenerateSingleStreamCluster( | 2696 AppendCluster(video_id, GenerateSingleStreamCluster( |
| 2712 0, kVideoBlockDuration * 4, kVideoTrackNum, kVideoBlockDuration)); | 2697 0, kVideoBlockDuration * 4, kVideoTrackNum, kVideoBlockDuration)); |
| 2713 GenerateVideoStreamExpectedReads(27300, 4); | 2698 GenerateVideoStreamExpectedReads(27300, 4); |
| 2714 GenerateAudioStreamExpectedReads(27300, 4); | 2699 GenerateAudioStreamExpectedReads(27300, 4); |
| 2715 } | 2700 } |
| 2716 | 2701 |
| 2717 TEST_P(ChunkDemuxerTest, IsParsingMediaSegmentMidMediaSegment) { | 2702 TEST_F(ChunkDemuxerTest, IsParsingMediaSegmentMidMediaSegment) { |
| 2718 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); | 2703 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); |
| 2719 | 2704 |
| 2720 scoped_ptr<Cluster> cluster = GenerateCluster(0, 2); | 2705 scoped_ptr<Cluster> cluster = GenerateCluster(0, 2); |
| 2721 // Append only part of the cluster data. | 2706 // Append only part of the cluster data. |
| 2722 AppendData(cluster->data(), cluster->size() - 13); | 2707 AppendData(cluster->data(), cluster->size() - 13); |
| 2723 | 2708 |
| 2724 // Confirm we're in the middle of parsing a media segment. | 2709 // Confirm we're in the middle of parsing a media segment. |
| 2725 ASSERT_TRUE(demuxer_->IsParsingMediaSegment(kSourceId)); | 2710 ASSERT_TRUE(demuxer_->IsParsingMediaSegment(kSourceId)); |
| 2726 | 2711 |
| 2727 demuxer_->Abort(kSourceId, | 2712 demuxer_->Abort(kSourceId, |
| 2728 append_window_start_for_next_append_, | 2713 append_window_start_for_next_append_, |
| 2729 append_window_end_for_next_append_, | 2714 append_window_end_for_next_append_, |
| 2730 ×tamp_offset_map_[kSourceId]); | 2715 ×tamp_offset_map_[kSourceId]); |
| 2731 | 2716 |
| 2732 // After Abort(), parsing should no longer be in the middle of a media | 2717 // After Abort(), parsing should no longer be in the middle of a media |
| 2733 // segment. | 2718 // segment. |
| 2734 ASSERT_FALSE(demuxer_->IsParsingMediaSegment(kSourceId)); | 2719 ASSERT_FALSE(demuxer_->IsParsingMediaSegment(kSourceId)); |
| 2735 } | 2720 } |
| 2736 | 2721 |
| 2737 #if defined(USE_PROPRIETARY_CODECS) | 2722 #if defined(USE_PROPRIETARY_CODECS) |
| 2738 #if defined(ENABLE_MPEG2TS_STREAM_PARSER) | 2723 #if defined(ENABLE_MPEG2TS_STREAM_PARSER) |
| 2739 TEST_P(ChunkDemuxerTest, EmitBuffersDuringAbort) { | 2724 TEST_F(ChunkDemuxerTest, EmitBuffersDuringAbort) { |
| 2740 EXPECT_CALL(*this, DemuxerOpened()); | 2725 EXPECT_CALL(*this, DemuxerOpened()); |
| 2741 demuxer_->Initialize( | 2726 demuxer_->Initialize( |
| 2742 &host_, CreateInitDoneCB(kInfiniteDuration(), PIPELINE_OK), true); | 2727 &host_, CreateInitDoneCB(kInfiniteDuration(), PIPELINE_OK), true); |
| 2743 EXPECT_EQ(ChunkDemuxer::kOk, AddIdForMp2tSource(kSourceId)); | 2728 EXPECT_EQ(ChunkDemuxer::kOk, AddIdForMp2tSource(kSourceId)); |
| 2744 | 2729 |
| 2745 // For info: | 2730 // For info: |
| 2746 // DTS/PTS derived using dvbsnoop -s ts -if bear-1280x720.ts -tssubdecode | 2731 // DTS/PTS derived using dvbsnoop -s ts -if bear-1280x720.ts -tssubdecode |
| 2747 // Video: first PES: | 2732 // Video: first PES: |
| 2748 // PTS: 126912 (0x0001efc0) [= 90 kHz-Timestamp: 0:00:01.4101] | 2733 // PTS: 126912 (0x0001efc0) [= 90 kHz-Timestamp: 0:00:01.4101] |
| 2749 // DTS: 123909 (0x0001e405) [= 90 kHz-Timestamp: 0:00:01.3767] | 2734 // DTS: 123909 (0x0001e405) [= 90 kHz-Timestamp: 0:00:01.3767] |
| (...skipping 24 matching lines...) Expand all Loading... |
| 2774 demuxer_->GetBufferedRanges(kSourceId); | 2759 demuxer_->GetBufferedRanges(kSourceId); |
| 2775 | 2760 |
| 2776 ASSERT_EQ(range_before_abort.size(), 1u); | 2761 ASSERT_EQ(range_before_abort.size(), 1u); |
| 2777 ASSERT_EQ(range_after_abort.size(), 1u); | 2762 ASSERT_EQ(range_after_abort.size(), 1u); |
| 2778 EXPECT_EQ(range_after_abort.start(0), range_before_abort.start(0)); | 2763 EXPECT_EQ(range_after_abort.start(0), range_before_abort.start(0)); |
| 2779 EXPECT_GT(range_after_abort.end(0), range_before_abort.end(0)); | 2764 EXPECT_GT(range_after_abort.end(0), range_before_abort.end(0)); |
| 2780 } | 2765 } |
| 2781 #endif | 2766 #endif |
| 2782 #endif | 2767 #endif |
| 2783 | 2768 |
| 2784 TEST_P(ChunkDemuxerTest, WebMIsParsingMediaSegmentDetection) { | 2769 TEST_F(ChunkDemuxerTest, WebMIsParsingMediaSegmentDetection) { |
| 2785 // TODO(wolenetz): Also test 'unknown' sized clusters. | 2770 // TODO(wolenetz): Also test 'unknown' sized clusters. |
| 2786 // See http://crbug.com/335676. | 2771 // See http://crbug.com/335676. |
| 2787 const uint8 kBuffer[] = { | 2772 const uint8 kBuffer[] = { |
| 2788 0x1F, 0x43, 0xB6, 0x75, 0x83, // CLUSTER (size = 3) | 2773 0x1F, 0x43, 0xB6, 0x75, 0x83, // CLUSTER (size = 3) |
| 2789 0xE7, 0x81, 0x01, // Cluster TIMECODE (value = 1) | 2774 0xE7, 0x81, 0x01, // Cluster TIMECODE (value = 1) |
| 2790 }; | 2775 }; |
| 2791 | 2776 |
| 2792 // This array indicates expected return value of IsParsingMediaSegment() | 2777 // This array indicates expected return value of IsParsingMediaSegment() |
| 2793 // following each incrementally appended byte in |kBuffer|. | 2778 // following each incrementally appended byte in |kBuffer|. |
| 2794 const bool kExpectedReturnValues[] = { | 2779 const bool kExpectedReturnValues[] = { |
| 2795 false, false, false, false, true, | 2780 false, false, false, false, true, |
| 2796 true, true, false, | 2781 true, true, false, |
| 2797 }; | 2782 }; |
| 2798 | 2783 |
| 2799 COMPILE_ASSERT(arraysize(kBuffer) == arraysize(kExpectedReturnValues), | 2784 COMPILE_ASSERT(arraysize(kBuffer) == arraysize(kExpectedReturnValues), |
| 2800 test_arrays_out_of_sync); | 2785 test_arrays_out_of_sync); |
| 2801 COMPILE_ASSERT(arraysize(kBuffer) == sizeof(kBuffer), not_one_byte_per_index); | 2786 COMPILE_ASSERT(arraysize(kBuffer) == sizeof(kBuffer), not_one_byte_per_index); |
| 2802 | 2787 |
| 2803 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); | 2788 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); |
| 2804 | 2789 |
| 2805 for (size_t i = 0; i < sizeof(kBuffer); i++) { | 2790 for (size_t i = 0; i < sizeof(kBuffer); i++) { |
| 2806 DVLOG(3) << "Appending and testing index " << i; | 2791 DVLOG(3) << "Appending and testing index " << i; |
| 2807 AppendData(kBuffer + i, 1); | 2792 AppendData(kBuffer + i, 1); |
| 2808 bool expected_return_value = kExpectedReturnValues[i]; | 2793 bool expected_return_value = kExpectedReturnValues[i]; |
| 2809 EXPECT_EQ(expected_return_value, | 2794 EXPECT_EQ(expected_return_value, |
| 2810 demuxer_->IsParsingMediaSegment(kSourceId)); | 2795 demuxer_->IsParsingMediaSegment(kSourceId)); |
| 2811 } | 2796 } |
| 2812 } | 2797 } |
| 2813 | 2798 |
| 2814 TEST_P(ChunkDemuxerTest, DurationChange) { | 2799 TEST_F(ChunkDemuxerTest, DurationChange) { |
| 2815 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); | 2800 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); |
| 2816 const int kStreamDuration = kDefaultDuration().InMilliseconds(); | 2801 const int kStreamDuration = kDefaultDuration().InMilliseconds(); |
| 2817 | 2802 |
| 2818 // Add data leading up to the currently set duration. | 2803 // Add data leading up to the currently set duration. |
| 2819 AppendCluster(GenerateCluster(kStreamDuration - kAudioBlockDuration, | 2804 AppendCluster(GenerateCluster(kStreamDuration - kAudioBlockDuration, |
| 2820 kStreamDuration - kVideoBlockDuration, | 2805 kStreamDuration - kVideoBlockDuration, |
| 2821 2)); | 2806 2)); |
| 2822 | 2807 |
| 2823 CheckExpectedRanges(kSourceId, "{ [201191,201224) }"); | 2808 CheckExpectedRanges(kSourceId, "{ [201191,201224) }"); |
| 2824 | 2809 |
| 2825 // Add data beginning at the currently set duration and expect a new duration | 2810 // Add data beginning at the currently set duration and expect a new duration |
| 2826 // to be signaled. Note that the last video block will have a higher end | 2811 // to be signaled. Note that the last video block will have a higher end |
| 2827 // timestamp than the last audio block. | 2812 // timestamp than the last audio block. |
| 2828 if (use_legacy_frame_processor_) { | |
| 2829 const int kNewStreamDurationAudio = kStreamDuration + kAudioBlockDuration; | |
| 2830 EXPECT_CALL(host_, SetDuration( | |
| 2831 base::TimeDelta::FromMilliseconds(kNewStreamDurationAudio))); | |
| 2832 } | |
| 2833 const int kNewStreamDurationVideo = kStreamDuration + kVideoBlockDuration; | 2813 const int kNewStreamDurationVideo = kStreamDuration + kVideoBlockDuration; |
| 2834 EXPECT_CALL(host_, SetDuration( | 2814 EXPECT_CALL(host_, SetDuration( |
| 2835 base::TimeDelta::FromMilliseconds(kNewStreamDurationVideo))); | 2815 base::TimeDelta::FromMilliseconds(kNewStreamDurationVideo))); |
| 2836 AppendCluster(GenerateCluster(kDefaultDuration().InMilliseconds(), 2)); | 2816 AppendCluster(GenerateCluster(kDefaultDuration().InMilliseconds(), 2)); |
| 2837 | 2817 |
| 2838 CheckExpectedRanges(kSourceId, "{ [201191,201247) }"); | 2818 CheckExpectedRanges(kSourceId, "{ [201191,201247) }"); |
| 2839 | 2819 |
| 2840 // Add more data to the end of each media type. Note that the last audio block | 2820 // Add more data to the end of each media type. Note that the last audio block |
| 2841 // will have a higher end timestamp than the last video block. | 2821 // will have a higher end timestamp than the last video block. |
| 2842 const int kFinalStreamDuration = kStreamDuration + kAudioBlockDuration * 3; | 2822 const int kFinalStreamDuration = kStreamDuration + kAudioBlockDuration * 3; |
| 2843 EXPECT_CALL(host_, SetDuration( | 2823 EXPECT_CALL(host_, SetDuration( |
| 2844 base::TimeDelta::FromMilliseconds(kFinalStreamDuration))); | 2824 base::TimeDelta::FromMilliseconds(kFinalStreamDuration))); |
| 2845 AppendCluster(GenerateCluster(kStreamDuration + kAudioBlockDuration, | 2825 AppendCluster(GenerateCluster(kStreamDuration + kAudioBlockDuration, |
| 2846 kStreamDuration + kVideoBlockDuration, | 2826 kStreamDuration + kVideoBlockDuration, |
| 2847 3)); | 2827 3)); |
| 2848 | 2828 |
| 2849 // See that the range has increased appropriately (but not to the full | 2829 // See that the range has increased appropriately (but not to the full |
| 2850 // duration of 201293, since there is not enough video appended for that). | 2830 // duration of 201293, since there is not enough video appended for that). |
| 2851 CheckExpectedRanges(kSourceId, "{ [201191,201290) }"); | 2831 CheckExpectedRanges(kSourceId, "{ [201191,201290) }"); |
| 2852 } | 2832 } |
| 2853 | 2833 |
| 2854 TEST_P(ChunkDemuxerTest, DurationChangeTimestampOffset) { | 2834 TEST_F(ChunkDemuxerTest, DurationChangeTimestampOffset) { |
| 2855 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); | 2835 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); |
| 2856 | |
| 2857 ASSERT_TRUE(SetTimestampOffset(kSourceId, kDefaultDuration())); | 2836 ASSERT_TRUE(SetTimestampOffset(kSourceId, kDefaultDuration())); |
| 2858 | |
| 2859 if (use_legacy_frame_processor_) { | |
| 2860 EXPECT_CALL(host_, SetDuration( | |
| 2861 kDefaultDuration() + base::TimeDelta::FromMilliseconds( | |
| 2862 kAudioBlockDuration * 2))); | |
| 2863 } | |
| 2864 EXPECT_CALL(host_, SetDuration( | 2837 EXPECT_CALL(host_, SetDuration( |
| 2865 kDefaultDuration() + base::TimeDelta::FromMilliseconds( | 2838 kDefaultDuration() + base::TimeDelta::FromMilliseconds( |
| 2866 kVideoBlockDuration * 2))); | 2839 kVideoBlockDuration * 2))); |
| 2867 AppendCluster(GenerateCluster(0, 4)); | 2840 AppendCluster(GenerateCluster(0, 4)); |
| 2868 } | 2841 } |
| 2869 | 2842 |
| 2870 TEST_P(ChunkDemuxerTest, EndOfStreamTruncateDuration) { | 2843 TEST_F(ChunkDemuxerTest, EndOfStreamTruncateDuration) { |
| 2871 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); | 2844 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); |
| 2872 | 2845 |
| 2873 AppendCluster(kDefaultFirstCluster()); | 2846 AppendCluster(kDefaultFirstCluster()); |
| 2874 | 2847 |
| 2875 EXPECT_CALL(host_, SetDuration( | 2848 EXPECT_CALL(host_, SetDuration( |
| 2876 base::TimeDelta::FromMilliseconds(kDefaultFirstClusterEndTimestamp))); | 2849 base::TimeDelta::FromMilliseconds(kDefaultFirstClusterEndTimestamp))); |
| 2877 MarkEndOfStream(PIPELINE_OK); | 2850 MarkEndOfStream(PIPELINE_OK); |
| 2878 } | 2851 } |
| 2879 | 2852 |
| 2880 | 2853 |
| 2881 TEST_P(ChunkDemuxerTest, ZeroLengthAppend) { | 2854 TEST_F(ChunkDemuxerTest, ZeroLengthAppend) { |
| 2882 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); | 2855 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); |
| 2883 AppendData(NULL, 0); | 2856 AppendData(NULL, 0); |
| 2884 } | 2857 } |
| 2885 | 2858 |
| 2886 TEST_P(ChunkDemuxerTest, AppendAfterEndOfStream) { | 2859 TEST_F(ChunkDemuxerTest, AppendAfterEndOfStream) { |
| 2887 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); | 2860 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); |
| 2888 | 2861 |
| 2889 EXPECT_CALL(host_, SetDuration(_)) | 2862 EXPECT_CALL(host_, SetDuration(_)) |
| 2890 .Times(AnyNumber()); | 2863 .Times(AnyNumber()); |
| 2891 | 2864 |
| 2892 AppendCluster(kDefaultFirstCluster()); | 2865 AppendCluster(kDefaultFirstCluster()); |
| 2893 MarkEndOfStream(PIPELINE_OK); | 2866 MarkEndOfStream(PIPELINE_OK); |
| 2894 | 2867 |
| 2895 demuxer_->UnmarkEndOfStream(); | 2868 demuxer_->UnmarkEndOfStream(); |
| 2896 | 2869 |
| 2897 AppendCluster(kDefaultSecondCluster()); | 2870 AppendCluster(kDefaultSecondCluster()); |
| 2898 MarkEndOfStream(PIPELINE_OK); | 2871 MarkEndOfStream(PIPELINE_OK); |
| 2899 } | 2872 } |
| 2900 | 2873 |
| 2901 // Test receiving a Shutdown() call before we get an Initialize() | 2874 // Test receiving a Shutdown() call before we get an Initialize() |
| 2902 // call. This can happen if video element gets destroyed before | 2875 // call. This can happen if video element gets destroyed before |
| 2903 // the pipeline has a chance to initialize the demuxer. | 2876 // the pipeline has a chance to initialize the demuxer. |
| 2904 TEST_P(ChunkDemuxerTest, Shutdown_BeforeInitialize) { | 2877 TEST_F(ChunkDemuxerTest, Shutdown_BeforeInitialize) { |
| 2905 demuxer_->Shutdown(); | 2878 demuxer_->Shutdown(); |
| 2906 demuxer_->Initialize( | 2879 demuxer_->Initialize( |
| 2907 &host_, CreateInitDoneCB(DEMUXER_ERROR_COULD_NOT_OPEN), true); | 2880 &host_, CreateInitDoneCB(DEMUXER_ERROR_COULD_NOT_OPEN), true); |
| 2908 message_loop_.RunUntilIdle(); | 2881 message_loop_.RunUntilIdle(); |
| 2909 } | 2882 } |
| 2910 | 2883 |
| 2911 // Verifies that signaling end of stream while stalled at a gap | 2884 // Verifies that signaling end of stream while stalled at a gap |
| 2912 // boundary does not trigger end of stream buffers to be returned. | 2885 // boundary does not trigger end of stream buffers to be returned. |
| 2913 TEST_P(ChunkDemuxerTest, EndOfStreamWhileWaitingForGapToBeFilled) { | 2886 TEST_F(ChunkDemuxerTest, EndOfStreamWhileWaitingForGapToBeFilled) { |
| 2914 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); | 2887 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); |
| 2915 | 2888 |
| 2916 AppendCluster(0, 10); | 2889 AppendCluster(0, 10); |
| 2917 AppendCluster(300, 10); | 2890 AppendCluster(300, 10); |
| 2918 CheckExpectedRanges(kSourceId, "{ [0,132) [300,432) }"); | 2891 CheckExpectedRanges(kSourceId, "{ [0,132) [300,432) }"); |
| 2919 | 2892 |
| 2920 GenerateExpectedReads(0, 10); | 2893 GenerateExpectedReads(0, 10); |
| 2921 | 2894 |
| 2922 bool audio_read_done = false; | 2895 bool audio_read_done = false; |
| 2923 bool video_read_done = false; | 2896 bool video_read_done = false; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2966 EXPECT_FALSE(audio_read_done); | 2939 EXPECT_FALSE(audio_read_done); |
| 2967 EXPECT_FALSE(video_read_done); | 2940 EXPECT_FALSE(video_read_done); |
| 2968 | 2941 |
| 2969 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(437))); | 2942 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(437))); |
| 2970 MarkEndOfStream(PIPELINE_OK); | 2943 MarkEndOfStream(PIPELINE_OK); |
| 2971 | 2944 |
| 2972 EXPECT_TRUE(audio_read_done); | 2945 EXPECT_TRUE(audio_read_done); |
| 2973 EXPECT_TRUE(video_read_done); | 2946 EXPECT_TRUE(video_read_done); |
| 2974 } | 2947 } |
| 2975 | 2948 |
| 2976 TEST_P(ChunkDemuxerTest, CanceledSeekDuringInitialPreroll) { | 2949 TEST_F(ChunkDemuxerTest, CanceledSeekDuringInitialPreroll) { |
| 2977 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); | 2950 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); |
| 2978 | 2951 |
| 2979 // Cancel preroll. | 2952 // Cancel preroll. |
| 2980 base::TimeDelta seek_time = base::TimeDelta::FromMilliseconds(200); | 2953 base::TimeDelta seek_time = base::TimeDelta::FromMilliseconds(200); |
| 2981 demuxer_->CancelPendingSeek(seek_time); | 2954 demuxer_->CancelPendingSeek(seek_time); |
| 2982 | 2955 |
| 2983 // Initiate the seek to the new location. | 2956 // Initiate the seek to the new location. |
| 2984 Seek(seek_time); | 2957 Seek(seek_time); |
| 2985 | 2958 |
| 2986 // Append data to satisfy the seek. | 2959 // Append data to satisfy the seek. |
| 2987 AppendCluster(seek_time.InMilliseconds(), 10); | 2960 AppendCluster(seek_time.InMilliseconds(), 10); |
| 2988 } | 2961 } |
| 2989 | 2962 |
| 2990 TEST_P(ChunkDemuxerTest, GCDuringSeek) { | 2963 TEST_F(ChunkDemuxerTest, GCDuringSeek) { |
| 2991 ASSERT_TRUE(InitDemuxer(HAS_AUDIO)); | 2964 ASSERT_TRUE(InitDemuxer(HAS_AUDIO)); |
| 2992 | 2965 |
| 2993 demuxer_->SetMemoryLimitsForTesting(5 * kBlockSize); | 2966 demuxer_->SetMemoryLimitsForTesting(5 * kBlockSize); |
| 2994 | 2967 |
| 2995 base::TimeDelta seek_time1 = base::TimeDelta::FromMilliseconds(1000); | 2968 base::TimeDelta seek_time1 = base::TimeDelta::FromMilliseconds(1000); |
| 2996 base::TimeDelta seek_time2 = base::TimeDelta::FromMilliseconds(500); | 2969 base::TimeDelta seek_time2 = base::TimeDelta::FromMilliseconds(500); |
| 2997 | 2970 |
| 2998 // Initiate a seek to |seek_time1|. | 2971 // Initiate a seek to |seek_time1|. |
| 2999 Seek(seek_time1); | 2972 Seek(seek_time1); |
| 3000 | 2973 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 3023 // Append more data and make sure that the blocks for |seek_time2| | 2996 // Append more data and make sure that the blocks for |seek_time2| |
| 3024 // don't get removed. | 2997 // don't get removed. |
| 3025 // | 2998 // |
| 3026 // NOTE: The current GC algorithm tries to preserve the GOP at the | 2999 // NOTE: The current GC algorithm tries to preserve the GOP at the |
| 3027 // current position as well as the last appended GOP. This is | 3000 // current position as well as the last appended GOP. This is |
| 3028 // why there are 2 ranges in the expectations. | 3001 // why there are 2 ranges in the expectations. |
| 3029 AppendSingleStreamCluster(kSourceId, kAudioTrackNum, 700, 5); | 3002 AppendSingleStreamCluster(kSourceId, kAudioTrackNum, 700, 5); |
| 3030 CheckExpectedRanges(kSourceId, "{ [500,592) [792,815) }"); | 3003 CheckExpectedRanges(kSourceId, "{ [500,592) [792,815) }"); |
| 3031 } | 3004 } |
| 3032 | 3005 |
| 3033 TEST_P(ChunkDemuxerTest, AppendWindow_Video) { | 3006 TEST_F(ChunkDemuxerTest, AppendWindow_Video) { |
| 3034 ASSERT_TRUE(InitDemuxer(HAS_VIDEO)); | 3007 ASSERT_TRUE(InitDemuxer(HAS_VIDEO)); |
| 3035 DemuxerStream* stream = demuxer_->GetStream(DemuxerStream::VIDEO); | 3008 DemuxerStream* stream = demuxer_->GetStream(DemuxerStream::VIDEO); |
| 3036 | 3009 |
| 3037 // Set the append window to [50,280). | 3010 // Set the append window to [50,280). |
| 3038 append_window_start_for_next_append_ = base::TimeDelta::FromMilliseconds(50); | 3011 append_window_start_for_next_append_ = base::TimeDelta::FromMilliseconds(50); |
| 3039 append_window_end_for_next_append_ = base::TimeDelta::FromMilliseconds(280); | 3012 append_window_end_for_next_append_ = base::TimeDelta::FromMilliseconds(280); |
| 3040 | 3013 |
| 3041 // Append a cluster that starts before and ends after the append window. | 3014 // Append a cluster that starts before and ends after the append window. |
| 3042 AppendSingleStreamCluster(kSourceId, kVideoTrackNum, | 3015 AppendSingleStreamCluster(kSourceId, kVideoTrackNum, |
| 3043 "0K 30 60 90 120K 150 180 210 240K 270 300 330K"); | 3016 "0K 30 60 90 120K 150 180 210 240K 270 300 330K"); |
| 3044 | 3017 |
| 3045 // Verify that GOPs that start outside the window are not included | 3018 // Verify that GOPs that start outside the window are not included |
| 3046 // in the buffer. Also verify that buffers that start inside the | 3019 // in the buffer. Also verify that buffers that start inside the |
| 3047 // window and extend beyond the end of the window are not included. | 3020 // window and extend beyond the end of the window are not included. |
| 3048 CheckExpectedRanges(kSourceId, "{ [120,270) }"); | 3021 CheckExpectedRanges(kSourceId, "{ [120,270) }"); |
| 3049 CheckExpectedBuffers(stream, "120 150 180 210 240"); | 3022 CheckExpectedBuffers(stream, "120 150 180 210 240"); |
| 3050 | 3023 |
| 3051 // Extend the append window to [50,650). | 3024 // Extend the append window to [50,650). |
| 3052 append_window_end_for_next_append_ = base::TimeDelta::FromMilliseconds(650); | 3025 append_window_end_for_next_append_ = base::TimeDelta::FromMilliseconds(650); |
| 3053 | 3026 |
| 3054 // Append more data and verify that adding buffers start at the next | 3027 // Append more data and verify that adding buffers start at the next |
| 3055 // keyframe. | 3028 // keyframe. |
| 3056 AppendSingleStreamCluster(kSourceId, kVideoTrackNum, | 3029 AppendSingleStreamCluster(kSourceId, kVideoTrackNum, |
| 3057 "360 390 420K 450 480 510 540K 570 600 630K"); | 3030 "360 390 420K 450 480 510 540K 570 600 630K"); |
| 3058 CheckExpectedRanges(kSourceId, "{ [120,270) [420,630) }"); | 3031 CheckExpectedRanges(kSourceId, "{ [120,270) [420,630) }"); |
| 3059 } | 3032 } |
| 3060 | 3033 |
| 3061 TEST_P(ChunkDemuxerTest, AppendWindow_Audio) { | 3034 TEST_F(ChunkDemuxerTest, AppendWindow_Audio) { |
| 3062 ASSERT_TRUE(InitDemuxer(HAS_AUDIO)); | 3035 ASSERT_TRUE(InitDemuxer(HAS_AUDIO)); |
| 3063 DemuxerStream* stream = demuxer_->GetStream(DemuxerStream::AUDIO); | 3036 DemuxerStream* stream = demuxer_->GetStream(DemuxerStream::AUDIO); |
| 3064 | 3037 |
| 3065 // Set the append window to [50,280). | 3038 // Set the append window to [50,280). |
| 3066 append_window_start_for_next_append_ = base::TimeDelta::FromMilliseconds(50); | 3039 append_window_start_for_next_append_ = base::TimeDelta::FromMilliseconds(50); |
| 3067 append_window_end_for_next_append_ = base::TimeDelta::FromMilliseconds(280); | 3040 append_window_end_for_next_append_ = base::TimeDelta::FromMilliseconds(280); |
| 3068 | 3041 |
| 3069 // Append a cluster that starts before and ends after the append window. | 3042 // Append a cluster that starts before and ends after the append window. |
| 3070 AppendSingleStreamCluster( | 3043 AppendSingleStreamCluster( |
| 3071 kSourceId, kAudioTrackNum, | 3044 kSourceId, kAudioTrackNum, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 3086 // Extend the append window to [50,650). | 3059 // Extend the append window to [50,650). |
| 3087 append_window_end_for_next_append_ = base::TimeDelta::FromMilliseconds(650); | 3060 append_window_end_for_next_append_ = base::TimeDelta::FromMilliseconds(650); |
| 3088 | 3061 |
| 3089 // Append more data and verify that a new range is created. | 3062 // Append more data and verify that a new range is created. |
| 3090 AppendSingleStreamCluster( | 3063 AppendSingleStreamCluster( |
| 3091 kSourceId, kAudioTrackNum, | 3064 kSourceId, kAudioTrackNum, |
| 3092 "360K 390K 420K 450K 480K 510K 540K 570K 600K 630K"); | 3065 "360K 390K 420K 450K 480K 510K 540K 570K 600K 630K"); |
| 3093 CheckExpectedRanges(kSourceId, "{ [50,270) [360,630) }"); | 3066 CheckExpectedRanges(kSourceId, "{ [50,270) [360,630) }"); |
| 3094 } | 3067 } |
| 3095 | 3068 |
| 3096 TEST_P(ChunkDemuxerTest, AppendWindow_AudioOverlapStartAndEnd) { | 3069 TEST_F(ChunkDemuxerTest, AppendWindow_AudioOverlapStartAndEnd) { |
| 3097 ASSERT_TRUE(InitDemuxer(HAS_AUDIO)); | 3070 ASSERT_TRUE(InitDemuxer(HAS_AUDIO)); |
| 3098 | 3071 |
| 3099 // Set the append window to [10,20). | 3072 // Set the append window to [10,20). |
| 3100 append_window_start_for_next_append_ = base::TimeDelta::FromMilliseconds(10); | 3073 append_window_start_for_next_append_ = base::TimeDelta::FromMilliseconds(10); |
| 3101 append_window_end_for_next_append_ = base::TimeDelta::FromMilliseconds(20); | 3074 append_window_end_for_next_append_ = base::TimeDelta::FromMilliseconds(20); |
| 3102 | 3075 |
| 3103 // Append a cluster that starts before and ends after the append window. | 3076 // Append a cluster that starts before and ends after the append window. |
| 3104 AppendSingleStreamCluster(kSourceId, kAudioTrackNum, "0K"); | 3077 AppendSingleStreamCluster(kSourceId, kAudioTrackNum, "0K"); |
| 3105 | 3078 |
| 3106 // Verify that everything is dropped in this case. No partial append should | 3079 // Verify that everything is dropped in this case. No partial append should |
| 3107 // be generated. | 3080 // be generated. |
| 3108 CheckExpectedRanges(kSourceId, "{ }"); | 3081 CheckExpectedRanges(kSourceId, "{ }"); |
| 3109 } | 3082 } |
| 3110 | 3083 |
| 3111 TEST_P(ChunkDemuxerTest, AppendWindow_WebMFile_AudioOnly) { | 3084 TEST_F(ChunkDemuxerTest, AppendWindow_WebMFile_AudioOnly) { |
| 3112 EXPECT_CALL(*this, DemuxerOpened()); | 3085 EXPECT_CALL(*this, DemuxerOpened()); |
| 3113 demuxer_->Initialize( | 3086 demuxer_->Initialize( |
| 3114 &host_, | 3087 &host_, |
| 3115 CreateInitDoneCB(base::TimeDelta::FromMilliseconds(2744), PIPELINE_OK), | 3088 CreateInitDoneCB(base::TimeDelta::FromMilliseconds(2744), PIPELINE_OK), |
| 3116 true); | 3089 true); |
| 3117 ASSERT_EQ(ChunkDemuxer::kOk, AddId(kSourceId, HAS_AUDIO)); | 3090 ASSERT_EQ(ChunkDemuxer::kOk, AddId(kSourceId, HAS_AUDIO)); |
| 3118 | 3091 |
| 3119 // Set the append window to [50,150). | 3092 // Set the append window to [50,150). |
| 3120 append_window_start_for_next_append_ = base::TimeDelta::FromMilliseconds(50); | 3093 append_window_start_for_next_append_ = base::TimeDelta::FromMilliseconds(50); |
| 3121 append_window_end_for_next_append_ = base::TimeDelta::FromMilliseconds(150); | 3094 append_window_end_for_next_append_ = base::TimeDelta::FromMilliseconds(150); |
| 3122 | 3095 |
| 3123 // Read a WebM file into memory and send the data to the demuxer. The chunk | 3096 // Read a WebM file into memory and send the data to the demuxer. The chunk |
| 3124 // size has been chosen carefully to ensure the preroll buffer used by the | 3097 // size has been chosen carefully to ensure the preroll buffer used by the |
| 3125 // partial append window trim must come from a previous Append() call. | 3098 // partial append window trim must come from a previous Append() call. |
| 3126 scoped_refptr<DecoderBuffer> buffer = | 3099 scoped_refptr<DecoderBuffer> buffer = |
| 3127 ReadTestDataFile("bear-320x240-audio-only.webm"); | 3100 ReadTestDataFile("bear-320x240-audio-only.webm"); |
| 3128 AppendDataInPieces(buffer->data(), buffer->data_size(), 128); | 3101 AppendDataInPieces(buffer->data(), buffer->data_size(), 128); |
| 3129 | 3102 |
| 3130 DemuxerStream* stream = demuxer_->GetStream(DemuxerStream::AUDIO); | 3103 DemuxerStream* stream = demuxer_->GetStream(DemuxerStream::AUDIO); |
| 3131 CheckExpectedBuffers(stream, "50P 50 62 86 109 122 125 128"); | 3104 CheckExpectedBuffers(stream, "50P 50 62 86 109 122 125 128"); |
| 3132 } | 3105 } |
| 3133 | 3106 |
| 3134 TEST_P(ChunkDemuxerTest, AppendWindow_AudioConfigUpdateRemovesPreroll) { | 3107 TEST_F(ChunkDemuxerTest, AppendWindow_AudioConfigUpdateRemovesPreroll) { |
| 3135 EXPECT_CALL(*this, DemuxerOpened()); | 3108 EXPECT_CALL(*this, DemuxerOpened()); |
| 3136 demuxer_->Initialize( | 3109 demuxer_->Initialize( |
| 3137 &host_, | 3110 &host_, |
| 3138 CreateInitDoneCB(base::TimeDelta::FromMilliseconds(2744), PIPELINE_OK), | 3111 CreateInitDoneCB(base::TimeDelta::FromMilliseconds(2744), PIPELINE_OK), |
| 3139 true); | 3112 true); |
| 3140 ASSERT_EQ(ChunkDemuxer::kOk, AddId(kSourceId, HAS_AUDIO)); | 3113 ASSERT_EQ(ChunkDemuxer::kOk, AddId(kSourceId, HAS_AUDIO)); |
| 3141 | 3114 |
| 3142 // Set the append window such that the first file is completely before the | 3115 // Set the append window such that the first file is completely before the |
| 3143 // append window. | 3116 // append window. |
| 3144 // TODO(wolenetz/acolwell): Update this duration once the files are fixed to | 3117 // TODO(wolenetz/acolwell): Update this duration once the files are fixed to |
| (...skipping 19 matching lines...) Expand all Loading... |
| 3164 ASSERT_TRUE(SetTimestampOffset(kSourceId, duration_1)); | 3137 ASSERT_TRUE(SetTimestampOffset(kSourceId, duration_1)); |
| 3165 AppendDataInPieces(buffer2->data(), buffer2->data_size(), 512); | 3138 AppendDataInPieces(buffer2->data(), buffer2->data_size(), 512); |
| 3166 CheckExpectedRanges(kSourceId, "{ [2746,5519) }"); | 3139 CheckExpectedRanges(kSourceId, "{ [2746,5519) }"); |
| 3167 | 3140 |
| 3168 Seek(duration_1); | 3141 Seek(duration_1); |
| 3169 ExpectConfigChanged(DemuxerStream::AUDIO); | 3142 ExpectConfigChanged(DemuxerStream::AUDIO); |
| 3170 ASSERT_FALSE(config_1.Matches(stream->audio_decoder_config())); | 3143 ASSERT_FALSE(config_1.Matches(stream->audio_decoder_config())); |
| 3171 CheckExpectedBuffers(stream, "2746 2767 2789 2810"); | 3144 CheckExpectedBuffers(stream, "2746 2767 2789 2810"); |
| 3172 } | 3145 } |
| 3173 | 3146 |
| 3174 TEST_P(ChunkDemuxerTest, AppendWindow_Text) { | 3147 TEST_F(ChunkDemuxerTest, AppendWindow_Text) { |
| 3175 DemuxerStream* text_stream = NULL; | 3148 DemuxerStream* text_stream = NULL; |
| 3176 EXPECT_CALL(host_, AddTextStream(_, _)) | 3149 EXPECT_CALL(host_, AddTextStream(_, _)) |
| 3177 .WillOnce(SaveArg<0>(&text_stream)); | 3150 .WillOnce(SaveArg<0>(&text_stream)); |
| 3178 ASSERT_TRUE(InitDemuxer(HAS_VIDEO | HAS_TEXT)); | 3151 ASSERT_TRUE(InitDemuxer(HAS_VIDEO | HAS_TEXT)); |
| 3179 DemuxerStream* video_stream = demuxer_->GetStream(DemuxerStream::VIDEO); | 3152 DemuxerStream* video_stream = demuxer_->GetStream(DemuxerStream::VIDEO); |
| 3180 | 3153 |
| 3181 // Set the append window to [20,280). | 3154 // Set the append window to [20,280). |
| 3182 append_window_start_for_next_append_ = base::TimeDelta::FromMilliseconds(20); | 3155 append_window_start_for_next_append_ = base::TimeDelta::FromMilliseconds(20); |
| 3183 append_window_end_for_next_append_ = base::TimeDelta::FromMilliseconds(280); | 3156 append_window_end_for_next_append_ = base::TimeDelta::FromMilliseconds(280); |
| 3184 | 3157 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 3203 "360 390 420K 450 480 510 540K 570 600 630K"); | 3176 "360 390 420K 450 480 510 540K 570 600 630K"); |
| 3204 AppendSingleStreamCluster(kSourceId, kTextTrackNum, "400K 500K 600K 700K"); | 3177 AppendSingleStreamCluster(kSourceId, kTextTrackNum, "400K 500K 600K 700K"); |
| 3205 CheckExpectedRanges(kSourceId, "{ [120,270) [420,630) }"); | 3178 CheckExpectedRanges(kSourceId, "{ [120,270) [420,630) }"); |
| 3206 | 3179 |
| 3207 // Seek to the new range and verify that the expected buffers are returned. | 3180 // Seek to the new range and verify that the expected buffers are returned. |
| 3208 Seek(base::TimeDelta::FromMilliseconds(420)); | 3181 Seek(base::TimeDelta::FromMilliseconds(420)); |
| 3209 CheckExpectedBuffers(video_stream, "420 450 480 510 540 570 600"); | 3182 CheckExpectedBuffers(video_stream, "420 450 480 510 540 570 600"); |
| 3210 CheckExpectedBuffers(text_stream, "400 500"); | 3183 CheckExpectedBuffers(text_stream, "400 500"); |
| 3211 } | 3184 } |
| 3212 | 3185 |
| 3213 TEST_P(ChunkDemuxerTest, StartWaitingForSeekAfterParseError) { | 3186 TEST_F(ChunkDemuxerTest, StartWaitingForSeekAfterParseError) { |
| 3214 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); | 3187 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); |
| 3215 EXPECT_CALL(host_, OnDemuxerError(PIPELINE_ERROR_DECODE)); | 3188 EXPECT_CALL(host_, OnDemuxerError(PIPELINE_ERROR_DECODE)); |
| 3216 AppendGarbage(); | 3189 AppendGarbage(); |
| 3217 base::TimeDelta seek_time = base::TimeDelta::FromSeconds(50); | 3190 base::TimeDelta seek_time = base::TimeDelta::FromSeconds(50); |
| 3218 demuxer_->StartWaitingForSeek(seek_time); | 3191 demuxer_->StartWaitingForSeek(seek_time); |
| 3219 } | 3192 } |
| 3220 | 3193 |
| 3221 TEST_P(ChunkDemuxerTest, Remove_AudioVideoText) { | 3194 TEST_F(ChunkDemuxerTest, Remove_AudioVideoText) { |
| 3222 DemuxerStream* text_stream = NULL; | 3195 DemuxerStream* text_stream = NULL; |
| 3223 EXPECT_CALL(host_, AddTextStream(_, _)) | 3196 EXPECT_CALL(host_, AddTextStream(_, _)) |
| 3224 .WillOnce(SaveArg<0>(&text_stream)); | 3197 .WillOnce(SaveArg<0>(&text_stream)); |
| 3225 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO | HAS_TEXT)); | 3198 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO | HAS_TEXT)); |
| 3226 | 3199 |
| 3227 DemuxerStream* audio_stream = demuxer_->GetStream(DemuxerStream::AUDIO); | 3200 DemuxerStream* audio_stream = demuxer_->GetStream(DemuxerStream::AUDIO); |
| 3228 DemuxerStream* video_stream = demuxer_->GetStream(DemuxerStream::VIDEO); | 3201 DemuxerStream* video_stream = demuxer_->GetStream(DemuxerStream::VIDEO); |
| 3229 | 3202 |
| 3230 AppendSingleStreamCluster(kSourceId, kAudioTrackNum, | 3203 AppendSingleStreamCluster(kSourceId, kAudioTrackNum, |
| 3231 "0K 20K 40K 60K 80K 100K 120K 140K"); | 3204 "0K 20K 40K 60K 80K 100K 120K 140K"); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 3251 AppendSingleStreamCluster(kSourceId, kVideoTrackNum, | 3224 AppendSingleStreamCluster(kSourceId, kVideoTrackNum, |
| 3252 "1K 31 61 91 121K 151 181"); | 3225 "1K 31 61 91 121K 151 181"); |
| 3253 AppendSingleStreamCluster(kSourceId, kTextTrackNum, "1K 101K 201K"); | 3226 AppendSingleStreamCluster(kSourceId, kTextTrackNum, "1K 101K 201K"); |
| 3254 | 3227 |
| 3255 Seek(base::TimeDelta()); | 3228 Seek(base::TimeDelta()); |
| 3256 CheckExpectedBuffers(audio_stream, "1 21 41 61 81 101 121 141"); | 3229 CheckExpectedBuffers(audio_stream, "1 21 41 61 81 101 121 141"); |
| 3257 CheckExpectedBuffers(video_stream, "1 31 61 91 121 151 181"); | 3230 CheckExpectedBuffers(video_stream, "1 31 61 91 121 151 181"); |
| 3258 CheckExpectedBuffers(text_stream, "1 101 201"); | 3231 CheckExpectedBuffers(text_stream, "1 101 201"); |
| 3259 } | 3232 } |
| 3260 | 3233 |
| 3261 TEST_P(ChunkDemuxerTest, Remove_StartAtDuration) { | 3234 TEST_F(ChunkDemuxerTest, Remove_StartAtDuration) { |
| 3262 ASSERT_TRUE(InitDemuxer(HAS_AUDIO)); | 3235 ASSERT_TRUE(InitDemuxer(HAS_AUDIO)); |
| 3263 DemuxerStream* audio_stream = demuxer_->GetStream(DemuxerStream::AUDIO); | 3236 DemuxerStream* audio_stream = demuxer_->GetStream(DemuxerStream::AUDIO); |
| 3264 | 3237 |
| 3265 // Set the duration to something small so that the append that | 3238 // Set the duration to something small so that the append that |
| 3266 // follows updates the duration to reflect the end of the appended data. | 3239 // follows updates the duration to reflect the end of the appended data. |
| 3267 EXPECT_CALL(host_, SetDuration( | 3240 EXPECT_CALL(host_, SetDuration( |
| 3268 base::TimeDelta::FromMilliseconds(1))); | 3241 base::TimeDelta::FromMilliseconds(1))); |
| 3269 demuxer_->SetDuration(0.001); | 3242 demuxer_->SetDuration(0.001); |
| 3270 | 3243 |
| 3271 EXPECT_CALL(host_, SetDuration( | 3244 EXPECT_CALL(host_, SetDuration( |
| 3272 base::TimeDelta::FromMilliseconds(160))); | 3245 base::TimeDelta::FromMilliseconds(160))); |
| 3273 AppendSingleStreamCluster(kSourceId, kAudioTrackNum, | 3246 AppendSingleStreamCluster(kSourceId, kAudioTrackNum, |
| 3274 "0K 20K 40K 60K 80K 100K 120K 140K"); | 3247 "0K 20K 40K 60K 80K 100K 120K 140K"); |
| 3275 | 3248 |
| 3276 CheckExpectedRanges(kSourceId, "{ [0,160) }"); | 3249 CheckExpectedRanges(kSourceId, "{ [0,160) }"); |
| 3277 CheckExpectedBuffers(audio_stream, "0 20 40 60 80 100 120 140"); | 3250 CheckExpectedBuffers(audio_stream, "0 20 40 60 80 100 120 140"); |
| 3278 | 3251 |
| 3279 demuxer_->Remove(kSourceId, | 3252 demuxer_->Remove(kSourceId, |
| 3280 base::TimeDelta::FromSecondsD(demuxer_->GetDuration()), | 3253 base::TimeDelta::FromSecondsD(demuxer_->GetDuration()), |
| 3281 kInfiniteDuration()); | 3254 kInfiniteDuration()); |
| 3282 | 3255 |
| 3283 Seek(base::TimeDelta()); | 3256 Seek(base::TimeDelta()); |
| 3284 CheckExpectedRanges(kSourceId, "{ [0,160) }"); | 3257 CheckExpectedRanges(kSourceId, "{ [0,160) }"); |
| 3285 CheckExpectedBuffers(audio_stream, "0 20 40 60 80 100 120 140"); | 3258 CheckExpectedBuffers(audio_stream, "0 20 40 60 80 100 120 140"); |
| 3286 } | 3259 } |
| 3287 | 3260 |
| 3288 // Verifies that a Seek() will complete without text cues for | 3261 // Verifies that a Seek() will complete without text cues for |
| 3289 // the seek point and will return cues after the seek position | 3262 // the seek point and will return cues after the seek position |
| 3290 // when they are eventually appended. | 3263 // when they are eventually appended. |
| 3291 TEST_P(ChunkDemuxerTest, SeekCompletesWithoutTextCues) { | 3264 TEST_F(ChunkDemuxerTest, SeekCompletesWithoutTextCues) { |
| 3292 DemuxerStream* text_stream = NULL; | 3265 DemuxerStream* text_stream = NULL; |
| 3293 EXPECT_CALL(host_, AddTextStream(_, _)) | 3266 EXPECT_CALL(host_, AddTextStream(_, _)) |
| 3294 .WillOnce(SaveArg<0>(&text_stream)); | 3267 .WillOnce(SaveArg<0>(&text_stream)); |
| 3295 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO | HAS_TEXT)); | 3268 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO | HAS_TEXT)); |
| 3296 | 3269 |
| 3297 DemuxerStream* audio_stream = demuxer_->GetStream(DemuxerStream::AUDIO); | 3270 DemuxerStream* audio_stream = demuxer_->GetStream(DemuxerStream::AUDIO); |
| 3298 DemuxerStream* video_stream = demuxer_->GetStream(DemuxerStream::VIDEO); | 3271 DemuxerStream* video_stream = demuxer_->GetStream(DemuxerStream::VIDEO); |
| 3299 | 3272 |
| 3300 base::TimeDelta seek_time = base::TimeDelta::FromMilliseconds(120); | 3273 base::TimeDelta seek_time = base::TimeDelta::FromMilliseconds(120); |
| 3301 bool seek_cb_was_called = false; | 3274 bool seek_cb_was_called = false; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3336 | 3309 |
| 3337 // NOTE: we start at 175 here because the buffer at 125 was returned | 3310 // NOTE: we start at 175 here because the buffer at 125 was returned |
| 3338 // to the pending read initiated above. | 3311 // to the pending read initiated above. |
| 3339 CheckExpectedBuffers(text_stream, "175 225"); | 3312 CheckExpectedBuffers(text_stream, "175 225"); |
| 3340 | 3313 |
| 3341 // Verify that audio & video streams continue to return expected values. | 3314 // Verify that audio & video streams continue to return expected values. |
| 3342 CheckExpectedBuffers(audio_stream, "160 180"); | 3315 CheckExpectedBuffers(audio_stream, "160 180"); |
| 3343 CheckExpectedBuffers(video_stream, "180 210"); | 3316 CheckExpectedBuffers(video_stream, "180 210"); |
| 3344 } | 3317 } |
| 3345 | 3318 |
| 3346 // Generate two sets of tests: one using FrameProcessor, and one using | |
| 3347 // LegacyFrameProcessor. | |
| 3348 INSTANTIATE_TEST_CASE_P(NewFrameProcessor, ChunkDemuxerTest, Values(false)); | |
| 3349 INSTANTIATE_TEST_CASE_P(LegacyFrameProcessor, ChunkDemuxerTest, Values(true)); | |
| 3350 | |
| 3351 } // namespace media | 3319 } // namespace media |
| OLD | NEW |