| 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 const AudioDecoderConfig& ac = tracks->getFirstAudioConfig(); |
| 119 const VideoDecoderConfig& vc = tracks->getFirstVideoConfig(); |
| 120 DVLOG(1) << "OnNewConfig: media tracks count=" << tracks->tracks().size() |
| 121 << ", audio=" << ac.IsValidConfig() |
| 118 << ", video=" << vc.IsValidConfig(); | 122 << ", video=" << vc.IsValidConfig(); |
| 119 config_count_++; | 123 config_count_++; |
| 120 EXPECT_TRUE(ac.IsValidConfig()); | 124 EXPECT_TRUE(ac.IsValidConfig()); |
| 121 EXPECT_EQ(vc.IsValidConfig(), has_video_); | 125 EXPECT_EQ(vc.IsValidConfig(), has_video_); |
| 122 return true; | 126 return true; |
| 123 } | 127 } |
| 124 | 128 |
| 125 | 129 |
| 126 void DumpBuffers(const std::string& label, | 130 void DumpBuffers(const std::string& label, |
| 127 const StreamParser::BufferQueue& buffers) { | 131 const StreamParser::BufferQueue& buffers) { |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 parser_->Flush(); | 294 parser_->Flush(); |
| 291 EXPECT_EQ(audio_frame_count_, 40); | 295 EXPECT_EQ(audio_frame_count_, 40); |
| 292 EXPECT_EQ(video_frame_count_, 0); | 296 EXPECT_EQ(video_frame_count_, 0); |
| 293 // This stream has no mid-stream configuration change. | 297 // This stream has no mid-stream configuration change. |
| 294 EXPECT_EQ(config_count_, 1); | 298 EXPECT_EQ(config_count_, 1); |
| 295 EXPECT_EQ(segment_count_, 1); | 299 EXPECT_EQ(segment_count_, 1); |
| 296 } | 300 } |
| 297 | 301 |
| 298 } // namespace mp2t | 302 } // namespace mp2t |
| 299 } // namespace media | 303 } // namespace media |
| OLD | NEW |