Chromium Code Reviews| Index: webkit/media/webmediaplayer_impl.cc |
| diff --git a/webkit/media/webmediaplayer_impl.cc b/webkit/media/webmediaplayer_impl.cc |
| index 11df8bcce468a5d0785857b07d984e36fd41c99c..099f08f7ec56a581c2b978839737546f0b57031c 100644 |
| --- a/webkit/media/webmediaplayer_impl.cc |
| +++ b/webkit/media/webmediaplayer_impl.cc |
| @@ -24,6 +24,7 @@ |
| #include "media/base/pipeline.h" |
| #include "media/base/video_frame.h" |
| #include "media/filters/audio_renderer_impl.h" |
| +#include "media/filters/chunk_demuxer.h" |
| #include "media/filters/video_renderer_base.h" |
| #include "third_party/WebKit/Source/WebKit/chromium/public/WebVideoFrame.h" |
| #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
| @@ -105,6 +106,20 @@ static WebKit::WebTimeRanges ConvertToWebTimeRanges( |
| return result; |
| } |
| +typedef base::Callback<void(const std::string&, |
| + const std::string&, |
|
Ami GONE FROM CHROMIUM
2012/09/12 18:45:34
what's with these std::strings??
acolwell GONE FROM CHROMIUM
2012/09/12 22:03:53
These are for the key_system and session_id. I'm n
Ami GONE FROM CHROMIUM
2012/09/12 22:29:03
Feel like adding a TODO to figure out whether thes
acolwell GONE FROM CHROMIUM
2012/09/13 00:16:23
Done.
|
| + scoped_array<uint8>, |
| + int)> OnNeedKeyCB; |
| + |
| +static void OnDemuxerNeedKeyTrampoline( |
| + const scoped_refptr<base::MessageLoopProxy>& message_loop, |
| + const OnNeedKeyCB& need_key_cb, |
| + scoped_array<uint8> init_data, |
| + int init_data_size) { |
| + message_loop->PostTask(FROM_HERE, base::Bind( |
| + need_key_cb, "", "", base::Passed(&init_data), init_data_size)); |
| +} |
| + |
| WebMediaPlayerImpl::WebMediaPlayerImpl( |
| WebKit::WebFrame* frame, |
| WebKit::WebMediaPlayerClient* client, |
| @@ -249,10 +264,17 @@ void WebMediaPlayerImpl::load(const WebKit::WebURL& url, CORSMode cors_mode) { |
| } |
| // Media source pipelines can start immediately. |
| - if (BuildMediaSourceCollection(url, GetClient()->sourceURL(), proxy_, |
| - message_loop_factory_.get(), |
| - filter_collection_.get(), |
| - &decryptor_)) { |
| + if (!url.isEmpty() && url == GetClient()->sourceURL()) { |
| + chunk_demuxer_ = new media::ChunkDemuxer( |
| + BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnDemuxerOpened), |
| + base::Bind(&OnDemuxerNeedKeyTrampoline, |
|
Ami GONE FROM CHROMIUM
2012/09/12 18:45:34
why not BIND_TO_RENDER_LOOP for this as well?
acolwell GONE FROM CHROMIUM
2012/09/12 22:03:53
BindToLoop doesn't like the scoped_array<> in the
Ami GONE FROM CHROMIUM
2012/09/12 22:29:03
This isn't an array, it's a scoped_array.
I'm surp
acolwell GONE FROM CHROMIUM
2012/09/13 00:16:23
I was too. I'll left it as is for now and will cha
|
| + main_loop_->message_loop_proxy(), |
| + base::Bind(&WebMediaPlayerImpl::OnNeedKey, AsWeakPtr()))); |
| + |
| + BuildMediaSourceCollection(chunk_demuxer_, |
| + message_loop_factory_.get(), |
| + filter_collection_.get(), |
| + &decryptor_); |
| supports_save_ = false; |
| StartPipeline(); |
| return; |
| @@ -322,7 +344,8 @@ void WebMediaPlayerImpl::seek(float seconds) { |
| if (starting_ || seeking_) { |
| pending_seek_ = true; |
| pending_seek_seconds_ = seconds; |
| - proxy_->DemuxerCancelPendingSeek(); |
| + if (chunk_demuxer_) |
| + chunk_demuxer_->CancelPendingSeek(); |
| return; |
| } |
| @@ -336,7 +359,8 @@ void WebMediaPlayerImpl::seek(float seconds) { |
| seeking_ = true; |
| - proxy_->DemuxerStartWaitingForSeek(); |
| + if (chunk_demuxer_) |
| + chunk_demuxer_->StartWaitingForSeek(); |
| // Kick off the asynchronous seek! |
| pipeline_->Seek( |
| @@ -630,19 +654,19 @@ WebKit::WebMediaPlayer::AddIdStatus WebMediaPlayerImpl::sourceAddId( |
| new_codecs[i] = codecs[i].utf8().data(); |
| return static_cast<WebKit::WebMediaPlayer::AddIdStatus>( |
| - proxy_->DemuxerAddId(id.utf8().data(), type.utf8().data(), |
| - new_codecs)); |
| + chunk_demuxer_->AddId(id.utf8().data(), type.utf8().data(), new_codecs)); |
| } |
| bool WebMediaPlayerImpl::sourceRemoveId(const WebKit::WebString& id) { |
| DCHECK(!id.isEmpty()); |
| - proxy_->DemuxerRemoveId(id.utf8().data()); |
| + chunk_demuxer_->RemoveId(id.utf8().data()); |
| return true; |
| } |
| WebKit::WebTimeRanges WebMediaPlayerImpl::sourceBuffered( |
| const WebKit::WebString& id) { |
| - return ConvertToWebTimeRanges(proxy_->DemuxerBufferedRange(id.utf8().data())); |
| + return ConvertToWebTimeRanges( |
| + chunk_demuxer_->GetBufferedRanges(id.utf8().data())); |
| } |
| bool WebMediaPlayerImpl::sourceAppend(const WebKit::WebString& id, |
| @@ -651,7 +675,7 @@ bool WebMediaPlayerImpl::sourceAppend(const WebKit::WebString& id, |
| DCHECK_EQ(main_loop_, MessageLoop::current()); |
| float old_duration = duration(); |
| - if (!proxy_->DemuxerAppend(id.utf8().data(), data, length)) |
| + if (!chunk_demuxer_->AppendData(id.utf8().data(), data, length)) |
| return false; |
| if (old_duration != duration()) |
| @@ -661,7 +685,7 @@ bool WebMediaPlayerImpl::sourceAppend(const WebKit::WebString& id, |
| } |
| bool WebMediaPlayerImpl::sourceAbort(const WebKit::WebString& id) { |
| - proxy_->DemuxerAbort(id.utf8().data()); |
| + chunk_demuxer_->Abort(id.utf8().data()); |
| return true; |
| } |
| @@ -669,7 +693,7 @@ void WebMediaPlayerImpl::sourceSetDuration(double new_duration) { |
| if (static_cast<double>(duration()) == new_duration) |
| return; |
| - proxy_->DemuxerSetDuration( |
| + chunk_demuxer_->SetDuration( |
| base::TimeDelta::FromMicroseconds( |
| new_duration * base::Time::kMicrosecondsPerSecond)); |
| GetClient()->durationChanged(); |
| @@ -694,7 +718,7 @@ void WebMediaPlayerImpl::sourceEndOfStream( |
| } |
| float old_duration = duration(); |
| - proxy_->DemuxerEndOfStream(pipeline_status); |
| + chunk_demuxer_->EndOfStream(pipeline_status); |
| if (old_duration != duration()) |
| GetClient()->durationChanged(); |
| @@ -704,7 +728,7 @@ bool WebMediaPlayerImpl::sourceSetTimestampOffset(const WebKit::WebString& id, |
| double offset) { |
| base::TimeDelta time_offset = base::TimeDelta::FromMicroseconds( |
| offset * base::Time::kMicrosecondsPerSecond); |
| - return proxy_->DemuxerSetTimestampOffset(id.utf8().data(), time_offset); |
| + return chunk_demuxer_->SetTimestampOffset(id.utf8().data(), time_offset); |
| } |
| WebKit::WebMediaPlayer::MediaKeyException |
| @@ -891,7 +915,6 @@ void WebMediaPlayerImpl::OnPipelineBufferingState( |
| void WebMediaPlayerImpl::OnDemuxerOpened() { |
| DCHECK_EQ(main_loop_, MessageLoop::current()); |
| - |
| GetClient()->sourceOpened(); |
| } |
| @@ -1027,7 +1050,10 @@ void WebMediaPlayerImpl::Destroy() { |
| // not blocked when issuing stop commands to the other filters. |
| if (proxy_) { |
| proxy_->AbortDataSource(); |
| - proxy_->DemuxerShutdown(); |
| + if (chunk_demuxer_) { |
| + chunk_demuxer_->Shutdown(); |
| + chunk_demuxer_ = NULL; |
| + } |
| } |
| // Make sure to kill the pipeline so there's no more media threads running. |