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 2540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2551 } | 2551 } |
2552 | 2552 |
2553 void HTMLMediaElement::togglePlayState() { | 2553 void HTMLMediaElement::togglePlayState() { |
2554 if (paused()) | 2554 if (paused()) |
2555 play(); | 2555 play(); |
2556 else | 2556 else |
2557 pause(); | 2557 pause(); |
2558 } | 2558 } |
2559 | 2559 |
2560 AudioTrackList& HTMLMediaElement::audioTracks() { | 2560 AudioTrackList& HTMLMediaElement::audioTracks() { |
2561 DCHECK(RuntimeEnabledFeatures::audioVideoTracksEnabled()); | |
2562 return *m_audioTracks; | 2561 return *m_audioTracks; |
2563 } | 2562 } |
2564 | 2563 |
2565 void HTMLMediaElement::audioTrackChanged(AudioTrack* track) { | 2564 void HTMLMediaElement::audioTrackChanged(AudioTrack* track) { |
2566 BLINK_MEDIA_LOG << "audioTrackChanged(" << (void*)this | 2565 BLINK_MEDIA_LOG << "audioTrackChanged(" << (void*)this |
2567 << ") trackId= " << String(track->id()) | 2566 << ") trackId= " << String(track->id()) |
2568 << " enabled=" << boolString(track->enabled()); | 2567 << " enabled=" << boolString(track->enabled()); |
2569 DCHECK(RuntimeEnabledFeatures::audioVideoTracksEnabled()); | 2568 DCHECK(RuntimeEnabledFeatures::audioVideoTracksEnabled()); |
2570 | 2569 |
2571 audioTracks().scheduleChangeEvent(); | 2570 audioTracks().scheduleChangeEvent(); |
(...skipping 21 matching lines...) Expand all Loading... |
2593 WebMediaPlayerClient::AudioTrackKind kind, | 2592 WebMediaPlayerClient::AudioTrackKind kind, |
2594 const WebString& label, | 2593 const WebString& label, |
2595 const WebString& language, | 2594 const WebString& language, |
2596 bool enabled) { | 2595 bool enabled) { |
2597 AtomicString kindString = AudioKindToString(kind); | 2596 AtomicString kindString = AudioKindToString(kind); |
2598 BLINK_MEDIA_LOG << "addAudioTrack(" << (void*)this << ", '" << (String)id | 2597 BLINK_MEDIA_LOG << "addAudioTrack(" << (void*)this << ", '" << (String)id |
2599 << "', ' " << (AtomicString)kindString << "', '" | 2598 << "', ' " << (AtomicString)kindString << "', '" |
2600 << (String)label << "', '" << (String)language << "', " | 2599 << (String)label << "', '" << (String)language << "', " |
2601 << boolString(enabled) << ")"; | 2600 << boolString(enabled) << ")"; |
2602 | 2601 |
2603 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) | |
2604 return blink::WebMediaPlayer::TrackId(); | |
2605 | |
2606 AudioTrack* audioTrack = | 2602 AudioTrack* audioTrack = |
2607 AudioTrack::create(id, kindString, label, language, enabled); | 2603 AudioTrack::create(id, kindString, label, language, enabled); |
2608 audioTracks().add(audioTrack); | 2604 audioTracks().add(audioTrack); |
2609 | 2605 |
2610 return audioTrack->id(); | 2606 return audioTrack->id(); |
2611 } | 2607 } |
2612 | 2608 |
2613 void HTMLMediaElement::removeAudioTrack(WebMediaPlayer::TrackId trackId) { | 2609 void HTMLMediaElement::removeAudioTrack(WebMediaPlayer::TrackId trackId) { |
2614 BLINK_MEDIA_LOG << "removeAudioTrack(" << (void*)this << ")"; | 2610 BLINK_MEDIA_LOG << "removeAudioTrack(" << (void*)this << ")"; |
2615 | 2611 |
2616 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) | |
2617 return; | |
2618 | |
2619 audioTracks().remove(trackId); | 2612 audioTracks().remove(trackId); |
2620 } | 2613 } |
2621 | 2614 |
2622 VideoTrackList& HTMLMediaElement::videoTracks() { | 2615 VideoTrackList& HTMLMediaElement::videoTracks() { |
2623 DCHECK(RuntimeEnabledFeatures::audioVideoTracksEnabled()); | |
2624 return *m_videoTracks; | 2616 return *m_videoTracks; |
2625 } | 2617 } |
2626 | 2618 |
2627 void HTMLMediaElement::selectedVideoTrackChanged(VideoTrack* track) { | 2619 void HTMLMediaElement::selectedVideoTrackChanged(VideoTrack* track) { |
2628 BLINK_MEDIA_LOG << "selectedVideoTrackChanged(" << (void*)this | 2620 BLINK_MEDIA_LOG << "selectedVideoTrackChanged(" << (void*)this |
2629 << ") selectedTrackId=" | 2621 << ") selectedTrackId=" |
2630 << (track->selected() ? String(track->id()) : "none"); | 2622 << (track->selected() ? String(track->id()) : "none"); |
2631 DCHECK(RuntimeEnabledFeatures::audioVideoTracksEnabled()); | 2623 DCHECK(RuntimeEnabledFeatures::audioVideoTracksEnabled()); |
2632 | 2624 |
2633 if (track->selected()) | 2625 if (track->selected()) |
(...skipping 14 matching lines...) Expand all Loading... |
2648 WebMediaPlayerClient::VideoTrackKind kind, | 2640 WebMediaPlayerClient::VideoTrackKind kind, |
2649 const WebString& label, | 2641 const WebString& label, |
2650 const WebString& language, | 2642 const WebString& language, |
2651 bool selected) { | 2643 bool selected) { |
2652 AtomicString kindString = VideoKindToString(kind); | 2644 AtomicString kindString = VideoKindToString(kind); |
2653 BLINK_MEDIA_LOG << "addVideoTrack(" << (void*)this << ", '" << (String)id | 2645 BLINK_MEDIA_LOG << "addVideoTrack(" << (void*)this << ", '" << (String)id |
2654 << "', '" << (AtomicString)kindString << "', '" | 2646 << "', '" << (AtomicString)kindString << "', '" |
2655 << (String)label << "', '" << (String)language << "', " | 2647 << (String)label << "', '" << (String)language << "', " |
2656 << boolString(selected) << ")"; | 2648 << boolString(selected) << ")"; |
2657 | 2649 |
2658 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) | |
2659 return blink::WebMediaPlayer::TrackId(); | |
2660 | |
2661 // If another track was selected (potentially by the user), leave it selected. | 2650 // If another track was selected (potentially by the user), leave it selected. |
2662 if (selected && videoTracks().selectedIndex() != -1) | 2651 if (selected && videoTracks().selectedIndex() != -1) |
2663 selected = false; | 2652 selected = false; |
2664 | 2653 |
2665 VideoTrack* videoTrack = | 2654 VideoTrack* videoTrack = |
2666 VideoTrack::create(id, kindString, label, language, selected); | 2655 VideoTrack::create(id, kindString, label, language, selected); |
2667 videoTracks().add(videoTrack); | 2656 videoTracks().add(videoTrack); |
2668 | 2657 |
2669 return videoTrack->id(); | 2658 return videoTrack->id(); |
2670 } | 2659 } |
2671 | 2660 |
2672 void HTMLMediaElement::removeVideoTrack(WebMediaPlayer::TrackId trackId) { | 2661 void HTMLMediaElement::removeVideoTrack(WebMediaPlayer::TrackId trackId) { |
2673 BLINK_MEDIA_LOG << "removeVideoTrack(" << (void*)this << ")"; | 2662 BLINK_MEDIA_LOG << "removeVideoTrack(" << (void*)this << ")"; |
2674 | 2663 |
2675 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) | |
2676 return; | |
2677 | |
2678 videoTracks().remove(trackId); | 2664 videoTracks().remove(trackId); |
2679 } | 2665 } |
2680 | 2666 |
2681 void HTMLMediaElement::addTextTrack(WebInbandTextTrack* webTrack) { | 2667 void HTMLMediaElement::addTextTrack(WebInbandTextTrack* webTrack) { |
2682 // 4.8.10.12.2 Sourcing in-band text tracks | 2668 // 4.8.10.12.2 Sourcing in-band text tracks |
2683 // 1. Associate the relevant data with a new text track and its corresponding | 2669 // 1. Associate the relevant data with a new text track and its corresponding |
2684 // new TextTrack object. | 2670 // new TextTrack object. |
2685 InbandTextTrack* textTrack = InbandTextTrack::create(webTrack); | 2671 InbandTextTrack* textTrack = InbandTextTrack::create(webTrack); |
2686 | 2672 |
2687 // 2. Set the new text track's kind, label, and language based on the | 2673 // 2. Set the new text track's kind, label, and language based on the |
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3198 void HTMLMediaElement::cancelledRemotePlaybackRequest() { | 3184 void HTMLMediaElement::cancelledRemotePlaybackRequest() { |
3199 if (remotePlaybackClient()) | 3185 if (remotePlaybackClient()) |
3200 remotePlaybackClient()->promptCancelled(); | 3186 remotePlaybackClient()->promptCancelled(); |
3201 } | 3187 } |
3202 | 3188 |
3203 void HTMLMediaElement::remotePlaybackStarted() { | 3189 void HTMLMediaElement::remotePlaybackStarted() { |
3204 if (remotePlaybackClient()) | 3190 if (remotePlaybackClient()) |
3205 remotePlaybackClient()->stateChanged(WebRemotePlaybackState::Connected); | 3191 remotePlaybackClient()->stateChanged(WebRemotePlaybackState::Connected); |
3206 } | 3192 } |
3207 | 3193 |
| 3194 bool HTMLMediaElement::hasSelectedVideoTrack() { |
| 3195 DCHECK(RuntimeEnabledFeatures::backgroundVideoTrackOptimizationEnabled()); |
| 3196 |
| 3197 return m_videoTracks && m_videoTracks->selectedIndex() != -1; |
| 3198 } |
| 3199 |
| 3200 WebMediaPlayer::TrackId HTMLMediaElement::getSelectedVideoTrackId() { |
| 3201 DCHECK(RuntimeEnabledFeatures::backgroundVideoTrackOptimizationEnabled()); |
| 3202 DCHECK(hasSelectedVideoTrack()); |
| 3203 |
| 3204 int selectedTrackIndex = m_videoTracks->selectedIndex(); |
| 3205 VideoTrack* track = m_videoTracks->anonymousIndexedGetter(selectedTrackIndex); |
| 3206 return track->id(); |
| 3207 } |
| 3208 |
3208 bool HTMLMediaElement::isAutoplayingMuted() { | 3209 bool HTMLMediaElement::isAutoplayingMuted() { |
3209 if (!isHTMLVideoElement() || | 3210 if (!isHTMLVideoElement() || |
3210 !RuntimeEnabledFeatures::autoplayMutedVideosEnabled()) { | 3211 !RuntimeEnabledFeatures::autoplayMutedVideosEnabled()) { |
3211 return false; | 3212 return false; |
3212 } | 3213 } |
3213 | 3214 |
3214 return !paused() && muted() && isLockedPendingUserGesture(); | 3215 return !paused() && muted() && isLockedPendingUserGesture(); |
3215 } | 3216 } |
3216 | 3217 |
3217 void HTMLMediaElement::requestReload(const WebURL& newUrl) { | 3218 void HTMLMediaElement::requestReload(const WebURL& newUrl) { |
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3852 } | 3853 } |
3853 | 3854 |
3854 DEFINE_TRACE_WRAPPERS(HTMLMediaElement) { | 3855 DEFINE_TRACE_WRAPPERS(HTMLMediaElement) { |
3855 visitor->traceWrappers(m_videoTracks); | 3856 visitor->traceWrappers(m_videoTracks); |
3856 visitor->traceWrappers(m_audioTracks); | 3857 visitor->traceWrappers(m_audioTracks); |
3857 visitor->traceWrappers(m_textTracks); | 3858 visitor->traceWrappers(m_textTracks); |
3858 HTMLElement::traceWrappers(visitor); | 3859 HTMLElement::traceWrappers(visitor); |
3859 } | 3860 } |
3860 | 3861 |
3861 void HTMLMediaElement::createPlaceholderTracksIfNecessary() { | 3862 void HTMLMediaElement::createPlaceholderTracksIfNecessary() { |
3862 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) | 3863 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled() && |
| 3864 !RuntimeEnabledFeatures::backgroundVideoTrackOptimizationEnabled()) { |
3863 return; | 3865 return; |
| 3866 } |
3864 | 3867 |
3865 // Create a placeholder audio track if the player says it has audio but it | 3868 // Create a placeholder audio track if the player says it has audio but it |
3866 // didn't explicitly announce the tracks. | 3869 // didn't explicitly announce the tracks. |
3867 if (hasAudio() && !audioTracks().length()) | 3870 if (hasAudio() && !audioTracks().length()) |
3868 addAudioTrack("audio", WebMediaPlayerClient::AudioTrackKindMain, | 3871 addAudioTrack("audio", WebMediaPlayerClient::AudioTrackKindMain, |
3869 "Audio Track", "", true); | 3872 "Audio Track", "", true); |
3870 | 3873 |
3871 // Create a placeholder video track if the player says it has video but it | 3874 // Create a placeholder video track if the player says it has video but it |
3872 // didn't explicitly announce the tracks. | 3875 // didn't explicitly announce the tracks. |
3873 if (hasVideo() && !videoTracks().length()) | 3876 if (hasVideo() && !videoTracks().length()) |
3874 addVideoTrack("video", WebMediaPlayerClient::VideoTrackKindMain, | 3877 addVideoTrack("video", WebMediaPlayerClient::VideoTrackKindMain, |
3875 "Video Track", "", true); | 3878 "Video Track", "", true); |
3876 } | 3879 } |
3877 | 3880 |
3878 void HTMLMediaElement::selectInitialTracksIfNecessary() { | 3881 void HTMLMediaElement::selectInitialTracksIfNecessary() { |
3879 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) | 3882 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled() && |
| 3883 !RuntimeEnabledFeatures::backgroundVideoTrackOptimizationEnabled()) { |
3880 return; | 3884 return; |
| 3885 } |
3881 | 3886 |
3882 // Enable the first audio track if an audio track hasn't been enabled yet. | 3887 // Enable the first audio track if an audio track hasn't been enabled yet. |
3883 if (audioTracks().length() > 0 && !audioTracks().hasEnabledTrack()) | 3888 if (audioTracks().length() > 0 && !audioTracks().hasEnabledTrack()) |
3884 audioTracks().anonymousIndexedGetter(0)->setEnabled(true); | 3889 audioTracks().anonymousIndexedGetter(0)->setEnabled(true); |
3885 | 3890 |
3886 // Select the first video track if a video track hasn't been selected yet. | 3891 // Select the first video track if a video track hasn't been selected yet. |
3887 if (videoTracks().length() > 0 && videoTracks().selectedIndex() == -1) | 3892 if (videoTracks().length() > 0 && videoTracks().selectedIndex() == -1) |
3888 videoTracks().anonymousIndexedGetter(0)->setSelected(true); | 3893 videoTracks().anonymousIndexedGetter(0)->setSelected(true); |
3889 } | 3894 } |
3890 | 3895 |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4197 | 4202 |
4198 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() | 4203 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() |
4199 const { | 4204 const { |
4200 IntRect result; | 4205 IntRect result; |
4201 if (LayoutObject* object = m_element->layoutObject()) | 4206 if (LayoutObject* object = m_element->layoutObject()) |
4202 result = object->absoluteBoundingBoxRect(); | 4207 result = object->absoluteBoundingBoxRect(); |
4203 return result; | 4208 return result; |
4204 } | 4209 } |
4205 | 4210 |
4206 } // namespace blink | 4211 } // namespace blink |
OLD | NEW |