Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(762)

Unified Diff: Source/core/html/HTMLMediaElement.cpp

Issue 1055503002: Eliminate MediaPlayer & MediaPlayerClient abstractions (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Added separate interface for EncryptedMedia Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/html/HTMLMediaElement.cpp
diff --git a/Source/core/html/HTMLMediaElement.cpp b/Source/core/html/HTMLMediaElement.cpp
index 237fdde0e1d0bd7b657796f0368964d5884a5204..a90d02da464cefe36189c8067d7dc87a8e248520 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"
@@ -330,7 +334,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())
@@ -486,10 +490,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();
}
@@ -504,7 +508,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();
@@ -538,17 +542,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 (!autoplay() && m_player)
+ if (!autoplay())
philipj_slow 2015/05/06 15:39:32 Is dropping the m_player bit entirely equivalent?
Srirama 2015/05/19 10:39:46 I have added the webmediaplayer check to be on saf
setPlayerPreload();
} else if (name == mediagroupAttr && RuntimeEnabledFeatures::mediaControllerEnabled()) {
@@ -989,7 +993,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 {
@@ -1028,14 +1032,15 @@ void HTMLMediaElement::startPlayerLoad()
if (!requestURL.pass().isEmpty())
requestURL.setPass(String());
- m_player->load(loadType(), requestURL, corsMode());
+ loadMediaPlayer(requestURL);
}
void HTMLMediaElement::setPlayerPreload()
{
- m_player->setPreload(m_preload);
philipj_slow 2015/05/06 15:39:33 The code doesn't looks quite like this any more, s
Srirama 2015/05/19 10:39:46 Rebased to latest.
+ if (m_webMediaPlayer)
+ m_webMediaPlayer->setPreload(m_preload);
- if (loadIsDeferred() && m_preload != MediaPlayer::None)
+ if (loadIsDeferred() && m_preload != WebMediaPlayer::PreloadNone)
startDeferredLoad();
}
@@ -1299,7 +1304,7 @@ void HTMLMediaElement::cancelPendingEventsAndCallbacks()
source->cancelPendingErrorEvent();
}
-void HTMLMediaElement::mediaPlayerNetworkStateChanged()
+void HTMLMediaElement::networkStateChanged()
{
setNetworkState(webMediaPlayer()->networkState());
}
@@ -1390,7 +1395,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
@@ -1401,7 +1405,7 @@ void HTMLMediaElement::changeNetworkStateFromLoadingToIdle()
m_networkState = NETWORK_IDLE;
}
-void HTMLMediaElement::mediaPlayerReadyStateChanged()
+void HTMLMediaElement::readyStateChanged()
{
setReadyState(static_cast<ReadyState>(webMediaPlayer()->readyState()));
}
@@ -1556,7 +1560,6 @@ void HTMLMediaElement::setReadyState(ReadyState state)
void HTMLMediaElement::progressEventTimerFired(Timer<HTMLMediaElement>*)
{
- ASSERT(m_player);
if (m_networkState != NETWORK_LOADING)
return;
@@ -1609,7 +1612,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.
@@ -1783,10 +1786,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
+ // FIXME: remove m_webMediaPlayer check once we figure out how m_webMediaPlayer is going
philipj_slow 2015/05/06 15:39:33 It seems somewhat likely that this problem will ma
Srirama 2015/05/19 10:39:46 keeping it for time being as per the below comment
+ // out of sync with readystate. m_webMediaPlayer is cleared but readystate is not set
// to HAVE_NOTHING
- if (!m_player || m_readyState < HAVE_METADATA)
+ 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
@@ -1855,7 +1858,7 @@ HTMLMediaElement::DirectionOfPlayback HTMLMediaElement::directionOfPlayback() co
void HTMLMediaElement::updatePlaybackRate()
{
double effectiveRate = effectivePlaybackRate();
- if (m_player && potentiallyPlaying())
+ if (potentiallyPlaying())
philipj_slow 2015/05/06 15:39:32 This doesn't quite jive with the FIXME in HTMLMedi
Srirama 2015/05/19 10:39:46 Logically what you were saying is correct, in both
webMediaPlayer()->setRate(effectiveRate);
}
@@ -1875,13 +1878,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;
}
@@ -1918,7 +1921,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
@@ -1978,7 +1981,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;
@@ -2123,7 +2126,7 @@ void HTMLMediaElement::startPlaybackProgressTimer()
void HTMLMediaElement::playbackProgressTimerFired(Timer<HTMLMediaElement>*)
{
- ASSERT(m_player);
+ ASSERT(m_webMediaPlayer);
if (!std::isnan(m_fragmentEndTime) && currentTime() >= m_fragmentEndTime && directionOfPlayback() == Forward) {
m_fragmentEndTime = std::numeric_limits<double>::quiet_NaN();
@@ -2219,11 +2222,11 @@ void HTMLMediaElement::audioTracksTimerFired(Timer<HTMLMediaElement>*)
webMediaPlayer()->enabledAudioTracksChanged(enabledTrackIds);
}
-WebMediaPlayer::TrackId HTMLMediaElement::addAudioTrack(const String& id, blink::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;
@@ -2263,11 +2266,11 @@ void HTMLMediaElement::selectedVideoTrackChanged(WebMediaPlayer::TrackId* select
webMediaPlayer()->selectedVideoTrackChanged(selectedTrackId);
}
-WebMediaPlayer::TrackId HTMLMediaElement::addVideoTrack(const String& id, blink::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;
@@ -2292,7 +2295,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.
@@ -2321,10 +2324,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;
@@ -2335,7 +2338,7 @@ void HTMLMediaElement::mediaPlayerDidRemoveTextTrack(WebInbandTextTrack* webTrac
if (!textTrack)
return;
- removeTextTrack(textTrack.get());
+ mediaPlayerRemoveTextTrack(textTrack.get());
}
void HTMLMediaElement::textTracksChanged()
@@ -2344,14 +2347,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);
@@ -2397,7 +2400,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.
@@ -2430,7 +2433,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.
@@ -2458,7 +2461,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)
@@ -2665,7 +2668,7 @@ void HTMLMediaElement::sourceWasRemoved(HTMLSourceElement* source)
}
}
-void HTMLMediaElement::mediaPlayerTimeChanged()
+void HTMLMediaElement::timeChanged()
{
WTF_LOG(Media, "HTMLMediaElement::mediaPlayerTimeChanged(%p)", this);
@@ -2718,19 +2721,19 @@ void HTMLMediaElement::mediaPlayerTimeChanged()
updatePlayState();
}
-void HTMLMediaElement::mediaPlayerDurationChanged()
+void HTMLMediaElement::durationChanged()
{
- WTF_LOG(Media, "HTMLMediaElement::mediaPlayerDurationChanged(%p)", this);
+ WTF_LOG(Media, "HTMLMediaElement::durationChanged(%p)", this);
// FIXME: Change MediaPlayerClient & WebMediaPlayer to convey
philipj_slow 2015/05/06 15:39:32 MediaPlayerClient is gone.
Srirama 2015/05/19 10:39:46 Done.
// 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());
+ 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)
@@ -2749,7 +2752,7 @@ void HTMLMediaElement::durationChanged(double duration, bool requestSeek)
seek(duration);
}
-void HTMLMediaElement::mediaPlayerPlaybackStateChanged()
+void HTMLMediaElement::playbackStateChanged()
{
WTF_LOG(Media, "HTMLMediaElement::mediaPlayerPlaybackStateChanged(%p)", this);
@@ -2762,7 +2765,7 @@ void HTMLMediaElement::mediaPlayerPlaybackStateChanged()
playInternal();
}
-void HTMLMediaElement::mediaPlayerRequestFullscreen()
+void HTMLMediaElement::requestFullscreen()
philipj_slow 2015/05/06 15:39:32 This name is a bit tricky, it could be seen as an
Srirama 2015/05/19 10:39:46 It is like this because we are overriding the func
{
WTF_LOG(Media, "HTMLMediaElement::mediaPlayerRequestFullscreen(%p)", this);
@@ -2773,7 +2776,7 @@ void HTMLMediaElement::mediaPlayerRequestFullscreen()
enterFullscreen();
}
-void HTMLMediaElement::mediaPlayerRequestSeek(double time)
+void HTMLMediaElement::requestSeek(double time)
philipj_slow 2015/05/06 15:39:32 I think in this case too the old name is good beca
Srirama 2015/05/19 10:39:46 Same as above.
{
// The player is the source of this seek request.
if (m_mediaController) {
@@ -2805,7 +2808,7 @@ void HTMLMediaElement::disconnectedFromRemoteDevice()
}
// MediaPlayerPresentation methods
-void HTMLMediaElement::mediaPlayerRepaint()
+void HTMLMediaElement::repaint()
{
if (m_webLayer)
m_webLayer->invalidate();
@@ -2815,7 +2818,7 @@ void HTMLMediaElement::mediaPlayerRepaint()
layoutObject()->setShouldDoFullPaintInvalidation();
}
-void HTMLMediaElement::mediaPlayerSizeChanged()
+void HTMLMediaElement::sizeChanged()
{
WTF_LOG(Media, "HTMLMediaElement::mediaPlayerSizeChanged(%p)", this);
@@ -2880,7 +2883,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
@@ -2916,9 +2919,6 @@ bool HTMLMediaElement::stoppedDueToErrors() const
void HTMLMediaElement::updatePlayState()
{
- if (!m_player)
- return;
-
bool isPlaying = webMediaPlayer() && !webMediaPlayer()->paused();
bool shouldBePlaying = potentiallyPlaying();
@@ -3009,7 +3009,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();
@@ -3022,7 +3022,7 @@ void HTMLMediaElement::clearMediaPlayerAndAudioSourceProviderClientWithoutLockin
if (audioSourceProvider())
audioSourceProvider()->setClient(0);
#endif
- m_player.clear();
+ m_webMediaPlayer.clear(); // Revisit
}
void HTMLMediaElement::clearMediaPlayer(int flags)
@@ -3244,7 +3244,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;
@@ -3426,18 +3426,9 @@ void HTMLMediaElement::createMediaPlayer()
closeMediaSource();
- m_player = MediaPlayer::create(this);
-
// 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)
@@ -3452,10 +3443,8 @@ void HTMLMediaElement::setAudioSourceNode(AudioSourceProviderClient* sourceNode)
AudioSourceProvider* HTMLMediaElement::audioSourceProvider()
{
- if (m_player)
- return m_player->audioSourceProvider();
-
- return nullptr;
+ // null check
+ return &m_audioSourceProvider;
}
#endif
@@ -3568,7 +3557,7 @@ WebMediaPlayer::CORSMode HTMLMediaElement::corsMode() const
return WebMediaPlayer::CORSModeAnonymous;
}
-void HTMLMediaElement::mediaPlayerSetWebLayer(blink::WebLayer* webLayer)
+void HTMLMediaElement::setWebLayer(blink::WebLayer* webLayer)
{
if (webLayer == m_webLayer)
return;
@@ -3588,7 +3577,7 @@ void HTMLMediaElement::mediaPlayerSetWebLayer(blink::WebLayer* webLayer)
GraphicsLayer::registerContentsLayer(m_webLayer);
}
-void HTMLMediaElement::mediaPlayerMediaSourceOpened(blink::WebMediaSource* webMediaSource)
+void HTMLMediaElement::mediaSourceOpened(blink::WebMediaSource* webMediaSource)
{
m_mediaSource->setWebMediaSourceAndOpen(adoptPtr(webMediaSource));
}
@@ -3659,12 +3648,98 @@ void HTMLMediaElement::selectInitialTracksIfNecessary()
videoTracks().anonymousIndexedGetter(0)->setSelected(true);
}
+void HTMLMediaElement::loadMediaPlayer(const WTF::String& url)
philipj_slow 2015/05/06 15:39:33 loadMediaPlayer() as a name isn't only part of wha
Srirama 2015/05/19 10:39:46 I renamed it to prepareAndLoadMediaPlayer to be co
+{
+ 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(preloadType());
+
+ m_webMediaPlayer->load(loadType(), kurl, corsMode());
+
+ if (isFullscreen())
+ m_webMediaPlayer->enterFullscreen();
+}
+
#if ENABLE(WEB_AUDIO)
void HTMLMediaElement::clearWeakMembers(Visitor* visitor)
{
if (!visitor->isAlive(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
}

Powered by Google App Engine
This is Rietveld 408576698