|
1 /* |
|
2 * Copyright (C) 2009 Google 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 are |
|
6 * met: |
|
7 * |
|
8 * * Redistributions of source code must retain the above copyright |
|
9 * notice, this list of conditions and the following disclaimer. |
|
10 * * Redistributions in binary form must reproduce the above |
|
11 * copyright notice, this list of conditions and the following disclaimer |
|
12 * in the documentation and/or other materials provided with the |
|
13 * distribution. |
|
14 * * Neither the name of Google Inc. nor the names of its |
|
15 * contributors may be used to endorse or promote products derived from |
|
16 * this software without specific prior written permission. |
|
17 * |
|
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
|
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
|
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
29 */ |
|
30 |
|
31 #ifndef WebMediaPlayerClientImpl_h |
|
32 #define WebMediaPlayerClientImpl_h |
|
33 |
|
34 #if ENABLE(VIDEO) |
|
35 |
|
36 #include "MediaPlayerPrivate.h" |
|
37 #include "WebMediaPlayerClient.h" |
|
38 #include <wtf/OwnPtr.h> |
|
39 |
|
40 namespace WebKit { |
|
41 |
|
42 class WebMediaElement; |
|
43 class WebMediaPlayer; |
|
44 |
|
45 // This class serves as a bridge between WebCore::MediaPlayer and |
|
46 // WebKit::WebMediaPlayer. |
|
47 class WebMediaPlayerClientImpl : public WebMediaPlayerClient |
|
48 , public WebCore::MediaPlayerPrivateInterface { |
|
49 public: |
|
50 static bool isEnabled(); |
|
51 static void setIsEnabled(bool); |
|
52 static void registerSelf(WebCore::MediaEngineRegistrar); |
|
53 |
|
54 static WebMediaPlayerClientImpl* fromMediaElement(const WebMediaElement* element); |
|
55 |
|
56 // Returns the encapsulated WebKit::WebMediaPlayer. |
|
57 WebMediaPlayer* mediaPlayer() const; |
|
58 |
|
59 // WebMediaPlayerClient methods: |
|
60 virtual void networkStateChanged(); |
|
61 virtual void readyStateChanged(); |
|
62 virtual void volumeChanged(float); |
|
63 virtual void muteChanged(bool); |
|
64 virtual void timeChanged(); |
|
65 virtual void repaint(); |
|
66 virtual void durationChanged(); |
|
67 virtual void rateChanged(); |
|
68 virtual void sizeChanged(); |
|
69 virtual void sawUnsupportedTracks(); |
|
70 virtual float volume() const; |
|
71 |
|
72 // MediaPlayerPrivateInterface methods: |
|
73 virtual void load(const WebCore::String& url); |
|
74 virtual void cancelLoad(); |
|
75 #if USE(ACCELERATED_COMPOSITING) |
|
76 virtual WebCore::PlatformLayer* platformLayer() const; |
|
77 #endif |
|
78 virtual WebCore::PlatformMedia platformMedia() const; |
|
79 virtual void play(); |
|
80 virtual void pause(); |
|
81 virtual bool supportsFullscreen() const; |
|
82 virtual bool supportsSave() const; |
|
83 virtual WebCore::IntSize naturalSize() const; |
|
84 virtual bool hasVideo() const; |
|
85 virtual bool hasAudio() const; |
|
86 virtual void setVisible(bool); |
|
87 virtual float duration() const; |
|
88 virtual float currentTime() const; |
|
89 virtual void seek(float time); |
|
90 virtual bool seeking() const; |
|
91 virtual void setEndTime(float time); |
|
92 virtual void setRate(float); |
|
93 virtual bool paused() const; |
|
94 virtual void setVolume(float); |
|
95 virtual WebCore::MediaPlayer::NetworkState networkState() const; |
|
96 virtual WebCore::MediaPlayer::ReadyState readyState() const; |
|
97 virtual float maxTimeSeekable() const; |
|
98 virtual WTF::PassRefPtr<WebCore::TimeRanges> buffered() const; |
|
99 virtual int dataRate() const; |
|
100 virtual void setAutobuffer(bool); |
|
101 virtual bool totalBytesKnown() const; |
|
102 virtual unsigned totalBytes() const; |
|
103 virtual unsigned bytesLoaded() const; |
|
104 virtual void setSize(const WebCore::IntSize&); |
|
105 virtual void paint(WebCore::GraphicsContext*, const WebCore::IntRect&); |
|
106 virtual bool hasSingleSecurityOrigin() const; |
|
107 #if USE(ACCELERATED_COMPOSITING) |
|
108 virtual bool supportsAcceleratedRendering() const; |
|
109 #endif |
|
110 |
|
111 virtual WebCore::MediaPlayer::MovieLoadType movieLoadType() const; |
|
112 |
|
113 private: |
|
114 WebMediaPlayerClientImpl(); |
|
115 |
|
116 static WebCore::MediaPlayerPrivateInterface* create(WebCore::MediaPlayer*); |
|
117 static void getSupportedTypes(WTF::HashSet<WebCore::String>&); |
|
118 static WebCore::MediaPlayer::SupportsType supportsType( |
|
119 const WebCore::String& type, const WebCore::String& codecs); |
|
120 |
|
121 WebCore::MediaPlayer* m_mediaPlayer; |
|
122 OwnPtr<WebMediaPlayer> m_webMediaPlayer; |
|
123 #if USE(ACCELERATED_COMPOSITING) |
|
124 RefPtr<WebCore::PlatformLayer> m_videoLayer; |
|
125 bool m_supportsAcceleratedCompositing; |
|
126 #endif |
|
127 static bool m_isEnabled; |
|
128 }; |
|
129 |
|
130 } // namespace WebKit |
|
131 |
|
132 #endif |
|
133 |
|
134 #endif |