| 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 "media/formats/common/stream_parser_test_base.h" | 5 #include "media/formats/common/stream_parser_test_base.h" |
| 6 | 6 |
| 7 #include <memory> |
| 7 #include <utility> | 8 #include <utility> |
| 8 | 9 |
| 9 #include "base/bind.h" | 10 #include "base/bind.h" |
| 10 #include "media/base/media_track.h" | 11 #include "media/base/media_track.h" |
| 11 #include "media/base/media_tracks.h" | 12 #include "media/base/media_tracks.h" |
| 12 #include "media/base/test_data_util.h" | 13 #include "media/base/test_data_util.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 14 | 15 |
| 15 namespace media { | 16 namespace media { |
| 16 | 17 |
| 17 static std::string BufferQueueToString( | 18 static std::string BufferQueueToString( |
| 18 const StreamParser::BufferQueue& buffers) { | 19 const StreamParser::BufferQueue& buffers) { |
| 19 std::stringstream ss; | 20 std::stringstream ss; |
| 20 | 21 |
| 21 ss << "{"; | 22 ss << "{"; |
| 22 for (StreamParser::BufferQueue::const_iterator itr = buffers.begin(); | 23 for (StreamParser::BufferQueue::const_iterator itr = buffers.begin(); |
| 23 itr != buffers.end(); | 24 itr != buffers.end(); |
| 24 ++itr) { | 25 ++itr) { |
| 25 ss << " " << (*itr)->timestamp().InMilliseconds(); | 26 ss << " " << (*itr)->timestamp().InMilliseconds(); |
| 26 if ((*itr)->is_key_frame()) | 27 if ((*itr)->is_key_frame()) |
| 27 ss << "K"; | 28 ss << "K"; |
| 28 } | 29 } |
| 29 ss << " }"; | 30 ss << " }"; |
| 30 | 31 |
| 31 return ss.str(); | 32 return ss.str(); |
| 32 } | 33 } |
| 33 | 34 |
| 34 StreamParserTestBase::StreamParserTestBase( | 35 StreamParserTestBase::StreamParserTestBase( |
| 35 scoped_ptr<StreamParser> stream_parser) | 36 std::unique_ptr<StreamParser> stream_parser) |
| 36 : parser_(std::move(stream_parser)) { | 37 : parser_(std::move(stream_parser)) { |
| 37 parser_->Init( | 38 parser_->Init( |
| 38 base::Bind(&StreamParserTestBase::OnInitDone, base::Unretained(this)), | 39 base::Bind(&StreamParserTestBase::OnInitDone, base::Unretained(this)), |
| 39 base::Bind(&StreamParserTestBase::OnNewConfig, base::Unretained(this)), | 40 base::Bind(&StreamParserTestBase::OnNewConfig, base::Unretained(this)), |
| 40 base::Bind(&StreamParserTestBase::OnNewBuffers, base::Unretained(this)), | 41 base::Bind(&StreamParserTestBase::OnNewBuffers, base::Unretained(this)), |
| 41 true, | 42 true, |
| 42 base::Bind(&StreamParserTestBase::OnKeyNeeded, base::Unretained(this)), | 43 base::Bind(&StreamParserTestBase::OnKeyNeeded, base::Unretained(this)), |
| 43 base::Bind(&StreamParserTestBase::OnNewSegment, base::Unretained(this)), | 44 base::Bind(&StreamParserTestBase::OnNewSegment, base::Unretained(this)), |
| 44 base::Bind(&StreamParserTestBase::OnEndOfSegment, base::Unretained(this)), | 45 base::Bind(&StreamParserTestBase::OnEndOfSegment, base::Unretained(this)), |
| 45 new MediaLog()); | 46 new MediaLog()); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 } | 79 } |
| 79 | 80 |
| 80 void StreamParserTestBase::OnInitDone( | 81 void StreamParserTestBase::OnInitDone( |
| 81 const StreamParser::InitParameters& params) { | 82 const StreamParser::InitParameters& params) { |
| 82 EXPECT_TRUE(params.auto_update_timestamp_offset); | 83 EXPECT_TRUE(params.auto_update_timestamp_offset); |
| 83 DVLOG(1) << __FUNCTION__ << "(" << params.duration.InMilliseconds() << ", " | 84 DVLOG(1) << __FUNCTION__ << "(" << params.duration.InMilliseconds() << ", " |
| 84 << params.auto_update_timestamp_offset << ")"; | 85 << params.auto_update_timestamp_offset << ")"; |
| 85 } | 86 } |
| 86 | 87 |
| 87 bool StreamParserTestBase::OnNewConfig( | 88 bool StreamParserTestBase::OnNewConfig( |
| 88 scoped_ptr<MediaTracks> tracks, | 89 std::unique_ptr<MediaTracks> tracks, |
| 89 const StreamParser::TextTrackConfigMap& text_config) { | 90 const StreamParser::TextTrackConfigMap& text_config) { |
| 90 DVLOG(1) << __FUNCTION__ << " media tracks count=" << tracks->tracks().size(); | 91 DVLOG(1) << __FUNCTION__ << " media tracks count=" << tracks->tracks().size(); |
| 91 EXPECT_EQ(tracks->tracks().size(), 1u); | 92 EXPECT_EQ(tracks->tracks().size(), 1u); |
| 92 EXPECT_TRUE(tracks->getFirstAudioConfig().IsValidConfig()); | 93 EXPECT_TRUE(tracks->getFirstAudioConfig().IsValidConfig()); |
| 93 EXPECT_FALSE(tracks->getFirstVideoConfig().IsValidConfig()); | 94 EXPECT_FALSE(tracks->getFirstVideoConfig().IsValidConfig()); |
| 94 last_audio_config_ = tracks->getFirstAudioConfig(); | 95 last_audio_config_ = tracks->getFirstAudioConfig(); |
| 95 return true; | 96 return true; |
| 96 } | 97 } |
| 97 | 98 |
| 98 bool StreamParserTestBase::OnNewBuffers( | 99 bool StreamParserTestBase::OnNewBuffers( |
| (...skipping 23 matching lines...) Expand all Loading... |
| 122 DVLOG(1) << __FUNCTION__; | 123 DVLOG(1) << __FUNCTION__; |
| 123 results_stream_ << "NewSegment"; | 124 results_stream_ << "NewSegment"; |
| 124 } | 125 } |
| 125 | 126 |
| 126 void StreamParserTestBase::OnEndOfSegment() { | 127 void StreamParserTestBase::OnEndOfSegment() { |
| 127 DVLOG(1) << __FUNCTION__; | 128 DVLOG(1) << __FUNCTION__; |
| 128 results_stream_ << "EndOfSegment"; | 129 results_stream_ << "EndOfSegment"; |
| 129 } | 130 } |
| 130 | 131 |
| 131 } // namespace media | 132 } // namespace media |
| OLD | NEW |