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

Unified Diff: media/base/stream_parser_buffer.cc

Issue 276573002: Add gapless playback support for AAC playback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Comments. Created 6 years, 7 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
Index: media/base/stream_parser_buffer.cc
diff --git a/media/base/stream_parser_buffer.cc b/media/base/stream_parser_buffer.cc
index 1d3440235488a9a241d75ac5530dc11e9cfcf11b..598cf55a402f86bcbcb26cb771d564131c145e50 100644
--- a/media/base/stream_parser_buffer.cc
+++ b/media/base/stream_parser_buffer.cc
@@ -67,8 +67,10 @@ base::TimeDelta StreamParserBuffer::GetDecodeTimestamp() const {
return decode_timestamp_;
}
-void StreamParserBuffer::SetDecodeTimestamp(const base::TimeDelta& timestamp) {
+void StreamParserBuffer::SetDecodeTimestamp(base::TimeDelta timestamp) {
decode_timestamp_ = timestamp;
+ if (preroll_buffer_)
+ preroll_buffer_->SetDecodeTimestamp(timestamp);
}
StreamParserBuffer::StreamParserBuffer(const uint8* data, int data_size,
@@ -97,6 +99,8 @@ int StreamParserBuffer::GetConfigId() const {
void StreamParserBuffer::SetConfigId(int config_id) {
config_id_ = config_id;
+ if (preroll_buffer_)
+ preroll_buffer_->SetConfigId(config_id);
}
void StreamParserBuffer::ConvertToSpliceBuffer(
@@ -118,6 +122,12 @@ void StreamParserBuffer::ConvertToSpliceBuffer(
// that implies EOS care must be taken to ensure there are no clients relying
// on that behavior.
+ // Move over any preroll from this buffer.
+ if (preroll_buffer_) {
+ DCHECK(!overlapping_buffer->preroll_buffer_);
+ overlapping_buffer->preroll_buffer_.swap(preroll_buffer_);
+ }
+
// Rewrite |this| buffer as a splice buffer.
SetDecodeTimestamp(first_splice_buffer->GetDecodeTimestamp());
SetConfigId(first_splice_buffer->GetConfigId());
@@ -141,6 +151,7 @@ void StreamParserBuffer::ConvertToSpliceBuffer(
++it) {
const scoped_refptr<StreamParserBuffer>& buffer = *it;
DCHECK(!buffer->end_of_stream());
+ DCHECK(!buffer->preroll_buffer());
DCHECK(buffer->splice_buffers().empty());
splice_buffers_.push_back(CopyBuffer(*buffer));
splice_buffers_.back()->set_splice_timestamp(splice_timestamp());
@@ -149,4 +160,33 @@ void StreamParserBuffer::ConvertToSpliceBuffer(
splice_buffers_.push_back(overlapping_buffer);
}
+void StreamParserBuffer::SetPrerollBuffer(
+ const scoped_refptr<StreamParserBuffer>& preroll_buffer) {
+ DCHECK(!preroll_buffer_);
+ DCHECK(!end_of_stream());
+ DCHECK(!preroll_buffer->end_of_stream());
+ DCHECK(!preroll_buffer->preroll_buffer_);
+ DCHECK(preroll_buffer->splice_timestamp() == kNoTimestamp());
+ DCHECK(preroll_buffer->splice_buffers().empty());
+ DCHECK(preroll_buffer->timestamp() <= timestamp());
wolenetz 2014/05/23 19:59:45 Please add DCHECK(preroll_buffer->GetDecodeTimesta
DaleCurtis 2014/05/23 21:46:26 Currently I ignore the decode timestamp on the pre
+ DCHECK(preroll_buffer->discard_padding() == DecoderBuffer::DiscardPadding());
+ DCHECK_EQ(preroll_buffer->type(), type());
+
+ preroll_buffer_ = preroll_buffer;
+ preroll_buffer_->track_id_ = track_id_;
acolwell GONE FROM CHROMIUM 2014/05/23 17:27:30 Why do you have to do this? I would expect these b
DaleCurtis 2014/05/23 21:46:26 I was just wholesale copying here, looking at it m
+ preroll_buffer_->set_timestamp(timestamp());
+ preroll_buffer_->SetDecodeTimestamp(GetDecodeTimestamp());
+ preroll_buffer_->SetConfigId(GetConfigId());
acolwell GONE FROM CHROMIUM 2014/05/23 17:27:30 Why do you need this? It seems like there would be
DaleCurtis 2014/05/23 21:46:26 Because a config ID hasn't yet been assigned to th
acolwell GONE FROM CHROMIUM 2014/05/24 00:58:20 ok, but isn't this method always called before the
DaleCurtis 2014/05/27 23:59:32 Oh I see what you're saying. Yes this is useless,
+
+ // Mark the entire buffer for discard.
+ preroll_buffer_->set_discard_padding(
+ std::make_pair(kInfiniteDuration(), base::TimeDelta()));
+}
+
+void StreamParserBuffer::set_timestamp(base::TimeDelta timestamp) {
+ DecoderBuffer::set_timestamp(timestamp);
+ if (preroll_buffer_)
+ preroll_buffer_->set_timestamp(timestamp);
+}
+
} // namespace media

Powered by Google App Engine
This is Rietveld 408576698