diff options
author | Mingming Yin <mingming@codeaurora.org> | 2015-08-11 10:32:57 -0700 |
---|---|---|
committer | Linux Build Service Account <lnxbuild@localhost> | 2015-10-06 03:27:18 -0600 |
commit | 2bf89af522103e62e1264cdf273b5859fe4253f8 (patch) | |
tree | edd95caf5f62502a11fa6bfbe4b376d0d98976a8 | |
parent | 887b3242c97056c69d17c3ddff948f8722ec0edb (diff) | |
download | frameworks_base-2bf89af522103e62e1264cdf273b5859fe4253f8.zip frameworks_base-2bf89af522103e62e1264cdf273b5859fe4253f8.tar.gz frameworks_base-2bf89af522103e62e1264cdf273b5859fe4253f8.tar.bz2 |
audio: add support for extended audio encoding
- add support for EVRC, QCELP ,LPCM, and multichannel
encoding.
Change-Id: I9542ec9dec1872237940846952d28bef3ce24285
-rw-r--r-- | core/jni/android_media_AudioFormat.h | 32 | ||||
-rw-r--r-- | media/java/android/media/AudioFormat.java | 64 | ||||
-rw-r--r-- | media/java/android/media/AudioRecord.java | 21 | ||||
-rw-r--r-- | media/java/android/media/MediaFile.java | 22 | ||||
-rw-r--r-- | media/java/android/media/MediaRecorder.java | 13 |
5 files changed, 150 insertions, 2 deletions
diff --git a/core/jni/android_media_AudioFormat.h b/core/jni/android_media_AudioFormat.h index bb13c35..211b4f0 100644 --- a/core/jni/android_media_AudioFormat.h +++ b/core/jni/android_media_AudioFormat.h @@ -31,6 +31,14 @@ #define ENCODING_AAC_LC 10 #define ENCODING_AAC_HE_V1 11 #define ENCODING_AAC_HE_V2 12 + +#define ENCODING_AMR_NB 100 +#define ENCODING_AMR_WB 101 +#define ENCODING_EVRC 102 +#define ENCODING_EVRC_B 103 +#define ENCODING_EVRC_WB 104 +#define ENCODING_EVRC_NW 105 + #define ENCODING_INVALID 0 #define ENCODING_DEFAULT 1 @@ -64,6 +72,18 @@ static inline audio_format_t audioFormatToNative(int audioFormat) return AUDIO_FORMAT_AAC_HE_V1; case ENCODING_AAC_HE_V2: return AUDIO_FORMAT_AAC_HE_V2; + case ENCODING_AMR_NB: + return AUDIO_FORMAT_AMR_NB; + case ENCODING_AMR_WB: + return AUDIO_FORMAT_AMR_WB; + case ENCODING_EVRC: + return AUDIO_FORMAT_EVRC; + case ENCODING_EVRC_B: + return AUDIO_FORMAT_EVRCB; + case ENCODING_EVRC_WB: + return AUDIO_FORMAT_EVRCWB; + case ENCODING_EVRC_NW: + return AUDIO_FORMAT_EVRCNW; case ENCODING_DEFAULT: return AUDIO_FORMAT_DEFAULT; default: @@ -103,6 +123,18 @@ static inline int audioFormatFromNative(audio_format_t nativeFormat) return ENCODING_AAC_HE_V1; case AUDIO_FORMAT_AAC_HE_V2: return ENCODING_AAC_HE_V2; + case AUDIO_FORMAT_AMR_NB: + return ENCODING_AMR_NB; + case AUDIO_FORMAT_AMR_WB: + return ENCODING_AMR_WB; + case AUDIO_FORMAT_EVRC: + return ENCODING_EVRC; + case AUDIO_FORMAT_EVRCB: + return ENCODING_EVRC_B; + case AUDIO_FORMAT_EVRCWB: + return ENCODING_EVRC_WB; + case AUDIO_FORMAT_EVRCNW: + return ENCODING_EVRC_NW; case AUDIO_FORMAT_DEFAULT: return ENCODING_DEFAULT; default: diff --git a/media/java/android/media/AudioFormat.java b/media/java/android/media/AudioFormat.java index bde3d19..962316b 100644 --- a/media/java/android/media/AudioFormat.java +++ b/media/java/android/media/AudioFormat.java @@ -252,6 +252,30 @@ public class AudioFormat { * */ public static final int ENCODING_AAC_HE_V2 = 12; + /** Audio data format: AMRNB + * @hide + * */ + public static final int ENCODING_AMRNB = 100; + /** Audio data format: AMRWB + * @hide + * */ + public static final int ENCODING_AMRWB = 101; + /** Audio data format: EVRC + * @hide + * */ + public static final int ENCODING_EVRC = 102; + /** Audio data format: EVRCB + * @hide + * */ + public static final int ENCODING_EVRCB = 103; + /** Audio data format: EVRCWB + * @hide + * */ + public static final int ENCODING_EVRCWB = 104; + /** Audio data format: EVRCNW + * @hide + * */ + public static final int ENCODING_EVRCNW = 105; /** Invalid audio channel configuration */ /** @deprecated Use {@link #CHANNEL_INVALID} instead. */ @Deprecated public static final int CHANNEL_CONFIGURATION_INVALID = 0; @@ -409,6 +433,11 @@ public class AudioFormat { public static final int CHANNEL_IN_STEREO = (CHANNEL_IN_LEFT | CHANNEL_IN_RIGHT); /** @hide */ public static final int CHANNEL_IN_FRONT_BACK = CHANNEL_IN_FRONT | CHANNEL_IN_BACK; + /** @hide */ + public static final int CHANNEL_IN_5POINT1 = (CHANNEL_IN_LEFT | + CHANNEL_IN_RIGHT | CHANNEL_IN_FRONT | CHANNEL_IN_BACK | + CHANNEL_IN_LEFT_PROCESSED | CHANNEL_IN_RIGHT_PROCESSED); + // CHANNEL_IN_ALL is not yet defined; if added then it should match AUDIO_CHANNEL_IN_ALL /** @hide */ @@ -422,6 +451,15 @@ public class AudioFormat { return 2; case ENCODING_PCM_FLOAT: return 4; + case ENCODING_AMRNB: + return 32; + case ENCODING_AMRWB: + return 61; + case ENCODING_EVRC: + case ENCODING_EVRCB: + case ENCODING_EVRCWB: + case ENCODING_EVRCNW: + return 23; case ENCODING_INVALID: default: throw new IllegalArgumentException("Bad audio format " + audioFormat); @@ -443,6 +481,12 @@ public class AudioFormat { case ENCODING_AAC_LC: case ENCODING_AAC_HE_V1: case ENCODING_AAC_HE_V2: + case ENCODING_AMRNB: + case ENCODING_AMRWB: + case ENCODING_EVRC: + case ENCODING_EVRCB: + case ENCODING_EVRCWB: + case ENCODING_EVRCNW: return true; default: return false; @@ -483,6 +527,12 @@ public class AudioFormat { case ENCODING_AAC_LC: case ENCODING_AAC_HE_V1: case ENCODING_AAC_HE_V2: + case ENCODING_AMRNB: + case ENCODING_AMRWB: + case ENCODING_EVRC: + case ENCODING_EVRCB: + case ENCODING_EVRCWB: + case ENCODING_EVRCNW: return false; case ENCODING_INVALID: default: @@ -715,6 +765,12 @@ public class AudioFormat { case ENCODING_E_AC3: case ENCODING_DTS: case ENCODING_DTS_HD: + case ENCODING_AMRNB: + case ENCODING_AMRWB: + case ENCODING_EVRC: + case ENCODING_EVRCB: + case ENCODING_EVRCWB: + case ENCODING_EVRCNW: mEncoding = encoding; break; case ENCODING_INVALID: @@ -859,7 +915,13 @@ public class AudioFormat { ENCODING_AC3, ENCODING_E_AC3, ENCODING_DTS, - ENCODING_DTS_HD + ENCODING_DTS_HD, + ENCODING_AMRNB, + ENCODING_AMRWB, + ENCODING_EVRC, + ENCODING_EVRCB, + ENCODING_EVRCWB, + ENCODING_EVRCNW }) @Retention(RetentionPolicy.SOURCE) public @interface Encoding {} diff --git a/media/java/android/media/AudioRecord.java b/media/java/android/media/AudioRecord.java index 974b62e..8b7a396 100644 --- a/media/java/android/media/AudioRecord.java +++ b/media/java/android/media/AudioRecord.java @@ -643,6 +643,12 @@ public class AudioRecord case AudioFormat.ENCODING_PCM_FLOAT: case AudioFormat.ENCODING_PCM_16BIT: case AudioFormat.ENCODING_PCM_8BIT: + case AudioFormat.ENCODING_AMRNB: + case AudioFormat.ENCODING_AMRWB: + case AudioFormat.ENCODING_EVRC: + case AudioFormat.ENCODING_EVRCB: + case AudioFormat.ENCODING_EVRCWB: + case AudioFormat.ENCODING_EVRCNW: mAudioFormat = audioFormat; break; default: @@ -845,12 +851,27 @@ public class AudioRecord case (AudioFormat.CHANNEL_IN_FRONT | AudioFormat.CHANNEL_IN_BACK): channelCount = 2; break; + case AudioFormat.CHANNEL_IN_5POINT1: + channelCount = 6; + break; case AudioFormat.CHANNEL_INVALID: default: loge("getMinBufferSize(): Invalid channel configuration."); return ERROR_BAD_VALUE; } + // PCM_8BIT is not supported at the moment + if (audioFormat != AudioFormat.ENCODING_PCM_16BIT + && audioFormat != AudioFormat.ENCODING_AMRNB + && audioFormat != AudioFormat.ENCODING_AMRWB + && audioFormat != AudioFormat.ENCODING_EVRC + && audioFormat != AudioFormat.ENCODING_EVRCB + && audioFormat != AudioFormat.ENCODING_EVRCWB + && audioFormat != AudioFormat.ENCODING_EVRCNW) { + loge("getMinBufferSize(): Invalid audio format."); + return ERROR_BAD_VALUE; + } + int size = native_get_min_buff_size(sampleRateInHz, channelCount, audioFormat); if (size == 0) { return ERROR_BAD_VALUE; diff --git a/media/java/android/media/MediaFile.java b/media/java/android/media/MediaFile.java index 22669a5..e91548c 100644 --- a/media/java/android/media/MediaFile.java +++ b/media/java/android/media/MediaFile.java @@ -46,6 +46,18 @@ public class MediaFile { private static final int FIRST_AUDIO_FILE_TYPE = FILE_TYPE_MP3; private static final int LAST_AUDIO_FILE_TYPE = FILE_TYPE_FLAC; + // More audio file types + public static final int FILE_TYPE_DTS = 300; + public static final int FILE_TYPE_3GPA = 301; + public static final int FILE_TYPE_AC3 = 302; + public static final int FILE_TYPE_QCP = 303; + public static final int FILE_TYPE_PCM = 304; + public static final int FILE_TYPE_EC3 = 305; + public static final int FILE_TYPE_AIFF = 306; + public static final int FILE_TYPE_APE = 307; + private static final int FIRST_AUDIO_FILE_TYPE_EXT = FILE_TYPE_DTS; + private static final int LAST_AUDIO_FILE_TYPE_EXT = FILE_TYPE_APE; + // MIDI file types public static final int FILE_TYPE_MID = 11; public static final int FILE_TYPE_SMF = 12; @@ -246,13 +258,21 @@ public class MediaFile { addFileType("DIVX", FILE_TYPE_DIVX, "video/divx"); addFileType("FLV", FILE_TYPE_FLV, "video/flv"); addFileType("MPD", FILE_TYPE_DASH, "application/dash+xml"); + addFileType("QCP", FILE_TYPE_QCP, "audio/qcelp"); + addFileType("AC3", FILE_TYPE_AC3, "audio/ac3"); + addFileType("EC3", FILE_TYPE_EC3, "audio/eac3"); + addFileType("AIF", FILE_TYPE_AIFF, "audio/x-aiff"); + addFileType("AIFF", FILE_TYPE_AIFF, "audio/x-aiff"); + addFileType("APE", FILE_TYPE_APE, "audio/x-ape"); } public static boolean isAudioFileType(int fileType) { return ((fileType >= FIRST_AUDIO_FILE_TYPE && fileType <= LAST_AUDIO_FILE_TYPE) || (fileType >= FIRST_MIDI_FILE_TYPE && - fileType <= LAST_MIDI_FILE_TYPE)); + fileType <= LAST_MIDI_FILE_TYPE) || + (fileType >= FIRST_AUDIO_FILE_TYPE_EXT && + fileType <= LAST_AUDIO_FILE_TYPE_EXT)); } public static boolean isVideoFileType(int fileType) { diff --git a/media/java/android/media/MediaRecorder.java b/media/java/android/media/MediaRecorder.java index ed2c4cbd..6dae6cc 100644 --- a/media/java/android/media/MediaRecorder.java +++ b/media/java/android/media/MediaRecorder.java @@ -345,6 +345,13 @@ public class MediaRecorder /** VP8/VORBIS data in a WEBM container */ public static final int WEBM = 9; + + /** @hide QCP file format */ + public static final int QCP = 20; + + /** @hide WAVE media file format*/ + public static final int WAVE = 21; + }; /** @@ -369,6 +376,12 @@ public class MediaRecorder public static final int AAC_ELD = 5; /** Ogg Vorbis audio codec */ public static final int VORBIS = 6; + /** @hide EVRC audio codec */ + public static final int EVRC = 10; + /** @hide QCELP audio codec */ + public static final int QCELP = 11; + /** @hide Linear PCM audio codec */ + public static final int LPCM = 12; } /** |