From 4ddbc0e3773a5028b5598f8828e565a878eee8fd Mon Sep 17 00:00:00 2001 From: Phil Burk Date: Wed, 27 Jan 2016 11:45:06 -0800 Subject: [PATCH] AudioFormat: add ENCODING_IEC61937 Allows applications to wrap compressed audio in a PCM stream and pass through directly to HDMI output. Bug: 24541671 Bug: 20891646 Bug: 26373761 Change-Id: I67a25672a3b5066b5747380d013c26e60c14c272 Signed-off-by: Phil Burk --- api/current.txt | 1 + api/system-current.txt | 1 + api/test-current.txt | 1 + media/java/android/media/AudioFormat.java | 36 ++++++++++++++++++++++- 4 files changed, 38 insertions(+), 1 deletion(-) diff --git a/api/current.txt b/api/current.txt index 0b371e8743230..56b0d3a03e243 100644 --- a/api/current.txt +++ b/api/current.txt @@ -19320,6 +19320,7 @@ package android.media { field public static final int ENCODING_DTS = 7; // 0x7 field public static final int ENCODING_DTS_HD = 8; // 0x8 field public static final int ENCODING_E_AC3 = 6; // 0x6 + field public static final int ENCODING_IEC61937 = 13; // 0xd field public static final int ENCODING_INVALID = 0; // 0x0 field public static final int ENCODING_PCM_16BIT = 2; // 0x2 field public static final int ENCODING_PCM_8BIT = 3; // 0x3 diff --git a/api/system-current.txt b/api/system-current.txt index 466806522af1c..632c37c6e5ebc 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -20660,6 +20660,7 @@ package android.media { field public static final int ENCODING_DTS = 7; // 0x7 field public static final int ENCODING_DTS_HD = 8; // 0x8 field public static final int ENCODING_E_AC3 = 6; // 0x6 + field public static final int ENCODING_IEC61937 = 13; // 0xd field public static final int ENCODING_INVALID = 0; // 0x0 field public static final int ENCODING_PCM_16BIT = 2; // 0x2 field public static final int ENCODING_PCM_8BIT = 3; // 0x3 diff --git a/api/test-current.txt b/api/test-current.txt index c87da044e83fa..b1535339c0e32 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -19328,6 +19328,7 @@ package android.media { field public static final int ENCODING_DTS = 7; // 0x7 field public static final int ENCODING_DTS_HD = 8; // 0x8 field public static final int ENCODING_E_AC3 = 6; // 0x6 + field public static final int ENCODING_IEC61937 = 13; // 0xd field public static final int ENCODING_INVALID = 0; // 0x0 field public static final int ENCODING_PCM_16BIT = 2; // 0x2 field public static final int ENCODING_PCM_8BIT = 3; // 0x3 diff --git a/media/java/android/media/AudioFormat.java b/media/java/android/media/AudioFormat.java index bde3d196c37cb..000a56d186b53 100644 --- a/media/java/android/media/AudioFormat.java +++ b/media/java/android/media/AudioFormat.java @@ -251,6 +251,10 @@ public class AudioFormat { * @hide * */ public static final int ENCODING_AAC_HE_V2 = 12; + /** Audio data format: compressed audio wrapped in PCM for HDMI + * or S/PDIF passthrough. + */ + public static final int ENCODING_IEC61937 = 13; /** Invalid audio channel configuration */ /** @deprecated Use {@link #CHANNEL_INVALID} instead. */ @@ -418,6 +422,7 @@ public class AudioFormat { case ENCODING_PCM_8BIT: return 1; case ENCODING_PCM_16BIT: + case ENCODING_IEC61937: case ENCODING_DEFAULT: return 2; case ENCODING_PCM_FLOAT: @@ -443,6 +448,7 @@ public class AudioFormat { case ENCODING_AAC_LC: case ENCODING_AAC_HE_V1: case ENCODING_AAC_HE_V2: + case ENCODING_IEC61937: return true; default: return false; @@ -460,6 +466,7 @@ public class AudioFormat { case ENCODING_E_AC3: case ENCODING_DTS: case ENCODING_DTS_HD: + case ENCODING_IEC61937: return true; default: return false; @@ -483,6 +490,7 @@ public class AudioFormat { case ENCODING_AAC_LC: case ENCODING_AAC_HE_V1: case ENCODING_AAC_HE_V2: + case ENCODING_IEC61937: // wrapped in PCM but compressed return false; case ENCODING_INVALID: default: @@ -490,6 +498,30 @@ public class AudioFormat { } } + /** @hide */ + public static boolean isEncodingLinearFrames(int audioFormat) + { + switch (audioFormat) { + case ENCODING_PCM_8BIT: + case ENCODING_PCM_16BIT: + case ENCODING_PCM_FLOAT: + case ENCODING_IEC61937: // same size as stereo PCM + case ENCODING_DEFAULT: + return true; + case ENCODING_AC3: + case ENCODING_E_AC3: + case ENCODING_DTS: + case ENCODING_DTS_HD: + case ENCODING_MP3: + case ENCODING_AAC_LC: + case ENCODING_AAC_HE_V1: + case ENCODING_AAC_HE_V2: + return false; + case ENCODING_INVALID: + default: + throw new IllegalArgumentException("Bad audio format " + audioFormat); + } + } /** * Returns an array of public encoding values extracted from an array of * encoding values. @@ -715,6 +747,7 @@ public class AudioFormat { case ENCODING_E_AC3: case ENCODING_DTS: case ENCODING_DTS_HD: + case ENCODING_IEC61937: mEncoding = encoding; break; case ENCODING_INVALID: @@ -859,7 +892,8 @@ public class AudioFormat { ENCODING_AC3, ENCODING_E_AC3, ENCODING_DTS, - ENCODING_DTS_HD + ENCODING_DTS_HD, + ENCODING_IEC61937 }) @Retention(RetentionPolicy.SOURCE) public @interface Encoding {}