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

Commit a1f099ad authored by Rahul's avatar Rahul Committed by Dorin Drimus
Browse files

Add AudioCapabilities for DTS audio formats

Add codec profile limits for DTS audio formats.

Bug: 235469058
Test: Build
Change-Id: I4685114bb8c0c75e894f692e71aa6f94e81c29d2
parent 7355e9fa
Loading
Loading
Loading
Loading
+62 −2
Original line number Original line Diff line number Diff line
@@ -981,8 +981,20 @@ public final class MediaCodecInfo {
                    continue;
                    continue;
                }
                }


                // AAC does not use levels
                // No specific level requested
                if (level == null || mMime.equalsIgnoreCase(MediaFormat.MIMETYPE_AUDIO_AAC)) {
                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;
                    return true;
                }
                }


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


            if (mime.equalsIgnoreCase(MediaFormat.MIMETYPE_AUDIO_MPEG)) {
            if (mime.equalsIgnoreCase(MediaFormat.MIMETYPE_AUDIO_MPEG)) {
@@ -1473,6 +1486,53 @@ public final class MediaCodecInfo {
                sampleRates = new int[] { 44100, 48000, 96000, 192000 };
                sampleRates = new int[] { 44100, 48000, 96000, 192000 };
                bitRates = Range.create(16000, 2688000);
                bitRates = Range.create(16000, 2688000);
                maxChannels = 24;
                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 {
            } else {
                Log.w(TAG, "Unsupported mime " + mime);
                Log.w(TAG, "Unsupported mime " + mime);
                mParent.mError |= ERROR_UNSUPPORTED;
                mParent.mError |= ERROR_UNSUPPORTED;
+12 −3
Original line number Original line Diff line number Diff line
@@ -174,11 +174,20 @@ public final class MediaFormat {
    public static final String MIMETYPE_AUDIO_MPEGH_MHA1 = "audio/mha1";
    public static final String MIMETYPE_AUDIO_MPEGH_MHA1 = "audio/mha1";
    /** MIME type for MPEG-H Audio single stream, encapsulated in MHAS */
    /** MIME type for MPEG-H Audio single stream, encapsulated in MHAS */
    public static final String MIMETYPE_AUDIO_MPEGH_MHM1 = "audio/mhm1";
    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";
    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";
    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";
    public static final String MIMETYPE_AUDIO_DTS_UHD = "audio/vnd.dts.uhd";
    /** MIME type for Dynamic Resolution Adaptation (DRA) audio stream. */
    /** MIME type for Dynamic Resolution Adaptation (DRA) audio stream. */
    public static final String MIMETYPE_AUDIO_DRA = "audio/vnd.dra";
    public static final String MIMETYPE_AUDIO_DRA = "audio/vnd.dra";