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 <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 | 7 |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
16 #include "media/base/audio_decoder_config.h" | 16 #include "media/base/audio_decoder_config.h" |
17 #include "media/base/decoder_buffer.h" | 17 #include "media/base/decoder_buffer.h" |
| 18 #include "media/base/media_track.h" |
| 19 #include "media/base/media_tracks.h" |
18 #include "media/base/stream_parser_buffer.h" | 20 #include "media/base/stream_parser_buffer.h" |
19 #include "media/base/test_data_util.h" | 21 #include "media/base/test_data_util.h" |
20 #include "media/base/text_track_config.h" | 22 #include "media/base/text_track_config.h" |
21 #include "media/base/video_decoder_config.h" | 23 #include "media/base/video_decoder_config.h" |
22 #include "media/formats/mp2t/mp2t_stream_parser.h" | 24 #include "media/formats/mp2t/mp2t_stream_parser.h" |
23 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
24 | 26 |
25 namespace media { | 27 namespace media { |
26 namespace mp2t { | 28 namespace mp2t { |
27 | 29 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 start += append_size; | 106 start += append_size; |
105 } | 107 } |
106 return true; | 108 return true; |
107 } | 109 } |
108 | 110 |
109 void OnInit(const StreamParser::InitParameters& params) { | 111 void OnInit(const StreamParser::InitParameters& params) { |
110 DVLOG(1) << "OnInit: dur=" << params.duration.InMilliseconds() | 112 DVLOG(1) << "OnInit: dur=" << params.duration.InMilliseconds() |
111 << ", autoTimestampOffset=" << params.auto_update_timestamp_offset; | 113 << ", autoTimestampOffset=" << params.auto_update_timestamp_offset; |
112 } | 114 } |
113 | 115 |
114 bool OnNewConfig(const AudioDecoderConfig& ac, | 116 bool OnNewConfig(scoped_ptr<MediaTracks> tracks, |
115 const VideoDecoderConfig& vc, | |
116 const StreamParser::TextTrackConfigMap& tc) { | 117 const StreamParser::TextTrackConfigMap& tc) { |
117 DVLOG(1) << "OnNewConfig: audio=" << ac.IsValidConfig() | 118 DVLOG(1) << "OnNewConfig: media tracks count=" << tracks->tracks().size(); |
118 << ", video=" << vc.IsValidConfig(); | |
119 config_count_++; | 119 config_count_++; |
| 120 const AudioDecoderConfig& ac = tracks->getFirstAudioConfig(); |
| 121 const VideoDecoderConfig& vc = tracks->getFirstVideoConfig(); |
120 EXPECT_TRUE(ac.IsValidConfig()); | 122 EXPECT_TRUE(ac.IsValidConfig()); |
121 EXPECT_EQ(vc.IsValidConfig(), has_video_); | 123 EXPECT_EQ(vc.IsValidConfig(), has_video_); |
122 return true; | 124 return true; |
123 } | 125 } |
124 | 126 |
125 | 127 |
126 void DumpBuffers(const std::string& label, | 128 void DumpBuffers(const std::string& label, |
127 const StreamParser::BufferQueue& buffers) { | 129 const StreamParser::BufferQueue& buffers) { |
128 DVLOG(2) << "DumpBuffers: " << label << " size " << buffers.size(); | 130 DVLOG(2) << "DumpBuffers: " << label << " size " << buffers.size(); |
129 for (StreamParser::BufferQueue::const_iterator buf = buffers.begin(); | 131 for (StreamParser::BufferQueue::const_iterator buf = buffers.begin(); |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 parser_->Flush(); | 292 parser_->Flush(); |
291 EXPECT_EQ(audio_frame_count_, 40); | 293 EXPECT_EQ(audio_frame_count_, 40); |
292 EXPECT_EQ(video_frame_count_, 0); | 294 EXPECT_EQ(video_frame_count_, 0); |
293 // This stream has no mid-stream configuration change. | 295 // This stream has no mid-stream configuration change. |
294 EXPECT_EQ(config_count_, 1); | 296 EXPECT_EQ(config_count_, 1); |
295 EXPECT_EQ(segment_count_, 1); | 297 EXPECT_EQ(segment_count_, 1); |
296 } | 298 } |
297 | 299 |
298 } // namespace mp2t | 300 } // namespace mp2t |
299 } // namespace media | 301 } // namespace media |
OLD | NEW |