Changeset 162360 in webkit


Ignore:
Timestamp:
Jan 20, 2014 11:23:40 AM (10 years ago)
Author:
eric.carlson@apple.com
Message:

Allow MediaSessionManager to restrict 'preload' behavior
https://bugs.webkit.org/show_bug.cgi?id=127297

Reviewed by Jer Noble.

Source/WebCore:

Tests: media/video-restricted-no-preload-auto.html

media/video-restricted-no-preload-metadata.html

  • html/HTMLMediaElement.cpp:

(WebCore::HTMLMediaElement::parseAttribute): Apply restrictions to preload attribute before

passing to media engine.

(WebCore::HTMLMediaElement::loadResource): Ditto.

  • html/HTMLMediaSession.cpp:

(WebCore::HTMLMediaSession::effectivePreloadForElement): New, limit preload according to restrictions.

  • html/HTMLMediaSession.h:
  • platform/audio/MediaSessionManager.h:
  • platform/audio/ios/MediaSessionManagerIOS.mm:

(WebCore::MediaSessionManageriOS::resetRestrictions): Limit preload to metadata only. Drive-by

static deviceClass initialization cleanup.

  • testing/Internals.cpp:

(WebCore::Internals::setMediaSessionRestrictions): Support MetadataPreloadingNotPermitted and

AutoPreloadingNotPermitted.

LayoutTests:

  • media/video-restricted-no-preload-auto-expected.txt: Added.
  • media/video-restricted-no-preload-auto.html: Added.
  • media/video-restricted-no-preload-metadata-expected.txt: Added.
  • media/video-restricted-no-preload-metadata.html: Added.
