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 3012 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3023 // Append more data and make sure that the blocks for |seek_time2| | 3023 // Append more data and make sure that the blocks for |seek_time2| |
3024 // don't get removed. | 3024 // don't get removed. |
3025 // | 3025 // |
3026 // NOTE: The current GC algorithm tries to preserve the GOP at the | 3026 // NOTE: The current GC algorithm tries to preserve the GOP at the |
3027 // current position as well as the last appended GOP. This is | 3027 // current position as well as the last appended GOP. This is |
3028 // why there are 2 ranges in the expectations. | 3028 // why there are 2 ranges in the expectations. |
3029 AppendSingleStreamCluster(kSourceId, kAudioTrackNum, 700, 5); | 3029 AppendSingleStreamCluster(kSourceId, kAudioTrackNum, 700, 5); |
3030 CheckExpectedRanges(kSourceId, "{ [500,592) [792,815) }"); | 3030 CheckExpectedRanges(kSourceId, "{ [500,592) [792,815) }"); |
3031 } | 3031 } |
3032 | 3032 |
3033 TEST_P(ChunkDemuxerTest, RemoveBeforeInitSegment) { | |
3034 EXPECT_CALL(*this, DemuxerOpened()); | |
3035 demuxer_->Initialize( | |
3036 &host_, CreateInitDoneCB(kNoTimestamp(), PIPELINE_OK), true); | |
3037 | |
3038 EXPECT_EQ(ChunkDemuxer::kOk, AddId(kSourceId, HAS_AUDIO | HAS_VIDEO)); | |
3039 | |
3040 demuxer_->Remove(kSourceId, base::TimeDelta::FromMilliseconds(0), | |
3041 base::TimeDelta::FromMilliseconds(1)); | |
3042 } | |
3043 | |
3044 TEST_P(ChunkDemuxerTest, AppendWindow_Video) { | 3033 TEST_P(ChunkDemuxerTest, AppendWindow_Video) { |
3045 ASSERT_TRUE(InitDemuxer(HAS_VIDEO)); | 3034 ASSERT_TRUE(InitDemuxer(HAS_VIDEO)); |
3046 DemuxerStream* stream = demuxer_->GetStream(DemuxerStream::VIDEO); | 3035 DemuxerStream* stream = demuxer_->GetStream(DemuxerStream::VIDEO); |
3047 | 3036 |
3048 // Set the append window to [50,280). | 3037 // Set the append window to [50,280). |
3049 append_window_start_for_next_append_ = base::TimeDelta::FromMilliseconds(50); | 3038 append_window_start_for_next_append_ = base::TimeDelta::FromMilliseconds(50); |
3050 append_window_end_for_next_append_ = base::TimeDelta::FromMilliseconds(280); | 3039 append_window_end_for_next_append_ = base::TimeDelta::FromMilliseconds(280); |
3051 | 3040 |
3052 // Append a cluster that starts before and ends after the append window. | 3041 // Append a cluster that starts before and ends after the append window. |
3053 AppendSingleStreamCluster(kSourceId, kVideoTrackNum, | 3042 AppendSingleStreamCluster(kSourceId, kVideoTrackNum, |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3262 AppendSingleStreamCluster(kSourceId, kVideoTrackNum, | 3251 AppendSingleStreamCluster(kSourceId, kVideoTrackNum, |
3263 "1K 31 61 91 121K 151 181"); | 3252 "1K 31 61 91 121K 151 181"); |
3264 AppendSingleStreamCluster(kSourceId, kTextTrackNum, "1K 101K 201K"); | 3253 AppendSingleStreamCluster(kSourceId, kTextTrackNum, "1K 101K 201K"); |
3265 | 3254 |
3266 Seek(base::TimeDelta()); | 3255 Seek(base::TimeDelta()); |
3267 CheckExpectedBuffers(audio_stream, "1 21 41 61 81 101 121 141"); | 3256 CheckExpectedBuffers(audio_stream, "1 21 41 61 81 101 121 141"); |
3268 CheckExpectedBuffers(video_stream, "1 31 61 91 121 151 181"); | 3257 CheckExpectedBuffers(video_stream, "1 31 61 91 121 151 181"); |
3269 CheckExpectedBuffers(text_stream, "1 101 201"); | 3258 CheckExpectedBuffers(text_stream, "1 101 201"); |
3270 } | 3259 } |
3271 | 3260 |
| 3261 TEST_P(ChunkDemuxerTest, Remove_StartAtDuration) { |
| 3262 ASSERT_TRUE(InitDemuxer(HAS_AUDIO)); |
| 3263 DemuxerStream* audio_stream = demuxer_->GetStream(DemuxerStream::AUDIO); |
| 3264 |
| 3265 // Set the duration to something small so that the append that |
| 3266 // follows updates the duration to reflect the end of the appended data. |
| 3267 EXPECT_CALL(host_, SetDuration( |
| 3268 base::TimeDelta::FromMilliseconds(1))); |
| 3269 demuxer_->SetDuration(0.001); |
| 3270 |
| 3271 EXPECT_CALL(host_, SetDuration( |
| 3272 base::TimeDelta::FromMilliseconds(160))); |
| 3273 AppendSingleStreamCluster(kSourceId, kAudioTrackNum, |
| 3274 "0K 20K 40K 60K 80K 100K 120K 140K"); |
| 3275 |
| 3276 CheckExpectedRanges(kSourceId, "{ [0,160) }"); |
| 3277 CheckExpectedBuffers(audio_stream, "0 20 40 60 80 100 120 140"); |
| 3278 |
| 3279 demuxer_->Remove(kSourceId, |
| 3280 base::TimeDelta::FromSecondsD(demuxer_->GetDuration()), |
| 3281 kInfiniteDuration()); |
| 3282 |
| 3283 Seek(base::TimeDelta()); |
| 3284 CheckExpectedRanges(kSourceId, "{ [0,160) }"); |
| 3285 CheckExpectedBuffers(audio_stream, "0 20 40 60 80 100 120 140"); |
| 3286 } |
| 3287 |
3272 // Verifies that a Seek() will complete without text cues for | 3288 // Verifies that a Seek() will complete without text cues for |
3273 // the seek point and will return cues after the seek position | 3289 // the seek point and will return cues after the seek position |
3274 // when they are eventually appended. | 3290 // when they are eventually appended. |
3275 TEST_P(ChunkDemuxerTest, SeekCompletesWithoutTextCues) { | 3291 TEST_P(ChunkDemuxerTest, SeekCompletesWithoutTextCues) { |
3276 DemuxerStream* text_stream = NULL; | 3292 DemuxerStream* text_stream = NULL; |
3277 EXPECT_CALL(host_, AddTextStream(_, _)) | 3293 EXPECT_CALL(host_, AddTextStream(_, _)) |
3278 .WillOnce(SaveArg<0>(&text_stream)); | 3294 .WillOnce(SaveArg<0>(&text_stream)); |
3279 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO | HAS_TEXT)); | 3295 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO | HAS_TEXT)); |
3280 | 3296 |
3281 DemuxerStream* audio_stream = demuxer_->GetStream(DemuxerStream::AUDIO); | 3297 DemuxerStream* audio_stream = demuxer_->GetStream(DemuxerStream::AUDIO); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3326 CheckExpectedBuffers(audio_stream, "160 180"); | 3342 CheckExpectedBuffers(audio_stream, "160 180"); |
3327 CheckExpectedBuffers(video_stream, "180 210"); | 3343 CheckExpectedBuffers(video_stream, "180 210"); |
3328 } | 3344 } |
3329 | 3345 |
3330 // Generate two sets of tests: one using FrameProcessor, and one using | 3346 // Generate two sets of tests: one using FrameProcessor, and one using |
3331 // LegacyFrameProcessor. | 3347 // LegacyFrameProcessor. |
3332 INSTANTIATE_TEST_CASE_P(NewFrameProcessor, ChunkDemuxerTest, Values(false)); | 3348 INSTANTIATE_TEST_CASE_P(NewFrameProcessor, ChunkDemuxerTest, Values(false)); |
3333 INSTANTIATE_TEST_CASE_P(LegacyFrameProcessor, ChunkDemuxerTest, Values(true)); | 3349 INSTANTIATE_TEST_CASE_P(LegacyFrameProcessor, ChunkDemuxerTest, Values(true)); |
3334 | 3350 |
3335 } // namespace media | 3351 } // namespace media |
OLD | NEW |