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/mp2t/mp2t_stream_parser.h" | 5 #include "media/formats/mp2t/mp2t_stream_parser.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
111 return true; | 111 return true; |
112 } | 112 } |
113 | 113 |
114 void OnInit(const StreamParser::InitParameters& params) { | 114 void OnInit(const StreamParser::InitParameters& params) { |
115 DVLOG(1) << "OnInit: dur=" << params.duration.InMilliseconds() | 115 DVLOG(1) << "OnInit: dur=" << params.duration.InMilliseconds() |
116 << ", autoTimestampOffset=" << params.auto_update_timestamp_offset; | 116 << ", autoTimestampOffset=" << params.auto_update_timestamp_offset; |
117 } | 117 } |
118 | 118 |
119 bool OnNewConfig(std::unique_ptr<MediaTracks> tracks, | 119 bool OnNewConfig(std::unique_ptr<MediaTracks> tracks, |
120 const StreamParser::TextTrackConfigMap& tc) { | 120 const StreamParser::TextTrackConfigMap& tc) { |
121 const AudioDecoderConfig& ac = tracks->getFirstAudioConfig(); | 121 DVLOG(1) << "OnNewConfig: got " << tracks->tracks().size() << " tracks"; |
122 const VideoDecoderConfig& vc = tracks->getFirstVideoConfig(); | 122 bool found_audio_track = false; |
123 DVLOG(1) << "OnNewConfig: media tracks count=" << tracks->tracks().size() | 123 bool found_video_track = false; |
124 << ", audio=" << ac.IsValidConfig() | 124 for (const auto& track : tracks->tracks()) { |
125 << ", video=" << vc.IsValidConfig(); | 125 const auto& track_id = track->bytestream_track_id(); |
126 if (track->type() == MediaTrack::Audio) { | |
127 found_audio_track = true; | |
128 EXPECT_TRUE(tracks->getAudioConfig(track_id).IsValidConfig()); | |
129 } else if (track->type() == MediaTrack::Video) { | |
130 found_video_track = true; | |
131 EXPECT_TRUE(tracks->getVideoConfig(track_id).IsValidConfig()); | |
132 } else { | |
133 // Unexpected track type. | |
134 NOTREACHED(); | |
wolenetz
2016/06/16 21:25:00
Sorry I missed this before: Don't use NOTREACHED()
servolk
2016/06/16 21:33:24
Oh, good to know, thanks, I'll fix this.
| |
135 } | |
136 } | |
137 EXPECT_TRUE(found_audio_track); | |
138 EXPECT_EQ(has_video_, found_video_track); | |
126 config_count_++; | 139 config_count_++; |
127 EXPECT_TRUE(ac.IsValidConfig()); | |
128 EXPECT_EQ(vc.IsValidConfig(), has_video_); | |
129 return true; | 140 return true; |
130 } | 141 } |
131 | 142 |
132 | 143 |
133 void DumpBuffers(const std::string& label, | 144 void DumpBuffers(const std::string& label, |
134 const StreamParser::BufferQueue& buffers) { | 145 const StreamParser::BufferQueue& buffers) { |
135 DVLOG(2) << "DumpBuffers: " << label << " size " << buffers.size(); | 146 DVLOG(2) << "DumpBuffers: " << label << " size " << buffers.size(); |
136 for (StreamParser::BufferQueue::const_iterator buf = buffers.begin(); | 147 for (StreamParser::BufferQueue::const_iterator buf = buffers.begin(); |
137 buf != buffers.end(); buf++) { | 148 buf != buffers.end(); buf++) { |
138 DVLOG(3) << " n=" << buf - buffers.begin() | 149 DVLOG(3) << " n=" << buf - buffers.begin() |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
297 parser_->Flush(); | 308 parser_->Flush(); |
298 EXPECT_EQ(audio_frame_count_, 40); | 309 EXPECT_EQ(audio_frame_count_, 40); |
299 EXPECT_EQ(video_frame_count_, 0); | 310 EXPECT_EQ(video_frame_count_, 0); |
300 // This stream has no mid-stream configuration change. | 311 // This stream has no mid-stream configuration change. |
301 EXPECT_EQ(config_count_, 1); | 312 EXPECT_EQ(config_count_, 1); |
302 EXPECT_EQ(segment_count_, 1); | 313 EXPECT_EQ(segment_count_, 1); |
303 } | 314 } |
304 | 315 |
305 } // namespace mp2t | 316 } // namespace mp2t |
306 } // namespace media | 317 } // namespace media |
OLD | NEW |