Changeset 126008 in webkit


Ignore:
Timestamp:
Aug 20, 2012 1:47:04 AM (12 years ago)
Author:
commit-queue@webkit.org
Message:

[BlackBerry] Adapt to changes in the platform media player API
https://bugs.webkit.org/show_bug.cgi?id=94329
PR #194237

Patch by Robin Cao <robin.cao@torchmobile.com.cn> on 2012-08-20
Reviewed by Antonio Gomes.

The interface to platform's media player has changed from MMRPlayer
to PlatformPlayer. This patch adapts to this change.

And we also decided to postpone the creation of PlatformPlayer until
the loading started. This is needed because we may create different
types of player for different media sources.

This is a refactor, no new tests.

  • platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.cpp:

(WebCore::MediaPlayerPrivate::getSupportedTypes):
(WebCore::MediaPlayerPrivate::supportsType):
(WebCore::MediaPlayerPrivate::notifyAppActivatedEvent):
(WebCore::MediaPlayerPrivate::setCertificatePath):
(WebCore::MediaPlayerPrivate::MediaPlayerPrivate):
(WebCore::MediaPlayerPrivate::load):
(WebCore::MediaPlayerPrivate::cancelLoad):
(WebCore::MediaPlayerPrivate::prepareToPlay):
(WebCore::MediaPlayerPrivate::play):
(WebCore::MediaPlayerPrivate::pause):
(WebCore::MediaPlayerPrivate::naturalSize):
(WebCore::MediaPlayerPrivate::hasVideo):
(WebCore::MediaPlayerPrivate::hasAudio):
(WebCore::MediaPlayerPrivate::duration):
(WebCore::MediaPlayerPrivate::currentTime):
(WebCore::MediaPlayerPrivate::seek):
(WebCore::MediaPlayerPrivate::setRate):
(WebCore::MediaPlayerPrivate::paused):
(WebCore::MediaPlayerPrivate::setVolume):
(WebCore::MediaPlayerPrivate::maxTimeSeekable):
(WebCore::MediaPlayerPrivate::buffered):
(WebCore::MediaPlayerPrivate::paint):
(WebCore::MediaPlayerPrivate::hasAvailableVideoFrame):
(WebCore::MediaPlayerPrivate::movieLoadType):
(WebCore::MediaPlayerPrivate::setAllowPPSVolumeUpdates):
(WebCore::MediaPlayerPrivate::updateStates):
(WebCore):
(WebCore::MediaPlayerPrivate::onStateChanged):
(WebCore::MediaPlayerPrivate::onMediaStatusChanged):
(WebCore::MediaPlayerPrivate::onError):
(WebCore::MediaPlayerPrivate::waitMetadataTimerFired):
(WebCore::MediaPlayerPrivate::showErrorDialog):

  • platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.h:

