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

Side by Side Diff: media/mp3/mp3_stream_parser_unittest.cc

Issue 23702007: Render inband text tracks in the media pipeline (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: fix compile errors 11/21 #6 Created 7 years 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/mp3/mp3_stream_parser.cc ('k') | media/mp4/mp4_stream_parser.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 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/text_track_config.h"
10 #include "media/base/video_decoder_config.h" 11 #include "media/base/video_decoder_config.h"
11 #include "media/mp3/mp3_stream_parser.h" 12 #include "media/mp3/mp3_stream_parser.h"
12 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
13 14
14 namespace media { 15 namespace media {
15 16
16 class MP3StreamParserTest : public testing::Test { 17 class MP3StreamParserTest : public testing::Test {
17 public: 18 public:
18 MP3StreamParserTest() {} 19 MP3StreamParserTest() {}
19 20
(...skipping 17 matching lines...) Expand all
37 } 38 }
38 return true; 39 return true;
39 } 40 }
40 41
41 void OnInitDone(bool success, base::TimeDelta duration) { 42 void OnInitDone(bool success, base::TimeDelta duration) {
42 DVLOG(1) << __FUNCTION__ << "(" << success << ", " 43 DVLOG(1) << __FUNCTION__ << "(" << success << ", "
43 << duration.InMilliseconds() << ")"; 44 << duration.InMilliseconds() << ")";
44 } 45 }
45 46
46 bool OnNewConfig(const AudioDecoderConfig& audio_config, 47 bool OnNewConfig(const AudioDecoderConfig& audio_config,
47 const VideoDecoderConfig& video_config) { 48 const VideoDecoderConfig& video_config,
49 const StreamParser::TextTrackConfigMap& text_config) {
48 DVLOG(1) << __FUNCTION__ << "(" << audio_config.IsValidConfig() << ", " 50 DVLOG(1) << __FUNCTION__ << "(" << audio_config.IsValidConfig() << ", "
49 << video_config.IsValidConfig() << ")"; 51 << video_config.IsValidConfig() << ")";
50 EXPECT_TRUE(audio_config.IsValidConfig()); 52 EXPECT_TRUE(audio_config.IsValidConfig());
51 EXPECT_FALSE(video_config.IsValidConfig()); 53 EXPECT_FALSE(video_config.IsValidConfig());
52 return true; 54 return true;
53 } 55 }
54 56
55 std::string BufferQueueToString(const StreamParser::BufferQueue& buffers) { 57 std::string BufferQueueToString(const StreamParser::BufferQueue& buffers) {
56 std::stringstream ss; 58 std::stringstream ss;
57 59
(...skipping 14 matching lines...) Expand all
72 const StreamParser::BufferQueue& video_buffers) { 74 const StreamParser::BufferQueue& video_buffers) {
73 EXPECT_FALSE(audio_buffers.empty()); 75 EXPECT_FALSE(audio_buffers.empty());
74 EXPECT_TRUE(video_buffers.empty()); 76 EXPECT_TRUE(video_buffers.empty());
75 77
76 std::string buffers_str = BufferQueueToString(audio_buffers); 78 std::string buffers_str = BufferQueueToString(audio_buffers);
77 DVLOG(1) << __FUNCTION__ << " : " << buffers_str; 79 DVLOG(1) << __FUNCTION__ << " : " << buffers_str;
78 results_stream_ << buffers_str; 80 results_stream_ << buffers_str;
79 return true; 81 return true;
80 } 82 }
81 83
82 bool OnNewTextBuffers(TextTrack* text_track,
83 const StreamParser::BufferQueue& buffers) {
84 return true;
85 }
86
87 void OnKeyNeeded(const std::string& type, 84 void OnKeyNeeded(const std::string& type,
88 const std::vector<uint8>& init_data) { 85 const std::vector<uint8>& init_data) {
89 DVLOG(1) << __FUNCTION__ << "(" << type << ", " << init_data.size() << ")"; 86 DVLOG(1) << __FUNCTION__ << "(" << type << ", " << init_data.size() << ")";
90 } 87 }
91 88
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() { 89 void OnNewSegment() {
99 DVLOG(1) << __FUNCTION__; 90 DVLOG(1) << __FUNCTION__;
100 results_stream_ << "NewSegment"; 91 results_stream_ << "NewSegment";
101 } 92 }
102 93
103 void OnEndOfSegment() { 94 void OnEndOfSegment() {
104 DVLOG(1) << __FUNCTION__; 95 DVLOG(1) << __FUNCTION__;
105 results_stream_ << "EndOfSegment"; 96 results_stream_ << "EndOfSegment";
106 } 97 }
107 98
108 void InitializeParser() { 99 void InitializeParser() {
109 parser_.Init( 100 parser_.Init(
110 base::Bind(&MP3StreamParserTest::OnInitDone, base::Unretained(this)), 101 base::Bind(&MP3StreamParserTest::OnInitDone, base::Unretained(this)),
111 base::Bind(&MP3StreamParserTest::OnNewConfig, base::Unretained(this)), 102 base::Bind(&MP3StreamParserTest::OnNewConfig, base::Unretained(this)),
112 base::Bind(&MP3StreamParserTest::OnNewBuffers, base::Unretained(this)), 103 base::Bind(&MP3StreamParserTest::OnNewBuffers, base::Unretained(this)),
113 base::Bind(&MP3StreamParserTest::OnNewTextBuffers, 104 StreamParser::NewTextBuffersCB(),
114 base::Unretained(this)),
115 base::Bind(&MP3StreamParserTest::OnKeyNeeded, base::Unretained(this)), 105 base::Bind(&MP3StreamParserTest::OnKeyNeeded, base::Unretained(this)),
116 base::Bind(&MP3StreamParserTest::OnAddTextTrack,
117 base::Unretained(this)),
118 base::Bind(&MP3StreamParserTest::OnNewSegment, base::Unretained(this)), 106 base::Bind(&MP3StreamParserTest::OnNewSegment, base::Unretained(this)),
119 base::Bind(&MP3StreamParserTest::OnEndOfSegment, 107 base::Bind(&MP3StreamParserTest::OnEndOfSegment,
120 base::Unretained(this)), 108 base::Unretained(this)),
121 LogCB()); 109 LogCB());
122 } 110 }
123 111
124 std::string ParseFile(const std::string& filename, int append_bytes) { 112 std::string ParseFile(const std::string& filename, int append_bytes) {
125 results_stream_.clear(); 113 results_stream_.clear();
126 InitializeParser(); 114 InitializeParser();
127 115
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 "EndOfSegment" 156 "EndOfSegment"
169 "NewSegment" 157 "NewSegment"
170 "{ 130K 156K 182K }" 158 "{ 130K 156K 182K }"
171 "{ 208K 235K 261K 287K }" 159 "{ 208K 235K 261K 287K }"
172 "{ 313K }" 160 "{ 313K }"
173 "EndOfSegment"; 161 "EndOfSegment";
174 EXPECT_EQ(expected, ParseFile("sfx.mp3", 512)); 162 EXPECT_EQ(expected, ParseFile("sfx.mp3", 512));
175 } 163 }
176 164
177 } // namespace media 165 } // namespace media
OLDNEW
« no previous file with comments | « media/mp3/mp3_stream_parser.cc ('k') | media/mp4/mp4_stream_parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698