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

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLMediaElement.cpp

Issue 2532233003: [Video] Add dummy video/audio tracks inactive to select them later. (Closed)
Patch Set: Created 4 years 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 unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/mediasource/MediaSource.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights
3 * reserved. 3 * reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 case WebMediaPlayer::PreloadMetaData: 277 case WebMediaPlayer::PreloadMetaData:
278 return "metadata"; 278 return "metadata";
279 case WebMediaPlayer::PreloadAuto: 279 case WebMediaPlayer::PreloadAuto:
280 return "auto"; 280 return "auto";
281 } 281 }
282 282
283 NOTREACHED(); 283 NOTREACHED();
284 return String(); 284 return String();
285 } 285 }
286 286
287 bool hasAudioVideoTracks() {
chcunningham 2016/11/29 22:39:18 You can make this a media:: namespaced utilitiy me
mlamouri (slow - plz ping) 2016/11/30 09:34:00 That wouldn't be available from Blink. Or did you
whywhat 2016/11/30 20:45:39 I've put it into HTMLMediaElement as a public stat
288 return RuntimeEnabledFeatures::audioVideoTracksEnabled() ||
289 RuntimeEnabledFeatures::backgroundVideoTrackOptimizationEnabled();
290 }
mlamouri (slow - plz ping) 2016/11/30 09:34:00 nit: can you name the method hasAudioVideoTracksEn
whywhat 2016/11/30 20:45:39 The meaning is not about the feature enabled but i
291
287 } // anonymous namespace 292 } // anonymous namespace
288 293
289 class HTMLMediaElement::AutoplayHelperClientImpl 294 class HTMLMediaElement::AutoplayHelperClientImpl
290 : public AutoplayExperimentHelper::Client { 295 : public AutoplayExperimentHelper::Client {
291 public: 296 public:
292 static AutoplayHelperClientImpl* create(HTMLMediaElement* element) { 297 static AutoplayHelperClientImpl* create(HTMLMediaElement* element) {
293 return new AutoplayHelperClientImpl(element); 298 return new AutoplayHelperClientImpl(element);
294 } 299 }
295 300
296 virtual ~AutoplayHelperClientImpl(); 301 virtual ~AutoplayHelperClientImpl();
(...skipping 2261 matching lines...) Expand 10 before | Expand all | Expand 10 after
2558 } 2563 }
2559 2564
2560 AudioTrackList& HTMLMediaElement::audioTracks() { 2565 AudioTrackList& HTMLMediaElement::audioTracks() {
2561 return *m_audioTracks; 2566 return *m_audioTracks;
2562 } 2567 }
2563 2568
2564 void HTMLMediaElement::audioTrackChanged(AudioTrack* track) { 2569 void HTMLMediaElement::audioTrackChanged(AudioTrack* track) {
2565 BLINK_MEDIA_LOG << "audioTrackChanged(" << (void*)this 2570 BLINK_MEDIA_LOG << "audioTrackChanged(" << (void*)this
2566 << ") trackId= " << String(track->id()) 2571 << ") trackId= " << String(track->id())
2567 << " enabled=" << boolString(track->enabled()); 2572 << " enabled=" << boolString(track->enabled());
2568 DCHECK(RuntimeEnabledFeatures::audioVideoTracksEnabled()); 2573 DCHECK(hasAudioVideoTracks());
2569 2574
2570 audioTracks().scheduleChangeEvent(); 2575 audioTracks().scheduleChangeEvent();
2571 2576
2572 if (m_mediaSource) 2577 if (m_mediaSource)
2573 m_mediaSource->onTrackChanged(track); 2578 m_mediaSource->onTrackChanged(track);
2574 2579
2575 if (!m_audioTracksTimer.isActive()) 2580 if (!m_audioTracksTimer.isActive())
2576 m_audioTracksTimer.startOneShot(0, BLINK_FROM_HERE); 2581 m_audioTracksTimer.startOneShot(0, BLINK_FROM_HERE);
2577 } 2582 }
2578 2583
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
2613 } 2618 }
2614 2619
2615 VideoTrackList& HTMLMediaElement::videoTracks() { 2620 VideoTrackList& HTMLMediaElement::videoTracks() {
2616 return *m_videoTracks; 2621 return *m_videoTracks;
2617 } 2622 }
2618 2623
2619 void HTMLMediaElement::selectedVideoTrackChanged(VideoTrack* track) { 2624 void HTMLMediaElement::selectedVideoTrackChanged(VideoTrack* track) {
2620 BLINK_MEDIA_LOG << "selectedVideoTrackChanged(" << (void*)this 2625 BLINK_MEDIA_LOG << "selectedVideoTrackChanged(" << (void*)this
2621 << ") selectedTrackId=" 2626 << ") selectedTrackId="
2622 << (track->selected() ? String(track->id()) : "none"); 2627 << (track->selected() ? String(track->id()) : "none");
2623 DCHECK(RuntimeEnabledFeatures::audioVideoTracksEnabled()); 2628 DCHECK(hasAudioVideoTracks());
2624 2629
2625 if (track->selected()) 2630 if (track->selected())
2626 videoTracks().trackSelected(track->id()); 2631 videoTracks().trackSelected(track->id());
2627 2632
2628 videoTracks().scheduleChangeEvent(); 2633 videoTracks().scheduleChangeEvent();
2629 2634
2630 if (m_mediaSource) 2635 if (m_mediaSource)
2631 m_mediaSource->onTrackChanged(track); 2636 m_mediaSource->onTrackChanged(track);
2632 2637
2633 WebMediaPlayer::TrackId id = track->id(); 2638 WebMediaPlayer::TrackId id = track->id();
(...skipping 1219 matching lines...) Expand 10 before | Expand all | Expand 10 after
3853 } 3858 }
3854 3859
3855 DEFINE_TRACE_WRAPPERS(HTMLMediaElement) { 3860 DEFINE_TRACE_WRAPPERS(HTMLMediaElement) {
3856 visitor->traceWrappers(m_videoTracks); 3861 visitor->traceWrappers(m_videoTracks);
3857 visitor->traceWrappers(m_audioTracks); 3862 visitor->traceWrappers(m_audioTracks);
3858 visitor->traceWrappers(m_textTracks); 3863 visitor->traceWrappers(m_textTracks);
3859 HTMLElement::traceWrappers(visitor); 3864 HTMLElement::traceWrappers(visitor);
3860 } 3865 }
3861 3866
3862 void HTMLMediaElement::createPlaceholderTracksIfNecessary() { 3867 void HTMLMediaElement::createPlaceholderTracksIfNecessary() {
3863 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled() && 3868 if (!hasAudioVideoTracks())
3864 !RuntimeEnabledFeatures::backgroundVideoTrackOptimizationEnabled()) {
3865 return; 3869 return;
3866 }
3867 3870
3868 // Create a placeholder audio track if the player says it has audio but it 3871 // Create a placeholder audio track if the player says it has audio but it
3869 // didn't explicitly announce the tracks. 3872 // didn't explicitly announce the tracks.
3870 if (hasAudio() && !audioTracks().length()) 3873 if (hasAudio() && !audioTracks().length()) {
3871 addAudioTrack("audio", WebMediaPlayerClient::AudioTrackKindMain, 3874 addAudioTrack("audio", WebMediaPlayerClient::AudioTrackKindMain,
3872 "Audio Track", "", true); 3875 "Audio Track", "", false);
3876 }
3873 3877
3874 // Create a placeholder video track if the player says it has video but it 3878 // Create a placeholder video track if the player says it has video but it
3875 // didn't explicitly announce the tracks. 3879 // didn't explicitly announce the tracks.
3876 if (hasVideo() && !videoTracks().length()) 3880 if (hasVideo() && !videoTracks().length()) {
3877 addVideoTrack("video", WebMediaPlayerClient::VideoTrackKindMain, 3881 addVideoTrack("video", WebMediaPlayerClient::VideoTrackKindMain,
3878 "Video Track", "", true); 3882 "Video Track", "", false);
3883 }
3879 } 3884 }
3880 3885
3881 void HTMLMediaElement::selectInitialTracksIfNecessary() { 3886 void HTMLMediaElement::selectInitialTracksIfNecessary() {
3882 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled() && 3887 if (!hasAudioVideoTracks())
3883 !RuntimeEnabledFeatures::backgroundVideoTrackOptimizationEnabled()) {
3884 return; 3888 return;
3885 }
3886 3889
3887 // Enable the first audio track if an audio track hasn't been enabled yet. 3890 // Enable the first audio track if an audio track hasn't been enabled yet.
3888 if (audioTracks().length() > 0 && !audioTracks().hasEnabledTrack()) 3891 if (audioTracks().length() > 0 && !audioTracks().hasEnabledTrack())
3889 audioTracks().anonymousIndexedGetter(0)->setEnabled(true); 3892 audioTracks().anonymousIndexedGetter(0)->setEnabled(true);
3890 3893
3891 // Select the first video track if a video track hasn't been selected yet. 3894 // Select the first video track if a video track hasn't been selected yet.
3892 if (videoTracks().length() > 0 && videoTracks().selectedIndex() == -1) 3895 if (videoTracks().length() > 0 && videoTracks().selectedIndex() == -1)
3893 videoTracks().anonymousIndexedGetter(0)->setSelected(true); 3896 videoTracks().anonymousIndexedGetter(0)->setSelected(true);
3894 } 3897 }
3895 3898
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
4202 4205
4203 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() 4206 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect()
4204 const { 4207 const {
4205 IntRect result; 4208 IntRect result;
4206 if (LayoutObject* object = m_element->layoutObject()) 4209 if (LayoutObject* object = m_element->layoutObject())
4207 result = object->absoluteBoundingBoxRect(); 4210 result = object->absoluteBoundingBoxRect();
4208 return result; 4211 return result;
4209 } 4212 }
4210 4213
4211 } // namespace blink 4214 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/mediasource/MediaSource.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698