| OLD | NEW |
| 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 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 // Keep the same logic as in media_codec_util.h. | 392 // Keep the same logic as in media_codec_util.h. |
| 393 if (url.isNull() || url.isEmpty()) | 393 if (url.isNull() || url.isEmpty()) |
| 394 return false; | 394 return false; |
| 395 | 395 |
| 396 if (!url.isLocalFile() && !url.protocolIs("http") && !url.protocolIs("https")) | 396 if (!url.isLocalFile() && !url.protocolIs("http") && !url.protocolIs("https")) |
| 397 return false; | 397 return false; |
| 398 | 398 |
| 399 return url.getString().contains("m3u8"); | 399 return url.getString().contains("m3u8"); |
| 400 } | 400 } |
| 401 | 401 |
| 402 bool HTMLMediaElement::mediaTracksEnabledInternally() { |
| 403 return RuntimeEnabledFeatures::audioVideoTracksEnabled() || |
| 404 RuntimeEnabledFeatures::backgroundVideoTrackOptimizationEnabled(); |
| 405 } |
| 406 |
| 402 HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, | 407 HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, |
| 403 Document& document) | 408 Document& document) |
| 404 : HTMLElement(tagName, document), | 409 : HTMLElement(tagName, document), |
| 405 ActiveScriptWrappable(this), | 410 ActiveScriptWrappable(this), |
| 406 ActiveDOMObject(&document), | 411 ActiveDOMObject(&document), |
| 407 m_loadTimer(this, &HTMLMediaElement::loadTimerFired), | 412 m_loadTimer(this, &HTMLMediaElement::loadTimerFired), |
| 408 m_progressEventTimer(this, &HTMLMediaElement::progressEventTimerFired), | 413 m_progressEventTimer(this, &HTMLMediaElement::progressEventTimerFired), |
| 409 m_playbackProgressTimer(this, | 414 m_playbackProgressTimer(this, |
| 410 &HTMLMediaElement::playbackProgressTimerFired), | 415 &HTMLMediaElement::playbackProgressTimerFired), |
| 411 m_audioTracksTimer(this, &HTMLMediaElement::audioTracksTimerFired), | 416 m_audioTracksTimer(this, &HTMLMediaElement::audioTracksTimerFired), |
| (...skipping 2141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2553 } | 2558 } |
| 2554 | 2559 |
| 2555 AudioTrackList& HTMLMediaElement::audioTracks() { | 2560 AudioTrackList& HTMLMediaElement::audioTracks() { |
| 2556 return *m_audioTracks; | 2561 return *m_audioTracks; |
| 2557 } | 2562 } |
| 2558 | 2563 |
| 2559 void HTMLMediaElement::audioTrackChanged(AudioTrack* track) { | 2564 void HTMLMediaElement::audioTrackChanged(AudioTrack* track) { |
| 2560 BLINK_MEDIA_LOG << "audioTrackChanged(" << (void*)this | 2565 BLINK_MEDIA_LOG << "audioTrackChanged(" << (void*)this |
| 2561 << ") trackId= " << String(track->id()) | 2566 << ") trackId= " << String(track->id()) |
| 2562 << " enabled=" << boolString(track->enabled()); | 2567 << " enabled=" << boolString(track->enabled()); |
| 2563 DCHECK(RuntimeEnabledFeatures::audioVideoTracksEnabled()); | 2568 DCHECK(mediaTracksEnabledInternally()); |
| 2564 | 2569 |
| 2565 audioTracks().scheduleChangeEvent(); | 2570 audioTracks().scheduleChangeEvent(); |
| 2566 | 2571 |
| 2567 if (m_mediaSource) | 2572 if (m_mediaSource) |
| 2568 m_mediaSource->onTrackChanged(track); | 2573 m_mediaSource->onTrackChanged(track); |
| 2569 | 2574 |
| 2570 if (!m_audioTracksTimer.isActive()) | 2575 if (!m_audioTracksTimer.isActive()) |
| 2571 m_audioTracksTimer.startOneShot(0, BLINK_FROM_HERE); | 2576 m_audioTracksTimer.startOneShot(0, BLINK_FROM_HERE); |
| 2572 } | 2577 } |
| 2573 | 2578 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2608 } | 2613 } |
| 2609 | 2614 |
| 2610 VideoTrackList& HTMLMediaElement::videoTracks() { | 2615 VideoTrackList& HTMLMediaElement::videoTracks() { |
| 2611 return *m_videoTracks; | 2616 return *m_videoTracks; |
| 2612 } | 2617 } |
| 2613 | 2618 |
| 2614 void HTMLMediaElement::selectedVideoTrackChanged(VideoTrack* track) { | 2619 void HTMLMediaElement::selectedVideoTrackChanged(VideoTrack* track) { |
| 2615 BLINK_MEDIA_LOG << "selectedVideoTrackChanged(" << (void*)this | 2620 BLINK_MEDIA_LOG << "selectedVideoTrackChanged(" << (void*)this |
| 2616 << ") selectedTrackId=" | 2621 << ") selectedTrackId=" |
| 2617 << (track->selected() ? String(track->id()) : "none"); | 2622 << (track->selected() ? String(track->id()) : "none"); |
| 2618 DCHECK(RuntimeEnabledFeatures::audioVideoTracksEnabled()); | 2623 DCHECK(mediaTracksEnabledInternally()); |
| 2619 | 2624 |
| 2620 if (track->selected()) | 2625 if (track->selected()) |
| 2621 videoTracks().trackSelected(track->id()); | 2626 videoTracks().trackSelected(track->id()); |
| 2622 | 2627 |
| 2623 videoTracks().scheduleChangeEvent(); | 2628 videoTracks().scheduleChangeEvent(); |
| 2624 | 2629 |
| 2625 if (m_mediaSource) | 2630 if (m_mediaSource) |
| 2626 m_mediaSource->onTrackChanged(track); | 2631 m_mediaSource->onTrackChanged(track); |
| 2627 | 2632 |
| 2628 WebMediaPlayer::TrackId id = track->id(); | 2633 WebMediaPlayer::TrackId id = track->id(); |
| (...skipping 1213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3842 } | 3847 } |
| 3843 | 3848 |
| 3844 DEFINE_TRACE_WRAPPERS(HTMLMediaElement) { | 3849 DEFINE_TRACE_WRAPPERS(HTMLMediaElement) { |
| 3845 visitor->traceWrappers(m_videoTracks); | 3850 visitor->traceWrappers(m_videoTracks); |
| 3846 visitor->traceWrappers(m_audioTracks); | 3851 visitor->traceWrappers(m_audioTracks); |
| 3847 visitor->traceWrappers(m_textTracks); | 3852 visitor->traceWrappers(m_textTracks); |
| 3848 HTMLElement::traceWrappers(visitor); | 3853 HTMLElement::traceWrappers(visitor); |
| 3849 } | 3854 } |
| 3850 | 3855 |
| 3851 void HTMLMediaElement::createPlaceholderTracksIfNecessary() { | 3856 void HTMLMediaElement::createPlaceholderTracksIfNecessary() { |
| 3852 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled() && | 3857 if (!mediaTracksEnabledInternally()) |
| 3853 !RuntimeEnabledFeatures::backgroundVideoTrackOptimizationEnabled()) { | |
| 3854 return; | 3858 return; |
| 3855 } | |
| 3856 | 3859 |
| 3857 // Create a placeholder audio track if the player says it has audio but it | 3860 // Create a placeholder audio track if the player says it has audio but it |
| 3858 // didn't explicitly announce the tracks. | 3861 // didn't explicitly announce the tracks. |
| 3859 if (hasAudio() && !audioTracks().length()) | 3862 if (hasAudio() && !audioTracks().length()) { |
| 3860 addAudioTrack("audio", WebMediaPlayerClient::AudioTrackKindMain, | 3863 addAudioTrack("audio", WebMediaPlayerClient::AudioTrackKindMain, |
| 3861 "Audio Track", "", true); | 3864 "Audio Track", "", false); |
| 3865 } |
| 3862 | 3866 |
| 3863 // Create a placeholder video track if the player says it has video but it | 3867 // Create a placeholder video track if the player says it has video but it |
| 3864 // didn't explicitly announce the tracks. | 3868 // didn't explicitly announce the tracks. |
| 3865 if (hasVideo() && !videoTracks().length()) | 3869 if (hasVideo() && !videoTracks().length()) { |
| 3866 addVideoTrack("video", WebMediaPlayerClient::VideoTrackKindMain, | 3870 addVideoTrack("video", WebMediaPlayerClient::VideoTrackKindMain, |
| 3867 "Video Track", "", true); | 3871 "Video Track", "", false); |
| 3872 } |
| 3868 } | 3873 } |
| 3869 | 3874 |
| 3870 void HTMLMediaElement::selectInitialTracksIfNecessary() { | 3875 void HTMLMediaElement::selectInitialTracksIfNecessary() { |
| 3871 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled() && | 3876 if (!mediaTracksEnabledInternally()) |
| 3872 !RuntimeEnabledFeatures::backgroundVideoTrackOptimizationEnabled()) { | |
| 3873 return; | 3877 return; |
| 3874 } | |
| 3875 | 3878 |
| 3876 // Enable the first audio track if an audio track hasn't been enabled yet. | 3879 // Enable the first audio track if an audio track hasn't been enabled yet. |
| 3877 if (audioTracks().length() > 0 && !audioTracks().hasEnabledTrack()) | 3880 if (audioTracks().length() > 0 && !audioTracks().hasEnabledTrack()) |
| 3878 audioTracks().anonymousIndexedGetter(0)->setEnabled(true); | 3881 audioTracks().anonymousIndexedGetter(0)->setEnabled(true); |
| 3879 | 3882 |
| 3880 // Select the first video track if a video track hasn't been selected yet. | 3883 // Select the first video track if a video track hasn't been selected yet. |
| 3881 if (videoTracks().length() > 0 && videoTracks().selectedIndex() == -1) | 3884 if (videoTracks().length() > 0 && videoTracks().selectedIndex() == -1) |
| 3882 videoTracks().anonymousIndexedGetter(0)->setSelected(true); | 3885 videoTracks().anonymousIndexedGetter(0)->setSelected(true); |
| 3883 } | 3886 } |
| 3884 | 3887 |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4191 | 4194 |
| 4192 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() | 4195 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() |
| 4193 const { | 4196 const { |
| 4194 IntRect result; | 4197 IntRect result; |
| 4195 if (LayoutObject* object = m_element->layoutObject()) | 4198 if (LayoutObject* object = m_element->layoutObject()) |
| 4196 result = object->absoluteBoundingBoxRect(); | 4199 result = object->absoluteBoundingBoxRect(); |
| 4197 return result; | 4200 return result; |
| 4198 } | 4201 } |
| 4199 | 4202 |
| 4200 } // namespace blink | 4203 } // namespace blink |
| OLD | NEW |