summaryrefslogtreecommitdiffstats
path: root/src/com/android
diff options
context:
space:
mode:
authorKryten2k35 <kryten2k35@gmail.com>2014-09-18 21:46:23 +0100
committeremancebo <emancebo@cyngn.com>2014-11-07 09:07:55 -0800
commit16a17cd0e273efffe7b163c3a248807ec4475e00 (patch)
treecd24533ace21d44ee0b31f6bd27f00213c3df3b0 /src/com/android
parent84f8765dfc20cba00981e9abb8d86e4665b61486 (diff)
downloadandroid_packages_apps_Dialer-16a17cd0e273efffe7b163c3a248807ec4475e00.tar.gz
android_packages_apps_Dialer-16a17cd0e273efffe7b163c3a248807ec4475e00.tar.bz2
android_packages_apps_Dialer-16a17cd0e273efffe7b163c3a248807ec4475e00.zip
Call recording encoder/format choice 1/3
PS1: Adds a user option between WB AMR (the default) or HE-AAC for the encoding of call recording audio. Also changes the output format of the file appropriately (WB AMR now uses the WB_AMR output format and HE_AAC chooses the MPEG_4 output. File extensions are adjust accordingly as well). This was in reponse to people complaining the quality of call recording audio is poor. It's noticibly better using HE-AAC, but filesizes are larger. PS2: Removed unnecessary code in DialtactsActivity (see Teleservice patch). Removed whitespace and changed coding style to meet the standard PS3: Fixed whitespace, finally! Change-Id: I95620bf944e18491652c716890396c3da4be70c4
Diffstat (limited to 'src/com/android')
-rw-r--r--src/com/android/services/callrecorder/CallRecorderService.java35
1 files changed, 32 insertions, 3 deletions
diff --git a/src/com/android/services/callrecorder/CallRecorderService.java b/src/com/android/services/callrecorder/CallRecorderService.java
index eef17f998..2df222dca 100644
--- a/src/com/android/services/callrecorder/CallRecorderService.java
+++ b/src/com/android/services/callrecorder/CallRecorderService.java
@@ -23,6 +23,7 @@ import android.media.MediaRecorder;
import android.os.IBinder;
import android.os.RemoteException;
import android.os.SystemProperties;
+import android.provider.Settings;
import android.util.Log;
import com.android.services.callrecorder.common.CallRecording;
@@ -52,6 +53,8 @@ public class CallRecorderService extends Service {
private SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyyMMddHHmmssSSS");
+ private int mDefaultEncoder;
+
private final ICallRecorderService.Stub mBinder = new ICallRecorderService.Stub() {
@Override
public CallRecording stopRecording() {
@@ -86,6 +89,7 @@ public class CallRecorderService extends Service {
@Override
public void onCreate() {
if (DBG) Log.d(TAG, "Creating CallRecorderService");
+ mDefaultEncoder = getResources().getInteger(R.integer.call_recording_audio_encoder);
}
@Override
@@ -98,6 +102,26 @@ public class CallRecorderService extends Service {
return SystemProperties.getInt(AUDIO_SOURCE_PROPERTY, defaultValue);
}
+ private int getAudioFormat() {
+ int formatValue = Settings.System.getInt(
+ getContentResolver(), Settings.System.CALL_RECORDING_FORMAT, mDefaultEncoder);
+ if (formatValue == 0){
+ return MediaRecorder.OutputFormat.AMR_WB;
+ } else {
+ return MediaRecorder.OutputFormat.MPEG_4;
+ }
+ }
+
+ private int getAudioEncoder() {
+ int formatValue = Settings.System.getInt(
+ getContentResolver(), Settings.System.CALL_RECORDING_FORMAT, mDefaultEncoder);
+ if (formatValue == 0){
+ return MediaRecorder.AudioEncoder.AMR_WB;
+ } else {
+ return MediaRecorder.AudioEncoder.HE_AAC;
+ }
+ }
+
private synchronized boolean startRecordingInternal(File file) {
if (mMediaRecorder != null) {
if (DBG) {
@@ -113,8 +137,8 @@ public class CallRecorderService extends Service {
int audioSource = getAudioSource();
if (DBG) Log.d(TAG, "Creating media recorder with audio source " + audioSource);
mMediaRecorder.setAudioSource(audioSource);
- mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.AMR_NB);
- mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT);
+ mMediaRecorder.setOutputFormat(getAudioFormat());
+ mMediaRecorder.setAudioEncoder(getAudioEncoder());
} catch (IllegalStateException e) {
Log.w(TAG, "Error initializing media recorder", e);
return false;
@@ -179,7 +203,12 @@ public class CallRecorderService extends Service {
private String generateFilename() {
String timestamp = DATE_FORMAT.format(new Date());
- return "callrecorder_" + timestamp + ".amr";
+ int audioFormat = getAudioFormat();
+ if (audioFormat == MediaRecorder.OutputFormat.AMR_WB){
+ return "callrecorder_" + timestamp + ".amr";
+ } else {
+ return "callrecorder_" + timestamp + ".m4a ";
+ }
}
public static boolean isEnabled(Context context) {