Chromium Code Reviews| Index: media/base/media.cc |
| diff --git a/media/base/media.cc b/media/base/media.cc |
| index f55d1c437a5bf6e3baee3b23a10355ce635153de..6b04d0b00e4c52decfb7f92dcf15db8b748a6581 100644 |
| --- a/media/base/media.cc |
| +++ b/media/base/media.cc |
| @@ -4,15 +4,19 @@ |
| #include "media/base/media.h" |
| -#include "base/files/file_path.h" |
| +#include "base/command_line.h" |
| #include "base/lazy_instance.h" |
| #include "base/macros.h" |
| -#include "base/path_service.h" |
| -#include "base/synchronization/lock.h" |
| +#include "base/metrics/field_trial.h" |
| #include "base/trace_event/trace_event.h" |
| -#include "build/build_config.h" |
| +#include "media/base/media_switches.h" |
| #include "media/base/yuv_convert.h" |
| +#if defined(OS_ANDROID) |
| +#include "base/android/build_info.h" |
| +#include "media/base/android/media_codec_util.h" |
| +#endif |
| + |
| #if !defined(MEDIA_DISABLE_FFMPEG) |
| #include "media/ffmpeg/ffmpeg_common.h" |
| #endif |
| @@ -21,6 +25,13 @@ namespace media { |
| // Media must only be initialized once, so use a LazyInstance to ensure this. |
| class MediaInitializer { |
| + public: |
| + void enable_platform_decoder_support() { |
| + has_platform_decoder_support_ = true; |
| + } |
| + |
| + bool has_platform_decoder_support() { return has_platform_decoder_support_; } |
| + |
| private: |
| friend struct base::DefaultLazyInstanceTraits<MediaInitializer>; |
| @@ -51,6 +62,8 @@ class MediaInitializer { |
| NOTREACHED() << "MediaInitializer should be leaky!"; |
| } |
| + bool has_platform_decoder_support_ = false; |
| + |
| DISALLOW_COPY_AND_ASSIGN(MediaInitializer); |
| }; |
| @@ -61,4 +74,43 @@ void InitializeMediaLibrary() { |
| g_media_library.Get(); |
| } |
| +#if defined(OS_ANDROID) |
| +void EnablePlatformDecoderSupport() { |
| + g_media_library.Pointer()->enable_platform_decoder_support(); |
| +} |
| + |
| +bool HasPlatformDecoderSupport() { |
| + return g_media_library.Pointer()->has_platform_decoder_support(); |
| +} |
| + |
| +bool PlatformHasOpusSupport() { |
| + return base::android::BuildInfo::GetInstance()->sdk_int() >= 21; |
| +} |
| + |
| +bool PlatformHasVp9Support() { |
| + return base::android::BuildInfo::GetInstance()->sdk_int() >= 19; |
| +} |
| + |
| +bool IsUnifiedMediaPipelineEnabled() { |
| + // TODO(dalecurtis): This experiment is temporary and should be removed once |
| + // we have enough data to support the primacy of the unified media pipeline; |
| + // see http://crbug.com/533190 for details. |
| + // |
| + // Note: It's important to query the field trial state first, to ensure that |
| + // UMA reports the correct group. |
| + const std::string group_name = |
| + base::FieldTrialList::FindFullName("UnifiedMediaPipelineTrial"); |
| + const bool enabled_via_cli = |
| + base::CommandLine::ForCurrentProcess()->HasSwitch( |
| + switches::kEnableUnifiedMediaPipeline); |
| + return enabled_via_cli || |
| + base::StartsWith(group_name, "Enabled", base::CompareCase::SENSITIVE); |
| +} |
| + |
| +bool IsUnifiedMediaPipelineEnabledForMse() { |
| + 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
|
| + !MediaCodecUtil::IsMediaCodecAvailable(); |
| +} |
| +#endif |
| + |
| } // namespace media |