Index: Source/core/html/HTMLMediaElement.cpp |
diff --git a/Source/core/html/HTMLMediaElement.cpp b/Source/core/html/HTMLMediaElement.cpp |
index aa41d278c8f73fc305c6fb6df818e5137559f8c7..0251fc77a37325987076b7ed2a2ef44e81bebf98 100644 |
--- a/Source/core/html/HTMLMediaElement.cpp |
+++ b/Source/core/html/HTMLMediaElement.cpp |
@@ -64,15 +64,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" |
@@ -334,7 +338,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()) |
@@ -495,10 +499,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(); |
} |
@@ -513,7 +517,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(); |
@@ -547,19 +551,17 @@ 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) |
- setPlayerPreload(); |
- |
+ setPlayerPreload(); |
} else if (name == mediagroupAttr && RuntimeEnabledFeatures::mediaControllerEnabled()) { |
setMediaGroup(value); |
} else { |
@@ -1004,7 +1006,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 { |
@@ -1043,14 +1045,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) |
+ m_webMediaPlayer->setPreload(effectivePreloadType()); |
- if (loadIsDeferred() && m_preload != MediaPlayer::None) |
+ if (loadIsDeferred() && m_preload != WebMediaPlayer::PreloadNone) |
startDeferredLoad(); |
} |
@@ -1314,7 +1317,7 @@ void HTMLMediaElement::cancelPendingEventsAndCallbacks() |
source->cancelPendingErrorEvent(); |
} |
-void HTMLMediaElement::mediaPlayerNetworkStateChanged() |
+void HTMLMediaElement::networkStateChanged() |
{ |
setNetworkState(webMediaPlayer()->networkState()); |
} |
@@ -1405,7 +1408,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 |
@@ -1416,7 +1418,7 @@ void HTMLMediaElement::changeNetworkStateFromLoadingToIdle() |
m_networkState = NETWORK_IDLE; |
} |
-void HTMLMediaElement::mediaPlayerReadyStateChanged() |
+void HTMLMediaElement::readyStateChanged() |
{ |
setReadyState(static_cast<ReadyState>(webMediaPlayer()->readyState())); |
} |
@@ -1574,7 +1576,6 @@ void HTMLMediaElement::setReadyState(ReadyState state) |
void HTMLMediaElement::progressEventTimerFired(Timer<HTMLMediaElement>*) |
{ |
- ASSERT(m_player); |
if (m_networkState != NETWORK_LOADING) |
return; |
@@ -1627,7 +1628,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. |
@@ -1801,10 +1802,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 |
@@ -1873,7 +1874,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); |
} |
@@ -1893,13 +1897,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; |
} |
@@ -1914,9 +1918,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() |
@@ -1944,7 +1948,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 |
@@ -2004,7 +2008,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; |
@@ -2149,8 +2153,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) { |
@@ -2245,11 +2247,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); |
philipj_slow
2015/07/01 13:49:19
I think calling utf8() here is probably more appro
Srirama
2015/07/03 12:59:01
Done.
|
if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) |
return 0; |
@@ -2289,11 +2291,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); |
philipj_slow
2015/07/01 13:49:19
Ditto.
Srirama
2015/07/03 12:59:02
Done.
|
if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) |
return 0; |
@@ -2318,7 +2320,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. |
@@ -2347,10 +2349,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; |
@@ -2361,7 +2363,7 @@ void HTMLMediaElement::mediaPlayerDidRemoveTextTrack(WebInbandTextTrack* webTrac |
if (!textTrack) |
return; |
- removeTextTrack(textTrack.get()); |
+ mediaPlayerRemoveTextTrack(textTrack.get()); |
} |
void HTMLMediaElement::textTracksChanged() |
@@ -2370,14 +2372,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); |
@@ -2423,7 +2425,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. |
@@ -2456,7 +2458,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. |
@@ -2484,7 +2486,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) |
@@ -2691,7 +2693,7 @@ void HTMLMediaElement::sourceWasRemoved(HTMLSourceElement* source) |
} |
} |
-void HTMLMediaElement::mediaPlayerTimeChanged() |
+void HTMLMediaElement::timeChanged() |
{ |
WTF_LOG(Media, "HTMLMediaElement::mediaPlayerTimeChanged(%p)", this); |
@@ -2744,19 +2746,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) |
@@ -2775,7 +2777,7 @@ void HTMLMediaElement::durationChanged(double duration, bool requestSeek) |
seek(duration); |
} |
-void HTMLMediaElement::mediaPlayerPlaybackStateChanged() |
+void HTMLMediaElement::playbackStateChanged() |
{ |
WTF_LOG(Media, "HTMLMediaElement::mediaPlayerPlaybackStateChanged(%p)", this); |
@@ -2820,7 +2822,7 @@ void HTMLMediaElement::disconnectedFromRemoteDevice() |
} |
// MediaPlayerPresentation methods |
-void HTMLMediaElement::mediaPlayerRepaint() |
+void HTMLMediaElement::repaint() |
{ |
if (m_webLayer) |
m_webLayer->invalidate(); |
@@ -2830,7 +2832,7 @@ void HTMLMediaElement::mediaPlayerRepaint() |
layoutObject()->setShouldDoFullPaintInvalidation(); |
} |
-void HTMLMediaElement::mediaPlayerSizeChanged() |
+void HTMLMediaElement::sizeChanged() |
{ |
WTF_LOG(Media, "HTMLMediaElement::mediaPlayerSizeChanged(%p)", this); |
@@ -2895,7 +2897,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 |
@@ -2931,9 +2933,6 @@ bool HTMLMediaElement::stoppedDueToErrors() const |
void HTMLMediaElement::updatePlayState() |
{ |
- if (!m_player) |
- return; |
- |
bool isPlaying = webMediaPlayer() && !webMediaPlayer()->paused(); |
bool shouldBePlaying = potentiallyPlaying(); |
@@ -3024,7 +3023,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(); |
@@ -3037,7 +3036,10 @@ void HTMLMediaElement::clearMediaPlayerAndAudioSourceProviderClientWithoutLockin |
if (audioSourceProvider()) |
audioSourceProvider()->setClient(0); |
#endif |
- m_player.clear(); |
+ if (m_webMediaPlayer) { |
+ m_audioSourceProvider.wrap(0); |
philipj_slow
2015/07/01 13:49:19
Use nullptr here, and why not in the above setClie
Srirama
2015/07/03 12:59:01
Done. Thanks for the info, generally i used to loo
philipj_slow
2015/07/06 11:07:10
Following local style is always the most important
|
+ m_webMediaPlayer.clear(); |
+ } |
} |
void HTMLMediaElement::clearMediaPlayer(int flags) |
@@ -3262,7 +3264,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; |
@@ -3444,7 +3446,10 @@ void HTMLMediaElement::createMediaPlayer() |
closeMediaSource(); |
- m_player = MediaPlayer::create(this); |
+ if (m_webMediaPlayer) { |
+ m_audioSourceProvider.wrap(0); |
philipj_slow
2015/07/01 13:49:18
Ditto.
Srirama
2015/07/03 12:59:01
Done.
|
+ m_webMediaPlayer.clear(); |
+ } |
// We haven't yet found out if any remote routes are available. |
m_remoteRoutesAvailable = false; |
@@ -3468,14 +3473,6 @@ void HTMLMediaElement::setAudioSourceNode(AudioSourceProviderClient* sourceNode) |
if (audioSourceProvider()) |
audioSourceProvider()->setClient(m_audioSourceNode); |
} |
- |
-AudioSourceProvider* HTMLMediaElement::audioSourceProvider() |
-{ |
- if (m_player) |
- return m_player->audioSourceProvider(); |
- |
- return nullptr; |
-} |
#endif |
const AtomicString& HTMLMediaElement::mediaGroup() const |
@@ -3587,7 +3584,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; |
@@ -3607,7 +3604,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)); |
} |
@@ -3678,12 +3675,100 @@ void HTMLMediaElement::selectInitialTracksIfNecessary() |
videoTracks().anonymousIndexedGetter(0)->setSelected(true); |
} |
+void HTMLMediaElement::prepareAndLoadMediaPlayer(const WTF::String& url) |
philipj_slow
2015/07/01 13:49:19
Maybe this can simply be folded into startPlayerLo
Srirama
2015/07/03 12:59:02
Done. Moved it to startPlayerLoad
|
+{ |
+ ASSERT(!m_webMediaPlayer); |
+ |
+ WebURL poster = mediaPlayerPosterURL(); |
philipj_slow
2015/07/01 13:49:19
Inline this into the setPoster call as that's the
Srirama
2015/07/03 12:59:02
Done.
|
+ |
+ KURL kurl(ParsedURLString, url); |
philipj_slow
2015/07/01 13:49:18
Move this down to where it is used, or maybe inlin
Srirama
2015/07/03 12:59:02
Done. Moved it down, but didn't inline it as it is
|
+ LocalFrame* frame = document().frame(); |
+ ASSERT(frame); |
philipj_slow
2015/07/01 13:49:18
In the original code the case !webFrame case was h
Srirama
2015/07/03 12:59:01
Added similar check in executeDeferredLoad() to be
philipj_slow
2015/07/06 11:07:10
See new comment on the moved code.
|
+ m_webMediaPlayer = frame->loader().client()->createWebMediaPlayer(this, kurl); |
+ if (!m_webMediaPlayer) |
philipj_slow
2015/07/01 13:49:19
Can this happen, and should it be treated as a dec
Srirama
2015/07/03 12:59:02
It can previously because of webframe null case bu
philipj_slow
2015/07/06 11:07:10
Acknowledged.
|
+ return; |
+ |
+ if (layoutObject()) |
+ layoutObject()->setShouldDoFullPaintInvalidation(); |
+#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 (!Heap::isHeapObjectAlive(m_audioSourceNode) && audioSourceProvider()) |
audioSourceProvider()->setClient(nullptr); |
} |
+ |
+void HTMLMediaElement::AudioSourceProviderImpl::wrap(WebAudioSourceProvider* provider) |
philipj_slow
2015/07/01 13:49:19
I'd like someone who knows Web Audio to take a loo
Srirama
2015/07/03 12:59:01
Acknowledged.
|
+{ |
+ 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 |
} |