| 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 18 matching lines...) Expand all Loading... |
| 29 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, | 29 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, |
| 30 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 | 30 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 |
| 31 }; | 31 }; |
| 32 | 32 |
| 33 FakeDemuxerStream::FakeDemuxerStream(int num_configs, | 33 FakeDemuxerStream::FakeDemuxerStream(int num_configs, |
| 34 int num_buffers_in_one_config, | 34 int num_buffers_in_one_config, |
| 35 bool is_encrypted) | 35 bool is_encrypted) |
| 36 : task_runner_(base::MessageLoopProxy::current()), | 36 : task_runner_(base::MessageLoopProxy::current()), |
| 37 num_configs_left_(num_configs), | 37 num_configs_left_(num_configs), |
| 38 num_buffers_in_one_config_(num_buffers_in_one_config), | 38 num_buffers_in_one_config_(num_buffers_in_one_config), |
| 39 config_changes_(num_configs > 1), |
| 39 is_encrypted_(is_encrypted), | 40 is_encrypted_(is_encrypted), |
| 40 num_buffers_left_in_current_config_(num_buffers_in_one_config), | 41 num_buffers_left_in_current_config_(num_buffers_in_one_config), |
| 41 num_buffers_returned_(0), | 42 num_buffers_returned_(0), |
| 42 current_timestamp_(base::TimeDelta::FromMilliseconds(kStartTimestampMs)), | 43 current_timestamp_(base::TimeDelta::FromMilliseconds(kStartTimestampMs)), |
| 43 duration_(base::TimeDelta::FromMilliseconds(kDurationMs)), | 44 duration_(base::TimeDelta::FromMilliseconds(kDurationMs)), |
| 44 next_coded_size_(kStartWidth, kStartHeight), | 45 next_coded_size_(kStartWidth, kStartHeight), |
| 45 next_read_num_(0), | 46 next_read_num_(0), |
| 46 read_to_hold_(-1) { | 47 read_to_hold_(-1) { |
| 47 DCHECK_GT(num_configs_left_, 0); | 48 DCHECK_GT(num_configs_left_, 0); |
| 48 DCHECK_GT(num_buffers_in_one_config_, 0); | 49 DCHECK_GT(num_buffers_in_one_config_, 0); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 78 // TODO(xhwang): Support audio if needed. | 79 // TODO(xhwang): Support audio if needed. |
| 79 DemuxerStream::Type FakeDemuxerStream::type() { | 80 DemuxerStream::Type FakeDemuxerStream::type() { |
| 80 DCHECK(task_runner_->BelongsToCurrentThread()); | 81 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 81 return VIDEO; | 82 return VIDEO; |
| 82 } | 83 } |
| 83 | 84 |
| 84 void FakeDemuxerStream::EnableBitstreamConverter() { | 85 void FakeDemuxerStream::EnableBitstreamConverter() { |
| 85 DCHECK(task_runner_->BelongsToCurrentThread()); | 86 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 86 } | 87 } |
| 87 | 88 |
| 89 bool FakeDemuxerStream::SupportsConfigChanges() { |
| 90 return config_changes_; |
| 91 } |
| 92 |
| 88 void FakeDemuxerStream::HoldNextRead() { | 93 void FakeDemuxerStream::HoldNextRead() { |
| 89 DCHECK(task_runner_->BelongsToCurrentThread()); | 94 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 90 read_to_hold_ = next_read_num_; | 95 read_to_hold_ = next_read_num_; |
| 91 } | 96 } |
| 92 | 97 |
| 93 void FakeDemuxerStream::HoldNextConfigChangeRead() { | 98 void FakeDemuxerStream::HoldNextConfigChangeRead() { |
| 94 DCHECK(task_runner_->BelongsToCurrentThread()); | 99 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 95 // Set |read_to_hold_| to be the next config change read. | 100 // Set |read_to_hold_| to be the next config change read. |
| 96 read_to_hold_ = next_read_num_ + num_buffers_in_one_config_ - | 101 read_to_hold_ = next_read_num_ + num_buffers_in_one_config_ - |
| 97 next_read_num_ % (num_buffers_in_one_config_ + 1); | 102 next_read_num_ % (num_buffers_in_one_config_ + 1); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 | 164 |
| 160 num_buffers_left_in_current_config_--; | 165 num_buffers_left_in_current_config_--; |
| 161 if (num_buffers_left_in_current_config_ == 0) | 166 if (num_buffers_left_in_current_config_ == 0) |
| 162 num_configs_left_--; | 167 num_configs_left_--; |
| 163 | 168 |
| 164 num_buffers_returned_++; | 169 num_buffers_returned_++; |
| 165 base::ResetAndReturn(&read_cb_).Run(kOk, buffer); | 170 base::ResetAndReturn(&read_cb_).Run(kOk, buffer); |
| 166 } | 171 } |
| 167 | 172 |
| 168 } // namespace media | 173 } // namespace media |
| OLD | NEW |