Chromium Code Reviews| Index: Source/core/html/HTMLMediaElement.cpp |
| diff --git a/Source/core/html/HTMLMediaElement.cpp b/Source/core/html/HTMLMediaElement.cpp |
| index 91b9d3084f173b8da8c61e0dde318a5957380d9d..7c7807ef44113c062594fe4516c262addd8b567a 100644 |
| --- a/Source/core/html/HTMLMediaElement.cpp |
| +++ b/Source/core/html/HTMLMediaElement.cpp |
| @@ -63,15 +63,19 @@ |
| #include "core/layout/LayoutView.h" |
| #include "core/layout/compositing/DeprecatedPaintLayerCompositor.h" |
| #include "core/loader/FrameLoader.h" |
| +#include "core/loader/FrameLoaderClient.h" |
| #include "platform/ContentType.h" |
| #include "platform/Logging.h" |
| #include "platform/MIMETypeFromURL.h" |
| #include "platform/MIMETypeRegistry.h" |
| #include "platform/RuntimeEnabledFeatures.h" |
| #include "platform/UserGestureIndicator.h" |
| +#include "platform/audio/AudioBus.h" |
| +#include "platform/audio/AudioSourceProviderClient.h" |
| #include "platform/graphics/GraphicsLayer.h" |
| #include "platform/weborigin/SecurityOrigin.h" |
| #include "public/platform/Platform.h" |
| +#include "public/platform/WebAudioSourceProvider.h" |
| #include "public/platform/WebContentDecryptionModule.h" |
| #include "public/platform/WebInbandTextTrack.h" |
| #include "wtf/CurrentTime.h" |
| @@ -331,7 +335,7 @@ HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, Document& docum |
| , m_deferredLoadState(NotDeferred) |
| , m_deferredLoadTimer(this, &HTMLMediaElement::deferredLoadTimerFired) |
| , m_webLayer(nullptr) |
| - , m_preload(MediaPlayer::Auto) |
| + , m_preload(WebMediaPlayer::PreloadAuto) |
| , m_displayMode(Unknown) |
| , m_cachedTime(std::numeric_limits<double>::quiet_NaN()) |
| , m_fragmentEndTime(std::numeric_limits<double>::quiet_NaN()) |
| @@ -487,10 +491,10 @@ void HTMLMediaElement::didMoveToNewDocument(Document& oldDocument) |
| if (m_shouldDelayLoadEvent) { |
| document().incrementLoadEventDelayCount(); |
| // Note: Keeping the load event delay count increment on oldDocument that was added |
| - // when m_shouldDelayLoadEvent was set so that destruction of m_player can not |
| + // when m_shouldDelayLoadEvent was set so that destruction of m_webMediaPlayer can not |
| // cause load event dispatching in oldDocument. |
| } else { |
| - // Incrementing the load event delay count so that destruction of m_player can not |
| + // Incrementing the load event delay count so that destruction of m_webMediaPlayer can not |
| // cause load event dispatching in oldDocument. |
| oldDocument.incrementLoadEventDelayCount(); |
| } |
| @@ -505,7 +509,7 @@ void HTMLMediaElement::didMoveToNewDocument(Document& oldDocument) |
| // document changes so that playback can be resumed properly. |
| userCancelledLoad(); |
| - // Decrement the load event delay count on oldDocument now that m_player has been destroyed |
| + // Decrement the load event delay count on oldDocument now that m_webMediaPlayer has been destroyed |
| // and there is no risk of dispatching a load event from within the destructor. |
| oldDocument.decrementLoadEventDelayCount(); |
| @@ -539,19 +543,18 @@ void HTMLMediaElement::parseAttribute(const QualifiedName& name, const AtomicStr |
| configureMediaControls(); |
| } else if (name == preloadAttr) { |
| if (equalIgnoringCase(value, "none")) { |
| - m_preload = MediaPlayer::None; |
| + m_preload = WebMediaPlayer::PreloadNone; |
| } else if (equalIgnoringCase(value, "metadata")) { |
| - m_preload = MediaPlayer::MetaData; |
| + m_preload = WebMediaPlayer::PreloadMetaData; |
| } else { |
| // The spec does not define an "invalid value default" but "auto" is suggested as the |
| // "missing value default", so use it for everything except "none" and "metadata" |
| - m_preload = MediaPlayer::Auto; |
| + m_preload = WebMediaPlayer::PreloadAuto; |
| } |
| // The attribute must be ignored if the autoplay attribute is present |
| - if (m_player) |
| + if (m_webMediaPlayer) |
| setPlayerPreload(); |
| - |
| } else if (name == mediagroupAttr && RuntimeEnabledFeatures::mediaControllerEnabled()) { |
| setMediaGroup(value); |
| } else { |
| @@ -996,7 +999,7 @@ void HTMLMediaElement::loadResource(const KURL& url, ContentType& contentType, c |
| if (attemptLoad && canLoadURL(url, contentType, keySystem)) { |
| ASSERT(!webMediaPlayer()); |
| - if (!m_havePreparedToPlay && !autoplay() && m_preload == MediaPlayer::None) { |
| + if (!m_havePreparedToPlay && !autoplay() && m_preload == WebMediaPlayer::PreloadNone) { |
| WTF_LOG(Media, "HTMLMediaElement::loadResource(%p) : Delaying load because preload == 'none'", this); |
| deferLoad(); |
| } else { |
| @@ -1035,14 +1038,15 @@ void HTMLMediaElement::startPlayerLoad() |
| if (!requestURL.pass().isEmpty()) |
| requestURL.setPass(String()); |
| - m_player->load(loadType(), requestURL, corsMode()); |
| + prepareAndLoadMediaPlayer(requestURL); |
| } |
| void HTMLMediaElement::setPlayerPreload() |
| { |
| - m_player->setPreload(effectivePreloadType()); |
| + if (m_webMediaPlayer) |
|
Srirama
2015/06/09 14:24:29
this is a duplicate condition when coming from par
|
| + m_webMediaPlayer->setPreload(effectivePreloadType()); |
| - if (loadIsDeferred() && m_preload != MediaPlayer::None) |
| + if (loadIsDeferred() && m_preload != WebMediaPlayer::PreloadNone) |
| startDeferredLoad(); |
| } |
| @@ -1306,7 +1310,7 @@ void HTMLMediaElement::cancelPendingEventsAndCallbacks() |
| source->cancelPendingErrorEvent(); |
| } |
| -void HTMLMediaElement::mediaPlayerNetworkStateChanged() |
| +void HTMLMediaElement::networkStateChanged() |
| { |
| setNetworkState(webMediaPlayer()->networkState()); |
| } |
| @@ -1397,7 +1401,6 @@ void HTMLMediaElement::setNetworkState(WebMediaPlayer::NetworkState state) |
| void HTMLMediaElement::changeNetworkStateFromLoadingToIdle() |
| { |
| - ASSERT(m_player); |
| m_progressEventTimer.stop(); |
| // Schedule one last progress event so we guarantee that at least one is fired |
| @@ -1408,7 +1411,7 @@ void HTMLMediaElement::changeNetworkStateFromLoadingToIdle() |
| m_networkState = NETWORK_IDLE; |
| } |
| -void HTMLMediaElement::mediaPlayerReadyStateChanged() |
| +void HTMLMediaElement::readyStateChanged() |
| { |
| setReadyState(static_cast<ReadyState>(webMediaPlayer()->readyState())); |
| } |
| @@ -1563,7 +1566,6 @@ void HTMLMediaElement::setReadyState(ReadyState state) |
| void HTMLMediaElement::progressEventTimerFired(Timer<HTMLMediaElement>*) |
| { |
| - ASSERT(m_player); |
| if (m_networkState != NETWORK_LOADING) |
| return; |
| @@ -1616,7 +1618,7 @@ void HTMLMediaElement::seek(double time) |
| return; |
| // If the media engine has been told to postpone loading data, let it go ahead now. |
| - if (m_preload < MediaPlayer::Auto && m_readyState < HAVE_FUTURE_DATA) |
| + if (m_preload < WebMediaPlayer::PreloadAuto && m_readyState < HAVE_FUTURE_DATA) |
| prepareToPlay(); |
| // Get the current time before setting m_seeking, m_lastSeekTime is returned once it is set. |
| @@ -1790,10 +1792,10 @@ void HTMLMediaElement::setCurrentTime(double time, ExceptionState& exceptionStat |
| double HTMLMediaElement::duration() const |
| { |
| - // FIXME: remove m_player check once we figure out how m_player is going |
| - // out of sync with readystate. m_player is cleared but readystate is not set |
| - // to HAVE_NOTHING |
| - if (!m_player || m_readyState < HAVE_METADATA) |
| + // FIXME: remove m_webMediaPlayer check once we figure out how |
| + // m_webMediaPlayer is going out of sync with readystate. |
| + // m_webMediaPlayer is cleared but readystate is not set to HAVE_NOTHING. |
| + if (!m_webMediaPlayer || m_readyState < HAVE_METADATA) |
| return std::numeric_limits<double>::quiet_NaN(); |
| // FIXME: Refactor so m_duration is kept current (in both MSE and |
| @@ -1862,7 +1864,10 @@ HTMLMediaElement::DirectionOfPlayback HTMLMediaElement::directionOfPlayback() co |
| void HTMLMediaElement::updatePlaybackRate() |
| { |
| double effectiveRate = effectivePlaybackRate(); |
| - if (m_player && potentiallyPlaying()) |
| + // FIXME: remove m_webMediaPlayer check once we figure out how |
| + // m_webMediaPlayer is going out of sync with readystate. |
| + // m_webMediaPlayer is cleared but readystate is not set to HAVE_NOTHING. |
| + if (m_webMediaPlayer && potentiallyPlaying()) |
| webMediaPlayer()->setRate(effectiveRate); |
| } |
| @@ -1882,13 +1887,13 @@ bool HTMLMediaElement::autoplay() const |
| String HTMLMediaElement::preload() const |
| { |
| switch (m_preload) { |
| - case MediaPlayer::None: |
| + case WebMediaPlayer::PreloadNone: |
| return "none"; |
| break; |
| - case MediaPlayer::MetaData: |
| + case WebMediaPlayer::PreloadMetaData: |
| return "metadata"; |
| break; |
| - case MediaPlayer::Auto: |
| + case WebMediaPlayer::PreloadAuto: |
| return "auto"; |
| break; |
| } |
| @@ -1903,9 +1908,9 @@ void HTMLMediaElement::setPreload(const AtomicString& preload) |
| setAttribute(preloadAttr, preload); |
| } |
| -MediaPlayer::Preload HTMLMediaElement::effectivePreloadType() const |
| +WebMediaPlayer::Preload HTMLMediaElement::effectivePreloadType() const |
| { |
| - return autoplay() ? MediaPlayer::Auto : m_preload; |
| + return autoplay() ? WebMediaPlayer::PreloadAuto : m_preload; |
| } |
| void HTMLMediaElement::play() |
| @@ -1930,7 +1935,7 @@ void HTMLMediaElement::playInternal() |
| WTF_LOG(Media, "HTMLMediaElement::playInternal(%p)", this); |
| // 4.8.10.9. Playing the media resource |
| - if (!m_player || m_networkState == NETWORK_EMPTY) |
| + if (m_networkState == NETWORK_EMPTY) |
| scheduleDelayedAction(LoadMediaResource); |
| // Generally "ended" and "looping" are exclusive. Here, the loop attribute |
| @@ -1990,7 +1995,7 @@ void HTMLMediaElement::pause() |
| { |
| WTF_LOG(Media, "HTMLMediaElement::pause(%p)", this); |
| - if (!m_player || m_networkState == NETWORK_EMPTY) |
| + if (m_networkState == NETWORK_EMPTY) |
| scheduleDelayedAction(LoadMediaResource); |
| m_autoplaying = false; |
| @@ -2135,8 +2140,6 @@ void HTMLMediaElement::startPlaybackProgressTimer() |
| void HTMLMediaElement::playbackProgressTimerFired(Timer<HTMLMediaElement>*) |
| { |
| - ASSERT(m_player); |
| - |
| if (!std::isnan(m_fragmentEndTime) && currentTime() >= m_fragmentEndTime && directionOfPlayback() == Forward) { |
| m_fragmentEndTime = std::numeric_limits<double>::quiet_NaN(); |
| if (!m_mediaController && !m_paused) { |
| @@ -2231,11 +2234,11 @@ void HTMLMediaElement::audioTracksTimerFired(Timer<HTMLMediaElement>*) |
| webMediaPlayer()->enabledAudioTracksChanged(enabledTrackIds); |
| } |
| -WebMediaPlayer::TrackId HTMLMediaElement::addAudioTrack(const String& id, WebMediaPlayerClient::AudioTrackKind kind, const AtomicString& label, const AtomicString& language, bool enabled) |
| +WebMediaPlayer::TrackId HTMLMediaElement::addAudioTrack(const WebString& id, blink::WebMediaPlayerClient::AudioTrackKind kind, const WebString& label, const WebString& language, bool enabled) |
| { |
| AtomicString kindString = AudioKindToString(kind); |
| WTF_LOG(Media, "HTMLMediaElement::addAudioTrack(%p, '%s', '%s', '%s', '%s', %d)", |
| - this, id.ascii().data(), kindString.ascii().data(), label.ascii().data(), language.ascii().data(), enabled); |
| + this, id.latin1().data(), kindString.ascii().data(), label.latin1().data(), language.latin1().data(), enabled); |
| if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) |
| return 0; |
| @@ -2275,11 +2278,11 @@ void HTMLMediaElement::selectedVideoTrackChanged(WebMediaPlayer::TrackId* select |
| webMediaPlayer()->selectedVideoTrackChanged(selectedTrackId); |
| } |
| -WebMediaPlayer::TrackId HTMLMediaElement::addVideoTrack(const String& id, WebMediaPlayerClient::VideoTrackKind kind, const AtomicString& label, const AtomicString& language, bool selected) |
| +WebMediaPlayer::TrackId HTMLMediaElement::addVideoTrack(const WebString& id, blink::WebMediaPlayerClient::VideoTrackKind kind, const WebString& label, const WebString& language, bool selected) |
| { |
| AtomicString kindString = VideoKindToString(kind); |
| WTF_LOG(Media, "HTMLMediaElement::addVideoTrack(%p, '%s', '%s', '%s', '%s', %d)", |
| - this, id.ascii().data(), kindString.ascii().data(), label.ascii().data(), language.ascii().data(), selected); |
| + this, id.latin1().data(), kindString.ascii().data(), label.latin1().data(), language.latin1().data(), selected); |
| if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) |
| return 0; |
| @@ -2304,7 +2307,7 @@ void HTMLMediaElement::removeVideoTrack(WebMediaPlayer::TrackId trackId) |
| videoTracks().remove(trackId); |
| } |
| -void HTMLMediaElement::mediaPlayerDidAddTextTrack(WebInbandTextTrack* webTrack) |
| +void HTMLMediaElement::addTextTrack(WebInbandTextTrack* webTrack) |
| { |
| // 4.8.10.12.2 Sourcing in-band text tracks |
| // 1. Associate the relevant data with a new text track and its corresponding new TextTrack object. |
| @@ -2333,10 +2336,10 @@ void HTMLMediaElement::mediaPlayerDidAddTextTrack(WebInbandTextTrack* webTrack) |
| // 9. Fire an event with the name addtrack, that does not bubble and is not cancelable, and that uses the TrackEvent |
| // interface, with the track attribute initialized to the text track's TextTrack object, at the media element's |
| // textTracks attribute's TextTrackList object. |
| - addTextTrack(textTrack.get()); |
| + mediaPlayerAddTextTrack(textTrack.get()); |
| } |
| -void HTMLMediaElement::mediaPlayerDidRemoveTextTrack(WebInbandTextTrack* webTrack) |
| +void HTMLMediaElement::removeTextTrack(WebInbandTextTrack* webTrack) |
| { |
| if (!m_textTracks) |
| return; |
| @@ -2347,7 +2350,7 @@ void HTMLMediaElement::mediaPlayerDidRemoveTextTrack(WebInbandTextTrack* webTrac |
| if (!textTrack) |
| return; |
| - removeTextTrack(textTrack.get()); |
| + mediaPlayerRemoveTextTrack(textTrack.get()); |
| } |
| void HTMLMediaElement::textTracksChanged() |
| @@ -2356,14 +2359,14 @@ void HTMLMediaElement::textTracksChanged() |
| mediaControls()->refreshClosedCaptionsButtonVisibility(); |
| } |
| -void HTMLMediaElement::addTextTrack(TextTrack* track) |
| +void HTMLMediaElement::mediaPlayerAddTextTrack(TextTrack* track) |
| { |
| textTracks()->append(track); |
| textTracksChanged(); |
| } |
| -void HTMLMediaElement::removeTextTrack(TextTrack* track) |
| +void HTMLMediaElement::mediaPlayerRemoveTextTrack(TextTrack* track) |
| { |
| m_textTracks->remove(track); |
| @@ -2409,7 +2412,7 @@ PassRefPtrWillBeRawPtr<TextTrack> HTMLMediaElement::addTextTrack(const AtomicStr |
| // interface, with the track attribute initialised to the new text |
| // track's TextTrack object, at the media element's textTracks |
| // attribute's TextTrackList object. |
| - addTextTrack(textTrack.get()); |
| + mediaPlayerAddTextTrack(textTrack.get()); |
| // Note: Due to side effects when changing track parameters, we have to |
| // first append the track to the text track list. |
| @@ -2442,7 +2445,7 @@ void HTMLMediaElement::didAddTrackElement(HTMLTrackElement* trackElement) |
| if (!textTrack) |
| return; |
| - addTextTrack(textTrack.get()); |
| + mediaPlayerAddTextTrack(textTrack.get()); |
| // Do not schedule the track loading until parsing finishes so we don't start before all tracks |
| // in the markup have been added. |
| @@ -2470,7 +2473,7 @@ void HTMLMediaElement::didRemoveTrackElement(HTMLTrackElement* trackElement) |
| // When a track element's parent element changes and the old parent was a media element, |
| // then the user agent must remove the track element's corresponding text track from the |
| // media element's list of text tracks. |
| - removeTextTrack(textTrack.get()); |
| + mediaPlayerRemoveTextTrack(textTrack.get()); |
| size_t index = m_textTracksWhenResourceSelectionBegan.find(textTrack.get()); |
| if (index != kNotFound) |
| @@ -2677,7 +2680,7 @@ void HTMLMediaElement::sourceWasRemoved(HTMLSourceElement* source) |
| } |
| } |
| -void HTMLMediaElement::mediaPlayerTimeChanged() |
| +void HTMLMediaElement::timeChanged() |
| { |
| WTF_LOG(Media, "HTMLMediaElement::mediaPlayerTimeChanged(%p)", this); |
| @@ -2730,19 +2733,19 @@ void HTMLMediaElement::mediaPlayerTimeChanged() |
| updatePlayState(); |
| } |
| -void HTMLMediaElement::mediaPlayerDurationChanged() |
| +void HTMLMediaElement::durationChanged() |
| { |
| - WTF_LOG(Media, "HTMLMediaElement::mediaPlayerDurationChanged(%p)", this); |
| - // FIXME: Change MediaPlayerClient & WebMediaPlayer to convey |
| - // the currentTime when the duration change occured. The current |
| - // WebMediaPlayer implementations always clamp currentTime() to |
| - // duration() so the requestSeek condition here is always false. |
| - durationChanged(duration(), currentTime() > duration()); |
| + WTF_LOG(Media, "HTMLMediaElement::durationChanged(%p)", this); |
| + // FIXME: Change WebMediaPlayer to convey the currentTime |
| + // when the duration change occured. The current WebMediaPlayer |
| + // implementations always clamp currentTime() to duration() |
| + // so the requestSeek condition here is always false. |
| + mediaPlayerDurationChanged(duration(), currentTime() > duration()); |
| } |
| -void HTMLMediaElement::durationChanged(double duration, bool requestSeek) |
| +void HTMLMediaElement::mediaPlayerDurationChanged(double duration, bool requestSeek) |
| { |
| - WTF_LOG(Media, "HTMLMediaElement::durationChanged(%p, %f, %d)", this, duration, requestSeek); |
| + WTF_LOG(Media, "HTMLMediaElement::mediaPlayerDurationChanged(%p, %f, %d)", this, duration, requestSeek); |
| // Abort if duration unchanged. |
| if (m_duration == duration) |
| @@ -2761,7 +2764,7 @@ void HTMLMediaElement::durationChanged(double duration, bool requestSeek) |
| seek(duration); |
| } |
| -void HTMLMediaElement::mediaPlayerPlaybackStateChanged() |
| +void HTMLMediaElement::playbackStateChanged() |
| { |
| WTF_LOG(Media, "HTMLMediaElement::mediaPlayerPlaybackStateChanged(%p)", this); |
| @@ -2817,7 +2820,7 @@ void HTMLMediaElement::disconnectedFromRemoteDevice() |
| } |
| // MediaPlayerPresentation methods |
| -void HTMLMediaElement::mediaPlayerRepaint() |
| +void HTMLMediaElement::repaint() |
| { |
| if (m_webLayer) |
| m_webLayer->invalidate(); |
| @@ -2827,7 +2830,7 @@ void HTMLMediaElement::mediaPlayerRepaint() |
| layoutObject()->setShouldDoFullPaintInvalidation(); |
| } |
| -void HTMLMediaElement::mediaPlayerSizeChanged() |
| +void HTMLMediaElement::sizeChanged() |
| { |
| WTF_LOG(Media, "HTMLMediaElement::mediaPlayerSizeChanged(%p)", this); |
| @@ -2892,7 +2895,7 @@ bool HTMLMediaElement::couldPlayIfEnoughData() const |
| bool HTMLMediaElement::endedPlayback(LoopCondition loopCondition) const |
| { |
| double dur = duration(); |
| - if (!m_player || std::isnan(dur)) |
| + if (std::isnan(dur)) |
| return false; |
| // 4.8.10.8 Playing the media resource |
| @@ -2928,9 +2931,6 @@ bool HTMLMediaElement::stoppedDueToErrors() const |
| void HTMLMediaElement::updatePlayState() |
| { |
| - if (!m_player) |
| - return; |
| - |
| bool isPlaying = webMediaPlayer() && !webMediaPlayer()->paused(); |
| bool shouldBePlaying = potentiallyPlaying(); |
| @@ -3021,7 +3021,7 @@ void HTMLMediaElement::userCancelledLoad() |
| // 6 - Abort the overall resource selection algorithm. |
| m_currentSourceNode = nullptr; |
| - // Reset m_readyState since m_player is gone. |
| + // Reset m_readyState since m_webMediaPlayer is gone. |
| m_readyState = HAVE_NOTHING; |
| invalidateCachedTime(); |
| updateMediaController(); |
| @@ -3034,7 +3034,8 @@ void HTMLMediaElement::clearMediaPlayerAndAudioSourceProviderClientWithoutLockin |
| if (audioSourceProvider()) |
| audioSourceProvider()->setClient(0); |
| #endif |
| - m_player.clear(); |
| + if (m_webMediaPlayer) |
| + m_webMediaPlayer.clear(); |
| } |
| void HTMLMediaElement::clearMediaPlayer(int flags) |
| @@ -3242,7 +3243,7 @@ void HTMLMediaElement::setClosedCaptionsVisible(bool closedCaptionVisible) |
| { |
| WTF_LOG(Media, "HTMLMediaElement::setClosedCaptionsVisible(%p, %s)", this, boolString(closedCaptionVisible)); |
| - if (!m_player || !hasClosedCaptions()) |
| + if (!hasClosedCaptions()) |
| return; |
| m_closedCaptionsVisible = closedCaptionVisible; |
| @@ -3424,18 +3425,12 @@ void HTMLMediaElement::createMediaPlayer() |
| closeMediaSource(); |
| - m_player = MediaPlayer::create(this); |
| + if (m_webMediaPlayer) |
| + m_webMediaPlayer.clear(); |
| // We haven't yet found out if any remote routes are available. |
| m_remoteRoutesAvailable = false; |
| m_playingRemotely = false; |
| - |
| -#if ENABLE(WEB_AUDIO) |
| - if (m_audioSourceNode && audioSourceProvider()) { |
| - // When creating the player, make sure its AudioSourceProvider knows about the client. |
| - audioSourceProvider()->setClient(m_audioSourceNode); |
| - } |
| -#endif |
| } |
| #if ENABLE(WEB_AUDIO) |
| @@ -3451,8 +3446,8 @@ void HTMLMediaElement::setAudioSourceNode(AudioSourceProviderClient* sourceNode) |
| AudioSourceProvider* HTMLMediaElement::audioSourceProvider() |
| { |
| - if (m_player) |
| - return m_player->audioSourceProvider(); |
| + if (m_webMediaPlayer) |
| + return &m_audioSourceProvider; |
| return nullptr; |
| } |
| @@ -3567,7 +3562,7 @@ WebMediaPlayer::CORSMode HTMLMediaElement::corsMode() const |
| return WebMediaPlayer::CORSModeAnonymous; |
| } |
| -void HTMLMediaElement::mediaPlayerSetWebLayer(WebLayer* webLayer) |
| +void HTMLMediaElement::setWebLayer(blink::WebLayer* webLayer) |
| { |
| if (webLayer == m_webLayer) |
| return; |
| @@ -3587,7 +3582,7 @@ void HTMLMediaElement::mediaPlayerSetWebLayer(WebLayer* webLayer) |
| GraphicsLayer::registerContentsLayer(m_webLayer); |
| } |
| -void HTMLMediaElement::mediaPlayerMediaSourceOpened(WebMediaSource* webMediaSource) |
| +void HTMLMediaElement::mediaSourceOpened(blink::WebMediaSource* webMediaSource) |
| { |
| m_mediaSource->setWebMediaSourceAndOpen(adoptPtr(webMediaSource)); |
| } |
| @@ -3658,12 +3653,98 @@ void HTMLMediaElement::selectInitialTracksIfNecessary() |
| videoTracks().anonymousIndexedGetter(0)->setSelected(true); |
| } |
| +void HTMLMediaElement::prepareAndLoadMediaPlayer(const WTF::String& url) |
| +{ |
| + ASSERT(!m_webMediaPlayer); |
| + |
| + WebURL poster = mediaPlayerPosterURL(); |
| + |
| + KURL kurl(ParsedURLString, url); |
| + LocalFrame* frame = document().frame(); |
| + ASSERT(frame); |
| + m_webMediaPlayer = frame->loader().client()->createWebMediaPlayer(this, kurl); |
| + if (!m_webMediaPlayer) |
| + return; |
| + |
| +#if ENABLE(WEB_AUDIO) |
| + // Make sure if we create/re-create the WebMediaPlayer that we update our wrapper. |
| + m_audioSourceProvider.wrap(m_webMediaPlayer->audioSourceProvider()); |
| +#endif |
| + m_webMediaPlayer->setVolume(effectiveMediaVolume()); |
| + |
| + m_webMediaPlayer->setPoster(poster); |
| + |
| + m_webMediaPlayer->setPreload(effectivePreloadType()); |
| + |
| + m_webMediaPlayer->load(loadType(), kurl, corsMode()); |
| + |
| + if (isFullscreen()) |
| + m_webMediaPlayer->enterFullscreen(); |
| +} |
| + |
| #if ENABLE(WEB_AUDIO) |
| void HTMLMediaElement::clearWeakMembers(Visitor* visitor) |
| { |
| if (!visitor->isHeapObjectAlive(m_audioSourceNode) && audioSourceProvider()) |
| audioSourceProvider()->setClient(nullptr); |
| } |
| + |
| +void HTMLMediaElement::AudioSourceProviderImpl::wrap(WebAudioSourceProvider* provider) |
| +{ |
| + MutexLocker locker(provideInputLock); |
| + |
| + if (m_webAudioSourceProvider && provider != m_webAudioSourceProvider) |
| + m_webAudioSourceProvider->setClient(0); |
| + |
| + m_webAudioSourceProvider = provider; |
| + if (m_webAudioSourceProvider) |
| + m_webAudioSourceProvider->setClient(m_client.get()); |
| +} |
| + |
| +void HTMLMediaElement::AudioSourceProviderImpl::setClient(AudioSourceProviderClient* client) |
| +{ |
| + MutexLocker locker(provideInputLock); |
| + |
| + if (client) |
| + m_client = new HTMLMediaElement::AudioClientImpl(client); |
| + else |
| + m_client.clear(); |
| + |
| + if (m_webAudioSourceProvider) |
| + m_webAudioSourceProvider->setClient(m_client.get()); |
| +} |
| + |
| +void HTMLMediaElement::AudioSourceProviderImpl::provideInput(blink::AudioBus* bus, size_t framesToProcess) |
| +{ |
| + ASSERT(bus); |
| + if (!bus) |
| + return; |
| + |
| + MutexTryLocker tryLocker(provideInputLock); |
| + if (!tryLocker.locked() || !m_webAudioSourceProvider || !m_client.get()) { |
| + bus->zero(); |
| + return; |
| + } |
| + |
| + // Wrap the AudioBus channel data using WebVector. |
| + size_t n = bus->numberOfChannels(); |
| + WebVector<float*> webAudioData(n); |
| + for (size_t i = 0; i < n; ++i) |
| + webAudioData[i] = bus->channel(i)->mutableData(); |
| + |
| + m_webAudioSourceProvider->provideInput(webAudioData, framesToProcess); |
| +} |
| + |
| +void HTMLMediaElement::AudioClientImpl::setFormat(size_t numberOfChannels, float sampleRate) |
| +{ |
| + if (m_client) |
| + m_client->setFormat(numberOfChannels, sampleRate); |
| +} |
| + |
| +DEFINE_TRACE(HTMLMediaElement::AudioClientImpl) |
| +{ |
| + visitor->trace(m_client); |
| +} |
| #endif |
| } |