Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(64)

Side by Side Diff: media/base/android/media_codec_util.h

Issue 2697643003: media: Clean up MediaCodecBridge and remove subclasses (Closed)
Patch Set: Remove static initializers (thanks to dale's suggestion) Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/android/media_codec_direction.h" 15 #include "media/base/android/media_codec_direction.h"
16 #include "media/base/audio_codecs.h"
16 #include "media/base/media_export.h" 17 #include "media/base/media_export.h"
17 #include "media/base/video_codecs.h" 18 #include "media/base/video_codecs.h"
18 19
19 class GURL; 20 class GURL;
20 21
21 namespace media { 22 namespace media {
22 23
24 namespace mime_type {
25 extern const char kMp3[];
26 extern const char kAac[];
27 extern const char kOpus[];
28 extern const char kVorbis[];
29 extern const char kAc3[];
30 extern const char kEac3[];
31 extern const char kAvc[];
32 extern const char kHevc[];
33 extern const char kVp8[];
34 extern const char kVp9[];
35 }
36
23 class MediaCodecBridge; 37 class MediaCodecBridge;
24 38
25 // Helper macro to skip the test if MediaCodecBridge isn't available.
26 #define SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE() \
27 do { \
28 if (!MediaCodecUtil::IsMediaCodecAvailable()) { \
29 VLOG(0) << "Could not run test - not supported on device."; \
30 return; \
31 } \
32 } while (0)
33
34 // Helper macro to skip the test if VP8 decoding isn't supported.
35 #define SKIP_TEST_IF_VP8_DECODER_IS_NOT_SUPPORTED() \
36 do { \
37 if (!MediaCodecUtil::IsVp8DecoderAvailable()) { \
38 VLOG(0) << "Could not run test - not supported on device."; \
39 return; \
40 } \
41 } while (0)
42
43 class MEDIA_EXPORT MediaCodecUtil { 39 class MEDIA_EXPORT MediaCodecUtil {
44 public: 40 public:
41 static std::string CodecToAndroidMimeType(AudioCodec codec);
42 static std::string CodecToAndroidMimeType(VideoCodec codec);
43
45 // Returns true if MediaCodec is available on the device. 44 // Returns true if MediaCodec is available on the device.
46 // All other static methods check IsAvailable() internally. There's no need 45 // All other static methods check IsAvailable() internally. There's no need
47 // to check IsAvailable() explicitly before calling them. 46 // to check IsAvailable() explicitly before calling them.
48 static bool IsMediaCodecAvailable(); 47 static bool IsMediaCodecAvailable();
49 48
50 // Returns true if MediaCodec.setParameters() is available on the device. 49 // Returns true if MediaCodec.setParameters() is available on the device.
51 static bool SupportsSetParameters(); 50 static bool SupportsSetParameters();
52 51
53 // Returns whether MediaCodecBridge has a decoder that |is_secure| and can 52 // Returns whether it's possible to create a MediaCodec for the given mime
54 // decode |codec| type. 53 // type and secureness.
55 static bool CanDecode(const std::string& codec, bool is_secure); 54 static bool CanDecode(const std::string& mime_type, bool is_secure);
56 55
57 // Returns a vector of supported codecs profiles and levels. 56 // Returns a vector of supported codecs profiles and levels.
58 static bool AddSupportedCodecProfileLevels( 57 static bool AddSupportedCodecProfileLevels(
59 std::vector<CodecProfileLevel>* out); 58 std::vector<CodecProfileLevel>* out);
60 59
61 // Get a list of encoder supported color formats for |mime_type|. 60 // Get a list of encoder supported color formats for |mime_type|.
62 // The mapping of color format name and its value refers to 61 // The mapping of color format name and its value refers to
63 // MediaCodecInfo.CodecCapabilities. 62 // MediaCodecInfo.CodecCapabilities.
64 static std::set<int> GetEncoderColorFormats(const std::string& mime_type); 63 static std::set<int> GetEncoderColorFormats(const std::string& mime_type);
65 64
66 // Returns true if |mime_type| is known to be unaccelerated (i.e. backed by a 65 // Returns true if |mime_type| is known to be unaccelerated (i.e. backed by a
67 // software codec instead of a hardware one). 66 // software codec instead of a hardware one).
68 static bool IsKnownUnaccelerated(const std::string& mime_type, 67 static bool IsKnownUnaccelerated(VideoCodec codec,
69 MediaCodecDirection direction); 68 MediaCodecDirection direction);
70 69
71 // Test whether a URL contains "m3u8". 70 // Test whether a URL contains "m3u8".
72 static bool IsHLSURL(const GURL& url); 71 static bool IsHLSURL(const GURL& url);
73 72
74 // Test whether the path of a URL ends with ".m3u8". 73 // Test whether the path of a URL ends with ".m3u8".
75 static bool IsHLSPath(const GURL& url); 74 static bool IsHLSPath(const GURL& url);
76 75
77 // 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.
78 static bool IsVp8DecoderAvailable(); 77 static bool IsVp8DecoderAvailable();
(...skipping 14 matching lines...) Expand all
93 // Indicates if the decoder is known to fail when flushed. (b/8125974, 92 // Indicates if the decoder is known to fail when flushed. (b/8125974,
94 // b/8347958) 93 // b/8347958)
95 // When true, the client should work around the issue by releasing the 94 // When true, the client should work around the issue by releasing the
96 // decoder and instantiating a new one rather than flushing the current one. 95 // decoder and instantiating a new one rather than flushing the current one.
97 static bool CodecNeedsFlushWorkaround(MediaCodecBridge* codec); 96 static bool CodecNeedsFlushWorkaround(MediaCodecBridge* codec);
98 }; 97 };
99 98
100 } // namespace media 99 } // namespace media
101 100
102 #endif // MEDIA_BASE_ANDROID_MEDIA_CODEC_UTIL_H_ 101 #endif // MEDIA_BASE_ANDROID_MEDIA_CODEC_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698