OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/base/fake_demuxer_stream.h" | 5 #include "media/base/fake_demuxer_stream.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 | 54 |
55 FakeDemuxerStream::~FakeDemuxerStream() {} | 55 FakeDemuxerStream::~FakeDemuxerStream() {} |
56 | 56 |
57 void FakeDemuxerStream::Initialize() { | 57 void FakeDemuxerStream::Initialize() { |
58 DCHECK_EQ(-1, read_to_hold_); | 58 DCHECK_EQ(-1, read_to_hold_); |
59 num_configs_left_ = num_configs_; | 59 num_configs_left_ = num_configs_; |
60 num_buffers_left_in_current_config_ = num_buffers_in_one_config_; | 60 num_buffers_left_in_current_config_ = num_buffers_in_one_config_; |
61 num_buffers_returned_ = 0; | 61 num_buffers_returned_ = 0; |
62 current_timestamp_ = base::TimeDelta::FromMilliseconds(kStartTimestampMs); | 62 current_timestamp_ = base::TimeDelta::FromMilliseconds(kStartTimestampMs); |
63 duration_ = base::TimeDelta::FromMilliseconds(kDurationMs); | 63 duration_ = base::TimeDelta::FromMilliseconds(kDurationMs); |
64 splice_timestamp_ = kNoTimestamp; | |
65 next_coded_size_ = gfx::Size(kStartWidth, kStartHeight); | 64 next_coded_size_ = gfx::Size(kStartWidth, kStartHeight); |
66 next_read_num_ = 0; | 65 next_read_num_ = 0; |
67 } | 66 } |
68 | 67 |
69 void FakeDemuxerStream::Read(const ReadCB& read_cb) { | 68 void FakeDemuxerStream::Read(const ReadCB& read_cb) { |
70 DCHECK(task_runner_->BelongsToCurrentThread()); | 69 DCHECK(task_runner_->BelongsToCurrentThread()); |
71 DCHECK(read_cb_.is_null()); | 70 DCHECK(read_cb_.is_null()); |
72 | 71 |
73 read_cb_ = BindToCurrentLoop(read_cb); | 72 read_cb_ = BindToCurrentLoop(read_cb); |
74 | 73 |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 video_decoder_config_, current_timestamp_, duration_); | 198 video_decoder_config_, current_timestamp_, duration_); |
200 | 199 |
201 // TODO(xhwang): Output out-of-order buffers if needed. | 200 // TODO(xhwang): Output out-of-order buffers if needed. |
202 if (is_encrypted_) { | 201 if (is_encrypted_) { |
203 buffer->set_decrypt_config(base::MakeUnique<DecryptConfig>( | 202 buffer->set_decrypt_config(base::MakeUnique<DecryptConfig>( |
204 std::string(kKeyId, kKeyId + arraysize(kKeyId)), | 203 std::string(kKeyId, kKeyId + arraysize(kKeyId)), |
205 std::string(kIv, kIv + arraysize(kIv)), std::vector<SubsampleEntry>())); | 204 std::string(kIv, kIv + arraysize(kIv)), std::vector<SubsampleEntry>())); |
206 } | 205 } |
207 buffer->set_timestamp(current_timestamp_); | 206 buffer->set_timestamp(current_timestamp_); |
208 buffer->set_duration(duration_); | 207 buffer->set_duration(duration_); |
209 buffer->set_splice_timestamp(splice_timestamp_); | |
210 current_timestamp_ += duration_; | 208 current_timestamp_ += duration_; |
211 | 209 |
212 num_buffers_left_in_current_config_--; | 210 num_buffers_left_in_current_config_--; |
213 if (num_buffers_left_in_current_config_ == 0) | 211 if (num_buffers_left_in_current_config_ == 0) |
214 num_configs_left_--; | 212 num_configs_left_--; |
215 | 213 |
216 num_buffers_returned_++; | 214 num_buffers_returned_++; |
217 base::ResetAndReturn(&read_cb_).Run(kOk, buffer); | 215 base::ResetAndReturn(&read_cb_).Run(kOk, buffer); |
218 } | 216 } |
219 | 217 |
220 FakeDemuxerStreamProvider::FakeDemuxerStreamProvider( | 218 FakeDemuxerStreamProvider::FakeDemuxerStreamProvider( |
221 int num_video_configs, | 219 int num_video_configs, |
222 int num_video_buffers_in_one_config, | 220 int num_video_buffers_in_one_config, |
223 bool is_video_encrypted) | 221 bool is_video_encrypted) |
224 : fake_video_stream_(num_video_configs, | 222 : fake_video_stream_(num_video_configs, |
225 num_video_buffers_in_one_config, | 223 num_video_buffers_in_one_config, |
226 is_video_encrypted) { | 224 is_video_encrypted) { |
227 } | 225 } |
228 | 226 |
229 FakeDemuxerStreamProvider::~FakeDemuxerStreamProvider() { | 227 FakeDemuxerStreamProvider::~FakeDemuxerStreamProvider() { |
230 } | 228 } |
231 | 229 |
232 DemuxerStream* FakeDemuxerStreamProvider::GetStream(DemuxerStream::Type type) { | 230 DemuxerStream* FakeDemuxerStreamProvider::GetStream(DemuxerStream::Type type) { |
233 if (type == DemuxerStream::Type::AUDIO) | 231 if (type == DemuxerStream::Type::AUDIO) |
234 return nullptr; | 232 return nullptr; |
235 return &fake_video_stream_; | 233 return &fake_video_stream_; |
236 }; | 234 }; |
237 | 235 |
238 } // namespace media | 236 } // namespace media |
OLD | NEW |