31
#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
32
#include "MediaPlayerProxy.h"
31
35
#include "IntRect.h"
32
36
#include "StringHash.h"
33
37
#include <wtf/HashSet.h>
38
#include <wtf/OwnPtr.h>
34
39
#include <wtf/Noncopyable.h>
36
41
namespace WebCore {
39
45
class GraphicsContext;
42
class MediaPlayerPrivate;
49
class MediaPlayerPrivateInterface;
53
#if USE(ACCELERATED_COMPOSITING)
45
57
class MediaPlayerClient {
47
59
virtual ~MediaPlayerClient() { }
61
// the network state has changed
48
62
virtual void mediaPlayerNetworkStateChanged(MediaPlayer*) { }
64
// the ready state has changed
49
65
virtual void mediaPlayerReadyStateChanged(MediaPlayer*) { }
67
// the volume or muted state has changed
50
68
virtual void mediaPlayerVolumeChanged(MediaPlayer*) { }
70
// time has jumped, eg. not as a result of normal playback
51
71
virtual void mediaPlayerTimeChanged(MediaPlayer*) { }
73
// the media file duration has changed, or is now known
74
virtual void mediaPlayerDurationChanged(MediaPlayer*) { }
76
// the playback rate has changed
77
virtual void mediaPlayerRateChanged(MediaPlayer*) { }
79
// The MediaPlayer has found potentially problematic media content.
80
// This is used internally to trigger swapping from a <video>
81
// element to an <embed> in standalone documents
82
virtual void mediaPlayerSawUnsupportedTracks(MediaPlayer*) { }
84
// Presentation-related methods
85
// a new frame of video is available
52
86
virtual void mediaPlayerRepaint(MediaPlayer*) { }
88
// the movie size has changed
89
virtual void mediaPlayerSizeChanged(MediaPlayer*) { }
91
#if USE(ACCELERATED_COMPOSITING)
92
// whether the rendering system can accelerate the display of this MediaPlayer.
93
virtual bool mediaPlayerRenderingCanBeAccelerated(MediaPlayer*) { return false; }
95
// return the GraphicsLayer that will host the presentation for this MediaPlayer.
96
virtual GraphicsLayer* mediaPlayerGraphicsLayer(MediaPlayer*) { return 0; }
55
class MediaPlayer : Noncopyable {
100
class MediaPlayer : public Noncopyable {
57
102
MediaPlayer(MediaPlayerClient*);
58
103
virtual ~MediaPlayer();
105
// media engine support
106
enum SupportsType { IsNotSupported, IsSupported, MayBeSupported };
107
static MediaPlayer::SupportsType supportsType(ContentType contentType);
108
static void getSupportedTypes(HashSet<String>&);
60
109
static bool isAvailable();
61
static bool supportsType(const String&);
62
static void getSupportedTypes(HashSet<String>&);
111
bool supportsFullscreen() const;
112
bool supportsSave() const;
64
113
IntSize naturalSize();
114
bool hasVideo() const;
115
bool hasAudio() const;
67
117
void setFrameView(FrameView* frameView) { m_frameView = frameView; }
118
FrameView* frameView() { return m_frameView; }
68
119
bool inMediaDocument();
70
// FIXME: it would be better to just have a getter and setter for size.
71
// This is currently an absolute rect, which is not appropriate for
72
// content with transforms
73
IntRect rect() const { return m_rect; }
74
void setRect(const IntRect& r);
121
IntSize size() const { return m_size; }
122
void setSize(const IntSize& size);
76
void load(const String& url);
124
void load(const String& url, const ContentType& contentType);
77
125
void cancelLoad();
79
127
bool visible() const;
105
158
void setVolume(float);
107
160
int dataRate() const;
162
bool autobuffer() const;
163
void setAutobuffer(bool);
109
165
void paint(GraphicsContext*, const IntRect&);
166
void paintCurrentFrameInContext(GraphicsContext*, const IntRect&);
111
enum NetworkState { Empty, LoadFailed, Loading, LoadedMetaData, LoadedFirstFrame, Loaded };
168
enum NetworkState { Empty, Idle, Loading, Loaded, FormatError, NetworkError, DecodeError };
112
169
NetworkState networkState();
114
enum ReadyState { DataUnavailable, CanShowCurrentFrame, CanPlay, CanPlayThrough };
171
enum ReadyState { HaveNothing, HaveMetadata, HaveCurrentData, HaveFutureData, HaveEnoughData };
115
172
ReadyState readyState();
174
enum MovieLoadType { Unknown, Download, StoredStream, LiveStream };
175
MovieLoadType movieLoadType() const;
117
177
void networkStateChanged();
118
178
void readyStateChanged();
119
179
void volumeChanged();
120
180
void timeChanged();
183
void durationChanged();
187
MediaPlayerClient* mediaPlayerClient() const { return m_mediaPlayerClient; }
189
#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
190
void setPoster(const String& url);
191
void deliverNotification(MediaPlayerProxyNotificationType notification);
192
void setMediaPlayerProxy(WebMediaPlayerProxy* proxy);
195
#if USE(ACCELERATED_COMPOSITING)
196
// whether accelerated rendering is supported by the media engine for the current media.
197
bool supportsAcceleratedRendering() const;
198
// called when the rendering system flips the into or out of accelerated rendering mode.
199
void acceleratedRenderingStateChanged();
202
bool hasSingleSecurityOrigin() const;
126
friend class MediaPlayerPrivate;
205
static void initializeMediaEngines();
128
207
MediaPlayerClient* m_mediaPlayerClient;
129
MediaPlayerPrivate* m_private;
208
OwnPtr<MediaPlayerPrivateInterface*> m_private;
209
void* m_currentMediaEngine;
130
210
FrameView* m_frameView;
215
bool m_preservesPitch;
217
#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
218
WebMediaPlayerProxy* m_playerProxy; // not owned or used, passed to m_private
222
typedef MediaPlayerPrivateInterface* (*CreateMediaEnginePlayer)(MediaPlayer*);
223
typedef void (*MediaEngineSupportedTypes)(HashSet<String>& types);
224
typedef MediaPlayer::SupportsType (*MediaEngineSupportsType)(const String& type, const String& codecs);
226
typedef void (*MediaEngineRegistrar)(CreateMediaEnginePlayer, MediaEngineSupportedTypes, MediaEngineSupportsType);
231
#endif // ENABLE(VIDEO)