Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/renderer/media/android/webmediaplayer_android.h" | 5 #include "content/renderer/media/android/webmediaplayer_android.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 454 | 454 |
| 455 bool WebMediaPlayerAndroid::seeking() const { | 455 bool WebMediaPlayerAndroid::seeking() const { |
| 456 return seeking_; | 456 return seeking_; |
| 457 } | 457 } |
| 458 | 458 |
| 459 double WebMediaPlayerAndroid::duration() const { | 459 double WebMediaPlayerAndroid::duration() const { |
| 460 // HTML5 spec requires duration to be NaN if readyState is HAVE_NOTHING | 460 // HTML5 spec requires duration to be NaN if readyState is HAVE_NOTHING |
| 461 if (ready_state_ == WebMediaPlayer::ReadyStateHaveNothing) | 461 if (ready_state_ == WebMediaPlayer::ReadyStateHaveNothing) |
| 462 return std::numeric_limits<double>::quiet_NaN(); | 462 return std::numeric_limits<double>::quiet_NaN(); |
| 463 | 463 |
| 464 // TODO(wolenetz): Correctly handle durations that MediaSourcePlayer | |
| 465 // considers unseekable, including kInfiniteDuration(). | |
|
acolwell GONE FROM CHROMIUM
2014/01/14 16:36:40
This comment should not be removed since this code
amogh.bihani
2014/01/15 06:33:02
initially when i had stopped duration to be more t
amogh.bihani
2014/01/15 06:33:02
Done.
| |
| 466 // See http://crbug.com/248396 | |
| 467 return duration_.InSecondsF(); | 464 return duration_.InSecondsF(); |
| 468 } | 465 } |
| 469 | 466 |
| 470 double WebMediaPlayerAndroid::currentTime() const { | 467 double WebMediaPlayerAndroid::currentTime() const { |
| 471 // If the player is processing a seek, return the seek time. | 468 // If the player is processing a seek, return the seek time. |
| 472 // Blink may still query us if updatePlaybackState() occurs while seeking. | 469 // Blink may still query us if updatePlaybackState() occurs while seeking. |
| 473 if (seeking()) { | 470 if (seeking()) { |
| 474 return pending_seek_ ? | 471 return pending_seek_ ? |
| 475 pending_seek_time_.InSecondsF() : seek_time_.InSecondsF(); | 472 pending_seek_time_.InSecondsF() : seek_time_.InSecondsF(); |
| 476 } | 473 } |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 494 if (media_source_delegate_) | 491 if (media_source_delegate_) |
| 495 return media_source_delegate_->Buffered(); | 492 return media_source_delegate_->Buffered(); |
| 496 return buffered_; | 493 return buffered_; |
| 497 } | 494 } |
| 498 | 495 |
| 499 double WebMediaPlayerAndroid::maxTimeSeekable() const { | 496 double WebMediaPlayerAndroid::maxTimeSeekable() const { |
| 500 // If we haven't even gotten to ReadyStateHaveMetadata yet then just | 497 // If we haven't even gotten to ReadyStateHaveMetadata yet then just |
| 501 // return 0 so that the seekable range is empty. | 498 // return 0 so that the seekable range is empty. |
| 502 if (ready_state_ < WebMediaPlayer::ReadyStateHaveMetadata) | 499 if (ready_state_ < WebMediaPlayer::ReadyStateHaveMetadata) |
| 503 return 0.0; | 500 return 0.0; |
| 504 | 501 |
|
acolwell GONE FROM CHROMIUM
2014/01/14 16:36:40
You also need the following to properly handle cli
amogh.bihani
2014/01/15 06:33:02
Done.
| |
| 505 // TODO(hclam): If this stream is not seekable this should return 0. | 502 return std::min(std::numeric_limits<int32>max(), duration()); |
| 506 return duration(); | |
| 507 } | 503 } |
| 508 | 504 |
| 509 bool WebMediaPlayerAndroid::didLoadingProgress() const { | 505 bool WebMediaPlayerAndroid::didLoadingProgress() const { |
| 510 bool ret = did_loading_progress_; | 506 bool ret = did_loading_progress_; |
| 511 did_loading_progress_ = false; | 507 did_loading_progress_ = false; |
| 512 return ret; | 508 return ret; |
| 513 } | 509 } |
| 514 | 510 |
| 515 void WebMediaPlayerAndroid::paint(blink::WebCanvas* canvas, | 511 void WebMediaPlayerAndroid::paint(blink::WebCanvas* canvas, |
| 516 const blink::WebRect& rect, | 512 const blink::WebRect& rect, |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 612 | 608 |
| 613 void WebMediaPlayerAndroid::OnMediaMetadataChanged( | 609 void WebMediaPlayerAndroid::OnMediaMetadataChanged( |
| 614 const base::TimeDelta& duration, int width, int height, bool success) { | 610 const base::TimeDelta& duration, int width, int height, bool success) { |
| 615 bool need_to_signal_duration_changed = false; | 611 bool need_to_signal_duration_changed = false; |
| 616 | 612 |
| 617 if (url_.SchemeIs("file")) | 613 if (url_.SchemeIs("file")) |
| 618 UpdateNetworkState(WebMediaPlayer::NetworkStateLoaded); | 614 UpdateNetworkState(WebMediaPlayer::NetworkStateLoaded); |
| 619 | 615 |
| 620 // Update duration, if necessary, prior to ready state updates that may | 616 // Update duration, if necessary, prior to ready state updates that may |
| 621 // cause duration() query. | 617 // cause duration() query. |
| 622 // TODO(wolenetz): Correctly handle durations that MediaSourcePlayer | |
| 623 // considers unseekable, including kInfiniteDuration(). | |
| 624 // See http://crbug.com/248396 | |
| 625 if (!ignore_metadata_duration_change_ && duration_ != duration) { | 618 if (!ignore_metadata_duration_change_ && duration_ != duration) { |
| 626 duration_ = duration; | 619 duration_ = duration; |
| 627 | 620 |
| 628 // Client readyState transition from HAVE_NOTHING to HAVE_METADATA | 621 // Client readyState transition from HAVE_NOTHING to HAVE_METADATA |
| 629 // already triggers a durationchanged event. If this is a different | 622 // already triggers a durationchanged event. If this is a different |
| 630 // transition, remember to signal durationchanged. | 623 // transition, remember to signal durationchanged. |
| 631 // Do not ever signal durationchanged on metadata change in MSE case | 624 // Do not ever signal durationchanged on metadata change in MSE case |
| 632 // because OnDurationChanged() handles this. | 625 // because OnDurationChanged() handles this. |
| 633 if (ready_state_ > WebMediaPlayer::ReadyStateHaveNothing && | 626 if (ready_state_ > WebMediaPlayer::ReadyStateHaveNothing && |
| 634 player_type_ != MEDIA_PLAYER_TYPE_MEDIA_SOURCE) { | 627 player_type_ != MEDIA_PLAYER_TYPE_MEDIA_SOURCE) { |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 821 | 814 |
| 822 void WebMediaPlayerAndroid::OnRequestFullscreen() { | 815 void WebMediaPlayerAndroid::OnRequestFullscreen() { |
| 823 client_->requestFullscreen(); | 816 client_->requestFullscreen(); |
| 824 } | 817 } |
| 825 | 818 |
| 826 void WebMediaPlayerAndroid::OnDurationChanged(const base::TimeDelta& duration) { | 819 void WebMediaPlayerAndroid::OnDurationChanged(const base::TimeDelta& duration) { |
| 827 DCHECK(main_loop_->BelongsToCurrentThread()); | 820 DCHECK(main_loop_->BelongsToCurrentThread()); |
| 828 // Only MSE |player_type_| registers this callback. | 821 // Only MSE |player_type_| registers this callback. |
| 829 DCHECK_EQ(player_type_, MEDIA_PLAYER_TYPE_MEDIA_SOURCE); | 822 DCHECK_EQ(player_type_, MEDIA_PLAYER_TYPE_MEDIA_SOURCE); |
| 830 | 823 |
| 824 // MediaSourcePlayer assumes duration more than 2^31 as unseekable | |
| 825 // because java player uses 32-bit integer for time at millisecond resolution | |
| 826 if (duration >= | |
|
acolwell GONE FROM CHROMIUM
2014/01/14 16:36:40
This prevents Blink from being notified of the new
amogh.bihani
2014/01/15 06:33:02
Done.
| |
| 827 base::TimeDelta::FromMilliseconds(std::numeric_limits<int32>max())) { | |
| 828 return; | |
| 829 } | |
| 830 | |
| 831 // Cache the new duration value and trust it over any subsequent duration | 831 // Cache the new duration value and trust it over any subsequent duration |
| 832 // values received in OnMediaMetadataChanged(). | 832 // values received in OnMediaMetadataChanged(). |
| 833 // TODO(wolenetz): Correctly handle durations that MediaSourcePlayer | |
| 834 // considers unseekable, including kInfiniteDuration(). | |
| 835 // See http://crbug.com/248396 | |
| 836 duration_ = duration; | 833 duration_ = duration; |
| 837 ignore_metadata_duration_change_ = true; | 834 ignore_metadata_duration_change_ = true; |
| 838 | 835 |
| 839 // Notify MediaPlayerClient that duration has changed, if > HAVE_NOTHING. | 836 // Notify MediaPlayerClient that duration has changed, if > HAVE_NOTHING. |
| 840 if (ready_state_ > WebMediaPlayer::ReadyStateHaveNothing) | 837 if (ready_state_ > WebMediaPlayer::ReadyStateHaveNothing) |
| 841 client_->durationChanged(); | 838 client_->durationChanged(); |
| 842 } | 839 } |
| 843 | 840 |
| 844 void WebMediaPlayerAndroid::UpdateNetworkState( | 841 void WebMediaPlayerAndroid::UpdateNetworkState( |
| 845 WebMediaPlayer::NetworkState state) { | 842 WebMediaPlayer::NetworkState state) { |
| (...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1462 | 1459 |
| 1463 void WebMediaPlayerAndroid::exitFullscreen() { | 1460 void WebMediaPlayerAndroid::exitFullscreen() { |
| 1464 manager_->ExitFullscreen(player_id_); | 1461 manager_->ExitFullscreen(player_id_); |
| 1465 } | 1462 } |
| 1466 | 1463 |
| 1467 bool WebMediaPlayerAndroid::canEnterFullscreen() const { | 1464 bool WebMediaPlayerAndroid::canEnterFullscreen() const { |
| 1468 return manager_->CanEnterFullscreen(frame_); | 1465 return manager_->CanEnterFullscreen(frame_); |
| 1469 } | 1466 } |
| 1470 | 1467 |
| 1471 } // namespace content | 1468 } // namespace content |
| OLD | NEW |