| 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 double WebMediaPlayerClientImpl::rate() const | |
| 209 { | |
| 210 return m_rate; | |
| 211 } | |
| 212 | |
| 213 void WebMediaPlayerClientImpl::setRate(double rate) | |
| 214 { | |
| 215 m_rate = rate; | |
| 216 if (m_webMediaPlayer) | |
| 217 m_webMediaPlayer->setRate(rate); | |
| 218 } | |
| 219 | |
| 220 MediaPlayer::NetworkState WebMediaPlayerClientImpl::networkState() const | 210 MediaPlayer::NetworkState WebMediaPlayerClientImpl::networkState() const |
| 221 { | 211 { |
| 222 if (m_webMediaPlayer) | 212 if (m_webMediaPlayer) |
| 223 return static_cast<MediaPlayer::NetworkState>(m_webMediaPlayer->networkS
tate()); | 213 return static_cast<MediaPlayer::NetworkState>(m_webMediaPlayer->networkS
tate()); |
| 224 return MediaPlayer::Empty; | 214 return MediaPlayer::Empty; |
| 225 } | 215 } |
| 226 | 216 |
| 227 MediaPlayer::ReadyState WebMediaPlayerClientImpl::readyState() const | 217 MediaPlayer::ReadyState WebMediaPlayerClientImpl::readyState() const |
| 228 { | 218 { |
| 229 if (m_webMediaPlayer) | 219 if (m_webMediaPlayer) |
| 230 return static_cast<MediaPlayer::ReadyState>(m_webMediaPlayer->readyState
()); | 220 return static_cast<MediaPlayer::ReadyState>(m_webMediaPlayer->readyState
()); |
| 231 return MediaPlayer::HaveNothing; | 221 return MediaPlayer::HaveNothing; |
| 232 } | 222 } |
| 233 | 223 |
| 234 double WebMediaPlayerClientImpl::maxTimeSeekable() const | |
| 235 { | |
| 236 if (m_webMediaPlayer) | |
| 237 return m_webMediaPlayer->maxTimeSeekable(); | |
| 238 return 0.0; | |
| 239 } | |
| 240 | |
| 241 PassRefPtr<TimeRanges> WebMediaPlayerClientImpl::buffered() const | |
| 242 { | |
| 243 if (m_webMediaPlayer) | |
| 244 return TimeRanges::create(m_webMediaPlayer->buffered()); | |
| 245 return TimeRanges::create(); | |
| 246 } | |
| 247 | |
| 248 bool WebMediaPlayerClientImpl::didLoadingProgress() const | |
| 249 { | |
| 250 return m_webMediaPlayer && m_webMediaPlayer->didLoadingProgress(); | |
| 251 } | |
| 252 | |
| 253 void WebMediaPlayerClientImpl::paint(GraphicsContext* context, const IntRect& re
ct) | 224 void WebMediaPlayerClientImpl::paint(GraphicsContext* context, const IntRect& re
ct) |
| 254 { | 225 { |
| 255 // Normally GraphicsContext operations do nothing when painting is disabled. | 226 // Normally GraphicsContext operations do nothing when painting is disabled. |
| 256 // Since we're accessing platformContext() directly we have to manually | 227 // Since we're accessing platformContext() directly we have to manually |
| 257 // check. | 228 // check. |
| 258 if (m_webMediaPlayer && !context->paintingDisabled()) { | 229 if (m_webMediaPlayer && !context->paintingDisabled()) { |
| 259 // On Android, video frame is emitted as GL_TEXTURE_EXTERNAL_OES texture
. We use a different path to | 230 // On Android, video frame is emitted as GL_TEXTURE_EXTERNAL_OES texture
. We use a different path to |
| 260 // paint the video frame into the context. | 231 // paint the video frame into the context. |
| 261 #if OS(ANDROID) | 232 #if OS(ANDROID) |
| 262 if (m_usePaintOnAndroid) { | 233 if (m_usePaintOnAndroid) { |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 SkPaint paint; | 303 SkPaint paint; |
| 333 paint.setAlpha(alpha); | 304 paint.setAlpha(alpha); |
| 334 // It is not necessary to pass the dest into the drawBitmap call since all t
he context have been set up before calling paintCurrentFrameInContext. | 305 // It is not necessary to pass the dest into the drawBitmap call since all t
he context have been set up before calling paintCurrentFrameInContext. |
| 335 canvas->drawBitmapRect(m_bitmap, NULL, dest, &paint); | 306 canvas->drawBitmapRect(m_bitmap, NULL, dest, &paint); |
| 336 } | 307 } |
| 337 #endif | 308 #endif |
| 338 | 309 |
| 339 WebMediaPlayerClientImpl::WebMediaPlayerClientImpl(MediaPlayerClient* client) | 310 WebMediaPlayerClientImpl::WebMediaPlayerClientImpl(MediaPlayerClient* client) |
| 340 : m_client(client) | 311 : m_client(client) |
| 341 , m_preload(MediaPlayer::Auto) | 312 , m_preload(MediaPlayer::Auto) |
| 342 , m_rate(1.0) | |
| 343 #if OS(ANDROID) | 313 #if OS(ANDROID) |
| 344 , m_usePaintOnAndroid(false) | 314 , m_usePaintOnAndroid(false) |
| 345 #endif | 315 #endif |
| 346 { | 316 { |
| 347 ASSERT(m_client); | 317 ASSERT(m_client); |
| 348 } | 318 } |
| 349 | 319 |
| 350 WebCore::HTMLMediaElement& WebMediaPlayerClientImpl::mediaElement() const | 320 WebCore::HTMLMediaElement& WebMediaPlayerClientImpl::mediaElement() const |
| 351 { | 321 { |
| 352 return *static_cast<HTMLMediaElement*>(m_client); | 322 return *static_cast<HTMLMediaElement*>(m_client); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 | 371 |
| 402 void WebMediaPlayerClientImpl::AudioClientImpl::setFormat(size_t numberOfChannel
s, float sampleRate) | 372 void WebMediaPlayerClientImpl::AudioClientImpl::setFormat(size_t numberOfChannel
s, float sampleRate) |
| 403 { | 373 { |
| 404 if (m_client) | 374 if (m_client) |
| 405 m_client->setFormat(numberOfChannels, sampleRate); | 375 m_client->setFormat(numberOfChannels, sampleRate); |
| 406 } | 376 } |
| 407 | 377 |
| 408 #endif | 378 #endif |
| 409 | 379 |
| 410 } // namespace blink | 380 } // namespace blink |
| OLD | NEW |