Index: media/filters/source_buffer_stream.h |
diff --git a/media/filters/source_buffer_stream.h b/media/filters/source_buffer_stream.h |
index 3f4a2113c7bd572241cc0e993eb6548d2e7537bf..5b9097d506f36371dba5f64ff1171794319bb913 100644 |
--- a/media/filters/source_buffer_stream.h |
+++ b/media/filters/source_buffer_stream.h |
@@ -8,6 +8,7 @@ |
#include <deque> |
#include <list> |
#include <utility> |
+#include <vector> |
#include "base/memory/ref_counted.h" |
#include "media/base/audio_decoder_config.h" |
@@ -28,6 +29,17 @@ class MEDIA_EXPORT SourceBufferStream { |
public: |
typedef std::deque<scoped_refptr<StreamParserBuffer> > BufferQueue; |
+ // Status returned by GetNextBuffer(). |
+ // kSuccess: Indicates that the next buffer was returned. |
+ // kNeedBuffer: Indicates that we need more data before a buffer can be |
+ // returned. |
+ // kConfigChange: Indicates that the next buffer requires a config change. |
+ enum Status { |
+ kSuccess, |
+ kNeedBuffer, |
+ kConfigChange, |
+ }; |
+ |
explicit SourceBufferStream(const AudioDecoderConfig& audio_config); |
explicit SourceBufferStream(const VideoDecoderConfig& video_config); |
@@ -58,9 +70,10 @@ class MEDIA_EXPORT SourceBufferStream { |
// Seek() has not been called yet. |
// |out_buffer|'s timestamp may be earlier than the |timestamp| passed to |
// the last Seek() call. |
- // Returns true if |out_buffer| is filled with a valid buffer, false if |
- // there is not enough data buffered to fulfill the request. |
- bool GetNextBuffer(scoped_refptr<StreamParserBuffer>* out_buffer); |
+ // Returns kSuccess if |out_buffer| is filled with a valid buffer, kNeedBuffer |
+ // if there is not enough data buffered to fulfill the request, and |
+ // kConfigChange if the next buffer requires a config change. |
+ Status GetNextBuffer(scoped_refptr<StreamParserBuffer>* out_buffer); |
// Returns a list of the buffered time ranges. |
Ranges<base::TimeDelta> GetBufferedTime() const; |
@@ -76,12 +89,25 @@ class MEDIA_EXPORT SourceBufferStream { |
bool CanEndOfStream() const; |
const AudioDecoderConfig& GetCurrentAudioDecoderConfig() { |
- return audio_config_; |
+ return *audio_configs_[current_config_index_]; |
} |
const VideoDecoderConfig& GetCurrentVideoDecoderConfig() { |
- return video_config_; |
+ return *video_configs_[current_config_index_]; |
} |
+ // Notifies this object that the audio config has changed and buffers in |
+ // future Append() calls should be associated with this new config. |
+ bool UpdateAudioConfig(const AudioDecoderConfig& config); |
+ |
+ // Notifies this object that the video config has changed and buffers in |
+ // future Append() calls should be associated with this new config. |
+ bool UpdateVideoConfig(const VideoDecoderConfig& config); |
+ |
+ // Updates |current_config_index_| to match the index of the next buffer. |
+ // Calling this method causes GetNextBuffer() to stop returning kConfigChange |
+ // and start returning kSuccess. |
+ void UpdateCurrentConfigIndex(); |
+ |
// Returns the largest distance between two adjacent buffers in this stream, |
// or an estimate if no two adjacent buffers have been appended to the stream |
// yet. |
@@ -162,11 +188,16 @@ class MEDIA_EXPORT SourceBufferStream { |
// Measures the distances between buffer timestamps and tracks the max. |
void UpdateMaxInterbufferDistance(const BufferQueue& buffers); |
+ // Calls set_config_id() on each buffer with |append_config_index_|. |
vrk (LEFT CHROMIUM)
2012/07/12 19:37:55
nit: Since the "set_config_id()" method isn't in t
acolwell GONE FROM CHROMIUM
2012/07/12 23:07:58
Done.
|
+ void SetConfigIDs(const BufferQueue& buffers); |
xhwang
2012/07/12 18:09:12
s/ID/Id?
acolwell GONE FROM CHROMIUM
2012/07/12 23:07:58
Done.
|
+ |
// List of disjoint buffered ranges, ordered by start time. |
RangeList ranges_; |
- AudioDecoderConfig audio_config_; |
- VideoDecoderConfig video_config_; |
+ int current_config_index_; |
vrk (LEFT CHROMIUM)
2012/07/12 19:37:55
nit: add comments for new fields
acolwell GONE FROM CHROMIUM
2012/07/12 23:07:58
Done.
|
+ int append_config_index_; |
+ std::vector<AudioDecoderConfig*> audio_configs_; |
+ std::vector<VideoDecoderConfig*> video_configs_; |
// True if more data needs to be appended before the Seek() can complete, |
// false if no Seek() has been requested or the Seek() is completed. |