| 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 #ifndef MEDIA_FILTERS_ADAPTIVE_DEMUXER_H_ | 9 #ifndef MEDIA_FILTERS_ADAPTIVE_DEMUXER_H_ |
| 10 #define MEDIA_FILTERS_ADAPTIVE_DEMUXER_H_ | 10 #define MEDIA_FILTERS_ADAPTIVE_DEMUXER_H_ |
| 11 | 11 |
| 12 #include <deque> | 12 #include <deque> |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "base/callback.h" | 15 #include "base/callback.h" |
| 16 #include "base/synchronization/lock.h" | 16 #include "base/synchronization/lock.h" |
| 17 #include "media/base/buffers.h" | 17 #include "media/base/buffers.h" |
| 18 #include "media/base/filter_factories.h" | 18 #include "media/base/filter_factories.h" |
| 19 #include "media/base/filters.h" | 19 #include "media/base/filters.h" |
| 20 #include "media/base/pipeline.h" | 20 #include "media/base/pipeline.h" |
| 21 #include "media/base/media_format.h" | |
| 22 | 21 |
| 23 namespace media { | 22 namespace media { |
| 24 | 23 |
| 25 class AdaptiveDemuxer; | 24 class AdaptiveDemuxer; |
| 26 class StreamSwitchManager; | 25 class StreamSwitchManager; |
| 27 | 26 |
| 28 class AdaptiveDemuxerStream : public DemuxerStream { | 27 class AdaptiveDemuxerStream : public DemuxerStream { |
| 29 public: | 28 public: |
| 30 typedef std::vector<scoped_refptr<DemuxerStream> > StreamVector; | 29 typedef std::vector<scoped_refptr<DemuxerStream> > StreamVector; |
| 31 typedef std::deque<ReadCallback> ReadCBQueue; | 30 typedef std::deque<ReadCallback> ReadCBQueue; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 43 // than the requested time. | 42 // than the requested time. |
| 44 typedef base::Callback<void(base::TimeDelta, PipelineStatus)> SeekFunctionCB; | 43 typedef base::Callback<void(base::TimeDelta, PipelineStatus)> SeekFunctionCB; |
| 45 | 44 |
| 46 // Wraps a function that performs a seek on a specified stream. The | 45 // Wraps a function that performs a seek on a specified stream. The |
| 47 // base::TimeDelta parameter indicates what time to seek to. The | 46 // base::TimeDelta parameter indicates what time to seek to. The |
| 48 // SeekFunctionCBparameter specifies the callback we want called when the seek | 47 // SeekFunctionCBparameter specifies the callback we want called when the seek |
| 49 // completes. | 48 // completes. |
| 50 typedef base::Callback<void(base::TimeDelta, SeekFunctionCB)> SeekFunction; | 49 typedef base::Callback<void(base::TimeDelta, SeekFunctionCB)> SeekFunction; |
| 51 | 50 |
| 52 // Keeps references to the passed-in streams. |streams| must be non-empty and | 51 // Keeps references to the passed-in streams. |streams| must be non-empty and |
| 53 // all the streams in it must agree on type and media_format (or be NULL). | 52 // all the streams in it must agree on type. |
| 53 // |
| 54 // |initial_stream| must be a valid index into |streams| and specifies the | 54 // |initial_stream| must be a valid index into |streams| and specifies the |
| 55 // current stream on construction. | 55 // current stream on construction. |
| 56 AdaptiveDemuxerStream(StreamVector const& streams, int initial_stream); | 56 AdaptiveDemuxerStream(StreamVector const& streams, int initial_stream); |
| 57 virtual ~AdaptiveDemuxerStream(); | 57 virtual ~AdaptiveDemuxerStream(); |
| 58 | 58 |
| 59 // Notifies this stream that a Seek() was requested on the demuxer. | 59 // Notifies this stream that a Seek() was requested on the demuxer. |
| 60 void OnAdaptiveDemuxerSeek(base::TimeDelta seek_time); | 60 void OnAdaptiveDemuxerSeek(base::TimeDelta seek_time); |
| 61 | 61 |
| 62 // Change the stream to satisfy subsequent Read() requests from. The | 62 // Change the stream to satisfy subsequent Read() requests from. The |
| 63 // referenced pointer must not be NULL. The SeekFunction parameter | 63 // referenced pointer must not be NULL. The SeekFunction parameter |
| 64 // provides a way to seek |streams_[index]| to a specific time. | 64 // provides a way to seek |streams_[index]| to a specific time. |
| 65 void ChangeCurrentStream(int index, const SeekFunction& seek_function, | 65 void ChangeCurrentStream(int index, const SeekFunction& seek_function, |
| 66 const PipelineStatusCB& cb); | 66 const PipelineStatusCB& cb); |
| 67 | 67 |
| 68 // DemuxerStream methods. | 68 // DemuxerStream methods. |
| 69 virtual void Read(const ReadCallback& read_callback); | 69 virtual void Read(const ReadCallback& read_callback); |
| 70 virtual Type type(); | 70 virtual Type type(); |
| 71 virtual const MediaFormat& media_format(); | |
| 72 virtual void EnableBitstreamConverter(); | 71 virtual void EnableBitstreamConverter(); |
| 73 virtual AVStream* GetAVStream(); | 72 virtual AVStream* GetAVStream(); |
| 74 | 73 |
| 75 private: | 74 private: |
| 76 // Returns a pointer to the current stream. | 75 // Returns a pointer to the current stream. |
| 77 DemuxerStream* current_stream(); | 76 DemuxerStream* current_stream(); |
| 78 | 77 |
| 79 // DEBUG_MODE-only CHECK that the data members are in a reasonable state. | 78 // DEBUG_MODE-only CHECK that the data members are in a reasonable state. |
| 80 void DCheckSanity(); | 79 void DCheckSanity(); |
| 81 | 80 |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 | 256 |
| 258 private: | 257 private: |
| 259 scoped_ptr<DemuxerFactory> delegate_factory_; | 258 scoped_ptr<DemuxerFactory> delegate_factory_; |
| 260 | 259 |
| 261 DISALLOW_IMPLICIT_CONSTRUCTORS(AdaptiveDemuxerFactory); | 260 DISALLOW_IMPLICIT_CONSTRUCTORS(AdaptiveDemuxerFactory); |
| 262 }; | 261 }; |
| 263 | 262 |
| 264 } // namespace media | 263 } // namespace media |
| 265 | 264 |
| 266 #endif // MEDIA_FILTERS_ADAPTIVE_DEMUXER_H_ | 265 #endif // MEDIA_FILTERS_ADAPTIVE_DEMUXER_H_ |
| OLD | NEW |