Chromium Code Reviews| 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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 126 #include "content/renderer/stats_collection_controller.h" | 126 #include "content/renderer/stats_collection_controller.h" |
| 127 #include "content/renderer/usb/web_usb_client_impl.h" | 127 #include "content/renderer/usb/web_usb_client_impl.h" |
| 128 #include "content/renderer/wake_lock/wake_lock_dispatcher.h" | 128 #include "content/renderer/wake_lock/wake_lock_dispatcher.h" |
| 129 #include "content/renderer/web_frame_utils.h" | 129 #include "content/renderer/web_frame_utils.h" |
| 130 #include "content/renderer/web_ui_extension.h" | 130 #include "content/renderer/web_ui_extension.h" |
| 131 #include "content/renderer/websharedworker_proxy.h" | 131 #include "content/renderer/websharedworker_proxy.h" |
| 132 #include "crypto/sha2.h" | 132 #include "crypto/sha2.h" |
| 133 #include "gin/modules/module_registry.h" | 133 #include "gin/modules/module_registry.h" |
| 134 #include "media/audio/audio_output_device.h" | 134 #include "media/audio/audio_output_device.h" |
| 135 #include "media/base/audio_renderer_mixer_input.h" | 135 #include "media/base/audio_renderer_mixer_input.h" |
| 136 #include "media/base/media.h" | |
| 136 #include "media/base/media_log.h" | 137 #include "media/base/media_log.h" |
| 137 #include "media/base/media_switches.h" | 138 #include "media/base/media_switches.h" |
| 138 #include "media/blink/url_index.h" | 139 #include "media/blink/url_index.h" |
| 139 #include "media/blink/webencryptedmediaclient_impl.h" | 140 #include "media/blink/webencryptedmediaclient_impl.h" |
| 140 #include "media/blink/webmediaplayer_impl.h" | 141 #include "media/blink/webmediaplayer_impl.h" |
| 141 #include "media/renderers/gpu_video_accelerator_factories.h" | 142 #include "media/renderers/gpu_video_accelerator_factories.h" |
| 142 #include "mojo/common/url_type_converters.h" | 143 #include "mojo/common/url_type_converters.h" |
| 143 #include "mojo/edk/js/core.h" | 144 #include "mojo/edk/js/core.h" |
| 144 #include "mojo/edk/js/support.h" | 145 #include "mojo/edk/js/support.h" |
| 145 #include "net/base/data_url.h" | 146 #include "net/base/data_url.h" |
| (...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 736 main_resource_ssl_status.security_style != | 737 main_resource_ssl_status.security_style != |
| 737 ssl_status.security_style || | 738 ssl_status.security_style || |
| 738 main_resource_ssl_status.cert_id != ssl_status.cert_id || | 739 main_resource_ssl_status.cert_id != ssl_status.cert_id || |
| 739 main_resource_ssl_status.cert_status != ssl_status.cert_status || | 740 main_resource_ssl_status.cert_status != ssl_status.cert_status || |
| 740 main_resource_ssl_status.security_bits != ssl_status.security_bits || | 741 main_resource_ssl_status.security_bits != ssl_status.security_bits || |
| 741 main_resource_ssl_status.connection_status != | 742 main_resource_ssl_status.connection_status != |
| 742 ssl_status.connection_status); | 743 ssl_status.connection_status); |
| 743 } | 744 } |
| 744 | 745 |
| 745 #if defined(OS_ANDROID) | 746 #if defined(OS_ANDROID) |
| 746 // Returns true if WMPI must be used for playback because WMPA will not work. | 747 // Returns true if WMPI should be used for playback, false otherwise. |
| 747 bool MustUseWebMediaPlayerImpl(blink::WebMediaPlayer::LoadType load_type, | |
| 748 const GURL& url) { | |
| 749 // WMPA can't play MSE if MediaCodec is unavailable. In this case WMPI may | |
| 750 // still work (via libvpx). | |
| 751 return (load_type == blink::WebMediaPlayer::LoadTypeMediaSource && | |
| 752 !media::MediaCodecUtil::IsMediaCodecAvailable()); | |
| 753 } | |
| 754 | |
| 755 // Returns true if WMPI can be used for playback, false if it may not work. | |
| 756 // | 748 // |
| 757 // Note that HLS and WebM detection are pre-redirect and path-based. It is | 749 // Note that HLS and MP4 detection are pre-redirect and path-based. It is |
| 758 // possible to load such a URL and find different content. | 750 // possible to load such a URL and find different content. |
| 759 bool CanUseWebMediaPlayerImpl(blink::WebMediaPlayer::LoadType load_type, | 751 bool UseWebMediaPlayerImpl(blink::WebMediaPlayer::LoadType load_type, |
| 760 const GURL& url) { | 752 const GURL& url) { |
| 761 if (MustUseWebMediaPlayerImpl(load_type, url)) | 753 if (load_type == blink::WebMediaPlayer::LoadTypeMediaSource) |
| 762 return true; | 754 return media::IsUnifiedMediaPipelineEnabledForMse(); |
| 763 | 755 |
| 764 // WMPI does not support HLS. | 756 // WMPI does not support HLS. |
| 765 if (media::MediaCodecUtil::IsHLSPath(url)) | 757 if (media::MediaCodecUtil::IsHLSPath(url)) |
| 766 return false; | 758 return false; |
| 767 | 759 |
| 768 // Otherwise --enable-unified-media-pipeline always enables WMPI. | 760 // Don't use WMPI if the container likely contains h264 and hardware decoders |
|
ddorwin
2016/02/16 20:34:36
nit: s/h264/non-vpx codec/? IOW, if we don't have
DaleCurtis
2016/02/17 03:01:05
Done.
| |
| 769 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 761 // are not available. |
| 770 switches::kEnableUnifiedMediaPipeline)) { | 762 if (base::EndsWith(url.path(), ".mp4", |
| 771 return true; | 763 base::CompareCase::INSENSITIVE_ASCII) && |
| 764 (base::CommandLine::ForCurrentProcess()->HasSwitch( | |
|
ddorwin
2016/02/16 20:34:36
Should this be a call to HasPlatformDecoderSupport
DaleCurtis
2016/02/17 03:01:05
Done.
| |
| 765 switches::kDisableAcceleratedVideoDecode) || | |
| 766 !media::MediaCodecUtil::IsMediaCodecAvailable())) { | |
| 767 return false; | |
| 772 } | 768 } |
| 773 | 769 |
| 774 // WMPI can always play WebM (via libvpx). | 770 // Otherwise enable WMPI if indicated via experiment or command line. Video |
| 775 if (base::EndsWith(url.path(), ".webm", base::CompareCase::INSENSITIVE_ASCII)) | 771 // decode may still be blacklisted for some codecs and platforms based on |
|
ddorwin
2016/02/16 20:34:36
nit: Make it clearer that this means "there could
DaleCurtis
2016/02/17 03:01:05
Deleted this whole comment since I think it's just
| |
| 776 return true; | 772 // the GPU feature blacklist or the hardcoded blacklist inside MediaCodecUtil. |
| 777 | 773 return media::IsUnifiedMediaPipelineEnabled(); |
| 778 // Otherwise, WMPI can only be used if AVDA is working. | |
| 779 return (!base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 780 switches::kDisableAcceleratedVideoDecode) && | |
| 781 media::MediaCodecUtil::IsMediaCodecAvailable()); | |
| 782 } | 774 } |
| 783 #endif // defined(OS_ANDROID) | 775 #endif // defined(OS_ANDROID) |
| 784 | 776 |
| 785 } // namespace | 777 } // namespace |
| 786 | 778 |
| 787 // static | 779 // static |
| 788 RenderFrameImpl* RenderFrameImpl::Create(RenderViewImpl* render_view, | 780 RenderFrameImpl* RenderFrameImpl::Create(RenderViewImpl* render_view, |
| 789 int32_t routing_id) { | 781 int32_t routing_id) { |
| 790 DCHECK(routing_id != MSG_ROUTING_NONE); | 782 DCHECK(routing_id != MSG_ROUTING_NONE); |
| 791 CreateParams params(render_view, routing_id); | 783 CreateParams params(render_view, routing_id); |
| (...skipping 1695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2487 static_cast<RenderFrame*>(this), | 2479 static_cast<RenderFrame*>(this), |
| 2488 GetWebMediaPlayerDelegate()->has_played_media()), | 2480 GetWebMediaPlayerDelegate()->has_played_media()), |
| 2489 audio_renderer_sink, media_log, render_thread->GetMediaThreadTaskRunner(), | 2481 audio_renderer_sink, media_log, render_thread->GetMediaThreadTaskRunner(), |
| 2490 render_thread->GetWorkerTaskRunner(), | 2482 render_thread->GetWorkerTaskRunner(), |
| 2491 render_thread->compositor_task_runner(), context_3d_cb, | 2483 render_thread->compositor_task_runner(), context_3d_cb, |
| 2492 base::Bind(&v8::Isolate::AdjustAmountOfExternalAllocatedMemory, | 2484 base::Bind(&v8::Isolate::AdjustAmountOfExternalAllocatedMemory, |
| 2493 base::Unretained(blink::mainThreadIsolate())), | 2485 base::Unretained(blink::mainThreadIsolate())), |
| 2494 GetMediaPermission(), initial_cdm); | 2486 GetMediaPermission(), initial_cdm); |
| 2495 | 2487 |
| 2496 #if defined(OS_ANDROID) | 2488 #if defined(OS_ANDROID) |
| 2497 if (!CanUseWebMediaPlayerImpl(load_type, url)) { | 2489 if (!UseWebMediaPlayerImpl(load_type, url)) |
| 2498 return CreateAndroidWebMediaPlayer(client, encrypted_client, params); | 2490 return CreateAndroidWebMediaPlayer(client, encrypted_client, params); |
| 2499 } else if (!MustUseWebMediaPlayerImpl(load_type, url)) { | |
| 2500 // TODO(dalecurtis): This experiment is temporary and should be removed once | |
| 2501 // we have enough data to support the primacy of the unified media pipeline; | |
| 2502 // see http://crbug.com/533190 for details. | |
| 2503 // | |
| 2504 // Note: It's important to query the field trial state first, to ensure that | |
| 2505 // UMA reports the correct group. | |
| 2506 const std::string group_name = | |
| 2507 base::FieldTrialList::FindFullName("UnifiedMediaPipelineTrial"); | |
| 2508 const bool enabled_via_cli = | |
| 2509 base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 2510 switches::kEnableUnifiedMediaPipeline); | |
| 2511 const bool enable_unified_media_pipeline = | |
| 2512 enabled_via_cli || | |
| 2513 base::StartsWith(group_name, "Enabled", base::CompareCase::SENSITIVE); | |
| 2514 | |
| 2515 if (!enable_unified_media_pipeline) | |
| 2516 return CreateAndroidWebMediaPlayer(client, encrypted_client, params); | |
| 2517 } | |
| 2518 #endif // defined(OS_ANDROID) | 2491 #endif // defined(OS_ANDROID) |
| 2519 | 2492 |
| 2520 #if defined(ENABLE_MOJO_MEDIA) && !defined(OS_ANDROID) | 2493 #if defined(ENABLE_MOJO_MEDIA) && !defined(OS_ANDROID) |
| 2521 scoped_ptr<media::RendererFactory> media_renderer_factory( | 2494 scoped_ptr<media::RendererFactory> media_renderer_factory( |
| 2522 new media::MojoRendererFactory(GetMediaServiceFactory())); | 2495 new media::MojoRendererFactory(GetMediaServiceFactory())); |
| 2523 #else | 2496 #else |
| 2524 scoped_ptr<media::RendererFactory> media_renderer_factory = | 2497 scoped_ptr<media::RendererFactory> media_renderer_factory = |
| 2525 GetContentClient()->renderer()->CreateMediaRendererFactory( | 2498 GetContentClient()->renderer()->CreateMediaRendererFactory( |
| 2526 this, render_thread->GetGpuFactories(), media_log); | 2499 this, render_thread->GetGpuFactories(), media_log); |
| 2527 | 2500 |
| (...skipping 3602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6130 int match_count, | 6103 int match_count, |
| 6131 int ordinal, | 6104 int ordinal, |
| 6132 const WebRect& selection_rect, | 6105 const WebRect& selection_rect, |
| 6133 bool final_status_update) { | 6106 bool final_status_update) { |
| 6134 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count, | 6107 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count, |
| 6135 selection_rect, ordinal, | 6108 selection_rect, ordinal, |
| 6136 final_status_update)); | 6109 final_status_update)); |
| 6137 } | 6110 } |
| 6138 | 6111 |
| 6139 } // namespace content | 6112 } // namespace content |
| OLD | NEW |