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

Unified Diff: media/filters/frame_processor_base.cc

Issue 276573002: Add gapless playback support for AAC playback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix msvc error. 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
« no previous file with comments | « media/filters/frame_processor_base.h ('k') | media/filters/legacy_frame_processor.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/frame_processor_base.cc
diff --git a/media/filters/frame_processor_base.cc b/media/filters/frame_processor_base.cc
index 09b1b86c3b39011ce2d0a6cc406ebc80af98ef15..51888a25e656ab52a011637fe1924ad504fcfaba 100644
--- a/media/filters/frame_processor_base.cc
+++ b/media/filters/frame_processor_base.cc
@@ -97,4 +97,70 @@ void FrameProcessorBase::NotifyNewMediaSegmentStarting(
}
}
+bool FrameProcessorBase::HandlePartialAppendWindowTrimming(
+ base::TimeDelta append_window_start,
+ base::TimeDelta append_window_end,
+ const scoped_refptr<StreamParserBuffer>& buffer) {
+ DCHECK(buffer->duration() > base::TimeDelta());
+ DCHECK_EQ(DemuxerStream::AUDIO, buffer->type());
+
+ const base::TimeDelta frame_end_timestamp =
+ buffer->timestamp() + buffer->duration();
+
+ // Ignore any buffers which start after |append_window_start| or end after
+ // |append_window_end|. For simplicity, even those that start before
+ // |append_window_start|.
+ if (buffer->timestamp() > append_window_start ||
+ frame_end_timestamp > append_window_end) {
+ // TODO(dalecurtis): Partial append window trimming could also be done
+ // around |append_window_end|, but is not necessary since splice frames
+ // cover overlaps there.
+ return false;
+ }
+
+ // If the buffer is entirely before |append_window_start|, save it as preroll
+ // for the first buffer which overlaps |append_window_start|.
+ if (buffer->timestamp() < append_window_start &&
+ frame_end_timestamp <= append_window_start) {
+ audio_preroll_buffer_ = buffer;
+ return false;
+ }
+
+ // See if a partial discard can be done around |append_window_start|.
+ DCHECK(buffer->timestamp() <= append_window_start);
+ DCHECK(buffer->IsKeyframe());
+ DVLOG(1) << "Truncating buffer which overlaps append window start."
+ << " presentation_timestamp " << buffer->timestamp().InSecondsF()
+ << " append_window_start " << append_window_start.InSecondsF();
+
+ // If this isn't the first buffer discarded by the append window, try to use
+ // the last buffer discarded for preroll. This ensures that the partially
+ // trimmed buffer can be correctly decoded.
+ if (audio_preroll_buffer_) {
+ if (audio_preroll_buffer_->timestamp() +
+ audio_preroll_buffer_->duration() ==
+ buffer->timestamp()) {
+ buffer->SetPrerollBuffer(audio_preroll_buffer_);
+ } else {
+ // TODO(dalecurtis): Add a MEDIA_LOG() for when this is dropped unused.
+ }
+ audio_preroll_buffer_ = NULL;
+ }
+
+ // Decrease the duration appropriately. We only need to shorten the buffer if
+ // it overlaps |append_window_start|.
+ if (buffer->timestamp() < append_window_start) {
+ buffer->set_discard_padding(std::make_pair(
+ append_window_start - buffer->timestamp(), base::TimeDelta()));
+ buffer->set_duration(frame_end_timestamp - append_window_start);
+ }
+
+ // Adjust the timestamp of this buffer forward to |append_window_start|. The
+ // timestamps are always set, even if |buffer|'s timestamp is already set to
+ // |append_window_start|, to ensure the preroll buffer is setup correctly.
+ buffer->set_timestamp(append_window_start);
+ buffer->SetDecodeTimestamp(append_window_start);
+ return true;
+}
+
} // namespace media
« no previous file with comments | « media/filters/frame_processor_base.h ('k') | media/filters/legacy_frame_processor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698