| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // Implements a Demuxer that can switch among different data sources mid-stream. | 5 // Implements a Demuxer that can switch among different data sources mid-stream. |
| 6 // Uses FFmpegDemuxer under the covers, so see the caveats at the top of | 6 // Uses FFmpegDemuxer under the covers, so see the caveats at the top of |
| 7 // ffmpeg_demuxer.h. | 7 // ffmpeg_demuxer.h. |
| 8 | 8 |
| 9 #include "media/filters/chunk_demuxer.h" | 9 #include "media/filters/chunk_demuxer.h" |
| 10 | 10 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 bool CanAddBuffers(const BufferQueue& buffers) const; | 73 bool CanAddBuffers(const BufferQueue& buffers) const; |
| 74 | 74 |
| 75 void AddBuffers(const BufferQueue& buffers); | 75 void AddBuffers(const BufferQueue& buffers); |
| 76 void Shutdown(); | 76 void Shutdown(); |
| 77 | 77 |
| 78 bool GetLastBufferTimestamp(base::TimeDelta* timestamp) const; | 78 bool GetLastBufferTimestamp(base::TimeDelta* timestamp) const; |
| 79 | 79 |
| 80 // DemuxerStream methods. | 80 // DemuxerStream methods. |
| 81 virtual void Read(const ReadCallback& read_callback); | 81 virtual void Read(const ReadCallback& read_callback); |
| 82 virtual Type type(); | 82 virtual Type type(); |
| 83 virtual const MediaFormat& media_format(); | |
| 84 virtual void EnableBitstreamConverter(); | 83 virtual void EnableBitstreamConverter(); |
| 85 virtual AVStream* GetAVStream(); | 84 virtual AVStream* GetAVStream(); |
| 86 | 85 |
| 87 private: | 86 private: |
| 88 static void RunCallback(ReadCallback cb, scoped_refptr<Buffer> buffer); | 87 static void RunCallback(ReadCallback cb, scoped_refptr<Buffer> buffer); |
| 89 | 88 |
| 90 Type type_; | 89 Type type_; |
| 91 MediaFormat media_format_; | |
| 92 AVStream* av_stream_; | 90 AVStream* av_stream_; |
| 93 | 91 |
| 94 mutable base::Lock lock_; | 92 mutable base::Lock lock_; |
| 95 ReadCBQueue read_cbs_; | 93 ReadCBQueue read_cbs_; |
| 96 BufferQueue buffers_; | 94 BufferQueue buffers_; |
| 97 bool shutdown_called_; | 95 bool shutdown_called_; |
| 98 | 96 |
| 99 // Keeps track of the timestamp of the last buffer we have | 97 // Keeps track of the timestamp of the last buffer we have |
| 100 // added to |buffers_|. This is used to enforce buffers with strictly | 98 // added to |buffers_|. This is used to enforce buffers with strictly |
| 101 // monotonically increasing timestamps. | 99 // monotonically increasing timestamps. |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 buffer = buffers_.front(); | 251 buffer = buffers_.front(); |
| 254 buffers_.pop_front(); | 252 buffers_.pop_front(); |
| 255 } | 253 } |
| 256 } | 254 } |
| 257 | 255 |
| 258 read_callback.Run(buffer); | 256 read_callback.Run(buffer); |
| 259 } | 257 } |
| 260 | 258 |
| 261 DemuxerStream::Type ChunkDemuxerStream::type() { return type_; } | 259 DemuxerStream::Type ChunkDemuxerStream::type() { return type_; } |
| 262 | 260 |
| 263 const MediaFormat& ChunkDemuxerStream::media_format() { return media_format_; } | |
| 264 | |
| 265 void ChunkDemuxerStream::EnableBitstreamConverter() {} | 261 void ChunkDemuxerStream::EnableBitstreamConverter() {} |
| 266 | 262 |
| 267 AVStream* ChunkDemuxerStream::GetAVStream() { return av_stream_; } | 263 AVStream* ChunkDemuxerStream::GetAVStream() { return av_stream_; } |
| 268 | 264 |
| 269 ChunkDemuxer::ChunkDemuxer() | 265 ChunkDemuxer::ChunkDemuxer() |
| 270 : state_(WAITING_FOR_INIT), | 266 : state_(WAITING_FOR_INIT), |
| 271 format_context_(NULL), | 267 format_context_(NULL), |
| 272 buffered_bytes_(0), | 268 buffered_bytes_(0), |
| 273 seek_waits_for_data_(true) { | 269 seek_waits_for_data_(true) { |
| 274 } | 270 } |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 643 } | 639 } |
| 644 | 640 |
| 645 void ChunkDemuxer::InitFailed_Locked() { | 641 void ChunkDemuxer::InitFailed_Locked() { |
| 646 ChangeState(INIT_ERROR); | 642 ChangeState(INIT_ERROR); |
| 647 PipelineStatusCB cb; | 643 PipelineStatusCB cb; |
| 648 std::swap(cb, init_cb_); | 644 std::swap(cb, init_cb_); |
| 649 cb.Run(DEMUXER_ERROR_COULD_NOT_OPEN); | 645 cb.Run(DEMUXER_ERROR_COULD_NOT_OPEN); |
| 650 } | 646 } |
| 651 | 647 |
| 652 } // namespace media | 648 } // namespace media |
| OLD | NEW |