diff options
author | kjyoun@google.com <kjyoun@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-21 10:03:56 +0000 |
---|---|---|
committer | kjyoun@google.com <kjyoun@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-21 10:03:56 +0000 |
commit | 3c46ec2d5c86b0ed4b21b9c078ea834e6e7718e8 (patch) | |
tree | 7634a08f215b3a1b22b47beca8dd9a619b131518 | |
parent | 59fe2c3b8b23b8fe3631e8a53d7678d09ef2cb11 (diff) | |
download | chromium_src-3c46ec2d5c86b0ed4b21b9c078ea834e6e7718e8.zip chromium_src-3c46ec2d5c86b0ed4b21b9c078ea834e6e7718e8.tar.gz chromium_src-3c46ec2d5c86b0ed4b21b9c078ea834e6e7718e8.tar.bz2 |
Currently, NotifyDemuxerReady() is called whenever key is added,
which made problem when multiple keys are added.
This CL is to make sure NotifyDemuxerReady() once.
BUG=
Review URL: https://chromiumcodereview.appspot.com/17449020
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@207783 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | webkit/renderer/media/android/media_source_delegate.cc | 36 | ||||
-rw-r--r-- | webkit/renderer/media/android/media_source_delegate.h | 5 | ||||
-rw-r--r-- | webkit/renderer/media/android/webmediaplayer_android.cc | 2 |
3 files changed, 34 insertions, 9 deletions
diff --git a/webkit/renderer/media/android/media_source_delegate.cc b/webkit/renderer/media/android/media_source_delegate.cc index ada609c2..f428b12 100644 --- a/webkit/renderer/media/android/media_source_delegate.cc +++ b/webkit/renderer/media/android/media_source_delegate.cc @@ -69,6 +69,7 @@ MediaSourceDelegate::MediaSourceDelegate(WebMediaPlayerProxyAndroid* proxy, audio_params_(new MediaPlayerHostMsg_ReadFromDemuxerAck_Params), video_params_(new MediaPlayerHostMsg_ReadFromDemuxerAck_Params), seeking_(false), + key_added_(false), access_unit_size_(0) { } @@ -331,7 +332,8 @@ void MediaSourceDelegate::OnDemuxerInitDone( OnDemuxerError(status); return; } - NotifyDemuxerReady(""); + if (CanNotifyDemuxerReady()) + NotifyDemuxerReady(""); } void MediaSourceDelegate::OnDemuxerStopDone() { @@ -341,12 +343,34 @@ void MediaSourceDelegate::OnDemuxerStopDone() { } void MediaSourceDelegate::OnMediaConfigRequest() { - NotifyDemuxerReady(""); + if (CanNotifyDemuxerReady()) + NotifyDemuxerReady(""); } -void MediaSourceDelegate::NotifyDemuxerReady(const std::string& key_system) { - if (!demuxer_) +void MediaSourceDelegate::NotifyKeyAdded(const std::string& key_system) { + // TODO(kjyoun): Enhance logic to detect when to call NotifyDemuxerReady() + // For now, we calls it when the first key is added. + if (key_added_) return; + key_added_ = true; + if (CanNotifyDemuxerReady()) + NotifyDemuxerReady(key_system); +} + +bool MediaSourceDelegate::CanNotifyDemuxerReady() { + if (key_added_) + return true; + DemuxerStream* audio_stream = demuxer_->GetStream(DemuxerStream::AUDIO); + if (audio_stream && audio_stream->audio_decoder_config().is_encrypted()) + return false; + DemuxerStream* video_stream = demuxer_->GetStream(DemuxerStream::VIDEO); + if (video_stream && video_stream->video_decoder_config().is_encrypted()) + return false; + return true; +} + +void MediaSourceDelegate::NotifyDemuxerReady(const std::string& key_system) { + DCHECK(demuxer_); MediaPlayerHostMsg_DemuxerReady_Params params; DemuxerStream* audio_stream = demuxer_->GetStream(DemuxerStream::AUDIO); if (audio_stream) { @@ -373,9 +397,7 @@ void MediaSourceDelegate::NotifyDemuxerReady(const std::string& key_system) { params.duration_ms = GetDurationMs(); params.key_system = key_system; - bool ready_to_send = (!params.is_audio_encrypted && - !params.is_video_encrypted) || !key_system.empty(); - if (proxy_ && ready_to_send) + if (proxy_) proxy_->DemuxerReady(player_id_, params); } diff --git a/webkit/renderer/media/android/media_source_delegate.h b/webkit/renderer/media/android/media_source_delegate.h index dfe717f..cc71521 100644 --- a/webkit/renderer/media/android/media_source_delegate.h +++ b/webkit/renderer/media/android/media_source_delegate.h @@ -72,7 +72,7 @@ class MediaSourceDelegate : public media::DemuxerHost { void CancelPendingSeek(); - void NotifyDemuxerReady(const std::string& key_system); + void NotifyKeyAdded(const std::string& key_system); // Called when DemuxerStreamPlayer needs to read data from ChunkDemuxer. // If it's the first request after the seek, |seek_done| will be true. @@ -107,6 +107,8 @@ class MediaSourceDelegate : public media::DemuxerHost { scoped_ptr<media::TextTrack> OnAddTextTrack(media::TextKind kind, const std::string& label, const std::string& language); + void NotifyDemuxerReady(const std::string& key_system); + bool CanNotifyDemuxerReady(); // Reads an access unit from the demuxer stream |stream| and stores it in // the |index|th access unit in |params|. @@ -156,6 +158,7 @@ class MediaSourceDelegate : public media::DemuxerHost { scoped_ptr<media::MediaPlayerHostMsg_ReadFromDemuxerAck_Params> video_params_; bool seeking_; + bool key_added_; size_t access_unit_size_; DISALLOW_COPY_AND_ASSIGN(MediaSourceDelegate); diff --git a/webkit/renderer/media/android/webmediaplayer_android.cc b/webkit/renderer/media/android/webmediaplayer_android.cc index b37ee7c..31e9fa4 100644 --- a/webkit/renderer/media/android/webmediaplayer_android.cc +++ b/webkit/renderer/media/android/webmediaplayer_android.cc @@ -1020,7 +1020,7 @@ void WebMediaPlayerAndroid::OnKeyAdded(const std::string& session_id) { EmeUMAHistogramCounts(current_key_system_.utf8(), "KeyAdded", 1); if (media_source_delegate_) - media_source_delegate_->NotifyDemuxerReady(current_key_system_.utf8()); + media_source_delegate_->NotifyKeyAdded(current_key_system_.utf8()); client_->keyAdded(current_key_system_, WebString::fromUTF8(session_id)); } |