Merge "media: update MediaCodec/Info/List/Format APIs based on review comments" into lmp-dev

This commit is contained in:
Lajos Molnar
2014-08-28 13:28:50 +00:00
committed by Android (Google) Code Review
6 changed files with 1668 additions and 1620 deletions

View File

@ -14526,7 +14526,6 @@ package android.media {
method public abstract long getTimestamp();
method public abstract int getWidth();
method public void setCropRect(android.graphics.Rect);
field protected android.graphics.Rect mCropRect;
}
public static abstract class Image.Plane {
@ -14658,7 +14657,6 @@ package android.media {
}
public static final class MediaCodec.CodecException extends java.lang.IllegalStateException {
ctor public MediaCodec.CodecException(int, int, java.lang.String);
method public int getErrorCode();
method public boolean isRecoverable();
method public boolean isTransient();
@ -14690,14 +14688,22 @@ package android.media {
method public final boolean isEncoder();
}
public static final class MediaCodecInfo.AudioCapabilities {
method public android.util.Range<java.lang.Integer> getBitrateRange();
method public int getMaxInputChannelCount();
method public android.util.Range<java.lang.Integer>[] getSupportedSampleRateRanges();
method public int[] getSupportedSampleRates();
method public boolean isSampleRateSupported(int);
}
public static final class MediaCodecInfo.CodecCapabilities {
ctor public MediaCodecInfo.CodecCapabilities();
method public static final android.media.MediaCodecInfo.CodecCapabilities CreateFromProfileLevel(java.lang.String, int, int);
method public final android.media.MediaCodecInfo.CodecCapabilities.AudioCapabilities getAudioCapabilities();
method public final android.media.MediaFormat getDefaultFormat();
method public final android.media.MediaCodecInfo.CodecCapabilities.EncoderCapabilities getEncoderCapabilities();
method public final java.lang.String getMime();
method public final android.media.MediaCodecInfo.CodecCapabilities.VideoCapabilities getVideoCapabilities();
method public static android.media.MediaCodecInfo.CodecCapabilities CreateFromProfileLevel(java.lang.String, int, int);
method public android.media.MediaCodecInfo.AudioCapabilities getAudioCapabilities();
method public android.media.MediaFormat getDefaultFormat();
method public android.media.MediaCodecInfo.EncoderCapabilities getEncoderCapabilities();
method public java.lang.String getMimeType();
method public android.media.MediaCodecInfo.VideoCapabilities getVideoCapabilities();
method public final boolean isFeatureRequired(java.lang.String);
method public final boolean isFeatureSupported(java.lang.String);
method public final boolean isFormatSupported(android.media.MediaFormat);
@ -14755,39 +14761,6 @@ package android.media {
field public android.media.MediaCodecInfo.CodecProfileLevel[] profileLevels;
}
public static final class MediaCodecInfo.CodecCapabilities.AudioCapabilities extends android.media.MediaCodecInfo.CodecCapabilities.BaseCapabilities {
method public final int getMaxInputChannelCount();
method public final android.util.Range<java.lang.Integer>[] getSupportedSampleRateRanges();
method public final int[] getSupportedSampleRates();
method public final boolean isSampleRateSupported(int);
}
public static class MediaCodecInfo.CodecCapabilities.BaseCapabilities {
method public final android.util.Range<java.lang.Integer> getBitrateRange();
}
public static final class MediaCodecInfo.CodecCapabilities.EncoderCapabilities {
method public final android.util.Range<java.lang.Integer> getComplexityRange();
method public final android.util.Range<java.lang.Integer> getQualityRange();
method public final boolean isBitrateModeSupported(int);
field public static final int BITRATE_MODE_CBR = 2; // 0x2
field public static final int BITRATE_MODE_CQ = 0; // 0x0
field public static final int BITRATE_MODE_VBR = 1; // 0x1
}
public static final class MediaCodecInfo.CodecCapabilities.VideoCapabilities extends android.media.MediaCodecInfo.CodecCapabilities.BaseCapabilities {
method public final boolean areSizeAndRateSupported(int, int, double);
method public final int getHeightAlignment();
method public final android.util.Range<java.lang.Integer> getSupportedFrameRates();
method public final android.util.Range<java.lang.Double> getSupportedFrameRatesFor(int, int);
method public final android.util.Range<java.lang.Integer> getSupportedHeights();
method public final android.util.Range<java.lang.Integer> getSupportedHeightsFor(int);
method public final android.util.Range<java.lang.Integer> getSupportedWidths();
method public final android.util.Range<java.lang.Integer> getSupportedWidthsFor(int);
method public final int getWidthAlignment();
method public final boolean isSizeSupported(int, int);
}
public static final class MediaCodecInfo.CodecProfileLevel {
ctor public MediaCodecInfo.CodecProfileLevel();
field public static final int AACObjectELD = 39; // 0x27
@ -14902,12 +14875,34 @@ package android.media {
field public int profile;
}
public static final class MediaCodecInfo.EncoderCapabilities {
method public android.util.Range<java.lang.Integer> getComplexityRange();
method public boolean isBitrateModeSupported(int);
field public static final int BITRATE_MODE_CBR = 2; // 0x2
field public static final int BITRATE_MODE_CQ = 0; // 0x0
field public static final int BITRATE_MODE_VBR = 1; // 0x1
}
public static final class MediaCodecInfo.VideoCapabilities {
method public boolean areSizeAndRateSupported(int, int, double);
method public android.util.Range<java.lang.Integer> getBitrateRange();
method public int getHeightAlignment();
method public android.util.Range<java.lang.Integer> getSupportedFrameRates();
method public android.util.Range<java.lang.Double> getSupportedFrameRatesFor(int, int);
method public android.util.Range<java.lang.Integer> getSupportedHeights();
method public android.util.Range<java.lang.Integer> getSupportedHeightsFor(int);
method public android.util.Range<java.lang.Integer> getSupportedWidths();
method public android.util.Range<java.lang.Integer> getSupportedWidthsFor(int);
method public int getWidthAlignment();
method public boolean isSizeSupported(int, int);
}
public final class MediaCodecList {
ctor public MediaCodecList(int);
method public final java.lang.String findDecoderForFormat(android.media.MediaFormat);
method public final java.lang.String findEncoderForFormat(android.media.MediaFormat);
method public static final int getCodecCount();
method public static final android.media.MediaCodecInfo getCodecInfoAt(int);
method public static final deprecated int getCodecCount();
method public static final deprecated android.media.MediaCodecInfo getCodecInfoAt(int);
method public final android.media.MediaCodecInfo[] getCodecInfos();
field public static final int ALL_CODECS = 1; // 0x1
field public static final int REGULAR_CODECS = 0; // 0x0
@ -15026,11 +15021,13 @@ package android.media {
method public static final android.media.MediaFormat createSubtitleFormat(java.lang.String, java.lang.String);
method public static final android.media.MediaFormat createVideoFormat(java.lang.String, int, int);
method public final java.nio.ByteBuffer getByteBuffer(java.lang.String);
method public boolean getFeatureEnabled(java.lang.String);
method public final float getFloat(java.lang.String);
method public final int getInteger(java.lang.String);
method public final long getLong(java.lang.String);
method public final java.lang.String getString(java.lang.String);
method public final void setByteBuffer(java.lang.String, java.nio.ByteBuffer);
method public void setFeatureEnabled(java.lang.String, boolean);
method public final void setFloat(java.lang.String, float);
method public final void setInteger(java.lang.String, int);
method public final void setLong(java.lang.String, long);
@ -15052,7 +15049,6 @@ package android.media {
field public static final java.lang.String KEY_COLOR_FORMAT = "color-format";
field public static final java.lang.String KEY_COMPLEXITY = "complexity";
field public static final java.lang.String KEY_DURATION = "durationUs";
field public static final java.lang.String KEY_FEATURE_ = "feature-";
field public static final java.lang.String KEY_FLAC_COMPRESSION_LEVEL = "flac-compression-level";
field public static final java.lang.String KEY_FRAME_RATE = "frame-rate";
field public static final java.lang.String KEY_HEIGHT = "height";
@ -15068,7 +15064,6 @@ package android.media {
field public static final java.lang.String KEY_MIME = "mime";
field public static final java.lang.String KEY_PROFILE = "profile";
field public static final java.lang.String KEY_PUSH_BLANK_BUFFERS_ON_STOP = "push-blank-buffers-on-shutdown";
field public static final java.lang.String KEY_QUALITY = "quality";
field public static final java.lang.String KEY_REPEAT_PREVIOUS_FRAME_AFTER = "repeat-previous-frame-after";
field public static final java.lang.String KEY_SAMPLE_RATE = "sample-rate";
field public static final java.lang.String KEY_TEMPORAL_LAYERING = "ts-schema";

View File

@ -123,7 +123,7 @@ public abstract class Image implements AutoCloseable {
*/
public abstract long getTimestamp();
protected Rect mCropRect;
private Rect mCropRect;
/**
* Get the crop rectangle associated with this frame.

View File

@ -665,7 +665,7 @@ final public class MediaCodec {
* Thrown when an internal codec error occurs.
*/
public final static class CodecException extends IllegalStateException {
public CodecException(int errorCode, int actionCode, String detailMessage) {
CodecException(int errorCode, int actionCode, String detailMessage) {
super(detailMessage);
mErrorCode = errorCode;
mActionCode = actionCode;
@ -1729,7 +1729,7 @@ final public class MediaCodec {
if (cropRect != null) {
cropRect.offset(-xOffset, -yOffset);
}
mCropRect = cropRect;
setCropRect(cropRect);
// save offsets and info
mXOffset = xOffset;

File diff suppressed because it is too large Load Diff

View File

@ -36,6 +36,8 @@ final public class MediaCodecList {
/**
* Count the number of available (regular) codecs.
*
* @deprecated Use {@link #getCodecInfos} instead.
*
* @see #REGULAR_CODECS
*/
public static final int getCodecCount() {
@ -49,6 +51,8 @@ final public class MediaCodecList {
* Return the {@link MediaCodecInfo} object for the codec at
* the given {@code index} in the regular list.
*
* @deprecated Use {@link #getCodecInfos} instead.
*
* @see #REGULAR_CODECS
*/
public static final MediaCodecInfo getCodecInfoAt(int index) {
@ -116,13 +120,22 @@ final public class MediaCodecList {
/**
* Use in {@link #MediaCodecList} to enumerate only codecs that are suitable
* for normal playback and recording.
* for regular (buffer-to-buffer) decoding or encoding.
*
* <em>NOTE:</em> These are the codecs that are returned prior to API 21,
* using the now deprecated static methods.
*/
public static final int REGULAR_CODECS = 0;
/**
* Use in {@link #MediaCodecList} to enumerate all codecs, even ones that are
* not suitable for normal playback or recording.
* not suitable for regular (buffer-to-buffer) decoding or encoding. These
* include codecs, for example, that only work with special input or output
* surfaces, such as secure-only or tunneled-only codecs.
*
* @see MediaCodecInfo.CodecCapabilities#isFormatSupported
* @see MediaCodecInfo.CodecCapabilities#FEATURE_SecurePlayback
* @see MediaCodecInfo.CodecCapabilities#FEATURE_TunneledPlayback
*/
public static final int ALL_CODECS = 1;

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.