Merge "media: polish EncoderProfiles" into sc-dev
diff --git a/core/api/current.txt b/core/api/current.txt
index 03e29a7..499eb9b 100644
--- a/core/api/current.txt
+++ b/core/api/current.txt
@@ -20973,8 +20973,8 @@
}
public class CamcorderProfile {
- method public static android.media.CamcorderProfile get(int);
- method public static android.media.CamcorderProfile get(int, int);
+ method @Deprecated public static android.media.CamcorderProfile get(int);
+ method @Deprecated public static android.media.CamcorderProfile get(int, int);
method @Nullable public static android.media.EncoderProfiles getAll(@NonNull String, int);
method public static boolean hasProfile(int);
method public static boolean hasProfile(int, int);
@@ -21056,14 +21056,14 @@
field @NonNull public final java.util.UUID uuid;
}
- public class EncoderProfiles {
+ public final class EncoderProfiles {
method @NonNull public java.util.List<android.media.EncoderProfiles.AudioProfile> getAudioProfiles();
- method public int getDurationSeconds();
- method public int getFileFormat();
+ method public int getDefaultDurationSeconds();
+ method public int getRecommendedFileFormat();
method @NonNull public java.util.List<android.media.EncoderProfiles.VideoProfile> getVideoProfiles();
}
- public static class EncoderProfiles.AudioProfile {
+ public static final class EncoderProfiles.AudioProfile {
method public int getBitrate();
method public int getChannels();
method public int getCodec();
@@ -21072,7 +21072,7 @@
method public int getSampleRate();
}
- public static class EncoderProfiles.VideoProfile {
+ public static final class EncoderProfiles.VideoProfile {
method public int getBitrate();
method public int getCodec();
method public int getFrameRate();
diff --git a/media/java/android/media/CamcorderProfile.java b/media/java/android/media/CamcorderProfile.java
index 2059f02..f6f0a59 100644
--- a/media/java/android/media/CamcorderProfile.java
+++ b/media/java/android/media/CamcorderProfile.java
@@ -442,6 +442,7 @@
* camera on the device. If the device has no back-facing camera, this returns null.
* @param quality the target quality level for the camcorder profile
* @see #get(int, int)
+ * @deprecated Use {@link #getAll} instead
*/
public static CamcorderProfile get(int quality) {
int numberOfCameras = Camera.getNumberOfCameras();
@@ -508,6 +509,7 @@
* @see #QUALITY_HIGH_SPEED_720P
* @see #QUALITY_HIGH_SPEED_1080P
* @see #QUALITY_HIGH_SPEED_2160P
+ * @deprecated Use {@link #getAll} instead
* @throws IllegalArgumentException if quality is not one of the defined QUALITY_ values.
*/
public static CamcorderProfile get(int cameraId, int quality) {
@@ -549,9 +551,9 @@
* resolution and higher audio sampling rate, etc, than those with lower quality
* level.
*
- * @param cameraId the id for the camera. Numeric camera ids parsed from the list received by
- * invoking {@link CameraManager#getCameraIdList} can be used as long as they
- * are {@link CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_BACKWARD_COMPATIBLE}
+ * @param cameraId the id for the camera. Numeric camera ids from the list received by invoking
+ * {@link CameraManager#getCameraIdList} can be used as long as they are
+ * {@link CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_BACKWARD_COMPATIBLE}
* and not
* {@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_EXTERNAL EXTERNAL}.
* @param quality the target quality level for the camcorder profile.
diff --git a/media/java/android/media/EncoderProfiles.java b/media/java/android/media/EncoderProfiles.java
index ca3daef..d9eabbd4 100644
--- a/media/java/android/media/EncoderProfiles.java
+++ b/media/java/android/media/EncoderProfiles.java
@@ -51,14 +51,14 @@
* <li> Number of audio channels for recording.
* </ul>
*/
-public class EncoderProfiles
+public final class EncoderProfiles
{
/**
* Default recording duration in seconds before the session is terminated.
- * This is useful for applications like MMS has limited file size requirement.
+ * This is useful for applications like MMS that have a limited file size requirement.
* This could be 0 if there is no default recording duration.
*/
- public int getDurationSeconds() {
+ public int getDefaultDurationSeconds() {
return durationSecs;
}
@@ -66,19 +66,19 @@
* Recommended output file format
* @see android.media.MediaRecorder.OutputFormat
*/
- public int getFileFormat() {
+ public @MediaRecorder.OutputFormatValues int getRecommendedFileFormat() {
return fileFormat;
}
/**
* Configuration for a video encoder.
*/
- public static class VideoProfile {
+ public final static class VideoProfile {
/**
* The video encoder being used for the video track
* @see android.media.MediaRecorder.VideoEncoder
*/
- public int getCodec() {
+ public @MediaRecorder.VideoEncoderValues int getCodec() {
return codec;
}
@@ -238,12 +238,12 @@
/**
* Configuration for an audio encoder.
*/
- public static class AudioProfile {
+ public final static class AudioProfile {
/**
* The audio encoder being used for the audio track.
* @see android.media.MediaRecorder.AudioEncoder
*/
- public int getCodec() {
+ public @MediaRecorder.AudioEncoderValues int getCodec() {
return codec;
}
@@ -326,11 +326,6 @@
private int bitrate;
}
- //static {
- // System.loadLibrary("media_jni");
- //native_init();
- //}
-
private int durationSecs;
private int fileFormat;
// non-modifiable lists
diff --git a/media/java/android/media/MediaRecorder.java b/media/java/android/media/MediaRecorder.java
index 5eb57da..499034e 100644
--- a/media/java/android/media/MediaRecorder.java
+++ b/media/java/android/media/MediaRecorder.java
@@ -609,6 +609,25 @@
};
/**
+ * @hide
+ */
+ @IntDef({
+ OutputFormat.DEFAULT,
+ OutputFormat.THREE_GPP,
+ OutputFormat.MPEG_4,
+ OutputFormat.AMR_NB,
+ OutputFormat.AMR_WB,
+ OutputFormat.AAC_ADIF,
+ OutputFormat.AAC_ADTS,
+ OutputFormat.MPEG_2_TS,
+ OutputFormat.WEBM,
+ OutputFormat.HEIF,
+ OutputFormat.OGG,
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface OutputFormatValues {}
+
+ /**
* Defines the audio encoding. These constants are used with
* {@link MediaRecorder#setAudioEncoder(int)}.
*/
@@ -635,6 +654,22 @@
}
/**
+ * @hide
+ */
+ @IntDef({
+ AudioEncoder.DEFAULT,
+ AudioEncoder.AMR_NB,
+ AudioEncoder.AMR_WB,
+ AudioEncoder.AAC,
+ AudioEncoder.HE_AAC,
+ AudioEncoder.AAC_ELD,
+ AudioEncoder.VORBIS,
+ AudioEncoder.OPUS,
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface AudioEncoderValues {}
+
+ /**
* Defines the video encoding. These constants are used with
* {@link MediaRecorder#setVideoEncoder(int)}.
*/
@@ -652,6 +687,20 @@
}
/**
+ * @hide
+ */
+ @IntDef({
+ VideoEncoder.DEFAULT,
+ VideoEncoder.H263,
+ VideoEncoder.H264,
+ VideoEncoder.MPEG_4_SP,
+ VideoEncoder.VP8,
+ VideoEncoder.HEVC,
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface VideoEncoderValues {}
+
+ /**
* Sets the audio source to be used for recording. If this method is not
* called, the output file will not contain an audio track. The source needs
* to be specified before setting recording-parameters or encoders. Call
@@ -887,7 +936,7 @@
* setAudioSource()/setVideoSource().
* @see android.media.MediaRecorder.OutputFormat
*/
- public native void setOutputFormat(int output_format)
+ public native void setOutputFormat(@OutputFormatValues int output_format)
throws IllegalStateException;
/**
@@ -970,7 +1019,7 @@
* setOutputFormat() or after prepare().
* @see android.media.MediaRecorder.AudioEncoder
*/
- public native void setAudioEncoder(int audio_encoder)
+ public native void setAudioEncoder(@AudioEncoderValues int audio_encoder)
throws IllegalStateException;
/**
@@ -983,7 +1032,7 @@
* setOutputFormat() or after prepare()
* @see android.media.MediaRecorder.VideoEncoder
*/
- public native void setVideoEncoder(int video_encoder)
+ public native void setVideoEncoder(@VideoEncoderValues int video_encoder)
throws IllegalStateException;
/**