OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <map> | 5 #include <map> |
6 #include <string> | 6 #include <string> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 buffer_timestamps.push_back(buffer_timestamps[0]); | 121 buffer_timestamps.push_back(buffer_timestamps[0]); |
122 CHECK_EQ(2u, buffer_timestamps.size()); | 122 CHECK_EQ(2u, buffer_timestamps.size()); |
123 | 123 |
124 double time_in_ms, decode_time_in_ms; | 124 double time_in_ms, decode_time_in_ms; |
125 CHECK(base::StringToDouble(buffer_timestamps[0], &time_in_ms)); | 125 CHECK(base::StringToDouble(buffer_timestamps[0], &time_in_ms)); |
126 CHECK(base::StringToDouble(buffer_timestamps[1], &decode_time_in_ms)); | 126 CHECK(base::StringToDouble(buffer_timestamps[1], &decode_time_in_ms)); |
127 | 127 |
128 // Create buffer. Encode the original time_in_ms as the buffer's data to | 128 // Create buffer. Encode the original time_in_ms as the buffer's data to |
129 // enable later verification of possible buffer relocation in presentation | 129 // enable later verification of possible buffer relocation in presentation |
130 // timeline due to coded frame processing. | 130 // timeline due to coded frame processing. |
131 const uint8* timestamp_as_data = reinterpret_cast<uint8*>(&time_in_ms); | 131 const uint8_t* timestamp_as_data = |
| 132 reinterpret_cast<uint8_t*>(&time_in_ms); |
132 scoped_refptr<StreamParserBuffer> buffer = | 133 scoped_refptr<StreamParserBuffer> buffer = |
133 StreamParserBuffer::CopyFrom(timestamp_as_data, sizeof(time_in_ms), | 134 StreamParserBuffer::CopyFrom(timestamp_as_data, sizeof(time_in_ms), |
134 is_keyframe, type, track_id); | 135 is_keyframe, type, track_id); |
135 base::TimeDelta timestamp = base::TimeDelta::FromSecondsD( | 136 base::TimeDelta timestamp = base::TimeDelta::FromSecondsD( |
136 time_in_ms / base::Time::kMillisecondsPerSecond); | 137 time_in_ms / base::Time::kMillisecondsPerSecond); |
137 buffer->set_timestamp(timestamp); | 138 buffer->set_timestamp(timestamp); |
138 if (time_in_ms != decode_time_in_ms) { | 139 if (time_in_ms != decode_time_in_ms) { |
139 DecodeTimestamp decode_timestamp = DecodeTimestamp::FromSecondsD( | 140 DecodeTimestamp decode_timestamp = DecodeTimestamp::FromSecondsD( |
140 decode_time_in_ms / base::Time::kMillisecondsPerSecond); | 141 decode_time_in_ms / base::Time::kMillisecondsPerSecond); |
141 buffer->SetDecodeTimestamp(decode_timestamp); | 142 buffer->SetDecodeTimestamp(decode_timestamp); |
(...skipping 16 matching lines...) Expand all Loading... |
158 } | 159 } |
159 | 160 |
160 void CheckExpectedRangesByTimestamp(ChunkDemuxerStream* stream, | 161 void CheckExpectedRangesByTimestamp(ChunkDemuxerStream* stream, |
161 const std::string& expected) { | 162 const std::string& expected) { |
162 // Note, DemuxerStream::TEXT streams return [0,duration (==infinity here)) | 163 // Note, DemuxerStream::TEXT streams return [0,duration (==infinity here)) |
163 Ranges<base::TimeDelta> r = stream->GetBufferedRanges(kInfiniteDuration()); | 164 Ranges<base::TimeDelta> r = stream->GetBufferedRanges(kInfiniteDuration()); |
164 | 165 |
165 std::stringstream ss; | 166 std::stringstream ss; |
166 ss << "{ "; | 167 ss << "{ "; |
167 for (size_t i = 0; i < r.size(); ++i) { | 168 for (size_t i = 0; i < r.size(); ++i) { |
168 int64 start = r.start(i).InMilliseconds(); | 169 int64_t start = r.start(i).InMilliseconds(); |
169 int64 end = r.end(i).InMilliseconds(); | 170 int64_t end = r.end(i).InMilliseconds(); |
170 ss << "[" << start << "," << end << ") "; | 171 ss << "[" << start << "," << end << ") "; |
171 } | 172 } |
172 ss << "}"; | 173 ss << "}"; |
173 EXPECT_EQ(expected, ss.str()); | 174 EXPECT_EQ(expected, ss.str()); |
174 } | 175 } |
175 | 176 |
176 void CheckReadStalls(ChunkDemuxerStream* stream) { | 177 void CheckReadStalls(ChunkDemuxerStream* stream) { |
177 int loop_count = 0; | 178 int loop_count = 0; |
178 | 179 |
179 do { | 180 do { |
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
752 EXPECT_EQ(frame_duration_ * -9, timestamp_offset_); | 753 EXPECT_EQ(frame_duration_ * -9, timestamp_offset_); |
753 EXPECT_FALSE(new_media_segment_); | 754 EXPECT_FALSE(new_media_segment_); |
754 CheckExpectedRangesByTimestamp(audio_.get(), "{ [0,20) }"); | 755 CheckExpectedRangesByTimestamp(audio_.get(), "{ [0,20) }"); |
755 CheckReadsThenReadStalls(audio_.get(), "0 10:100"); | 756 CheckReadsThenReadStalls(audio_.get(), "0 10:100"); |
756 } | 757 } |
757 | 758 |
758 INSTANTIATE_TEST_CASE_P(SequenceMode, FrameProcessorTest, Values(true)); | 759 INSTANTIATE_TEST_CASE_P(SequenceMode, FrameProcessorTest, Values(true)); |
759 INSTANTIATE_TEST_CASE_P(SegmentsMode, FrameProcessorTest, Values(false)); | 760 INSTANTIATE_TEST_CASE_P(SegmentsMode, FrameProcessorTest, Values(false)); |
760 | 761 |
761 } // namespace media | 762 } // namespace media |
OLD | NEW |