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 QTMovieWin_h
     27 #define QTMovieWin_h
     28 
     29 #include <Unicode.h>
     30 #include <windows.h>
     31 
     32 #ifdef QTMOVIEWIN_EXPORTS
     33 #define QTMOVIEWIN_API __declspec(dllexport)
     34 #else
     35 #define QTMOVIEWIN_API __declspec(dllimport)
     36 #endif
     37 
     38 class QTMovieWin;
     39 class QTMovieWinPrivate;
     40 
     41 class QTMovieWinClient {
     42 public:
     43     virtual void movieEnded(QTMovieWin*) = 0;
     44     virtual void movieLoadStateChanged(QTMovieWin*) = 0;
     45     virtual void movieTimeChanged(QTMovieWin*) = 0;
     46     virtual void movieNewImageAvailable(QTMovieWin*) = 0;
     47 };
     48 
     49 class QTMovieWinFullscreenClient {
     50 public:
     51     virtual LRESULT fullscreenClientWndProc(HWND, UINT message, WPARAM, LPARAM) = 0;
     52 };
     53 
     54 enum {
     55     QTMovieLoadStateError = -1L,
     56     QTMovieLoadStateLoaded  = 2000L,
     57     QTMovieLoadStatePlayable = 10000L,
     58     QTMovieLoadStatePlaythroughOK = 20000L,
     59     QTMovieLoadStateComplete = 100000L
     60 };
     61 
     62 typedef const struct __CFURL * CFURLRef;
     63 
     64 class QTMOVIEWIN_API QTMovieWin {
     65 public:
     66     static bool initializeQuickTime();
     67 
     68     typedef void (*SetTaskTimerDelayFunc)(double);
     69     typedef void (*StopTaskTimerFunc)();
     70     static void setTaskTimerFuncs(SetTaskTimerDelayFunc, StopTaskTimerFunc);
     71     static void taskTimerFired();
     72 
     73     QTMovieWin(QTMovieWinClient*);
     74     ~QTMovieWin();
     75 
     76     void load(const UChar* url, int len, bool preservesPitch);
     77     long loadState() const;
     78     float maxTimeLoaded() const;
     79 
     80     void play();
     81     void pause();
     82 
     83     float rate() const;
     84     void setRate(float);
     85 
     86     float duration() const;
     87     float currentTime() const;
     88     void setCurrentTime(float) const;
     89 
     90     void setVolume(float);
     91     void setPreservesPitch(bool);
     92 
     93     unsigned dataSize() const;
     94 
     95     void getNaturalSize(int& width, int& height);
     96     void setSize(int width, int height);
     97 
     98     void setVisible(bool);
     99     void paint(HDC, int x, int y);
    100     void getCurrentFrameInfo(void*& buffer, unsigned& bitsPerPixel, unsigned& rowBytes, unsigned& width, unsigned& height);
    101 
    102     void disableUnsupportedTracks(unsigned& enabledTrackCount, unsigned& totalTrackCount);
    103     void setDisabled(bool);
    104 
    105     bool hasVideo() const;
    106     bool hasAudio() const;
    107 
    108     bool hasClosedCaptions() const;
    109     void setClosedCaptionsVisible(bool);
    110 
    111     static unsigned countSupportedTypes();
    112     static void getSupportedType(unsigned index, const UChar*& str, unsigned& len);
    113 
    114     // Returns the full-screen window created
    115     HWND enterFullscreen(QTMovieWinFullscreenClient*);
    116     void exitFullscreen();
    117 
    118 private:
    119     void load(CFURLRef, bool preservesPitch);
    120     static LRESULT fullscreenWndProc(HWND, UINT message, WPARAM, LPARAM);
    121 
    122     QTMovieWinPrivate* m_private;
    123     bool m_disabled;
    124     friend class QTMovieWinPrivate;
    125 };
    126 
    127 #endif
    128