Home | History | Annotate | Download | only in win
      1 /*
      2  * Copyright (C) 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
      3  *
      4  * Redistribution and use in source and binary forms, with or without
      5  * modification, are permitted provided that the following conditions
      6  * are met:
      7  * 1. Redistributions of source code must retain the above copyright
      8  *    notice, this list of conditions and the following disclaimer.
      9  * 2. Redistributions in binary form must reproduce the above copyright
     10  *    notice, this list of conditions and the following disclaimer in the
     11  *    documentation and/or other materials provided with the distribution.
     12  *
     13  * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
     14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     16  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
     17  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     18  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
     20  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
     21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     24  */
     25 
     26 #ifndef MediaPlayerPrivateQTKit_h
     27 #define MediaPlayerPrivateQTKit_h
     28 
     29 #if ENABLE(VIDEO)
     30 
     31 #include "MediaPlayerPrivate.h"
     32 #include "Timer.h"
     33 #include <QTMovieWin.h>
     34 #include <wtf/OwnPtr.h>
     35 #include <wtf/RetainPtr.h>
     36 
     37 #if USE(ACCELERATED_COMPOSITING)
     38 #include "GraphicsLayerClient.h"
     39 #endif
     40 
     41 #ifndef DRAW_FRAME_RATE
     42 #define DRAW_FRAME_RATE 0
     43 #endif
     44 
     45 typedef struct CGImage *CGImageRef;
     46 
     47 namespace WebCore {
     48 
     49 class GraphicsContext;
     50 class IntSize;
     51 class IntRect;
     52 class String;
     53 
     54 class MediaPlayerPrivate : public MediaPlayerPrivateInterface, public QTMovieWinClient
     55 #if USE(ACCELERATED_COMPOSITING)
     56         , public GraphicsLayerClient
     57 #endif
     58 {
     59 public:
     60     static void registerMediaEngine(MediaEngineRegistrar);
     61 
     62     ~MediaPlayerPrivate();
     63 
     64 private:
     65 
     66 #if USE(ACCELERATED_COMPOSITING)
     67     // GraphicsLayerClient methods
     68     virtual void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsLayerPaintingPhase, const IntRect& inClip);
     69     virtual void notifyAnimationStarted(const GraphicsLayer*, double time) { }
     70     virtual void notifySyncRequired(const GraphicsLayer*);
     71     virtual bool showDebugBorders() const { return false; }
     72     virtual bool showRepaintCounter() const { return false; }
     73 #endif
     74 
     75     MediaPlayerPrivate(MediaPlayer*);
     76 
     77     virtual bool supportsFullscreen() const;
     78     virtual PlatformMedia platformMedia() const;
     79 
     80     IntSize naturalSize() const;
     81     bool hasVideo() const;
     82     bool hasAudio() const;
     83 
     84     void load(const String& url);
     85     void cancelLoad();
     86 
     87     void play();
     88     void pause();
     89 
     90     bool paused() const;
     91     bool seeking() const;
     92 
     93     float duration() const;
     94     float currentTime() const;
     95     void seek(float time);
     96 
     97     void setRate(float);
     98     void setVolume(float);
     99     void setPreservesPitch(bool);
    100 
    101     MediaPlayer::NetworkState networkState() const { return m_networkState; }
    102     MediaPlayer::ReadyState readyState() const { return m_readyState; }
    103 
    104     PassRefPtr<TimeRanges> buffered() const;
    105     float maxTimeSeekable() const;
    106     unsigned bytesLoaded() const;
    107     unsigned totalBytes() const;
    108 
    109     void setVisible(bool);
    110     void setSize(const IntSize&);
    111 
    112     void loadStateChanged();
    113     void didEnd();
    114 
    115     void paint(GraphicsContext*, const IntRect&);
    116     void paintCompleted(GraphicsContext&, const IntRect&);
    117 
    118     bool hasSingleSecurityOrigin() const;
    119 
    120     bool hasClosedCaptions() const;
    121     void setClosedCaptionsVisible(bool);
    122 
    123     void updateStates();
    124     void doSeek();
    125     void cancelSeek();
    126     void seekTimerFired(Timer<MediaPlayerPrivate>*);
    127     float maxTimeLoaded() const;
    128     void sawUnsupportedTracks();
    129 
    130     virtual void movieEnded(QTMovieWin*);
    131     virtual void movieLoadStateChanged(QTMovieWin*);
    132     virtual void movieTimeChanged(QTMovieWin*);
    133     virtual void movieNewImageAvailable(QTMovieWin*);
    134 
    135     // engine support
    136     static MediaPlayerPrivateInterface* create(MediaPlayer*);
    137     static void getSupportedTypes(HashSet<String>& types);
    138     static MediaPlayer::SupportsType supportsType(const String& type, const String& codecs);
    139     static bool isAvailable();
    140 
    141 #if USE(ACCELERATED_COMPOSITING)
    142     virtual bool supportsAcceleratedRendering() const;
    143     virtual void acceleratedRenderingStateChanged();
    144 #endif
    145 
    146     enum MediaRenderingMode { MediaRenderingNone, MediaRenderingSoftwareRenderer, MediaRenderingMovieLayer };
    147     MediaRenderingMode currentRenderingMode() const;
    148     MediaRenderingMode preferredRenderingMode() const;
    149     bool isReadyForRendering() const;
    150 
    151     void setUpVideoRendering();
    152     void tearDownVideoRendering();
    153     bool hasSetUpVideoRendering() const;
    154 
    155     void createLayerForMovie();
    156     void destroyLayerForMovie();
    157 
    158     MediaPlayer* m_player;
    159     OwnPtr<QTMovieWin> m_qtMovie;
    160 #if USE(ACCELERATED_COMPOSITING)
    161     OwnPtr<GraphicsLayer> m_qtVideoLayer;
    162 #endif
    163     float m_seekTo;
    164     Timer<MediaPlayerPrivate> m_seekTimer;
    165     IntSize m_size;
    166     MediaPlayer::NetworkState m_networkState;
    167     MediaPlayer::ReadyState m_readyState;
    168     unsigned m_enabledTrackCount;
    169     unsigned m_totalTrackCount;
    170     bool m_hasUnsupportedTracks;
    171     bool m_startedPlaying;
    172     bool m_isStreaming;
    173     bool m_visible;
    174     bool m_newFrameAvailable;
    175 #if DRAW_FRAME_RATE
    176     double m_frameCountWhilePlaying;
    177     double m_timeStartedPlaying;
    178     double m_timeStoppedPlaying;
    179 #endif
    180 };
    181 
    182 }
    183 
    184 #endif
    185 #endif
    186