~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to src/3rdparty/webkit/WebCore/platform/graphics/MediaPlayer.h

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2009-11-02 18:30:08 UTC
  • mfrom: (1.2.2 upstream)
  • mto: (15.2.5 experimental)
  • mto: This revision was merged to the branch mainline in revision 88.
  • Revision ID: james.westby@ubuntu.com-20091102183008-b6a4gcs128mvfb3m
Tags: upstream-4.6.0~beta1
ImportĀ upstreamĀ versionĀ 4.6.0~beta1

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright (C) 2007 Apple Inc. All rights reserved.
 
2
 * Copyright (C) 2007, 2008, 2009 Apple Inc. All rights reserved.
3
3
 *
4
4
 * Redistribution and use in source and binary forms, with or without
5
5
 * modification, are permitted provided that the following conditions
28
28
 
29
29
#if ENABLE(VIDEO)
30
30
 
 
31
#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
 
32
#include "MediaPlayerProxy.h"
 
33
#endif
 
34
 
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>
35
40
 
36
41
namespace WebCore {
37
42
 
 
43
class ContentType;
38
44
class FrameView;
39
45
class GraphicsContext;
 
46
class IntRect;
40
47
class IntSize;
41
48
class MediaPlayer;
42
 
class MediaPlayerPrivate;
 
49
class MediaPlayerPrivateInterface;
43
50
class String;
 
51
class TimeRanges;
 
52
 
 
53
#if USE(ACCELERATED_COMPOSITING)
 
54
class GraphicsLayer;
 
55
#endif
44
56
 
45
57
class MediaPlayerClient {
46
58
public:
47
59
    virtual ~MediaPlayerClient() { }
 
60
 
 
61
    // the network state has changed
48
62
    virtual void mediaPlayerNetworkStateChanged(MediaPlayer*) { }
 
63
 
 
64
    // the ready state has changed
49
65
    virtual void mediaPlayerReadyStateChanged(MediaPlayer*) { }
 
66
 
 
67
    // the volume or muted state has changed
50
68
    virtual void mediaPlayerVolumeChanged(MediaPlayer*) { }
 
69
 
 
70
    // time has jumped, eg. not as a result of normal playback
51
71
    virtual void mediaPlayerTimeChanged(MediaPlayer*) { }
 
72
    
 
73
    // the media file duration has changed, or is now known
 
74
    virtual void mediaPlayerDurationChanged(MediaPlayer*) { }
 
75
    
 
76
    // the playback rate has changed
 
77
    virtual void mediaPlayerRateChanged(MediaPlayer*) { }
 
78
 
 
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*) { }
 
83
 
 
84
// Presentation-related methods
 
85
    // a new frame of video is available
52
86
    virtual void mediaPlayerRepaint(MediaPlayer*) { }
 
87
 
 
88
    // the movie size has changed
 
89
    virtual void mediaPlayerSizeChanged(MediaPlayer*) { }
 
90
 
 
91
#if USE(ACCELERATED_COMPOSITING)
 
92
    // whether the rendering system can accelerate the display of this MediaPlayer.
 
93
    virtual bool mediaPlayerRenderingCanBeAccelerated(MediaPlayer*) { return false; }
 
94
 
 
95
    // return the GraphicsLayer that will host the presentation for this MediaPlayer.
 
96
    virtual GraphicsLayer* mediaPlayerGraphicsLayer(MediaPlayer*) { return 0; }
 
97
#endif
53
98
};
54
99
 
55
 
class MediaPlayer : Noncopyable {
 
100
class MediaPlayer : public Noncopyable {
56
101
public:
57
102
    MediaPlayer(MediaPlayerClient*);
58
103
    virtual ~MediaPlayer();
59
 
    
 
104
 
 
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>&);
63
 
    
 
110
 
 
111
    bool supportsFullscreen() const;
 
112
    bool supportsSave() const;
64
113
    IntSize naturalSize();
65
 
    bool hasVideo();
 
114
    bool hasVideo() const;
 
115
    bool hasAudio() const;
66
116
    
67
117
    void setFrameView(FrameView* frameView) { m_frameView = frameView; }
 
118
    FrameView* frameView() { return m_frameView; }
68
119
    bool inMediaDocument();
69
120
    
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);
75
123
    
76
 
    void load(const String& url);
 
124
    void load(const String& url, const ContentType& contentType);
