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

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

Issue 1514473008: Add aecdump support to AppRTCDemo (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fix try and tests Created 5 years 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2014 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2014 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 package org.appspot.apprtc; 11 package org.appspot.apprtc;
12 12
13 import android.content.Context; 13 import android.content.Context;
14 import android.os.ParcelFileDescriptor;
14 import android.util.Log; 15 import android.util.Log;
15 16
16 import org.appspot.apprtc.AppRTCClient.SignalingParameters; 17 import org.appspot.apprtc.AppRTCClient.SignalingParameters;
17 import org.appspot.apprtc.util.LooperExecutor; 18 import org.appspot.apprtc.util.LooperExecutor;
18 import org.webrtc.CameraEnumerationAndroid; 19 import org.webrtc.CameraEnumerationAndroid;
19 import org.webrtc.DataChannel; 20 import org.webrtc.DataChannel;
20 import org.webrtc.EglBase; 21 import org.webrtc.EglBase;
21 import org.webrtc.IceCandidate; 22 import org.webrtc.IceCandidate;
22 import org.webrtc.Logging; 23 import org.webrtc.Logging;
23 import org.webrtc.MediaCodecVideoEncoder; 24 import org.webrtc.MediaCodecVideoEncoder;
24 import org.webrtc.MediaConstraints; 25 import org.webrtc.MediaConstraints;
25 import org.webrtc.MediaConstraints.KeyValuePair; 26 import org.webrtc.MediaConstraints.KeyValuePair;
26 import org.webrtc.MediaStream; 27 import org.webrtc.MediaStream;
27 import org.webrtc.PeerConnection; 28 import org.webrtc.PeerConnection;
28 import org.webrtc.PeerConnection.IceConnectionState; 29 import org.webrtc.PeerConnection.IceConnectionState;
29 import org.webrtc.PeerConnectionFactory; 30 import org.webrtc.PeerConnectionFactory;
30 import org.webrtc.SdpObserver; 31 import org.webrtc.SdpObserver;
31 import org.webrtc.SessionDescription; 32 import org.webrtc.SessionDescription;
32 import org.webrtc.StatsObserver; 33 import org.webrtc.StatsObserver;
33 import org.webrtc.StatsReport; 34 import org.webrtc.StatsReport;
34 import org.webrtc.VideoCapturerAndroid; 35 import org.webrtc.VideoCapturerAndroid;
35 import org.webrtc.VideoRenderer; 36 import org.webrtc.VideoRenderer;
36 import org.webrtc.VideoSource; 37 import org.webrtc.VideoSource;
37 import org.webrtc.VideoTrack; 38 import org.webrtc.VideoTrack;
38 import org.webrtc.voiceengine.WebRtcAudioManager; 39 import org.webrtc.voiceengine.WebRtcAudioManager;
39 40
41 import java.io.File;
42 import java.io.IOException;
40 import java.util.EnumSet; 43 import java.util.EnumSet;
41 import java.util.LinkedList; 44 import java.util.LinkedList;
42 import java.util.Timer; 45 import java.util.Timer;
43 import java.util.TimerTask; 46 import java.util.TimerTask;
44 import java.util.regex.Matcher; 47 import java.util.regex.Matcher;
45 import java.util.regex.Pattern; 48 import java.util.regex.Pattern;
46 49
47 import javax.microedition.khronos.egl.EGLContext; 50 import javax.microedition.khronos.egl.EGLContext;
48 51
49 /** 52 /**
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 private String preferredVideoCodec; 101 private String preferredVideoCodec;
99 private boolean videoSourceStopped; 102 private boolean videoSourceStopped;
100 private boolean isError; 103 private boolean isError;
101 private Timer statsTimer; 104 private Timer statsTimer;
102 private VideoRenderer.Callbacks localRender; 105 private VideoRenderer.Callbacks localRender;
103 private VideoRenderer.Callbacks remoteRender; 106 private VideoRenderer.Callbacks remoteRender;
104 private SignalingParameters signalingParameters; 107 private SignalingParameters signalingParameters;
105 private MediaConstraints pcConstraints; 108 private MediaConstraints pcConstraints;
106 private MediaConstraints videoConstraints; 109 private MediaConstraints videoConstraints;
107 private MediaConstraints audioConstraints; 110 private MediaConstraints audioConstraints;
111 private ParcelFileDescriptor aecDumpFileDescriptor;
108 private MediaConstraints sdpMediaConstraints; 112 private MediaConstraints sdpMediaConstraints;
109 private PeerConnectionParameters peerConnectionParameters; 113 private PeerConnectionParameters peerConnectionParameters;
110 // Queued remote ICE candidates are consumed only after both local and 114 // Queued remote ICE candidates are consumed only after both local and
111 // remote descriptions are set. Similarly local ICE candidates are sent to 115 // remote descriptions are set. Similarly local ICE candidates are sent to
112 // remote peer after both local and remote description are set. 116 // remote peer after both local and remote description are set.
113 private LinkedList<IceCandidate> queuedRemoteCandidates; 117 private LinkedList<IceCandidate> queuedRemoteCandidates;
114 private PeerConnectionEvents events; 118 private PeerConnectionEvents events;
115 private boolean isInitiator; 119 private boolean isInitiator;
116 private SessionDescription localSdp; // either offer or answer SDP 120 private SessionDescription localSdp; // either offer or answer SDP
117 private MediaStream mediaStream; 121 private MediaStream mediaStream;
(...skipping 13 matching lines...) Expand all
131 public final int videoWidth; 135 public final int videoWidth;
132 public final int videoHeight; 136 public final int videoHeight;
133 public final int videoFps; 137 public final int videoFps;
134 public final int videoStartBitrate; 138 public final int videoStartBitrate;
135 public final String videoCodec; 139 public final String videoCodec;
136 public final boolean videoCodecHwAcceleration; 140 public final boolean videoCodecHwAcceleration;
137 public final boolean captureToTexture; 141 public final boolean captureToTexture;
138 public final int audioStartBitrate; 142 public final int audioStartBitrate;
139 public final String audioCodec; 143 public final String audioCodec;
140 public final boolean noAudioProcessing; 144 public final boolean noAudioProcessing;
145 public final boolean aecDump;
141 public final boolean useOpenSLES; 146 public final boolean useOpenSLES;
142 147
143 public PeerConnectionParameters( 148 public PeerConnectionParameters(
144 boolean videoCallEnabled, boolean loopback, 149 boolean videoCallEnabled, boolean loopback,
145 int videoWidth, int videoHeight, int videoFps, int videoStartBitrate, 150 int videoWidth, int videoHeight, int videoFps, int videoStartBitrate,
146 String videoCodec, boolean videoCodecHwAcceleration, boolean captureToTe xture, 151 String videoCodec, boolean videoCodecHwAcceleration, boolean captureToTe xture,
147 int audioStartBitrate, String audioCodec, 152 int audioStartBitrate, String audioCodec,
148 boolean noAudioProcessing, boolean useOpenSLES) { 153 boolean noAudioProcessing, boolean aecDump, boolean useOpenSLES) {
149 this.videoCallEnabled = videoCallEnabled; 154 this.videoCallEnabled = videoCallEnabled;
150 this.loopback = loopback; 155 this.loopback = loopback;
151 this.videoWidth = videoWidth; 156 this.videoWidth = videoWidth;
152 this.videoHeight = videoHeight; 157 this.videoHeight = videoHeight;
153 this.videoFps = videoFps; 158 this.videoFps = videoFps;
154 this.videoStartBitrate = videoStartBitrate; 159 this.videoStartBitrate = videoStartBitrate;
155 this.videoCodec = videoCodec; 160 this.videoCodec = videoCodec;
156 this.videoCodecHwAcceleration = videoCodecHwAcceleration; 161 this.videoCodecHwAcceleration = videoCodecHwAcceleration;
157 this.captureToTexture = captureToTexture; 162 this.captureToTexture = captureToTexture;
158 this.audioStartBitrate = audioStartBitrate; 163 this.audioStartBitrate = audioStartBitrate;
159 this.audioCodec = audioCodec; 164 this.audioCodec = audioCodec;
160 this.noAudioProcessing = noAudioProcessing; 165 this.noAudioProcessing = noAudioProcessing;
166 this.aecDump = aecDump;
161 this.useOpenSLES = useOpenSLES; 167 this.useOpenSLES = useOpenSLES;
162 } 168 }
163 } 169 }
164 170
165 /** 171 /**
166 * Peer connection events. 172 * Peer connection events.
167 */ 173 */
168 public static interface PeerConnectionEvents { 174 public static interface PeerConnectionEvents {
169 /** 175 /**
170 * Callback fired once local SDP is created and set. 176 * Callback fired once local SDP is created and set.
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 return; 478 return;
473 } 479 }
474 mediaStream.addTrack(createVideoTrack(videoCapturer)); 480 mediaStream.addTrack(createVideoTrack(videoCapturer));
475 } 481 }
476 482
477 mediaStream.addTrack(factory.createAudioTrack( 483 mediaStream.addTrack(factory.createAudioTrack(
478 AUDIO_TRACK_ID, 484 AUDIO_TRACK_ID,
479 factory.createAudioSource(audioConstraints))); 485 factory.createAudioSource(audioConstraints)));
480 peerConnection.addStream(mediaStream); 486 peerConnection.addStream(mediaStream);
481 487
488 if (peerConnectionParameters.aecDump) {
489 try {
490 aecDumpFileDescriptor = ParcelFileDescriptor.open(
491 new File("/sdcard/Download/audio.aecdump"),
492 ParcelFileDescriptor.MODE_READ_WRITE |
493 ParcelFileDescriptor.MODE_CREATE |
494 ParcelFileDescriptor.MODE_TRUNCATE);
495 factory.startAecDump(aecDumpFileDescriptor.getFd());
496 } catch(IOException e) {
497 Log.e(TAG, "Can not open aecdump file", e);
498 }
499 }
500
482 Log.d(TAG, "Peer connection created."); 501 Log.d(TAG, "Peer connection created.");
483 } 502 }
484 503
485 private void closeInternal() { 504 private void closeInternal() {
505 if (factory != null && peerConnectionParameters.aecDump) {
506 factory.stopAecDump();
507 }
486 Log.d(TAG, "Closing peer connection."); 508 Log.d(TAG, "Closing peer connection.");
487 statsTimer.cancel(); 509 statsTimer.cancel();
488 if (peerConnection != null) { 510 if (peerConnection != null) {
489 peerConnection.dispose(); 511 peerConnection.dispose();
490 peerConnection = null; 512 peerConnection = null;
491 } 513 }
492 Log.d(TAG, "Closing video source."); 514 Log.d(TAG, "Closing video source.");
493 if (videoSource != null) { 515 if (videoSource != null) {
494 videoSource.dispose(); 516 videoSource.dispose();
495 videoSource = null; 517 videoSource = null;
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after
1046 public void onCreateFailure(final String error) { 1068 public void onCreateFailure(final String error) {
1047 reportError("createSDP error: " + error); 1069 reportError("createSDP error: " + error);
1048 } 1070 }
1049 1071
1050 @Override 1072 @Override
1051 public void onSetFailure(final String error) { 1073 public void onSetFailure(final String error) {
1052 reportError("setSDP error: " + error); 1074 reportError("setSDP error: " + error);
1053 } 1075 }
1054 } 1076 }
1055 } 1077 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698