Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(297)

Side by Side Diff: content/renderer/render_frame_impl.cc

Issue 1133033003: Eliminate MediaPlayer & MediaPlayerClient abstractions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed review comments Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/renderer/render_frame_impl.h ('k') | media/blink/encrypted_media_player_support.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/render_frame_impl.h" 5 #include "content/renderer/render_frame_impl.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 #include "media/base/audio_renderer_mixer_input.h" 109 #include "media/base/audio_renderer_mixer_input.h"
110 #include "media/base/media_log.h" 110 #include "media/base/media_log.h"
111 #include "media/blink/webencryptedmediaclient_impl.h" 111 #include "media/blink/webencryptedmediaclient_impl.h"
112 #include "media/blink/webmediaplayer_impl.h" 112 #include "media/blink/webmediaplayer_impl.h"
113 #include "media/blink/webmediaplayer_params.h" 113 #include "media/blink/webmediaplayer_params.h"
114 #include "media/renderers/gpu_video_accelerator_factories.h" 114 #include "media/renderers/gpu_video_accelerator_factories.h"
115 #include "net/base/data_url.h" 115 #include "net/base/data_url.h"
116 #include "net/base/net_errors.h" 116 #include "net/base/net_errors.h"
117 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" 117 #include "net/base/registry_controlled_domains/registry_controlled_domain.h"
118 #include "net/http/http_util.h" 118 #include "net/http/http_util.h"
119 #include "third_party/WebKit/public/platform/WebMediaPlayerClient.h"
119 #include "third_party/WebKit/public/platform/WebStorageQuotaCallbacks.h" 120 #include "third_party/WebKit/public/platform/WebStorageQuotaCallbacks.h"
120 #include "third_party/WebKit/public/platform/WebString.h" 121 #include "third_party/WebKit/public/platform/WebString.h"
121 #include "third_party/WebKit/public/platform/WebURL.h" 122 #include "third_party/WebKit/public/platform/WebURL.h"
122 #include "third_party/WebKit/public/platform/WebURLError.h" 123 #include "third_party/WebKit/public/platform/WebURLError.h"
123 #include "third_party/WebKit/public/platform/WebURLResponse.h" 124 #include "third_party/WebKit/public/platform/WebURLResponse.h"
124 #include "third_party/WebKit/public/platform/WebVector.h" 125 #include "third_party/WebKit/public/platform/WebVector.h"
125 #include "third_party/WebKit/public/web/WebColorSuggestion.h" 126 #include "third_party/WebKit/public/web/WebColorSuggestion.h"
126 #include "third_party/WebKit/public/web/WebDocument.h" 127 #include "third_party/WebKit/public/web/WebDocument.h"
127 #include "third_party/WebKit/public/web/WebFrameWidget.h" 128 #include "third_party/WebKit/public/web/WebFrameWidget.h"
128 #include "third_party/WebKit/public/web/WebGlyphCache.h" 129 #include "third_party/WebKit/public/web/WebGlyphCache.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 #include "mojo/application/public/interfaces/shell.mojom.h" 185 #include "mojo/application/public/interfaces/shell.mojom.h"
185 #include "third_party/mojo/src/mojo/public/cpp/bindings/interface_request.h" 186 #include "third_party/mojo/src/mojo/public/cpp/bindings/interface_request.h"
186 #else 187 #else
187 #include "media/renderers/default_renderer_factory.h" 188 #include "media/renderers/default_renderer_factory.h"
188 #endif 189 #endif
189 190
190 #if defined(ENABLE_WEBVR) 191 #if defined(ENABLE_WEBVR)
191 #include "content/renderer/vr/vr_dispatcher.h" 192 #include "content/renderer/vr/vr_dispatcher.h"
192 #endif 193 #endif
193 194
195 using blink::WebContentDecryptionModule;
194 using blink::WebContextMenuData; 196 using blink::WebContextMenuData;
195 using blink::WebData; 197 using blink::WebData;
196 using blink::WebDataSource; 198 using blink::WebDataSource;
197 using blink::WebDocument; 199 using blink::WebDocument;
198 using blink::WebDOMEvent; 200 using blink::WebDOMEvent;
199 using blink::WebDOMMessageEvent; 201 using blink::WebDOMMessageEvent;
200 using blink::WebElement; 202 using blink::WebElement;
201 using blink::WebExternalPopupMenu; 203 using blink::WebExternalPopupMenu;
202 using blink::WebExternalPopupMenuClient; 204 using blink::WebExternalPopupMenuClient;
203 using blink::WebFrame; 205 using blink::WebFrame;
204 using blink::WebHistoryItem; 206 using blink::WebHistoryItem;
205 using blink::WebHTTPBody; 207 using blink::WebHTTPBody;
206 using blink::WebLocalFrame; 208 using blink::WebLocalFrame;
207 using blink::WebMediaPlayer; 209 using blink::WebMediaPlayer;
208 using blink::WebMediaPlayerClient; 210 using blink::WebMediaPlayerClient;
211 using blink::WebMediaPlayerEncryptedMediaClient;
209 using blink::WebNavigationPolicy; 212 using blink::WebNavigationPolicy;
210 using blink::WebNavigationType; 213 using blink::WebNavigationType;
211 using blink::WebNode; 214 using blink::WebNode;
212 using blink::WebPluginParams; 215 using blink::WebPluginParams;
213 using blink::WebPopupMenuInfo; 216 using blink::WebPopupMenuInfo;
214 using blink::WebRange; 217 using blink::WebRange;
215 using blink::WebReferrerPolicy; 218 using blink::WebReferrerPolicy;
216 using blink::WebScriptSource; 219 using blink::WebScriptSource;
217 using blink::WebSearchableFormData; 220 using blink::WebSearchableFormData;
218 using blink::WebSecurityOrigin; 221 using blink::WebSecurityOrigin;
(...skipping 1735 matching lines...) Expand 10 before | Expand all | Expand 10 after
1954 params_to_use.mimeType = WebString::fromUTF8(mime_type); 1957 params_to_use.mimeType = WebString::fromUTF8(mime_type);
1955 return CreatePlugin(frame, info, params_to_use, nullptr /* throttler */); 1958 return CreatePlugin(frame, info, params_to_use, nullptr /* throttler */);
1956 #else 1959 #else
1957 return NULL; 1960 return NULL;
1958 #endif // defined(ENABLE_PLUGINS) 1961 #endif // defined(ENABLE_PLUGINS)
1959 } 1962 }
1960 1963
1961 blink::WebMediaPlayer* RenderFrameImpl::createMediaPlayer( 1964 blink::WebMediaPlayer* RenderFrameImpl::createMediaPlayer(
1962 blink::WebLocalFrame* frame, 1965 blink::WebLocalFrame* frame,
1963 const blink::WebURL& url, 1966 const blink::WebURL& url,
1964 blink::WebMediaPlayerClient* client, 1967 WebMediaPlayerClient* client,
1965 blink::WebContentDecryptionModule* initial_cdm) { 1968 WebContentDecryptionModule* initial_cdm) {
1969 return createMediaPlayer(frame, url, client, client, initial_cdm);
1970 }
1971
1972 blink::WebMediaPlayer* RenderFrameImpl::createMediaPlayer(
1973 blink::WebLocalFrame* frame,
1974 const blink::WebURL& url,
1975 WebMediaPlayerClient* client,
1976 WebMediaPlayerEncryptedMediaClient* encrypted_client,
1977 WebContentDecryptionModule* initial_cdm) {
1966 #if defined(VIDEO_HOLE) 1978 #if defined(VIDEO_HOLE)
1967 if (!contains_media_player_) { 1979 if (!contains_media_player_) {
1968 render_view_->RegisterVideoHoleFrame(this); 1980 render_view_->RegisterVideoHoleFrame(this);
1969 contains_media_player_ = true; 1981 contains_media_player_ = true;
1970 } 1982 }
1971 #endif // defined(VIDEO_HOLE) 1983 #endif // defined(VIDEO_HOLE)
1972 1984
1973 blink::WebMediaStream web_stream( 1985 blink::WebMediaStream web_stream(
1974 blink::WebMediaStreamRegistry::lookupMediaStreamDescriptor(url)); 1986 blink::WebMediaStreamRegistry::lookupMediaStreamDescriptor(url));
1975 if (!web_stream.isNull()) 1987 if (!web_stream.isNull())
1976 return CreateWebMediaPlayerForMediaStream(client); 1988 return CreateWebMediaPlayerForMediaStream(client);
1977 1989
1978 #if defined(OS_ANDROID) 1990 #if defined(OS_ANDROID)
1979 return CreateAndroidWebMediaPlayer(client, GetMediaPermission(), initial_cdm); 1991 return CreateAndroidWebMediaPlayer(client, encrypted_client,
1992 GetMediaPermission(), initial_cdm);
1980 #else 1993 #else
1981 scoped_refptr<media::MediaLog> media_log(new RenderMediaLog()); 1994 scoped_refptr<media::MediaLog> media_log(new RenderMediaLog());
1982 1995
1983 RenderThreadImpl* render_thread = RenderThreadImpl::current(); 1996 RenderThreadImpl* render_thread = RenderThreadImpl::current();
1984 media::WebMediaPlayerParams params( 1997 media::WebMediaPlayerParams params(
1985 base::Bind(&ContentRendererClient::DeferMediaLoad, 1998 base::Bind(&ContentRendererClient::DeferMediaLoad,
1986 base::Unretained(GetContentClient()->renderer()), 1999 base::Unretained(GetContentClient()->renderer()),
1987 static_cast<RenderFrame*>(this)), 2000 static_cast<RenderFrame*>(this)),
1988 render_thread->GetAudioRendererMixerManager()->CreateInput(routing_id_), 2001 render_thread->GetAudioRendererMixerManager()->CreateInput(routing_id_),
1989 media_log, render_thread->GetMediaThreadTaskRunner(), 2002 media_log, render_thread->GetMediaThreadTaskRunner(),
(...skipping 10 matching lines...) Expand all
2000 this, render_thread->GetGpuFactories(), media_log); 2013 this, render_thread->GetGpuFactories(), media_log);
2001 2014
2002 if (!media_renderer_factory.get()) { 2015 if (!media_renderer_factory.get()) {
2003 media_renderer_factory.reset(new media::DefaultRendererFactory( 2016 media_renderer_factory.reset(new media::DefaultRendererFactory(
2004 media_log, render_thread->GetGpuFactories(), 2017 media_log, render_thread->GetGpuFactories(),
2005 *render_thread->GetAudioHardwareConfig())); 2018 *render_thread->GetAudioHardwareConfig()));
2006 } 2019 }
2007 #endif // defined(ENABLE_MOJO_MEDIA) 2020 #endif // defined(ENABLE_MOJO_MEDIA)
2008 2021
2009 return new media::WebMediaPlayerImpl( 2022 return new media::WebMediaPlayerImpl(
2010 frame, client, weak_factory_.GetWeakPtr(), media_renderer_factory.Pass(), 2023 frame, client, encrypted_client, weak_factory_.GetWeakPtr(),
2011 GetCdmFactory(), params); 2024 media_renderer_factory.Pass(), GetCdmFactory(), params);
2012 #endif // defined(OS_ANDROID) 2025 #endif // defined(OS_ANDROID)
2013 } 2026 }
2014 2027
2015 blink::WebApplicationCacheHost* RenderFrameImpl::createApplicationCacheHost( 2028 blink::WebApplicationCacheHost* RenderFrameImpl::createApplicationCacheHost(
2016 blink::WebLocalFrame* frame, 2029 blink::WebLocalFrame* frame,
2017 blink::WebApplicationCacheHostClient* client) { 2030 blink::WebApplicationCacheHostClient* client) {
2018 if (!frame || !frame->view()) 2031 if (!frame || !frame->view())
2019 return NULL; 2032 return NULL;
2020 DCHECK(!frame_ || frame_ == frame); 2033 DCHECK(!frame_ || frame_ == frame);
2021 return new RendererWebApplicationCacheHostImpl( 2034 return new RendererWebApplicationCacheHostImpl(
(...skipping 1755 matching lines...) Expand 10 before | Expand all | Expand 10 after
3777 3790
3778 #if defined(ENABLE_WEBVR) 3791 #if defined(ENABLE_WEBVR)
3779 blink::WebVRClient* RenderFrameImpl::webVRClient() { 3792 blink::WebVRClient* RenderFrameImpl::webVRClient() {
3780 if (!vr_dispatcher_) 3793 if (!vr_dispatcher_)
3781 vr_dispatcher_.reset(new VRDispatcher(GetServiceRegistry())); 3794 vr_dispatcher_.reset(new VRDispatcher(GetServiceRegistry()));
3782 3795
3783 return vr_dispatcher_.get(); 3796 return vr_dispatcher_.get();
3784 } 3797 }
3785 #endif 3798 #endif
3786 3799
3787 void RenderFrameImpl::DidPlay(blink::WebMediaPlayer* player) { 3800 void RenderFrameImpl::DidPlay(WebMediaPlayer* player) {
3788 Send(new FrameHostMsg_MediaPlayingNotification( 3801 Send(new FrameHostMsg_MediaPlayingNotification(
3789 routing_id_, reinterpret_cast<int64>(player), player->hasVideo(), 3802 routing_id_, reinterpret_cast<int64>(player), player->hasVideo(),
3790 player->hasAudio(), player->isRemote())); 3803 player->hasAudio(), player->isRemote()));
3791 } 3804 }
3792 3805
3793 void RenderFrameImpl::DidPause(blink::WebMediaPlayer* player) { 3806 void RenderFrameImpl::DidPause(WebMediaPlayer* player) {
3794 Send(new FrameHostMsg_MediaPausedNotification( 3807 Send(new FrameHostMsg_MediaPausedNotification(
3795 routing_id_, reinterpret_cast<int64>(player))); 3808 routing_id_, reinterpret_cast<int64>(player)));
3796 } 3809 }
3797 3810
3798 void RenderFrameImpl::PlayerGone(blink::WebMediaPlayer* player) { 3811 void RenderFrameImpl::PlayerGone(WebMediaPlayer* player) {
3799 DidPause(player); 3812 DidPause(player);
3800 } 3813 }
3801 3814
3802 void RenderFrameImpl::AddObserver(RenderFrameObserver* observer) { 3815 void RenderFrameImpl::AddObserver(RenderFrameObserver* observer) {
3803 observers_.AddObserver(observer); 3816 observers_.AddObserver(observer);
3804 } 3817 }
3805 3818
3806 void RenderFrameImpl::RemoveObserver(RenderFrameObserver* observer) { 3819 void RenderFrameImpl::RemoveObserver(RenderFrameObserver* observer) {
3807 observer->RenderFrameGone(); 3820 observer->RenderFrameGone();
3808 observers_.RemoveObserver(observer); 3821 observers_.RemoveObserver(observer);
(...skipping 1097 matching lines...) Expand 10 before | Expand all | Expand 10 after
4906 pending_navigation_params_->start_params, 4919 pending_navigation_params_->start_params,
4907 pending_navigation_params_->request_params); 4920 pending_navigation_params_->request_params);
4908 } 4921 }
4909 return NavigationStateImpl::CreateContentInitiated(); 4922 return NavigationStateImpl::CreateContentInitiated();
4910 } 4923 }
4911 4924
4912 #if defined(OS_ANDROID) 4925 #if defined(OS_ANDROID)
4913 4926
4914 WebMediaPlayer* RenderFrameImpl::CreateAndroidWebMediaPlayer( 4927 WebMediaPlayer* RenderFrameImpl::CreateAndroidWebMediaPlayer(
4915 WebMediaPlayerClient* client, 4928 WebMediaPlayerClient* client,
4929 WebMediaPlayerEncryptedMediaClient* encrypted_client,
4916 media::MediaPermission* media_permission, 4930 media::MediaPermission* media_permission,
4917 blink::WebContentDecryptionModule* initial_cdm) { 4931 WebContentDecryptionModule* initial_cdm) {
4918
4919 scoped_refptr<StreamTextureFactory> stream_texture_factory; 4932 scoped_refptr<StreamTextureFactory> stream_texture_factory;
4920 if (SynchronousCompositorFactory* factory = 4933 if (SynchronousCompositorFactory* factory =
4921 SynchronousCompositorFactory::GetInstance()) { 4934 SynchronousCompositorFactory::GetInstance()) {
4922 stream_texture_factory = factory->CreateStreamTextureFactory(routing_id_); 4935 stream_texture_factory = factory->CreateStreamTextureFactory(routing_id_);
4923 } else { 4936 } else {
4924 GpuChannelHost* gpu_channel_host = 4937 GpuChannelHost* gpu_channel_host =
4925 RenderThreadImpl::current()->EstablishGpuChannelSync( 4938 RenderThreadImpl::current()->EstablishGpuChannelSync(
4926 CAUSE_FOR_GPU_LAUNCH_VIDEODECODEACCELERATOR_INITIALIZE); 4939 CAUSE_FOR_GPU_LAUNCH_VIDEODECODEACCELERATOR_INITIALIZE);
4927 4940
4928 if (!gpu_channel_host) { 4941 if (!gpu_channel_host) {
4929 LOG(ERROR) << "Failed to establish GPU channel for media player"; 4942 LOG(ERROR) << "Failed to establish GPU channel for media player";
4930 return NULL; 4943 return NULL;
4931 } 4944 }
4932 4945
4933 scoped_refptr<cc_blink::ContextProviderWebContext> context_provider = 4946 scoped_refptr<cc_blink::ContextProviderWebContext> context_provider =
4934 RenderThreadImpl::current()->SharedMainThreadContextProvider(); 4947 RenderThreadImpl::current()->SharedMainThreadContextProvider();
4935 4948
4936 if (!context_provider.get()) { 4949 if (!context_provider.get()) {
4937 LOG(ERROR) << "Failed to get context3d for media player"; 4950 LOG(ERROR) << "Failed to get context3d for media player";
4938 return NULL; 4951 return NULL;
4939 } 4952 }
4940 4953
4941 stream_texture_factory = StreamTextureFactoryImpl::Create( 4954 stream_texture_factory = StreamTextureFactoryImpl::Create(
4942 context_provider, gpu_channel_host, routing_id_); 4955 context_provider, gpu_channel_host, routing_id_);
4943 } 4956 }
4944 4957
4945 return new WebMediaPlayerAndroid( 4958 return new WebMediaPlayerAndroid(
4946 frame_, client, weak_factory_.GetWeakPtr(), GetMediaPlayerManager(), 4959 frame_, client, encrypted_client, weak_factory_.GetWeakPtr(),
4947 GetCdmFactory(), media_permission, initial_cdm, stream_texture_factory, 4960 GetMediaPlayerManager(), GetCdmFactory(), media_permission, initial_cdm,
4961 stream_texture_factory,
4948 RenderThreadImpl::current()->GetMediaThreadTaskRunner(), 4962 RenderThreadImpl::current()->GetMediaThreadTaskRunner(),
4949 new RenderMediaLog()); 4963 new RenderMediaLog());
4950 } 4964 }
4951 4965
4952 RendererMediaPlayerManager* RenderFrameImpl::GetMediaPlayerManager() { 4966 RendererMediaPlayerManager* RenderFrameImpl::GetMediaPlayerManager() {
4953 if (!media_player_manager_) 4967 if (!media_player_manager_)
4954 media_player_manager_ = new RendererMediaPlayerManager(this); 4968 media_player_manager_ = new RendererMediaPlayerManager(this);
4955 return media_player_manager_; 4969 return media_player_manager_;
4956 } 4970 }
4957 4971
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
5022 void RenderFrameImpl::RegisterMojoServices() { 5036 void RenderFrameImpl::RegisterMojoServices() {
5023 // Only main frame have ImageDownloader service. 5037 // Only main frame have ImageDownloader service.
5024 if (!frame_->parent()) { 5038 if (!frame_->parent()) {
5025 GetServiceRegistry()->AddService<image_downloader::ImageDownloader>( 5039 GetServiceRegistry()->AddService<image_downloader::ImageDownloader>(
5026 base::Bind(&ImageDownloaderImpl::CreateMojoService, 5040 base::Bind(&ImageDownloaderImpl::CreateMojoService,
5027 base::Unretained(this))); 5041 base::Unretained(this)));
5028 } 5042 }
5029 } 5043 }
5030 5044
5031 } // namespace content 5045 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_frame_impl.h ('k') | media/blink/encrypted_media_player_support.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698