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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 void FakeDemuxerStream::DoRead() { | 121 void FakeDemuxerStream::DoRead() { |
122 DCHECK(message_loop_->BelongsToCurrentThread()); | 122 DCHECK(message_loop_->BelongsToCurrentThread()); |
123 DCHECK(!read_cb_.is_null()); | 123 DCHECK(!read_cb_.is_null()); |
124 | 124 |
125 next_read_num_++; | 125 next_read_num_++; |
126 | 126 |
127 if (num_buffers_left_in_current_config_ == 0) { | 127 if (num_buffers_left_in_current_config_ == 0) { |
128 // End of stream. | 128 // End of stream. |
129 if (num_configs_left_ == 0) { | 129 if (num_configs_left_ == 0) { |
130 base::ResetAndReturn(&read_cb_).Run(kOk, | 130 base::ResetAndReturn(&read_cb_).Run(kOk, |
131 DecoderBuffer::CreateEOSBuffer()); | 131 DecoderBuffer::create_eos_buffer()); |
132 return; | 132 return; |
133 } | 133 } |
134 | 134 |
135 // Config change. | 135 // Config change. |
136 num_buffers_left_in_current_config_ = num_buffers_in_one_config_; | 136 num_buffers_left_in_current_config_ = num_buffers_in_one_config_; |
137 UpdateVideoDecoderConfig(); | 137 UpdateVideoDecoderConfig(); |
138 base::ResetAndReturn(&read_cb_).Run(kConfigChanged, NULL); | 138 base::ResetAndReturn(&read_cb_).Run(kConfigChanged, NULL); |
139 return; | 139 return; |
140 } | 140 } |
141 | 141 |
142 // Prepare the next buffer. | 142 // Prepare the next buffer. |
143 Pickle pickle; | 143 Pickle pickle; |
144 pickle.WriteString(kFakeBufferHeader); | 144 pickle.WriteString(kFakeBufferHeader); |
145 pickle.WriteInt(video_decoder_config_.coded_size().width()); | 145 pickle.WriteInt(video_decoder_config_.coded_size().width()); |
146 pickle.WriteInt(video_decoder_config_.coded_size().height()); | 146 pickle.WriteInt(video_decoder_config_.coded_size().height()); |
147 pickle.WriteInt64(current_timestamp_.InMilliseconds()); | 147 pickle.WriteInt64(current_timestamp_.InMilliseconds()); |
148 | 148 |
149 scoped_refptr<DecoderBuffer> buffer = DecoderBuffer::CopyFrom( | 149 scoped_refptr<DecoderBuffer> buffer = DecoderBuffer::copy_from( |
150 static_cast<const uint8*>(pickle.data()), pickle.size()); | 150 static_cast<const uint8*>(pickle.data()), pickle.size()); |
151 | 151 |
152 // TODO(xhwang): Output out-of-order buffers if needed. | 152 // TODO(xhwang): Output out-of-order buffers if needed. |
153 buffer->SetTimestamp(current_timestamp_); | 153 buffer->set_timestamp(current_timestamp_); |
154 buffer->SetDuration(duration_); | 154 buffer->set_duration(duration_); |
155 current_timestamp_ += duration_; | 155 current_timestamp_ += duration_; |
156 | 156 |
157 num_buffers_left_in_current_config_--; | 157 num_buffers_left_in_current_config_--; |
158 if (num_buffers_left_in_current_config_ == 0) | 158 if (num_buffers_left_in_current_config_ == 0) |
159 num_configs_left_--; | 159 num_configs_left_--; |
160 | 160 |
161 num_buffers_returned_++; | 161 num_buffers_returned_++; |
162 base::ResetAndReturn(&read_cb_).Run(kOk, buffer); | 162 base::ResetAndReturn(&read_cb_).Run(kOk, buffer); |
163 } | 163 } |
164 | 164 |
165 } // namespace media | 165 } // namespace media |
OLD | NEW |