diff options
-rw-r--r-- | api/current.txt | 3 | ||||
-rw-r--r-- | media/java/android/media/MediaCodec.java | 33 | ||||
-rw-r--r-- | media/java/android/media/MediaFormat.java | 57 |
3 files changed, 93 insertions, 0 deletions
diff --git a/api/current.txt b/api/current.txt index ab18d721fcfc..9dec22e7ca65 100644 --- a/api/current.txt +++ b/api/current.txt @@ -24142,8 +24142,10 @@ package android.media { field public static final int INFO_OUTPUT_FORMAT_CHANGED = -2; // 0xfffffffe field public static final int INFO_TRY_AGAIN_LATER = -1; // 0xffffffff field public static final String PARAMETER_KEY_HDR10_PLUS_INFO = "hdr10-plus-info"; + field public static final String PARAMETER_KEY_OFFSET_TIME = "time-offset-us"; field public static final String PARAMETER_KEY_REQUEST_SYNC_FRAME = "request-sync"; field public static final String PARAMETER_KEY_SUSPEND = "drop-input-frames"; + field public static final String PARAMETER_KEY_SUSPEND_TIME = "drop-start-time-us"; field public static final String PARAMETER_KEY_VIDEO_BITRATE = "video-bitrate"; field public static final int VIDEO_SCALING_MODE_SCALE_TO_FIT = 1; // 0x1 field public static final int VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING = 2; // 0x2 @@ -24988,6 +24990,7 @@ package android.media { field public static final String KEY_COLOR_STANDARD = "color-standard"; field public static final String KEY_COLOR_TRANSFER = "color-transfer"; field public static final String KEY_COMPLEXITY = "complexity"; + field public static final String KEY_CREATE_INPUT_SURFACE_SUSPENDED = "create-input-buffers-suspended"; field public static final String KEY_DURATION = "durationUs"; field public static final String KEY_FLAC_COMPRESSION_LEVEL = "flac-compression-level"; field public static final String KEY_FRAME_RATE = "frame-rate"; diff --git a/media/java/android/media/MediaCodec.java b/media/java/android/media/MediaCodec.java index 0c3d6255f871..c6c2fdd00674 100644 --- a/media/java/android/media/MediaCodec.java +++ b/media/java/android/media/MediaCodec.java @@ -3373,6 +3373,8 @@ final public class MediaCodec { /** * Change a video encoder's target bitrate on the fly. The value is an * Integer object containing the new bitrate in bps. + * + * @see #setParameters(Bundle) */ public static final String PARAMETER_KEY_VIDEO_BITRATE = "video-bitrate"; @@ -3384,12 +3386,43 @@ final public class MediaCodec { * input-side of the encoder in that case. * The value is an Integer object containing the value 1 to suspend * or the value 0 to resume. + * + * @see #setParameters(Bundle) */ public static final String PARAMETER_KEY_SUSPEND = "drop-input-frames"; /** + * When {@link #PARAMETER_KEY_SUSPEND} is present, the client can also + * optionally use this key to specify the timestamp (in micro-second) + * at which the suspend/resume operation takes effect. + * + * Note that the specified timestamp must be greater than or equal to the + * timestamp of any previously queued suspend/resume operations. + * + * The value is a long int, indicating the timestamp to suspend/resume. + * + * @see #setParameters(Bundle) + */ + public static final String PARAMETER_KEY_SUSPEND_TIME = "drop-start-time-us"; + + /** + * Specify an offset (in micro-second) to be added on top of the timestamps + * onward. A typical use case is to apply an adjust to the timestamps after + * a period of pause by the user. + * + * This parameter can only be used on an encoder in "surface-input" mode. + * + * The value is a long int, indicating the timestamp offset to be applied. + * + * @see #setParameters(Bundle) + */ + public static final String PARAMETER_KEY_OFFSET_TIME = "time-offset-us"; + + /** * Request that the encoder produce a sync frame "soon". * Provide an Integer with the value 0. + * + * @see #setParameters(Bundle) */ public static final String PARAMETER_KEY_REQUEST_SYNC_FRAME = "request-sync"; diff --git a/media/java/android/media/MediaFormat.java b/media/java/android/media/MediaFormat.java index c82b5f6f12a1..4ca0216c80f2 100644 --- a/media/java/android/media/MediaFormat.java +++ b/media/java/android/media/MediaFormat.java @@ -463,6 +463,63 @@ public final class MediaFormat { = "repeat-previous-frame-after"; /** + * Instruct the video encoder in "surface-input" mode to drop excessive + * frames from the source, so that the input frame rate to the encoder + * does not exceed the specified fps. + * + * The associated value is a float, representing the max frame rate to + * feed the encoder at. + * + * @hide + */ + public static final String KEY_MAX_FPS_TO_ENCODER + = "max-fps-to-encoder"; + + /** + * Instruct the video encoder in "surface-input" mode to limit the gap of + * timestamp between any two adjacent frames fed to the encoder to the + * specified amount (in micro-second). + * + * The associated value is a long int. When positive, it represents the max + * timestamp gap between two adjacent frames fed to the encoder. When negative, + * the absolute value represents a fixed timestamp gap between any two adjacent + * frames fed to the encoder. Note that this will also apply even when the + * original timestamp goes backward in time. Under normal conditions, such frames + * would be dropped and not sent to the encoder. + * + * The output timestamp will be restored to the original timestamp and will + * not be affected. + * + * This is used in some special scenarios where input frames arrive sparingly + * but it's undesirable to allocate more bits to any single frame, or when it's + * important to ensure all frames are captured (rather than captured in the + * correct order). + * + * @hide + */ + public static final String KEY_MAX_PTS_GAP_TO_ENCODER + = "max-pts-gap-to-encoder"; + + /** + * If specified when configuring a video encoder that's in "surface-input" + * mode, it will instruct the encoder to put the surface source in suspended + * state when it's connected. No video frames will be accepted until a resume + * operation (see {@link MediaCodec#PARAMETER_KEY_SUSPEND}), optionally with + * timestamp specified via {@link MediaCodec#PARAMETER_KEY_SUSPEND_TIME}, is + * received. + * + * The value is an integer, with 1 indicating to create with the surface + * source suspended, or 0 otherwise. The default value is 0. + * + * If this key is not set or set to 0, the surface source will accept buffers + * as soon as it's connected to the encoder (although they may not be encoded + * immediately). This key can be used when the client wants to prepare the + * encoder session in advance, but do not want to accept buffers immediately. + */ + public static final String KEY_CREATE_INPUT_SURFACE_SUSPENDED + = "create-input-buffers-suspended"; + + /** * If specified when configuring a video decoder rendering to a surface, * causes the decoder to output "blank", i.e. black frames to the surface * when stopped to clear out any previously displayed contents. |