| 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 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 737 main_resource_ssl_status.security_style != | 738 main_resource_ssl_status.security_style != |
| 738 ssl_status.security_style || | 739 ssl_status.security_style || |
| 739 main_resource_ssl_status.cert_id != ssl_status.cert_id || | 740 main_resource_ssl_status.cert_id != ssl_status.cert_id || |
| 740 main_resource_ssl_status.cert_status != ssl_status.cert_status || | 741 main_resource_ssl_status.cert_status != ssl_status.cert_status || |
| 741 main_resource_ssl_status.security_bits != ssl_status.security_bits || | 742 main_resource_ssl_status.security_bits != ssl_status.security_bits || |
| 742 main_resource_ssl_status.connection_status != | 743 main_resource_ssl_status.connection_status != |
| 743 ssl_status.connection_status); | 744 ssl_status.connection_status); |
| 744 } | 745 } |
| 745 | 746 |
| 746 #if defined(OS_ANDROID) | 747 #if defined(OS_ANDROID) |
| 747 // Returns true if WMPI must be used for playback because WMPA will not work. | 748 // Returns true if WMPI should be used for playback, false otherwise. |
| 748 bool MustUseWebMediaPlayerImpl(blink::WebMediaPlayer::LoadType load_type, | |
| 749 const GURL& url) { | |
| 750 // WMPA can't play MSE if MediaCodec is unavailable. In this case WMPI may | |
| 751 // still work (via libvpx). | |
| 752 return (load_type == blink::WebMediaPlayer::LoadTypeMediaSource && | |
| 753 !media::MediaCodecUtil::IsMediaCodecAvailable()); | |
| 754 } | |
| 755 | |
| 756 // Returns true if WMPI can be used for playback, false if it may not work. | |
| 757 // | 749 // |
| 758 // Note that HLS and WebM detection are pre-redirect and path-based. It is | 750 // Note that HLS and MP4 detection are pre-redirect and path-based. It is |
| 759 // possible to load such a URL and find different content. | 751 // possible to load such a URL and find different content. |
| 760 bool CanUseWebMediaPlayerImpl(blink::WebMediaPlayer::LoadType load_type, | 752 bool UseWebMediaPlayerImpl(blink::WebMediaPlayer::LoadType load_type, |
| 761 const GURL& url) { | 753 const GURL& url) { |
| 762 if (MustUseWebMediaPlayerImpl(load_type, url)) | 754 if (load_type == blink::WebMediaPlayer::LoadTypeMediaSource) |
| 763 return true; | 755 return media::IsUnifiedMediaPipelineEnabledForMse(); |
| 764 | 756 |
| 765 // WMPI does not support HLS. | 757 // WMPI does not support HLS. |
| 766 if (media::MediaCodecUtil::IsHLSPath(url)) | 758 if (media::MediaCodecUtil::IsHLSPath(url)) |
| 767 return false; | 759 return false; |
| 768 | 760 |
| 769 // Otherwise --enable-unified-media-pipeline always enables WMPI. | 761 // Don't use WMPI if the container likely contains a codec we can't decode in |
| 770 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 762 // software and hardware decoders are not available. |
| 771 switches::kEnableUnifiedMediaPipeline)) { | 763 if (base::EndsWith(url.path(), ".mp4", |
| 772 return true; | 764 base::CompareCase::INSENSITIVE_ASCII) && |
| 765 !media::HasPlatformDecoderSupport()) { |
| 766 return false; |
| 773 } | 767 } |
| 774 | 768 |
| 775 // WMPI can always play WebM (via libvpx). | 769 // Otherwise enable WMPI if indicated via experiment or command line. |
| 776 if (base::EndsWith(url.path(), ".webm", base::CompareCase::INSENSITIVE_ASCII)) | 770 return media::IsUnifiedMediaPipelineEnabled(); |
| 777 return true; | |
| 778 | |
| 779 // Otherwise, WMPI can only be used if AVDA is working. | |
| 780 return (!base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 781 switches::kDisableAcceleratedVideoDecode) && | |
| 782 media::MediaCodecUtil::IsMediaCodecAvailable()); | |
| 783 } | 771 } |
| 784 #endif // defined(OS_ANDROID) | 772 #endif // defined(OS_ANDROID) |
| 785 | 773 |
| 786 } // namespace | 774 } // namespace |
| 787 | 775 |
| 788 // static | 776 // static |
| 789 RenderFrameImpl* RenderFrameImpl::Create(RenderViewImpl* render_view, | 777 RenderFrameImpl* RenderFrameImpl::Create(RenderViewImpl* render_view, |
| 790 int32_t routing_id) { | 778 int32_t routing_id) { |
| 791 DCHECK(routing_id != MSG_ROUTING_NONE); | 779 DCHECK(routing_id != MSG_ROUTING_NONE); |
| 792 CreateParams params(render_view, routing_id); | 780 CreateParams params(render_view, routing_id); |
| (...skipping 1699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2492 static_cast<RenderFrame*>(this), | 2480 static_cast<RenderFrame*>(this), |
| 2493 GetWebMediaPlayerDelegate()->has_played_media()), | 2481 GetWebMediaPlayerDelegate()->has_played_media()), |
| 2494 audio_renderer_sink, media_log, render_thread->GetMediaThreadTaskRunner(), | 2482 audio_renderer_sink, media_log, render_thread->GetMediaThreadTaskRunner(), |
| 2495 render_thread->GetWorkerTaskRunner(), | 2483 render_thread->GetWorkerTaskRunner(), |
| 2496 render_thread->compositor_task_runner(), context_3d_cb, | 2484 render_thread->compositor_task_runner(), context_3d_cb, |
| 2497 base::Bind(&v8::Isolate::AdjustAmountOfExternalAllocatedMemory, | 2485 base::Bind(&v8::Isolate::AdjustAmountOfExternalAllocatedMemory, |
| 2498 base::Unretained(blink::mainThreadIsolate())), | 2486 base::Unretained(blink::mainThreadIsolate())), |
| 2499 GetMediaPermission(), initial_cdm, media_surface_manager_); | 2487 GetMediaPermission(), initial_cdm, media_surface_manager_); |
| 2500 | 2488 |
| 2501 #if defined(OS_ANDROID) | 2489 #if defined(OS_ANDROID) |
| 2502 if (!CanUseWebMediaPlayerImpl(load_type, url)) { | 2490 if (!UseWebMediaPlayerImpl(load_type, url)) |
| 2503 return CreateAndroidWebMediaPlayer(client, encrypted_client, params); | 2491 return CreateAndroidWebMediaPlayer(client, encrypted_client, params); |
| 2504 } else if (!MustUseWebMediaPlayerImpl(load_type, url)) { | |
| 2505 // TODO(dalecurtis): This experiment is temporary and should be removed once | |
| 2506 // we have enough data to support the primacy of the unified media pipeline; | |
| 2507 // see http://crbug.com/533190 for details. | |
| 2508 // | |
| 2509 // Note: It's important to query the field trial state first, to ensure that | |
| 2510 // UMA reports the correct group. | |
| 2511 const std::string group_name = | |
| 2512 base::FieldTrialList::FindFullName("UnifiedMediaPipelineTrial"); | |
| 2513 const bool enabled_via_cli = | |
| 2514 base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 2515 switches::kEnableUnifiedMediaPipeline); | |
| 2516 const bool enable_unified_media_pipeline = | |
| 2517 enabled_via_cli || | |
| 2518 base::StartsWith(group_name, "Enabled", base::CompareCase::SENSITIVE); | |
| 2519 | |
| 2520 if (!enable_unified_media_pipeline) | |
| 2521 return CreateAndroidWebMediaPlayer(client, encrypted_client, params); | |
| 2522 } | |
| 2523 #endif // defined(OS_ANDROID) | 2492 #endif // defined(OS_ANDROID) |
| 2524 | 2493 |
| 2525 #if defined(ENABLE_MOJO_MEDIA) && !defined(OS_ANDROID) | 2494 #if defined(ENABLE_MOJO_MEDIA) && !defined(OS_ANDROID) |
| 2526 scoped_ptr<media::RendererFactory> media_renderer_factory( | 2495 scoped_ptr<media::RendererFactory> media_renderer_factory( |
| 2527 new media::MojoRendererFactory(GetMediaServiceFactory())); | 2496 new media::MojoRendererFactory(GetMediaServiceFactory())); |
| 2528 #else | 2497 #else |
| 2529 scoped_ptr<media::RendererFactory> media_renderer_factory = | 2498 scoped_ptr<media::RendererFactory> media_renderer_factory = |
| 2530 GetContentClient()->renderer()->CreateMediaRendererFactory( | 2499 GetContentClient()->renderer()->CreateMediaRendererFactory( |
| 2531 this, render_thread->GetGpuFactories(), media_log); | 2500 this, render_thread->GetGpuFactories(), media_log); |
| 2532 | 2501 |
| (...skipping 3569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6102 int match_count, | 6071 int match_count, |
| 6103 int ordinal, | 6072 int ordinal, |
| 6104 const WebRect& selection_rect, | 6073 const WebRect& selection_rect, |
| 6105 bool final_status_update) { | 6074 bool final_status_update) { |
| 6106 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count, | 6075 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count, |
| 6107 selection_rect, ordinal, | 6076 selection_rect, ordinal, |
| 6108 final_status_update)); | 6077 final_status_update)); |
| 6109 } | 6078 } |
| 6110 | 6079 |
| 6111 } // namespace content | 6080 } // namespace content |
| OLD | NEW |