| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "media/base/audio_decoder_config.h" | 6 #include "media/base/audio_decoder_config.h" |
| 7 #include "media/base/decoder_buffer.h" | 7 #include "media/base/decoder_buffer.h" |
| 8 #include "media/base/stream_parser_buffer.h" | 8 #include "media/base/stream_parser_buffer.h" |
| 9 #include "media/base/test_data_util.h" | 9 #include "media/base/test_data_util.h" |
| 10 #include "media/base/video_decoder_config.h" | 10 #include "media/base/video_decoder_config.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 } | 37 } |
| 38 return true; | 38 return true; |
| 39 } | 39 } |
| 40 | 40 |
| 41 void OnInitDone(bool success, base::TimeDelta duration) { | 41 void OnInitDone(bool success, base::TimeDelta duration) { |
| 42 DVLOG(1) << __FUNCTION__ << "(" << success << ", " | 42 DVLOG(1) << __FUNCTION__ << "(" << success << ", " |
| 43 << duration.InMilliseconds() << ")"; | 43 << duration.InMilliseconds() << ")"; |
| 44 } | 44 } |
| 45 | 45 |
| 46 bool OnNewConfig(const AudioDecoderConfig& audio_config, | 46 bool OnNewConfig(const AudioDecoderConfig& audio_config, |
| 47 const VideoDecoderConfig& video_config) { | 47 const VideoDecoderConfig& video_config, |
| 48 const TextTrackConfigMap& text_config) { |
| 48 DVLOG(1) << __FUNCTION__ << "(" << audio_config.IsValidConfig() << ", " | 49 DVLOG(1) << __FUNCTION__ << "(" << audio_config.IsValidConfig() << ", " |
| 49 << video_config.IsValidConfig() << ")"; | 50 << video_config.IsValidConfig() << ")"; |
| 50 EXPECT_TRUE(audio_config.IsValidConfig()); | 51 EXPECT_TRUE(audio_config.IsValidConfig()); |
| 51 EXPECT_FALSE(video_config.IsValidConfig()); | 52 EXPECT_FALSE(video_config.IsValidConfig()); |
| 52 return true; | 53 return true; |
| 53 } | 54 } |
| 54 | 55 |
| 55 std::string BufferQueueToString(const StreamParser::BufferQueue& buffers) { | 56 std::string BufferQueueToString(const StreamParser::BufferQueue& buffers) { |
| 56 std::stringstream ss; | 57 std::stringstream ss; |
| 57 | 58 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 72 const StreamParser::BufferQueue& video_buffers) { | 73 const StreamParser::BufferQueue& video_buffers) { |
| 73 EXPECT_FALSE(audio_buffers.empty()); | 74 EXPECT_FALSE(audio_buffers.empty()); |
| 74 EXPECT_TRUE(video_buffers.empty()); | 75 EXPECT_TRUE(video_buffers.empty()); |
| 75 | 76 |
| 76 std::string buffers_str = BufferQueueToString(audio_buffers); | 77 std::string buffers_str = BufferQueueToString(audio_buffers); |
| 77 DVLOG(1) << __FUNCTION__ << " : " << buffers_str; | 78 DVLOG(1) << __FUNCTION__ << " : " << buffers_str; |
| 78 results_stream_ << buffers_str; | 79 results_stream_ << buffers_str; |
| 79 return true; | 80 return true; |
| 80 } | 81 } |
| 81 | 82 |
| 82 bool OnNewTextBuffers(TextTrack* text_track, | 83 bool OnNewTextBuffers(int text_track, |
| 83 const StreamParser::BufferQueue& buffers) { | 84 const StreamParser::BufferQueue& buffers) { |
| 84 return true; | 85 return true; |
| 85 } | 86 } |
| 86 | 87 |
| 87 void OnKeyNeeded(const std::string& type, | 88 void OnKeyNeeded(const std::string& type, |
| 88 const std::vector<uint8>& init_data) { | 89 const std::vector<uint8>& init_data) { |
| 89 DVLOG(1) << __FUNCTION__ << "(" << type << ", " << init_data.size() << ")"; | 90 DVLOG(1) << __FUNCTION__ << "(" << type << ", " << init_data.size() << ")"; |
| 90 } | 91 } |
| 91 | 92 |
| 92 scoped_ptr<TextTrack> OnAddTextTrack(TextKind kind, | |
| 93 const std::string& label, | |
| 94 const std::string& language) { | |
| 95 return scoped_ptr<TextTrack>(); | |
| 96 } | |
| 97 | |
| 98 void OnNewSegment() { | 93 void OnNewSegment() { |
| 99 DVLOG(1) << __FUNCTION__; | 94 DVLOG(1) << __FUNCTION__; |
| 100 results_stream_ << "NewSegment"; | 95 results_stream_ << "NewSegment"; |
| 101 } | 96 } |
| 102 | 97 |
| 103 void OnEndOfSegment() { | 98 void OnEndOfSegment() { |
| 104 DVLOG(1) << __FUNCTION__; | 99 DVLOG(1) << __FUNCTION__; |
| 105 results_stream_ << "EndOfSegment"; | 100 results_stream_ << "EndOfSegment"; |
| 106 } | 101 } |
| 107 | 102 |
| 108 void InitializeParser() { | 103 void InitializeParser() { |
| 109 parser_.Init( | 104 parser_.Init( |
| 110 base::Bind(&MP3StreamParserTest::OnInitDone, base::Unretained(this)), | 105 base::Bind(&MP3StreamParserTest::OnInitDone, base::Unretained(this)), |
| 111 base::Bind(&MP3StreamParserTest::OnNewConfig, base::Unretained(this)), | 106 base::Bind(&MP3StreamParserTest::OnNewConfig, base::Unretained(this)), |
| 112 base::Bind(&MP3StreamParserTest::OnNewBuffers, base::Unretained(this)), | 107 base::Bind(&MP3StreamParserTest::OnNewBuffers, base::Unretained(this)), |
| 113 base::Bind(&MP3StreamParserTest::OnNewTextBuffers, | 108 base::Bind(&MP3StreamParserTest::OnNewTextBuffers, |
| 114 base::Unretained(this)), | 109 base::Unretained(this)), |
| 115 base::Bind(&MP3StreamParserTest::OnKeyNeeded, base::Unretained(this)), | 110 base::Bind(&MP3StreamParserTest::OnKeyNeeded, base::Unretained(this)), |
| 116 base::Bind(&MP3StreamParserTest::OnAddTextTrack, | 111 true, |
| 117 base::Unretained(this)), | |
| 118 base::Bind(&MP3StreamParserTest::OnNewSegment, base::Unretained(this)), | 112 base::Bind(&MP3StreamParserTest::OnNewSegment, base::Unretained(this)), |
| 119 base::Bind(&MP3StreamParserTest::OnEndOfSegment, | 113 base::Bind(&MP3StreamParserTest::OnEndOfSegment, |
| 120 base::Unretained(this)), | 114 base::Unretained(this)), |
| 121 LogCB()); | 115 LogCB()); |
| 122 } | 116 } |
| 123 | 117 |
| 124 std::string ParseFile(const std::string& filename, int append_bytes) { | 118 std::string ParseFile(const std::string& filename, int append_bytes) { |
| 125 results_stream_.clear(); | 119 results_stream_.clear(); |
| 126 InitializeParser(); | 120 InitializeParser(); |
| 127 | 121 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 "EndOfSegment" | 162 "EndOfSegment" |
| 169 "NewSegment" | 163 "NewSegment" |
| 170 "{ 130K 156K 182K }" | 164 "{ 130K 156K 182K }" |
| 171 "{ 208K 235K 261K 287K }" | 165 "{ 208K 235K 261K 287K }" |
| 172 "{ 313K }" | 166 "{ 313K }" |
| 173 "EndOfSegment"; | 167 "EndOfSegment"; |
| 174 EXPECT_EQ(expected, ParseFile("sfx.mp3", 512)); | 168 EXPECT_EQ(expected, ParseFile("sfx.mp3", 512)); |
| 175 } | 169 } |
| 176 | 170 |
| 177 } // namespace media | 171 } // namespace media |
| OLD | NEW |