Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1081)

Unified Diff: media/filters/chunk_demuxer.cc

Issue 125543002: Add plumbing and support for crossfading StreamParserBuffers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ChunkDemuxerStream. Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/base/stream_parser_buffer.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/chunk_demuxer.cc
diff --git a/media/filters/chunk_demuxer.cc b/media/filters/chunk_demuxer.cc
index f5fcf7dac7c7ca3995256ac9e2b01c4194a6cac5..939284200dc3d670e867b93010c95b245d7b46da 100644
--- a/media/filters/chunk_demuxer.cc
+++ b/media/filters/chunk_demuxer.cc
@@ -301,11 +301,12 @@ class ChunkDemuxerStream : public DemuxerStream {
void CompletePendingReadIfPossible_Locked();
- // Gets the value to pass to the next Read() callback. Returns true if
- // |status| and |buffer| should be passed to the callback. False indicates
- // that |status| and |buffer| were not set and more data is needed.
- bool GetNextBuffer_Locked(DemuxerStream::Status* status,
- scoped_refptr<StreamParserBuffer>* buffer);
+ // Retrieves a new buffer from SourceBufferStream::GetNextBuffer() and handles
+ // splice frame buffers. For normal buffers, the status is simply passed
+ // through. Splice frame buffers will return kSuccess for buffer within the
+ // crossfade along with a kConfigChange in between fade out and fade in.
+ SourceBufferStream::Status GetNextBuffer_Locked(
+ scoped_refptr<StreamParserBuffer>* buffer);
// Specifies the type of the stream.
Type type_;
@@ -316,6 +317,15 @@ class ChunkDemuxerStream : public DemuxerStream {
State state_;
ReadCB read_cb_;
+ // Used by GetNextBuffer_Locked() when a buffer with fade out is returned from
+ // the SourceBufferStream. Will be set to the returned buffer and will be
+ // consumed after the fade out section has been exhausted.
+ scoped_refptr<StreamParserBuffer> fade_in_buffer_;
+
+ // Indicates which of the fade out preroll buffers in |fade_in_buffer_| should
+ // be handled out next.
+ size_t fade_out_preroll_index_;
+
DISALLOW_IMPLICIT_CONSTRUCTORS(ChunkDemuxerStream);
};
@@ -749,7 +759,8 @@ void SourceState::FilterWithAppendWindow(
ChunkDemuxerStream::ChunkDemuxerStream(Type type)
: type_(type),
- state_(UNINITIALIZED) {
+ state_(UNINITIALIZED),
+ fade_out_preroll_index_(0) {
}
void ChunkDemuxerStream::StartReturningData() {
@@ -757,6 +768,8 @@ void ChunkDemuxerStream::StartReturningData() {
base::AutoLock auto_lock(lock_);
DCHECK(read_cb_.is_null());
ChangeState_Locked(RETURNING_DATA_FOR_READS);
+ fade_in_buffer_ = NULL;
+ fade_out_preroll_index_ = 0;
}
void ChunkDemuxerStream::AbortReads() {
@@ -967,7 +980,7 @@ void ChunkDemuxerStream::CompletePendingReadIfPossible_Locked() {
NOTREACHED();
return;
case RETURNING_DATA_FOR_READS:
- switch (stream_->GetNextBuffer(&buffer)) {
+ switch (GetNextBuffer_Locked(&buffer)) {
case SourceBufferStream::kSuccess:
status = DemuxerStream::kOk;
break;
@@ -1002,6 +1015,51 @@ void ChunkDemuxerStream::CompletePendingReadIfPossible_Locked() {
base::ResetAndReturn(&read_cb_).Run(status, buffer);
}
+SourceBufferStream::Status ChunkDemuxerStream::GetNextBuffer_Locked(
+ scoped_refptr<StreamParserBuffer>* out_buffer) {
+ lock_.AssertAcquired();
+
+ if (!fade_in_buffer_) {
+ const SourceBufferStream::Status status =
+ stream_->GetNextBuffer(out_buffer);
+
+ // Just return if GetNextBuffer() failed or there's no fade out preroll,
+ // there's nothing else to do.
+ if (status != SourceBufferStream::kSuccess ||
+ (*out_buffer)->GetFadeOutPreroll().empty()) {
+ return status;
+ }
+
+ // Setup fade in buffer and fall through into splice frame buffer handling.
+ fade_out_preroll_index_ = 0;
+ fade_in_buffer_ = *out_buffer;
+ }
+
+ DCHECK(fade_in_buffer_);
+ const size_t fade_out_size = fade_in_buffer_->GetFadeOutPreroll().size();
+
+ // Are there any fade out buffers left to hand out?
+ if (fade_out_preroll_index_ < fade_out_size) {
+ *out_buffer =
acolwell GONE FROM CHROMIUM 2014/01/08 18:13:26 I think you need to be careful here because I beli
DaleCurtis 2014/01/08 18:45:55 Ah you're right on both counts. Crap; this will pr
DaleCurtis 2014/01/08 22:23:52 Actually, we could keep the code here if we extend
DaleCurtis 2014/01/08 23:00:38 Ahgh, an issue with this idea is when the next buf
+ fade_in_buffer_->GetFadeOutPreroll()[fade_out_preroll_index_++];
+ return SourceBufferStream::kSuccess;
+ }
+
+ // Did we hand out the last fade out buffer on the last call?
+ if (fade_out_preroll_index_ == fade_out_size) {
+ fade_out_preroll_index_++;
+ return SourceBufferStream::kConfigChange;
+ }
+
+ // All fade out buffers have been handed out and a config change completed, so
+ // hand out the final buffer for fade in.
+ DCHECK_GT(fade_out_preroll_index_, fade_out_size);
+ *out_buffer = fade_in_buffer_;
+ fade_in_buffer_ = NULL;
+ fade_out_preroll_index_ = 0;
+ return SourceBufferStream::kSuccess;
+}
+
ChunkDemuxer::ChunkDemuxer(const base::Closure& open_cb,
const NeedKeyCB& need_key_cb,
const LogCB& log_cb)
« no previous file with comments | « media/base/stream_parser_buffer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698