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 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 379 pending_seek_ = true; | 379 pending_seek_ = true; |
| 380 pending_seek_time_ = new_seek_time; | 380 pending_seek_time_ = new_seek_time; |
| 381 | 381 |
| 382 if (media_source_delegate_) | 382 if (media_source_delegate_) |
| 383 media_source_delegate_->CancelPendingSeek(pending_seek_time_); | 383 media_source_delegate_->CancelPendingSeek(pending_seek_time_); |
| 384 | 384 |
| 385 // Later, OnSeekComplete will trigger the pending seek. | 385 // Later, OnSeekComplete will trigger the pending seek. |
| 386 return; | 386 return; |
| 387 } | 387 } |
| 388 | 388 |
| 389 if (new_seek_time >= | |
|
acolwell GONE FROM CHROMIUM
2014/01/13 16:32:07
This should not be needed if maxTimeSeekable() nev
amogh.bihani
2014/01/14 08:03:09
Done.
| |
| 390 base::TimeDelta::FromMilliseconds(std::numeric_limits<int32>max())) { | |
| 391 return; | |
| 392 } | |
| 393 | |
| 389 seeking_ = true; | 394 seeking_ = true; |
| 390 seek_time_ = new_seek_time; | 395 seek_time_ = new_seek_time; |
| 391 | 396 |
| 392 if (media_source_delegate_) | 397 if (media_source_delegate_) |
| 393 media_source_delegate_->StartWaitingForSeek(seek_time_); | 398 media_source_delegate_->StartWaitingForSeek(seek_time_); |
| 394 | 399 |
| 395 // Kick off the asynchronous seek! | 400 // Kick off the asynchronous seek! |
| 396 manager_->Seek(player_id_, seek_time_); | 401 manager_->Seek(player_id_, seek_time_); |
| 397 } | 402 } |
| 398 | 403 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 495 return media_source_delegate_->Buffered(); | 500 return media_source_delegate_->Buffered(); |
| 496 return buffered_; | 501 return buffered_; |
| 497 } | 502 } |
| 498 | 503 |
| 499 double WebMediaPlayerAndroid::maxTimeSeekable() const { | 504 double WebMediaPlayerAndroid::maxTimeSeekable() const { |
| 500 // If we haven't even gotten to ReadyStateHaveMetadata yet then just | 505 // If we haven't even gotten to ReadyStateHaveMetadata yet then just |
| 501 // return 0 so that the seekable range is empty. | 506 // return 0 so that the seekable range is empty. |
| 502 if (ready_state_ < WebMediaPlayer::ReadyStateHaveMetadata) | 507 if (ready_state_ < WebMediaPlayer::ReadyStateHaveMetadata) |
| 503 return 0.0; | 508 return 0.0; |
| 504 | 509 |
| 505 // TODO(hclam): If this stream is not seekable this should return 0. | |
|
amogh.bihani
2014/01/13 11:43:14
This is handled in this patch automatically
| |
| 506 return duration(); | 510 return duration(); |
|
acolwell GONE FROM CHROMIUM
2014/01/13 16:32:07
This does not see right to me. I believe this shou
amogh.bihani
2014/01/14 08:03:09
Done.
| |
| 507 } | 511 } |
| 508 | 512 |
| 509 bool WebMediaPlayerAndroid::didLoadingProgress() const { | 513 bool WebMediaPlayerAndroid::didLoadingProgress() const { |
| 510 bool ret = did_loading_progress_; | 514 bool ret = did_loading_progress_; |
| 511 did_loading_progress_ = false; | 515 did_loading_progress_ = false; |
| 512 return ret; | 516 return ret; |
| 513 } | 517 } |
| 514 | 518 |
| 515 void WebMediaPlayerAndroid::paint(blink::WebCanvas* canvas, | 519 void WebMediaPlayerAndroid::paint(blink::WebCanvas* canvas, |
| 516 const blink::WebRect& rect, | 520 const blink::WebRect& rect, |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 612 | 616 |
| 613 void WebMediaPlayerAndroid::OnMediaMetadataChanged( | 617 void WebMediaPlayerAndroid::OnMediaMetadataChanged( |
| 614 const base::TimeDelta& duration, int width, int height, bool success) { | 618 const base::TimeDelta& duration, int width, int height, bool success) { |
| 615 bool need_to_signal_duration_changed = false; | 619 bool need_to_signal_duration_changed = false; |
| 616 | 620 |
| 617 if (url_.SchemeIs("file")) | 621 if (url_.SchemeIs("file")) |
| 618 UpdateNetworkState(WebMediaPlayer::NetworkStateLoaded); | 622 UpdateNetworkState(WebMediaPlayer::NetworkStateLoaded); |
| 619 | 623 |
| 620 // Update duration, if necessary, prior to ready state updates that may | 624 // Update duration, if necessary, prior to ready state updates that may |
| 621 // cause duration() query. | 625 // cause duration() query. |
| 622 // TODO(wolenetz): Correctly handle durations that MediaSourcePlayer | 626 |
| 623 // considers unseekable, including kInfiniteDuration(). | 627 // MediaSourcePlayer assumes duration more than 2^31 as unseekable |
|
amogh.bihani
2014/01/13 11:43:14
kInfiniteDuration is 2^63, so this is automaticall
| |
| 624 // See http://crbug.com/248396 | 628 // because java player uses 32-bit integer for time at millisecond resolution |
| 629 if (duration >= | |
|
acolwell GONE FROM CHROMIUM
2014/01/13 16:32:07
This does not seem right. The clip duration and th
amogh.bihani
2014/01/14 08:03:09
Done.
| |
| 630 base::TimeDelta::FromMilliseconds(std::numeric_limits<int32>max())) { | |
| 631 return; | |
| 632 } | |
| 633 | |
| 625 if (!ignore_metadata_duration_change_ && duration_ != duration) { | 634 if (!ignore_metadata_duration_change_ && duration_ != duration) { |
| 626 duration_ = duration; | 635 duration_ = duration; |
| 627 | 636 |
| 628 // Client readyState transition from HAVE_NOTHING to HAVE_METADATA | 637 // Client readyState transition from HAVE_NOTHING to HAVE_METADATA |
| 629 // already triggers a durationchanged event. If this is a different | 638 // already triggers a durationchanged event. If this is a different |
| 630 // transition, remember to signal durationchanged. | 639 // transition, remember to signal durationchanged. |
| 631 // Do not ever signal durationchanged on metadata change in MSE case | 640 // Do not ever signal durationchanged on metadata change in MSE case |
| 632 // because OnDurationChanged() handles this. | 641 // because OnDurationChanged() handles this. |
| 633 if (ready_state_ > WebMediaPlayer::ReadyStateHaveNothing && | 642 if (ready_state_ > WebMediaPlayer::ReadyStateHaveNothing && |
| 634 player_type_ != MEDIA_PLAYER_TYPE_MEDIA_SOURCE) { | 643 player_type_ != MEDIA_PLAYER_TYPE_MEDIA_SOURCE) { |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 821 | 830 |
| 822 void WebMediaPlayerAndroid::OnRequestFullscreen() { | 831 void WebMediaPlayerAndroid::OnRequestFullscreen() { |
| 823 client_->requestFullscreen(); | 832 client_->requestFullscreen(); |
| 824 } | 833 } |
| 825 | 834 |
| 826 void WebMediaPlayerAndroid::OnDurationChanged(const base::TimeDelta& duration) { | 835 void WebMediaPlayerAndroid::OnDurationChanged(const base::TimeDelta& duration) { |
| 827 DCHECK(main_loop_->BelongsToCurrentThread()); | 836 DCHECK(main_loop_->BelongsToCurrentThread()); |
| 828 // Only MSE |player_type_| registers this callback. | 837 // Only MSE |player_type_| registers this callback. |
| 829 DCHECK_EQ(player_type_, MEDIA_PLAYER_TYPE_MEDIA_SOURCE); | 838 DCHECK_EQ(player_type_, MEDIA_PLAYER_TYPE_MEDIA_SOURCE); |
| 830 | 839 |
| 840 // MediaSourcePlayer assumes duration more than 2^31 as unseekable | |
| 841 // because java player uses 32-bit integer for time at millisecond resolution | |
| 842 if (duration >= | |
| 843 base::TimeDelta::FromMilliseconds(std::numeric_limits<int32>max())) { | |
| 844 return; | |
| 845 } | |
| 846 | |
| 831 // Cache the new duration value and trust it over any subsequent duration | 847 // Cache the new duration value and trust it over any subsequent duration |
| 832 // values received in OnMediaMetadataChanged(). | 848 // 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; | 849 duration_ = duration; |
| 837 ignore_metadata_duration_change_ = true; | 850 ignore_metadata_duration_change_ = true; |
| 838 | 851 |
| 839 // Notify MediaPlayerClient that duration has changed, if > HAVE_NOTHING. | 852 // Notify MediaPlayerClient that duration has changed, if > HAVE_NOTHING. |
| 840 if (ready_state_ > WebMediaPlayer::ReadyStateHaveNothing) | 853 if (ready_state_ > WebMediaPlayer::ReadyStateHaveNothing) |
| 841 client_->durationChanged(); | 854 client_->durationChanged(); |
| 842 } | 855 } |
| 843 | 856 |
| 844 void WebMediaPlayerAndroid::UpdateNetworkState( | 857 void WebMediaPlayerAndroid::UpdateNetworkState( |
| 845 WebMediaPlayer::NetworkState state) { | 858 WebMediaPlayer::NetworkState state) { |
| (...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1462 | 1475 |
| 1463 void WebMediaPlayerAndroid::exitFullscreen() { | 1476 void WebMediaPlayerAndroid::exitFullscreen() { |
| 1464 manager_->ExitFullscreen(player_id_); | 1477 manager_->ExitFullscreen(player_id_); |
| 1465 } | 1478 } |
| 1466 | 1479 |
| 1467 bool WebMediaPlayerAndroid::canEnterFullscreen() const { | 1480 bool WebMediaPlayerAndroid::canEnterFullscreen() const { |
| 1468 return manager_->CanEnterFullscreen(frame_); | 1481 return manager_->CanEnterFullscreen(frame_); |
| 1469 } | 1482 } |
| 1470 | 1483 |
| 1471 } // namespace content | 1484 } // namespace content |
| OLD | NEW |