| OLD | NEW |
| 1 // Copyright (c) 2008-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2008-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 "webkit/glue/webmediaplayer_impl.h" | 5 #include "webkit/glue/webmediaplayer_impl.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "googleurl/src/gurl.h" | 8 #include "googleurl/src/gurl.h" |
| 9 #include "media/base/media_format.h" |
| 9 #include "media/filters/ffmpeg_audio_decoder.h" | 10 #include "media/filters/ffmpeg_audio_decoder.h" |
| 10 #include "media/filters/ffmpeg_demuxer.h" | 11 #include "media/filters/ffmpeg_demuxer.h" |
| 11 #include "media/filters/ffmpeg_video_decoder.h" | 12 #include "media/filters/ffmpeg_video_decoder.h" |
| 12 #include "media/filters/null_audio_renderer.h" | 13 #include "media/filters/null_audio_renderer.h" |
| 13 #include "webkit/api/public/WebRect.h" | 14 #include "webkit/api/public/WebRect.h" |
| 14 #include "webkit/api/public/WebSize.h" | 15 #include "webkit/api/public/WebSize.h" |
| 15 #include "webkit/api/public/WebURL.h" | 16 #include "webkit/api/public/WebURL.h" |
| 16 #include "webkit/glue/media/video_renderer_impl.h" | 17 #include "webkit/glue/media/video_renderer_impl.h" |
| 17 | 18 |
| 18 using WebKit::WebCanvas; | 19 using WebKit::WebCanvas; |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 | 258 |
| 258 bool WebMediaPlayerImpl::totalBytesKnown() { | 259 bool WebMediaPlayerImpl::totalBytesKnown() { |
| 259 DCHECK(MessageLoop::current() == main_loop_); | 260 DCHECK(MessageLoop::current() == main_loop_); |
| 260 | 261 |
| 261 return pipeline_->GetTotalBytes() != 0; | 262 return pipeline_->GetTotalBytes() != 0; |
| 262 } | 263 } |
| 263 | 264 |
| 264 bool WebMediaPlayerImpl::hasVideo() const { | 265 bool WebMediaPlayerImpl::hasVideo() const { |
| 265 DCHECK(MessageLoop::current() == main_loop_); | 266 DCHECK(MessageLoop::current() == main_loop_); |
| 266 | 267 |
| 267 size_t width, height; | 268 return pipeline_->IsRendered(media::mime_type::kMajorTypeVideo); |
| 268 pipeline_->GetVideoSize(&width, &height); | |
| 269 return width != 0 && height != 0; | |
| 270 } | 269 } |
| 271 | 270 |
| 272 WebKit::WebSize WebMediaPlayerImpl::naturalSize() const { | 271 WebKit::WebSize WebMediaPlayerImpl::naturalSize() const { |
| 273 DCHECK(MessageLoop::current() == main_loop_); | 272 DCHECK(MessageLoop::current() == main_loop_); |
| 274 | 273 |
| 275 size_t width, height; | 274 size_t width, height; |
| 276 pipeline_->GetVideoSize(&width, &height); | 275 pipeline_->GetVideoSize(&width, &height); |
| 277 return WebKit::WebSize(width, height); | 276 return WebKit::WebSize(width, height); |
| 278 } | 277 } |
| 279 | 278 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 310 | 309 |
| 311 float WebMediaPlayerImpl::maxTimeBuffered() const { | 310 float WebMediaPlayerImpl::maxTimeBuffered() const { |
| 312 DCHECK(MessageLoop::current() == main_loop_); | 311 DCHECK(MessageLoop::current() == main_loop_); |
| 313 | 312 |
| 314 return static_cast<float>(pipeline_->GetBufferedTime().InSecondsF()); | 313 return static_cast<float>(pipeline_->GetBufferedTime().InSecondsF()); |
| 315 } | 314 } |
| 316 | 315 |
| 317 float WebMediaPlayerImpl::maxTimeSeekable() const { | 316 float WebMediaPlayerImpl::maxTimeSeekable() const { |
| 318 DCHECK(MessageLoop::current() == main_loop_); | 317 DCHECK(MessageLoop::current() == main_loop_); |
| 319 | 318 |
| 320 // TODO(scherkus): move this logic down into the pipeline. | 319 // If we are performing streaming, we report that we cannot seek at all. |
| 321 if (pipeline_->GetTotalBytes() == 0) { | 320 // We are using this flag to indicate if the data source supports seeking |
| 321 // or not. We should be able to seek even if we are performing streaming. |
| 322 // TODO(hclam): We need to update this when we have better caching. |
| 323 if (pipeline_->IsStreaming()) |
| 322 return 0.0f; | 324 return 0.0f; |
| 323 } | 325 return static_cast<float>(pipeline_->GetDuration().InSecondsF()); |
| 324 double total_bytes = static_cast<double>(pipeline_->GetTotalBytes()); | |
| 325 double buffered_bytes = static_cast<double>(pipeline_->GetBufferedBytes()); | |
| 326 double duration = static_cast<double>(pipeline_->GetDuration().InSecondsF()); | |
| 327 return static_cast<float>(duration * (buffered_bytes / total_bytes)); | |
| 328 } | 326 } |
| 329 | 327 |
| 330 unsigned long long WebMediaPlayerImpl::bytesLoaded() const { | 328 unsigned long long WebMediaPlayerImpl::bytesLoaded() const { |
| 331 DCHECK(MessageLoop::current() == main_loop_); | 329 DCHECK(MessageLoop::current() == main_loop_); |
| 332 | 330 |
| 333 return pipeline_->GetBufferedBytes(); | 331 return pipeline_->GetBufferedBytes(); |
| 334 } | 332 } |
| 335 | 333 |
| 336 unsigned long long WebMediaPlayerImpl::totalBytes() const { | 334 unsigned long long WebMediaPlayerImpl::totalBytes() const { |
| 337 DCHECK(MessageLoop::current() == main_loop_); | 335 DCHECK(MessageLoop::current() == main_loop_); |
| 338 | 336 |
| 339 return pipeline_->GetTotalBytes(); | 337 return pipeline_->GetTotalBytes(); |
| 340 } | 338 } |
| 341 | 339 |
| 342 void WebMediaPlayerImpl::setSize(const WebSize& size) { | 340 void WebMediaPlayerImpl::setSize(const WebSize& size) { |
| 343 DCHECK(MessageLoop::current() == main_loop_); | 341 DCHECK(MessageLoop::current() == main_loop_); |
| 344 DCHECK(proxy_); | 342 DCHECK(proxy_); |
| 345 | 343 |
| 346 proxy_->SetSize(gfx::Rect(0, 0, size.width, size.height)); | 344 proxy_->SetSize(gfx::Rect(0, 0, size.width, size.height)); |
| 347 } | 345 } |
| 348 | 346 |
| 349 void WebMediaPlayerImpl::paint(WebCanvas* canvas, | 347 void WebMediaPlayerImpl::paint(WebCanvas* canvas, |
| 350 const WebRect& rect) { | 348 const WebRect& rect) { |
| 351 DCHECK(MessageLoop::current() == main_loop_); | 349 DCHECK(MessageLoop::current() == main_loop_); |
| 352 DCHECK(proxy_); | 350 DCHECK(proxy_); |
| 353 | 351 |
| 354 proxy_->Paint(canvas, rect); | 352 proxy_->Paint(canvas, rect); |
| 355 } | 353 } |
| 356 | 354 |
| 355 bool WebMediaPlayerImpl::hasSingleSecurityOrigin() const { |
| 356 // TODO(hclam): Implement this. |
| 357 return false; |
| 358 } |
| 359 |
| 360 WebKit::WebMediaPlayer::MovieLoadType |
| 361 WebMediaPlayerImpl::movieLoadType() const { |
| 362 DCHECK(MessageLoop::current() == main_loop_); |
| 363 |
| 364 // TODO(hclam): If the pipeline is performing streaming, we say that this is |
| 365 // a live stream. But instead it should be a StoredStream if we have proper |
| 366 // caching. |
| 367 if (pipeline_->IsStreaming()) |
| 368 return WebKit::WebMediaPlayer::LiveStream; |
| 369 return WebKit::WebMediaPlayer::Unknown; |
| 370 } |
| 371 |
| 357 void WebMediaPlayerImpl::WillDestroyCurrentMessageLoop() { | 372 void WebMediaPlayerImpl::WillDestroyCurrentMessageLoop() { |
| 358 Destroy(); | 373 Destroy(); |
| 359 main_loop_ = NULL; | 374 main_loop_ = NULL; |
| 360 } | 375 } |
| 361 | 376 |
| 362 void WebMediaPlayerImpl::Repaint() { | 377 void WebMediaPlayerImpl::Repaint() { |
| 363 DCHECK(MessageLoop::current() == main_loop_); | 378 DCHECK(MessageLoop::current() == main_loop_); |
| 364 GetClient()->repaint(); | 379 GetClient()->repaint(); |
| 365 } | 380 } |
| 366 | 381 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 } | 438 } |
| 424 } | 439 } |
| 425 | 440 |
| 426 WebKit::WebMediaPlayerClient* WebMediaPlayerImpl::GetClient() { | 441 WebKit::WebMediaPlayerClient* WebMediaPlayerImpl::GetClient() { |
| 427 DCHECK(MessageLoop::current() == main_loop_); | 442 DCHECK(MessageLoop::current() == main_loop_); |
| 428 DCHECK(client_); | 443 DCHECK(client_); |
| 429 return client_; | 444 return client_; |
| 430 } | 445 } |
| 431 | 446 |
| 432 } // namespace webkit_glue | 447 } // namespace webkit_glue |
| OLD | NEW |