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/video_frame_stream.h" | 5 #include "media/filters/video_frame_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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 return; | 209 return; |
210 } | 210 } |
211 } | 211 } |
212 | 212 |
213 void VideoFrameStream::OnFrameReady(const VideoDecoder::Status status, | 213 void VideoFrameStream::OnFrameReady(const VideoDecoder::Status status, |
214 const scoped_refptr<VideoFrame>& frame) { | 214 const scoped_refptr<VideoFrame>& frame) { |
215 DCHECK(state_ == STATE_NORMAL || state_ == STATE_FLUSHING_DECODER) << state_; | 215 DCHECK(state_ == STATE_NORMAL || state_ == STATE_FLUSHING_DECODER) << state_; |
216 DCHECK(!read_cb_.is_null()); | 216 DCHECK(!read_cb_.is_null()); |
217 | 217 |
218 if (status != VideoDecoder::kOk) { | 218 if (status != VideoDecoder::kOk) { |
219 DCHECK(!frame); | 219 DCHECK(!frame.get()); |
220 state_ = STATE_ERROR; | 220 state_ = STATE_ERROR; |
221 base::ResetAndReturn(&read_cb_).Run(status, NULL); | 221 base::ResetAndReturn(&read_cb_).Run(status, NULL); |
222 return; | 222 return; |
223 } | 223 } |
224 | 224 |
225 // The stopping/resetting process will be handled when the decoder is | 225 // The stopping/resetting process will be handled when the decoder is |
226 // stopped/reset. | 226 // stopped/reset. |
227 if (!stop_cb_.is_null() || !reset_cb_.is_null()) { | 227 if (!stop_cb_.is_null() || !reset_cb_.is_null()) { |
228 base::ResetAndReturn(&read_cb_).Run(VideoDecoder::kOk, NULL); | 228 base::ResetAndReturn(&read_cb_).Run(VideoDecoder::kOk, NULL); |
229 return; | 229 return; |
230 } | 230 } |
231 | 231 |
232 // Decoder flush finished. Reinitialize the video decoder. | 232 // Decoder flush finished. Reinitialize the video decoder. |
233 if (state_ == STATE_FLUSHING_DECODER && | 233 if (state_ == STATE_FLUSHING_DECODER && |
234 status == VideoDecoder::kOk && frame->IsEndOfStream()) { | 234 status == VideoDecoder::kOk && frame->IsEndOfStream()) { |
235 ReinitializeDecoder(); | 235 ReinitializeDecoder(); |
236 return; | 236 return; |
237 } | 237 } |
238 | 238 |
239 base::ResetAndReturn(&read_cb_).Run(status, frame); | 239 base::ResetAndReturn(&read_cb_).Run(status, frame); |
240 } | 240 } |
241 | 241 |
242 void VideoFrameStream::OnBufferReady( | 242 void VideoFrameStream::OnBufferReady( |
243 const DemuxerStream::ReadCB& demuxer_read_cb, | 243 const DemuxerStream::ReadCB& demuxer_read_cb, |
244 DemuxerStream::Status status, | 244 DemuxerStream::Status status, |
245 const scoped_refptr<DecoderBuffer>& buffer) { | 245 const scoped_refptr<DecoderBuffer>& buffer) { |
246 DCHECK(message_loop_->BelongsToCurrentThread()); | 246 DCHECK(message_loop_->BelongsToCurrentThread()); |
247 // VideoFrameStream reads from demuxer stream only when in NORMAL state. | 247 // VideoFrameStream reads from demuxer stream only when in NORMAL state. |
248 DCHECK_EQ(state_, STATE_NORMAL) << state_; | 248 DCHECK_EQ(state_, STATE_NORMAL) << state_; |
249 DCHECK_EQ(buffer != NULL, status == DemuxerStream::kOk) << status; | 249 DCHECK_EQ(buffer.get() != NULL, status == DemuxerStream::kOk) << status; |
250 | 250 |
251 if (status == DemuxerStream::kConfigChanged) { | 251 if (status == DemuxerStream::kConfigChanged) { |
252 DVLOG(2) << "OnBufferReady() - kConfigChanged"; | 252 DVLOG(2) << "OnBufferReady() - kConfigChanged"; |
253 state_ = STATE_FLUSHING_DECODER; | 253 state_ = STATE_FLUSHING_DECODER; |
254 demuxer_read_cb.Run(DemuxerStream::kOk, DecoderBuffer::CreateEOSBuffer()); | 254 demuxer_read_cb.Run(DemuxerStream::kOk, DecoderBuffer::CreateEOSBuffer()); |
255 return; | 255 return; |
256 } | 256 } |
257 | 257 |
258 DCHECK(status == DemuxerStream::kOk || status == DemuxerStream::kAborted); | 258 DCHECK(status == DemuxerStream::kOk || status == DemuxerStream::kAborted); |
259 demuxer_read_cb.Run(status, buffer); | 259 demuxer_read_cb.Run(status, buffer); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 DCHECK(!stop_cb_.is_null()); | 353 DCHECK(!stop_cb_.is_null()); |
354 | 354 |
355 state_ = STATE_STOPPED; | 355 state_ = STATE_STOPPED; |
356 stream_ = NULL; | 356 stream_ = NULL; |
357 decoder_.reset(); | 357 decoder_.reset(); |
358 decrypting_demuxer_stream_.reset(); | 358 decrypting_demuxer_stream_.reset(); |
359 base::ResetAndReturn(&stop_cb_).Run(); | 359 base::ResetAndReturn(&stop_cb_).Run(); |
360 } | 360 } |
361 | 361 |
362 } // namespace media | 362 } // namespace media |
OLD | NEW |