OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <memory> |
| 6 |
5 #include "base/bind.h" | 7 #include "base/bind.h" |
6 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/ptr_util.h" |
7 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
8 #include "base/memory/scoped_ptr.h" | |
9 #include "base/memory/scoped_vector.h" | 11 #include "base/memory/scoped_vector.h" |
10 #include "base/thread_task_runner_handle.h" | 12 #include "base/thread_task_runner_handle.h" |
11 #include "base/threading/thread.h" | 13 #include "base/threading/thread.h" |
12 #include "base/time/time.h" | 14 #include "base/time/time.h" |
13 #include "chromecast/media/cma/base/balanced_media_task_runner_factory.h" | 15 #include "chromecast/media/cma/base/balanced_media_task_runner_factory.h" |
14 #include "chromecast/media/cma/base/decoder_buffer_base.h" | 16 #include "chromecast/media/cma/base/decoder_buffer_base.h" |
15 #include "chromecast/media/cma/base/demuxer_stream_adapter.h" | 17 #include "chromecast/media/cma/base/demuxer_stream_adapter.h" |
16 #include "chromecast/media/cma/base/demuxer_stream_for_test.h" | 18 #include "chromecast/media/cma/base/demuxer_stream_for_test.h" |
17 #include "chromecast/public/media/cast_decoder_buffer.h" | 19 #include "chromecast/public/media/cast_decoder_buffer.h" |
18 #include "media/base/audio_decoder_config.h" | 20 #include "media/base/audio_decoder_config.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 base::Unretained(this)), | 83 base::Unretained(this)), |
82 base::TimeDelta::FromSeconds(5)); | 84 base::TimeDelta::FromSeconds(5)); |
83 | 85 |
84 media_task_runner_factory_ = new BalancedMediaTaskRunnerFactory( | 86 media_task_runner_factory_ = new BalancedMediaTaskRunnerFactory( |
85 base::TimeDelta::FromMilliseconds(kMaxPtsDiffMs)); | 87 base::TimeDelta::FromMilliseconds(kMaxPtsDiffMs)); |
86 | 88 |
87 coded_frame_providers_.clear(); | 89 coded_frame_providers_.clear(); |
88 frame_received_count_ = 0; | 90 frame_received_count_ = 0; |
89 | 91 |
90 for (auto& stream : demuxer_streams_) { | 92 for (auto& stream : demuxer_streams_) { |
91 coded_frame_providers_.push_back(make_scoped_ptr( | 93 coded_frame_providers_.push_back(base::WrapUnique( |
92 new DemuxerStreamAdapter(base::ThreadTaskRunnerHandle::Get(), | 94 new DemuxerStreamAdapter(base::ThreadTaskRunnerHandle::Get(), |
93 media_task_runner_factory_, | 95 media_task_runner_factory_, stream))); |
94 stream))); | |
95 } | 96 } |
96 running_stream_count_ = coded_frame_providers_.size(); | 97 running_stream_count_ = coded_frame_providers_.size(); |
97 | 98 |
98 // read each stream | 99 // read each stream |
99 for (auto& code_frame_provider : coded_frame_providers_) { | 100 for (auto& code_frame_provider : coded_frame_providers_) { |
100 auto read_cb = base::Bind(&MultiDemuxerStreamAdaptersTest::OnNewFrame, | 101 auto read_cb = base::Bind(&MultiDemuxerStreamAdaptersTest::OnNewFrame, |
101 base::Unretained(this), | 102 base::Unretained(this), |
102 code_frame_provider); | 103 code_frame_provider); |
103 | 104 |
104 base::Closure task = base::Bind(&CodedFrameProvider::Read, | 105 base::Closure task = base::Bind(&CodedFrameProvider::Read, |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 | 144 |
144 TEST_F(MultiDemuxerStreamAdaptersTest, EarlyEos) { | 145 TEST_F(MultiDemuxerStreamAdaptersTest, EarlyEos) { |
145 // We have more than one streams here. One of them is much shorter than the | 146 // We have more than one streams here. One of them is much shorter than the |
146 // others. When the shortest stream reaches EOS, other streams should still | 147 // others. When the shortest stream reaches EOS, other streams should still |
147 // run as usually. BalancedTaskRunner should not be blocked. | 148 // run as usually. BalancedTaskRunner should not be blocked. |
148 int frame_count_short = 2; | 149 int frame_count_short = 2; |
149 int frame_count_long = | 150 int frame_count_long = |
150 frame_count_short + | 151 frame_count_short + |
151 kMaxPtsDiffMs / DemuxerStreamForTest::kDemuxerStreamForTestFrameDuration + | 152 kMaxPtsDiffMs / DemuxerStreamForTest::kDemuxerStreamForTestFrameDuration + |
152 100; | 153 100; |
153 demuxer_streams_.push_back(scoped_ptr<DemuxerStreamForTest>( | 154 demuxer_streams_.push_back(std::unique_ptr<DemuxerStreamForTest>( |
154 new DemuxerStreamForTest(frame_count_short, 2, 0, config_idx_))); | 155 new DemuxerStreamForTest(frame_count_short, 2, 0, config_idx_))); |
155 demuxer_streams_.push_back(scoped_ptr<DemuxerStreamForTest>( | 156 demuxer_streams_.push_back(std::unique_ptr<DemuxerStreamForTest>( |
156 new DemuxerStreamForTest(frame_count_long, 10, 0, config_idx_))); | 157 new DemuxerStreamForTest(frame_count_long, 10, 0, config_idx_))); |
157 | 158 |
158 total_expected_frames_ = frame_count_short + frame_count_long; | 159 total_expected_frames_ = frame_count_short + frame_count_long; |
159 | 160 |
160 scoped_ptr<base::MessageLoop> message_loop(new base::MessageLoop()); | 161 std::unique_ptr<base::MessageLoop> message_loop(new base::MessageLoop()); |
161 message_loop->PostTask(FROM_HERE, | 162 message_loop->PostTask(FROM_HERE, |
162 base::Bind(&MultiDemuxerStreamAdaptersTest::Start, | 163 base::Bind(&MultiDemuxerStreamAdaptersTest::Start, |
163 base::Unretained(this))); | 164 base::Unretained(this))); |
164 message_loop->Run(); | 165 message_loop->Run(); |
165 } | 166 } |
166 } // namespace media | 167 } // namespace media |
167 } // namespace chromecast | 168 } // namespace chromecast |
OLD | NEW |