Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(514)

Side by Side Diff: media/filters/frame_processor_unittest.cc

Issue 2254093002: Return buffers from StreamParsers in a single unified map (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Restored calling GetBuffers after each Parse in WebM test Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/filters/frame_processor.cc ('k') | media/filters/media_source_state.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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>
(...skipping 15 matching lines...) Expand all
26 #include "media/filters/frame_processor.h" 26 #include "media/filters/frame_processor.h"
27 #include "testing/gtest/include/gtest/gtest.h" 27 #include "testing/gtest/include/gtest/gtest.h"
28 28
29 using ::testing::InSequence; 29 using ::testing::InSequence;
30 using ::testing::StrictMock; 30 using ::testing::StrictMock;
31 using ::testing::Values; 31 using ::testing::Values;
32 32
33 namespace media { 33 namespace media {
34 34
35 typedef StreamParser::BufferQueue BufferQueue; 35 typedef StreamParser::BufferQueue BufferQueue;
36 typedef StreamParser::TextBufferQueueMap TextBufferQueueMap;
37 typedef StreamParser::TrackId TrackId; 36 typedef StreamParser::TrackId TrackId;
38 37
39 // Used for setting expectations on callbacks. Using a StrictMock also lets us 38 // Used for setting expectations on callbacks. Using a StrictMock also lets us
40 // test for missing or extra callbacks. 39 // test for missing or extra callbacks.
41 class FrameProcessorTestCallbackHelper { 40 class FrameProcessorTestCallbackHelper {
42 public: 41 public:
43 FrameProcessorTestCallbackHelper() {} 42 FrameProcessorTestCallbackHelper() {}
44 virtual ~FrameProcessorTestCallbackHelper() {} 43 virtual ~FrameProcessorTestCallbackHelper() {}
45 44
46 MOCK_METHOD1(PossibleDurationIncrease, void(base::TimeDelta new_duration)); 45 MOCK_METHOD1(PossibleDurationIncrease, void(base::TimeDelta new_duration));
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 } 144 }
146 145
147 buffer->set_duration(frame_duration_); 146 buffer->set_duration(frame_duration_);
148 buffers.push_back(buffer); 147 buffers.push_back(buffer);
149 } 148 }
150 return buffers; 149 return buffers;
151 } 150 }
152 151
153 void ProcessFrames(const std::string& audio_timestamps, 152 void ProcessFrames(const std::string& audio_timestamps,
154 const std::string& video_timestamps) { 153 const std::string& video_timestamps) {
154 StreamParser::BufferQueueMap buffer_queue_map;
155 const auto& audio_buffers =
156 StringToBufferQueue(audio_timestamps, audio_id_, DemuxerStream::AUDIO);
157 if (!audio_buffers.empty())
158 buffer_queue_map.insert(std::make_pair(audio_id_, audio_buffers));
159 const auto& video_buffers =
160 StringToBufferQueue(video_timestamps, video_id_, DemuxerStream::VIDEO);
161 if (!video_buffers.empty())
162 buffer_queue_map.insert(std::make_pair(video_id_, video_buffers));
155 ASSERT_TRUE(frame_processor_->ProcessFrames( 163 ASSERT_TRUE(frame_processor_->ProcessFrames(
156 StringToBufferQueue(audio_timestamps, audio_id_, DemuxerStream::AUDIO), 164 buffer_queue_map, append_window_start_, append_window_end_,
157 StringToBufferQueue(video_timestamps, video_id_, DemuxerStream::VIDEO),
158 empty_text_buffers_, append_window_start_, append_window_end_,
159 &timestamp_offset_)); 165 &timestamp_offset_));
160 } 166 }
161 167
162 void CheckExpectedRangesByTimestamp(ChunkDemuxerStream* stream, 168 void CheckExpectedRangesByTimestamp(ChunkDemuxerStream* stream,
163 const std::string& expected) { 169 const std::string& expected) {
164 // Note, DemuxerStream::TEXT streams return [0,duration (==infinity here)) 170 // Note, DemuxerStream::TEXT streams return [0,duration (==infinity here))
165 Ranges<base::TimeDelta> r = stream->GetBufferedRanges(kInfiniteDuration); 171 Ranges<base::TimeDelta> r = stream->GetBufferedRanges(kInfiniteDuration);
166 172
167 std::stringstream ss; 173 std::stringstream ss;
168 ss << "{ "; 174 ss << "{ ";
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 std::unique_ptr<FrameProcessor> frame_processor_; 269 std::unique_ptr<FrameProcessor> frame_processor_;
264 base::TimeDelta append_window_start_; 270 base::TimeDelta append_window_start_;
265 base::TimeDelta append_window_end_; 271 base::TimeDelta append_window_end_;
266 base::TimeDelta timestamp_offset_; 272 base::TimeDelta timestamp_offset_;
267 base::TimeDelta frame_duration_; 273 base::TimeDelta frame_duration_;
268 std::unique_ptr<ChunkDemuxerStream> audio_; 274 std::unique_ptr<ChunkDemuxerStream> audio_;
269 std::unique_ptr<ChunkDemuxerStream> video_; 275 std::unique_ptr<ChunkDemuxerStream> video_;
270 const TrackId audio_id_; 276 const TrackId audio_id_;
271 const TrackId video_id_; 277 const TrackId video_id_;
272 const BufferQueue empty_queue_; 278 const BufferQueue empty_queue_;
273 const TextBufferQueueMap empty_text_buffers_;
274 279
275 // StoreStatusAndBuffer's most recent result. 280 // StoreStatusAndBuffer's most recent result.
276 DemuxerStream::Status last_read_status_; 281 DemuxerStream::Status last_read_status_;
277 scoped_refptr<DecoderBuffer> last_read_buffer_; 282 scoped_refptr<DecoderBuffer> last_read_buffer_;
278 bool read_callback_called_; 283 bool read_callback_called_;
279 284
280 private: 285 private:
281 void StoreStatusAndBuffer(DemuxerStream::Status status, 286 void StoreStatusAndBuffer(DemuxerStream::Status status,
282 const scoped_refptr<DecoderBuffer>& buffer) { 287 const scoped_refptr<DecoderBuffer>& buffer) {
283 if (status == DemuxerStream::kOk && buffer.get()) { 288 if (status == DemuxerStream::kOk && buffer.get()) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 } 326 }
322 } 327 }
323 328
324 DISALLOW_COPY_AND_ASSIGN(FrameProcessorTest); 329 DISALLOW_COPY_AND_ASSIGN(FrameProcessorTest);
325 }; 330 };
326 331
327 TEST_F(FrameProcessorTest, WrongTypeInAppendedBuffer) { 332 TEST_F(FrameProcessorTest, WrongTypeInAppendedBuffer) {
328 AddTestTracks(HAS_AUDIO); 333 AddTestTracks(HAS_AUDIO);
329 EXPECT_FALSE(in_coded_frame_group()); 334 EXPECT_FALSE(in_coded_frame_group());
330 335
331 ASSERT_FALSE(frame_processor_->ProcessFrames( 336 StreamParser::BufferQueueMap buffer_queue_map;
332 StringToBufferQueue("0K", audio_id_, DemuxerStream::VIDEO), empty_queue_, 337 const auto& audio_buffers =
333 empty_text_buffers_, append_window_start_, append_window_end_, 338 StringToBufferQueue("0K", audio_id_, DemuxerStream::VIDEO);
334 &timestamp_offset_)); 339 buffer_queue_map.insert(std::make_pair(audio_id_, audio_buffers));
340 ASSERT_FALSE(
341 frame_processor_->ProcessFrames(buffer_queue_map, append_window_start_,
342 append_window_end_, &timestamp_offset_));
335 EXPECT_FALSE(in_coded_frame_group()); 343 EXPECT_FALSE(in_coded_frame_group());
336 EXPECT_EQ(base::TimeDelta(), timestamp_offset_); 344 EXPECT_EQ(base::TimeDelta(), timestamp_offset_);
337 CheckExpectedRangesByTimestamp(audio_.get(), "{ }"); 345 CheckExpectedRangesByTimestamp(audio_.get(), "{ }");
338 CheckReadStalls(audio_.get()); 346 CheckReadStalls(audio_.get());
339 } 347 }
340 348
341 TEST_F(FrameProcessorTest, NonMonotonicallyIncreasingTimestampInOneCall) { 349 TEST_F(FrameProcessorTest, NonMonotonicallyIncreasingTimestampInOneCall) {
342 AddTestTracks(HAS_AUDIO); 350 AddTestTracks(HAS_AUDIO);
343 351
344 ASSERT_FALSE(frame_processor_->ProcessFrames( 352 StreamParser::BufferQueueMap buffer_queue_map;
345 StringToBufferQueue("10K 0K", audio_id_, DemuxerStream::AUDIO), 353 const auto& audio_buffers =
346 empty_queue_, empty_text_buffers_, append_window_start_, 354 StringToBufferQueue("10K 0K", audio_id_, DemuxerStream::AUDIO);
347 append_window_end_, &timestamp_offset_)); 355 buffer_queue_map.insert(std::make_pair(audio_id_, audio_buffers));
356 ASSERT_FALSE(
357 frame_processor_->ProcessFrames(buffer_queue_map, append_window_start_,
358 append_window_end_, &timestamp_offset_));
348 EXPECT_FALSE(in_coded_frame_group()); 359 EXPECT_FALSE(in_coded_frame_group());
349 EXPECT_EQ(base::TimeDelta(), timestamp_offset_); 360 EXPECT_EQ(base::TimeDelta(), timestamp_offset_);
350 CheckExpectedRangesByTimestamp(audio_.get(), "{ }"); 361 CheckExpectedRangesByTimestamp(audio_.get(), "{ }");
351 CheckReadStalls(audio_.get()); 362 CheckReadStalls(audio_.get());
352 } 363 }
353 364
354 TEST_P(FrameProcessorTest, AudioOnly_SingleFrame) { 365 TEST_P(FrameProcessorTest, AudioOnly_SingleFrame) {
355 // Tests A: P(A) -> (a) 366 // Tests A: P(A) -> (a)
356 InSequence s; 367 InSequence s;
357 AddTestTracks(HAS_AUDIO); 368 AddTestTracks(HAS_AUDIO);
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 StreamParserBuffer* last_read_parser_buffer = 899 StreamParserBuffer* last_read_parser_buffer =
889 static_cast<StreamParserBuffer*>(last_read_buffer_.get()); 900 static_cast<StreamParserBuffer*>(last_read_buffer_.get());
890 ASSERT_EQ(base::TimeDelta::FromMilliseconds(0), 901 ASSERT_EQ(base::TimeDelta::FromMilliseconds(0),
891 last_read_parser_buffer->preroll_buffer()->duration()); 902 last_read_parser_buffer->preroll_buffer()->duration());
892 } 903 }
893 904
894 INSTANTIATE_TEST_CASE_P(SequenceMode, FrameProcessorTest, Values(true)); 905 INSTANTIATE_TEST_CASE_P(SequenceMode, FrameProcessorTest, Values(true));
895 INSTANTIATE_TEST_CASE_P(SegmentsMode, FrameProcessorTest, Values(false)); 906 INSTANTIATE_TEST_CASE_P(SegmentsMode, FrameProcessorTest, Values(false));
896 907
897 } // namespace media 908 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/frame_processor.cc ('k') | media/filters/media_source_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698