OLD | NEW |
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/files/file_path.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/path_service.h" |
11 #include "base/synchronization/lock.h" | 11 #include "base/synchronization/lock.h" |
12 #include "base/trace_event/trace_event.h" | 12 #include "base/trace_event/trace_event.h" |
13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
14 #include "media/base/yuv_convert.h" | 14 #include "media/base/yuv_convert.h" |
15 | 15 |
16 #if !defined(MEDIA_DISABLE_FFMPEG) | 16 #if !defined(MEDIA_DISABLE_FFMPEG) |
17 #include "media/ffmpeg/ffmpeg_common.h" | 17 #include "media/ffmpeg/ffmpeg_common.h" |
| 18 #include "media/filters/ffmpeg_audio_decoder.h" |
| 19 #include "media/filters/ffmpeg_video_decoder.h" |
18 #endif | 20 #endif |
19 | 21 |
20 namespace media { | 22 namespace media { |
21 | 23 |
22 // Media must only be initialized once, so use a LazyInstance to ensure this. | 24 // Media must only be initialized once, so use a LazyInstance to ensure this. |
23 class MediaInitializer { | 25 class MediaInitializer { |
24 private: | 26 private: |
25 friend struct base::DefaultLazyInstanceTraits<MediaInitializer>; | 27 friend struct base::DefaultLazyInstanceTraits<MediaInitializer>; |
26 | 28 |
27 MediaInitializer() { | 29 MediaInitializer() { |
(...skipping 26 matching lines...) Expand all Loading... |
54 DISALLOW_COPY_AND_ASSIGN(MediaInitializer); | 56 DISALLOW_COPY_AND_ASSIGN(MediaInitializer); |
55 }; | 57 }; |
56 | 58 |
57 static base::LazyInstance<MediaInitializer>::Leaky g_media_library = | 59 static base::LazyInstance<MediaInitializer>::Leaky g_media_library = |
58 LAZY_INSTANCE_INITIALIZER; | 60 LAZY_INSTANCE_INITIALIZER; |
59 | 61 |
60 void InitializeMediaLibrary() { | 62 void InitializeMediaLibrary() { |
61 g_media_library.Get(); | 63 g_media_library.Get(); |
62 } | 64 } |
63 | 65 |
| 66 bool IsAudioCodecSupported(AudioCodec codec) { |
| 67 // Opus is always enabled. |
| 68 if (codec == media::kCodecOpus) |
| 69 return true; |
| 70 |
| 71 #if !defined(MEDIA_DISABLE_FFMPEG) && !defined(DISABLE_FFMPEG_AUDIO_DECODERS) |
| 72 return media::FFmpegAudioDecoder::IsCodecSupported(codec, |
| 73 kUnknownSampleFormat); |
| 74 #else |
| 75 return false; |
| 76 #endif |
| 77 } |
| 78 |
| 79 bool IsVideoCodecSupported(VideoCodec codec) { |
| 80 #if !defined(MEDIA_DISABLE_LIBVPX) |
| 81 if (codec == media::kCodecVP9) |
| 82 return true; |
| 83 #endif |
| 84 |
| 85 #if !defined(MEDIA_DISABLE_FFMPEG) && !defined(DISABLE_FFMPEG_VIDEO_DECODERS) |
| 86 return media::FFmpegVideoDecoder::IsCodecSupported(codec); |
| 87 #else |
| 88 return false; |
| 89 #endif |
| 90 } |
| 91 |
64 } // namespace media | 92 } // namespace media |
OLD | NEW |