| 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/filters/fake_demuxer_stream.h" | 5 #include "media/filters/fake_demuxer_stream.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 | 47 |
| 48 FakeDemuxerStream::~FakeDemuxerStream() {} | 48 FakeDemuxerStream::~FakeDemuxerStream() {} |
| 49 | 49 |
| 50 void FakeDemuxerStream::Initialize() { | 50 void FakeDemuxerStream::Initialize() { |
| 51 DCHECK_EQ(-1, read_to_hold_); | 51 DCHECK_EQ(-1, read_to_hold_); |
| 52 num_configs_left_ = num_configs_; | 52 num_configs_left_ = num_configs_; |
| 53 num_buffers_left_in_current_config_ = num_buffers_in_one_config_; | 53 num_buffers_left_in_current_config_ = num_buffers_in_one_config_; |
| 54 num_buffers_returned_ = 0; | 54 num_buffers_returned_ = 0; |
| 55 current_timestamp_ = base::TimeDelta::FromMilliseconds(kStartTimestampMs); | 55 current_timestamp_ = base::TimeDelta::FromMilliseconds(kStartTimestampMs); |
| 56 duration_ = base::TimeDelta::FromMilliseconds(kDurationMs); | 56 duration_ = base::TimeDelta::FromMilliseconds(kDurationMs); |
| 57 splice_timestamp_ = kNoTimestamp(); |
| 57 next_coded_size_ = gfx::Size(kStartWidth, kStartHeight); | 58 next_coded_size_ = gfx::Size(kStartWidth, kStartHeight); |
| 58 next_read_num_ = 0; | 59 next_read_num_ = 0; |
| 59 } | 60 } |
| 60 | 61 |
| 61 void FakeDemuxerStream::Read(const ReadCB& read_cb) { | 62 void FakeDemuxerStream::Read(const ReadCB& read_cb) { |
| 62 DCHECK(task_runner_->BelongsToCurrentThread()); | 63 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 63 DCHECK(read_cb_.is_null()); | 64 DCHECK(read_cb_.is_null()); |
| 64 | 65 |
| 65 read_cb_ = BindToCurrentLoop(read_cb); | 66 read_cb_ = BindToCurrentLoop(read_cb); |
| 66 | 67 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 | 174 |
| 174 // TODO(xhwang): Output out-of-order buffers if needed. | 175 // TODO(xhwang): Output out-of-order buffers if needed. |
| 175 if (is_encrypted_) { | 176 if (is_encrypted_) { |
| 176 buffer->set_decrypt_config(scoped_ptr<DecryptConfig>( | 177 buffer->set_decrypt_config(scoped_ptr<DecryptConfig>( |
| 177 new DecryptConfig(std::string(kKeyId, kKeyId + arraysize(kKeyId)), | 178 new DecryptConfig(std::string(kKeyId, kKeyId + arraysize(kKeyId)), |
| 178 std::string(kIv, kIv + arraysize(kIv)), | 179 std::string(kIv, kIv + arraysize(kIv)), |
| 179 std::vector<SubsampleEntry>()))); | 180 std::vector<SubsampleEntry>()))); |
| 180 } | 181 } |
| 181 buffer->set_timestamp(current_timestamp_); | 182 buffer->set_timestamp(current_timestamp_); |
| 182 buffer->set_duration(duration_); | 183 buffer->set_duration(duration_); |
| 184 buffer->set_splice_timestamp(splice_timestamp_); |
| 183 current_timestamp_ += duration_; | 185 current_timestamp_ += duration_; |
| 184 | 186 |
| 185 num_buffers_left_in_current_config_--; | 187 num_buffers_left_in_current_config_--; |
| 186 if (num_buffers_left_in_current_config_ == 0) | 188 if (num_buffers_left_in_current_config_ == 0) |
| 187 num_configs_left_--; | 189 num_configs_left_--; |
| 188 | 190 |
| 189 num_buffers_returned_++; | 191 num_buffers_returned_++; |
| 190 base::ResetAndReturn(&read_cb_).Run(kOk, buffer); | 192 base::ResetAndReturn(&read_cb_).Run(kOk, buffer); |
| 191 } | 193 } |
| 192 | 194 |
| 193 } // namespace media | 195 } // namespace media |
| OLD | NEW |