(MediaPlayerPrivate):

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r126005 r126008  
     12012-08-20  Robin Cao  <robin.cao@torchmobile.com.cn>
     2
     3        [BlackBerry] Adapt to changes in the platform media player API
     4        https://bugs.webkit.org/show_bug.cgi?id=94329
     5        PR #194237
     6
     7        Reviewed by Antonio Gomes.
     8
     9        The interface to platform's media player has changed from MMRPlayer
     10        to PlatformPlayer. This patch adapts to this change.
     11
     12        And we also decided to postpone the creation of PlatformPlayer until
     13        the loading started. This is needed because we may create different
     14        types of player for different media sources.
     15
     16        This is a refactor, no new tests.
     17
     18        * platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.cpp:
     19        (WebCore::MediaPlayerPrivate::getSupportedTypes):
     20        (WebCore::MediaPlayerPrivate::supportsType):
     21        (WebCore::MediaPlayerPrivate::notifyAppActivatedEvent):
     22        (WebCore::MediaPlayerPrivate::setCertificatePath):
     23        (WebCore::MediaPlayerPrivate::MediaPlayerPrivate):
     24        (WebCore::MediaPlayerPrivate::load):
     25        (WebCore::MediaPlayerPrivate::cancelLoad):
     26        (WebCore::MediaPlayerPrivate::prepareToPlay):
     27        (WebCore::MediaPlayerPrivate::play):
     28        (WebCore::MediaPlayerPrivate::pause):
     29        (WebCore::MediaPlayerPrivate::naturalSize):
     30        (WebCore::MediaPlayerPrivate::hasVideo):
     31        (WebCore::MediaPlayerPrivate::hasAudio):
     32        (WebCore::MediaPlayerPrivate::duration):
     33        (WebCore::MediaPlayerPrivate::currentTime):
     34        (WebCore::MediaPlayerPrivate::seek):
     35        (WebCore::MediaPlayerPrivate::setRate):
     36        (WebCore::MediaPlayerPrivate::paused):
     37        (WebCore::MediaPlayerPrivate::setVolume):
     38        (WebCore::MediaPlayerPrivate::maxTimeSeekable):
     39        (WebCore::MediaPlayerPrivate::buffered):
     40        (WebCore::MediaPlayerPrivate::paint):
     41        (WebCore::MediaPlayerPrivate::hasAvailableVideoFrame):
     42        (WebCore::MediaPlayerPrivate::movieLoadType):
     43        (WebCore::MediaPlayerPrivate::setAllowPPSVolumeUpdates):
     44        (WebCore::MediaPlayerPrivate::updateStates):
     45        (WebCore):
     46        (WebCore::MediaPlayerPrivate::onStateChanged):
     47        (WebCore::MediaPlayerPrivate::onMediaStatusChanged):
     48        (WebCore::MediaPlayerPrivate::onError):
     49        (WebCore::MediaPlayerPrivate::waitMetadataTimerFired):
     50        (WebCore::MediaPlayerPrivate::showErrorDialog):
     51        * platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.h:
     52        (MediaPlayerPrivate):
     53
    1542012-08-19  Kentaro Hara  <haraken@chromium.org>
    255
  • trunk/Source/WebCore/platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.cpp

    r125388 r126008  
    6767void MediaPlayerPrivate::getSupportedTypes(HashSet<String>& types)
    6868{
    69     set<string> supported = MMRPlayer::allSupportedMimeTypes();
     69    set<string> supported = PlatformPlayer::allSupportedMimeTypes();
    7070    set<string>::iterator i = supported.begin();
    7171    for (; i != supported.end(); i++)
     
    8181
    8282    // spec says we should not return "probably" if the codecs string is empty
    83     if (MMRPlayer::mimeTypeSupported(type.ascii().data())) {
     83    if (PlatformPlayer::mimeTypeSupported(type.ascii().data())) {
    8484        LOG(Media, "MediaPlayer supports type; cache contains type '%s'.", type.ascii().data());
    8585        return codecs.isEmpty() ? MediaPlayer::MayBeSupported : MediaPlayer::IsSupported;
     
    9191void MediaPlayerPrivate::notifyAppActivatedEvent(bool activated)
    9292{
    93     MMRPlayer::notifyAppActivatedEvent(activated);
     93    PlatformPlayer::notifyAppActivatedEvent(activated);
    9494}
    9595
    9696void MediaPlayerPrivate::setCertificatePath(const String& caPath)
    9797{
    98     MMRPlayer::setCertificatePath(string(caPath.utf8().data()));
     98    PlatformPlayer::setCertificatePath(string(caPath.utf8().data()));
    9999}
    100100
    101101MediaPlayerPrivate::MediaPlayerPrivate(MediaPlayer* player)
    102102    : m_webCorePlayer(player)
     103    , m_platformPlayer(0)
    103104    , m_networkState(MediaPlayer::Empty)
    104105    , m_readyState(MediaPlayer::HaveNothing)
     
    115116    , m_waitMetadataPopDialogCounter(0)
    116117{
    117     void* tabId = 0;
    118     if (frameView() && frameView()->hostWindow())
    119         tabId = frameView()->hostWindow()->platformPageClient();
    120 #if USE(ACCELERATED_COMPOSITING)
    121     m_platformPlayer = new MMRPlayer(this, tabId, true);
    122 #else
    123     m_platformPlayer = new MMRPlayer(this, tabId, false);
    124 #endif
    125118}
    126119
     
    157150    }
    158151
     152    void* tabId = 0;
     153    if (frameView() && frameView()->hostWindow())
     154        tabId = frameView()->hostWindow()->platformPageClient();
     155
     156    deleteGuardedObject(m_platformPlayer);
     157#if USE(ACCELERATED_COMPOSITING)
     158    m_platformPlayer = PlatformPlayer::create(this, tabId, true, modifiedUrl.utf8().data());
     159#else
     160    m_platformPlayer = PlatformPlayer::create(this, tabId, false, modifiedUrl.utf8().data());
     161#endif
     162
    159163    String cookiePairs;
    160164    if (!url.isEmpty())
     
    168172void MediaPlayerPrivate::cancelLoad()
    169173{
    170     m_platformPlayer->cancelLoad();
     174    if (m_platformPlayer)
     175        m_platformPlayer->cancelLoad();
    171176}
    172177
    173178void MediaPlayerPrivate::prepareToPlay()
    174179{
    175     m_platformPlayer->prepareToPlay();
     180    if (m_platformPlayer)
     181        m_platformPlayer->prepareToPlay();
    176182}
    177183
    178184void MediaPlayerPrivate::play()
    179185{
    180     m_platformPlayer->play();
     186    if (m_platformPlayer)
     187        m_platformPlayer->play();
    181188}
    182189
    183190void MediaPlayerPrivate::pause()
    184191{
    185     m_platformPlayer->pause();
     192    if (m_platformPlayer)
     193        m_platformPlayer->pause();
    186194}
    187195
     
    193201IntSize MediaPlayerPrivate::naturalSize() const
    194202{
     203    if (!m_platformPlayer)
     204        return IntSize();
     205
    195206    // Cannot return empty size, otherwise paint() will never get called.
    196207    // Also, the values here will affect the aspect ratio of the output rectangle that will
     
    210221bool MediaPlayerPrivate::hasVideo() const
    211222{
    212     return m_platformPlayer->hasVideo();
     223    if (m_platformPlayer)
     224        return m_platformPlayer->hasVideo();
     225    return false;
    213226}
    214227
    215228bool MediaPlayerPrivate::hasAudio() const
    216229{
    217     return m_platformPlayer->hasAudio();
     230    if (m_platformPlayer)
     231        return m_platformPlayer->hasAudio();
     232    return false;
    218233}
    219234
     
    225240float MediaPlayerPrivate::duration() const
    226241{
    227     return m_platformPlayer->duration();
     242    if (m_platformPlayer)
     243        return m_platformPlayer->duration();
     244    return 0.0f;
    228245}
    229246
     
    233250float MediaPlayerPrivate::currentTime() const
    234251{
     252    if (!m_platformPlayer)
     253        return 0.0f;
     254
    235255    // For very short media on the order of SeekSubmissionDelay we get
    236256    // unwanted repeats if we don't return the most up-to-date currentTime().
     
    241261void MediaPlayerPrivate::seek(float time)
    242262{
     263    if (!m_platformPlayer)
     264        return;
     265
    243266    m_lastSeekTime = time;
    244267    m_lastSeekTimePending = true;
     
    263286void MediaPlayerPrivate::setRate(float rate)
    264287{
    265     m_platformPlayer->setRate(rate);
     288    if (m_platformPlayer)
     289        m_platformPlayer->setRate(rate);
    266290}
    267291
    268292bool MediaPlayerPrivate::paused() const
    269293{
    270     return m_platformPlayer->paused();
     294    if (m_platformPlayer)
     295        return m_platformPlayer->paused();
     296    return false;
    271297}
    272298
    273299void MediaPlayerPrivate::setVolume(float volume)
    274300{
    275     m_platformPlayer->setVolume(volume);
     301    if (m_platformPlayer)
     302        m_platformPlayer->setVolume(volume);
    276303}
    277304
     
    288315float MediaPlayerPrivate::maxTimeSeekable() const
    289316{
    290     return m_platformPlayer->maxTimeSeekable();
     317    if (m_platformPlayer)
     318        return m_platformPlayer->maxTimeSeekable();
     319    return 0.0f;
    291320}
    292321
    293322PassRefPtr<TimeRanges> MediaPlayerPrivate::buffered() const
    294323{
     324    if (!m_platformPlayer)
     325        return TimeRanges::create();
     326
    295327    RefPtr<TimeRanges> timeRanges = TimeRanges::create();
    296328    if (float bufferLoaded = m_platformPlayer->bufferLoaded())
     
    312344void MediaPlayerPrivate::paint(GraphicsContext* context, const IntRect& rect)
    313345{
     346    if (!m_platformPlayer)
     347        return;
     348
    314349#if USE(ACCELERATED_COMPOSITING)
    315350    // Only process paint calls coming via the accelerated compositing code
     
    336371bool MediaPlayerPrivate::hasAvailableVideoFrame() const
    337372{
    338     return m_platformPlayer->hasAvailableVideoFrame();
     373    if (m_platformPlayer)
     374        return m_platformPlayer->hasAvailableVideoFrame();
     375    return false;
    339376}
    340377
     
    346383MediaPlayer::MovieLoadType MediaPlayerPrivate::movieLoadType() const
    347384{
    348     return static_cast<MediaPlayer::MovieLoadType>(m_platformPlayer->movieLoadType());
     385    if (m_platformPlayer)
     386        return static_cast<MediaPlayer::MovieLoadType>(m_platformPlayer->movieLoadType());
     387    return MediaPlayer::Unknown;
    349388}
    350389
     
    455494void MediaPlayerPrivate::setAllowPPSVolumeUpdates(bool allow)
    456495{
    457     return m_platformPlayer->setAllowPPSVolumeUpdates(allow);
     496    if (m_platformPlayer)
     497        return m_platformPlayer->setAllowPPSVolumeUpdates(allow);
    458498}
    459499
     
    463503    MediaPlayer::ReadyState oldReadyState = m_readyState;
    464504
    465     MMRPlayer::Error currentError = m_platformPlayer->error();
     505    PlatformPlayer::Error currentError = m_platformPlayer->error();
    466506
    467507    HTMLMediaElement* element = static_cast<HTMLMediaElement*>(m_webCorePlayer->mediaPlayerClient());
    468508
    469     if (currentError != MMRPlayer::MediaOK) {
     509    if (currentError != PlatformPlayer::MediaOK) {
    470510        m_readyState = MediaPlayer::HaveNothing;
    471         if (currentError == MMRPlayer::MediaDecodeError)
     511        if (currentError == PlatformPlayer::MediaDecodeError)
    472512            m_networkState = MediaPlayer::DecodeError;
    473         else if (currentError == MMRPlayer::MediaMetaDataError
    474             || currentError == MMRPlayer::MediaAudioReceiveError
    475             || currentError == MMRPlayer::MediaVideoReceiveError)
     513        else if (currentError == PlatformPlayer::MediaMetaDataError
     514            || currentError == PlatformPlayer::MediaAudioReceiveError
     515            || currentError == PlatformPlayer::MediaVideoReceiveError)
    476516            m_networkState = MediaPlayer::NetworkError;
    477517    } else {
    478518        switch (m_platformPlayer->mediaState()) {
    479         case MMRPlayer::MMRPlayStateIdle:
     519        case PlatformPlayer::MMRPlayStateIdle:
    480520            m_networkState = MediaPlayer::Idle;
    481521            break;
    482         case MMRPlayer::MMRPlayStatePlaying:
     522        case PlatformPlayer::MMRPlayStatePlaying:
    483523            m_networkState = MediaPlayer::Loading;
    484524            break;
    485         case MMRPlayer::MMRPlayStateStopped:
     525        case PlatformPlayer::MMRPlayStateStopped:
    486526            m_networkState = MediaPlayer::Idle;
    487527            break;
    488         case MMRPlayer::MMRPlayStateUnknown:
     528        case PlatformPlayer::MMRPlayStateUnknown:
    489529        default:
    490530            break;
     
    492532
    493533        switch (m_platformPlayer->state()) {
    494         case MMRPlayer::MP_STATE_IDLE:
     534        case PlatformPlayer::MP_STATE_IDLE:
    495535#if USE(ACCELERATED_COMPOSITING)
    496536            setBuffering(false);
     
    505545                element->exitFullscreen();
    506546            break;
    507         case MMRPlayer::MP_STATE_ACTIVE:
     547        case PlatformPlayer::MP_STATE_ACTIVE:
    508548#if USE(ACCELERATED_COMPOSITING)
    509549            m_showBufferingImage = false;
     
    514554#endif
    515555            break;
    516         case MMRPlayer::MP_STATE_UNSUPPORTED:
     556        case PlatformPlayer::MP_STATE_UNSUPPORTED:
    517557            break;
    518558        default:
     
    530570}
    531571
    532 // IMMRPlayerListener callbacks implementation
    533 void MediaPlayerPrivate::onStateChanged(MMRPlayer::MpState)
     572// IPlatformPlayerListener callbacks implementation
     573void MediaPlayerPrivate::onStateChanged(PlatformPlayer::MpState)
    534574{
    535575    updateStates();
    536576}
    537577
    538 void MediaPlayerPrivate::onMediaStatusChanged(MMRPlayer::MMRPlayState)
     578void MediaPlayerPrivate::onMediaStatusChanged(PlatformPlayer::MMRPlayState)
    539579{
    540580    updateStates();
    541581}
    542582
    543 void MediaPlayerPrivate::onError(MMRPlayer::Error type)
     583void MediaPlayerPrivate::onError(PlatformPlayer::Error type)
    544584{
    545585    updateStates();
     
    641681    m_waitMetadataPopDialogCounter = 0;
    642682
    643     int wait = showErrorDialog(MMRPlayer::MediaMetaDataTimeoutError);
     683    int wait = showErrorDialog(PlatformPlayer::MediaMetaDataTimeoutError);
    644684    if (!wait)
    645685        onPauseNotified();
     
    703743}
    704744
    705 int MediaPlayerPrivate::showErrorDialog(MMRPlayer::Error type)
     745int MediaPlayerPrivate::showErrorDialog(PlatformPlayer::Error type)
    706746{
    707747    using namespace BlackBerry::WebKit;
     
    709749    WebPageClient::AlertType atype;
    710750    switch (type) {
    711     case MMRPlayer::MediaOK:
     751    case PlatformPlayer::MediaOK:
    712752        atype = WebPageClient::MediaOK;
    713753        break;
    714     case MMRPlayer::MediaDecodeError:
     754    case PlatformPlayer::MediaDecodeError:
    715755        atype = WebPageClient::MediaDecodeError;
    716756        break;
    717     case MMRPlayer::MediaMetaDataError:
     757    case PlatformPlayer::MediaMetaDataError:
    718758        atype = WebPageClient::MediaMetaDataError;
    719759        break;
    720     case MMRPlayer::MediaMetaDataTimeoutError:
     760    case PlatformPlayer::MediaMetaDataTimeoutError:
    721761        atype = WebPageClient::MediaMetaDataTimeoutError;
    722762        break;
    723     case MMRPlayer::MediaNoMetaDataError:
     763    case PlatformPlayer::MediaNoMetaDataError:
    724764        atype = WebPageClient::MediaNoMetaDataError;
    725765        break;
    726     case MMRPlayer::MediaVideoReceiveError:
     766    case PlatformPlayer::MediaVideoReceiveError:
    727767        atype = WebPageClient::MediaVideoReceiveError;
    728768        break;
    729     case MMRPlayer::MediaAudioReceiveError:
     769    case PlatformPlayer::MediaAudioReceiveError:
    730770        atype = WebPageClient::MediaAudioReceiveError;
    731771        break;
    732     case MMRPlayer::MediaInvalidError:
     772    case PlatformPlayer::MediaInvalidError:
    733773        atype = WebPageClient::MediaInvalidError;
    734774        break;
  • trunk/Source/WebCore/platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.h

    r123747 r126008  
    2323#include "MediaPlayerPrivate.h"
    2424
    25 #include <BlackBerryPlatformMMRPlayer.h>
     25#include <BlackBerryPlatformPlayer.h>
    2626
    2727namespace BlackBerry {
     
    3333namespace WebCore {
    3434
    35 class MediaPlayerPrivate : public MediaPlayerPrivateInterface, public BlackBerry::Platform::IMMRPlayerListener {
     35class MediaPlayerPrivate : public MediaPlayerPrivateInterface, public BlackBerry::Platform::IPlatformPlayerListener {
    3636public:
    3737    virtual ~MediaPlayerPrivate();
     
    114114    void setAllowPPSVolumeUpdates(bool);
    115115
    116     // IMMRPlayerListener implementation.
    117     virtual void onStateChanged(BlackBerry::Platform::MMRPlayer::MpState);
    118     virtual void onMediaStatusChanged(BlackBerry::Platform::MMRPlayer::MMRPlayState);
    119     virtual void onError(BlackBerry::Platform::MMRPlayer::Error);
     116    // IPlatformPlayerListener implementation.
     117    virtual void onStateChanged(BlackBerry::Platform::PlatformPlayer::MpState);
     118    virtual void onMediaStatusChanged(BlackBerry::Platform::PlatformPlayer::MMRPlayState);
     119    virtual void onError(BlackBerry::Platform::PlatformPlayer::Error);
    120120    virtual void onDurationChanged(float);
    121121    virtual void onTimeChanged(float);
     
    137137    virtual bool isElementPaused() const;
    138138    virtual bool isTabVisible() const;
    139     virtual int showErrorDialog(BlackBerry::Platform::MMRPlayer::Error);
     139    virtual int showErrorDialog(BlackBerry::Platform::PlatformPlayer::Error);
    140140    virtual BlackBerry::Platform::Graphics::Window* platformWindow();
    141141
     
    150150
    151151    MediaPlayer* m_webCorePlayer;
    152     BlackBerry::Platform::MMRPlayer* m_platformPlayer;
     152    BlackBerry::Platform::PlatformPlayer* m_platformPlayer;
    153153
    154154    mutable MediaPlayer::NetworkState m_networkState;
Note: See TracChangeset for help on using the changeset viewer.