Chromium Code Reviews| 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 2535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2546 } | 2546 } |
| 2547 | 2547 |
| 2548 void HTMLMediaElement::togglePlayState() { | 2548 void HTMLMediaElement::togglePlayState() { |
| 2549 if (paused()) | 2549 if (paused()) |
| 2550 play(); | 2550 play(); |
| 2551 else | 2551 else |
| 2552 pause(); | 2552 pause(); |
| 2553 } | 2553 } |
| 2554 | 2554 |
| 2555 AudioTrackList& HTMLMediaElement::audioTracks() { | 2555 AudioTrackList& HTMLMediaElement::audioTracks() { |
| 2556 DCHECK(RuntimeEnabledFeatures::audioVideoTracksEnabled()); | |
|
mlamouri (slow - plz ping)
2016/11/12 23:35:48
Here and below, did you have to remove the checks?
whywhat
2016/11/14 21:50:12
When the Media Tracks API is enabled, HTMLMediaEle
| |
| 2557 return *m_audioTracks; | 2556 return *m_audioTracks; |
| 2558 } | 2557 } |
| 2559 | 2558 |
| 2560 void HTMLMediaElement::audioTrackChanged(AudioTrack* track) { | 2559 void HTMLMediaElement::audioTrackChanged(AudioTrack* track) { |
| 2561 BLINK_MEDIA_LOG << "audioTrackChanged(" << (void*)this | 2560 BLINK_MEDIA_LOG << "audioTrackChanged(" << (void*)this |
| 2562 << ") trackId= " << String(track->id()) | 2561 << ") trackId= " << String(track->id()) |
| 2563 << " enabled=" << boolString(track->enabled()); | 2562 << " enabled=" << boolString(track->enabled()); |
| 2564 DCHECK(RuntimeEnabledFeatures::audioVideoTracksEnabled()); | 2563 DCHECK(RuntimeEnabledFeatures::audioVideoTracksEnabled()); |
| 2565 | 2564 |
| 2566 audioTracks().scheduleChangeEvent(); | 2565 audioTracks().scheduleChangeEvent(); |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 2588 WebMediaPlayerClient::AudioTrackKind kind, | 2587 WebMediaPlayerClient::AudioTrackKind kind, |
| 2589 const WebString& label, | 2588 const WebString& label, |
| 2590 const WebString& language, | 2589 const WebString& language, |
| 2591 bool enabled) { | 2590 bool enabled) { |
| 2592 AtomicString kindString = AudioKindToString(kind); | 2591 AtomicString kindString = AudioKindToString(kind); |
| 2593 BLINK_MEDIA_LOG << "addAudioTrack(" << (void*)this << ", '" << (String)id | 2592 BLINK_MEDIA_LOG << "addAudioTrack(" << (void*)this << ", '" << (String)id |
| 2594 << "', ' " << (AtomicString)kindString << "', '" | 2593 << "', ' " << (AtomicString)kindString << "', '" |
| 2595 << (String)label << "', '" << (String)language << "', " | 2594 << (String)label << "', '" << (String)language << "', " |
| 2596 << boolString(enabled) << ")"; | 2595 << boolString(enabled) << ")"; |
| 2597 | 2596 |
| 2598 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) | |
| 2599 return blink::WebMediaPlayer::TrackId(); | |
| 2600 | |
| 2601 AudioTrack* audioTrack = | 2597 AudioTrack* audioTrack = |
| 2602 AudioTrack::create(id, kindString, label, language, enabled); | 2598 AudioTrack::create(id, kindString, label, language, enabled); |
| 2603 audioTracks().add(audioTrack); | 2599 audioTracks().add(audioTrack); |
| 2604 | 2600 |
| 2605 return audioTrack->id(); | 2601 return audioTrack->id(); |
| 2606 } | 2602 } |
| 2607 | 2603 |
| 2608 void HTMLMediaElement::removeAudioTrack(WebMediaPlayer::TrackId trackId) { | 2604 void HTMLMediaElement::removeAudioTrack(WebMediaPlayer::TrackId trackId) { |
| 2609 BLINK_MEDIA_LOG << "removeAudioTrack(" << (void*)this << ")"; | 2605 BLINK_MEDIA_LOG << "removeAudioTrack(" << (void*)this << ")"; |
| 2610 | 2606 |
| 2611 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) | |
| 2612 return; | |
| 2613 | |
| 2614 audioTracks().remove(trackId); | 2607 audioTracks().remove(trackId); |
| 2615 } | 2608 } |
| 2616 | 2609 |
| 2617 VideoTrackList& HTMLMediaElement::videoTracks() { | 2610 VideoTrackList& HTMLMediaElement::videoTracks() { |
| 2618 DCHECK(RuntimeEnabledFeatures::audioVideoTracksEnabled()); | |
| 2619 return *m_videoTracks; | 2611 return *m_videoTracks; |
| 2620 } | 2612 } |
| 2621 | 2613 |
| 2622 void HTMLMediaElement::selectedVideoTrackChanged(VideoTrack* track) { | 2614 void HTMLMediaElement::selectedVideoTrackChanged(VideoTrack* track) { |
| 2623 BLINK_MEDIA_LOG << "selectedVideoTrackChanged(" << (void*)this | 2615 BLINK_MEDIA_LOG << "selectedVideoTrackChanged(" << (void*)this |
| 2624 << ") selectedTrackId=" | 2616 << ") selectedTrackId=" |
| 2625 << (track->selected() ? String(track->id()) : "none"); | 2617 << (track->selected() ? String(track->id()) : "none"); |
| 2626 DCHECK(RuntimeEnabledFeatures::audioVideoTracksEnabled()); | 2618 DCHECK(RuntimeEnabledFeatures::audioVideoTracksEnabled()); |
| 2627 | 2619 |
| 2628 if (track->selected()) | 2620 if (track->selected()) |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 2643 WebMediaPlayerClient::VideoTrackKind kind, | 2635 WebMediaPlayerClient::VideoTrackKind kind, |
| 2644 const WebString& label, | 2636 const WebString& label, |
| 2645 const WebString& language, | 2637 const WebString& language, |
| 2646 bool selected) { | 2638 bool selected) { |
| 2647 AtomicString kindString = VideoKindToString(kind); | 2639 AtomicString kindString = VideoKindToString(kind); |
| 2648 BLINK_MEDIA_LOG << "addVideoTrack(" << (void*)this << ", '" << (String)id | 2640 BLINK_MEDIA_LOG << "addVideoTrack(" << (void*)this << ", '" << (String)id |
| 2649 << "', '" << (AtomicString)kindString << "', '" | 2641 << "', '" << (AtomicString)kindString << "', '" |
| 2650 << (String)label << "', '" << (String)language << "', " | 2642 << (String)label << "', '" << (String)language << "', " |
| 2651 << boolString(selected) << ")"; | 2643 << boolString(selected) << ")"; |
| 2652 | 2644 |
| 2653 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) | |
| 2654 return blink::WebMediaPlayer::TrackId(); | |
| 2655 | |
| 2656 // If another track was selected (potentially by the user), leave it selected. | 2645 // If another track was selected (potentially by the user), leave it selected. |
| 2657 if (selected && videoTracks().selectedIndex() != -1) | 2646 if (selected && videoTracks().selectedIndex() != -1) |
| 2658 selected = false; | 2647 selected = false; |
| 2659 | 2648 |
| 2660 VideoTrack* videoTrack = | 2649 VideoTrack* videoTrack = |
| 2661 VideoTrack::create(id, kindString, label, language, selected); | 2650 VideoTrack::create(id, kindString, label, language, selected); |
| 2662 videoTracks().add(videoTrack); | 2651 videoTracks().add(videoTrack); |
| 2663 | 2652 |
| 2664 return videoTrack->id(); | 2653 return videoTrack->id(); |
| 2665 } | 2654 } |
| 2666 | 2655 |
| 2667 void HTMLMediaElement::removeVideoTrack(WebMediaPlayer::TrackId trackId) { | 2656 void HTMLMediaElement::removeVideoTrack(WebMediaPlayer::TrackId trackId) { |
| 2668 BLINK_MEDIA_LOG << "removeVideoTrack(" << (void*)this << ")"; | 2657 BLINK_MEDIA_LOG << "removeVideoTrack(" << (void*)this << ")"; |
| 2669 | 2658 |
| 2670 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) | |
| 2671 return; | |
| 2672 | |
| 2673 videoTracks().remove(trackId); | 2659 videoTracks().remove(trackId); |
| 2674 } | 2660 } |
| 2675 | 2661 |
| 2676 void HTMLMediaElement::addTextTrack(WebInbandTextTrack* webTrack) { | 2662 void HTMLMediaElement::addTextTrack(WebInbandTextTrack* webTrack) { |
| 2677 // 4.8.10.12.2 Sourcing in-band text tracks | 2663 // 4.8.10.12.2 Sourcing in-band text tracks |
| 2678 // 1. Associate the relevant data with a new text track and its corresponding | 2664 // 1. Associate the relevant data with a new text track and its corresponding |
| 2679 // new TextTrack object. | 2665 // new TextTrack object. |
| 2680 InbandTextTrack* textTrack = InbandTextTrack::create(webTrack); | 2666 InbandTextTrack* textTrack = InbandTextTrack::create(webTrack); |
| 2681 | 2667 |
| 2682 // 2. Set the new text track's kind, label, and language based on the | 2668 // 2. Set the new text track's kind, label, and language based on the |
| (...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3188 void HTMLMediaElement::cancelledRemotePlaybackRequest() { | 3174 void HTMLMediaElement::cancelledRemotePlaybackRequest() { |
| 3189 if (remotePlaybackClient()) | 3175 if (remotePlaybackClient()) |
| 3190 remotePlaybackClient()->promptCancelled(); | 3176 remotePlaybackClient()->promptCancelled(); |
| 3191 } | 3177 } |
| 3192 | 3178 |
| 3193 void HTMLMediaElement::remotePlaybackStarted() { | 3179 void HTMLMediaElement::remotePlaybackStarted() { |
| 3194 if (remotePlaybackClient()) | 3180 if (remotePlaybackClient()) |
| 3195 remotePlaybackClient()->stateChanged(WebRemotePlaybackState::Connected); | 3181 remotePlaybackClient()->stateChanged(WebRemotePlaybackState::Connected); |
| 3196 } | 3182 } |
| 3197 | 3183 |
| 3184 void HTMLMediaElement::hidden() { | |
| 3185 if (!RuntimeEnabledFeatures::backgroundVideoTrackOptimizationEnabled()) | |
| 3186 return; | |
| 3187 | |
| 3188 webMediaPlayer()->selectedVideoTrackChanged(nullptr); | |
|
mlamouri (slow - plz ping)
2016/11/12 23:35:48
Here and below, you go from WMPI to HTMLMediaEleme
whywhat
2016/11/14 21:50:13
1. I can restore the previously selected video tra
sandersd (OOO until July 31)
2016/11/15 00:09:11
This also looks strange from the WMPI side (which
whywhat
2016/11/15 03:08:56
More thoughts:
- WMPA doesn't implement selectedV
| |
| 3189 } | |
| 3190 | |
| 3191 void HTMLMediaElement::shown() { | |
| 3192 if (!RuntimeEnabledFeatures::backgroundVideoTrackOptimizationEnabled()) | |
| 3193 return; | |
| 3194 | |
| 3195 int selectedTrackIndex = m_videoTracks->selectedIndex(); | |
| 3196 if (selectedTrackIndex == -1) | |
| 3197 return; | |
| 3198 | |
| 3199 VideoTrack* track = m_videoTracks->anonymousIndexedGetter(selectedTrackIndex); | |
| 3200 WebMediaPlayer::TrackId id = track->id(); | |
| 3201 webMediaPlayer()->selectedVideoTrackChanged(&id); | |
| 3202 } | |
| 3203 | |
| 3198 bool HTMLMediaElement::isAutoplayingMuted() { | 3204 bool HTMLMediaElement::isAutoplayingMuted() { |
| 3199 if (!isHTMLVideoElement() || | 3205 if (!isHTMLVideoElement() || |
| 3200 !RuntimeEnabledFeatures::autoplayMutedVideosEnabled()) { | 3206 !RuntimeEnabledFeatures::autoplayMutedVideosEnabled()) { |
| 3201 return false; | 3207 return false; |
| 3202 } | 3208 } |
| 3203 | 3209 |
| 3204 return !paused() && muted() && isLockedPendingUserGesture(); | 3210 return !paused() && muted() && isLockedPendingUserGesture(); |
| 3205 } | 3211 } |
| 3206 | 3212 |
| 3207 void HTMLMediaElement::requestReload(const WebURL& newUrl) { | 3213 void HTMLMediaElement::requestReload(const WebURL& newUrl) { |
| (...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3845 } | 3851 } |
| 3846 | 3852 |
| 3847 DEFINE_TRACE_WRAPPERS(HTMLMediaElement) { | 3853 DEFINE_TRACE_WRAPPERS(HTMLMediaElement) { |
| 3848 visitor->traceWrappers(m_videoTracks); | 3854 visitor->traceWrappers(m_videoTracks); |
| 3849 visitor->traceWrappers(m_audioTracks); | 3855 visitor->traceWrappers(m_audioTracks); |
| 3850 visitor->traceWrappers(m_textTracks); | 3856 visitor->traceWrappers(m_textTracks); |
| 3851 HTMLElement::traceWrappers(visitor); | 3857 HTMLElement::traceWrappers(visitor); |
| 3852 } | 3858 } |
| 3853 | 3859 |
| 3854 void HTMLMediaElement::createPlaceholderTracksIfNecessary() { | 3860 void HTMLMediaElement::createPlaceholderTracksIfNecessary() { |
| 3855 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) | 3861 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled() && |
| 3862 !RuntimeEnabledFeatures::backgroundVideoTrackOptimizationEnabled()) { | |
| 3856 return; | 3863 return; |
| 3864 } | |
| 3857 | 3865 |
| 3858 // Create a placeholder audio track if the player says it has audio but it | 3866 // Create a placeholder audio track if the player says it has audio but it |
| 3859 // didn't explicitly announce the tracks. | 3867 // didn't explicitly announce the tracks. |
| 3860 if (hasAudio() && !audioTracks().length()) | 3868 if (hasAudio() && !audioTracks().length()) |
| 3861 addAudioTrack("audio", WebMediaPlayerClient::AudioTrackKindMain, | 3869 addAudioTrack("audio", WebMediaPlayerClient::AudioTrackKindMain, |
| 3862 "Audio Track", "", true); | 3870 "Audio Track", "", true); |
| 3863 | 3871 |
| 3864 // Create a placeholder video track if the player says it has video but it | 3872 // Create a placeholder video track if the player says it has video but it |
| 3865 // didn't explicitly announce the tracks. | 3873 // didn't explicitly announce the tracks. |
| 3866 if (hasVideo() && !videoTracks().length()) | 3874 if (hasVideo() && !videoTracks().length()) |
| 3867 addVideoTrack("video", WebMediaPlayerClient::VideoTrackKindMain, | 3875 addVideoTrack("video", WebMediaPlayerClient::VideoTrackKindMain, |
| 3868 "Video Track", "", true); | 3876 "Video Track", "", true); |
| 3869 } | 3877 } |
| 3870 | 3878 |
| 3871 void HTMLMediaElement::selectInitialTracksIfNecessary() { | 3879 void HTMLMediaElement::selectInitialTracksIfNecessary() { |
| 3872 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) | 3880 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled() && |
| 3881 !RuntimeEnabledFeatures::backgroundVideoTrackOptimizationEnabled()) { | |
| 3873 return; | 3882 return; |
| 3883 } | |
| 3874 | 3884 |
| 3875 // Enable the first audio track if an audio track hasn't been enabled yet. | 3885 // Enable the first audio track if an audio track hasn't been enabled yet. |
| 3876 if (audioTracks().length() > 0 && !audioTracks().hasEnabledTrack()) | 3886 if (audioTracks().length() > 0 && !audioTracks().hasEnabledTrack()) |
| 3877 audioTracks().anonymousIndexedGetter(0)->setEnabled(true); | 3887 audioTracks().anonymousIndexedGetter(0)->setEnabled(true); |
| 3878 | 3888 |
| 3879 // Select the first video track if a video track hasn't been selected yet. | 3889 // Select the first video track if a video track hasn't been selected yet. |
| 3880 if (videoTracks().length() > 0 && videoTracks().selectedIndex() == -1) | 3890 if (videoTracks().length() > 0 && videoTracks().selectedIndex() == -1) |
| 3881 videoTracks().anonymousIndexedGetter(0)->setSelected(true); | 3891 videoTracks().anonymousIndexedGetter(0)->setSelected(true); |
| 3882 } | 3892 } |
| 3883 | 3893 |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4179 | 4189 |
| 4180 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() | 4190 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() |
| 4181 const { | 4191 const { |
| 4182 IntRect result; | 4192 IntRect result; |
| 4183 if (LayoutObject* object = m_element->layoutObject()) | 4193 if (LayoutObject* object = m_element->layoutObject()) |
| 4184 result = object->absoluteBoundingBoxRect(); | 4194 result = object->absoluteBoundingBoxRect(); |
| 4185 return result; | 4195 return result; |
| 4186 } | 4196 } |
| 4187 | 4197 |
| 4188 } // namespace blink | 4198 } // namespace blink |
| OLD | NEW |