Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef MEDIA_BASE_ANDROID_MEDIA_CODEC_UTIL_H_ | 5 #ifndef MEDIA_BASE_ANDROID_MEDIA_CODEC_UTIL_H_ |
| 6 #define MEDIA_BASE_ANDROID_MEDIA_CODEC_UTIL_H_ | 6 #define MEDIA_BASE_ANDROID_MEDIA_CODEC_UTIL_H_ |
| 7 | 7 |
| 8 #include <jni.h> | 8 #include <jni.h> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "media/base/media_export.h" | 15 #include "media/base/media_export.h" |
| 16 | 16 |
| 17 class GURL; | 17 class GURL; |
| 18 | 18 |
| 19 namespace media { | 19 namespace media { |
| 20 | 20 |
| 21 class MediaCodecBridge; | |
| 22 | |
| 21 // Helper macro to skip the test if MediaCodecBridge isn't available. | 23 // Helper macro to skip the test if MediaCodecBridge isn't available. |
| 22 #define SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE() \ | 24 #define SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE() \ |
| 23 do { \ | 25 do { \ |
| 24 if (!MediaCodecUtil::IsMediaCodecAvailable()) { \ | 26 if (!MediaCodecUtil::IsMediaCodecAvailable()) { \ |
| 25 VLOG(0) << "Could not run test - not supported on device."; \ | 27 VLOG(0) << "Could not run test - not supported on device."; \ |
| 26 return; \ | 28 return; \ |
| 27 } \ | 29 } \ |
| 28 } while (0) | 30 } while (0) |
| 29 | 31 |
| 30 // Codec direction. Keep this in sync with MediaCodecUtil.java. | 32 // Codec direction. Keep this in sync with MediaCodecUtil.java. |
| 31 enum MediaCodecDirection { | 33 enum MediaCodecDirection { |
| 32 MEDIA_CODEC_DECODER, | 34 MEDIA_CODEC_DECODER, |
| 33 MEDIA_CODEC_ENCODER, | 35 MEDIA_CODEC_ENCODER, |
| 34 }; | 36 }; |
| 35 | 37 |
| 36 class MEDIA_EXPORT MediaCodecUtil { | 38 class MEDIA_EXPORT MediaCodecUtil { |
| 37 public: | 39 public: |
| 38 // Returns true if MediaCodec is available on the device. | 40 // Returns true if MediaCodec is available on the device. |
| 39 // All other static methods check IsAvailable() internally. There's no need | 41 // All other static methods check IsAvailable() internally. There's no need |
| 40 // to check IsAvailable() explicitly before calling them. | 42 // to check IsAvailable() explicitly before calling them. |
| 41 static bool IsMediaCodecAvailable(); | 43 static bool IsMediaCodecAvailable(); |
| 42 | 44 |
| 45 // Returns the component name of the decoder that will be created for the | |
|
DaleCurtis
2016/04/23 19:06:21
I don't like exposing the codec name getter, since
| |
| 46 // given |mime_type| and |direction|. | |
| 47 static std::string GetDefaultCodecName(const std::string& mime_type, | |
| 48 MediaCodecDirection direction); | |
| 49 | |
| 43 // Returns true if MediaCodec.setParameters() is available on the device. | 50 // Returns true if MediaCodec.setParameters() is available on the device. |
| 44 static bool SupportsSetParameters(); | 51 static bool SupportsSetParameters(); |
| 45 | 52 |
| 46 // Returns whether MediaCodecBridge has a decoder that |is_secure| and can | 53 // Returns whether MediaCodecBridge has a decoder that |is_secure| and can |
| 47 // decode |codec| type. | 54 // decode |codec| type. |
| 48 static bool CanDecode(const std::string& codec, bool is_secure); | 55 static bool CanDecode(const std::string& codec, bool is_secure); |
| 49 | 56 |
| 50 // Get a list of encoder supported color formats for |mime_type|. | 57 // Get a list of encoder supported color formats for |mime_type|. |
| 51 // The mapping of color format name and its value refers to | 58 // The mapping of color format name and its value refers to |
| 52 // MediaCodecInfo.CodecCapabilities. | 59 // MediaCodecInfo.CodecCapabilities. |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 68 | 75 |
| 69 // Indicates if the vp8 decoder or encoder is available on this device. | 76 // Indicates if the vp8 decoder or encoder is available on this device. |
| 70 static bool IsVp8DecoderAvailable(); | 77 static bool IsVp8DecoderAvailable(); |
| 71 static bool IsVp8EncoderAvailable(); | 78 static bool IsVp8EncoderAvailable(); |
| 72 | 79 |
| 73 // Indicates if the vp9 decoder is available on this device. | 80 // Indicates if the vp9 decoder is available on this device. |
| 74 static bool IsVp9DecoderAvailable(); | 81 static bool IsVp9DecoderAvailable(); |
| 75 | 82 |
| 76 // Indicates if SurfaceView and MediaCodec work well together on this device. | 83 // Indicates if SurfaceView and MediaCodec work well together on this device. |
| 77 static bool IsSurfaceViewOutputSupported(); | 84 static bool IsSurfaceViewOutputSupported(); |
| 85 | |
| 86 // Indicates if the decoder is known to fail when flushed. (b/8125974, | |
| 87 // b/8347958) | |
| 88 // When true, the client should work around the issue by releasing the | |
| 89 // decoder and instantiating a new one rather than flushing the current one. | |
| 90 static bool CodecNeedsFlushWorkaround(MediaCodecBridge* codec); | |
| 78 }; | 91 }; |
| 79 | 92 |
| 80 } // namespace media | 93 } // namespace media |
| 81 | 94 |
| 82 #endif // MEDIA_BASE_ANDROID_MEDIA_CODEC_UTIL_H_ | 95 #endif // MEDIA_BASE_ANDROID_MEDIA_CODEC_UTIL_H_ |
| OLD | NEW |