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

Unified Diff: content/renderer/media/websourcebuffer_impl.cc

Issue 191513002: Extract coded frame processing from SourceState into LegacyFrameProcessor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase and address PS2 comments and nits Created 6 years, 9 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: content/renderer/media/websourcebuffer_impl.cc
diff --git a/content/renderer/media/websourcebuffer_impl.cc b/content/renderer/media/websourcebuffer_impl.cc
index a90f478327736fe1908ce711113057aa60ec0ee7..2ecaa0d3f13214345e116712af52f3b0291d901a 100644
--- a/content/renderer/media/websourcebuffer_impl.cc
+++ b/content/renderer/media/websourcebuffer_impl.cc
@@ -30,7 +30,8 @@ static base::TimeDelta DoubleToTimeDelta(double time) {
WebSourceBufferImpl::WebSourceBufferImpl(
const std::string& id, media::ChunkDemuxer* demuxer)
: id_(id),
- demuxer_(demuxer) {
+ demuxer_(demuxer),
+ append_window_end_(media::kInfiniteDuration()) {
DCHECK(demuxer_);
}
@@ -39,16 +40,22 @@ WebSourceBufferImpl::~WebSourceBufferImpl() {
}
bool WebSourceBufferImpl::setMode(WebSourceBuffer::AppendMode mode) {
- bool sequence_mode = false;
+ if (demuxer_->IsParsingMediaSegment(id_))
+ return false;
+
switch (mode) {
case WebSourceBuffer::AppendModeSegments:
+ demuxer_->SetSequenceMode(id_, false);
+ return true;
break;
acolwell GONE FROM CHROMIUM 2014/03/11 20:00:37 nit: remove break here and below.
wolenetz 2014/03/12 00:46:14 Done in the prereq CL I split out of this one.
case WebSourceBuffer::AppendModeSequence:
- sequence_mode = true;
+ demuxer_->SetSequenceMode(id_, true);
+ return true;
break;
}
- return demuxer_->SetSequenceMode(id_, sequence_mode);
+ NOTREACHED();
+ return false;
}
blink::WebTimeRanges WebSourceBufferImpl::buffered() {
@@ -65,7 +72,18 @@ void WebSourceBufferImpl::append(
const unsigned char* data,
unsigned length,
double* timestamp_offset) {
- demuxer_->AppendData(id_, data, length, timestamp_offset);
+ base::TimeDelta old_offset = timestamp_offset_;
+ demuxer_->AppendData(id_, data, length,
+ append_window_start_, append_window_end_,
+ &timestamp_offset_);
+
+ // Coded frame processing may update the timestamp offset. If the caller
+ // provides a non-NULL |timestamp_offset| and frame processing changes the
+ // timestamp offset, report the new offset to the caller. Do not update the
+ // caller's offset otherwise, to preserve any pre-existing value that may have
+ // more than microsecond precision.
+ if (timestamp_offset && old_offset != timestamp_offset_)
+ *timestamp_offset = timestamp_offset_.InSecondsF();
}
void WebSourceBufferImpl::abort() {
@@ -77,17 +95,19 @@ void WebSourceBufferImpl::remove(double start, double end) {
}
bool WebSourceBufferImpl::setTimestampOffset(double offset) {
- base::TimeDelta time_offset = base::TimeDelta::FromMicroseconds(
- offset * base::Time::kMicrosecondsPerSecond);
- return demuxer_->SetTimestampOffset(id_, time_offset);
+ if (demuxer_->IsParsingMediaSegment(id_))
+ return false;
+
+ timestamp_offset_ = DoubleToTimeDelta(offset);
+ return true;
}
void WebSourceBufferImpl::setAppendWindowStart(double start) {
- demuxer_->SetAppendWindowStart(id_, DoubleToTimeDelta(start));
+ append_window_start_ = DoubleToTimeDelta(start);
}
void WebSourceBufferImpl::setAppendWindowEnd(double end) {
- demuxer_->SetAppendWindowEnd(id_, DoubleToTimeDelta(end));
+ append_window_end_ = DoubleToTimeDelta(end);
}
void WebSourceBufferImpl::removedFromMediaSource() {

Powered by Google App Engine
This is Rietveld 408576698