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

Side by Side Diff: media/blink/websourcebuffer_impl.cc

Issue 547223003: MSE: Notify Blink SourceBuffer on init segment received (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/blink/websourcebuffer_impl.h" 5 #include "media/blink/websourcebuffer_impl.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/bind.h"
10 #include "base/callback.h"
11 #include "base/callback_helpers.h"
9 #include "base/float_util.h" 12 #include "base/float_util.h"
10 #include "media/filters/chunk_demuxer.h" 13 #include "media/filters/chunk_demuxer.h"
14 #include "third_party/WebKit/public/platform/WebSourceBufferClient.h"
11 15
12 namespace media { 16 namespace media {
13 17
14 static base::TimeDelta DoubleToTimeDelta(double time) { 18 static base::TimeDelta DoubleToTimeDelta(double time) {
15 DCHECK(!base::IsNaN(time)); 19 DCHECK(!base::IsNaN(time));
16 DCHECK_NE(time, -std::numeric_limits<double>::infinity()); 20 DCHECK_NE(time, -std::numeric_limits<double>::infinity());
17 21
18 if (time == std::numeric_limits<double>::infinity()) 22 if (time == std::numeric_limits<double>::infinity())
19 return kInfiniteDuration(); 23 return kInfiniteDuration();
20 24
21 // Don't use base::TimeDelta::Max() here, as we want the largest finite time 25 // Don't use base::TimeDelta::Max() here, as we want the largest finite time
22 // delta. 26 // delta.
23 base::TimeDelta max_time = base::TimeDelta::FromInternalValue(kint64max - 1); 27 base::TimeDelta max_time = base::TimeDelta::FromInternalValue(kint64max - 1);
24 double max_time_in_seconds = max_time.InSecondsF(); 28 double max_time_in_seconds = max_time.InSecondsF();
25 29
26 if (time >= max_time_in_seconds) 30 if (time >= max_time_in_seconds)
27 return max_time; 31 return max_time;
28 32
29 return base::TimeDelta::FromMicroseconds( 33 return base::TimeDelta::FromMicroseconds(
30 time * base::Time::kMicrosecondsPerSecond); 34 time * base::Time::kMicrosecondsPerSecond);
31 } 35 }
32 36
33 WebSourceBufferImpl::WebSourceBufferImpl( 37 WebSourceBufferImpl::WebSourceBufferImpl(
34 const std::string& id, ChunkDemuxer* demuxer) 38 const std::string& id, ChunkDemuxer* demuxer)
35 : id_(id), 39 : id_(id),
36 demuxer_(demuxer), 40 demuxer_(demuxer),
41 client_(NULL),
37 append_window_end_(kInfiniteDuration()) { 42 append_window_end_(kInfiniteDuration()) {
38 DCHECK(demuxer_); 43 DCHECK(demuxer_);
39 } 44 }
40 45
41 WebSourceBufferImpl::~WebSourceBufferImpl() { 46 WebSourceBufferImpl::~WebSourceBufferImpl() {
42 DCHECK(!demuxer_) << "Object destroyed w/o removedFromMediaSource() call"; 47 DCHECK(!demuxer_) << "Object destroyed w/o removedFromMediaSource() call";
48 DCHECK(!client_);
49 }
50
51 void WebSourceBufferImpl::setClient(blink::WebSourceBufferClient* client) {
52 DVLOG(0) << __FUNCTION__ << "BIG TODO remove this logging... client is: " << c lient;
53 client_ = client;
43 } 54 }
44 55
45 bool WebSourceBufferImpl::setMode(WebSourceBuffer::AppendMode mode) { 56 bool WebSourceBufferImpl::setMode(WebSourceBuffer::AppendMode mode) {
46 if (demuxer_->IsParsingMediaSegment(id_)) 57 if (demuxer_->IsParsingMediaSegment(id_))
47 return false; 58 return false;
48 59
49 switch (mode) { 60 switch (mode) {
50 case WebSourceBuffer::AppendModeSegments: 61 case WebSourceBuffer::AppendModeSegments:
51 demuxer_->SetSequenceMode(id_, false); 62 demuxer_->SetSequenceMode(id_, false);
52 return true; 63 return true;
(...skipping 16 matching lines...) Expand all
69 return result; 80 return result;
70 } 81 }
71 82
72 void WebSourceBufferImpl::append( 83 void WebSourceBufferImpl::append(
73 const unsigned char* data, 84 const unsigned char* data,
74 unsigned length, 85 unsigned length,
75 double* timestamp_offset) { 86 double* timestamp_offset) {
76 base::TimeDelta old_offset = timestamp_offset_; 87 base::TimeDelta old_offset = timestamp_offset_;
77 demuxer_->AppendData(id_, data, length, 88 demuxer_->AppendData(id_, data, length,
78 append_window_start_, append_window_end_, 89 append_window_start_, append_window_end_,
79 &timestamp_offset_); 90 &timestamp_offset_,
91 base::Bind(&WebSourceBufferImpl::InitSegmentReceived,
92 base::Unretained(this)));
80 93
81 // Coded frame processing may update the timestamp offset. If the caller 94 // Coded frame processing may update the timestamp offset. If the caller
82 // provides a non-NULL |timestamp_offset| and frame processing changes the 95 // provides a non-NULL |timestamp_offset| and frame processing changes the
83 // timestamp offset, report the new offset to the caller. Do not update the 96 // timestamp offset, report the new offset to the caller. Do not update the
84 // caller's offset otherwise, to preserve any pre-existing value that may have 97 // caller's offset otherwise, to preserve any pre-existing value that may have
85 // more than microsecond precision. 98 // more than microsecond precision.
86 if (timestamp_offset && old_offset != timestamp_offset_) 99 if (timestamp_offset && old_offset != timestamp_offset_)
87 *timestamp_offset = timestamp_offset_.InSecondsF(); 100 *timestamp_offset = timestamp_offset_.InSecondsF();
88 } 101 }
89 102
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 void WebSourceBufferImpl::setAppendWindowEnd(double end) { 137 void WebSourceBufferImpl::setAppendWindowEnd(double end) {
125 DCHECK_GE(end, 0); 138 DCHECK_GE(end, 0);
126 append_window_end_ = DoubleToTimeDelta(end); 139 append_window_end_ = DoubleToTimeDelta(end);
127 } 140 }
128 141
129 void WebSourceBufferImpl::removedFromMediaSource() { 142 void WebSourceBufferImpl::removedFromMediaSource() {
130 demuxer_->RemoveId(id_); 143 demuxer_->RemoveId(id_);
131 demuxer_ = NULL; 144 demuxer_ = NULL;
132 } 145 }
133 146
147 void WebSourceBufferImpl::InitSegmentReceived() {
148 DVLOG(1) << __FUNCTION__;
149 client_->initializationSegmentReceived();
150 }
151
134 } // namespace media 152 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698