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 DCHECK(tracks.get()); |
164 // TODO(servolk): Implement passing MediaTrack info to blink level. | 178 DVLOG(1) << __FUNCTION__ << " tracks=" << tracks->tracks().size(); |
165 // https://crbug.com/249428 | 179 |
166 client_->initializationSegmentReceived(); | 180 std::vector<blink::WebSourceBufferClient::MediaTrackInfo> trackInfoVector; |
| 181 for (const auto& track : tracks->tracks()) { |
| 182 trackInfoVector.push_back( |
| 183 std::make_tuple(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 |
| 190 std::vector<blink::WebMediaPlayer::TrackId> blinkTrackIds = |
| 191 client_->initializationSegmentReceived(trackInfoVector); |
167 } | 192 } |
168 | 193 |
169 } // namespace media | 194 } // namespace media |
OLD | NEW |