77
125
    void cancelLoad();
78
126
    
79
127
    bool visible() const;
88
136
    float duration() const;
89
137
    float currentTime() const;
90
138
    void seek(float time);
 
139
 
 
140
    float startTime() const;
91
141
    
92
142
    void setEndTime(float time);
93
143
    
94
144
    float rate() const;
95
145
    void setRate(float);
 
146
 
 
147
    bool preservesPitch() const;    
 
148
    void setPreservesPitch(bool);
96
149
    
97
 
    float maxTimeBuffered();
 
150
    PassRefPtr<TimeRanges> buffered();
98
151
    float maxTimeSeekable();
99
 
    
 
152
 
100
153
    unsigned bytesLoaded();
101
154
    bool totalBytesKnown();
102
155
    unsigned totalBytes();
105
158
    void setVolume(float);
106
159
    
107
160
    int dataRate() const;
108
 
    
 
161
 
 
162
    bool autobuffer() const;    
 
163
    void setAutobuffer(bool);
 
164
 
109
165
    void paint(GraphicsContext*, const IntRect&);
 
166
    void paintCurrentFrameInContext(GraphicsContext*, const IntRect&);
110
167
    
111
 
    enum NetworkState { Empty, LoadFailed, Loading, LoadedMetaData, LoadedFirstFrame, Loaded };
 
168
    enum NetworkState { Empty, Idle, Loading, Loaded, FormatError, NetworkError, DecodeError };
112
169
    NetworkState networkState();
113
170
 
114
 
    enum ReadyState  { DataUnavailable, CanShowCurrentFrame, CanPlay, CanPlayThrough };
 
171
    enum ReadyState  { HaveNothing, HaveMetadata, HaveCurrentData, HaveFutureData, HaveEnoughData };
115
172
    ReadyState readyState();
116
173
    
 
174
    enum MovieLoadType { Unknown, Download, StoredStream, LiveStream };
 
175
    MovieLoadType movieLoadType() const;
 
176
 
117
177
    void networkStateChanged();
118
178
    void readyStateChanged();
119
179
    void volumeChanged();
120
180
    void timeChanged();
 
181
    void sizeChanged();
 
182
    void rateChanged();
 
183
    void durationChanged();
121
184
 
122
185
    void repaint();
123
 
    
 
186
 
 
187
    MediaPlayerClient* mediaPlayerClient() const { return m_mediaPlayerClient; }
 
188
 
 
189
#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
 
190
    void setPoster(const String& url);
 
191
    void deliverNotification(MediaPlayerProxyNotificationType notification);
 
192
    void setMediaPlayerProxy(WebMediaPlayerProxy* proxy);
 
193
#endif
 
194
 
 
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();
 
200
#endif
 
201
 
 
202
    bool hasSingleSecurityOrigin() const;
 
203
 
124
204
private:
125
 
        
126
 
    friend class MediaPlayerPrivate;
127
 
    
 
205
    static void initializeMediaEngines();
 
206
 
128
207
    MediaPlayerClient* m_mediaPlayerClient;
129
 
    MediaPlayerPrivate* m_private;
 
208
    OwnPtr<MediaPlayerPrivateInterface*> m_private;
 
209
    void* m_currentMediaEngine;
130
210
    FrameView* m_frameView;
131
 
    IntRect m_rect;
 
211
    IntSize m_size;
132
212
    bool m_visible;
133
213
    float m_rate;
134
214
    float m_volume;
 
215
    bool m_preservesPitch;
 
216
    bool m_autobuffer;
 
217
#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
 
218
    WebMediaPlayerProxy* m_playerProxy;    // not owned or used, passed to m_private
 
219
#endif
135
220
};
136
221
 
 
222
typedef MediaPlayerPrivateInterface* (*CreateMediaEnginePlayer)(MediaPlayer*);
 
223
typedef void (*MediaEngineSupportedTypes)(HashSet<String>& types);
 
224
typedef MediaPlayer::SupportsType (*MediaEngineSupportsType)(const String& type, const String& codecs);
 
225
 
 
226
typedef void (*MediaEngineRegistrar)(CreateMediaEnginePlayer, MediaEngineSupportedTypes, MediaEngineSupportsType); 
 
227
 
 
228
 
137
229
}
138
230
 
139
 
#endif
 
231
#endif // ENABLE(VIDEO)
 
232
 
140
233
#endif