OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "config.h" | 5 #include "config.h" |
6 #include "web/WebMediaPlayerClientImpl.h" | 6 #include "web/WebMediaPlayerClientImpl.h" |
7 | 7 |
8 #include "core/frame/LocalFrame.h" | 8 #include "core/frame/LocalFrame.h" |
9 #include "core/html/HTMLMediaElement.h" | 9 #include "core/html/HTMLMediaElement.h" |
10 #include "core/html/TimeRanges.h" | 10 #include "core/html/TimeRanges.h" |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 | 189 |
190 #if ENABLE(WEB_AUDIO) | 190 #if ENABLE(WEB_AUDIO) |
191 // Make sure if we create/re-create the WebMediaPlayer that we update our wr
apper. | 191 // Make sure if we create/re-create the WebMediaPlayer that we update our wr
apper. |
192 m_audioSourceProvider.wrap(m_webMediaPlayer->audioSourceProvider()); | 192 m_audioSourceProvider.wrap(m_webMediaPlayer->audioSourceProvider()); |
193 #endif | 193 #endif |
194 | 194 |
195 m_webMediaPlayer->setVolume(mediaElement().playerVolume()); | 195 m_webMediaPlayer->setVolume(mediaElement().playerVolume()); |
196 | 196 |
197 m_webMediaPlayer->setPoster(poster); | 197 m_webMediaPlayer->setPoster(poster); |
198 | 198 |
| 199 m_webMediaPlayer->setRate(mediaElement().playbackRate()); |
| 200 |
199 #if OS(ANDROID) | 201 #if OS(ANDROID) |
200 m_usePaintOnAndroid = (loadType != WebMediaPlayer::LoadTypeMediaStream); | 202 m_usePaintOnAndroid = (loadType != WebMediaPlayer::LoadTypeMediaStream); |
201 #endif | 203 #endif |
202 | 204 |
203 // Tell WebMediaPlayer about any connected CDM (may be null). | 205 // Tell WebMediaPlayer about any connected CDM (may be null). |
204 m_webMediaPlayer->setContentDecryptionModule(HTMLMediaElementEncryptedMedia:
:contentDecryptionModule(mediaElement())); | 206 m_webMediaPlayer->setContentDecryptionModule(HTMLMediaElementEncryptedMedia:
:contentDecryptionModule(mediaElement())); |
205 m_webMediaPlayer->load(loadType, kurl, corsMode); | 207 m_webMediaPlayer->load(loadType, kurl, corsMode); |
206 } | 208 } |
207 | 209 |
208 void WebMediaPlayerClientImpl::play() | 210 void WebMediaPlayerClientImpl::play() |
(...skipping 28 matching lines...) Expand all Loading... |
237 m_webMediaPlayer->seek(time); | 239 m_webMediaPlayer->seek(time); |
238 } | 240 } |
239 | 241 |
240 bool WebMediaPlayerClientImpl::seeking() const | 242 bool WebMediaPlayerClientImpl::seeking() const |
241 { | 243 { |
242 if (m_webMediaPlayer) | 244 if (m_webMediaPlayer) |
243 return m_webMediaPlayer->seeking(); | 245 return m_webMediaPlayer->seeking(); |
244 return false; | 246 return false; |
245 } | 247 } |
246 | 248 |
247 double WebMediaPlayerClientImpl::rate() const | |
248 { | |
249 return m_rate; | |
250 } | |
251 | |
252 void WebMediaPlayerClientImpl::setRate(double rate) | |
253 { | |
254 m_rate = rate; | |
255 if (m_webMediaPlayer) | |
256 m_webMediaPlayer->setRate(rate); | |
257 } | |
258 | |
259 bool WebMediaPlayerClientImpl::paused() const | 249 bool WebMediaPlayerClientImpl::paused() const |
260 { | 250 { |
261 if (m_webMediaPlayer) | 251 if (m_webMediaPlayer) |
262 return m_webMediaPlayer->paused(); | 252 return m_webMediaPlayer->paused(); |
263 return false; | 253 return false; |
264 } | 254 } |
265 | 255 |
266 bool WebMediaPlayerClientImpl::supportsSave() const | 256 bool WebMediaPlayerClientImpl::supportsSave() const |
267 { | 257 { |
268 if (m_webMediaPlayer) | 258 if (m_webMediaPlayer) |
(...skipping 14 matching lines...) Expand all Loading... |
283 return MediaPlayer::Empty; | 273 return MediaPlayer::Empty; |
284 } | 274 } |
285 | 275 |
286 MediaPlayer::ReadyState WebMediaPlayerClientImpl::readyState() const | 276 MediaPlayer::ReadyState WebMediaPlayerClientImpl::readyState() const |
287 { | 277 { |
288 if (m_webMediaPlayer) | 278 if (m_webMediaPlayer) |
289 return static_cast<MediaPlayer::ReadyState>(m_webMediaPlayer->readyState
()); | 279 return static_cast<MediaPlayer::ReadyState>(m_webMediaPlayer->readyState
()); |
290 return MediaPlayer::HaveNothing; | 280 return MediaPlayer::HaveNothing; |
291 } | 281 } |
292 | 282 |
293 double WebMediaPlayerClientImpl::maxTimeSeekable() const | |
294 { | |
295 if (m_webMediaPlayer) | |
296 return m_webMediaPlayer->maxTimeSeekable(); | |
297 return 0.0; | |
298 } | |
299 | |
300 PassRefPtr<TimeRanges> WebMediaPlayerClientImpl::buffered() const | |
301 { | |
302 if (m_webMediaPlayer) | |
303 return TimeRanges::create(m_webMediaPlayer->buffered()); | |
304 return TimeRanges::create(); | |
305 } | |
306 | |
307 bool WebMediaPlayerClientImpl::didLoadingProgress() const | |
308 { | |
309 return m_webMediaPlayer && m_webMediaPlayer->didLoadingProgress(); | |
310 } | |
311 | |
312 void WebMediaPlayerClientImpl::paint(GraphicsContext* context, const IntRect& re
ct) | 283 void WebMediaPlayerClientImpl::paint(GraphicsContext* context, const IntRect& re
ct) |
313 { | 284 { |
314 // Normally GraphicsContext operations do nothing when painting is disabled. | 285 // Normally GraphicsContext operations do nothing when painting is disabled. |
315 // Since we're accessing platformContext() directly we have to manually | 286 // Since we're accessing platformContext() directly we have to manually |
316 // check. | 287 // check. |
317 if (m_webMediaPlayer && !context->paintingDisabled()) { | 288 if (m_webMediaPlayer && !context->paintingDisabled()) { |
318 // On Android, video frame is emitted as GL_TEXTURE_EXTERNAL_OES texture
. We use a different path to | 289 // On Android, video frame is emitted as GL_TEXTURE_EXTERNAL_OES texture
. We use a different path to |
319 // paint the video frame into the context. | 290 // paint the video frame into the context. |
320 #if OS(ANDROID) | 291 #if OS(ANDROID) |
321 if (m_usePaintOnAndroid) { | 292 if (m_usePaintOnAndroid) { |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 SkPaint paint; | 376 SkPaint paint; |
406 paint.setAlpha(alpha); | 377 paint.setAlpha(alpha); |
407 // It is not necessary to pass the dest into the drawBitmap call since all t
he context have been set up before calling paintCurrentFrameInContext. | 378 // It is not necessary to pass the dest into the drawBitmap call since all t
he context have been set up before calling paintCurrentFrameInContext. |
408 canvas->drawBitmapRect(m_bitmap, NULL, dest, &paint); | 379 canvas->drawBitmapRect(m_bitmap, NULL, dest, &paint); |
409 } | 380 } |
410 #endif | 381 #endif |
411 | 382 |
412 WebMediaPlayerClientImpl::WebMediaPlayerClientImpl(MediaPlayerClient* client) | 383 WebMediaPlayerClientImpl::WebMediaPlayerClientImpl(MediaPlayerClient* client) |
413 : m_client(client) | 384 : m_client(client) |
414 , m_preload(MediaPlayer::Auto) | 385 , m_preload(MediaPlayer::Auto) |
415 , m_rate(1.0) | |
416 #if OS(ANDROID) | 386 #if OS(ANDROID) |
417 , m_usePaintOnAndroid(false) | 387 , m_usePaintOnAndroid(false) |
418 #endif | 388 #endif |
419 { | 389 { |
420 ASSERT(m_client); | 390 ASSERT(m_client); |
421 } | 391 } |
422 | 392 |
423 WebCore::HTMLMediaElement& WebMediaPlayerClientImpl::mediaElement() const | 393 WebCore::HTMLMediaElement& WebMediaPlayerClientImpl::mediaElement() const |
424 { | 394 { |
425 return *static_cast<HTMLMediaElement*>(m_client); | 395 return *static_cast<HTMLMediaElement*>(m_client); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 | 444 |
475 void WebMediaPlayerClientImpl::AudioClientImpl::setFormat(size_t numberOfChannel
s, float sampleRate) | 445 void WebMediaPlayerClientImpl::AudioClientImpl::setFormat(size_t numberOfChannel
s, float sampleRate) |
476 { | 446 { |
477 if (m_client) | 447 if (m_client) |
478 m_client->setFormat(numberOfChannels, sampleRate); | 448 m_client->setFormat(numberOfChannels, sampleRate); |
479 } | 449 } |
480 | 450 |
481 #endif | 451 #endif |
482 | 452 |
483 } // namespace blink | 453 } // namespace blink |
OLD | NEW |