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> |
11 | 11 |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/callback_helpers.h" | 14 #include "base/callback_helpers.h" |
15 #include "media/base/media_tracks.h" | 15 #include "media/base/media_tracks.h" |
16 #include "media/base/timestamp_constants.h" | 16 #include "media/base/timestamp_constants.h" |
17 #include "media/filters/chunk_demuxer.h" | 17 #include "media/filters/chunk_demuxer.h" |
18 #include "third_party/WebKit/public/platform/WebMediaPlayer.h" | |
18 #include "third_party/WebKit/public/platform/WebSourceBufferClient.h" | 19 #include "third_party/WebKit/public/platform/WebSourceBufferClient.h" |
19 | 20 |
20 namespace media { | 21 namespace media { |
21 | 22 |
22 static base::TimeDelta DoubleToTimeDelta(double time) { | 23 static base::TimeDelta DoubleToTimeDelta(double time) { |
23 DCHECK(!std::isnan(time)); | 24 DCHECK(!std::isnan(time)); |
24 DCHECK_NE(time, -std::numeric_limits<double>::infinity()); | 25 DCHECK_NE(time, -std::numeric_limits<double>::infinity()); |
25 | 26 |
26 if (time == std::numeric_limits<double>::infinity()) | 27 if (time == std::numeric_limits<double>::infinity()) |
27 return kInfiniteDuration(); | 28 return kInfiniteDuration(); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
152 DCHECK_GE(end, 0); | 153 DCHECK_GE(end, 0); |
153 append_window_end_ = DoubleToTimeDelta(end); | 154 append_window_end_ = DoubleToTimeDelta(end); |
154 } | 155 } |
155 | 156 |
156 void WebSourceBufferImpl::removedFromMediaSource() { | 157 void WebSourceBufferImpl::removedFromMediaSource() { |
157 demuxer_->RemoveId(id_); | 158 demuxer_->RemoveId(id_); |
158 demuxer_ = NULL; | 159 demuxer_ = NULL; |
159 client_ = NULL; | 160 client_ = NULL; |
160 } | 161 } |
161 | 162 |
163 blink::WebMediaPlayer::TrackType mediaTrackTypeToBlink(MediaTrack::Type type) { | |
164 switch (type) { | |
165 case MediaTrack::Audio: | |
166 return blink::WebMediaPlayer::AudioTrack; | |
167 case MediaTrack::Text: | |
168 return blink::WebMediaPlayer::TextTrack; | |
169 case MediaTrack::Video: | |
170 return blink::WebMediaPlayer::VideoTrack; | |
171 } | |
172 NOTREACHED(); | |
173 return blink::WebMediaPlayer::AudioTrack; | |
174 } | |
175 | |
162 void WebSourceBufferImpl::InitSegmentReceived(scoped_ptr<MediaTracks> tracks) { | 176 void WebSourceBufferImpl::InitSegmentReceived(scoped_ptr<MediaTracks> tracks) { |
163 DVLOG(1) << __FUNCTION__; | 177 DVLOG(1) << __FUNCTION__; |
164 // TODO(servolk): Implement passing MediaTrack info to blink level. | 178 blink::WebVector<blink::WebMediaPlayer::TrackId> blinkTrackIds( |
wolenetz
2016/03/23 19:34:12
nit: DCHECK_LT(0, tracks->tracks().size() ?
servolk
2016/03/24 01:31:55
No need for this dcheck here, since the case of em
wolenetz
2016/03/24 01:54:06
Acknowledged.
| |
165 // https://crbug.com/249428 | 179 tracks->tracks().size()); |
166 client_->initializationSegmentReceived(); | 180 size_t i = 0; |
181 for (const auto& track : tracks->tracks()) { | |
182 blinkTrackIds[i++] = client_->createMediaTrack( | |
wolenetz
2016/03/23 19:34:13
Are these blinkTrackIds only valid within the proc
servolk
2016/03/24 01:31:55
Chromium does need to know these, since media trac
wolenetz
2016/03/24 01:54:07
Acknowledged.
| |
183 mediaTrackTypeToBlink(track->type()), | |
184 blink::WebString::fromUTF8(track->id()), | |
185 blink::WebString::fromUTF8(track->kind()), | |
186 blink::WebString::fromUTF8(track->label()), | |
187 blink::WebString::fromUTF8(track->language())); | |
188 } | |
189 client_->initializationSegmentReceived(blinkTrackIds); | |
167 } | 190 } |
168 | 191 |
169 } // namespace media | 192 } // namespace media |
OLD | NEW |