Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e6e5043f authored by Hangyu Kuang's avatar Hangyu Kuang Committed by android-build-merger
Browse files

Merge "media: Address api council comments." into oc-mr1-dev am: d3cef1bf

am: 515b44b3

Change-Id: I6e09042855c933647c5f08955e06378dbc56f324
parents 37076708 515b44b3
Loading
Loading
Loading
Loading
+23 −10
Original line number Original line Diff line number Diff line
@@ -16,6 +16,7 @@


package android.media;
package android.media;


import android.annotation.IntDef;
import android.content.ContentResolver;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Context;
import android.content.res.AssetFileDescriptor;
import android.content.res.AssetFileDescriptor;
@@ -27,6 +28,8 @@ import java.io.FileDescriptor;
import java.io.FileInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.IOException;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;


import java.util.Map;
import java.util.Map;


@@ -249,7 +252,7 @@ public class MediaMetadataRetriever
     * @return A Bitmap containing a representative video frame, which
     * @return A Bitmap containing a representative video frame, which
     *         can be null, if such a frame cannot be retrieved.
     *         can be null, if such a frame cannot be retrieved.
     */
     */
    public Bitmap getFrameAtTime(long timeUs, int option) {
    public Bitmap getFrameAtTime(long timeUs, @Option int option) {
        if (option < OPTION_PREVIOUS_SYNC ||
        if (option < OPTION_PREVIOUS_SYNC ||
            option > OPTION_CLOSEST) {
            option > OPTION_CLOSEST) {
            throw new IllegalArgumentException("Unsupported option: " + option);
            throw new IllegalArgumentException("Unsupported option: " + option);
@@ -286,27 +289,27 @@ public class MediaMetadataRetriever
     * {@link #OPTION_CLOSEST} often has larger performance overhead compared
     * {@link #OPTION_CLOSEST} often has larger performance overhead compared
     * to the other options if there is no sync frame located at timeUs.
     * to the other options if there is no sync frame located at timeUs.
     *
     *
     * @param dst_width expected output bitmap width
     * @param dstWidth expected output bitmap width
     * @param dst_height expected output bitmap height
     * @param dstHeight expected output bitmap height
     * @return A Bitmap of size not larger than dst_width by dst_height containing a
     * @return A Bitmap of size not larger than dstWidth by dstHeight containing a
     *         scaled video frame, which can be null, if such a frame cannot be retrieved.
     *         scaled video frame, which can be null, if such a frame cannot be retrieved.
     * @throws IllegalArgumentException if passed in invalid option or width by height
     * @throws IllegalArgumentException if passed in invalid option or width by height
     *         is less than or equal to 0.
     *         is less than or equal to 0.
     */
     */
    public Bitmap getScaledFrameAtTime(
    public Bitmap getScaledFrameAtTime(
            long timeUs, int option, int dst_width, int dst_height) {
            long timeUs, @Option int option, int dstWidth, int dstHeight) {
        if (option < OPTION_PREVIOUS_SYNC ||
        if (option < OPTION_PREVIOUS_SYNC ||
            option > OPTION_CLOSEST) {
            option > OPTION_CLOSEST) {
            throw new IllegalArgumentException("Unsupported option: " + option);
            throw new IllegalArgumentException("Unsupported option: " + option);
        }
        }
        if (dst_width <= 0) {
        if (dstWidth <= 0) {
            throw new IllegalArgumentException("Invalid width: " + dst_width);
            throw new IllegalArgumentException("Invalid width: " + dstWidth);
        }
        }
        if (dst_height <= 0) {
        if (dstHeight <= 0) {
            throw new IllegalArgumentException("Invalid height: " + dst_height);
            throw new IllegalArgumentException("Invalid height: " + dstHeight);
        }
        }


        return _getFrameAtTime(timeUs, option, dst_width, dst_height);
        return _getFrameAtTime(timeUs, option, dstWidth, dstHeight);
    }
    }


    /**
    /**
@@ -427,6 +430,16 @@ public class MediaMetadataRetriever
     */
     */
    public static final int OPTION_CLOSEST          = 0x03;
    public static final int OPTION_CLOSEST          = 0x03;


    /** @hide */
    @IntDef(flag = true, prefix = { "OPTION_" }, value = {
            OPTION_PREVIOUS_SYNC,
            OPTION_NEXT_SYNC,
            OPTION_CLOSEST_SYNC,
            OPTION_CLOSEST,
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface Option {}

    /*
    /*
     * Do not change these metadata key values without updating their
     * Do not change these metadata key values without updating their
     * counterparts in include/media/mediametadataretriever.h!
     * counterparts in include/media/mediametadataretriever.h!