]> git.saurik.com Git - iphone-api.git/blob - WebCore/MediaPlayerPrivateQTKit.h
Adding the WebCore headers (for Cydget).
[iphone-api.git] / WebCore / MediaPlayerPrivateQTKit.h
1 /*
2 * Copyright (C) 2007, 2008, 2009 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 <wtf/RetainPtr.h>
34
35 #ifdef __OBJC__
36 #import <QTKit/QTTime.h>
37 @class QTMovie;
38 @class QTMovieView;
39 @class QTVideoRendererWebKitOnly;
40 @class WebCoreMovieObserver;
41 #else
42 class QTMovie;
43 class QTMovieView;
44 class QTTime;
45 class QTVideoRendererWebKitOnly;
46 class WebCoreMovieObserver;
47 #endif
48
49 #ifndef DRAW_FRAME_RATE
50 #define DRAW_FRAME_RATE 0
51 #endif
52
53 namespace WebCore {
54
55 class MediaPlayerPrivate : public MediaPlayerPrivateInterface {
56 public:
57 static void registerMediaEngine(MediaEngineRegistrar);
58
59 ~MediaPlayerPrivate();
60
61 void repaint();
62 void loadStateChanged();
63 void rateChanged();
64 void sizeChanged();
65 void timeChanged();
66 void didEnd();
67
68 private:
69 MediaPlayerPrivate(MediaPlayer*);
70
71 // engine support
72 static MediaPlayerPrivateInterface* MediaPlayerPrivate::create(MediaPlayer* player);
73 static void getSupportedTypes(HashSet<String>& types);
74 static MediaPlayer::SupportsType supportsType(const String& type, const String& codecs);
75 static bool isAvailable();
76
77 IntSize naturalSize() const;
78 bool hasVideo() const;
79
80 void load(const String& url);
81 void cancelLoad();
82
83 void play();
84 void pause();
85
86 bool paused() const;
87 bool seeking() const;
88
89 float duration() const;
90 float currentTime() const;
91 void seek(float time);
92
93 void setRate(float);
94 void setVolume(float);
95
96 void setEndTime(float time);
97
98 int dataRate() const;
99
100 MediaPlayer::NetworkState networkState() const { return m_networkState; }
101 MediaPlayer::ReadyState readyState() const { return m_readyState; }
102
103 float maxTimeBuffered() const;
104 float maxTimeSeekable() const;
105 unsigned bytesLoaded() const;
106 bool totalBytesKnown() const;
107 unsigned totalBytes() const;
108
109 void setVisible(bool);
110 void setSize(const IntSize&);
111
112 void paint(GraphicsContext*, const IntRect&);
113
114 void createQTMovie(const String& url);
115 void setUpVideoRendering();
116 void tearDownVideoRendering();
117 void createQTMovieView();
118 void detachQTMovieView();
119 void createQTVideoRenderer();
120 void destroyQTVideoRenderer();
121 QTTime createQTTime(float time) const;
122
123 void updateStates();
124 void doSeek();
125 void cancelSeek();
126 void seekTimerFired(Timer<MediaPlayerPrivate>*);
127 float maxTimeLoaded() const;
128 void disableUnsupportedTracks();
129
130 bool metaDataAvailable() const { return m_qtMovie && m_readyState >= MediaPlayer::HaveMetadata; }
131
132 MediaPlayer* m_player;
133 RetainPtr<QTMovie> m_qtMovie;
134 RetainPtr<QTMovieView> m_qtMovieView;
135 RetainPtr<QTVideoRendererWebKitOnly> m_qtVideoRenderer;
136 RetainPtr<WebCoreMovieObserver> m_objcObserver;
137 float m_seekTo;
138 Timer<MediaPlayerPrivate> m_seekTimer;
139 MediaPlayer::NetworkState m_networkState;
140 MediaPlayer::ReadyState m_readyState;
141 bool m_startedPlaying;
142 bool m_isStreaming;
143 bool m_visible;
144 IntRect m_rect;
145 unsigned m_enabledTrackCount;
146 float m_duration;
147 #if DRAW_FRAME_RATE
148 int m_frameCountWhilePlaying;
149 double m_timeStartedPlaying;
150 double m_timeStoppedPlaying;
151 #endif
152 };
153
154 }
155
156 #endif
157 #endif