Location:
trunk
Files:
4 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r162359 r162360  
     12014-01-20  Eric Carlson  <eric.carlson@apple.com>
     2
     3        Allow MediaSessionManager to restrict 'preload' behavior
     4        https://bugs.webkit.org/show_bug.cgi?id=127297
     5
     6        Reviewed by Jer Noble.
     7
     8        * media/video-restricted-no-preload-auto-expected.txt: Added.
     9        * media/video-restricted-no-preload-auto.html: Added.
     10        * media/video-restricted-no-preload-metadata-expected.txt: Added.
     11        * media/video-restricted-no-preload-metadata.html: Added.
     12
    1132014-01-20  Mihai Tica  <mitica@adobe.com>
    214
  • trunk/Source/WebCore/ChangeLog

    r162356 r162360  
     12014-01-20  Eric Carlson  <eric.carlson@apple.com>
     2
     3        Allow MediaSessionManager to restrict 'preload' behavior
     4        https://bugs.webkit.org/show_bug.cgi?id=127297
     5
     6        Reviewed by Jer Noble.
     7
     8        Tests: media/video-restricted-no-preload-auto.html
     9               media/video-restricted-no-preload-metadata.html
     10
     11        * html/HTMLMediaElement.cpp:
     12        (WebCore::HTMLMediaElement::parseAttribute): Apply restrictions to preload attribute before
     13            passing to media engine.
     14        (WebCore::HTMLMediaElement::loadResource): Ditto.
     15
     16        * html/HTMLMediaSession.cpp:
     17        (WebCore::HTMLMediaSession::effectivePreloadForElement): New, limit preload according to restrictions.
     18        * html/HTMLMediaSession.h:
     19
     20        * platform/audio/MediaSessionManager.h:
     21        * platform/audio/ios/MediaSessionManagerIOS.mm:
     22        (WebCore::MediaSessionManageriOS::resetRestrictions): Limit preload to metadata only. Drive-by
     23            static deviceClass initialization cleanup.
     24
     25        * testing/Internals.cpp:
     26        (WebCore::Internals::setMediaSessionRestrictions): Support MetadataPreloadingNotPermitted and
     27            AutoPreloadingNotPermitted.
     28
    1292014-01-20  Andreas Kling  <akling@apple.com>
    230
  • trunk/Source/WebCore/html/HTMLMediaElement.cpp

    r162145 r162360  
    547547        // The attribute must be ignored if the autoplay attribute is present
    548548        if (!autoplay() && m_player)
    549             m_player->setPreload(m_preload);
     549            m_player->setPreload(m_mediaSession->effectivePreloadForElement(*this));
    550550
    551551    } else if (name == mediagroupAttr)
     
    988988    // algorithm, but do it now because we won't start that until after the timer fires and the
    989989    // event may have already fired by then.
    990     if (m_preload != MediaPlayer::None)
     990    MediaPlayer::Preload effectivePreload = m_mediaSession->effectivePreloadForElement(*this);
     991    if (effectivePreload != MediaPlayer::None)
    991992        setShouldDelayLoadEvent(true);
    992993
    993994#if PLATFORM(IOS)
    994995    Settings* settings = document().settings();
    995     if (m_preload != MediaPlayer::None && settings && settings->mediaDataLoadsAutomatically())
     996    if (effectivePreload != MediaPlayer::None && settings && settings->mediaDataLoadsAutomatically())
    996997        prepareToPlay();
    997998#endif
     
    12121213
    12131214    if (!autoplay())
    1214         m_player->setPreload(m_preload);
     1215        m_player->setPreload(m_mediaSession->effectivePreloadForElement(*this));
    12151216    m_player->setPreservesPitch(m_webkitPreservesPitch);
    12161217
  • trunk/Source/WebCore/html/HTMLMediaElement.h

    r162139 r162360  
    425425#endif
    426426
     427    MediaPlayer::Preload preloadValue() const { return m_preload; }
     428
    427429protected:
    428430    HTMLMediaElement(const QualifiedName&, Document&, bool);
  • trunk/Source/WebCore/html/HTMLMediaSession.cpp

    r162221 r162360  
    144144#endif
    145145
     146MediaPlayer::Preload HTMLMediaSession::effectivePreloadForElement(const HTMLMediaElement& element) const
     147{
     148    MediaSessionManager::SessionRestrictions restrictions = MediaSessionManager::sharedManager().restrictions(mediaType());
     149    MediaPlayer::Preload preload = element.preloadValue();
     150
     151    if ((restrictions & MediaSessionManager::MetadataPreloadingNotPermitted) == MediaSessionManager::MetadataPreloadingNotPermitted)
     152        return MediaPlayer::None;
     153
     154    if ((restrictions & MediaSessionManager::AutoPreloadingNotPermitted) == MediaSessionManager::AutoPreloadingNotPermitted) {
     155        if (preload > MediaPlayer::MetaData)
     156            return MediaPlayer::MetaData;
     157    }
     158
     159    return preload;
     160}
     161
    146162void HTMLMediaSession::clientWillBeginPlayback() const
    147163{
  • trunk/Source/WebCore/html/HTMLMediaSession.h

    r162145 r162360  
    2929#if ENABLE(VIDEO)
    3030
     31#include "MediaPlayer.h"
    3132#include "MediaSession.h"
    3233
     
    5354#endif
    5455    bool requiresFullscreenForVideoPlayback(const HTMLMediaElement&) const;
     56    MediaPlayer::Preload effectivePreloadForElement(const HTMLMediaElement&) const;
    5557
    5658    // Restrictions to modify default behaviors.
  • trunk/Source/WebCore/platform/audio/MediaSessionManager.h

    r162178 r162360  
    5151        NoRestrictions = 0,
    5252        ConcurrentPlaybackNotPermitted = 1 << 0,
    53         InlineVideoPlaybackRestricted = 1 << 0,
     53        InlineVideoPlaybackRestricted = 1 << 1,
     54        MetadataPreloadingNotPermitted = 1 << 2,
     55        AutoPreloadingNotPermitted = 1 << 3,
    5456    };
    5557    typedef unsigned SessionRestrictions;
  • trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm

    r162218 r162360  
    8080    MediaSessionManager::resetRestrictions();
    8181
    82     DEFINE_STATIC_LOCAL(wkDeviceClass, deviceClass, (iosDeviceClass()));
    83 
     82    static wkDeviceClass deviceClass = iosDeviceClass();
    8483    if (deviceClass == wkDeviceClassiPhone || deviceClass == wkDeviceClassiPod)
    8584        addRestriction(MediaSession::Video, InlineVideoPlaybackRestricted);
    8685
    8786    addRestriction(MediaSession::Video, ConcurrentPlaybackNotPermitted);
     87    removeRestriction(MediaSession::Audio, MetadataPreloadingNotPermitted);
     88    removeRestriction(MediaSession::Video, MetadataPreloadingNotPermitted);
     89    addRestriction(MediaSession::Audio, AutoPreloadingNotPermitted);
     90    addRestriction(MediaSession::Video, AutoPreloadingNotPermitted);
    8891}
    8992
  • trunk/Source/WebCore/testing/Internals.cpp

    r162264 r162360  
    22122212    if (equalIgnoringCase(restrictionsString, "InlineVideoPlaybackRestricted"))
    22132213        restrictions += MediaSessionManager::InlineVideoPlaybackRestricted;
    2214    
     2214    if (equalIgnoringCase(restrictionsString, "MetadataPreloadingNotPermitted"))
     2215        restrictions += MediaSessionManager::MetadataPreloadingNotPermitted;
     2216    if (equalIgnoringCase(restrictionsString, "AutoPreloadingNotPermitted"))
     2217        restrictions += MediaSessionManager::AutoPreloadingNotPermitted;
     2218
    22152219    MediaSessionManager::sharedManager().addRestriction(mediaType, restrictions);
    22162220}
Note: See TracChangeset for help on using the changeset viewer.