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

Side by Side Diff: media/base/media.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: Fix all teh things. 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 "media/base/media.h" 5 #include "media/base/media.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/command_line.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/path_service.h" 10 #include "base/metrics/field_trial.h"
11 #include "base/synchronization/lock.h"
12 #include "base/trace_event/trace_event.h" 11 #include "base/trace_event/trace_event.h"
13 #include "build/build_config.h" 12 #include "media/base/media_switches.h"
14 #include "media/base/yuv_convert.h" 13 #include "media/base/yuv_convert.h"
15 14
15 #if defined(OS_ANDROID)
16 #include "media/base/android/media_codec_util.h"
17 #endif
18
16 #if !defined(MEDIA_DISABLE_FFMPEG) 19 #if !defined(MEDIA_DISABLE_FFMPEG)
17 #include "media/ffmpeg/ffmpeg_common.h" 20 #include "media/ffmpeg/ffmpeg_common.h"
18 #endif 21 #endif
19 22
20 namespace media { 23 namespace media {
21 24
22 // Media must only be initialized once, so use a LazyInstance to ensure this. 25 // Media must only be initialized once, so use a LazyInstance to ensure this.
23 class MediaInitializer { 26 class MediaInitializer {
27 public:
28 void enable_platform_decoder_support() {
29 has_platform_decoder_support_ = true;
30 }
31
32 bool has_platform_decoder_support() { return has_platform_decoder_support_; }
33
24 private: 34 private:
25 friend struct base::DefaultLazyInstanceTraits<MediaInitializer>; 35 friend struct base::DefaultLazyInstanceTraits<MediaInitializer>;
26 36
27 MediaInitializer() { 37 MediaInitializer() {
28 TRACE_EVENT_WARMUP_CATEGORY("audio"); 38 TRACE_EVENT_WARMUP_CATEGORY("audio");
29 TRACE_EVENT_WARMUP_CATEGORY("media"); 39 TRACE_EVENT_WARMUP_CATEGORY("media");
30 40
31 // Perform initialization of libraries which require runtime CPU detection. 41 // Perform initialization of libraries which require runtime CPU detection.
32 InitializeCPUSpecificYUVConversions(); 42 InitializeCPUSpecificYUVConversions();
33 43
(...skipping 10 matching lines...) Expand all
44 av_max_alloc(0); 54 av_max_alloc(0);
45 #endif // defined(ALLOCATOR_SHIM) 55 #endif // defined(ALLOCATOR_SHIM)
46 56
47 #endif // !defined(MEDIA_DISABLE_FFMPEG) 57 #endif // !defined(MEDIA_DISABLE_FFMPEG)
48 } 58 }
49 59
50 ~MediaInitializer() { 60 ~MediaInitializer() {
51 NOTREACHED() << "MediaInitializer should be leaky!"; 61 NOTREACHED() << "MediaInitializer should be leaky!";
52 } 62 }
53 63
64 bool has_platform_decoder_support_ = false;
65
54 DISALLOW_COPY_AND_ASSIGN(MediaInitializer); 66 DISALLOW_COPY_AND_ASSIGN(MediaInitializer);
55 }; 67 };
56 68
57 static base::LazyInstance<MediaInitializer>::Leaky g_media_library = 69 static base::LazyInstance<MediaInitializer>::Leaky g_media_library =
58 LAZY_INSTANCE_INITIALIZER; 70 LAZY_INSTANCE_INITIALIZER;
59 71
60 void InitializeMediaLibrary() { 72 void InitializeMediaLibrary() {
61 g_media_library.Get(); 73 g_media_library.Get();
62 } 74 }
63 75
76 void EnablePlatformDecoderSupport() {
77 g_media_library.Pointer()->enable_platform_decoder_support();
78 }
79
80 bool HasPlatformDecoderSupport() {
81 return g_media_library.Pointer()->has_platform_decoder_support();
82 }
83
84 #if defined(OS_ANDROID)
85 bool IsUnifiedMediaPipelineEnabled() {
86 // TODO(dalecurtis): This experiment is temporary and should be removed once
87 // we have enough data to support the primacy of the unified media pipeline;
88 // see http://crbug.com/533190 for details.
89 //
90 // Note: It's important to query the field trial state first, to ensure that
91 // UMA reports the correct group.
92 const std::string group_name =
93 base::FieldTrialList::FindFullName("UnifiedMediaPipelineTrial");
94 const bool enabled_via_cli =
95 base::CommandLine::ForCurrentProcess()->HasSwitch(
96 switches::kEnableUnifiedMediaPipeline);
97 return enabled_via_cli ||
98 base::StartsWith(group_name, "Enabled", base::CompareCase::SENSITIVE);
99 }
100
101 bool IsUnifiedMediaPipelineEnabledForMse() {
102 // The unified media pipeline is available for MSE even when not normally
ddorwin 2016/02/16 20:34:36 This comment applies to the second half of the con
DaleCurtis 2016/02/17 03:01:05 Removed the comment and put it on the method proto
103 // enabled if the MediaCodec is not available -- since otherwise it would
ddorwin 2016/02/16 20:34:36 This won't work unless you change the path that di
DaleCurtis 2016/02/17 03:01:05 Thanks for the pointer, done!
104 // mean that MSE can't be used at all.
ddorwin 2016/02/16 20:34:37 Codecs that are only supported by the platform (e.
105 return IsUnifiedMediaPipelineEnabled() ||
DaleCurtis 2016/02/13 05:54:28 Just realized this part is wrong. It should not in
DaleCurtis 2016/02/17 03:01:05 Disregard, this seems okay. Don't remember why I w
106 !MediaCodecUtil::IsMediaCodecAvailable();
107 }
108 #endif
109
64 } // namespace media 110 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698