media: update MediaCodec/Info/List/Format APIs based on review comments

Bug: 17059255
Change-Id: Ifbba2a0799e7db5ae48190ba6b1e4ba13fffa167
This commit is contained in:
Lajos Molnar
2014-08-22 15:51:40 -07:00
parent e193455ee2
commit 217474682a
6 changed files with 1668 additions and 1620 deletions

View File

@@ -119,19 +119,6 @@ public final class MediaFormat {
private Map<String, Object> mMap;
/**
* A key prefix used together with a {@link MediaCodecInfo.CodecCapabilities}
* feature name describing a required or optional feature for a codec capabilities
* query.
* The associated value is an integer, where non-0 value means the feature is
* requested to be present, while 0 value means the feature is requested to be not
* present.
* @see MediaCodecList#findDecoderForFormat
* @see MediaCodecList#findEncoderForFormat
* @see MediaCodecInfo.CodecCapabilities#isFormatSupported
*/
public static final String KEY_FEATURE_ = "feature-";
/**
* A key describing the mime type of the MediaFormat.
* The associated value is a string.
@@ -422,6 +409,8 @@ public final class MediaFormat {
* codec specific, but lower values generally result in more efficient
* (smaller-sized) encoding.
*
* @hide
*
* @see MediaCodecInfo.CodecCapabilities.EncoderCapabilities#getQualityRange
*/
public static final String KEY_QUALITY = "quality";
@@ -509,6 +498,21 @@ public final class MediaFormat {
return mMap.containsKey(name);
}
/**
* A key prefix used together with a {@link MediaCodecInfo.CodecCapabilities}
* feature name describing a required or optional feature for a codec capabilities
* query.
* The associated value is an integer, where non-0 value means the feature is
* requested to be present, while 0 value means the feature is requested to be not
* present.
* @see MediaCodecList#findDecoderForFormat
* @see MediaCodecList#findEncoderForFormat
* @see MediaCodecInfo.CodecCapabilities#isFormatSupported
*
* @hide
*/
public static final String KEY_FEATURE_ = "feature-";
/**
* Returns the value of an integer key.
*/
@@ -558,6 +562,23 @@ public final class MediaFormat {
return (ByteBuffer)mMap.get(name);
}
/**
* Returns whether a feature is to be enabled ({@code true}) or disabled
* ({@code false}).
*
* @param feature the name of a {@link MediaCodecInfo.CodecCapabilities} feature.
*
* @throws IllegalArgumentException if the feature was neither set to be enabled
* nor to be disabled.
*/
public boolean getFeatureEnabled(String feature) {
Integer enabled = (Integer)mMap.get(KEY_FEATURE_ + feature);
if (enabled == null) {
throw new IllegalArgumentException("feature is not specified");
}
return enabled != 0;
}
/**
* Sets the value of an integer key.
*/
@@ -593,6 +614,23 @@ public final class MediaFormat {
mMap.put(name, bytes);
}
/**
* Sets whether a feature is to be enabled ({@code true}) or disabled
* ({@code false}).
*
* If {@code enabled} is {@code true}, the feature is requested to be present.
* Otherwise, the feature is requested to be not present.
*
* @param feature the name of a {@link MediaCodecInfo.CodecCapabilities} feature.
*
* @see MediaCodecList#findDecoderForFormat
* @see MediaCodecList#findEncoderForFormat
* @see MediaCodecInfo.CodecCapabilities#isFormatSupported
*/
public void setFeatureEnabled(String feature, boolean enabled) {
setInteger(KEY_FEATURE_ + feature, enabled ? 1 : 0);
}
/**
* Creates a minimal audio format.
* @param mime The mime type of the content.