OLD | NEW |
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 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 #if defined(ENABLE_MOJO_RENDERER) | 243 #if defined(ENABLE_MOJO_RENDERER) |
244 #include "media/mojo/clients/mojo_renderer_factory.h" // nogncheck | 244 #include "media/mojo/clients/mojo_renderer_factory.h" // nogncheck |
245 #else | 245 #else |
246 #include "media/renderers/default_renderer_factory.h" | 246 #include "media/renderers/default_renderer_factory.h" |
247 #endif | 247 #endif |
248 | 248 |
249 #if defined(ENABLE_MOJO_AUDIO_DECODER) || defined(ENABLE_MOJO_VIDEO_DECODER) | 249 #if defined(ENABLE_MOJO_AUDIO_DECODER) || defined(ENABLE_MOJO_VIDEO_DECODER) |
250 #include "media/mojo/clients/mojo_decoder_factory.h" // nogncheck | 250 #include "media/mojo/clients/mojo_decoder_factory.h" // nogncheck |
251 #endif | 251 #endif |
252 | 252 |
| 253 #if BUILDFLAG(ENABLE_MEDIA_REMOTING) |
| 254 #include "media/remoting/remoting_controller.h" // nogncheck |
| 255 #include "media/remoting/remoting_renderer_factory.h" // nogncheck |
| 256 #endif |
| 257 |
253 using base::Time; | 258 using base::Time; |
254 using base::TimeDelta; | 259 using base::TimeDelta; |
255 using blink::WebCachePolicy; | 260 using blink::WebCachePolicy; |
256 using blink::WebContentDecryptionModule; | 261 using blink::WebContentDecryptionModule; |
257 using blink::WebContextMenuData; | 262 using blink::WebContextMenuData; |
258 using blink::WebCString; | 263 using blink::WebCString; |
259 using blink::WebData; | 264 using blink::WebData; |
260 using blink::WebDataSource; | 265 using blink::WebDataSource; |
261 using blink::WebDocument; | 266 using blink::WebDocument; |
262 using blink::WebDOMEvent; | 267 using blink::WebDOMEvent; |
(...skipping 2375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2638 return NULL; | 2643 return NULL; |
2639 | 2644 |
2640 WebPluginParams params_to_use = params; | 2645 WebPluginParams params_to_use = params; |
2641 params_to_use.mimeType = WebString::fromUTF8(mime_type); | 2646 params_to_use.mimeType = WebString::fromUTF8(mime_type); |
2642 return CreatePlugin(frame, info, params_to_use, nullptr /* throttler */); | 2647 return CreatePlugin(frame, info, params_to_use, nullptr /* throttler */); |
2643 #else | 2648 #else |
2644 return NULL; | 2649 return NULL; |
2645 #endif // defined(ENABLE_PLUGINS) | 2650 #endif // defined(ENABLE_PLUGINS) |
2646 } | 2651 } |
2647 | 2652 |
| 2653 #if BUILDFLAG(ENABLE_MEDIA_REMOTING) |
| 2654 std::unique_ptr<media::RemotingController> |
| 2655 RenderFrameImpl::CreateRemotingController() { |
| 2656 media::mojom::RemotingSourcePtr remoting_source; |
| 2657 media::mojom::RemotingSourceRequest remoting_source_request = |
| 2658 mojo::GetProxy(&remoting_source); |
| 2659 media::mojom::RemoterPtr remoter; |
| 2660 GetRemoterFactory()->Create(std::move(remoting_source), |
| 2661 mojo::GetProxy(&remoter)); |
| 2662 return base::MakeUnique<media::RemotingController>( |
| 2663 std::move(remoting_source_request), std::move(remoter)); |
| 2664 } |
| 2665 #endif |
| 2666 |
2648 blink::WebMediaPlayer* RenderFrameImpl::createMediaPlayer( | 2667 blink::WebMediaPlayer* RenderFrameImpl::createMediaPlayer( |
2649 const blink::WebMediaPlayerSource& source, | 2668 const blink::WebMediaPlayerSource& source, |
2650 WebMediaPlayerClient* client, | 2669 WebMediaPlayerClient* client, |
2651 WebMediaPlayerEncryptedMediaClient* encrypted_client, | 2670 WebMediaPlayerEncryptedMediaClient* encrypted_client, |
2652 WebContentDecryptionModule* initial_cdm, | 2671 WebContentDecryptionModule* initial_cdm, |
2653 const blink::WebString& sink_id) { | 2672 const blink::WebString& sink_id) { |
2654 blink::WebMediaStream web_stream = | 2673 blink::WebMediaStream web_stream = |
2655 GetWebMediaStreamFromWebMediaPlayerSource(source); | 2674 GetWebMediaStreamFromWebMediaPlayerSource(source); |
2656 if (!web_stream.isNull()) | 2675 if (!web_stream.isNull()) |
2657 return CreateWebMediaPlayerForMediaStream(client, sink_id, | 2676 return CreateWebMediaPlayerForMediaStream(client, sink_id, |
(...skipping 18 matching lines...) Expand all Loading... |
2676 media::WebMediaPlayerParams::Context3DCB context_3d_cb = base::Bind( | 2695 media::WebMediaPlayerParams::Context3DCB context_3d_cb = base::Bind( |
2677 &GetSharedMainThreadContext3D, | 2696 &GetSharedMainThreadContext3D, |
2678 RenderThreadImpl::current()->SharedMainThreadContextProvider()); | 2697 RenderThreadImpl::current()->SharedMainThreadContextProvider()); |
2679 | 2698 |
2680 scoped_refptr<media::MediaLog> media_log(new RenderMediaLog( | 2699 scoped_refptr<media::MediaLog> media_log(new RenderMediaLog( |
2681 blink::WebStringToGURL(frame_->getSecurityOrigin().toString()))); | 2700 blink::WebStringToGURL(frame_->getSecurityOrigin().toString()))); |
2682 | 2701 |
2683 #if defined(OS_ANDROID) | 2702 #if defined(OS_ANDROID) |
2684 if (UseWebMediaPlayerImpl(url) && !media_surface_manager_) | 2703 if (UseWebMediaPlayerImpl(url) && !media_surface_manager_) |
2685 media_surface_manager_ = new RendererSurfaceViewManager(this); | 2704 media_surface_manager_ = new RendererSurfaceViewManager(this); |
| 2705 #endif // defined(OS_ANDROID) |
| 2706 |
| 2707 #if BUILDFLAG(ENABLE_MEDIA_REMOTING) |
| 2708 std::unique_ptr<media::RemotingController> remoting_controller = |
| 2709 CreateRemotingController(); |
| 2710 base::WeakPtr<media::MediaObserver> media_observer = |
| 2711 remoting_controller->GetWeakPtr(); |
| 2712 #else |
| 2713 base::WeakPtr<media::MediaObserver> media_observer = nullptr; |
2686 #endif | 2714 #endif |
| 2715 |
2687 media::WebMediaPlayerParams params( | 2716 media::WebMediaPlayerParams params( |
2688 base::Bind(&ContentRendererClient::DeferMediaLoad, | 2717 base::Bind(&ContentRendererClient::DeferMediaLoad, |
2689 base::Unretained(GetContentClient()->renderer()), | 2718 base::Unretained(GetContentClient()->renderer()), |
2690 static_cast<RenderFrame*>(this), | 2719 static_cast<RenderFrame*>(this), |
2691 GetWebMediaPlayerDelegate()->has_played_media()), | 2720 GetWebMediaPlayerDelegate()->has_played_media()), |
2692 audio_renderer_sink, media_log, render_thread->GetMediaThreadTaskRunner(), | 2721 audio_renderer_sink, media_log, render_thread->GetMediaThreadTaskRunner(), |
2693 render_thread->GetWorkerTaskRunner(), | 2722 render_thread->GetWorkerTaskRunner(), |
2694 render_thread->compositor_task_runner(), context_3d_cb, | 2723 render_thread->compositor_task_runner(), context_3d_cb, |
2695 base::Bind(&v8::Isolate::AdjustAmountOfExternalAllocatedMemory, | 2724 base::Bind(&v8::Isolate::AdjustAmountOfExternalAllocatedMemory, |
2696 base::Unretained(blink::mainThreadIsolate())), | 2725 base::Unretained(blink::mainThreadIsolate())), |
2697 initial_cdm, media_surface_manager_); | 2726 initial_cdm, media_surface_manager_, media_observer); |
2698 | 2727 |
2699 #if defined(OS_ANDROID) | 2728 #if defined(OS_ANDROID) |
2700 if (!UseWebMediaPlayerImpl(url)) { | 2729 if (!UseWebMediaPlayerImpl(url)) { |
2701 return CreateAndroidWebMediaPlayer(client, encrypted_client, params); | 2730 return CreateAndroidWebMediaPlayer(client, encrypted_client, params); |
2702 } | 2731 } |
2703 #endif // defined(OS_ANDROID) | 2732 #endif // defined(OS_ANDROID) |
2704 | 2733 |
2705 #if defined(ENABLE_MOJO_RENDERER) | 2734 #if defined(ENABLE_MOJO_RENDERER) |
2706 std::unique_ptr<media::RendererFactory> media_renderer_factory( | 2735 std::unique_ptr<media::RendererFactory> media_renderer_factory( |
2707 new media::MojoRendererFactory( | 2736 new media::MojoRendererFactory( |
2708 base::Bind(&RenderThreadImpl::GetGpuFactories, | 2737 base::Bind(&RenderThreadImpl::GetGpuFactories, |
2709 base::Unretained(render_thread)), | 2738 base::Unretained(render_thread)), |
2710 GetMediaInterfaceProvider())); | 2739 GetMediaInterfaceProvider())); |
2711 #else | 2740 #else |
2712 std::unique_ptr<media::RendererFactory> media_renderer_factory( | 2741 std::unique_ptr<media::RendererFactory> media_renderer_factory( |
2713 new media::DefaultRendererFactory( | 2742 new media::DefaultRendererFactory( |
2714 media_log, GetDecoderFactory(), | 2743 media_log, GetDecoderFactory(), |
2715 base::Bind(&RenderThreadImpl::GetGpuFactories, | 2744 base::Bind(&RenderThreadImpl::GetGpuFactories, |
2716 base::Unretained(render_thread)))); | 2745 base::Unretained(render_thread)))); |
2717 #endif // defined(ENABLE_MOJO_RENDERER) | 2746 #endif |
| 2747 |
| 2748 #if BUILDFLAG(ENABLE_MEDIA_REMOTING) |
| 2749 media::RemotingController* remoting_controller_ptr = |
| 2750 remoting_controller.get(); |
| 2751 media_renderer_factory = base::MakeUnique<media::RemotingRendererFactory>( |
| 2752 std::move(media_renderer_factory), std::move(remoting_controller)); |
| 2753 #endif |
2718 | 2754 |
2719 if (!url_index_.get() || url_index_->frame() != frame_) | 2755 if (!url_index_.get() || url_index_->frame() != frame_) |
2720 url_index_.reset(new media::UrlIndex(frame_)); | 2756 url_index_.reset(new media::UrlIndex(frame_)); |
2721 | 2757 |
2722 // TODO(miu): In a soon-upcoming change, call GetRemoterFactory()->Create() to | |
2723 // allow the local media pipeline to receive notifications about when Media | |
2724 // Remoting can take place. Control logic in/around WebMediaPlayerImpl will | |
2725 // implement media.mojom.RemotingSource. http://crbug.com/643964 | |
2726 | |
2727 media::WebMediaPlayerImpl* media_player = new media::WebMediaPlayerImpl( | 2758 media::WebMediaPlayerImpl* media_player = new media::WebMediaPlayerImpl( |
2728 frame_, client, encrypted_client, | 2759 frame_, client, encrypted_client, |
2729 GetWebMediaPlayerDelegate()->AsWeakPtr(), | 2760 GetWebMediaPlayerDelegate()->AsWeakPtr(), |
2730 std::move(media_renderer_factory), url_index_, params); | 2761 std::move(media_renderer_factory), url_index_, params); |
2731 | 2762 |
2732 #if defined(OS_ANDROID) // WMPI_CAST | 2763 #if defined(OS_ANDROID) // WMPI_CAST |
2733 media_player->SetMediaPlayerManager(GetMediaPlayerManager()); | 2764 media_player->SetMediaPlayerManager(GetMediaPlayerManager()); |
2734 media_player->SetDeviceScaleFactor(render_view_->GetDeviceScaleFactor()); | 2765 media_player->SetDeviceScaleFactor(render_view_->GetDeviceScaleFactor()); |
| 2766 #endif // defined(OS_ANDROID) |
| 2767 |
| 2768 #if BUILDFLAG(ENABLE_MEDIA_REMOTING) |
| 2769 remoting_controller_ptr->SetSwitchRendererCallback(base::Bind( |
| 2770 &media::WebMediaPlayerImpl::ScheduleRestart, media_player->AsWeakPtr())); |
2735 #endif | 2771 #endif |
2736 | 2772 |
2737 return media_player; | 2773 return media_player; |
2738 } | 2774 } |
2739 | 2775 |
2740 blink::WebApplicationCacheHost* RenderFrameImpl::createApplicationCacheHost( | 2776 blink::WebApplicationCacheHost* RenderFrameImpl::createApplicationCacheHost( |
2741 blink::WebApplicationCacheHostClient* client) { | 2777 blink::WebApplicationCacheHostClient* client) { |
2742 if (!frame_ || !frame_->view()) | 2778 if (!frame_ || !frame_->view()) |
2743 return NULL; | 2779 return NULL; |
2744 return new RendererWebApplicationCacheHostImpl( | 2780 return new RendererWebApplicationCacheHostImpl( |
(...skipping 3530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6275 bool RenderFrameImpl::AreSecureCodecsSupported() { | 6311 bool RenderFrameImpl::AreSecureCodecsSupported() { |
6276 #if defined(OS_ANDROID) | 6312 #if defined(OS_ANDROID) |
6277 // Hardware-secure codecs are only supported if secure surfaces are enabled. | 6313 // Hardware-secure codecs are only supported if secure surfaces are enabled. |
6278 return render_view_->renderer_preferences_ | 6314 return render_view_->renderer_preferences_ |
6279 .use_video_overlay_for_embedded_encrypted_video; | 6315 .use_video_overlay_for_embedded_encrypted_video; |
6280 #else | 6316 #else |
6281 return false; | 6317 return false; |
6282 #endif // defined(OS_ANDROID) | 6318 #endif // defined(OS_ANDROID) |
6283 } | 6319 } |
6284 | 6320 |
| 6321 #if BUILDFLAG(ENABLE_MEDIA_REMOTING) |
6285 media::mojom::RemoterFactory* RenderFrameImpl::GetRemoterFactory() { | 6322 media::mojom::RemoterFactory* RenderFrameImpl::GetRemoterFactory() { |
6286 if (!remoter_factory_) | 6323 if (!remoter_factory_) |
6287 GetRemoteInterfaces()->GetInterface(&remoter_factory_); | 6324 GetRemoteInterfaces()->GetInterface(&remoter_factory_); |
6288 return remoter_factory_.get(); | 6325 return remoter_factory_.get(); |
6289 } | 6326 } |
| 6327 #endif |
6290 | 6328 |
6291 media::CdmFactory* RenderFrameImpl::GetCdmFactory() { | 6329 media::CdmFactory* RenderFrameImpl::GetCdmFactory() { |
6292 if (cdm_factory_) | 6330 if (cdm_factory_) |
6293 return cdm_factory_.get(); | 6331 return cdm_factory_.get(); |
6294 | 6332 |
6295 #if defined(ENABLE_MOJO_CDM) | 6333 #if defined(ENABLE_MOJO_CDM) |
6296 if (UseMojoCdm()) { | 6334 if (UseMojoCdm()) { |
6297 cdm_factory_.reset(new media::MojoCdmFactory(GetMediaInterfaceProvider())); | 6335 cdm_factory_.reset(new media::MojoCdmFactory(GetMediaInterfaceProvider())); |
6298 return cdm_factory_.get(); | 6336 return cdm_factory_.get(); |
6299 } | 6337 } |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6484 // event target. Potentially a Pepper plugin will receive the event. | 6522 // event target. Potentially a Pepper plugin will receive the event. |
6485 // In order to tell whether a plugin gets the last mouse event and which it | 6523 // In order to tell whether a plugin gets the last mouse event and which it |
6486 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets | 6524 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets |
6487 // the event, it will notify us via DidReceiveMouseEvent() and set itself as | 6525 // the event, it will notify us via DidReceiveMouseEvent() and set itself as |
6488 // |pepper_last_mouse_event_target_|. | 6526 // |pepper_last_mouse_event_target_|. |
6489 pepper_last_mouse_event_target_ = nullptr; | 6527 pepper_last_mouse_event_target_ = nullptr; |
6490 #endif | 6528 #endif |
6491 } | 6529 } |
6492 | 6530 |
6493 } // namespace content | 6531 } // namespace content |
OLD | NEW |