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

Commit b84433bd authored by Dorin Drimus's avatar Dorin Drimus Committed by Gerrit Code Review
Browse files

Merge "Add AudioCapabilities for DTS audio formats"

parents 99fb0eee a1f099ad
Loading
Loading
Loading
Loading
+62 −2
Original line number Diff line number Diff line
@@ -981,8 +981,20 @@ public final class MediaCodecInfo {
                    continue;
                }

                // AAC does not use levels
                if (level == null || mMime.equalsIgnoreCase(MediaFormat.MIMETYPE_AUDIO_AAC)) {
                // No specific level requested
                if (level == null) {
                    return true;
                }

                // AAC doesn't use levels
                if (mMime.equalsIgnoreCase(MediaFormat.MIMETYPE_AUDIO_AAC)) {
                    return true;
                }

                // DTS doesn't use levels
                if (mMime.equalsIgnoreCase(MediaFormat.MIMETYPE_AUDIO_DTS)
                        || mMime.equalsIgnoreCase(MediaFormat.MIMETYPE_AUDIO_DTS_HD)
                        || mMime.equalsIgnoreCase(MediaFormat.MIMETYPE_AUDIO_DTS_UHD)) {
                    return true;
                }

@@ -1410,6 +1422,7 @@ public final class MediaCodecInfo {
            int[] sampleRates = null;
            Range<Integer> sampleRateRange = null, bitRates = null;
            int maxChannels = MAX_INPUT_CHANNEL_COUNT;
            CodecProfileLevel[] profileLevels = mParent.profileLevels;
            String mime = mParent.getMimeType();

            if (mime.equalsIgnoreCase(MediaFormat.MIMETYPE_AUDIO_MPEG)) {
@@ -1473,6 +1486,53 @@ public final class MediaCodecInfo {
                sampleRates = new int[] { 44100, 48000, 96000, 192000 };
                bitRates = Range.create(16000, 2688000);
                maxChannels = 24;
            } else if (mime.equalsIgnoreCase(MediaFormat.MIMETYPE_AUDIO_DTS)) {
                sampleRates = new int[] { 44100, 48000 };
                bitRates = Range.create(96000, 1524000);
                maxChannels = 6;
            } else if (mime.equalsIgnoreCase(MediaFormat.MIMETYPE_AUDIO_DTS_HD)) {
                for (CodecProfileLevel profileLevel: profileLevels) {
                    switch (profileLevel.profile) {
                        case CodecProfileLevel.DTS_HDProfileLBR:
                            sampleRates = new int[]{ 22050, 24000, 44100, 48000 };
                            bitRates = Range.create(32000, 768000);
                            break;
                        case CodecProfileLevel.DTS_HDProfileHRA:
                        case CodecProfileLevel.DTS_HDProfileMA:
                            sampleRates = new int[]{ 44100, 48000, 88200, 96000, 176400, 192000 };
                            bitRates = Range.create(96000, 24500000);
                            break;
                        default:
                            Log.w(TAG, "Unrecognized profile "
                                    + profileLevel.profile + " for " + mime);
                            mParent.mError |= ERROR_UNRECOGNIZED;
                            sampleRates = new int[]{ 44100, 48000, 88200, 96000, 176400, 192000 };
                            bitRates = Range.create(96000, 24500000);
                    }
                }
                maxChannels = 8;
            } else if (mime.equalsIgnoreCase(MediaFormat.MIMETYPE_AUDIO_DTS_UHD)) {
                for (CodecProfileLevel profileLevel: profileLevels) {
                    switch (profileLevel.profile) {
                        case CodecProfileLevel.DTS_UHDProfileP2:
                            sampleRates = new int[]{ 48000 };
                            bitRates = Range.create(96000, 768000);
                            maxChannels = 10;
                            break;
                        case CodecProfileLevel.DTS_UHDProfileP1:
                            sampleRates = new int[]{ 44100, 48000, 88200, 96000, 176400, 192000 };
                            bitRates = Range.create(96000, 24500000);
                            maxChannels = 32;
                            break;
                        default:
                            Log.w(TAG, "Unrecognized profile "
                                    + profileLevel.profile + " for " + mime);
                            mParent.mError |= ERROR_UNRECOGNIZED;
                            sampleRates = new int[]{ 44100, 48000, 88200, 96000, 176400, 192000 };
                            bitRates = Range.create(96000, 24500000);
                            maxChannels = 32;
                    }
                }
            } else {
                Log.w(TAG, "Unsupported mime " + mime);
                mParent.mError |= ERROR_UNSUPPORTED;
+12 −3
Original line number Diff line number Diff line
@@ -174,11 +174,20 @@ public final class MediaFormat {
    public static final String MIMETYPE_AUDIO_MPEGH_MHA1 = "audio/mha1";
    /** MIME type for MPEG-H Audio single stream, encapsulated in MHAS */
    public static final String MIMETYPE_AUDIO_MPEGH_MHM1 = "audio/mhm1";
    /** MIME type for DTS (up to 5.1 channels) audio stream. */
    /** MIME type for DTS Digital Surround (up to 5.1 channels) audio stream, aka DTS-CA. */
    public static final String MIMETYPE_AUDIO_DTS = "audio/vnd.dts";
    /** MIME type for DTS HD (up to 7.1 channels) audio stream. */
    /**
     * MIME type for DTS HD (up to 7.1 channels) audio stream.
     * With codec profile DTS_HDProfileHRA represents DTS HD High Resolution Audio.
     * With codec profile DTS_HDProfileMA represents DTS HD Master Audio.
     * With codec profile DTS_HDProfileLBR represents DTS Express.
     */
    public static final String MIMETYPE_AUDIO_DTS_HD = "audio/vnd.dts.hd";
    /** MIME type for DTS UHD (object-based) audio stream. */
    /**
     * MIME type for DTS UHD (object-based) audio stream, aka DTS:X.
     * With codec profile DTS_UHDProfileP1 represents DTS-UHD P1.
     * With codec profile DTS_UHDProfileP2 represents DTS-UHD P2.
     */
    public static final String MIMETYPE_AUDIO_DTS_UHD = "audio/vnd.dts.uhd";
    /** MIME type for Dynamic Resolution Adaptation (DRA) audio stream. */
    public static final String MIMETYPE_AUDIO_DRA = "audio/vnd.dra";