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

Side by Side Diff: media/mp4/mp4_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, 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
« no previous file with comments | « media/mp4/mp4_stream_parser.cc ('k') | media/webm/webm_cluster_parser.cc » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/mp4/es_descriptor.h" 19 #include "media/mp4/es_descriptor.h"
19 #include "media/mp4/mp4_stream_parser.h" 20 #include "media/mp4/mp4_stream_parser.h"
20 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
21 22
22 using base::TimeDelta; 23 using base::TimeDelta;
23 24
24 namespace media { 25 namespace media {
25 namespace mp4 { 26 namespace mp4 {
26 27
(...skipping 28 matching lines...) Expand all
55 start += append_size; 56 start += append_size;
56 } 57 }
57 return true; 58 return true;
58 } 59 }
59 60
60 void InitF(bool init_ok, base::TimeDelta duration) { 61 void InitF(bool init_ok, base::TimeDelta duration) {
61 DVLOG(1) << "InitF: ok=" << init_ok 62 DVLOG(1) << "InitF: ok=" << init_ok
62 << ", dur=" << duration.InMilliseconds(); 63 << ", dur=" << duration.InMilliseconds();
63 } 64 }
64 65
65 bool NewConfigF(const AudioDecoderConfig& ac, const VideoDecoderConfig& vc) { 66 bool NewConfigF(const AudioDecoderConfig& ac,
67 const VideoDecoderConfig& vc,
68 const StreamParser::TextTrackConfigMap& tc) {
66 DVLOG(1) << "NewConfigF: audio=" << ac.IsValidConfig() 69 DVLOG(1) << "NewConfigF: audio=" << ac.IsValidConfig()
67 << ", video=" << vc.IsValidConfig(); 70 << ", video=" << vc.IsValidConfig();
68 configs_received_ = true; 71 configs_received_ = true;
69 return true; 72 return true;
70 } 73 }
71 74
72 75
73 void DumpBuffers(const std::string& label, 76 void DumpBuffers(const std::string& label,
74 const StreamParser::BufferQueue& buffers) { 77 const StreamParser::BufferQueue& buffers) {
75 DVLOG(2) << "DumpBuffers: " << label << " size " << buffers.size(); 78 DVLOG(2) << "DumpBuffers: " << label << " size " << buffers.size();
76 for (StreamParser::BufferQueue::const_iterator buf = buffers.begin(); 79 for (StreamParser::BufferQueue::const_iterator buf = buffers.begin();
77 buf != buffers.end(); buf++) { 80 buf != buffers.end(); buf++) {
78 DVLOG(3) << " n=" << buf - buffers.begin() 81 DVLOG(3) << " n=" << buf - buffers.begin()
79 << ", size=" << (*buf)->data_size() 82 << ", size=" << (*buf)->data_size()
80 << ", dur=" << (*buf)->duration().InMilliseconds(); 83 << ", dur=" << (*buf)->duration().InMilliseconds();
81 } 84 }
82 } 85 }
83 86
84 bool NewBuffersF(const StreamParser::BufferQueue& audio_buffers, 87 bool NewBuffersF(const StreamParser::BufferQueue& audio_buffers,
85 const StreamParser::BufferQueue& video_buffers) { 88 const StreamParser::BufferQueue& video_buffers) {
86 DumpBuffers("audio_buffers", audio_buffers); 89 DumpBuffers("audio_buffers", audio_buffers);
87 DumpBuffers("video_buffers", video_buffers); 90 DumpBuffers("video_buffers", video_buffers);
88 return true; 91 return true;
89 } 92 }
90 93
91 bool NewTextBuffersF(TextTrack* text_track,
92 const StreamParser::BufferQueue& buffers) {
93 return true;
94 }
95
96 void KeyNeededF(const std::string& type, 94 void KeyNeededF(const std::string& type,
97 const std::vector<uint8>& init_data) { 95 const std::vector<uint8>& init_data) {
98 DVLOG(1) << "KeyNeededF: " << init_data.size(); 96 DVLOG(1) << "KeyNeededF: " << init_data.size();
99 EXPECT_EQ(kMp4InitDataType, type); 97 EXPECT_EQ(kMp4InitDataType, type);
100 EXPECT_FALSE(init_data.empty()); 98 EXPECT_FALSE(init_data.empty());
101 } 99 }
102 100
103 scoped_ptr<TextTrack> AddTextTrackF(
104 TextKind kind,
105 const std::string& label,
106 const std::string& language) {
107 return scoped_ptr<TextTrack>();
108 }
109
110 void NewSegmentF() { 101 void NewSegmentF() {
111 DVLOG(1) << "NewSegmentF"; 102 DVLOG(1) << "NewSegmentF";
112 } 103 }
113 104
114 void EndOfSegmentF() { 105 void EndOfSegmentF() {
115 DVLOG(1) << "EndOfSegmentF()"; 106 DVLOG(1) << "EndOfSegmentF()";
116 } 107 }
117 108
118 void InitializeParser() { 109 void InitializeParser() {
119 parser_->Init( 110 parser_->Init(
120 base::Bind(&MP4StreamParserTest::InitF, base::Unretained(this)), 111 base::Bind(&MP4StreamParserTest::InitF, base::Unretained(this)),
121 base::Bind(&MP4StreamParserTest::NewConfigF, base::Unretained(this)), 112 base::Bind(&MP4StreamParserTest::NewConfigF, base::Unretained(this)),
122 base::Bind(&MP4StreamParserTest::NewBuffersF, base::Unretained(this)), 113 base::Bind(&MP4StreamParserTest::NewBuffersF, base::Unretained(this)),
123 base::Bind(&MP4StreamParserTest::NewTextBuffersF, 114 StreamParser::NewTextBuffersCB(),
124 base::Unretained(this)),
125 base::Bind(&MP4StreamParserTest::KeyNeededF, base::Unretained(this)), 115 base::Bind(&MP4StreamParserTest::KeyNeededF, base::Unretained(this)),
126 base::Bind(&MP4StreamParserTest::AddTextTrackF, base::Unretained(this)),
127 base::Bind(&MP4StreamParserTest::NewSegmentF, base::Unretained(this)), 116 base::Bind(&MP4StreamParserTest::NewSegmentF, base::Unretained(this)),
128 base::Bind(&MP4StreamParserTest::EndOfSegmentF, 117 base::Bind(&MP4StreamParserTest::EndOfSegmentF,
129 base::Unretained(this)), 118 base::Unretained(this)),
130 LogCB()); 119 LogCB());
131 } 120 }
132 121
133 bool ParseMP4File(const std::string& filename, int append_bytes) { 122 bool ParseMP4File(const std::string& filename, int append_bytes) {
134 InitializeParser(); 123 InitializeParser();
135 124
136 scoped_refptr<DecoderBuffer> buffer = ReadTestDataFile(filename); 125 scoped_refptr<DecoderBuffer> buffer = ReadTestDataFile(filename);
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 EXPECT_TRUE(AppendDataInPieces(buffer->data() + kFirstMoofOffset, 195 EXPECT_TRUE(AppendDataInPieces(buffer->data() + kFirstMoofOffset,
207 buffer->data_size() - kFirstMoofOffset, 196 buffer->data_size() - kFirstMoofOffset,
208 512)); 197 512));
209 } 198 }
210 199
211 // TODO(strobe): Create and test media which uses CENC auxiliary info stored 200 // TODO(strobe): Create and test media which uses CENC auxiliary info stored
212 // inside a private box 201 // inside a private box
213 202
214 } // namespace mp4 203 } // namespace mp4
215 } // namespace media 204 } // namespace media
OLDNEW
« no previous file with comments | « media/mp4/mp4_stream_parser.cc ('k') | media/webm/webm_cluster_parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698