OLD | NEW |
---|---|
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 <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <cmath> | 9 #include <cmath> |
10 #include <limits> | 10 #include <limits> |
(...skipping 28 matching lines...) Expand all Loading... | |
39 time * base::Time::kMicrosecondsPerSecond); | 39 time * base::Time::kMicrosecondsPerSecond); |
40 } | 40 } |
41 | 41 |
42 WebSourceBufferImpl::WebSourceBufferImpl( | 42 WebSourceBufferImpl::WebSourceBufferImpl( |
43 const std::string& id, ChunkDemuxer* demuxer) | 43 const std::string& id, ChunkDemuxer* demuxer) |
44 : id_(id), | 44 : id_(id), |
45 demuxer_(demuxer), | 45 demuxer_(demuxer), |
46 client_(NULL), | 46 client_(NULL), |
47 append_window_end_(kInfiniteDuration()) { | 47 append_window_end_(kInfiniteDuration()) { |
48 DCHECK(demuxer_); | 48 DCHECK(demuxer_); |
49 demuxer_->SetTracksWatcher( | |
wolenetz
2016/03/05 01:47:43
This seems like a method that could be elevated to
| |
50 id, base::Bind(&WebSourceBufferImpl::InitSegmentReceived, | |
51 base::Unretained(this))); | |
49 } | 52 } |
50 | 53 |
51 WebSourceBufferImpl::~WebSourceBufferImpl() { | 54 WebSourceBufferImpl::~WebSourceBufferImpl() { |
52 DCHECK(!demuxer_) << "Object destroyed w/o removedFromMediaSource() call"; | 55 DCHECK(!demuxer_) << "Object destroyed w/o removedFromMediaSource() call"; |
53 DCHECK(!client_); | 56 DCHECK(!client_); |
54 } | 57 } |
55 | 58 |
56 void WebSourceBufferImpl::setClient(blink::WebSourceBufferClient* client) { | 59 void WebSourceBufferImpl::setClient(blink::WebSourceBufferClient* client) { |
57 DCHECK(client); | 60 DCHECK(client); |
58 DCHECK(!client_); | 61 DCHECK(!client_); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
92 id_, | 95 id_, |
93 base::TimeDelta::FromSecondsD(currentPlaybackTime), | 96 base::TimeDelta::FromSecondsD(currentPlaybackTime), |
94 newDataSize); | 97 newDataSize); |
95 } | 98 } |
96 | 99 |
97 void WebSourceBufferImpl::append( | 100 void WebSourceBufferImpl::append( |
98 const unsigned char* data, | 101 const unsigned char* data, |
99 unsigned length, | 102 unsigned length, |
100 double* timestamp_offset) { | 103 double* timestamp_offset) { |
101 base::TimeDelta old_offset = timestamp_offset_; | 104 base::TimeDelta old_offset = timestamp_offset_; |
102 demuxer_->AppendData(id_, data, length, | 105 demuxer_->AppendData(id_, data, length, append_window_start_, |
103 append_window_start_, append_window_end_, | 106 append_window_end_, ×tamp_offset_); |
104 ×tamp_offset_, | |
105 base::Bind(&WebSourceBufferImpl::InitSegmentReceived, | |
106 base::Unretained(this))); | |
107 | 107 |
108 // Coded frame processing may update the timestamp offset. If the caller | 108 // Coded frame processing may update the timestamp offset. If the caller |
109 // provides a non-NULL |timestamp_offset| and frame processing changes the | 109 // provides a non-NULL |timestamp_offset| and frame processing changes the |
110 // timestamp offset, report the new offset to the caller. Do not update the | 110 // timestamp offset, report the new offset to the caller. Do not update the |
111 // caller's offset otherwise, to preserve any pre-existing value that may have | 111 // caller's offset otherwise, to preserve any pre-existing value that may have |
112 // more than microsecond precision. | 112 // more than microsecond precision. |
113 if (timestamp_offset && old_offset != timestamp_offset_) | 113 if (timestamp_offset && old_offset != timestamp_offset_) |
114 *timestamp_offset = timestamp_offset_.InSecondsF(); | 114 *timestamp_offset = timestamp_offset_.InSecondsF(); |
115 } | 115 } |
116 | 116 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
152 DCHECK_GE(end, 0); | 152 DCHECK_GE(end, 0); |
153 append_window_end_ = DoubleToTimeDelta(end); | 153 append_window_end_ = DoubleToTimeDelta(end); |
154 } | 154 } |
155 | 155 |
156 void WebSourceBufferImpl::removedFromMediaSource() { | 156 void WebSourceBufferImpl::removedFromMediaSource() { |
157 demuxer_->RemoveId(id_); | 157 demuxer_->RemoveId(id_); |
158 demuxer_ = NULL; | 158 demuxer_ = NULL; |
159 client_ = NULL; | 159 client_ = NULL; |
160 } | 160 } |
161 | 161 |
162 void WebSourceBufferImpl::InitSegmentReceived(const MediaTracks& tracks) { | 162 void WebSourceBufferImpl::InitSegmentReceived(scoped_ptr<MediaTracks> tracks) { |
163 DVLOG(1) << __FUNCTION__; | 163 DVLOG(1) << __FUNCTION__; |
164 // TODO(servolk): Implement passing MediaTrack info to blink level. | 164 // TODO(servolk): Implement passing MediaTrack info to blink level. |
165 // https://crbug.com/249428 | 165 // https://crbug.com/249428 |
166 client_->initializationSegmentReceived(); | 166 client_->initializationSegmentReceived(); |
167 } | 167 } |
168 | 168 |
169 } // namespace media | 169 } // namespace media |
OLD | NEW |