Index: third_party/WebKit/Source/core/html/HTMLMediaElement.cpp |
diff --git a/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp b/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp |
index 5aba8cc8fca08d2ab2cdc0d41dec9571ad741b24..26c96f482d36418c0f2e33185ac42c97bb136068 100644 |
--- a/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp |
+++ b/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp |
@@ -2558,7 +2558,6 @@ void HTMLMediaElement::togglePlayState() { |
} |
AudioTrackList& HTMLMediaElement::audioTracks() { |
- DCHECK(RuntimeEnabledFeatures::audioVideoTracksEnabled()); |
return *m_audioTracks; |
} |
@@ -2600,9 +2599,6 @@ WebMediaPlayer::TrackId HTMLMediaElement::addAudioTrack( |
<< (String)label << "', '" << (String)language << "', " |
<< boolString(enabled) << ")"; |
- if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) |
- return blink::WebMediaPlayer::TrackId(); |
- |
AudioTrack* audioTrack = |
AudioTrack::create(id, kindString, label, language, enabled); |
audioTracks().add(audioTrack); |
@@ -2613,14 +2609,10 @@ WebMediaPlayer::TrackId HTMLMediaElement::addAudioTrack( |
void HTMLMediaElement::removeAudioTrack(WebMediaPlayer::TrackId trackId) { |
BLINK_MEDIA_LOG << "removeAudioTrack(" << (void*)this << ")"; |
- if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) |
- return; |
- |
audioTracks().remove(trackId); |
} |
VideoTrackList& HTMLMediaElement::videoTracks() { |
- DCHECK(RuntimeEnabledFeatures::audioVideoTracksEnabled()); |
return *m_videoTracks; |
} |
@@ -2655,9 +2647,6 @@ WebMediaPlayer::TrackId HTMLMediaElement::addVideoTrack( |
<< (String)label << "', '" << (String)language << "', " |
<< boolString(selected) << ")"; |
- if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) |
- return blink::WebMediaPlayer::TrackId(); |
- |
// If another track was selected (potentially by the user), leave it selected. |
if (selected && videoTracks().selectedIndex() != -1) |
selected = false; |
@@ -2672,9 +2661,6 @@ WebMediaPlayer::TrackId HTMLMediaElement::addVideoTrack( |
void HTMLMediaElement::removeVideoTrack(WebMediaPlayer::TrackId trackId) { |
BLINK_MEDIA_LOG << "removeVideoTrack(" << (void*)this << ")"; |
- if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) |
- return; |
- |
videoTracks().remove(trackId); |
} |
@@ -3205,6 +3191,21 @@ void HTMLMediaElement::remotePlaybackStarted() { |
remotePlaybackClient()->stateChanged(WebRemotePlaybackState::Connected); |
} |
+bool HTMLMediaElement::hasSelectedVideoTrack() { |
+ DCHECK(RuntimeEnabledFeatures::backgroundVideoTrackOptimizationEnabled()); |
+ |
+ return m_videoTracks && m_videoTracks->selectedIndex() != -1; |
+} |
+ |
+WebMediaPlayer::TrackId HTMLMediaElement::getSelectedVideoTrackId() { |
+ DCHECK(RuntimeEnabledFeatures::backgroundVideoTrackOptimizationEnabled()); |
+ DCHECK(hasSelectedVideoTrack()); |
+ |
+ int selectedTrackIndex = m_videoTracks->selectedIndex(); |
+ VideoTrack* track = m_videoTracks->anonymousIndexedGetter(selectedTrackIndex); |
+ return track->id(); |
+} |
+ |
bool HTMLMediaElement::isAutoplayingMuted() { |
if (!isHTMLVideoElement() || |
!RuntimeEnabledFeatures::autoplayMutedVideosEnabled()) { |
@@ -3859,8 +3860,10 @@ DEFINE_TRACE_WRAPPERS(HTMLMediaElement) { |
} |
void HTMLMediaElement::createPlaceholderTracksIfNecessary() { |
- if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) |
+ if (!RuntimeEnabledFeatures::audioVideoTracksEnabled() && |
+ !RuntimeEnabledFeatures::backgroundVideoTrackOptimizationEnabled()) { |
return; |
+ } |
// Create a placeholder audio track if the player says it has audio but it |
// didn't explicitly announce the tracks. |
@@ -3876,8 +3879,10 @@ void HTMLMediaElement::createPlaceholderTracksIfNecessary() { |
} |
void HTMLMediaElement::selectInitialTracksIfNecessary() { |
- if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) |
+ if (!RuntimeEnabledFeatures::audioVideoTracksEnabled() && |
+ !RuntimeEnabledFeatures::backgroundVideoTrackOptimizationEnabled()) { |
return; |
+ } |
// Enable the first audio track if an audio track hasn't been enabled yet. |
if (audioTracks().length() > 0 && !audioTracks().hasEnabledTrack()) |