]>
Commit | Line | Data |
---|---|---|
a90939db JF |
1 | /* |
2 | * Copyright (C) 2007 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 MediaPlayer_h | |
27 | #define MediaPlayer_h | |
28 | ||
29 | #if ENABLE(VIDEO) | |
30 | ||
31 | #if ENABLE(PLUGIN_PROXY_FOR_VIDEO) | |
32 | #include "MediaPlayerProxy.h" | |
33 | #endif | |
34 | ||
35 | #include "IntRect.h" | |
36 | #include "StringHash.h" | |
37 | #include <wtf/HashSet.h> | |
38 | #include <wtf/OwnPtr.h> | |
39 | #include <wtf/Noncopyable.h> | |
40 | ||
41 | namespace WebCore { | |
42 | ||
43 | class ContentType; | |
44 | class FrameView; | |
45 | class GraphicsContext; | |
46 | class IntRect; | |
47 | class IntSize; | |
48 | class MediaPlayer; | |
49 | class MediaPlayerPrivateInterface; | |
50 | class String; | |
51 | ||
52 | class MediaPlayerClient { | |
53 | public: | |
54 | virtual ~MediaPlayerClient() { } | |
55 | ||
56 | // the network state has changed | |
57 | virtual void mediaPlayerNetworkStateChanged(MediaPlayer*) { } | |
58 | ||
59 | // the ready state has changed | |
60 | virtual void mediaPlayerReadyStateChanged(MediaPlayer*) { } | |
61 | ||
62 | // the volume or muted state has changed | |
63 | virtual void mediaPlayerVolumeChanged(MediaPlayer*) { } | |
64 | ||
65 | // time has jumped, eg. not as a result of normal playback | |
66 | virtual void mediaPlayerTimeChanged(MediaPlayer*) { } | |
67 | ||
68 | // a new frame of video is available | |
69 | virtual void mediaPlayerRepaint(MediaPlayer*) { } | |
70 | ||
71 | // the media file duration has changed, or is now known | |
72 | virtual void mediaPlayerDurationChanged(MediaPlayer*) { } | |
73 | ||
74 | // the playback rate has changed | |
75 | virtual void mediaPlayerRateChanged(MediaPlayer*) { } | |
76 | ||
77 | // the movie size has changed | |
78 | virtual void mediaPlayerSizeChanged(MediaPlayer*) { } | |
79 | }; | |
80 | ||
81 | class MediaPlayer : Noncopyable { | |
82 | public: | |
83 | MediaPlayer(MediaPlayerClient*); | |
84 | virtual ~MediaPlayer(); | |
85 | ||
86 | // media engine support | |
87 | enum SupportsType { IsNotSupported, IsSupported, MayBeSupported }; | |
88 | static MediaPlayer::SupportsType supportsType(ContentType contentType); | |
89 | static void getSupportedTypes(HashSet<String>&); | |
90 | static bool isAvailable(); | |
91 | ||
92 | IntSize naturalSize(); | |
93 | bool hasVideo(); | |
94 | ||
95 | void setFrameView(FrameView* frameView) { m_frameView = frameView; } | |
96 | FrameView* frameView() { return m_frameView; } | |
97 | bool inMediaDocument(); | |
98 | ||
99 | IntSize size() const { return m_size; } | |
100 | void setSize(const IntSize& size); | |
101 | ||
102 | void load(const String& url, const ContentType& contentType); | |
103 | void cancelLoad(); | |
104 | ||
105 | bool visible() const; | |
106 | void setVisible(bool); | |
107 | ||
108 | void play(); | |
109 | void pause(); | |
110 | ||
111 | bool paused() const; | |
112 | bool seeking() const; | |
113 | ||
114 | float duration() const; | |
115 | float currentTime() const; | |
116 | void seek(float time); | |
117 | ||
118 | void setEndTime(float time); | |
119 | ||
120 | float rate() const; | |
121 | void setRate(float); | |
122 | ||
123 | float maxTimeBuffered(); | |
124 | float maxTimeSeekable(); | |
125 | ||
126 | unsigned bytesLoaded(); | |
127 | bool totalBytesKnown(); | |
128 | unsigned totalBytes(); | |
129 | ||
130 | float volume() const; | |
131 | void setVolume(float); | |
132 | ||
133 | int dataRate() const; | |
134 | ||
135 | bool autobuffer() const; | |
136 | void setAutobuffer(bool); | |
137 | ||
138 | void paint(GraphicsContext*, const IntRect&); | |
139 | ||
140 | enum NetworkState { Empty, Idle, Loading, Loaded, FormatError, NetworkError, DecodeError }; | |
141 | NetworkState networkState(); | |
142 | ||
143 | enum ReadyState { HaveNothing, HaveMetadata, HaveCurrentData, HaveFutureData, HaveEnoughData }; | |
144 | ReadyState readyState(); | |
145 | ||
146 | void networkStateChanged(); | |
147 | void readyStateChanged(); | |
148 | void volumeChanged(); | |
149 | void timeChanged(); | |
150 | void sizeChanged(); | |
151 | void rateChanged(); | |
152 | void durationChanged(); | |
153 | ||
154 | void repaint(); | |
155 | ||
156 | MediaPlayerClient* mediaPlayerClient() const { return m_mediaPlayerClient; } | |
157 | ||
158 | #if ENABLE(PLUGIN_PROXY_FOR_VIDEO) | |
159 | void setPoster(const String& url); | |
160 | void deliverNotification(MediaPlayerProxyNotificationType notification); | |
161 | void setMediaPlayerProxy(WebMediaPlayerProxy* proxy); | |
162 | #endif | |
163 | ||
164 | private: | |
165 | static void initializeMediaEngines(); | |
166 | ||
167 | MediaPlayerClient* m_mediaPlayerClient; | |
168 | OwnPtr<MediaPlayerPrivateInterface*> m_private; | |
169 | void* m_currentMediaEngine; | |
170 | FrameView* m_frameView; | |
171 | IntSize m_size; | |
172 | bool m_visible; | |
173 | float m_rate; | |
174 | float m_volume; | |
175 | bool m_autobuffer; | |
176 | #if ENABLE(PLUGIN_PROXY_FOR_VIDEO) | |
177 | WebMediaPlayerProxy* m_playerProxy; // not owned or used, passed to m_private | |
178 | #endif | |
179 | }; | |
180 | ||
181 | typedef MediaPlayerPrivateInterface* (*CreateMediaEnginePlayer)(MediaPlayer*); | |
182 | typedef void (*MediaEngineSupportedTypes)(HashSet<String>& types); | |
183 | typedef MediaPlayer::SupportsType (*MediaEngineSupportsType)(const String& type, const String& codecs); | |
184 | ||
185 | typedef void (*MediaEngineRegistrar)(CreateMediaEnginePlayer, MediaEngineSupportedTypes, MediaEngineSupportsType); | |
186 | ||
187 | ||
188 | } | |
189 | ||
190 | #endif // ENABLE(VIDEO) | |
191 | ||
192 | #endif |