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

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

Issue 1690063002: Fix mime type mappings when the unified media pipeline is enabled. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments. Fix vp8 inversion. Fix vp9 exclusion. Fix hevc. Created 4 years, 10 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
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 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 #include "content/renderer/stats_collection_controller.h" 124 #include "content/renderer/stats_collection_controller.h"
125 #include "content/renderer/usb/web_usb_client_impl.h" 125 #include "content/renderer/usb/web_usb_client_impl.h"
126 #include "content/renderer/wake_lock/wake_lock_dispatcher.h" 126 #include "content/renderer/wake_lock/wake_lock_dispatcher.h"
127 #include "content/renderer/web_frame_utils.h" 127 #include "content/renderer/web_frame_utils.h"
128 #include "content/renderer/web_ui_extension.h" 128 #include "content/renderer/web_ui_extension.h"
129 #include "content/renderer/websharedworker_proxy.h" 129 #include "content/renderer/websharedworker_proxy.h"
130 #include "crypto/sha2.h" 130 #include "crypto/sha2.h"
131 #include "gin/modules/module_registry.h" 131 #include "gin/modules/module_registry.h"
132 #include "media/audio/audio_output_device.h" 132 #include "media/audio/audio_output_device.h"
133 #include "media/base/audio_renderer_mixer_input.h" 133 #include "media/base/audio_renderer_mixer_input.h"
134 #include "media/base/media.h"
134 #include "media/base/media_log.h" 135 #include "media/base/media_log.h"
135 #include "media/base/media_switches.h" 136 #include "media/base/media_switches.h"
136 #include "media/blink/url_index.h" 137 #include "media/blink/url_index.h"
137 #include "media/blink/webencryptedmediaclient_impl.h" 138 #include "media/blink/webencryptedmediaclient_impl.h"
138 #include "media/blink/webmediaplayer_impl.h" 139 #include "media/blink/webmediaplayer_impl.h"
139 #include "media/renderers/gpu_video_accelerator_factories.h" 140 #include "media/renderers/gpu_video_accelerator_factories.h"
140 #include "mojo/common/url_type_converters.h" 141 #include "mojo/common/url_type_converters.h"
141 #include "mojo/edk/js/core.h" 142 #include "mojo/edk/js/core.h"
142 #include "mojo/edk/js/support.h" 143 #include "mojo/edk/js/support.h"
143 #include "net/base/data_url.h" 144 #include "net/base/data_url.h"
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 main_resource_ssl_status.security_style != 741 main_resource_ssl_status.security_style !=
741 ssl_status.security_style || 742 ssl_status.security_style ||
742 main_resource_ssl_status.cert_id != ssl_status.cert_id || 743 main_resource_ssl_status.cert_id != ssl_status.cert_id ||
743 main_resource_ssl_status.cert_status != ssl_status.cert_status || 744 main_resource_ssl_status.cert_status != ssl_status.cert_status ||
744 main_resource_ssl_status.security_bits != ssl_status.security_bits || 745 main_resource_ssl_status.security_bits != ssl_status.security_bits ||
745 main_resource_ssl_status.connection_status != 746 main_resource_ssl_status.connection_status !=
746 ssl_status.connection_status); 747 ssl_status.connection_status);
747 } 748 }
748 749
749 #if defined(OS_ANDROID) 750 #if defined(OS_ANDROID)
750 // Returns true if WMPI must be used for playback because WMPA will not work. 751 // Returns true if WMPI should be used for playback, false otherwise.
751 bool MustUseWebMediaPlayerImpl(blink::WebMediaPlayer::LoadType load_type,
752 const GURL& url) {
753 // WMPA can't play MSE if MediaCodec is unavailable. In this case WMPI may
754 // still work (via libvpx).
755 return (load_type == blink::WebMediaPlayer::LoadTypeMediaSource &&
756 !media::MediaCodecUtil::IsMediaCodecAvailable());
757 }
758
759 // Returns true if WMPI can be used for playback, false if it may not work.
760 // 752 //
761 // Note that HLS and WebM detection are pre-redirect and path-based. It is 753 // Note that HLS and MP4 detection are pre-redirect and path-based. It is
762 // possible to load such a URL and find different content. 754 // possible to load such a URL and find different content.
763 bool CanUseWebMediaPlayerImpl(blink::WebMediaPlayer::LoadType load_type, 755 bool UseWebMediaPlayerImpl(blink::WebMediaPlayer::LoadType load_type,
764 const GURL& url) { 756 const GURL& url) {
765 if (MustUseWebMediaPlayerImpl(load_type, url)) 757 if (load_type == blink::WebMediaPlayer::LoadTypeMediaSource)
766 return true; 758 return media::IsUnifiedMediaPipelineEnabledForMse();
767 759
768 // WMPI does not support HLS. 760 // WMPI does not support HLS.
769 if (media::MediaCodecUtil::IsHLSPath(url)) 761 if (media::MediaCodecUtil::IsHLSPath(url))
770 return false; 762 return false;
771 763
772 // Otherwise --enable-unified-media-pipeline always enables WMPI. 764 // Don't use WMPI if the container likely contains a codec we can't decode in
773 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 765 // software and hardware decoders are not available.
774 switches::kEnableUnifiedMediaPipeline)) { 766 if (base::EndsWith(url.path(), ".mp4",
775 return true; 767 base::CompareCase::INSENSITIVE_ASCII) &&
768 !media::HasPlatformDecoderSupport()) {
769 return false;
776 } 770 }
777 771
778 // WMPI can always play WebM (via libvpx). 772 // Otherwise enable WMPI if indicated via experiment or command line.
779 if (base::EndsWith(url.path(), ".webm", base::CompareCase::INSENSITIVE_ASCII)) 773 return media::IsUnifiedMediaPipelineEnabled();
780 return true;
781
782 // Otherwise, WMPI can only be used if AVDA is working.
783 return (!base::CommandLine::ForCurrentProcess()->HasSwitch(
784 switches::kDisableAcceleratedVideoDecode) &&
785 media::MediaCodecUtil::IsMediaCodecAvailable());
786 } 774 }
787 #endif // defined(OS_ANDROID) 775 #endif // defined(OS_ANDROID)
788 776
789 } // namespace 777 } // namespace
790 778
791 // static 779 // static
792 RenderFrameImpl* RenderFrameImpl::Create(RenderViewImpl* render_view, 780 RenderFrameImpl* RenderFrameImpl::Create(RenderViewImpl* render_view,
793 int32_t routing_id) { 781 int32_t routing_id) {
794 DCHECK(routing_id != MSG_ROUTING_NONE); 782 DCHECK(routing_id != MSG_ROUTING_NONE);
795 CreateParams params(render_view, routing_id); 783 CreateParams params(render_view, routing_id);
(...skipping 1700 matching lines...) Expand 10 before | Expand all | Expand 10 after
2496 static_cast<RenderFrame*>(this), 2484 static_cast<RenderFrame*>(this),
2497 GetWebMediaPlayerDelegate()->has_played_media()), 2485 GetWebMediaPlayerDelegate()->has_played_media()),
2498 audio_renderer_sink, media_log, render_thread->GetMediaThreadTaskRunner(), 2486 audio_renderer_sink, media_log, render_thread->GetMediaThreadTaskRunner(),
2499 render_thread->GetWorkerTaskRunner(), 2487 render_thread->GetWorkerTaskRunner(),
2500 render_thread->compositor_task_runner(), context_3d_cb, 2488 render_thread->compositor_task_runner(), context_3d_cb,
2501 base::Bind(&v8::Isolate::AdjustAmountOfExternalAllocatedMemory, 2489 base::Bind(&v8::Isolate::AdjustAmountOfExternalAllocatedMemory,
2502 base::Unretained(blink::mainThreadIsolate())), 2490 base::Unretained(blink::mainThreadIsolate())),
2503 GetMediaPermission(), initial_cdm, media_surface_manager_); 2491 GetMediaPermission(), initial_cdm, media_surface_manager_);
2504 2492
2505 #if defined(OS_ANDROID) 2493 #if defined(OS_ANDROID)
2506 if (!CanUseWebMediaPlayerImpl(load_type, url)) { 2494 if (!UseWebMediaPlayerImpl(load_type, url))
2507 return CreateAndroidWebMediaPlayer(client, encrypted_client, params); 2495 return CreateAndroidWebMediaPlayer(client, encrypted_client, params);
2508 } else if (!MustUseWebMediaPlayerImpl(load_type, url)) {
2509 // TODO(dalecurtis): This experiment is temporary and should be removed once
2510 // we have enough data to support the primacy of the unified media pipeline;
2511 // see http://crbug.com/533190 for details.
2512 //
2513 // Note: It's important to query the field trial state first, to ensure that
2514 // UMA reports the correct group.
2515 const std::string group_name =
2516 base::FieldTrialList::FindFullName("UnifiedMediaPipelineTrial");
2517 const bool enabled_via_cli =
2518 base::CommandLine::ForCurrentProcess()->HasSwitch(
2519 switches::kEnableUnifiedMediaPipeline);
2520 const bool enable_unified_media_pipeline =
2521 enabled_via_cli ||
2522 base::StartsWith(group_name, "Enabled", base::CompareCase::SENSITIVE);
2523
2524 if (!enable_unified_media_pipeline)
2525 return CreateAndroidWebMediaPlayer(client, encrypted_client, params);
2526 }
2527 #endif // defined(OS_ANDROID) 2496 #endif // defined(OS_ANDROID)
2528 2497
2529 #if defined(ENABLE_MOJO_RENDERER) 2498 #if defined(ENABLE_MOJO_RENDERER)
2530 scoped_ptr<media::RendererFactory> media_renderer_factory( 2499 scoped_ptr<media::RendererFactory> media_renderer_factory(
2531 new media::MojoRendererFactory(GetMediaServiceFactory())); 2500 new media::MojoRendererFactory(GetMediaServiceFactory()));
2532 #else 2501 #else
2533 scoped_ptr<media::RendererFactory> media_renderer_factory = 2502 scoped_ptr<media::RendererFactory> media_renderer_factory =
2534 GetContentClient()->renderer()->CreateMediaRendererFactory( 2503 GetContentClient()->renderer()->CreateMediaRendererFactory(
2535 this, render_thread->GetGpuFactories(), media_log); 2504 this, render_thread->GetGpuFactories(), media_log);
2536 2505
(...skipping 3565 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698