Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(507)

Unified Diff: webrtc/examples/androidapp/src/org/appspot/apprtc/PeerConnectionClient.java

Issue 1820113003: Add Mic Toggle button to AppRTCDemo (Android). (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Addressed comment Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/examples/androidapp/src/org/appspot/apprtc/CallFragment.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/examples/androidapp/src/org/appspot/apprtc/PeerConnectionClient.java
diff --git a/webrtc/examples/androidapp/src/org/appspot/apprtc/PeerConnectionClient.java b/webrtc/examples/androidapp/src/org/appspot/apprtc/PeerConnectionClient.java
index 69172c33a1ac6458ecddaab1c4b0ef88ff8ad3b5..9c33b6159a8da75bebcccafc734d24fb9d30a448 100644
--- a/webrtc/examples/androidapp/src/org/appspot/apprtc/PeerConnectionClient.java
+++ b/webrtc/examples/androidapp/src/org/appspot/apprtc/PeerConnectionClient.java
@@ -17,6 +17,7 @@ import android.util.Log;
import org.appspot.apprtc.AppRTCClient.SignalingParameters;
import org.appspot.apprtc.util.LooperExecutor;
+import org.webrtc.AudioTrack;
import org.webrtc.CameraEnumerationAndroid;
import org.webrtc.DataChannel;
import org.webrtc.EglBase;
@@ -124,6 +125,9 @@ public class PeerConnectionClient {
private boolean renderVideo;
private VideoTrack localVideoTrack;
private VideoTrack remoteVideoTrack;
+ // enableAudio is set to true if audio should be sent.
+ private boolean enableAudio;
+ private AudioTrack localAudioTrack;
/**
* Peer connection parameters.
@@ -252,6 +256,8 @@ public class PeerConnectionClient {
renderVideo = true;
localVideoTrack = null;
remoteVideoTrack = null;
+ enableAudio = true;
+ localAudioTrack = null;
statsTimer = new Timer();
executor.execute(new Runnable() {
@@ -492,9 +498,7 @@ public class PeerConnectionClient {
mediaStream.addTrack(createVideoTrack(videoCapturer));
}
- mediaStream.addTrack(factory.createAudioTrack(
- AUDIO_TRACK_ID,
- factory.createAudioSource(audioConstraints)));
+ mediaStream.addTrack(createAudioTrack());
peerConnection.addStream(mediaStream);
if (peerConnectionParameters.aecDump) {
@@ -605,6 +609,18 @@ public class PeerConnectionClient {
}
}
+ public void setAudioEnabled(final boolean enable) {
+ executor.execute(new Runnable() {
+ @Override
+ public void run() {
+ enableAudio = enable;
+ if (localAudioTrack != null) {
+ localAudioTrack.setEnabled(enableAudio);
+ }
+ }
+ });
+ }
+
public void setVideoEnabled(final boolean enable) {
executor.execute(new Runnable() {
@Override
@@ -749,6 +765,14 @@ public class PeerConnectionClient {
});
}
+ private AudioTrack createAudioTrack() {
+ localAudioTrack = factory.createAudioTrack(
+ AUDIO_TRACK_ID,
+ factory.createAudioSource(audioConstraints));
+ localAudioTrack.setEnabled(enableAudio);
+ return localAudioTrack;
+ }
+
private VideoTrack createVideoTrack(VideoCapturerAndroid capturer) {
videoSource = factory.createVideoSource(capturer, videoConstraints);
« no previous file with comments | « webrtc/examples/androidapp/src/org/appspot/apprtc/CallFragment.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698