diff options
author | wolenetz@chromium.org <wolenetz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-12 01:09:49 +0000 |
---|---|---|
committer | wolenetz@chromium.org <wolenetz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-12 01:09:49 +0000 |
commit | 0f7a70415b0a4b8d2ff6bc958307965eca7b5667 (patch) | |
tree | 663cdabcf373ec49677a5eb2f1b3fa967d7546d3 /media/base | |
parent | 1dec3e81277da1c7d710cb54d045b70093104261 (diff) | |
download | chromium_src-0f7a70415b0a4b8d2ff6bc958307965eca7b5667.zip chromium_src-0f7a70415b0a4b8d2ff6bc958307965eca7b5667.tar.gz chromium_src-0f7a70415b0a4b8d2ff6bc958307965eca7b5667.tar.bz2 |
Implement MediaSourceDelegate::SetDuration() for android
Notify MediaPlayerClient and (Android) MediaSourcePlayer when
MediaSourceDelegate's ChunkDemuxer duration changes:
* Bind WebMediaPlayerAndroid::OnDurationChanged() to
render loop to asynchronously handle callback from
MediaSourceDelegate::SetDuration().
* Cache the updated duration in WMPA. This needs
simplification in blink so this caching doesn't break MSE
spec conformance. Prerequisite blink change:
https://codereview.chromium.org/15735030/)
* Add IPC for WebMediaPlayerAndroid to notify (Android)
MediaSourcePlayer when MediaSourceDelegate/ChunkDemuxer updates duration.
With this patch, the following MSE layout tests now pass:
webkitmediasource-duration-boundaryconditions.html
webkitmediasource-duration-changed.html
webkitmediasource-seek-to-end-after-duration-change.html
BUG=246757,233420
TEST=manual verification of MSE layout tests show no regression
R=acolwell@chromium.org,yfriedman@chromium.org,qinmin@chromium.org,wonsik@chromium.org, jschuh@chromium.org
Review URL: https://chromiumcodereview.appspot.com/16372002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@205697 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/base')
-rw-r--r-- | media/base/android/media_player_android.cc | 4 | ||||
-rw-r--r-- | media/base/android/media_player_android.h | 5 | ||||
-rw-r--r-- | media/base/android/media_source_player.cc | 22 | ||||
-rw-r--r-- | media/base/android/media_source_player.h | 7 |
4 files changed, 30 insertions, 8 deletions
diff --git a/media/base/android/media_player_android.cc b/media/base/android/media_player_android.cc index 2de4887..0eddd01 100644 --- a/media/base/android/media_player_android.cc +++ b/media/base/android/media_player_android.cc @@ -76,6 +76,10 @@ void MediaPlayerAndroid::OnSeekRequestAck(unsigned seek_request_id) { NOTREACHED() << "Unexpected ipc received"; } +void MediaPlayerAndroid::DurationChanged(const base::TimeDelta& duration) { + NOTREACHED() << "Unexpected ipc received"; +} + GURL MediaPlayerAndroid::GetUrl() { return GURL(); } diff --git a/media/base/android/media_player_android.h b/media/base/android/media_player_android.h index c5abbb9..1310fbd 100644 --- a/media/base/android/media_player_android.h +++ b/media/base/android/media_player_android.h @@ -85,7 +85,7 @@ class MEDIA_EXPORT MediaPlayerAndroid { virtual GURL GetUrl(); virtual GURL GetFirstPartyForCookies(); - // Methods for DeumxerStreamPlayer. + // Methods for DemuxerStreamPlayer. // Informs DemuxerStreamPlayer that the demuxer is ready. virtual void DemuxerReady( const MediaPlayerHostMsg_DemuxerReady_Params& params); @@ -96,6 +96,9 @@ class MEDIA_EXPORT MediaPlayerAndroid { // Called when a seek request is acked by the render process. virtual void OnSeekRequestAck(unsigned seek_request_id); + // Called when the demuxer has changed the duration. + virtual void DurationChanged(const base::TimeDelta& duration); + int player_id() { return player_id_; } protected: diff --git a/media/base/android/media_source_player.cc b/media/base/android/media_source_player.cc index f3aabe5..8cadb60 100644 --- a/media/base/android/media_source_player.cc +++ b/media/base/android/media_source_player.cc @@ -254,7 +254,6 @@ MediaSourcePlayer::MediaSourcePlayer( video_codec_(kUnknownVideoCodec), num_channels_(0), sampling_rate_(0), - seekable_(true), audio_finished_(true), video_finished_(true), playing_(false), @@ -281,6 +280,15 @@ void MediaSourcePlayer::SetVideoSurface(gfx::ScopedJavaSurface surface) { ProcessPendingEvents(); } +bool MediaSourcePlayer::Seekable() { + // If the duration TimeDelta, converted to milliseconds from microseconds, + // is >= 2^31, then the media is assumed to be unbounded and unseekable. + // 2^31 is the bound due to java player using 32-bit integer for time + // values at millisecond resolution. + return duration_ < + base::TimeDelta::FromMilliseconds(std::numeric_limits<int32>::max()); +} + void MediaSourcePlayer::Start() { playing_ = true; @@ -338,15 +346,15 @@ void MediaSourcePlayer::SetVolume(float leftVolume, float rightVolume) { } bool MediaSourcePlayer::CanPause() { - return seekable_; + return Seekable(); } bool MediaSourcePlayer::CanSeekForward() { - return seekable_; + return Seekable(); } bool MediaSourcePlayer::CanSeekBackward() { - return seekable_; + return Seekable(); } bool MediaSourcePlayer::IsPlayerReady() { @@ -376,8 +384,6 @@ void MediaSourcePlayer::StartInternal() { void MediaSourcePlayer::DemuxerReady( const MediaPlayerHostMsg_DemuxerReady_Params& params) { - if (params.duration_ms == std::numeric_limits<int>::max()) - seekable_ = false; duration_ = base::TimeDelta::FromMilliseconds(params.duration_ms); width_ = params.video_size.width(); height_ = params.video_size.height(); @@ -428,6 +434,10 @@ void MediaSourcePlayer::ReadFromDemuxerAck( } } +void MediaSourcePlayer::DurationChanged(const base::TimeDelta& duration) { + duration_ = duration; +} + void MediaSourcePlayer::OnSeekRequestAck(unsigned seek_request_id) { // Do nothing until the most recent seek request is processed. if (seek_request_id_ != seek_request_id) diff --git a/media/base/android/media_source_player.h b/media/base/android/media_source_player.h index b2d5a72..3b12dd5 100644 --- a/media/base/android/media_source_player.h +++ b/media/base/android/media_source_player.h @@ -154,6 +154,9 @@ class MEDIA_EXPORT MediaSourcePlayer : public MediaPlayerAndroid { virtual void ReadFromDemuxerAck( const MediaPlayerHostMsg_ReadFromDemuxerAck_Params& params) OVERRIDE; + // Called when the demuxer has changed the duration. + virtual void DurationChanged(const base::TimeDelta& duration) OVERRIDE; + private: // Update the timestamps for A/V sync scheduling. void UpdateTimestamps( @@ -190,6 +193,9 @@ class MEDIA_EXPORT MediaSourcePlayer : public MediaPlayerAndroid { bool HasVideo(); bool HasAudio(); + // Determine seekability based on duration. + bool Seekable(); + enum PendingEventFlags { NO_EVENT_PENDING = 0, SEEK_EVENT_PENDING = 1 << 0, @@ -213,7 +219,6 @@ class MEDIA_EXPORT MediaSourcePlayer : public MediaPlayerAndroid { VideoCodec video_codec_; int num_channels_; int sampling_rate_; - bool seekable_; base::TimeDelta last_presentation_timestamp_; std::vector<uint8> audio_extra_data_; bool audio_finished_; |