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/source_buffer_stream.h" | 5 #include "media/filters/source_buffer_stream.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 4023 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4034 | 4034 |
4035 // If the overlapped buffer at timestamp 10 is removed, the adjusted duration | 4035 // If the overlapped buffer at timestamp 10 is removed, the adjusted duration |
4036 // should remain adjusted. | 4036 // should remain adjusted. |
4037 RemoveInMs(10, 20, 25); | 4037 RemoveInMs(10, 20, 25); |
4038 CheckExpectedRangesByTimestamp("{ [0,10) }"); | 4038 CheckExpectedRangesByTimestamp("{ [0,10) }"); |
4039 Seek(0); | 4039 Seek(0); |
4040 CheckExpectedBuffers("0K 5D5E"); | 4040 CheckExpectedBuffers("0K 5D5E"); |
4041 CheckNoNextBuffer(); | 4041 CheckNoNextBuffer(); |
4042 } | 4042 } |
4043 | 4043 |
| 4044 TEST_F(SourceBufferStreamTest, LeadingNonKeyframes_Kept) { |
| 4045 // Append a media segment that begins with a keyframe. |
| 4046 NewSegmentAppend("0K 10D10"); |
| 4047 |
| 4048 // Append another (continuous) media segment that begins with non-keyframes. |
| 4049 NewSegmentAppend("20 30 40K 50 60D10"); |
| 4050 |
| 4051 CheckExpectedRangesByTimestamp("{ [0,70) }"); |
| 4052 Seek(0); |
| 4053 CheckExpectedBuffers("0K 10D10 20 30 40K 50 60D10"); |
| 4054 CheckNoNextBuffer(); |
| 4055 } |
| 4056 |
| 4057 TEST_F(SourceBufferStreamTest, LeadingNonKeyframes_Dropped) { |
| 4058 // Append a media segment that has some initial non-keyframes. |
| 4059 NewSegmentAppend("0 10 20 30K 40 50 60 70D10K"); |
| 4060 |
| 4061 CheckExpectedRangesByTimestamp("{ [30,80) }"); |
| 4062 SeekToTimestamp(base::TimeDelta::FromMilliseconds(30)); |
| 4063 CheckExpectedBuffers("30K 40 50 60 70K"); |
| 4064 CheckNoNextBuffer(); |
| 4065 } |
| 4066 |
| 4067 TEST_F(SourceBufferStreamTest, |
| 4068 NonKeyframesDirectlyFollowingRemovedRange_Dropped) { |
| 4069 // Append a media segment containing decode dependencies for subsequent |
| 4070 // append. |
| 4071 NewSegmentAppend("0K 10 20 30 40D10K"); |
| 4072 CheckExpectedRangesByTimestamp("{ [0,50) }"); |
| 4073 |
| 4074 // Remove the decode dependency that subsequent append will depend upon. |
| 4075 RemoveInMs(40, 41, 50); |
| 4076 CheckExpectedRangesByTimestamp("{ [0,40) }"); |
| 4077 |
| 4078 // Append more media, leading with non-keyframes that supposedly might have |
| 4079 // depended upon the now-removed keyframe from time 40ms. |
| 4080 AppendBuffers("50 60 70K 80D10"); |
| 4081 CheckExpectedRangesByTimestamp("{ [0,40) [70,90) }"); |
| 4082 Seek(0); |
| 4083 CheckExpectedBuffers("0K 10 20 30D10"); |
| 4084 CheckNoNextBuffer(); |
| 4085 SeekToTimestamp(base::TimeDelta::FromMilliseconds(70)); |
| 4086 CheckExpectedBuffers("70K 80D10"); |
| 4087 CheckNoNextBuffer(); |
| 4088 } |
| 4089 |
4044 // TODO(vrk): Add unit tests where keyframes are unaligned between streams. | 4090 // TODO(vrk): Add unit tests where keyframes are unaligned between streams. |
4045 // (crbug.com/133557) | 4091 // (crbug.com/133557) |
4046 | 4092 |
4047 // TODO(vrk): Add unit tests with end of stream being called at interesting | 4093 // TODO(vrk): Add unit tests with end of stream being called at interesting |
4048 // times. | 4094 // times. |
4049 | 4095 |
4050 } // namespace media | 4096 } // namespace media |
OLD | NEW |