summaryrefslogtreecommitdiff
path: root/examples/android/src/org/appspot/apprtc/AppRTCDemoActivity.java
diff options
context:
space:
mode:
authorTorne (Richard Coles) <torne@google.com>2014-11-12 17:59:58 +0000
committerTorne (Richard Coles) <torne@google.com>2014-11-12 17:59:58 +0000
commit2eed1ff3f44fb784dbe3aece06ec6e4781e177f1 (patch)
tree3c7d78d81b4c69cae88708e072ba9eee0bec0257 /examples/android/src/org/appspot/apprtc/AppRTCDemoActivity.java
parentce708afc0470244d9ec2e52b28564c62a0f6cd01 (diff)
parentc8429e63ec07341d0055a8f31f66a995d62f8555 (diff)
downloadtalk-2eed1ff3f44fb784dbe3aece06ec6e4781e177f1.tar.gz
This commit was generated by merge_to_master.py. Change-Id: Ie97de41dee6631b70dd07c00db5bf3ad4dfe8e14
Diffstat (limited to 'examples/android/src/org/appspot/apprtc/AppRTCDemoActivity.java')
-rw-r--r--examples/android/src/org/appspot/apprtc/AppRTCDemoActivity.java24
1 files changed, 14 insertions, 10 deletions
diff --git a/examples/android/src/org/appspot/apprtc/AppRTCDemoActivity.java b/examples/android/src/org/appspot/apprtc/AppRTCDemoActivity.java
index ad0e2d5..3ad26af 100644
--- a/examples/android/src/org/appspot/apprtc/AppRTCDemoActivity.java
+++ b/examples/android/src/org/appspot/apprtc/AppRTCDemoActivity.java
@@ -34,7 +34,6 @@ import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.graphics.Color;
-import android.media.AudioManager;
import android.net.Uri;
import android.opengl.GLSurfaceView;
import android.os.Bundle;
@@ -72,6 +71,7 @@ public class AppRTCDemoActivity extends Activity
private PeerConnectionClient pc;
private AppRTCClient appRtcClient = new GAERTCClient(this, this);
private AppRTCSignalingParameters appRtcParameters;
+ private AppRTCAudioManager audioManager = null;
private View rootView;
private View menuBar;
private GLSurfaceView videoView;
@@ -187,15 +187,9 @@ public class AppRTCDemoActivity extends Activity
hudView.setVisibility(View.INVISIBLE);
addContentView(hudView, hudLayout);
- AudioManager audioManager =
- ((AudioManager) getSystemService(AUDIO_SERVICE));
- // TODO(fischman): figure out how to do this Right(tm) and remove the
- // suppression.
- @SuppressWarnings("deprecation")
- boolean isWiredHeadsetOn = audioManager.isWiredHeadsetOn();
- audioManager.setMode(isWiredHeadsetOn ?
- AudioManager.MODE_IN_CALL : AudioManager.MODE_IN_COMMUNICATION);
- audioManager.setSpeakerphoneOn(!isWiredHeadsetOn);
+ // Create and audio manager that will take care of audio routing,
+ // audio modes, audio device enumeration etc.
+ audioManager = AppRTCAudioManager.create(this);
final Intent intent = getIntent();
Uri url = intent.getData();
@@ -253,6 +247,10 @@ public class AppRTCDemoActivity extends Activity
@Override
protected void onDestroy() {
disconnect();
+ if (audioManager != null) {
+ audioManager.close();
+ audioManager = null;
+ }
super.onDestroy();
}
@@ -360,6 +358,12 @@ public class AppRTCDemoActivity extends Activity
// All events are called from UI thread.
@Override
public void onConnectedToRoom(final AppRTCSignalingParameters params) {
+ if (audioManager != null) {
+ // Store existing audio settings and change audio mode to
+ // MODE_IN_COMMUNICATION for best possible VoIP performance.
+ logAndToast("Initializing the audio manager...");
+ audioManager.init();
+ }
appRtcParameters = params;
abortUnless(PeerConnectionFactory.initializeAndroidGlobals(
this, true, true, VideoRendererGui.getEGLContext()),