OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 #include "webkit/glue/webmediaplayerclient_impl.h" | 6 #include "WebMediaPlayerClientImpl.h" |
7 | 7 |
8 #if ENABLE(VIDEO) | 8 #if ENABLE(VIDEO) |
9 | 9 |
10 #include "webkit/api/public/WebCanvas.h" | 10 #include "TemporaryGlue.h" |
11 #include "webkit/api/public/WebCString.h" | 11 #include "WebCanvas.h" |
12 #include "webkit/api/public/WebKit.h" | 12 #include "WebCString.h" |
13 #include "webkit/api/public/WebKitClient.h" | 13 #include "WebKit.h" |
14 #include "webkit/api/public/WebMediaPlayer.h" | 14 #include "WebKitClient.h" |
15 #include "webkit/api/public/WebRect.h" | 15 #include "WebMediaPlayer.h" |
16 #include "webkit/api/public/WebSize.h" | 16 #include "WebRect.h" |
17 #include "webkit/api/public/WebString.h" | 17 #include "WebSize.h" |
18 #include "webkit/api/public/WebURL.h" | 18 #include "WebString.h" |
19 #include "webkit/glue/glue_util.h" | 19 #include "WebURL.h" |
20 #include "webkit/glue/webframe_impl.h" | |
21 #include "webkit/glue/webview.h" | |
22 #include "webkit/glue/webview_delegate.h" | |
23 | 20 |
24 #include "CString.h" | 21 #include "CString.h" |
25 #include "Frame.h" | 22 #include "Frame.h" |
26 #include "GraphicsContext.h" | 23 #include "GraphicsContext.h" |
27 #include "HTMLMediaElement.h" | 24 #include "HTMLMediaElement.h" |
28 #include "IntSize.h" | 25 #include "IntSize.h" |
29 #include "KURL.h" | 26 #include "KURL.h" |
30 #include "MediaPlayer.h" | 27 #include "MediaPlayer.h" |
31 #include "NotImplemented.h" | 28 #include "NotImplemented.h" |
32 #include "PlatformContextSkia.h" | 29 #include "PlatformContextSkia.h" |
33 | 30 |
34 using namespace WebCore; | 31 using namespace WebCore; |
35 using namespace WebKit; | 32 |
| 33 namespace WebKit { |
| 34 |
| 35 static bool s_isEnabled = false; |
| 36 |
| 37 void WebMediaPlayerClientImpl::setIsEnabled(bool isEnabled) |
| 38 { |
| 39 s_isEnabled = isEnabled; |
| 40 } |
| 41 |
| 42 void WebMediaPlayerClientImpl::registerSelf(MediaEngineRegistrar registrar) |
| 43 { |
| 44 if (s_isEnabled) { |
| 45 registrar(WebMediaPlayerClientImpl::create, |
| 46 WebMediaPlayerClientImpl::getSupportedTypes, |
| 47 WebMediaPlayerClientImpl::supportsType); |
| 48 } |
| 49 } |
| 50 |
| 51 |
| 52 // WebMediaPlayerClient -------------------------------------------------------- |
| 53 |
| 54 void WebMediaPlayerClientImpl::networkStateChanged() |
| 55 { |
| 56 ASSERT(m_mediaPlayer); |
| 57 m_mediaPlayer->networkStateChanged(); |
| 58 } |
| 59 |
| 60 void WebMediaPlayerClientImpl::readyStateChanged() |
| 61 { |
| 62 ASSERT(m_mediaPlayer); |
| 63 m_mediaPlayer->readyStateChanged(); |
| 64 } |
| 65 |
| 66 void WebMediaPlayerClientImpl::volumeChanged() |
| 67 { |
| 68 ASSERT(m_mediaPlayer); |
| 69 m_mediaPlayer->volumeChanged(); |
| 70 } |
| 71 |
| 72 void WebMediaPlayerClientImpl::timeChanged() |
| 73 { |
| 74 ASSERT(m_mediaPlayer); |
| 75 m_mediaPlayer->timeChanged(); |
| 76 } |
| 77 |
| 78 void WebMediaPlayerClientImpl::repaint() |
| 79 { |
| 80 ASSERT(m_mediaPlayer); |
| 81 m_mediaPlayer->repaint(); |
| 82 } |
| 83 |
| 84 void WebMediaPlayerClientImpl::durationChanged() |
| 85 { |
| 86 ASSERT(m_mediaPlayer); |
| 87 m_mediaPlayer->durationChanged(); |
| 88 } |
| 89 |
| 90 void WebMediaPlayerClientImpl::rateChanged() |
| 91 { |
| 92 ASSERT(m_mediaPlayer); |
| 93 m_mediaPlayer->rateChanged(); |
| 94 } |
| 95 |
| 96 void WebMediaPlayerClientImpl::sizeChanged() |
| 97 { |
| 98 ASSERT(m_mediaPlayer); |
| 99 m_mediaPlayer->sizeChanged(); |
| 100 } |
| 101 |
| 102 void WebMediaPlayerClientImpl::sawUnsupportedTracks() |
| 103 { |
| 104 ASSERT(m_mediaPlayer); |
| 105 m_mediaPlayer->mediaPlayerClient()->mediaPlayerSawUnsupportedTracks(m_mediaPlayer); |
| 106 } |
| 107 |
| 108 // MediaPlayerPrivateInterface ------------------------------------------------- |
| 109 |
| 110 void WebMediaPlayerClientImpl::load(const String& url) |
| 111 { |
| 112 Frame* frame = static_cast<HTMLMediaElement*>( |
| 113 m_mediaPlayer->mediaPlayerClient())->document()->frame(); |
| 114 m_webMediaPlayer.set(TemporaryGlue::createWebMediaPlayer(this, frame)); |
| 115 if (m_webMediaPlayer.get()) |
| 116 m_webMediaPlayer->load(KURL(url)); |
| 117 } |
| 118 |
| 119 void WebMediaPlayerClientImpl::cancelLoad() |
| 120 { |
| 121 if (m_webMediaPlayer.get()) |
| 122 m_webMediaPlayer->cancelLoad(); |
| 123 } |
| 124 |
| 125 void WebMediaPlayerClientImpl::play() |
| 126 { |
| 127 if (m_webMediaPlayer.get()) |
| 128 m_webMediaPlayer->play(); |
| 129 } |
| 130 |
| 131 void WebMediaPlayerClientImpl::pause() |
| 132 { |
| 133 if (m_webMediaPlayer.get()) |
| 134 m_webMediaPlayer->pause(); |
| 135 } |
| 136 |
| 137 IntSize WebMediaPlayerClientImpl::naturalSize() const |
| 138 { |
| 139 if (m_webMediaPlayer.get()) |
| 140 return m_webMediaPlayer->naturalSize(); |
| 141 return IntSize(); |
| 142 } |
| 143 |
| 144 bool WebMediaPlayerClientImpl::hasVideo() const |
| 145 { |
| 146 if (m_webMediaPlayer.get()) |
| 147 return m_webMediaPlayer->hasVideo(); |
| 148 return false; |
| 149 } |
| 150 |
| 151 void WebMediaPlayerClientImpl::setVisible(bool visible) |
| 152 { |
| 153 if (m_webMediaPlayer.get()) |
| 154 m_webMediaPlayer->setVisible(visible); |
| 155 } |
| 156 |
| 157 float WebMediaPlayerClientImpl::duration() const |
| 158 { |
| 159 if (m_webMediaPlayer.get()) |
| 160 return m_webMediaPlayer->duration(); |
| 161 return 0.0f; |
| 162 } |
| 163 |
| 164 float WebMediaPlayerClientImpl::currentTime() const |
| 165 { |
| 166 if (m_webMediaPlayer.get()) |
| 167 return m_webMediaPlayer->currentTime(); |
| 168 return 0.0f; |
| 169 } |
| 170 |
| 171 void WebMediaPlayerClientImpl::seek(float time) |
| 172 { |
| 173 if (m_webMediaPlayer.get()) |
| 174 m_webMediaPlayer->seek(time); |
| 175 } |
| 176 |
| 177 bool WebMediaPlayerClientImpl::seeking() const |
| 178 { |
| 179 if (m_webMediaPlayer.get()) |
| 180 return m_webMediaPlayer->seeking(); |
| 181 return false; |
| 182 } |
| 183 |
| 184 void WebMediaPlayerClientImpl::setEndTime(float time) |
| 185 { |
| 186 if (m_webMediaPlayer.get()) |
| 187 m_webMediaPlayer->setEndTime(time); |
| 188 } |
| 189 |
| 190 void WebMediaPlayerClientImpl::setRate(float rate) |
| 191 { |
| 192 if (m_webMediaPlayer.get()) |
| 193 m_webMediaPlayer->setRate(rate); |
| 194 } |
| 195 |
| 196 bool WebMediaPlayerClientImpl::paused() const |
| 197 { |
| 198 if (m_webMediaPlayer.get()) |
| 199 return m_webMediaPlayer->paused(); |
| 200 return false; |
| 201 } |
| 202 |
| 203 void WebMediaPlayerClientImpl::setVolume(float volume) |
| 204 { |
| 205 if (m_webMediaPlayer.get()) |
| 206 m_webMediaPlayer->setVolume(volume); |
| 207 } |
| 208 |
| 209 MediaPlayer::NetworkState WebMediaPlayerClientImpl::networkState() const |
| 210 { |
| 211 COMPILE_ASSERT( |
| 212 int(WebMediaPlayer::Empty) == int(MediaPlayer::Empty), Empty); |
| 213 COMPILE_ASSERT( |
| 214 int(WebMediaPlayer::Idle) == int(MediaPlayer::Idle), Idle); |
| 215 COMPILE_ASSERT( |
| 216 int(WebMediaPlayer::Loading) == int(MediaPlayer::Loading), Loading); |
| 217 COMPILE_ASSERT( |
| 218 int(WebMediaPlayer::Loaded) == int(MediaPlayer::Loaded), Loaded); |
| 219 COMPILE_ASSERT( |
| 220 int(WebMediaPlayer::FormatError) == int(MediaPlayer::FormatError), |
| 221 FormatError); |
| 222 COMPILE_ASSERT( |
| 223 int(WebMediaPlayer::NetworkError) == int(MediaPlayer::NetworkError), |
| 224 NetworkError); |
| 225 COMPILE_ASSERT( |
| 226 int(WebMediaPlayer::DecodeError) == int(MediaPlayer::DecodeError), |
| 227 DecodeError); |
| 228 |
| 229 if (m_webMediaPlayer.get()) |
| 230 return static_cast<MediaPlayer::NetworkState>(m_webMediaPlayer->networkState()); |
| 231 return MediaPlayer::Empty; |
| 232 } |
| 233 |
| 234 MediaPlayer::ReadyState WebMediaPlayerClientImpl::readyState() const |
| 235 { |
| 236 COMPILE_ASSERT( |
| 237 int(WebMediaPlayer::HaveNothing) == int(MediaPlayer::HaveNothing), |
| 238 HaveNothing); |
| 239 COMPILE_ASSERT( |
| 240 int(WebMediaPlayer::HaveMetadata) == int(MediaPlayer::HaveMetadata), |
| 241 HaveMetadata); |
| 242 COMPILE_ASSERT( |
| 243 int(WebMediaPlayer::HaveCurrentData) == int(MediaPlayer::HaveCurrentData), |
| 244 HaveCurrentData); |
| 245 COMPILE_ASSERT( |
| 246 int(WebMediaPlayer::HaveFutureData) == int(MediaPlayer::HaveFutureData), |
| 247 HaveFutureData); |
| 248 COMPILE_ASSERT( |
| 249 int(WebMediaPlayer::HaveEnoughData) == int(MediaPlayer::HaveEnoughData), |
| 250 HaveEnoughData); |
| 251 |
| 252 if (m_webMediaPlayer.get()) |
| 253 return static_cast<MediaPlayer::ReadyState>(m_webMediaPlayer->readyState()); |
| 254 return MediaPlayer::HaveNothing; |
| 255 } |
| 256 |
| 257 float WebMediaPlayerClientImpl::maxTimeSeekable() const |
| 258 { |
| 259 if (m_webMediaPlayer.get()) |
| 260 return m_webMediaPlayer->maxTimeSeekable(); |
| 261 return 0.0f; |
| 262 } |
| 263 |
| 264 float WebMediaPlayerClientImpl::maxTimeBuffered() const |
| 265 { |
| 266 if (m_webMediaPlayer.get()) |
| 267 return m_webMediaPlayer->maxTimeBuffered(); |
| 268 return 0.0f; |
| 269 } |
| 270 |
| 271 int WebMediaPlayerClientImpl::dataRate() const |
| 272 { |
| 273 if (m_webMediaPlayer.get()) |
| 274 return m_webMediaPlayer->dataRate(); |
| 275 return 0; |
| 276 } |
| 277 |
| 278 bool WebMediaPlayerClientImpl::totalBytesKnown() const |
| 279 { |
| 280 if (m_webMediaPlayer.get()) |
| 281 return m_webMediaPlayer->totalBytesKnown(); |
| 282 return false; |
| 283 } |
| 284 |
| 285 unsigned WebMediaPlayerClientImpl::totalBytes() const |
| 286 { |
| 287 if (m_webMediaPlayer.get()) |
| 288 return static_cast<unsigned>(m_webMediaPlayer->totalBytes()); |
| 289 return 0; |
| 290 } |
| 291 |
| 292 unsigned WebMediaPlayerClientImpl::bytesLoaded() const |
| 293 { |
| 294 if (m_webMediaPlayer.get()) |
| 295 return static_cast<unsigned>(m_webMediaPlayer->bytesLoaded()); |
| 296 return 0; |
| 297 } |
| 298 |
| 299 void WebMediaPlayerClientImpl::setSize(const IntSize& size) |
| 300 { |
| 301 if (m_webMediaPlayer.get()) |
| 302 m_webMediaPlayer->setSize(WebSize(size.width(), size.height())); |
| 303 } |
| 304 |
| 305 void WebMediaPlayerClientImpl::paint(GraphicsContext* context, const IntRect& rect) |
| 306 { |
| 307 // FIXME: enable this for mac. |
| 308 #if WEBKIT_USING_SKIA |
| 309 if (m_webMediaPlayer.get()) |
| 310 m_webMediaPlayer->paint(context->platformContext()->canvas(), rect); |
| 311 #endif |
| 312 } |
| 313 |
| 314 void WebMediaPlayerClientImpl::setAutobuffer(bool autoBuffer) |
| 315 { |
| 316 if (m_webMediaPlayer.get()) |
| 317 m_webMediaPlayer->setAutoBuffer(autoBuffer); |
| 318 } |
| 319 |
| 320 MediaPlayerPrivateInterface* WebMediaPlayerClientImpl::create(MediaPlayer* player) |
| 321 { |
| 322 WebMediaPlayerClientImpl* client = new WebMediaPlayerClientImpl(); |
| 323 client->m_mediaPlayer = player; |
| 324 return client; |
| 325 } |
| 326 |
| 327 void WebMediaPlayerClientImpl::getSupportedTypes(HashSet<String>& supportedTypes) |
| 328 { |
| 329 // FIXME: decide what to do here, we should fill in the HashSet about |
| 330 // codecs that we support. |
| 331 notImplemented(); |
| 332 } |
| 333 |
| 334 MediaPlayer::SupportsType WebMediaPlayerClientImpl::supportsType(const String& type, |
| 335 const String& codecs) |
| 336 { |
| 337 // FIXME: implement this properly. |
| 338 return MediaPlayer::IsSupported; |
| 339 } |
36 | 340 |
37 WebMediaPlayerClientImpl::WebMediaPlayerClientImpl() | 341 WebMediaPlayerClientImpl::WebMediaPlayerClientImpl() |
38 : m_webMediaPlayer(0) { | 342 : m_mediaPlayer(0) |
39 } | 343 { |
40 | 344 } |
41 | 345 |
42 WebMediaPlayerClientImpl::~WebMediaPlayerClientImpl() { | 346 } // namespace WebKit |
43 delete m_webMediaPlayer; | |
44 } | |
45 | |
46 ////////////////////////////////////////////////////////////////////////////// | |
47 // WebMediaPlayerClientImpl, WebMediaPlayerClient implementations | |
48 void WebMediaPlayerClientImpl::networkStateChanged() { | |
49 ASSERT(m_mediaPlayer); | |
50 m_mediaPlayer->networkStateChanged(); | |
51 } | |
52 | |
53 void WebMediaPlayerClientImpl::readyStateChanged() { | |
54 ASSERT(m_mediaPlayer); | |
55 m_mediaPlayer->readyStateChanged(); | |
56 } | |
57 | |
58 void WebMediaPlayerClientImpl::volumeChanged() { | |
59 ASSERT(m_mediaPlayer); | |
60 m_mediaPlayer->volumeChanged(); | |
61 } | |
62 | |
63 void WebMediaPlayerClientImpl::timeChanged() { | |
64 ASSERT(m_mediaPlayer); | |
65 m_mediaPlayer->timeChanged(); | |
66 } | |
67 | |
68 void WebMediaPlayerClientImpl::repaint() { | |
69 ASSERT(m_mediaPlayer); | |
70 m_mediaPlayer->repaint(); | |
71 } | |
72 | |
73 void WebMediaPlayerClientImpl::durationChanged() { | |
74 ASSERT(m_mediaPlayer); | |
75 m_mediaPlayer->durationChanged(); | |
76 } | |
77 | |
78 void WebMediaPlayerClientImpl::rateChanged() { | |
79 ASSERT(m_mediaPlayer); | |
80 m_mediaPlayer->rateChanged(); | |
81 } | |
82 | |
83 void WebMediaPlayerClientImpl::sizeChanged() { | |
84 ASSERT(m_mediaPlayer); | |
85 m_mediaPlayer->sizeChanged(); | |
86 } | |
87 | |
88 void WebMediaPlayerClientImpl::sawUnsupportedTracks() { | |
89 ASSERT(m_mediaPlayer); | |
90 m_mediaPlayer->mediaPlayerClient()->mediaPlayerSawUnsupportedTracks( | |
91 m_mediaPlayer); | |
92 } | |
93 | |
94 ////////////////////////////////////////////////////////////////////////////// | |
95 // WebMediaPlayerClientImpl, MediaPlayerPrivateInterface implementations | |
96 void WebMediaPlayerClientImpl::load(const String& url) { | |
97 delete m_webMediaPlayer; | |
98 | |
99 WebCore::Frame* frame = static_cast<HTMLMediaElement*>( | |
100 m_mediaPlayer->mediaPlayerClient())->document()->frame(); | |
101 WebFrame* webFrame = WebFrameImpl::FromFrame(frame); | |
102 WebViewDelegate* d = webFrame->GetView()->GetDelegate(); | |
103 m_webMediaPlayer = d->CreateWebMediaPlayer(this); | |
104 m_webMediaPlayer->load(webkit_glue::KURLToWebURL(KURL(url))); | |
105 } | |
106 | |
107 void WebMediaPlayerClientImpl::cancelLoad() { | |
108 if (m_webMediaPlayer) | |
109 m_webMediaPlayer->cancelLoad(); | |
110 } | |
111 | |
112 void WebMediaPlayerClientImpl::play() { | |
113 if (m_webMediaPlayer) | |
114 m_webMediaPlayer->play(); | |
115 } | |
116 | |
117 void WebMediaPlayerClientImpl::pause() { | |
118 if (m_webMediaPlayer) | |
119 m_webMediaPlayer->pause(); | |
120 } | |
121 | |
122 IntSize WebMediaPlayerClientImpl::naturalSize() const { | |
123 if (m_webMediaPlayer) { | |
124 const WebSize& size = m_webMediaPlayer->naturalSize(); | |
125 return IntSize(size.width, size.height); | |
126 } | |
127 return IntSize(0, 0); | |
128 } | |
129 | |
130 bool WebMediaPlayerClientImpl::hasVideo() const { | |
131 if (m_webMediaPlayer) | |
132 return m_webMediaPlayer->hasVideo(); | |
133 return false; | |
134 } | |
135 | |
136 void WebMediaPlayerClientImpl::setVisible(bool visible) { | |
137 if (m_webMediaPlayer) | |
138 m_webMediaPlayer->setVisible(visible); | |
139 } | |
140 | |
141 float WebMediaPlayerClientImpl::duration() const { | |
142 if (m_webMediaPlayer) | |
143 return m_webMediaPlayer->duration(); | |
144 return 0.0f; | |
145 } | |
146 | |
147 float WebMediaPlayerClientImpl::currentTime() const { | |
148 if (m_webMediaPlayer) | |
149 return m_webMediaPlayer->currentTime(); | |
150 return 0.0f; | |
151 } | |
152 | |
153 void WebMediaPlayerClientImpl::seek(float time) { | |
154 if (m_webMediaPlayer) | |
155 m_webMediaPlayer->seek(time); | |
156 } | |
157 | |
158 bool WebMediaPlayerClientImpl::seeking() const { | |
159 return m_webMediaPlayer->seeking(); | |
160 } | |
161 | |
162 void WebMediaPlayerClientImpl::setEndTime(float time) { | |
163 if (m_webMediaPlayer) | |
164 m_webMediaPlayer->setEndTime(time); | |
165 } | |
166 | |
167 void WebMediaPlayerClientImpl::setRate(float rate) { | |
168 if (m_webMediaPlayer) | |
169 m_webMediaPlayer->setRate(rate); | |
170 } | |
171 | |
172 bool WebMediaPlayerClientImpl::paused() const { | |
173 if (m_webMediaPlayer) | |
174 return m_webMediaPlayer->paused(); | |
175 return false; | |
176 } | |
177 | |
178 void WebMediaPlayerClientImpl::setVolume(float volume) { | |
179 if (m_webMediaPlayer) | |
180 m_webMediaPlayer->setVolume(volume); | |
181 } | |
182 | |
183 MediaPlayer::NetworkState WebMediaPlayerClientImpl::networkState() const { | |
184 COMPILE_ASSERT( | |
185 int(WebMediaPlayer::Empty) == int(MediaPlayer::Empty), Empty); | |
186 COMPILE_ASSERT( | |
187 int(WebMediaPlayer::Idle) == int(MediaPlayer::Idle), Idle); | |
188 COMPILE_ASSERT( | |
189 int(WebMediaPlayer::Loading) == int(MediaPlayer::Loading), Loading); | |
190 COMPILE_ASSERT( | |
191 int(WebMediaPlayer::Loaded) == int(MediaPlayer::Loaded), Loaded); | |
192 COMPILE_ASSERT( | |
193 int(WebMediaPlayer::FormatError) == int(MediaPlayer::FormatError), | |
194 FormatError); | |
195 COMPILE_ASSERT( | |
196 int(WebMediaPlayer::NetworkError) == int(MediaPlayer::NetworkError), | |
197 NetworkError); | |
198 COMPILE_ASSERT( | |
199 int(WebMediaPlayer::DecodeError) == int(MediaPlayer::DecodeError), | |
200 DecodeError); | |
201 | |
202 if (m_webMediaPlayer) | |
203 return static_cast<MediaPlayer::NetworkState>( | |
204 m_webMediaPlayer->networkState()); | |
205 return MediaPlayer::Empty; | |
206 } | |
207 | |
208 MediaPlayer::ReadyState WebMediaPlayerClientImpl::readyState() const { | |
209 COMPILE_ASSERT( | |
210 int(WebMediaPlayer::HaveNothing) == int(MediaPlayer::HaveNothing), | |
211 HaveNothing); | |
212 COMPILE_ASSERT( | |
213 int(WebMediaPlayer::HaveMetadata) == int(MediaPlayer::HaveMetadata), | |
214 HaveMetadata); | |
215 COMPILE_ASSERT( | |
216 int(WebMediaPlayer::HaveCurrentData) == int(MediaPlayer::HaveCurrentData), | |
217 HaveCurrentData); | |
218 COMPILE_ASSERT( | |
219 int(WebMediaPlayer::HaveFutureData) == int(MediaPlayer::HaveFutureData), | |
220 HaveFutureData); | |
221 COMPILE_ASSERT( | |
222 int(WebMediaPlayer::HaveEnoughData) == int(MediaPlayer::HaveEnoughData), | |
223 HaveEnoughData); | |
224 | |
225 if (m_webMediaPlayer) | |
226 return static_cast<MediaPlayer::ReadyState>(m_webMediaPlayer->readyState()); | |
227 return MediaPlayer::HaveNothing; | |
228 } | |
229 | |
230 float WebMediaPlayerClientImpl::maxTimeSeekable() const { | |
231 if (m_webMediaPlayer) | |
232 return m_webMediaPlayer->maxTimeSeekable(); | |
233 return 0.0f; | |
234 } | |
235 | |
236 float WebMediaPlayerClientImpl::maxTimeBuffered() const { | |
237 if (m_webMediaPlayer) | |
238 return m_webMediaPlayer->maxTimeBuffered(); | |
239 return 0.0f; | |
240 } | |
241 | |
242 int WebMediaPlayerClientImpl::dataRate() const { | |
243 if (m_webMediaPlayer) | |
244 return m_webMediaPlayer->dataRate(); | |
245 return 0; | |
246 } | |
247 | |
248 bool WebMediaPlayerClientImpl::totalBytesKnown() const { | |
249 if (m_webMediaPlayer) | |
250 return m_webMediaPlayer->totalBytesKnown(); | |
251 return false; | |
252 } | |
253 | |
254 unsigned WebMediaPlayerClientImpl::totalBytes() const { | |
255 if (m_webMediaPlayer) | |
256 return static_cast<unsigned>(m_webMediaPlayer->totalBytes()); | |
257 return 0; | |
258 } | |
259 | |
260 unsigned WebMediaPlayerClientImpl::bytesLoaded() const { | |
261 if (m_webMediaPlayer) | |
262 return static_cast<unsigned>(m_webMediaPlayer->bytesLoaded()); | |
263 return 0; | |
264 } | |
265 | |
266 void WebMediaPlayerClientImpl::setSize(const IntSize& size) { | |
267 if (m_webMediaPlayer) | |
268 m_webMediaPlayer->setSize(WebSize(size.width(), size.height())); | |
269 } | |
270 | |
271 void WebMediaPlayerClientImpl::paint(GraphicsContext* context, | |
272 const IntRect& rect) { | |
273 // TODO(hclam): enable this for mac. | |
274 #if WEBKIT_USING_SKIA | |
275 if (m_webMediaPlayer) | |
276 m_webMediaPlayer->paint( | |
277 context->platformContext()->canvas(), | |
278 WebRect(rect.x(), rect.y(), rect.width(), rect.height())); | |
279 #endif | |
280 } | |
281 | |
282 void WebMediaPlayerClientImpl::setAutobuffer(bool autoBuffer) { | |
283 if (m_webMediaPlayer) | |
284 m_webMediaPlayer->setAutoBuffer(autoBuffer); | |
285 } | |
286 | |
287 // static | |
288 MediaPlayerPrivateInterface* WebMediaPlayerClientImpl::create( | |
289 MediaPlayer* player) { | |
290 WebMediaPlayerClientImpl* client = new WebMediaPlayerClientImpl(); | |
291 client->m_mediaPlayer = player; | |
292 return client; | |
293 } | |
294 | |
295 // static | |
296 void WebMediaPlayerClientImpl::getSupportedTypes( | |
297 HashSet<String>& supportedTypes) { | |
298 // TODO(hclam): decide what to do here, we should fill in the HashSet about | |
299 // codecs that we support. | |
300 notImplemented(); | |
301 } | |
302 | |
303 // static | |
304 MediaPlayer::SupportsType WebMediaPlayerClientImpl::supportsType( | |
305 const String& type, const String& codecs) { | |
306 // TODO(hclam): implement this nicely. | |
307 return MediaPlayer::IsSupported; | |
308 } | |
309 | 347 |
310 #endif // ENABLE(VIDEO) | 348 #endif // ENABLE(VIDEO) |
OLD | NEW |