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

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: Simplify, test, rebase on split. 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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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 a codec we can't decode in
769 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 761 // software and hardware decoders are not available.
770 switches::kEnableUnifiedMediaPipeline)) { 762 if (base::EndsWith(url.path(), ".mp4",
771 return true; 763 base::CompareCase::INSENSITIVE_ASCII) &&
764 !media::HasPlatformDecoderSupport()) {
765 return false;
772 } 766 }
773 767
774 // WMPI can always play WebM (via libvpx). 768 // Otherwise enable WMPI if indicated via experiment or command line.
775 if (base::EndsWith(url.path(), ".webm", base::CompareCase::INSENSITIVE_ASCII)) 769 return media::IsUnifiedMediaPipelineEnabled();
776 return true;
777
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 } 770 }
783 #endif // defined(OS_ANDROID) 771 #endif // defined(OS_ANDROID)
784 772
785 } // namespace 773 } // namespace
786 774
787 // static 775 // static
788 RenderFrameImpl* RenderFrameImpl::Create(RenderViewImpl* render_view, 776 RenderFrameImpl* RenderFrameImpl::Create(RenderViewImpl* render_view,
789 int32_t routing_id) { 777 int32_t routing_id) {
790 DCHECK(routing_id != MSG_ROUTING_NONE); 778 DCHECK(routing_id != MSG_ROUTING_NONE);
791 CreateParams params(render_view, routing_id); 779 CreateParams params(render_view, routing_id);
(...skipping 1694 matching lines...) Expand 10 before | Expand all | Expand 10 after
2486 static_cast<RenderFrame*>(this), 2474 static_cast<RenderFrame*>(this),
2487 GetWebMediaPlayerDelegate()->has_played_media()), 2475 GetWebMediaPlayerDelegate()->has_played_media()),
2488 audio_renderer_sink, media_log, render_thread->GetMediaThreadTaskRunner(), 2476 audio_renderer_sink, media_log, render_thread->GetMediaThreadTaskRunner(),
2489 render_thread->GetWorkerTaskRunner(), 2477 render_thread->GetWorkerTaskRunner(),
2490 render_thread->compositor_task_runner(), context_3d_cb, 2478 render_thread->compositor_task_runner(), context_3d_cb,
2491 base::Bind(&v8::Isolate::AdjustAmountOfExternalAllocatedMemory, 2479 base::Bind(&v8::Isolate::AdjustAmountOfExternalAllocatedMemory,
2492 base::Unretained(blink::mainThreadIsolate())), 2480 base::Unretained(blink::mainThreadIsolate())),
2493 GetMediaPermission(), initial_cdm); 2481 GetMediaPermission(), initial_cdm);
2494 2482
2495 #if defined(OS_ANDROID) 2483 #if defined(OS_ANDROID)
2496 if (!CanUseWebMediaPlayerImpl(load_type, url)) { 2484 if (!UseWebMediaPlayerImpl(load_type, url))
2497 return CreateAndroidWebMediaPlayer(client, encrypted_client, params); 2485 return CreateAndroidWebMediaPlayer(client, encrypted_client, params);
2498 } else if (!MustUseWebMediaPlayerImpl(load_type, url)) {
2499 // TODO(dalecurtis): This experiment is temporary and should be removed once
2500 // we have enough data to support the primacy of the unified media pipeline;
2501 // see http://crbug.com/533190 for details.
2502 //
2503 // Note: It's important to query the field trial state first, to ensure that
2504 // UMA reports the correct group.
2505 const std::string group_name =
2506 base::FieldTrialList::FindFullName("UnifiedMediaPipelineTrial");
2507 const bool enabled_via_cli =
2508 base::CommandLine::ForCurrentProcess()->HasSwitch(
2509 switches::kEnableUnifiedMediaPipeline);
2510 const bool enable_unified_media_pipeline =
2511 enabled_via_cli ||
2512 base::StartsWith(group_name, "Enabled", base::CompareCase::SENSITIVE);
2513
2514 if (!enable_unified_media_pipeline)
2515 return CreateAndroidWebMediaPlayer(client, encrypted_client, params);
2516 }
2517 #endif // defined(OS_ANDROID) 2486 #endif // defined(OS_ANDROID)
2518 2487
2519 #if defined(ENABLE_MOJO_MEDIA) && !defined(OS_ANDROID) 2488 #if defined(ENABLE_MOJO_MEDIA) && !defined(OS_ANDROID)
2520 scoped_ptr<media::RendererFactory> media_renderer_factory( 2489 scoped_ptr<media::RendererFactory> media_renderer_factory(
2521 new media::MojoRendererFactory(GetMediaServiceFactory())); 2490 new media::MojoRendererFactory(GetMediaServiceFactory()));
2522 #else 2491 #else
2523 scoped_ptr<media::RendererFactory> media_renderer_factory = 2492 scoped_ptr<media::RendererFactory> media_renderer_factory =
2524 GetContentClient()->renderer()->CreateMediaRendererFactory( 2493 GetContentClient()->renderer()->CreateMediaRendererFactory(
2525 this, render_thread->GetGpuFactories(), media_log); 2494 this, render_thread->GetGpuFactories(), media_log);
2526 2495
(...skipping 3594 matching lines...) Expand 10 before | Expand all | Expand 10 after
6121 int match_count, 6090 int match_count,
6122 int ordinal, 6091 int ordinal,
6123 const WebRect& selection_rect, 6092 const WebRect& selection_rect,
6124 bool final_status_update) { 6093 bool final_status_update) {
6125 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count, 6094 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count,
6126 selection_rect, ordinal, 6095 selection_rect, ordinal,
6127 final_status_update)); 6096 final_status_update));
6128 } 6097 }
6129 6098
6130 } // namespace content 6099 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698