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

Side by Side Diff: media/mp2t/mp2t_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: modified ffmpeg demuxer unittest Created 7 years, 1 month 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
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 <algorithm> 5 #include <algorithm>
6 #include <string> 6 #include <string>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/time/time.h" 12 #include "base/time/time.h"
13 #include "media/base/audio_decoder_config.h" 13 #include "media/base/audio_decoder_config.h"
14 #include "media/base/decoder_buffer.h" 14 #include "media/base/decoder_buffer.h"
15 #include "media/base/stream_parser_buffer.h" 15 #include "media/base/stream_parser_buffer.h"
16 #include "media/base/test_data_util.h" 16 #include "media/base/test_data_util.h"
17 #include "media/base/text_track_config.h"
17 #include "media/base/video_decoder_config.h" 18 #include "media/base/video_decoder_config.h"
18 #include "media/mp2t/mp2t_stream_parser.h" 19 #include "media/mp2t/mp2t_stream_parser.h"
19 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
20 21
21 namespace media { 22 namespace media {
22 namespace mp2t { 23 namespace mp2t {
23 24
24 class Mp2tStreamParserTest : public testing::Test { 25 class Mp2tStreamParserTest : public testing::Test {
25 public: 26 public:
26 Mp2tStreamParserTest() 27 Mp2tStreamParserTest()
(...skipping 26 matching lines...) Expand all
53 start += append_size; 54 start += append_size;
54 } 55 }
55 return true; 56 return true;
56 } 57 }
57 58
58 void OnInit(bool init_ok, base::TimeDelta duration) { 59 void OnInit(bool init_ok, base::TimeDelta duration) {
59 DVLOG(1) << "OnInit: ok=" << init_ok 60 DVLOG(1) << "OnInit: ok=" << init_ok
60 << ", dur=" << duration.InMilliseconds(); 61 << ", dur=" << duration.InMilliseconds();
61 } 62 }
62 63
63 bool OnNewConfig(const AudioDecoderConfig& ac, const VideoDecoderConfig& vc) { 64 bool OnNewConfig(const AudioDecoderConfig& ac,
65 const VideoDecoderConfig& vc,
66 const TextTrackConfigMap& tc) {
64 DVLOG(1) << "OnNewConfig: audio=" << ac.IsValidConfig() 67 DVLOG(1) << "OnNewConfig: audio=" << ac.IsValidConfig()
65 << ", video=" << vc.IsValidConfig(); 68 << ", video=" << vc.IsValidConfig();
66 return true; 69 return true;
67 } 70 }
68 71
69 72
70 void DumpBuffers(const std::string& label, 73 void DumpBuffers(const std::string& label,
71 const StreamParser::BufferQueue& buffers) { 74 const StreamParser::BufferQueue& buffers) {
72 DVLOG(2) << "DumpBuffers: " << label << " size " << buffers.size(); 75 DVLOG(2) << "DumpBuffers: " << label << " size " << buffers.size();
73 for (StreamParser::BufferQueue::const_iterator buf = buffers.begin(); 76 for (StreamParser::BufferQueue::const_iterator buf = buffers.begin();
(...skipping 20 matching lines...) Expand all
94 StreamParser::BufferQueue::const_iterator it2 = ++it1; 97 StreamParser::BufferQueue::const_iterator it2 = ++it1;
95 for ( ; it2 != video_buffers.end(); ++it1, ++it2) { 98 for ( ; it2 != video_buffers.end(); ++it1, ++it2) {
96 if ((*it2)->GetDecodeTimestamp() < (*it1)->GetDecodeTimestamp()) 99 if ((*it2)->GetDecodeTimestamp() < (*it1)->GetDecodeTimestamp())
97 return false; 100 return false;
98 } 101 }
99 } 102 }
100 103
101 return true; 104 return true;
102 } 105 }
103 106
104 bool OnNewTextBuffers(TextTrack* text_track, 107 bool OnNewTextBuffers(int text_track,
acolwell GONE FROM CHROMIUM 2013/10/29 21:14:19 nit: Remove this since you are removing the refere
Matthew Heaney (Chromium) 2013/11/05 04:52:40 Done.
105 const StreamParser::BufferQueue& buffers) { 108 const StreamParser::BufferQueue& buffers) {
106 return true; 109 return true;
107 } 110 }
108 111
109 void OnKeyNeeded(const std::string& type, 112 void OnKeyNeeded(const std::string& type,
110 const std::vector<uint8>& init_data) { 113 const std::vector<uint8>& init_data) {
111 DVLOG(1) << "OnKeyNeeded: " << init_data.size(); 114 DVLOG(1) << "OnKeyNeeded: " << init_data.size();
112 } 115 }
113 116
114 scoped_ptr<TextTrack> OnAddTextTrack(
115 TextKind kind,
116 const std::string& label,
117 const std::string& language) {
118 return scoped_ptr<TextTrack>();
119 }
120
121 void OnNewSegment() { 117 void OnNewSegment() {
122 DVLOG(1) << "OnNewSegment"; 118 DVLOG(1) << "OnNewSegment";
123 } 119 }
124 120
125 void OnEndOfSegment() { 121 void OnEndOfSegment() {
126 DVLOG(1) << "OnEndOfSegment()"; 122 DVLOG(1) << "OnEndOfSegment()";
127 } 123 }
128 124
129 void InitializeParser() { 125 void InitializeParser() {
130 parser_->Init( 126 parser_->Init(
131 base::Bind(&Mp2tStreamParserTest::OnInit, 127 base::Bind(&Mp2tStreamParserTest::OnInit,
132 base::Unretained(this)), 128 base::Unretained(this)),
133 base::Bind(&Mp2tStreamParserTest::OnNewConfig, 129 base::Bind(&Mp2tStreamParserTest::OnNewConfig,
134 base::Unretained(this)), 130 base::Unretained(this)),
135 base::Bind(&Mp2tStreamParserTest::OnNewBuffers, 131 base::Bind(&Mp2tStreamParserTest::OnNewBuffers,
136 base::Unretained(this)), 132 base::Unretained(this)),
137 base::Bind(&Mp2tStreamParserTest::OnNewTextBuffers, 133 StreamParser::NewTextBuffersCB(),
138 base::Unretained(this)),
139 base::Bind(&Mp2tStreamParserTest::OnKeyNeeded, 134 base::Bind(&Mp2tStreamParserTest::OnKeyNeeded,
140 base::Unretained(this)), 135 base::Unretained(this)),
141 base::Bind(&Mp2tStreamParserTest::OnAddTextTrack,
142 base::Unretained(this)),
143 base::Bind(&Mp2tStreamParserTest::OnNewSegment, 136 base::Bind(&Mp2tStreamParserTest::OnNewSegment,
144 base::Unretained(this)), 137 base::Unretained(this)),
145 base::Bind(&Mp2tStreamParserTest::OnEndOfSegment, 138 base::Bind(&Mp2tStreamParserTest::OnEndOfSegment,
146 base::Unretained(this)), 139 base::Unretained(this)),
147 LogCB()); 140 LogCB());
148 } 141 }
149 142
150 bool ParseMpeg2TsFile(const std::string& filename, int append_bytes) { 143 bool ParseMpeg2TsFile(const std::string& filename, int append_bytes) {
151 InitializeParser(); 144 InitializeParser();
152 145
(...skipping 27 matching lines...) Expand all
180 // (close to 2^33 / 90000) which results in timestamps wrap around 173 // (close to 2^33 / 90000) which results in timestamps wrap around
181 // in the Mpeg2 TS stream. 174 // in the Mpeg2 TS stream.
182 ParseMpeg2TsFile("bear-1280x720_ptswraparound.ts", 512); 175 ParseMpeg2TsFile("bear-1280x720_ptswraparound.ts", 512);
183 EXPECT_EQ(video_frame_count_, 81); 176 EXPECT_EQ(video_frame_count_, 81);
184 EXPECT_GE(video_min_dts_, base::TimeDelta::FromSeconds(95443 - 10)); 177 EXPECT_GE(video_min_dts_, base::TimeDelta::FromSeconds(95443 - 10));
185 EXPECT_LE(video_max_dts_, base::TimeDelta::FromSeconds(95443 + 10)); 178 EXPECT_LE(video_max_dts_, base::TimeDelta::FromSeconds(95443 + 10));
186 } 179 }
187 180
188 } // namespace mp2t 181 } // namespace mp2t
189 } // namespace media 182 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698