diff options
author | wjia@chromium.org <wjia@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-20 19:57:40 +0000 |
---|---|---|
committer | wjia@chromium.org <wjia@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-20 19:57:40 +0000 |
commit | ab2c4737d17cc4ce21e16e5382f19ce7aac8d7d7 (patch) | |
tree | aa8b742f1721b64c1ccc9486616bf05b5640de9d /webkit | |
parent | 13a8f498151ac4e1e771cb3d70d56f38848be04a (diff) | |
download | chromium_src-ab2c4737d17cc4ce21e16e5382f19ce7aac8d7d7.zip chromium_src-ab2c4737d17cc4ce21e16e5382f19ce7aac8d7d7.tar.gz chromium_src-ab2c4737d17cc4ce21e16e5382f19ce7aac8d7d7.tar.bz2 |
reland patch http://codereview.chromium.org/7204008 after webrtc build has been fixed.
BUG=none
TEST=try bots
Review URL: http://codereview.chromium.org/7458006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@93235 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/glue/media/media_stream_client.h | 33 | ||||
-rw-r--r-- | webkit/glue/webmediaplayer_impl.cc | 18 | ||||
-rw-r--r-- | webkit/glue/webmediaplayer_impl.h | 6 | ||||
-rw-r--r-- | webkit/support/webkit_support.cc | 3 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_webview_delegate.cc | 3 |
5 files changed, 58 insertions, 5 deletions
diff --git a/webkit/glue/media/media_stream_client.h b/webkit/glue/media/media_stream_client.h new file mode 100644 index 0000000..2f51d91 --- /dev/null +++ b/webkit/glue/media/media_stream_client.h @@ -0,0 +1,33 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef WEBKIT_GLUE_MEDIA_MEDIA_STREAM_CLIENT_H_ +#define WEBKIT_GLUE_MEDIA_MEDIA_STREAM_CLIENT_H_ + +#include "base/memory/ref_counted.h" + +class GURL; + +namespace media { +class VideoDecoder; +class MessageLoopFactory; +} + +namespace webkit_glue { + +// Define an interface for media stream client to get some information about +// the media stream. +class MediaStreamClient { + public: + virtual scoped_refptr<media::VideoDecoder> GetVideoDecoder( + const GURL& url, + media::MessageLoopFactory* message_loop_factory) = 0; + + protected: + virtual ~MediaStreamClient() {} +}; + +} // namespace webkit_glue + +#endif // WEBKIT_GLUE_MEDIA_MEDIA_STREAM_CLIENT_H_ diff --git a/webkit/glue/webmediaplayer_impl.cc b/webkit/glue/webmediaplayer_impl.cc index acc44bc..102116e 100644 --- a/webkit/glue/webmediaplayer_impl.cc +++ b/webkit/glue/webmediaplayer_impl.cc @@ -27,6 +27,7 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/WebVideoFrame.h" #include "webkit/glue/media/buffered_data_source.h" #include "webkit/glue/media/simple_data_source.h" +#include "webkit/glue/media/media_stream_client.h" #include "webkit/glue/media/video_renderer_impl.h" #include "webkit/glue/media/web_video_renderer.h" #include "webkit/glue/webvideoframe_impl.h" @@ -271,7 +272,8 @@ void WebMediaPlayerImpl::Proxy::PutCurrentFrame( WebMediaPlayerImpl::WebMediaPlayerImpl( WebKit::WebMediaPlayerClient* client, media::FilterCollection* collection, - media::MessageLoopFactory* message_loop_factory) + media::MessageLoopFactory* message_loop_factory, + MediaStreamClient* media_stream_client) : network_state_(WebKit::WebMediaPlayer::Empty), ready_state_(WebKit::WebMediaPlayer::HaveNothing), main_loop_(NULL), @@ -282,7 +284,8 @@ WebMediaPlayerImpl::WebMediaPlayerImpl( seeking_(false), playback_rate_(0.0f), client_(client), - proxy_(NULL) { + proxy_(NULL), + media_stream_client_(media_stream_client) { // Saves the current message loop. DCHECK(!main_loop_); main_loop_ = MessageLoop::current(); @@ -377,6 +380,17 @@ void WebMediaPlayerImpl::load(const WebKit::WebURL& url) { DCHECK(MessageLoop::current() == main_loop_); DCHECK(proxy_); + if (media_stream_client_) { + scoped_refptr<media::VideoDecoder> new_decoder = + media_stream_client_->GetVideoDecoder(url, message_loop_factory_.get()); + if (new_decoder.get()) { + // Remove the default decoder. + scoped_refptr<media::VideoDecoder> old_videodecoder; + filter_collection_->SelectVideoDecoder(&old_videodecoder); + filter_collection_->AddVideoDecoder(new_decoder.get()); + } + } + if (chunk_demuxer_factory_.get() && chunk_demuxer_factory_->IsUrlSupported(url.spec())) { media_data_sink_.reset(chunk_demuxer_factory_->CreateMediaDataSink()); diff --git a/webkit/glue/webmediaplayer_impl.h b/webkit/glue/webmediaplayer_impl.h index 53cac08..49ede0d 100644 --- a/webkit/glue/webmediaplayer_impl.h +++ b/webkit/glue/webmediaplayer_impl.h @@ -79,6 +79,7 @@ class WebFrame; namespace webkit_glue { class MediaResourceLoaderBridgeFactory; +class MediaStreamClient; class WebVideoRenderer; class WebMediaPlayerImpl : public WebKit::WebMediaPlayer, @@ -187,7 +188,8 @@ class WebMediaPlayerImpl : public WebKit::WebMediaPlayer, // Callers must call |Initialize()| before they can use the object. WebMediaPlayerImpl(WebKit::WebMediaPlayerClient* client, media::FilterCollection* collection, - media::MessageLoopFactory* message_loop_factory); + media::MessageLoopFactory* message_loop_factory, + MediaStreamClient* media_stream_client); virtual ~WebMediaPlayerImpl(); // Finalizes initialization of the object. @@ -331,6 +333,8 @@ class WebMediaPlayerImpl : public WebKit::WebMediaPlayer, scoped_ptr<media::ChunkDemuxerFactory> chunk_demuxer_factory_; scoped_ptr<media::MediaDataSink> media_data_sink_; + MediaStreamClient* media_stream_client_; + #if WEBKIT_USING_CG scoped_ptr<skia::PlatformCanvas> skia_canvas_; #endif diff --git a/webkit/support/webkit_support.cc b/webkit/support/webkit_support.cc index fd84ee6..18d5c8a 100644 --- a/webkit/support/webkit_support.cc +++ b/webkit/support/webkit_support.cc @@ -303,7 +303,8 @@ WebKit::WebMediaPlayer* CreateMediaPlayer(WebFrame* frame, scoped_ptr<webkit_glue::WebMediaPlayerImpl> result( new webkit_glue::WebMediaPlayerImpl(client, collection.release(), - message_loop_factory.release())); + message_loop_factory.release(), + NULL)); if (!result->Initialize(frame, false, video_renderer)) { return NULL; } diff --git a/webkit/tools/test_shell/test_webview_delegate.cc b/webkit/tools/test_shell/test_webview_delegate.cc index 9c6e2b7..61cc860 100644 --- a/webkit/tools/test_shell/test_webview_delegate.cc +++ b/webkit/tools/test_shell/test_webview_delegate.cc @@ -623,7 +623,8 @@ WebMediaPlayer* TestWebViewDelegate::createMediaPlayer( scoped_ptr<webkit_glue::WebMediaPlayerImpl> result( new webkit_glue::WebMediaPlayerImpl(client, collection.release(), - message_loop_factory.release())); + message_loop_factory.release(), + NULL)); if (!result->Initialize(frame, false, video_renderer)) { return NULL; } |