Chromium Code Reviews| Index: webkit/glue/webmediaplayer_impl.cc |
| diff --git a/webkit/glue/webmediaplayer_impl.cc b/webkit/glue/webmediaplayer_impl.cc |
| index a4c7f06daecbb6179bd2bc085105131844e993dc..d70355313433badc4fb987a34ca8837e9d3d14b0 100644 |
| --- a/webkit/glue/webmediaplayer_impl.cc |
| +++ b/webkit/glue/webmediaplayer_impl.cc |
| @@ -340,6 +340,11 @@ bool WebMediaPlayerImpl::Initialize( |
| data_source_factory->AddFactory(simple_data_source_factory.release()); |
| } |
| + if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableAdaptive)) { |
| + chunk_demuxer_factory_.reset(new media::ChunkDemuxerFactory( |
| + data_source_factory->Clone())); |
| + } |
| + |
| scoped_ptr<media::DemuxerFactory> demuxer_factory( |
| new media::FFmpegDemuxerFactory(data_source_factory.release(), |
| pipeline_message_loop)); |
| @@ -384,6 +389,12 @@ void WebMediaPlayerImpl::load(const WebKit::WebURL& url) { |
| filter_collection_->AddVideoDecoder(rtc_video_decoder); |
| } |
| + if (chunk_demuxer_factory_.get() && |
| + chunk_demuxer_factory_->IsUrlSupported(url.spec())) { |
| + media_data_sink_.reset(chunk_demuxer_factory_->CreateMediaDataSink()); |
|
scherkus (not reviewing)
2011/06/22 17:31:09
what if chunk_demuxer_factory_ passed a ref to a m
acolwell GONE FROM CHROMIUM
2011/06/23 16:51:29
No can do. WebMediaPlayerImpl needs to be able to
|
| + filter_collection_->SetDemuxerFactory(chunk_demuxer_factory_.release()); |
| + } |
| + |
| // Handle any volume changes that occured before load(). |
| setVolume(GetClient()->volume()); |
| // Get the preload value. |
| @@ -418,6 +429,15 @@ void WebMediaPlayerImpl::pause() { |
| paused_time_ = pipeline_->GetCurrentTime(); |
| } |
| +bool WebMediaPlayerImpl::addData(const unsigned char* data, unsigned length) { |
| + DCHECK(MessageLoop::current() == main_loop_); |
| + |
| + if (!media_data_sink_.get()) |
| + return false; |
| + |
| + return media_data_sink_->AddData(data, length); |
| +} |
| + |
| bool WebMediaPlayerImpl::supportsFullscreen() const { |
| DCHECK(MessageLoop::current() == main_loop_); |
| return true; |
| @@ -452,6 +472,9 @@ void WebMediaPlayerImpl::seek(float seconds) { |
| seeking_ = true; |
| + if (media_data_sink_.get()) |
| + media_data_sink_->Flush(); |
| + |
| // Kick off the asynchronous seek! |
| pipeline_->Seek( |
| seek_time, |
| @@ -562,16 +585,23 @@ float WebMediaPlayerImpl::duration() const { |
| base::TimeDelta duration = pipeline_->GetMediaDuration(); |
| if (duration.InMicroseconds() == media::Limits::kMaxTimeInMicroseconds) |
| return std::numeric_limits<float>::infinity(); |
| - return static_cast<float>(duration.InSecondsF()); |
| + float ret = static_cast<float>(duration.InSecondsF()); |
| + |
| + //LOG(ERROR) << "duration() : " << ret; |
|
scherkus (not reviewing)
2011/06/22 17:31:09
?
acolwell GONE FROM CHROMIUM
2011/06/23 16:51:29
reverted
|
| + |
| + return ret; |
| } |
| float WebMediaPlayerImpl::currentTime() const { |
| DCHECK(MessageLoop::current() == main_loop_); |
| - |
| + float ret = -1; |
| if (paused_) { |
| - return static_cast<float>(paused_time_.InSecondsF()); |
| + ret = static_cast<float>(paused_time_.InSecondsF()); |
|
scherkus (not reviewing)
2011/06/22 17:31:09
revert the changes here?
acolwell GONE FROM CHROMIUM
2011/06/23 16:51:29
Done.
|
| + } else { |
| + ret = static_cast<float>(pipeline_->GetCurrentTime().InSecondsF()); |
| } |
| - return static_cast<float>(pipeline_->GetCurrentTime().InSecondsF()); |
| + //LOG(ERROR) << "currentTime() : " << ret; |
|
scherkus (not reviewing)
2011/06/22 17:31:09
?
acolwell GONE FROM CHROMIUM
2011/06/23 16:51:29
reverted
|
| + return ret; |
| } |
| int WebMediaPlayerImpl::dataRate() const { |
| @@ -598,6 +628,9 @@ const WebKit::WebTimeRanges& WebMediaPlayerImpl::buffered() { |
| pipeline_->GetBufferedTime().InSecondsF()); |
| if (buffered_time >= buffered_[0].start) |
| buffered_[0].end = buffered_time; |
| + |
| + //LOG(ERROR) << "buffered() : " << buffered_[0].start |
| + // << " - " << buffered_[0].end; |
|
scherkus (not reviewing)
2011/06/22 17:31:09
?
acolwell GONE FROM CHROMIUM
2011/06/23 16:51:29
reverted
|
| } |
| return buffered_; |
| @@ -612,7 +645,10 @@ float WebMediaPlayerImpl::maxTimeSeekable() const { |
| // TODO(hclam): We need to update this when we have better caching. |
| if (pipeline_->IsStreaming()) |
| return 0.0f; |
| - return static_cast<float>(pipeline_->GetMediaDuration().InSecondsF()); |
| + float ret = static_cast<float>(pipeline_->GetMediaDuration().InSecondsF()); |
| + |
| + LOG(ERROR) << "maxTimeSeekable() : " << ret; |
|
acolwell GONE FROM CHROMIUM
2011/06/23 16:51:29
reverted
|
| + return ret; |
| } |
| unsigned long long WebMediaPlayerImpl::bytesLoaded() const { |
| @@ -908,6 +944,9 @@ void WebMediaPlayerImpl::Destroy() { |
| if (proxy_) |
| proxy_->AbortDataSources(); |
| + if (media_data_sink_.get()) |
| + media_data_sink_->Shutdown(); |
| + |
| // Make sure to kill the pipeline so there's no more media threads running. |
| // Note: stopping the pipeline might block for a long time. |
| if (pipeline_) { |