| 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 "media/filters/chunk_demuxer.h" | 5 #include "media/filters/chunk_demuxer.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 // has been appended. This cluster starts with blocks that | 259 // has been appended. This cluster starts with blocks that |
| 260 // have timestamps consistent with the end times of the blocks | 260 // have timestamps consistent with the end times of the blocks |
| 261 // in kDefaultFirstCluster() so that these two clusters represent | 261 // in kDefaultFirstCluster() so that these two clusters represent |
| 262 // a continuous region. | 262 // a continuous region. |
| 263 std::unique_ptr<Cluster> kDefaultSecondCluster() { | 263 std::unique_ptr<Cluster> kDefaultSecondCluster() { |
| 264 return GenerateCluster(46, 66, 5); | 264 return GenerateCluster(46, 66, 5); |
| 265 } | 265 } |
| 266 | 266 |
| 267 ChunkDemuxerTest() | 267 ChunkDemuxerTest() |
| 268 : media_log_(new StrictMock<MockMediaLog>()), | 268 : media_log_(new StrictMock<MockMediaLog>()), |
| 269 append_window_end_for_next_append_(kInfiniteDuration()) { | 269 append_window_end_for_next_append_(kInfiniteDuration) { |
| 270 init_segment_received_cb_ = base::Bind( | 270 init_segment_received_cb_ = base::Bind( |
| 271 &ChunkDemuxerTest::InitSegmentReceived, base::Unretained(this)); | 271 &ChunkDemuxerTest::InitSegmentReceived, base::Unretained(this)); |
| 272 CreateNewDemuxer(); | 272 CreateNewDemuxer(); |
| 273 } | 273 } |
| 274 | 274 |
| 275 void CreateNewDemuxer() { | 275 void CreateNewDemuxer() { |
| 276 base::Closure open_cb = | 276 base::Closure open_cb = |
| 277 base::Bind(&ChunkDemuxerTest::DemuxerOpened, base::Unretained(this)); | 277 base::Bind(&ChunkDemuxerTest::DemuxerOpened, base::Unretained(this)); |
| 278 Demuxer::EncryptedMediaInitDataCB encrypted_media_init_data_cb = base::Bind( | 278 Demuxer::EncryptedMediaInitDataCB encrypted_media_init_data_cb = base::Bind( |
| 279 &ChunkDemuxerTest::OnEncryptedMediaInitData, base::Unretained(this)); | 279 &ChunkDemuxerTest::OnEncryptedMediaInitData, base::Unretained(this)); |
| (...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 785 ASSERT_FALSE(AppendData(garbage_cluster.get(), garbage_cluster_size)); | 785 ASSERT_FALSE(AppendData(garbage_cluster.get(), garbage_cluster_size)); |
| 786 } | 786 } |
| 787 | 787 |
| 788 void InitDoneCalled(PipelineStatus expected_status, | 788 void InitDoneCalled(PipelineStatus expected_status, |
| 789 PipelineStatus status) { | 789 PipelineStatus status) { |
| 790 EXPECT_EQ(status, expected_status); | 790 EXPECT_EQ(status, expected_status); |
| 791 } | 791 } |
| 792 | 792 |
| 793 PipelineStatusCB CreateInitDoneCB(const base::TimeDelta& expected_duration, | 793 PipelineStatusCB CreateInitDoneCB(const base::TimeDelta& expected_duration, |
| 794 PipelineStatus expected_status) { | 794 PipelineStatus expected_status) { |
| 795 if (expected_duration != kNoTimestamp()) | 795 if (expected_duration != kNoTimestamp) |
| 796 EXPECT_CALL(host_, SetDuration(expected_duration)); | 796 EXPECT_CALL(host_, SetDuration(expected_duration)); |
| 797 return CreateInitDoneCB(expected_status); | 797 return CreateInitDoneCB(expected_status); |
| 798 } | 798 } |
| 799 | 799 |
| 800 PipelineStatusCB CreateInitDoneCB(PipelineStatus expected_status) { | 800 PipelineStatusCB CreateInitDoneCB(PipelineStatus expected_status) { |
| 801 return base::Bind(&ChunkDemuxerTest::InitDoneCalled, | 801 return base::Bind(&ChunkDemuxerTest::InitDoneCalled, |
| 802 base::Unretained(this), | 802 base::Unretained(this), |
| 803 expected_status); | 803 expected_status); |
| 804 } | 804 } |
| 805 | 805 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 826 EXPECT_MEDIA_LOG(FoundStream("video")); | 826 EXPECT_MEDIA_LOG(FoundStream("video")); |
| 827 EXPECT_MEDIA_LOG(CodecName("video", "vp8")); | 827 EXPECT_MEDIA_LOG(CodecName("video", "vp8")); |
| 828 } | 828 } |
| 829 } | 829 } |
| 830 | 830 |
| 831 bool InitDemuxerWithEncryptionInfo( | 831 bool InitDemuxerWithEncryptionInfo( |
| 832 int stream_flags, bool is_audio_encrypted, bool is_video_encrypted) { | 832 int stream_flags, bool is_audio_encrypted, bool is_video_encrypted) { |
| 833 PipelineStatus expected_status = | 833 PipelineStatus expected_status = |
| 834 (stream_flags != 0) ? PIPELINE_OK : CHUNK_DEMUXER_ERROR_APPEND_FAILED; | 834 (stream_flags != 0) ? PIPELINE_OK : CHUNK_DEMUXER_ERROR_APPEND_FAILED; |
| 835 | 835 |
| 836 base::TimeDelta expected_duration = kNoTimestamp(); | 836 base::TimeDelta expected_duration = kNoTimestamp; |
| 837 if (expected_status == PIPELINE_OK) | 837 if (expected_status == PIPELINE_OK) |
| 838 expected_duration = kDefaultDuration(); | 838 expected_duration = kDefaultDuration(); |
| 839 | 839 |
| 840 EXPECT_CALL(*this, DemuxerOpened()); | 840 EXPECT_CALL(*this, DemuxerOpened()); |
| 841 | 841 |
| 842 if (is_audio_encrypted || is_video_encrypted) { | 842 if (is_audio_encrypted || is_video_encrypted) { |
| 843 DCHECK(!is_audio_encrypted || stream_flags & HAS_AUDIO); | 843 DCHECK(!is_audio_encrypted || stream_flags & HAS_AUDIO); |
| 844 DCHECK(!is_video_encrypted || stream_flags & HAS_VIDEO); | 844 DCHECK(!is_video_encrypted || stream_flags & HAS_VIDEO); |
| 845 | 845 |
| 846 int need_key_count = | 846 int need_key_count = |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1221 *status_out = status; | 1221 *status_out = status; |
| 1222 *buffer_out = buffer; | 1222 *buffer_out = buffer; |
| 1223 } | 1223 } |
| 1224 | 1224 |
| 1225 void ReadUntilNotOkOrEndOfStream(DemuxerStream::Type type, | 1225 void ReadUntilNotOkOrEndOfStream(DemuxerStream::Type type, |
| 1226 DemuxerStream::Status* status, | 1226 DemuxerStream::Status* status, |
| 1227 base::TimeDelta* last_timestamp) { | 1227 base::TimeDelta* last_timestamp) { |
| 1228 DemuxerStream* stream = demuxer_->GetStream(type); | 1228 DemuxerStream* stream = demuxer_->GetStream(type); |
| 1229 scoped_refptr<DecoderBuffer> buffer; | 1229 scoped_refptr<DecoderBuffer> buffer; |
| 1230 | 1230 |
| 1231 *last_timestamp = kNoTimestamp(); | 1231 *last_timestamp = kNoTimestamp; |
| 1232 do { | 1232 do { |
| 1233 stream->Read(base::Bind(&ChunkDemuxerTest::StoreStatusAndBuffer, | 1233 stream->Read(base::Bind(&ChunkDemuxerTest::StoreStatusAndBuffer, |
| 1234 base::Unretained(this), status, &buffer)); | 1234 base::Unretained(this), status, &buffer)); |
| 1235 base::RunLoop().RunUntilIdle(); | 1235 base::RunLoop().RunUntilIdle(); |
| 1236 if (*status == DemuxerStream::kOk && !buffer->end_of_stream()) | 1236 if (*status == DemuxerStream::kOk && !buffer->end_of_stream()) |
| 1237 *last_timestamp = buffer->timestamp(); | 1237 *last_timestamp = buffer->timestamp(); |
| 1238 } while (*status == DemuxerStream::kOk && !buffer->end_of_stream()); | 1238 } while (*status == DemuxerStream::kOk && !buffer->end_of_stream()); |
| 1239 } | 1239 } |
| 1240 | 1240 |
| 1241 void ExpectEndOfStream(DemuxerStream::Type type) { | 1241 void ExpectEndOfStream(DemuxerStream::Type type) { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1279 | 1279 |
| 1280 if (i > 0) | 1280 if (i > 0) |
| 1281 ss << " "; | 1281 ss << " "; |
| 1282 ss << buffer->timestamp().InMilliseconds(); | 1282 ss << buffer->timestamp().InMilliseconds(); |
| 1283 | 1283 |
| 1284 if (buffer->is_key_frame()) | 1284 if (buffer->is_key_frame()) |
| 1285 ss << "K"; | 1285 ss << "K"; |
| 1286 | 1286 |
| 1287 // Handle preroll buffers. | 1287 // Handle preroll buffers. |
| 1288 if (base::EndsWith(timestamps[i], "P", base::CompareCase::SENSITIVE)) { | 1288 if (base::EndsWith(timestamps[i], "P", base::CompareCase::SENSITIVE)) { |
| 1289 ASSERT_EQ(kInfiniteDuration(), buffer->discard_padding().first); | 1289 ASSERT_EQ(kInfiniteDuration, buffer->discard_padding().first); |
| 1290 ASSERT_EQ(base::TimeDelta(), buffer->discard_padding().second); | 1290 ASSERT_EQ(base::TimeDelta(), buffer->discard_padding().second); |
| 1291 ss << "P"; | 1291 ss << "P"; |
| 1292 } | 1292 } |
| 1293 } | 1293 } |
| 1294 EXPECT_EQ(expected, ss.str()); | 1294 EXPECT_EQ(expected, ss.str()); |
| 1295 } | 1295 } |
| 1296 | 1296 |
| 1297 MOCK_METHOD1(Checkpoint, void(int id)); | 1297 MOCK_METHOD1(Checkpoint, void(int id)); |
| 1298 | 1298 |
| 1299 struct BufferTimestamps { | 1299 struct BufferTimestamps { |
| (...skipping 958 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2258 {33, 3}, | 2258 {33, 3}, |
| 2259 {67, 6}, | 2259 {67, 6}, |
| 2260 {100, 9}, | 2260 {100, 9}, |
| 2261 {133, 12}, | 2261 {133, 12}, |
| 2262 {kSkip, kSkip}, | 2262 {kSkip, kSkip}, |
| 2263 }; | 2263 }; |
| 2264 | 2264 |
| 2265 ExpectInitMediaLogs(HAS_AUDIO | HAS_VIDEO); | 2265 ExpectInitMediaLogs(HAS_AUDIO | HAS_VIDEO); |
| 2266 EXPECT_MEDIA_LOG(WebMSimpleBlockDurationEstimated(2)).Times(7); | 2266 EXPECT_MEDIA_LOG(WebMSimpleBlockDurationEstimated(2)).Times(7); |
| 2267 ASSERT_TRUE(ParseWebMFile("bear-320x240-live.webm", buffer_timestamps, | 2267 ASSERT_TRUE(ParseWebMFile("bear-320x240-live.webm", buffer_timestamps, |
| 2268 kInfiniteDuration())); | 2268 kInfiniteDuration)); |
| 2269 | 2269 |
| 2270 DemuxerStream* audio = demuxer_->GetStream(DemuxerStream::AUDIO); | 2270 DemuxerStream* audio = demuxer_->GetStream(DemuxerStream::AUDIO); |
| 2271 EXPECT_EQ(DemuxerStream::LIVENESS_LIVE, audio->liveness()); | 2271 EXPECT_EQ(DemuxerStream::LIVENESS_LIVE, audio->liveness()); |
| 2272 DemuxerStream* video = demuxer_->GetStream(DemuxerStream::VIDEO); | 2272 DemuxerStream* video = demuxer_->GetStream(DemuxerStream::VIDEO); |
| 2273 EXPECT_EQ(DemuxerStream::LIVENESS_LIVE, video->liveness()); | 2273 EXPECT_EQ(DemuxerStream::LIVENESS_LIVE, video->liveness()); |
| 2274 EXPECT_EQ(212949, demuxer_->GetMemoryUsage()); | 2274 EXPECT_EQ(212949, demuxer_->GetMemoryUsage()); |
| 2275 } | 2275 } |
| 2276 | 2276 |
| 2277 TEST_F(ChunkDemuxerTest, WebMFile_AudioOnly) { | 2277 TEST_F(ChunkDemuxerTest, WebMFile_AudioOnly) { |
| 2278 struct BufferTimestamps buffer_timestamps[] = { | 2278 struct BufferTimestamps buffer_timestamps[] = { |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2384 | 2384 |
| 2385 base::RunLoop().RunUntilIdle(); | 2385 base::RunLoop().RunUntilIdle(); |
| 2386 | 2386 |
| 2387 EXPECT_TRUE(audio_read_done); | 2387 EXPECT_TRUE(audio_read_done); |
| 2388 EXPECT_TRUE(video_read_done); | 2388 EXPECT_TRUE(video_read_done); |
| 2389 } | 2389 } |
| 2390 | 2390 |
| 2391 TEST_F(ChunkDemuxerTest, ParseErrorDuringInit) { | 2391 TEST_F(ChunkDemuxerTest, ParseErrorDuringInit) { |
| 2392 EXPECT_CALL(*this, DemuxerOpened()); | 2392 EXPECT_CALL(*this, DemuxerOpened()); |
| 2393 demuxer_->Initialize( | 2393 demuxer_->Initialize( |
| 2394 &host_, | 2394 &host_, CreateInitDoneCB(kNoTimestamp, CHUNK_DEMUXER_ERROR_APPEND_FAILED), |
| 2395 CreateInitDoneCB(kNoTimestamp(), CHUNK_DEMUXER_ERROR_APPEND_FAILED), | |
| 2396 true); | 2395 true); |
| 2397 | 2396 |
| 2398 ASSERT_EQ(AddId(), ChunkDemuxer::kOk); | 2397 ASSERT_EQ(AddId(), ChunkDemuxer::kOk); |
| 2399 | 2398 |
| 2400 EXPECT_MEDIA_LOG(StreamParsingFailed()); | 2399 EXPECT_MEDIA_LOG(StreamParsingFailed()); |
| 2401 uint8_t tmp = 0; | 2400 uint8_t tmp = 0; |
| 2402 ASSERT_FALSE(demuxer_->AppendData( | 2401 ASSERT_FALSE(demuxer_->AppendData( |
| 2403 kSourceId, &tmp, 1, append_window_start_for_next_append_, | 2402 kSourceId, &tmp, 1, append_window_start_for_next_append_, |
| 2404 append_window_end_for_next_append_, ×tamp_offset_map_[kSourceId])); | 2403 append_window_end_for_next_append_, ×tamp_offset_map_[kSourceId])); |
| 2405 } | 2404 } |
| 2406 | 2405 |
| 2407 TEST_F(ChunkDemuxerTest, AVHeadersWithAudioOnlyType) { | 2406 TEST_F(ChunkDemuxerTest, AVHeadersWithAudioOnlyType) { |
| 2408 EXPECT_CALL(*this, DemuxerOpened()); | 2407 EXPECT_CALL(*this, DemuxerOpened()); |
| 2409 demuxer_->Initialize( | 2408 demuxer_->Initialize( |
| 2410 &host_, | 2409 &host_, CreateInitDoneCB(kNoTimestamp, CHUNK_DEMUXER_ERROR_APPEND_FAILED), |
| 2411 CreateInitDoneCB(kNoTimestamp(), CHUNK_DEMUXER_ERROR_APPEND_FAILED), | |
| 2412 true); | 2410 true); |
| 2413 | 2411 |
| 2414 std::vector<std::string> codecs(1); | 2412 std::vector<std::string> codecs(1); |
| 2415 codecs[0] = "vorbis"; | 2413 codecs[0] = "vorbis"; |
| 2416 ASSERT_EQ(demuxer_->AddId(kSourceId, "audio/webm", codecs), | 2414 ASSERT_EQ(demuxer_->AddId(kSourceId, "audio/webm", codecs), |
| 2417 ChunkDemuxer::kOk); | 2415 ChunkDemuxer::kOk); |
| 2418 demuxer_->SetTracksWatcher(kSourceId, | 2416 demuxer_->SetTracksWatcher(kSourceId, |
| 2419 base::Bind(&ChunkDemuxerTest::InitSegmentReceived, | 2417 base::Bind(&ChunkDemuxerTest::InitSegmentReceived, |
| 2420 base::Unretained(this))); | 2418 base::Unretained(this))); |
| 2421 | 2419 |
| 2422 // Video track is unexpected per mimetype. | 2420 // Video track is unexpected per mimetype. |
| 2423 EXPECT_MEDIA_LOG(InitSegmentMismatchesMimeType("a video", true)); | 2421 EXPECT_MEDIA_LOG(InitSegmentMismatchesMimeType("a video", true)); |
| 2424 EXPECT_MEDIA_LOG(StreamParsingFailed()); | 2422 EXPECT_MEDIA_LOG(StreamParsingFailed()); |
| 2425 ASSERT_FALSE(AppendInitSegment(HAS_AUDIO | HAS_VIDEO)); | 2423 ASSERT_FALSE(AppendInitSegment(HAS_AUDIO | HAS_VIDEO)); |
| 2426 } | 2424 } |
| 2427 | 2425 |
| 2428 TEST_F(ChunkDemuxerTest, AVHeadersWithVideoOnlyType) { | 2426 TEST_F(ChunkDemuxerTest, AVHeadersWithVideoOnlyType) { |
| 2429 EXPECT_CALL(*this, DemuxerOpened()); | 2427 EXPECT_CALL(*this, DemuxerOpened()); |
| 2430 demuxer_->Initialize( | 2428 demuxer_->Initialize( |
| 2431 &host_, | 2429 &host_, CreateInitDoneCB(kNoTimestamp, CHUNK_DEMUXER_ERROR_APPEND_FAILED), |
| 2432 CreateInitDoneCB(kNoTimestamp(), CHUNK_DEMUXER_ERROR_APPEND_FAILED), | |
| 2433 true); | 2430 true); |
| 2434 | 2431 |
| 2435 std::vector<std::string> codecs(1); | 2432 std::vector<std::string> codecs(1); |
| 2436 codecs[0] = "vp8"; | 2433 codecs[0] = "vp8"; |
| 2437 ASSERT_EQ(demuxer_->AddId(kSourceId, "video/webm", codecs), | 2434 ASSERT_EQ(demuxer_->AddId(kSourceId, "video/webm", codecs), |
| 2438 ChunkDemuxer::kOk); | 2435 ChunkDemuxer::kOk); |
| 2439 demuxer_->SetTracksWatcher(kSourceId, | 2436 demuxer_->SetTracksWatcher(kSourceId, |
| 2440 base::Bind(&ChunkDemuxerTest::InitSegmentReceived, | 2437 base::Bind(&ChunkDemuxerTest::InitSegmentReceived, |
| 2441 base::Unretained(this))); | 2438 base::Unretained(this))); |
| 2442 | 2439 |
| 2443 // Audio track is unexpected per mimetype. | 2440 // Audio track is unexpected per mimetype. |
| 2444 EXPECT_MEDIA_LOG(InitSegmentMismatchesMimeType("an audio", true)); | 2441 EXPECT_MEDIA_LOG(InitSegmentMismatchesMimeType("an audio", true)); |
| 2445 EXPECT_MEDIA_LOG(StreamParsingFailed()); | 2442 EXPECT_MEDIA_LOG(StreamParsingFailed()); |
| 2446 ASSERT_FALSE(AppendInitSegment(HAS_AUDIO | HAS_VIDEO)); | 2443 ASSERT_FALSE(AppendInitSegment(HAS_AUDIO | HAS_VIDEO)); |
| 2447 } | 2444 } |
| 2448 | 2445 |
| 2449 TEST_F(ChunkDemuxerTest, AudioOnlyHeaderWithAVType) { | 2446 TEST_F(ChunkDemuxerTest, AudioOnlyHeaderWithAVType) { |
| 2450 EXPECT_CALL(*this, DemuxerOpened()); | 2447 EXPECT_CALL(*this, DemuxerOpened()); |
| 2451 demuxer_->Initialize( | 2448 demuxer_->Initialize( |
| 2452 &host_, | 2449 &host_, CreateInitDoneCB(kNoTimestamp, CHUNK_DEMUXER_ERROR_APPEND_FAILED), |
| 2453 CreateInitDoneCB(kNoTimestamp(), CHUNK_DEMUXER_ERROR_APPEND_FAILED), | |
| 2454 true); | 2450 true); |
| 2455 | 2451 |
| 2456 std::vector<std::string> codecs(2); | 2452 std::vector<std::string> codecs(2); |
| 2457 codecs[0] = "vorbis"; | 2453 codecs[0] = "vorbis"; |
| 2458 codecs[1] = "vp8"; | 2454 codecs[1] = "vp8"; |
| 2459 ASSERT_EQ(demuxer_->AddId(kSourceId, "video/webm", codecs), | 2455 ASSERT_EQ(demuxer_->AddId(kSourceId, "video/webm", codecs), |
| 2460 ChunkDemuxer::kOk); | 2456 ChunkDemuxer::kOk); |
| 2461 demuxer_->SetTracksWatcher(kSourceId, | 2457 demuxer_->SetTracksWatcher(kSourceId, |
| 2462 base::Bind(&ChunkDemuxerTest::InitSegmentReceived, | 2458 base::Bind(&ChunkDemuxerTest::InitSegmentReceived, |
| 2463 base::Unretained(this))); | 2459 base::Unretained(this))); |
| 2464 | 2460 |
| 2465 // Video track is also expected per mimetype. | 2461 // Video track is also expected per mimetype. |
| 2466 EXPECT_MEDIA_LOG(InitSegmentMismatchesMimeType("a video", false)); | 2462 EXPECT_MEDIA_LOG(InitSegmentMismatchesMimeType("a video", false)); |
| 2467 EXPECT_MEDIA_LOG(StreamParsingFailed()); | 2463 EXPECT_MEDIA_LOG(StreamParsingFailed()); |
| 2468 ASSERT_FALSE(AppendInitSegment(HAS_AUDIO)); | 2464 ASSERT_FALSE(AppendInitSegment(HAS_AUDIO)); |
| 2469 } | 2465 } |
| 2470 | 2466 |
| 2471 TEST_F(ChunkDemuxerTest, VideoOnlyHeaderWithAVType) { | 2467 TEST_F(ChunkDemuxerTest, VideoOnlyHeaderWithAVType) { |
| 2472 EXPECT_CALL(*this, DemuxerOpened()); | 2468 EXPECT_CALL(*this, DemuxerOpened()); |
| 2473 demuxer_->Initialize( | 2469 demuxer_->Initialize( |
| 2474 &host_, | 2470 &host_, CreateInitDoneCB(kNoTimestamp, CHUNK_DEMUXER_ERROR_APPEND_FAILED), |
| 2475 CreateInitDoneCB(kNoTimestamp(), CHUNK_DEMUXER_ERROR_APPEND_FAILED), | |
| 2476 true); | 2471 true); |
| 2477 | 2472 |
| 2478 std::vector<std::string> codecs(2); | 2473 std::vector<std::string> codecs(2); |
| 2479 codecs[0] = "vorbis"; | 2474 codecs[0] = "vorbis"; |
| 2480 codecs[1] = "vp8"; | 2475 codecs[1] = "vp8"; |
| 2481 ASSERT_EQ(demuxer_->AddId(kSourceId, "video/webm", codecs), | 2476 ASSERT_EQ(demuxer_->AddId(kSourceId, "video/webm", codecs), |
| 2482 ChunkDemuxer::kOk); | 2477 ChunkDemuxer::kOk); |
| 2483 demuxer_->SetTracksWatcher(kSourceId, | 2478 demuxer_->SetTracksWatcher(kSourceId, |
| 2484 base::Bind(&ChunkDemuxerTest::InitSegmentReceived, | 2479 base::Bind(&ChunkDemuxerTest::InitSegmentReceived, |
| 2485 base::Unretained(this))); | 2480 base::Unretained(this))); |
| (...skipping 991 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3477 } | 3472 } |
| 3478 | 3473 |
| 3479 #if defined(USE_PROPRIETARY_CODECS) | 3474 #if defined(USE_PROPRIETARY_CODECS) |
| 3480 #if BUILDFLAG(ENABLE_MSE_MPEG2TS_STREAM_PARSER) | 3475 #if BUILDFLAG(ENABLE_MSE_MPEG2TS_STREAM_PARSER) |
| 3481 TEST_F(ChunkDemuxerTest, EmitBuffersDuringAbort) { | 3476 TEST_F(ChunkDemuxerTest, EmitBuffersDuringAbort) { |
| 3482 EXPECT_CALL(*this, DemuxerOpened()); | 3477 EXPECT_CALL(*this, DemuxerOpened()); |
| 3483 EXPECT_MEDIA_LOG(FoundStream("audio")); | 3478 EXPECT_MEDIA_LOG(FoundStream("audio")); |
| 3484 EXPECT_MEDIA_LOG(CodecName("audio", "aac")); | 3479 EXPECT_MEDIA_LOG(CodecName("audio", "aac")); |
| 3485 EXPECT_MEDIA_LOG(FoundStream("video")); | 3480 EXPECT_MEDIA_LOG(FoundStream("video")); |
| 3486 EXPECT_MEDIA_LOG(CodecName("video", "h264")); | 3481 EXPECT_MEDIA_LOG(CodecName("video", "h264")); |
| 3487 demuxer_->Initialize( | 3482 demuxer_->Initialize(&host_, CreateInitDoneCB(kInfiniteDuration, PIPELINE_OK), |
| 3488 &host_, CreateInitDoneCB(kInfiniteDuration(), PIPELINE_OK), true); | 3483 true); |
| 3489 EXPECT_EQ(ChunkDemuxer::kOk, AddIdForMp2tSource(kSourceId)); | 3484 EXPECT_EQ(ChunkDemuxer::kOk, AddIdForMp2tSource(kSourceId)); |
| 3490 | 3485 |
| 3491 // For info: | 3486 // For info: |
| 3492 // DTS/PTS derived using dvbsnoop -s ts -if bear-1280x720.ts -tssubdecode | 3487 // DTS/PTS derived using dvbsnoop -s ts -if bear-1280x720.ts -tssubdecode |
| 3493 // Video: first PES: | 3488 // Video: first PES: |
| 3494 // PTS: 126912 (0x0001efc0) [= 90 kHz-Timestamp: 0:00:01.4101] | 3489 // PTS: 126912 (0x0001efc0) [= 90 kHz-Timestamp: 0:00:01.4101] |
| 3495 // DTS: 123909 (0x0001e405) [= 90 kHz-Timestamp: 0:00:01.3767] | 3490 // DTS: 123909 (0x0001e405) [= 90 kHz-Timestamp: 0:00:01.3767] |
| 3496 // Audio: first PES: | 3491 // Audio: first PES: |
| 3497 // PTS: 126000 (0x0001ec30) [= 90 kHz-Timestamp: 0:00:01.4000] | 3492 // PTS: 126000 (0x0001ec30) [= 90 kHz-Timestamp: 0:00:01.4000] |
| 3498 // DTS: 123910 (0x0001e406) [= 90 kHz-Timestamp: 0:00:01.3767] | 3493 // DTS: 123910 (0x0001e406) [= 90 kHz-Timestamp: 0:00:01.3767] |
| (...skipping 26 matching lines...) Expand all Loading... |
| 3525 EXPECT_EQ(range_after_abort.start(0), range_before_abort.start(0)); | 3520 EXPECT_EQ(range_after_abort.start(0), range_before_abort.start(0)); |
| 3526 EXPECT_GT(range_after_abort.end(0), range_before_abort.end(0)); | 3521 EXPECT_GT(range_after_abort.end(0), range_before_abort.end(0)); |
| 3527 } | 3522 } |
| 3528 | 3523 |
| 3529 TEST_F(ChunkDemuxerTest, SeekCompleteDuringAbort) { | 3524 TEST_F(ChunkDemuxerTest, SeekCompleteDuringAbort) { |
| 3530 EXPECT_CALL(*this, DemuxerOpened()); | 3525 EXPECT_CALL(*this, DemuxerOpened()); |
| 3531 EXPECT_MEDIA_LOG(FoundStream("audio")); | 3526 EXPECT_MEDIA_LOG(FoundStream("audio")); |
| 3532 EXPECT_MEDIA_LOG(CodecName("audio", "aac")); | 3527 EXPECT_MEDIA_LOG(CodecName("audio", "aac")); |
| 3533 EXPECT_MEDIA_LOG(FoundStream("video")); | 3528 EXPECT_MEDIA_LOG(FoundStream("video")); |
| 3534 EXPECT_MEDIA_LOG(CodecName("video", "h264")); | 3529 EXPECT_MEDIA_LOG(CodecName("video", "h264")); |
| 3535 demuxer_->Initialize( | 3530 demuxer_->Initialize(&host_, CreateInitDoneCB(kInfiniteDuration, PIPELINE_OK), |
| 3536 &host_, CreateInitDoneCB(kInfiniteDuration(), PIPELINE_OK), true); | 3531 true); |
| 3537 EXPECT_EQ(ChunkDemuxer::kOk, AddIdForMp2tSource(kSourceId)); | 3532 EXPECT_EQ(ChunkDemuxer::kOk, AddIdForMp2tSource(kSourceId)); |
| 3538 | 3533 |
| 3539 // For info: | 3534 // For info: |
| 3540 // DTS/PTS derived using dvbsnoop -s ts -if bear-1280x720.ts -tssubdecode | 3535 // DTS/PTS derived using dvbsnoop -s ts -if bear-1280x720.ts -tssubdecode |
| 3541 // Video: first PES: | 3536 // Video: first PES: |
| 3542 // PTS: 126912 (0x0001efc0) [= 90 kHz-Timestamp: 0:00:01.4101] | 3537 // PTS: 126912 (0x0001efc0) [= 90 kHz-Timestamp: 0:00:01.4101] |
| 3543 // DTS: 123909 (0x0001e405) [= 90 kHz-Timestamp: 0:00:01.3767] | 3538 // DTS: 123909 (0x0001e405) [= 90 kHz-Timestamp: 0:00:01.3767] |
| 3544 // Audio: first PES: | 3539 // Audio: first PES: |
| 3545 // PTS: 126000 (0x0001ec30) [= 90 kHz-Timestamp: 0:00:01.4000] | 3540 // PTS: 126000 (0x0001ec30) [= 90 kHz-Timestamp: 0:00:01.4000] |
| 3546 // DTS: 123910 (0x0001e406) [= 90 kHz-Timestamp: 0:00:01.3767] | 3541 // DTS: 123910 (0x0001e406) [= 90 kHz-Timestamp: 0:00:01.3767] |
| (...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4315 EXPECT_CALL(host_, SetDuration( | 4310 EXPECT_CALL(host_, SetDuration( |
| 4316 base::TimeDelta::FromMilliseconds(160))); | 4311 base::TimeDelta::FromMilliseconds(160))); |
| 4317 AppendSingleStreamCluster(kSourceId, kAudioTrackNum, | 4312 AppendSingleStreamCluster(kSourceId, kAudioTrackNum, |
| 4318 "0K 20K 40K 60K 80K 100K 120K 140D20K"); | 4313 "0K 20K 40K 60K 80K 100K 120K 140D20K"); |
| 4319 | 4314 |
| 4320 CheckExpectedRanges("{ [0,160) }"); | 4315 CheckExpectedRanges("{ [0,160) }"); |
| 4321 CheckExpectedBuffers(audio_stream, "0K 20K 40K 60K 80K 100K 120K 140K"); | 4316 CheckExpectedBuffers(audio_stream, "0K 20K 40K 60K 80K 100K 120K 140K"); |
| 4322 | 4317 |
| 4323 demuxer_->Remove(kSourceId, | 4318 demuxer_->Remove(kSourceId, |
| 4324 base::TimeDelta::FromSecondsD(demuxer_->GetDuration()), | 4319 base::TimeDelta::FromSecondsD(demuxer_->GetDuration()), |
| 4325 kInfiniteDuration()); | 4320 kInfiniteDuration); |
| 4326 | 4321 |
| 4327 Seek(base::TimeDelta()); | 4322 Seek(base::TimeDelta()); |
| 4328 CheckExpectedRanges("{ [0,160) }"); | 4323 CheckExpectedRanges("{ [0,160) }"); |
| 4329 CheckExpectedBuffers(audio_stream, "0K 20K 40K 60K 80K 100K 120K 140K"); | 4324 CheckExpectedBuffers(audio_stream, "0K 20K 40K 60K 80K 100K 120K 140K"); |
| 4330 } | 4325 } |
| 4331 | 4326 |
| 4332 // Verifies that a Seek() will complete without text cues for | 4327 // Verifies that a Seek() will complete without text cues for |
| 4333 // the seek point and will return cues after the seek position | 4328 // the seek point and will return cues after the seek position |
| 4334 // when they are eventually appended. | 4329 // when they are eventually appended. |
| 4335 TEST_F(ChunkDemuxerTest, SeekCompletesWithoutTextCues) { | 4330 TEST_F(ChunkDemuxerTest, SeekCompletesWithoutTextCues) { |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4705 cluster->size() - video_start)); | 4700 cluster->size() - video_start)); |
| 4706 | 4701 |
| 4707 CheckExpectedRanges(DemuxerStream::AUDIO, "{ [30,90) }"); | 4702 CheckExpectedRanges(DemuxerStream::AUDIO, "{ [30,90) }"); |
| 4708 CheckExpectedRanges(DemuxerStream::VIDEO, "{ [0,91) }"); | 4703 CheckExpectedRanges(DemuxerStream::VIDEO, "{ [0,91) }"); |
| 4709 CheckExpectedRanges("{ [30,90) }"); | 4704 CheckExpectedRanges("{ [30,90) }"); |
| 4710 CheckExpectedBuffers(audio_stream, "30K 40K 50K 60K 70K 80K"); | 4705 CheckExpectedBuffers(audio_stream, "30K 40K 50K 60K 70K 80K"); |
| 4711 CheckExpectedBuffers(video_stream, "71K 81"); | 4706 CheckExpectedBuffers(video_stream, "71K 81"); |
| 4712 } | 4707 } |
| 4713 | 4708 |
| 4714 } // namespace media | 4709 } // namespace media |
| OLD | NEW |