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

Commit 5996b120 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "transcoding: Address API council comments." into sc-dev

parents 82cd582c 20ad19c4
Loading
Loading
Loading
Loading
+3 −6
Original line number Diff line number Diff line
@@ -8,9 +8,10 @@ package android.media {
    method @NonNull public java.util.List<java.lang.String> getSupportedVideoMimeTypes();
    method @NonNull public java.util.List<java.lang.String> getUnsupportedHdrTypes();
    method @NonNull public java.util.List<java.lang.String> getUnsupportedVideoMimeTypes();
    method public boolean isHdrTypeSupported(@NonNull String) throws android.media.ApplicationMediaCapabilities.FormatNotFoundException;
    method public boolean isFormatSpecified(@NonNull String);
    method public boolean isHdrTypeSupported(@NonNull String);
    method public boolean isSlowMotionSupported();
    method public boolean isVideoMimeTypeSupported(@NonNull String) throws android.media.ApplicationMediaCapabilities.FormatNotFoundException;
    method public boolean isVideoMimeTypeSupported(@NonNull String);
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.media.ApplicationMediaCapabilities> CREATOR;
  }
@@ -24,10 +25,6 @@ package android.media {
    method @NonNull public android.media.ApplicationMediaCapabilities build();
  }

  public static class ApplicationMediaCapabilities.FormatNotFoundException extends android.util.AndroidException {
    ctor public ApplicationMediaCapabilities.FormatNotFoundException(@NonNull String);
  }

  public class MediaCommunicationManager {
    method @IntRange(from=1) public int getVersion();
  }
+31 −27
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ import android.net.Uri;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.AndroidException;
import android.util.Log;

import org.xmlpull.v1.XmlPullParser;
@@ -79,17 +78,7 @@ import java.util.Set;
public final class ApplicationMediaCapabilities implements Parcelable {
    private static final String TAG = "ApplicationMediaCapabilities";

    /**
     * This exception is thrown when a given format is not specified in the media capabilities.
     */
    public static class FormatNotFoundException extends AndroidException {
        public FormatNotFoundException(@NonNull String format) {
            super(format);
        }
    }

    /** List of supported video codec mime types. */
    // TODO: init it with avc and mpeg4 as application is assuming to support them.
    private Set<String> mSupportedVideoMimeTypes = new HashSet<>();

    /** List of unsupported video codec mime types. */
@@ -113,39 +102,54 @@ public final class ApplicationMediaCapabilities implements Parcelable {

    /**
     * Query if a video codec format is supported by the application.
     * <p>
     * If the application has not specified supporting the format or not, this will return false.
     * Use {@link #isFormatSpecified(String)} to query if a format is specified or not.
     *
     * @param videoMime The mime type of the video codec format. Must be the one used in
     * {@link MediaFormat#KEY_MIME}.
     * @return true if application supports the video codec format, false otherwise.
     * @throws FormatNotFoundException if the application did not specify the codec either in the
     * supported or unsupported formats.
     */
    public boolean isVideoMimeTypeSupported(
            @NonNull String videoMime) throws FormatNotFoundException {
        if (mUnsupportedVideoMimeTypes.contains(videoMime.toLowerCase())) {
            return false;
        } else if (mSupportedVideoMimeTypes.contains(videoMime.toLowerCase())) {
            @NonNull String videoMime) {
        if (mSupportedVideoMimeTypes.contains(videoMime.toLowerCase())) {
            return true;
        } else {
            throw new FormatNotFoundException(videoMime);
        }
        return false;
    }

    /**
     * Query if a HDR type is supported by the application.
     * <p>
     * If the application has not specified supporting the format or not, this will return false.
     * Use {@link #isFormatSpecified(String)} to query if a format is specified or not.
     *
     * @param hdrType The type of the HDR format.
     * @return true if application supports the HDR format, false otherwise.
     * @throws FormatNotFoundException if the application did not specify the format either in the
     * supported or unsupported formats.
     */
    public boolean isHdrTypeSupported(
            @NonNull @MediaFeature.MediaHdrType String hdrType) throws FormatNotFoundException {
        if (mUnsupportedHdrTypes.contains(hdrType)) {
            @NonNull @MediaFeature.MediaHdrType String hdrType) {
        if (mSupportedHdrTypes.contains(hdrType)) {
            return true;
        }
        return false;
        } else if (mSupportedHdrTypes.contains(hdrType)) {
    }

    /**
     * Query if a format is specified by the application.
     * <p>
     * The format could be either the video format or the hdr format.
     *
     * @param format The name of the format.
     * @return true if application specifies the format, false otherwise.
     */
    public boolean isFormatSpecified(@NonNull String format) {
        if (mSupportedVideoMimeTypes.contains(format) || mUnsupportedVideoMimeTypes.contains(format)
                || mSupportedHdrTypes.contains(format) || mUnsupportedHdrTypes.contains(format)) {
            return true;
        } else {
            throw new FormatNotFoundException(hdrType);

        }
        return false;
    }

    @Override
+2 −8
Original line number Diff line number Diff line
@@ -1062,14 +1062,8 @@ public final class MediaTranscodeManager {
                            "Source video format hint must be set!");
                }

                boolean supportHevc = false;
                try {
                    supportHevc = mClientCaps.isVideoMimeTypeSupported(
                boolean supportHevc = mClientCaps.isVideoMimeTypeSupported(
                        MediaFormat.MIMETYPE_VIDEO_HEVC);
                } catch (ApplicationMediaCapabilities.FormatNotFoundException ex) {
                    // Set to false if application did not specify.
                    supportHevc = false;
                }
                if (!supportHevc && MediaFormat.MIMETYPE_VIDEO_HEVC.equals(
                        mSrcVideoFormatHint.getString(MediaFormat.KEY_MIME))) {
                    return true;