Chromium Code Reviews| Index: media/filters/adaptive_demuxer.h |
| diff --git a/media/filters/adaptive_demuxer.h b/media/filters/adaptive_demuxer.h |
| index 6402b039022a997d5b4c31002b3bbe10b5ab0338..dc39fcb788d71cb0c63f2ee0708abea9fc9e8c9e 100644 |
| --- a/media/filters/adaptive_demuxer.h |
| +++ b/media/filters/adaptive_demuxer.h |
| @@ -23,10 +23,15 @@ |
| namespace media { |
| class AdaptiveDemuxer; |
| +class StreamSwitchManager; |
| + |
| +typedef base::Callback<void(PipelineStatus, base::TimeDelta)> SeekHelperCB; |
|
Ami GONE FROM CHROMIUM
2011/05/19 20:27:37
Any reason these need to be outside in namespace s
Ami GONE FROM CHROMIUM
2011/05/19 20:27:37
Doco these typedefs.
Their naming is leaving me sc
acolwell GONE FROM CHROMIUM
2011/05/20 01:26:37
Done.
acolwell GONE FROM CHROMIUM
2011/05/20 01:26:37
Done.
|
| +typedef base::Callback<void(const base::TimeDelta&, SeekHelperCB)> SeekHelper; |
|
Ami GONE FROM CHROMIUM
2011/05/19 20:27:37
TimeDelta is an int64; no need to pass by const&.
acolwell GONE FROM CHROMIUM
2011/05/20 01:26:37
Done.
|
| class AdaptiveDemuxerStream : public DemuxerStream { |
| public: |
| typedef std::vector<scoped_refptr<DemuxerStream> > StreamVector; |
| + typedef std::deque<ReadCallback> ReadCBQueue; |
| // Keeps references to the passed-in streams. |streams| must be non-empty and |
| // all the streams in it must agree on type and media_format (or be NULL). |
| @@ -35,9 +40,13 @@ class AdaptiveDemuxerStream : public DemuxerStream { |
| AdaptiveDemuxerStream(StreamVector const& streams, int initial_stream); |
| virtual ~AdaptiveDemuxerStream(); |
| + // Notifies this stream that a Seek() was requested on the demuxer. |
| + void OnAdaptiveDemuxerSeek(); |
| + |
| // Change the stream to satisfy subsequent Read() requests from. The |
| // referenced pointer must not be NULL. |
| - void ChangeCurrentStream(int index); |
| + void ChangeCurrentStream(int index, const SeekHelper& seek_helper, |
| + const PipelineStatusCB& cb); |
| // DemuxerStream methods. |
| virtual void Read(const ReadCallback& read_callback); |
| @@ -53,6 +62,19 @@ class AdaptiveDemuxerStream : public DemuxerStream { |
| // DEBUG_MODE-only CHECK that the data members are in a reasonable state. |
| void DCheckSanity(); |
| + void OnReadDone(Buffer* buffer); |
| + |
| + bool IsSwitchPending_Locked() const; |
| + |
| + // Starts the stream switch. This method expects that no Read()s are |
| + // outstanding on | streams_[current_stream_index_] |. |
|
Ami GONE FROM CHROMIUM
2011/05/19 20:27:37
Inward-facing spaces around |'s are unnecessary (h
acolwell GONE FROM CHROMIUM
2011/05/20 01:26:37
Done.
|
| + void StartSwitch(); |
| + |
| + // Called by the SeekHelper when it has completed the seek on |
| + // | streams_[switch_index_] |. |
| + void OnSwitchSeekDone(PipelineStatus status, |
| + const base::TimeDelta& seek_time); |
| + |
| StreamVector streams_; |
| // Guards the members below. Only held for simple variable reads/writes, not |
| // during async operation. |
| @@ -60,12 +82,32 @@ class AdaptiveDemuxerStream : public DemuxerStream { |
| int current_stream_index_; |
| bool bitstream_converter_enabled_; |
| + // The number of outstanding Read()'s on streams_[current_stream_index_]. |
|
Ami GONE FROM CHROMIUM
2011/05/19 20:27:37
||'ify code in comments (here and elsewhere).
|
| + int pending_reads_; |
| + |
| + // A queue of callback objects passed to Read() calls on this object. |
| + ReadCBQueue read_cb_queue_; |
| + |
| + // Callback passed to ChangeCurrentStream(). This is called & reset when the |
| + // stream switch has completed. |
| + PipelineStatusCB switch_cb_; |
| + |
| + // The index of the stream we are switching to. |
|
Ami GONE FROM CHROMIUM
2011/05/19 20:27:37
Document value while not switching (or that value
acolwell GONE FROM CHROMIUM
2011/05/20 01:26:37
Done.
|
| + int switch_index_; |
| + |
| + // Helper object used to seek streams_|switch_index_| to a specific time. |
|
Ami GONE FROM CHROMIUM
2011/05/19 20:27:37
brackets instead of pipes
acolwell GONE FROM CHROMIUM
2011/05/20 01:26:37
Done.
|
| + SeekHelper switch_seek_helper_; |
| + |
| + // The timestamp of the last buffered returned via a Read() callback. |
|
Ami GONE FROM CHROMIUM
2011/05/19 20:27:37
s/buffered/buffer/
acolwell GONE FROM CHROMIUM
2011/05/20 01:26:37
Done.
|
| + base::TimeDelta last_buffer_timestamp_; |
| + |
| DISALLOW_IMPLICIT_CONSTRUCTORS(AdaptiveDemuxerStream); |
| }; |
| class AdaptiveDemuxer : public Demuxer { |
| public: |
| typedef std::vector<scoped_refptr<Demuxer> > DemuxerVector; |
| + typedef std::vector<int> StreamIdVector; |
| // |demuxers| must be non-empty, and the index arguments must be valid indexes |
| // into |demuxers|, or -1 to indicate no demuxer is serving that type. |
| @@ -74,8 +116,14 @@ class AdaptiveDemuxer : public Demuxer { |
| int initial_video_demuxer_index); |
| virtual ~AdaptiveDemuxer(); |
| - // Change which demuxers the streams will use. |
| - void ChangeCurrentDemuxer(int audio_index, int video_index); |
| + // Change the to a different video stream. |
|
Ami GONE FROM CHROMIUM
2011/05/19 20:27:37
English.
I think this is the first time you/we enf
acolwell GONE FROM CHROMIUM
2011/05/20 01:26:37
Done.
For now I'm constraining code to video only
|
| + void ChangeVideoStream(int video_id, const PipelineStatusCB& done_cb); |
| + |
| + // Get the ID of the current video stream. |
|
Ami GONE FROM CHROMIUM
2011/05/19 20:27:37
This and the next method: are they really necessar
acolwell GONE FROM CHROMIUM
2011/05/20 01:26:37
These were added so a StreamSwitchManager object c
|
| + int GetCurrentVideoId() const; |
| + |
| + // Get all of the video stream IDs. |
| + StreamIdVector GetVideoIds() const; |
| // Filter implementation. |
| virtual void Stop(FilterCallback* callback); |
| @@ -92,14 +140,43 @@ class AdaptiveDemuxer : public Demuxer { |
| // Returns a pointer to the currently active demuxer of the given type. |
| Demuxer* current_demuxer(DemuxerStream::Type type); |
| + // Called when the AdaptiveDemuxerStream completes a stream switch. |
| + void ChangeVideoStreamDone(int new_stream_index, |
| + const PipelineStatusCB& done_cb, |
| + PipelineStatus status); |
| + |
| + // Methods for SeekHelper. |
| + // Initial method called when the AdaptiveDemuxerStream calls the SeekHelper. |
| + void StartStreamSwitchSeek(DemuxerStream::Type type, |
| + int stream_index, |
| + const base::TimeDelta& seek_time, |
| + const SeekHelperCB& seek_cb); |
| + |
| + // Called when the seek for index data initiated by StartStreamSwitchSeek() |
| + // completes. |
| + void OnIndexSeekDone(DemuxerStream::Type type, |
| + int stream_index, |
| + const base::TimeDelta& seek_time, |
| + const SeekHelperCB& seek_cb, |
| + PipelineStatus status); |
| + |
| + // Called when the stream seek initiated by StartStreamSwitchSeek() or |
| + // OnIndexSeekDone() completes. |
| + void OnStreamSeekDone(const base::TimeDelta& seek_point, |
| + const SeekHelperCB& seek_cb, |
| + PipelineStatus status); |
| + |
| DemuxerVector demuxers_; |
| scoped_refptr<AdaptiveDemuxerStream> audio_stream_; |
| scoped_refptr<AdaptiveDemuxerStream> video_stream_; |
| // Guards the members below. Only held for simple variable reads/writes, not |
| // during async operation. |
| - base::Lock lock_; |
| + mutable base::Lock lock_; |
| int current_audio_demuxer_index_; |
| int current_video_demuxer_index_; |
| + float playback_rate_; |
| + bool switch_pending_; |
| + scoped_refptr<StreamSwitchManager> stream_switch_manager_; |
| DISALLOW_IMPLICIT_CONSTRUCTORS(AdaptiveDemuxer); |
| }; |