| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef MEDIA_BASE_ANDROID_MEDIA_CODEC_UTIL_H_ | |
| 6 #define MEDIA_BASE_ANDROID_MEDIA_CODEC_UTIL_H_ | |
| 7 | |
| 8 #include <jni.h> | |
| 9 #include <set> | |
| 10 #include <string> | |
| 11 #include <vector> | |
| 12 | |
| 13 #include "base/compiler_specific.h" | |
| 14 #include "base/macros.h" | |
| 15 #include "media/base/media_export.h" | |
| 16 | |
| 17 namespace media { | |
| 18 | |
| 19 // Helper macro to skip the test if MediaCodecBridge isn't available. | |
| 20 #define SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE() \ | |
| 21 do { \ | |
| 22 if (!MediaCodecUtil::IsMediaCodecAvailable()) { \ | |
| 23 VLOG(0) << "Could not run test - not supported on device."; \ | |
| 24 return; \ | |
| 25 } \ | |
| 26 } while (0) | |
| 27 | |
| 28 // Codec direction. Keep this in sync with MediaCodecUtil.java. | |
| 29 enum MediaCodecDirection { | |
| 30 MEDIA_CODEC_DECODER, | |
| 31 MEDIA_CODEC_ENCODER, | |
| 32 }; | |
| 33 | |
| 34 class MEDIA_EXPORT MediaCodecUtil { | |
| 35 public: | |
| 36 // Returns true if MediaCodec is available on the device. | |
| 37 // All other static methods check IsAvailable() internally. There's no need | |
| 38 // to check IsAvailable() explicitly before calling them. | |
| 39 static bool IsMediaCodecAvailable(); | |
| 40 | |
| 41 // Returns true if MediaCodec.setParameters() is available on the device. | |
| 42 static bool SupportsSetParameters(); | |
| 43 | |
| 44 // Returns whether MediaCodecBridge has a decoder that |is_secure| and can | |
| 45 // decode |codec| type. | |
| 46 static bool CanDecode(const std::string& codec, bool is_secure); | |
| 47 | |
| 48 // Get a list of encoder supported color formats for |mime_type|. | |
| 49 // The mapping of color format name and its value refers to | |
| 50 // MediaCodecInfo.CodecCapabilities. | |
| 51 static std::set<int> GetEncoderColorFormats(const std::string& mime_type); | |
| 52 | |
| 53 // Returns true if |mime_type| is known to be unaccelerated (i.e. backed by a | |
| 54 // software codec instead of a hardware one). | |
| 55 static bool IsKnownUnaccelerated(const std::string& mime_type, | |
| 56 MediaCodecDirection direction); | |
| 57 | |
| 58 static bool RegisterMediaCodecUtil(JNIEnv* env); | |
| 59 }; | |
| 60 | |
| 61 } // namespace media | |
| 62 | |
| 63 #endif // MEDIA_BASE_ANDROID_MEDIA_CODEC_UTIL_H_ | |
| OLD | NEW |