| Index: media/base/media.cc
|
| diff --git a/media/base/media.cc b/media/base/media.cc
|
| index f55d1c437a5bf6e3baee3b23a10355ce635153de..efc495b682e3150fd0d40496d5859e13d5dc5d82 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,47 @@ 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() {
|
| + // Don't check IsUnifiedMediaPipelineEnabled() here since we don't want MSE to
|
| + // be enabled via experiment yet; only when the existing implementation can't
|
| + // be used (i.e. MediaCodec unavailable).
|
| + return base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| + switches::kEnableUnifiedMediaPipeline) ||
|
| + !MediaCodecUtil::IsMediaCodecAvailable();
|
| +}
|
| +#endif
|
| +
|
| } // namespace media
|
|
|