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 <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
| 15 #include "base/run_loop.h" |
15 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
16 #include "base/strings/string_split.h" | 17 #include "base/strings/string_split.h" |
17 #include "base/strings/string_util.h" | 18 #include "base/strings/string_util.h" |
18 #include "base/time/time.h" | 19 #include "base/time/time.h" |
19 #include "media/base/media_log.h" | 20 #include "media/base/media_log.h" |
20 #include "media/base/media_util.h" | 21 #include "media/base/media_util.h" |
21 #include "media/base/mock_filters.h" | 22 #include "media/base/mock_filters.h" |
22 #include "media/base/test_helpers.h" | 23 #include "media/base/test_helpers.h" |
23 #include "media/base/timestamp_constants.h" | 24 #include "media/base/timestamp_constants.h" |
24 #include "media/filters/chunk_demuxer.h" | 25 #include "media/filters/chunk_demuxer.h" |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 EXPECT_EQ(expected, ss.str()); | 175 EXPECT_EQ(expected, ss.str()); |
175 } | 176 } |
176 | 177 |
177 void CheckReadStalls(ChunkDemuxerStream* stream) { | 178 void CheckReadStalls(ChunkDemuxerStream* stream) { |
178 int loop_count = 0; | 179 int loop_count = 0; |
179 | 180 |
180 do { | 181 do { |
181 read_callback_called_ = false; | 182 read_callback_called_ = false; |
182 stream->Read(base::Bind(&FrameProcessorTest::StoreStatusAndBuffer, | 183 stream->Read(base::Bind(&FrameProcessorTest::StoreStatusAndBuffer, |
183 base::Unretained(this))); | 184 base::Unretained(this))); |
184 message_loop_.RunUntilIdle(); | 185 base::RunLoop().RunUntilIdle(); |
185 } while (++loop_count < 2 && read_callback_called_ && | 186 } while (++loop_count < 2 && read_callback_called_ && |
186 last_read_status_ == DemuxerStream::kAborted); | 187 last_read_status_ == DemuxerStream::kAborted); |
187 | 188 |
188 ASSERT_FALSE(read_callback_called_ && | 189 ASSERT_FALSE(read_callback_called_ && |
189 last_read_status_ == DemuxerStream::kAborted) | 190 last_read_status_ == DemuxerStream::kAborted) |
190 << "2 kAborted reads in a row. Giving up."; | 191 << "2 kAborted reads in a row. Giving up."; |
191 EXPECT_FALSE(read_callback_called_); | 192 EXPECT_FALSE(read_callback_called_); |
192 } | 193 } |
193 | 194 |
194 // Format of |expected| is a space-delimited sequence of | 195 // Format of |expected| is a space-delimited sequence of |
195 // timestamp_in_ms:original_timestamp_in_ms | 196 // timestamp_in_ms:original_timestamp_in_ms |
196 // original_timestamp_in_ms (and the colon) must be omitted if it is the same | 197 // original_timestamp_in_ms (and the colon) must be omitted if it is the same |
197 // as timestamp_in_ms. | 198 // as timestamp_in_ms. |
198 void CheckReadsThenReadStalls(ChunkDemuxerStream* stream, | 199 void CheckReadsThenReadStalls(ChunkDemuxerStream* stream, |
199 const std::string& expected) { | 200 const std::string& expected) { |
200 std::vector<std::string> timestamps = base::SplitString( | 201 std::vector<std::string> timestamps = base::SplitString( |
201 expected, " ", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); | 202 expected, " ", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
202 std::stringstream ss; | 203 std::stringstream ss; |
203 for (size_t i = 0; i < timestamps.size(); ++i) { | 204 for (size_t i = 0; i < timestamps.size(); ++i) { |
204 int loop_count = 0; | 205 int loop_count = 0; |
205 | 206 |
206 do { | 207 do { |
207 read_callback_called_ = false; | 208 read_callback_called_ = false; |
208 stream->Read(base::Bind(&FrameProcessorTest::StoreStatusAndBuffer, | 209 stream->Read(base::Bind(&FrameProcessorTest::StoreStatusAndBuffer, |
209 base::Unretained(this))); | 210 base::Unretained(this))); |
210 message_loop_.RunUntilIdle(); | 211 base::RunLoop().RunUntilIdle(); |
211 EXPECT_TRUE(read_callback_called_); | 212 EXPECT_TRUE(read_callback_called_); |
212 } while (++loop_count < 2 && | 213 } while (++loop_count < 2 && |
213 last_read_status_ == DemuxerStream::kAborted); | 214 last_read_status_ == DemuxerStream::kAborted); |
214 | 215 |
215 ASSERT_FALSE(last_read_status_ == DemuxerStream::kAborted) | 216 ASSERT_FALSE(last_read_status_ == DemuxerStream::kAborted) |
216 << "2 kAborted reads in a row. Giving up."; | 217 << "2 kAborted reads in a row. Giving up."; |
217 EXPECT_EQ(DemuxerStream::kOk, last_read_status_); | 218 EXPECT_EQ(DemuxerStream::kOk, last_read_status_); |
218 EXPECT_FALSE(last_read_buffer_->end_of_stream()); | 219 EXPECT_FALSE(last_read_buffer_->end_of_stream()); |
219 | 220 |
220 if (i > 0) | 221 if (i > 0) |
(...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
887 StreamParserBuffer* last_read_parser_buffer = | 888 StreamParserBuffer* last_read_parser_buffer = |
888 static_cast<StreamParserBuffer*>(last_read_buffer_.get()); | 889 static_cast<StreamParserBuffer*>(last_read_buffer_.get()); |
889 ASSERT_EQ(base::TimeDelta::FromMilliseconds(0), | 890 ASSERT_EQ(base::TimeDelta::FromMilliseconds(0), |
890 last_read_parser_buffer->preroll_buffer()->duration()); | 891 last_read_parser_buffer->preroll_buffer()->duration()); |
891 } | 892 } |
892 | 893 |
893 INSTANTIATE_TEST_CASE_P(SequenceMode, FrameProcessorTest, Values(true)); | 894 INSTANTIATE_TEST_CASE_P(SequenceMode, FrameProcessorTest, Values(true)); |
894 INSTANTIATE_TEST_CASE_P(SegmentsMode, FrameProcessorTest, Values(false)); | 895 INSTANTIATE_TEST_CASE_P(SegmentsMode, FrameProcessorTest, Values(false)); |
895 | 896 |
896 } // namespace media | 897 } // namespace media |
OLD | NEW |