diff options
author | vivek mehta <mvivek@codeaurora.org> | 2012-12-03 17:22:08 -0800 |
---|---|---|
committer | Gerrit Code Review <gerrit@review.cyanogenmod.com> | 2012-12-23 22:41:05 -0800 |
commit | d4e44f429362f1e7afefe923866c1ad90633eb55 (patch) | |
tree | 964a8d843ae5250122d010cf0c45e4db6e5bae80 /media | |
parent | 7086f427548485486f7557d1ddace5cdf00f52fe (diff) | |
download | frameworks_base-d4e44f429362f1e7afefe923866c1ad90633eb55.zip frameworks_base-d4e44f429362f1e7afefe923866c1ad90633eb55.tar.gz frameworks_base-d4e44f429362f1e7afefe923866c1ad90633eb55.tar.bz2 |
Squashed commit of audio changes from CodeAurora
MediaFile: Add DIVX and MPEG2TS file format
Change-Id: I9f8cfbe8138c6d3d0d824bff2542b91d72a06b82
audio: Define ANC headset and proxy device
Change-Id: I681d73433d874ec66ec0b1f1f39869008d7d7d0d
(cherry picked from commit 1e6c410eadfc510a9f116bb3da142214fe761225)
audio: add support for QCOM WiFi display
- Define QCOM WFD intents
- Register and handle WFD intends in AudioSystem
Change-Id: I1e5a73d4aa5595bed44d24652647c12b7ef4ae1f
audio: add support for QCOM audio formats
- Add support for EVRC, QCELP, and WMA formats
Change-Id: If3676b88fa287b484ef8616c0a6b67177b61a720
PhoneWindowManager: Changes for WFD.
- WFD now sends WIFI_DISPLAY_VIDEO intent to set UI orientation.
- PhoneWindowManager to listen for WFD intents.
- Display on WFD should be same as seen on the HDMI, so set the
orientation to HDMI orientation
Change-Id: I638adaa906e2151b1c6ae496343714fe828f5dbd
audio: add support for QCOM vocoders
- Add support for EVRC,QCELP and other
QCOM vocoders
Change-Id: I9b2a18fe7d01a9198eb470e94e7176b7a6da2c7c
Diffstat (limited to 'media')
-rw-r--r-- | media/java/android/media/AudioFormat.java | 10 | ||||
-rw-r--r-- | media/java/android/media/AudioRecord.java | 23 | ||||
-rwxr-xr-x[-rw-r--r--] | media/java/android/media/AudioService.java | 16 | ||||
-rwxr-xr-x[-rw-r--r--] | media/java/android/media/AudioSystem.java | 20 | ||||
-rw-r--r-- | media/java/android/media/AudioTrack.java | 12 | ||||
-rw-r--r-- | media/java/android/media/MediaFile.java | 51 | ||||
-rw-r--r-- | media/java/android/media/MediaRecorder.java | 13 |
7 files changed, 125 insertions, 20 deletions
diff --git a/media/java/android/media/AudioFormat.java b/media/java/android/media/AudioFormat.java index 49f498e..adfc135 100644 --- a/media/java/android/media/AudioFormat.java +++ b/media/java/android/media/AudioFormat.java @@ -36,6 +36,16 @@ public class AudioFormat { public static final int ENCODING_PCM_16BIT = 2; /** Audio data format: PCM 8 bit per sample. Not guaranteed to be supported by devices. */ public static final int ENCODING_PCM_8BIT = 3; + /** @hide */ + public static final int ENCODING_AMRNB = 100; // accessed by native code + /** @hide */ + public static final int ENCODING_AMRWB = 101; // accessed by native code + /** @hide */ + public static final int ENCODING_EVRC = 102; // accessed by native code + /** @hide */ + public static final int ENCODING_EVRCB = 103; // accessed by native code + /** @hide */ + public static final int ENCODING_EVRCWB = 104; // accessed by native code /** Invalid audio channel configuration */ /** @deprecated use CHANNEL_INVALID instead */ diff --git a/media/java/android/media/AudioRecord.java b/media/java/android/media/AudioRecord.java index 81e8028..59177a7 100644 --- a/media/java/android/media/AudioRecord.java +++ b/media/java/android/media/AudioRecord.java @@ -308,6 +308,11 @@ public class AudioRecord break; 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: mAudioFormat = audioFormat; break; default: @@ -327,8 +332,15 @@ public class AudioRecord private void audioBuffSizeCheck(int audioBufferSize) { // NB: this section is only valid with PCM data. // To update when supporting compressed formats - int frameSizeInBytes = mChannelCount - * (mAudioFormat == AudioFormat.ENCODING_PCM_8BIT ? 1 : 2); + int bytesPerSample; + if(mAudioFormat == AudioFormat.ENCODING_PCM_8BIT) + bytesPerSample = 1; + else if((mAudioFormat == AudioFormat.ENCODING_AMRWB) && + (mRecordSource != MediaRecorder.AudioSource.VOICE_COMMUNICATION)) + bytesPerSample = 61; + else + bytesPerSample = 2; + int frameSizeInBytes = mChannelCount * bytesPerSample; if ((audioBufferSize % frameSizeInBytes != 0) || (audioBufferSize < 1)) { throw (new IllegalArgumentException("Invalid audio buffer size.")); } @@ -476,7 +488,12 @@ public class AudioRecord } // PCM_8BIT is not supported at the moment - if (audioFormat != AudioFormat.ENCODING_PCM_16BIT) { + 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) { loge("getMinBufferSize(): Invalid audio format."); return AudioRecord.ERROR_BAD_VALUE; } diff --git a/media/java/android/media/AudioService.java b/media/java/android/media/AudioService.java index ed7dbac..140363d 100644..100755 --- a/media/java/android/media/AudioService.java +++ b/media/java/android/media/AudioService.java @@ -511,6 +511,7 @@ public class AudioService extends IAudioService.Stub implements OnFinished { intentFilter.addAction(Intent.ACTION_SCREEN_ON); intentFilter.addAction(Intent.ACTION_SCREEN_OFF); intentFilter.addAction(Intent.ACTION_USER_SWITCHED); + intentFilter.addAction(Intent.ACTION_WIFI_DISPLAY_AUDIO); intentFilter.addAction(Intent.ACTION_CONFIGURATION_CHANGED); // Register a configuration change listener only if requested by system properties @@ -3970,6 +3971,21 @@ public class AudioService extends IAudioService.Stub implements OnFinished { 0, 0, mStreamStates[AudioSystem.STREAM_MUSIC], 0); + } else if (action.equals(Intent.ACTION_WIFI_DISPLAY_AUDIO)) { + state = intent.getIntExtra("state", 0); + Log.v(TAG, "WiFi Display device state "+state); + boolean isConnected = mConnectedDevices.containsKey(AudioSystem.DEVICE_OUT_PROXY); + if(state == 1 && !isConnected){ + AudioSystem.setDeviceConnectionState(AudioSystem.DEVICE_OUT_PROXY, + AudioSystem.DEVICE_STATE_AVAILABLE, + ""); + mConnectedDevices.put( new Integer(AudioSystem.DEVICE_OUT_PROXY), ""); + }else if(state == 0 && isConnected){ + AudioSystem.setDeviceConnectionState(AudioSystem.DEVICE_OUT_PROXY, + AudioSystem.DEVICE_STATE_UNAVAILABLE, + ""); + mConnectedDevices.remove(AudioSystem.DEVICE_OUT_PROXY); + } } } } diff --git a/media/java/android/media/AudioSystem.java b/media/java/android/media/AudioSystem.java index dde2979..01e79e7 100644..100755 --- a/media/java/android/media/AudioSystem.java +++ b/media/java/android/media/AudioSystem.java @@ -219,7 +219,9 @@ public class AudioSystem public static final int DEVICE_OUT_USB_ACCESSORY = 0x2000; public static final int DEVICE_OUT_USB_DEVICE = 0x4000; public static final int DEVICE_OUT_REMOTE_SUBMIX = 0x8000; - + public static final int DEVICE_OUT_ANC_HEADSET = 0x10000; + public static final int DEVICE_OUT_ANC_HEADPHONE = 0x20000; + public static final int DEVICE_OUT_PROXY = 0x40000; public static final int DEVICE_OUT_DEFAULT = DEVICE_BIT_DEFAULT; public static final int DEVICE_OUT_ALL = (DEVICE_OUT_EARPIECE | @@ -238,6 +240,9 @@ public class AudioSystem DEVICE_OUT_USB_ACCESSORY | DEVICE_OUT_USB_DEVICE | DEVICE_OUT_REMOTE_SUBMIX | + DEVICE_OUT_ANC_HEADSET | + DEVICE_OUT_ANC_HEADPHONE | + DEVICE_OUT_PROXY | DEVICE_OUT_DEFAULT); public static final int DEVICE_OUT_ALL_A2DP = (DEVICE_OUT_BLUETOOTH_A2DP | DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES | @@ -262,6 +267,8 @@ public class AudioSystem public static final int DEVICE_IN_DGTL_DOCK_HEADSET = DEVICE_BIT_IN | 0x400; public static final int DEVICE_IN_USB_ACCESSORY = DEVICE_BIT_IN | 0x800; public static final int DEVICE_IN_USB_DEVICE = DEVICE_BIT_IN | 0x1000; + public static final int DEVICE_IN_ANC_HEADSET = DEVICE_BIT_IN | 0x2000; + public static final int DEVICE_IN_PROXY = DEVICE_BIT_IN | 0x4000; public static final int DEVICE_IN_DEFAULT = DEVICE_BIT_IN | DEVICE_BIT_DEFAULT; public static final int DEVICE_IN_ALL = (DEVICE_IN_COMMUNICATION | @@ -277,6 +284,8 @@ public class AudioSystem DEVICE_IN_DGTL_DOCK_HEADSET | DEVICE_IN_USB_ACCESSORY | DEVICE_IN_USB_DEVICE | + DEVICE_IN_ANC_HEADSET | + DEVICE_IN_PROXY | DEVICE_IN_DEFAULT); public static final int DEVICE_IN_ALL_SCO = DEVICE_IN_BLUETOOTH_SCO_HEADSET; @@ -301,6 +310,9 @@ public class AudioSystem public static final String DEVICE_OUT_USB_ACCESSORY_NAME = "usb_accessory"; public static final String DEVICE_OUT_USB_DEVICE_NAME = "usb_device"; public static final String DEVICE_OUT_REMOTE_SUBMIX_NAME = "remote_submix"; + public static final String DEVICE_OUT_ANC_HEADSET_NAME = "anc_headset"; + public static final String DEVICE_OUT_ANC_HEADPHONE_NAME = "anc_headphone"; + public static final String DEVICE_OUT_PROXY_NAME = "proxy"; public static String getDeviceName(int device) { @@ -337,6 +349,12 @@ public class AudioSystem return DEVICE_OUT_USB_DEVICE_NAME; case DEVICE_OUT_REMOTE_SUBMIX: return DEVICE_OUT_REMOTE_SUBMIX_NAME; + case DEVICE_OUT_ANC_HEADSET: + return DEVICE_OUT_ANC_HEADSET_NAME; + case DEVICE_OUT_ANC_HEADPHONE: + return DEVICE_OUT_ANC_HEADPHONE_NAME; + case DEVICE_OUT_PROXY: + return DEVICE_OUT_PROXY_NAME; case DEVICE_OUT_DEFAULT: default: return ""; diff --git a/media/java/android/media/AudioTrack.java b/media/java/android/media/AudioTrack.java index 96f01db..61e7932 100644 --- a/media/java/android/media/AudioTrack.java +++ b/media/java/android/media/AudioTrack.java @@ -421,6 +421,11 @@ public class AudioTrack break; 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: mAudioFormat = audioFormat; break; default: @@ -679,7 +684,12 @@ public class AudioTrack } if ((audioFormat != AudioFormat.ENCODING_PCM_16BIT) - && (audioFormat != AudioFormat.ENCODING_PCM_8BIT)) { + && (audioFormat != AudioFormat.ENCODING_PCM_8BIT) + && (audioFormat != AudioFormat.ENCODING_AMRNB) + && (audioFormat != AudioFormat.ENCODING_AMRWB) + && (audioFormat != AudioFormat.ENCODING_EVRC) + && (audioFormat != AudioFormat.ENCODING_EVRCB) + && (audioFormat != AudioFormat.ENCODING_EVRCWB)) { loge("getMinBufferSize(): Invalid audio format."); return AudioTrack.ERROR_BAD_VALUE; } diff --git a/media/java/android/media/MediaFile.java b/media/java/android/media/MediaFile.java index 06d43a2..5777729 100644 --- a/media/java/android/media/MediaFile.java +++ b/media/java/android/media/MediaFile.java @@ -1,5 +1,6 @@ /* * Copyright (C) 2007 The Android Open Source Project + * Copyright (c) 2012, The Linux Foundation. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,16 +48,27 @@ public class MediaFile { public static final int FILE_TYPE_AAC = 8; public static final int FILE_TYPE_MKA = 9; public static final int FILE_TYPE_FLAC = 10; + public static final int FILE_TYPE_3GPA = 11; + public static final int FILE_TYPE_AC3 = 12; + public static final int FILE_TYPE_QCP = 13; + public static final int FILE_TYPE_WEBMA = 14; + public static final int FILE_TYPE_PCM = 15; + public static final int FILE_TYPE_EC3 = 16; private static final int FIRST_AUDIO_FILE_TYPE = FILE_TYPE_MP3; - private static final int LAST_AUDIO_FILE_TYPE = FILE_TYPE_FLAC; + private static final int LAST_AUDIO_FILE_TYPE = FILE_TYPE_EC3; + + // More audio file types + public static final int FILE_TYPE_DTS = 300; + private static final int FIRST_AUDIO_FILE_TYPE2 = FILE_TYPE_DTS; + private static final int LAST_AUDIO_FILE_TYPE2 = FILE_TYPE_DTS; // MIDI file types - public static final int FILE_TYPE_MID = 11; - public static final int FILE_TYPE_SMF = 12; - public static final int FILE_TYPE_IMY = 13; + public static final int FILE_TYPE_MID = 16; + public static final int FILE_TYPE_SMF = 17; + public static final int FILE_TYPE_IMY = 18; private static final int FIRST_MIDI_FILE_TYPE = FILE_TYPE_MID; private static final int LAST_MIDI_FILE_TYPE = FILE_TYPE_IMY; - + // Video file types public static final int FILE_TYPE_MP4 = 21; public static final int FILE_TYPE_M4V = 22; @@ -68,9 +80,10 @@ public class MediaFile { public static final int FILE_TYPE_MP2TS = 28; public static final int FILE_TYPE_AVI = 29; public static final int FILE_TYPE_WEBM = 30; + public static final int FILE_TYPE_DIVX = 31; private static final int FIRST_VIDEO_FILE_TYPE = FILE_TYPE_MP4; - private static final int LAST_VIDEO_FILE_TYPE = FILE_TYPE_WEBM; - + private static final int LAST_VIDEO_FILE_TYPE = FILE_TYPE_DIVX; + // More video file types public static final int FILE_TYPE_MP2PS = 200; private static final int FIRST_VIDEO_FILE_TYPE2 = FILE_TYPE_MP2PS; @@ -85,7 +98,7 @@ public class MediaFile { public static final int FILE_TYPE_WEBP = 36; private static final int FIRST_IMAGE_FILE_TYPE = FILE_TYPE_JPEG; private static final int LAST_IMAGE_FILE_TYPE = FILE_TYPE_WEBP; - + // Playlist file types public static final int FILE_TYPE_M3U = 41; public static final int FILE_TYPE_PLS = 42; @@ -109,17 +122,17 @@ public class MediaFile { public static final int FILE_TYPE_MS_EXCEL = 105; public static final int FILE_TYPE_MS_POWERPOINT = 106; public static final int FILE_TYPE_ZIP = 107; - + public static class MediaFileType { public final int fileType; public final String mimeType; - + MediaFileType(int fileType, String mimeType) { this.fileType = fileType; this.mimeType = mimeType; } } - + private static final HashMap<String, MediaFileType> sFileTypeMap = new HashMap<String, MediaFileType>(); private static final HashMap<String, Integer> sMimeTypeMap @@ -175,18 +188,22 @@ public class MediaFile { addFileType("MPGA", FILE_TYPE_MP3, "audio/mpeg", MtpConstants.FORMAT_MP3); addFileType("M4A", FILE_TYPE_M4A, "audio/mp4", MtpConstants.FORMAT_MPEG); addFileType("WAV", FILE_TYPE_WAV, "audio/x-wav", MtpConstants.FORMAT_WAV); + addFileType("WAV", FILE_TYPE_PCM, "audio/wav"); addFileType("AMR", FILE_TYPE_AMR, "audio/amr"); addFileType("AWB", FILE_TYPE_AWB, "audio/amr-wb"); + addFileType("DIVX", FILE_TYPE_DIVX, "video/divx"); if (isWMAEnabled()) { addFileType("WMA", FILE_TYPE_WMA, "audio/x-ms-wma", MtpConstants.FORMAT_WMA); } + addFileType("QCP", FILE_TYPE_QCP, "audio/qcelp"); addFileType("OGG", FILE_TYPE_OGG, "audio/ogg", MtpConstants.FORMAT_OGG); addFileType("OGG", FILE_TYPE_OGG, "application/ogg", MtpConstants.FORMAT_OGG); + addFileType("OGA", FILE_TYPE_OGG, "audio/ogg", MtpConstants.FORMAT_OGG); addFileType("OGA", FILE_TYPE_OGG, "application/ogg", MtpConstants.FORMAT_OGG); addFileType("AAC", FILE_TYPE_AAC, "audio/aac", MtpConstants.FORMAT_AAC); addFileType("AAC", FILE_TYPE_AAC, "audio/aac-adts", MtpConstants.FORMAT_AAC); addFileType("MKA", FILE_TYPE_MKA, "audio/x-matroska"); - + addFileType("MID", FILE_TYPE_MID, "audio/midi"); addFileType("MIDI", FILE_TYPE_MID, "audio/midi"); addFileType("XMF", FILE_TYPE_MID, "audio/midi"); @@ -196,7 +213,7 @@ public class MediaFile { addFileType("RTX", FILE_TYPE_MID, "audio/midi"); addFileType("OTA", FILE_TYPE_MID, "audio/midi"); addFileType("MXMF", FILE_TYPE_MID, "audio/midi"); - + addFileType("MPEG", FILE_TYPE_MP4, "video/mpeg", MtpConstants.FORMAT_MPEG); addFileType("MPG", FILE_TYPE_MP4, "video/mpeg", MtpConstants.FORMAT_MPEG); addFileType("MP4", FILE_TYPE_MP4, "video/mp4", MtpConstants.FORMAT_MPEG); @@ -208,6 +225,8 @@ public class MediaFile { addFileType("MKV", FILE_TYPE_MKV, "video/x-matroska"); addFileType("WEBM", FILE_TYPE_WEBM, "video/webm"); addFileType("TS", FILE_TYPE_MP2TS, "video/mp2ts"); + addFileType("MPG", FILE_TYPE_MP2TS, "video/mp2ts"); + addFileType("AVI", FILE_TYPE_AVI, "video/avi"); if (isWMVEnabled()) { @@ -222,7 +241,7 @@ public class MediaFile { addFileType("BMP", FILE_TYPE_BMP, "image/x-ms-bmp", MtpConstants.FORMAT_BMP); addFileType("WBMP", FILE_TYPE_WBMP, "image/vnd.wap.wbmp"); addFileType("WEBP", FILE_TYPE_WEBP, "image/webp"); - + addFileType("M3U", FILE_TYPE_M3U, "audio/x-mpegurl", MtpConstants.FORMAT_M3U_PLAYLIST); addFileType("M3U", FILE_TYPE_M3U, "application/x-mpegurl", MtpConstants.FORMAT_M3U_PLAYLIST); addFileType("PLS", FILE_TYPE_PLS, "audio/x-scpls", MtpConstants.FORMAT_PLS_PLAYLIST); @@ -250,7 +269,9 @@ public class MediaFile { 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_TYPE2 && + fileType <= LAST_AUDIO_FILE_TYPE2)); } public static boolean isVideoFileType(int fileType) { diff --git a/media/java/android/media/MediaRecorder.java b/media/java/android/media/MediaRecorder.java index 48bea52..544410f 100644 --- a/media/java/android/media/MediaRecorder.java +++ b/media/java/android/media/MediaRecorder.java @@ -241,6 +241,13 @@ public class MediaRecorder /** @hide H.264/AAC data encapsulated in MPEG2/TS */ public static final int OUTPUT_FORMAT_MPEG2TS = 8; + + /** @hide QCP file format */ + public static final int QCP = 9; + /** @hide 3GPP2 media file format*/ + public static final int THREE_GPP2 = 10; + /** @hide WAVE media file format*/ + public static final int WAVE = 11; }; /** @@ -263,6 +270,12 @@ public class MediaRecorder public static final int HE_AAC = 4; /** Enhanced Low Delay AAC (AAC-ELD) audio codec */ public static final int AAC_ELD = 5; + /** @hide EVRC audio codec */ + public static final int EVRC = 6; + /** @hide QCELP audio codec */ + public static final int QCELP =7; + /** @hide Linear PCM audio codec */ + public static final int LPCM =8; } /** |