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

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: 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 "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 "base/android/build_info.h"
17 #include "media/base/android/media_codec_util.h"
18 #endif
19
16 #if !defined(MEDIA_DISABLE_FFMPEG) 20 #if !defined(MEDIA_DISABLE_FFMPEG)
17 #include "media/ffmpeg/ffmpeg_common.h" 21 #include "media/ffmpeg/ffmpeg_common.h"
18 #endif 22 #endif
19 23
20 namespace media { 24 namespace media {
21 25
22 // Media must only be initialized once, so use a LazyInstance to ensure this. 26 // Media must only be initialized once, so use a LazyInstance to ensure this.
23 class MediaInitializer { 27 class MediaInitializer {
28 public:
29 void enable_platform_decoder_support() {
30 has_platform_decoder_support_ = true;
31 }
32
33 bool has_platform_decoder_support() { return has_platform_decoder_support_; }
34
24 private: 35 private:
25 friend struct base::DefaultLazyInstanceTraits<MediaInitializer>; 36 friend struct base::DefaultLazyInstanceTraits<MediaInitializer>;
26 37
27 MediaInitializer() { 38 MediaInitializer() {
28 TRACE_EVENT_WARMUP_CATEGORY("audio"); 39 TRACE_EVENT_WARMUP_CATEGORY("audio");
29 TRACE_EVENT_WARMUP_CATEGORY("media"); 40 TRACE_EVENT_WARMUP_CATEGORY("media");
30 41
31 // Perform initialization of libraries which require runtime CPU detection. 42 // Perform initialization of libraries which require runtime CPU detection.
32 InitializeCPUSpecificYUVConversions(); 43 InitializeCPUSpecificYUVConversions();
33 44
(...skipping 10 matching lines...) Expand all
44 av_max_alloc(0); 55 av_max_alloc(0);
45 #endif // defined(ALLOCATOR_SHIM) 56 #endif // defined(ALLOCATOR_SHIM)
46 57
47 #endif // !defined(MEDIA_DISABLE_FFMPEG) 58 #endif // !defined(MEDIA_DISABLE_FFMPEG)
48 } 59 }
49 60
50 ~MediaInitializer() { 61 ~MediaInitializer() {
51 NOTREACHED() << "MediaInitializer should be leaky!"; 62 NOTREACHED() << "MediaInitializer should be leaky!";
52 } 63 }
53 64
65 bool has_platform_decoder_support_ = false;
66
54 DISALLOW_COPY_AND_ASSIGN(MediaInitializer); 67 DISALLOW_COPY_AND_ASSIGN(MediaInitializer);
55 }; 68 };
56 69
57 static base::LazyInstance<MediaInitializer>::Leaky g_media_library = 70 static base::LazyInstance<MediaInitializer>::Leaky g_media_library =
58 LAZY_INSTANCE_INITIALIZER; 71 LAZY_INSTANCE_INITIALIZER;
59 72
60 void InitializeMediaLibrary() { 73 void InitializeMediaLibrary() {
61 g_media_library.Get(); 74 g_media_library.Get();
62 } 75 }
63 76
77 #if defined(OS_ANDROID)
78 void EnablePlatformDecoderSupport() {
79 g_media_library.Pointer()->enable_platform_decoder_support();
80 }
81
82 bool HasPlatformDecoderSupport() {
83 return g_media_library.Pointer()->has_platform_decoder_support();
84 }
85
86 bool PlatformHasOpusSupport() {
87 return base::android::BuildInfo::GetInstance()->sdk_int() >= 21;
88 }
89
90 bool PlatformHasVp9Support() {
91 return base::android::BuildInfo::GetInstance()->sdk_int() >= 19;
92 }
93
94 bool IsUnifiedMediaPipelineEnabled() {
95 // TODO(dalecurtis): This experiment is temporary and should be removed once
96 // we have enough data to support the primacy of the unified media pipeline;
97 // see http://crbug.com/533190 for details.
98 //
99 // Note: It's important to query the field trial state first, to ensure that
100 // UMA reports the correct group.
101 const std::string group_name =
102 base::FieldTrialList::FindFullName("UnifiedMediaPipelineTrial");
103 const bool enabled_via_cli =
104 base::CommandLine::ForCurrentProcess()->HasSwitch(
105 switches::kEnableUnifiedMediaPipeline);
106 return enabled_via_cli ||
107 base::StartsWith(group_name, "Enabled", base::CompareCase::SENSITIVE);
108 }
109
110 bool IsUnifiedMediaPipelineEnabledForMse() {
111 return IsUnifiedMediaPipelineEnabled() ||
sandersd (OOO until July 31) 2016/02/19 21:07:12 We should probably rely on the command line flag u
DaleCurtis 2016/02/19 21:09:55 Good catch. This was what my comment last Friday w
112 !MediaCodecUtil::IsMediaCodecAvailable();
113 }
114 #endif
115
64 } // namespace media 116 } // namespace media
OLDNEW
« no previous file with comments | « media/base/media.h ('k') | media/base/mime_util.h » ('j') | media/base/mime_util_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698