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

Unified Diff: media/filters/chunk_demuxer.cc

Issue 547223003: MSE: Notify Blink SourceBuffer on init segment received (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed nits. Plan is to depend on blink-side CL landing first (https://codereview.chromium.org/55294… Created 6 years, 3 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/filters/chunk_demuxer.cc
diff --git a/media/filters/chunk_demuxer.cc b/media/filters/chunk_demuxer.cc
index 0ff996db7398bb3f243d602a96a02d2f3d1813bc..3332c9fd914b73fb30186df8f684ae95d5576a26 100644
--- a/media/filters/chunk_demuxer.cc
+++ b/media/filters/chunk_demuxer.cc
@@ -90,6 +90,8 @@ class SourceState {
typedef base::Callback<ChunkDemuxerStream*(
DemuxerStream::Type)> CreateDemuxerStreamCB;
+ typedef ChunkDemuxer::InitSegmentReceivedCB InitSegmentReceivedCB;
+
typedef base::Callback<void(
ChunkDemuxerStream*, const TextTrackConfig&)> NewTextTrackCB;
@@ -111,11 +113,14 @@ class SourceState {
// error occurred. |*timestamp_offset| is used and possibly updated by the
// append. |append_window_start| and |append_window_end| correspond to the MSE
// spec's similarly named source buffer attributes that are used in coded
- // frame processing.
- bool Append(const uint8* data, size_t length,
+ // frame processing. |init_segment_received_cb| is run for each new fully
+ // parsed initialization segment.
+ bool Append(const uint8* data,
+ size_t length,
TimeDelta append_window_start,
TimeDelta append_window_end,
- TimeDelta* timestamp_offset);
+ TimeDelta* timestamp_offset,
+ const InitSegmentReceivedCB& init_segment_received_cb);
// Aborts the current append sequence and resets the parser.
void Abort(TimeDelta append_window_start,
@@ -199,6 +204,13 @@ class SourceState {
// during the lifetime of an Append() call.
TimeDelta* timestamp_offset_during_append_;
+ // During Append(), OnNewConfigs() will trigger the initialization segment
+ // received algorithm. This callback is only non-NULL during the lifetime of
+ // an Append() call. Note, the MSE spec explicitly disallows this algorithm
+ // during an Abort(), since Abort() is allowed only to emit coded frames, and
+ // only if the parser is PARSING_MEDIA_SEGMENT (not an INIT segment).
+ InitSegmentReceivedCB init_segment_received_cb_during_append_;
acolwell GONE FROM CHROMIUM 2014/09/10 18:02:38 nit: move cb_ to the end like all the other callba
wolenetz 2014/09/11 22:40:37 Done.
+
// During Append(), coded frame processing triggered by OnNewBuffers()
// requires these two attributes. These are only valid during the lifetime of
// an Append() call.
@@ -299,20 +311,27 @@ void SourceState::SetGroupStartTimestampIfInSequenceMode(
frame_processor_->SetGroupStartTimestampIfInSequenceMode(timestamp_offset);
}
-bool SourceState::Append(const uint8* data, size_t length,
- TimeDelta append_window_start,
- TimeDelta append_window_end,
- TimeDelta* timestamp_offset) {
+bool SourceState::Append(
+ const uint8* data,
+ size_t length,
+ TimeDelta append_window_start,
+ TimeDelta append_window_end,
+ TimeDelta* timestamp_offset,
+ const InitSegmentReceivedCB& init_segment_received_cb) {
DCHECK(timestamp_offset);
DCHECK(!timestamp_offset_during_append_);
+ DCHECK(init_segment_received_cb_during_append_.is_null());
+ DCHECK(!init_segment_received_cb.is_null());
append_window_start_during_append_ = append_window_start;
append_window_end_during_append_ = append_window_end;
timestamp_offset_during_append_ = timestamp_offset;
+ init_segment_received_cb_during_append_ = init_segment_received_cb;
// TODO(wolenetz/acolwell): Curry and pass a NewBuffersCB here bound with
// append window and timestamp offset pointer. See http://crbug.com/351454.
bool err = stream_parser_->Parse(data, length);
timestamp_offset_during_append_ = NULL;
+ init_segment_received_cb_during_append_.Reset();
return err;
}
@@ -665,6 +684,9 @@ bool SourceState::OnNewConfigs(
frame_processor_->SetAllTrackBuffersNeedRandomAccessPoint();
DVLOG(1) << "OnNewConfigs() : " << (success ? "success" : "failed");
+ if (success)
+ init_segment_received_cb_during_append_.Run();
damienv1 2014/09/10 18:41:03 Can you DCHECK(!init_segment_received_cb_during_ap
wolenetz 2014/09/11 22:40:37 I'm confused. Running an is_null() callback should
wolenetz 2014/09/13 00:41:25 Done.
+
return success;
}
@@ -1229,15 +1251,19 @@ Ranges<TimeDelta> ChunkDemuxer::GetBufferedRanges(const std::string& id) const {
return itr->second->GetBufferedRanges(duration_, state_ == ENDED);
}
-void ChunkDemuxer::AppendData(const std::string& id,
- const uint8* data, size_t length,
- TimeDelta append_window_start,
- TimeDelta append_window_end,
- TimeDelta* timestamp_offset) {
+void ChunkDemuxer::AppendData(
+ const std::string& id,
+ const uint8* data,
+ size_t length,
+ TimeDelta append_window_start,
+ TimeDelta append_window_end,
+ TimeDelta* timestamp_offset,
+ const InitSegmentReceivedCB& init_segment_received_cb) {
DVLOG(1) << "AppendData(" << id << ", " << length << ")";
DCHECK(!id.empty());
DCHECK(timestamp_offset);
+ DCHECK(!init_segment_received_cb.is_null());
Ranges<TimeDelta> ranges;
@@ -1260,7 +1286,8 @@ void ChunkDemuxer::AppendData(const std::string& id,
if (!source_state_map_[id]->Append(data, length,
append_window_start,
append_window_end,
- timestamp_offset)) {
+ timestamp_offset,
+ init_segment_received_cb)) {
ReportError_Locked(DEMUXER_ERROR_COULD_NOT_OPEN);
return;
}
@@ -1271,7 +1298,8 @@ void ChunkDemuxer::AppendData(const std::string& id,
if (!source_state_map_[id]->Append(data, length,
append_window_start,
append_window_end,
- timestamp_offset)) {
+ timestamp_offset,
+ init_segment_received_cb)) {
ReportError_Locked(PIPELINE_ERROR_DECODE);
return;
}

Powered by Google App Engine
This is Rietveld 408576698