OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2015 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 |
(...skipping 24 matching lines...) Expand all Loading... |
35 import org.webrtc.PeerConnectionFactory; | 35 import org.webrtc.PeerConnectionFactory; |
36 import org.webrtc.RendererCommon.ScalingType; | 36 import org.webrtc.RendererCommon.ScalingType; |
37 import org.webrtc.SessionDescription; | 37 import org.webrtc.SessionDescription; |
38 import org.webrtc.StatsReport; | 38 import org.webrtc.StatsReport; |
39 import org.webrtc.SurfaceViewRenderer; | 39 import org.webrtc.SurfaceViewRenderer; |
40 | 40 |
41 /** | 41 /** |
42 * Activity for peer connection call setup, call waiting | 42 * Activity for peer connection call setup, call waiting |
43 * and call view. | 43 * and call view. |
44 */ | 44 */ |
45 public class CallActivity extends Activity | 45 public class CallActivity extends Activity implements AppRTCClient.SignalingEven
ts, |
46 implements AppRTCClient.SignalingEvents, | 46 PeerConnectionClient.PeerC
onnectionEvents, |
47 PeerConnectionClient.PeerConnectionEvents, | 47 CallFragment.OnCallEvents
{ |
48 CallFragment.OnCallEvents { | 48 public static final String EXTRA_ROOMID = "org.appspot.apprtc.ROOMID"; |
49 | 49 public static final String EXTRA_LOOPBACK = "org.appspot.apprtc.LOOPBACK"; |
50 public static final String EXTRA_ROOMID = | 50 public static final String EXTRA_VIDEO_CALL = "org.appspot.apprtc.VIDEO_CALL"; |
51 "org.appspot.apprtc.ROOMID"; | 51 public static final String EXTRA_CAMERA2 = "org.appspot.apprtc.CAMERA2"; |
52 public static final String EXTRA_LOOPBACK = | 52 public static final String EXTRA_VIDEO_WIDTH = "org.appspot.apprtc.VIDEO_WIDTH
"; |
53 "org.appspot.apprtc.LOOPBACK"; | 53 public static final String EXTRA_VIDEO_HEIGHT = "org.appspot.apprtc.VIDEO_HEIG
HT"; |
54 public static final String EXTRA_VIDEO_CALL = | 54 public static final String EXTRA_VIDEO_FPS = "org.appspot.apprtc.VIDEO_FPS"; |
55 "org.appspot.apprtc.VIDEO_CALL"; | |
56 public static final String EXTRA_CAMERA2 = | |
57 "org.appspot.apprtc.CAMERA2"; | |
58 public static final String EXTRA_VIDEO_WIDTH = | |
59 "org.appspot.apprtc.VIDEO_WIDTH"; | |
60 public static final String EXTRA_VIDEO_HEIGHT = | |
61 "org.appspot.apprtc.VIDEO_HEIGHT"; | |
62 public static final String EXTRA_VIDEO_FPS = | |
63 "org.appspot.apprtc.VIDEO_FPS"; | |
64 public static final String EXTRA_VIDEO_CAPTUREQUALITYSLIDER_ENABLED = | 55 public static final String EXTRA_VIDEO_CAPTUREQUALITYSLIDER_ENABLED = |
65 "org.appsopt.apprtc.VIDEO_CAPTUREQUALITYSLIDER"; | 56 "org.appsopt.apprtc.VIDEO_CAPTUREQUALITYSLIDER"; |
66 public static final String EXTRA_VIDEO_BITRATE = | 57 public static final String EXTRA_VIDEO_BITRATE = "org.appspot.apprtc.VIDEO_BIT
RATE"; |
67 "org.appspot.apprtc.VIDEO_BITRATE"; | 58 public static final String EXTRA_VIDEOCODEC = "org.appspot.apprtc.VIDEOCODEC"; |
68 public static final String EXTRA_VIDEOCODEC = | 59 public static final String EXTRA_HWCODEC_ENABLED = "org.appspot.apprtc.HWCODEC
"; |
69 "org.appspot.apprtc.VIDEOCODEC"; | 60 public static final String EXTRA_CAPTURETOTEXTURE_ENABLED = "org.appspot.apprt
c.CAPTURETOTEXTURE"; |
70 public static final String EXTRA_HWCODEC_ENABLED = | 61 public static final String EXTRA_AUDIO_BITRATE = "org.appspot.apprtc.AUDIO_BIT
RATE"; |
71 "org.appspot.apprtc.HWCODEC"; | 62 public static final String EXTRA_AUDIOCODEC = "org.appspot.apprtc.AUDIOCODEC"; |
72 public static final String EXTRA_CAPTURETOTEXTURE_ENABLED = | |
73 "org.appspot.apprtc.CAPTURETOTEXTURE"; | |
74 public static final String EXTRA_AUDIO_BITRATE = | |
75 "org.appspot.apprtc.AUDIO_BITRATE"; | |
76 public static final String EXTRA_AUDIOCODEC = | |
77 "org.appspot.apprtc.AUDIOCODEC"; | |
78 public static final String EXTRA_NOAUDIOPROCESSING_ENABLED = | 63 public static final String EXTRA_NOAUDIOPROCESSING_ENABLED = |
79 "org.appspot.apprtc.NOAUDIOPROCESSING"; | 64 "org.appspot.apprtc.NOAUDIOPROCESSING"; |
80 public static final String EXTRA_AECDUMP_ENABLED = | 65 public static final String EXTRA_AECDUMP_ENABLED = "org.appspot.apprtc.AECDUMP
"; |
81 "org.appspot.apprtc.AECDUMP"; | 66 public static final String EXTRA_OPENSLES_ENABLED = "org.appspot.apprtc.OPENSL
ES"; |
82 public static final String EXTRA_OPENSLES_ENABLED = | 67 public static final String EXTRA_DISABLE_BUILT_IN_AEC = "org.appspot.apprtc.DI
SABLE_BUILT_IN_AEC"; |
83 "org.appspot.apprtc.OPENSLES"; | 68 public static final String EXTRA_DISABLE_BUILT_IN_AGC = "org.appspot.apprtc.DI
SABLE_BUILT_IN_AGC"; |
84 public static final String EXTRA_DISABLE_BUILT_IN_AEC = | 69 public static final String EXTRA_DISABLE_BUILT_IN_NS = "org.appspot.apprtc.DIS
ABLE_BUILT_IN_NS"; |
85 "org.appspot.apprtc.DISABLE_BUILT_IN_AEC"; | 70 public static final String EXTRA_ENABLE_LEVEL_CONTROL = "org.appspot.apprtc.EN
ABLE_LEVEL_CONTROL"; |
86 public static final String EXTRA_DISABLE_BUILT_IN_AGC = | 71 public static final String EXTRA_DISPLAY_HUD = "org.appspot.apprtc.DISPLAY_HUD
"; |
87 "org.appspot.apprtc.DISABLE_BUILT_IN_AGC"; | |
88 public static final String EXTRA_DISABLE_BUILT_IN_NS = | |
89 "org.appspot.apprtc.DISABLE_BUILT_IN_NS"; | |
90 public static final String EXTRA_ENABLE_LEVEL_CONTROL = | |
91 "org.appspot.apprtc.ENABLE_LEVEL_CONTROL"; | |
92 public static final String EXTRA_DISPLAY_HUD = | |
93 "org.appspot.apprtc.DISPLAY_HUD"; | |
94 public static final String EXTRA_TRACING = "org.appspot.apprtc.TRACING"; | 72 public static final String EXTRA_TRACING = "org.appspot.apprtc.TRACING"; |
95 public static final String EXTRA_CMDLINE = | 73 public static final String EXTRA_CMDLINE = "org.appspot.apprtc.CMDLINE"; |
96 "org.appspot.apprtc.CMDLINE"; | 74 public static final String EXTRA_RUNTIME = "org.appspot.apprtc.RUNTIME"; |
97 public static final String EXTRA_RUNTIME = | |
98 "org.appspot.apprtc.RUNTIME"; | |
99 private static final String TAG = "CallRTCClient"; | 75 private static final String TAG = "CallRTCClient"; |
100 | 76 |
101 // List of mandatory application permissions. | 77 // List of mandatory application permissions. |
102 private static final String[] MANDATORY_PERMISSIONS = { | 78 private static final String[] MANDATORY_PERMISSIONS = {"android.permission.MOD
IFY_AUDIO_SETTINGS", |
103 "android.permission.MODIFY_AUDIO_SETTINGS", | 79 "android.permission.RECORD_AUDIO", "android.permission.INTERNET"}; |
104 "android.permission.RECORD_AUDIO", | |
105 "android.permission.INTERNET" | |
106 }; | |
107 | 80 |
108 // Peer connection statistics callback period in ms. | 81 // Peer connection statistics callback period in ms. |
109 private static final int STAT_CALLBACK_PERIOD = 1000; | 82 private static final int STAT_CALLBACK_PERIOD = 1000; |
110 // Local preview screen position before call is connected. | 83 // Local preview screen position before call is connected. |
111 private static final int LOCAL_X_CONNECTING = 0; | 84 private static final int LOCAL_X_CONNECTING = 0; |
112 private static final int LOCAL_Y_CONNECTING = 0; | 85 private static final int LOCAL_Y_CONNECTING = 0; |
113 private static final int LOCAL_WIDTH_CONNECTING = 100; | 86 private static final int LOCAL_WIDTH_CONNECTING = 100; |
114 private static final int LOCAL_HEIGHT_CONNECTING = 100; | 87 private static final int LOCAL_HEIGHT_CONNECTING = 100; |
115 // Local preview screen position after call is connected. | 88 // Local preview screen position after call is connected. |
116 private static final int LOCAL_X_CONNECTED = 72; | 89 private static final int LOCAL_X_CONNECTED = 72; |
(...skipping 28 matching lines...) Expand all Loading... |
145 private boolean micEnabled = true; | 118 private boolean micEnabled = true; |
146 | 119 |
147 // Controls | 120 // Controls |
148 private CallFragment callFragment; | 121 private CallFragment callFragment; |
149 private HudFragment hudFragment; | 122 private HudFragment hudFragment; |
150 private CpuMonitor cpuMonitor; | 123 private CpuMonitor cpuMonitor; |
151 | 124 |
152 @Override | 125 @Override |
153 public void onCreate(Bundle savedInstanceState) { | 126 public void onCreate(Bundle savedInstanceState) { |
154 super.onCreate(savedInstanceState); | 127 super.onCreate(savedInstanceState); |
155 Thread.setDefaultUncaughtExceptionHandler( | 128 Thread.setDefaultUncaughtExceptionHandler(new UnhandledExceptionHandler(this
)); |
156 new UnhandledExceptionHandler(this)); | |
157 | 129 |
158 // Set window styles for fullscreen-window size. Needs to be done before | 130 // Set window styles for fullscreen-window size. Needs to be done before |
159 // adding content. | 131 // adding content. |
160 requestWindowFeature(Window.FEATURE_NO_TITLE); | 132 requestWindowFeature(Window.FEATURE_NO_TITLE); |
161 getWindow().addFlags( | 133 getWindow().addFlags(LayoutParams.FLAG_FULLSCREEN | LayoutParams.FLAG_KEEP_S
CREEN_ON |
162 LayoutParams.FLAG_FULLSCREEN | 134 | LayoutParams.FLAG_DISMISS_KEYGUARD | LayoutParams.FLAG_SHOW_WHEN_LOCKE
D |
163 | LayoutParams.FLAG_KEEP_SCREEN_ON | |
164 | LayoutParams.FLAG_DISMISS_KEYGUARD | |
165 | LayoutParams.FLAG_SHOW_WHEN_LOCKED | |
166 | LayoutParams.FLAG_TURN_SCREEN_ON); | 135 | LayoutParams.FLAG_TURN_SCREEN_ON); |
167 getWindow().getDecorView().setSystemUiVisibility( | 136 getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NA
VIGATION |
168 View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | 137 | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY)
; |
169 | View.SYSTEM_UI_FLAG_FULLSCREEN | |
170 | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); | |
171 setContentView(R.layout.activity_call); | 138 setContentView(R.layout.activity_call); |
172 | 139 |
173 iceConnected = false; | 140 iceConnected = false; |
174 signalingParameters = null; | 141 signalingParameters = null; |
175 scalingType = ScalingType.SCALE_ASPECT_FILL; | 142 scalingType = ScalingType.SCALE_ASPECT_FILL; |
176 | 143 |
177 // Create UI controls. | 144 // Create UI controls. |
178 localRender = (SurfaceViewRenderer) findViewById(R.id.local_video_view); | 145 localRender = (SurfaceViewRenderer) findViewById(R.id.local_video_view); |
179 remoteRender = (SurfaceViewRenderer) findViewById(R.id.remote_video_view); | 146 remoteRender = (SurfaceViewRenderer) findViewById(R.id.remote_video_view); |
180 localRenderLayout = (PercentFrameLayout) findViewById(R.id.local_video_layou
t); | 147 localRenderLayout = (PercentFrameLayout) findViewById(R.id.local_video_layou
t); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 logAndToast(getString(R.string.missing_url)); | 192 logAndToast(getString(R.string.missing_url)); |
226 Log.e(TAG, "Incorrect room ID in intent!"); | 193 Log.e(TAG, "Incorrect room ID in intent!"); |
227 setResult(RESULT_CANCELED); | 194 setResult(RESULT_CANCELED); |
228 finish(); | 195 finish(); |
229 return; | 196 return; |
230 } | 197 } |
231 | 198 |
232 boolean loopback = intent.getBooleanExtra(EXTRA_LOOPBACK, false); | 199 boolean loopback = intent.getBooleanExtra(EXTRA_LOOPBACK, false); |
233 boolean tracing = intent.getBooleanExtra(EXTRA_TRACING, false); | 200 boolean tracing = intent.getBooleanExtra(EXTRA_TRACING, false); |
234 | 201 |
235 boolean useCamera2 = Camera2Enumerator.isSupported(this) | 202 boolean useCamera2 = |
236 && intent.getBooleanExtra(EXTRA_CAMERA2, true); | 203 Camera2Enumerator.isSupported(this) && intent.getBooleanExtra(EXTRA_CAME
RA2, true); |
237 | 204 |
238 peerConnectionParameters = new PeerConnectionParameters( | 205 peerConnectionParameters = |
239 intent.getBooleanExtra(EXTRA_VIDEO_CALL, true), | 206 new PeerConnectionParameters(intent.getBooleanExtra(EXTRA_VIDEO_CALL, tr
ue), loopback, |
240 loopback, | 207 tracing, useCamera2, intent.getIntExtra(EXTRA_VIDEO_WIDTH, 0), |
241 tracing, | 208 intent.getIntExtra(EXTRA_VIDEO_HEIGHT, 0), intent.getIntExtra(EXTRA_
VIDEO_FPS, 0), |
242 useCamera2, | 209 intent.getIntExtra(EXTRA_VIDEO_BITRATE, 0), intent.getStringExtra(EX
TRA_VIDEOCODEC), |
243 intent.getIntExtra(EXTRA_VIDEO_WIDTH, 0), | 210 intent.getBooleanExtra(EXTRA_HWCODEC_ENABLED, true), |
244 intent.getIntExtra(EXTRA_VIDEO_HEIGHT, 0), | 211 intent.getBooleanExtra(EXTRA_CAPTURETOTEXTURE_ENABLED, false), |
245 intent.getIntExtra(EXTRA_VIDEO_FPS, 0), | 212 intent.getIntExtra(EXTRA_AUDIO_BITRATE, 0), intent.getStringExtra(EX
TRA_AUDIOCODEC), |
246 intent.getIntExtra(EXTRA_VIDEO_BITRATE, 0), | 213 intent.getBooleanExtra(EXTRA_NOAUDIOPROCESSING_ENABLED, false), |
247 intent.getStringExtra(EXTRA_VIDEOCODEC), | 214 intent.getBooleanExtra(EXTRA_AECDUMP_ENABLED, false), |
248 intent.getBooleanExtra(EXTRA_HWCODEC_ENABLED, true), | 215 intent.getBooleanExtra(EXTRA_OPENSLES_ENABLED, false), |
249 intent.getBooleanExtra(EXTRA_CAPTURETOTEXTURE_ENABLED, false), | 216 intent.getBooleanExtra(EXTRA_DISABLE_BUILT_IN_AEC, false), |
250 intent.getIntExtra(EXTRA_AUDIO_BITRATE, 0), | 217 intent.getBooleanExtra(EXTRA_DISABLE_BUILT_IN_AGC, false), |
251 intent.getStringExtra(EXTRA_AUDIOCODEC), | 218 intent.getBooleanExtra(EXTRA_DISABLE_BUILT_IN_NS, false), |
252 intent.getBooleanExtra(EXTRA_NOAUDIOPROCESSING_ENABLED, false), | 219 intent.getBooleanExtra(EXTRA_ENABLE_LEVEL_CONTROL, false)); |
253 intent.getBooleanExtra(EXTRA_AECDUMP_ENABLED, false), | |
254 intent.getBooleanExtra(EXTRA_OPENSLES_ENABLED, false), | |
255 intent.getBooleanExtra(EXTRA_DISABLE_BUILT_IN_AEC, false), | |
256 intent.getBooleanExtra(EXTRA_DISABLE_BUILT_IN_AGC, false), | |
257 intent.getBooleanExtra(EXTRA_DISABLE_BUILT_IN_NS, false), | |
258 intent.getBooleanExtra(EXTRA_ENABLE_LEVEL_CONTROL, false)); | |
259 commandLineRun = intent.getBooleanExtra(EXTRA_CMDLINE, false); | 220 commandLineRun = intent.getBooleanExtra(EXTRA_CMDLINE, false); |
260 runTimeMs = intent.getIntExtra(EXTRA_RUNTIME, 0); | 221 runTimeMs = intent.getIntExtra(EXTRA_RUNTIME, 0); |
261 | 222 |
262 // Create connection client. Use DirectRTCClient if room name is an IP other
wise use the | 223 // Create connection client. Use DirectRTCClient if room name is an IP other
wise use the |
263 // standard WebSocketRTCClient. | 224 // standard WebSocketRTCClient. |
264 if (loopback || !DirectRTCClient.IP_PATTERN.matcher(roomId).matches()) { | 225 if (loopback || !DirectRTCClient.IP_PATTERN.matcher(roomId).matches()) { |
265 appRtcClient = new WebSocketRTCClient(this); | 226 appRtcClient = new WebSocketRTCClient(this); |
266 } else { | 227 } else { |
267 Log.i(TAG, "Using DirectRTCClient because room name looks like an IP."); | 228 Log.i(TAG, "Using DirectRTCClient because room name looks like an IP."); |
268 appRtcClient = new DirectRTCClient(this); | 229 appRtcClient = new DirectRTCClient(this); |
269 } | 230 } |
270 // Create connection parameters. | 231 // Create connection parameters. |
271 roomConnectionParameters = new RoomConnectionParameters( | 232 roomConnectionParameters = new RoomConnectionParameters(roomUri.toString(),
roomId, loopback); |
272 roomUri.toString(), roomId, loopback); | |
273 | 233 |
274 // Create CPU monitor | 234 // Create CPU monitor |
275 cpuMonitor = new CpuMonitor(this); | 235 cpuMonitor = new CpuMonitor(this); |
276 hudFragment.setCpuMonitor(cpuMonitor); | 236 hudFragment.setCpuMonitor(cpuMonitor); |
277 | 237 |
278 // Send intent arguments to fragments. | 238 // Send intent arguments to fragments. |
279 callFragment.setArguments(intent.getExtras()); | 239 callFragment.setArguments(intent.getExtras()); |
280 hudFragment.setArguments(intent.getExtras()); | 240 hudFragment.setArguments(intent.getExtras()); |
281 // Activate call and HUD fragments and start the call. | 241 // Activate call and HUD fragments and start the call. |
282 FragmentTransaction ft = getFragmentManager().beginTransaction(); | 242 FragmentTransaction ft = getFragmentManager().beginTransaction(); |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 } | 372 } |
413 | 373 |
414 private void startCall() { | 374 private void startCall() { |
415 if (appRtcClient == null) { | 375 if (appRtcClient == null) { |
416 Log.e(TAG, "AppRTC client is not allocated for a call."); | 376 Log.e(TAG, "AppRTC client is not allocated for a call."); |
417 return; | 377 return; |
418 } | 378 } |
419 callStartedTimeMs = System.currentTimeMillis(); | 379 callStartedTimeMs = System.currentTimeMillis(); |
420 | 380 |
421 // Start room connection. | 381 // Start room connection. |
422 logAndToast(getString(R.string.connecting_to, | 382 logAndToast(getString(R.string.connecting_to, roomConnectionParameters.roomU
rl)); |
423 roomConnectionParameters.roomUrl)); | |
424 appRtcClient.connectToRoom(roomConnectionParameters); | 383 appRtcClient.connectToRoom(roomConnectionParameters); |
425 | 384 |
426 // Create and audio manager that will take care of audio routing, | 385 // Create and audio manager that will take care of audio routing, |
427 // audio modes, audio device enumeration etc. | 386 // audio modes, audio device enumeration etc. |
428 audioManager = AppRTCAudioManager.create(this, new Runnable() { | 387 audioManager = AppRTCAudioManager.create(this, new Runnable() { |
429 // This method will be called each time the audio state (number and | 388 // This method will be called each time the audio state (number and |
430 // type of devices) has been changed. | 389 // type of devices) has been changed. |
431 @Override | 390 @Override |
432 public void run() { | 391 public void run() { |
433 onAudioManagerChangedState(); | 392 onAudioManagerChangedState(); |
434 } | |
435 } | 393 } |
436 ); | 394 }); |
437 // Store existing audio settings and change audio mode to | 395 // Store existing audio settings and change audio mode to |
438 // MODE_IN_COMMUNICATION for best possible VoIP performance. | 396 // MODE_IN_COMMUNICATION for best possible VoIP performance. |
439 Log.d(TAG, "Initializing the audio manager..."); | 397 Log.d(TAG, "Initializing the audio manager..."); |
440 audioManager.init(); | 398 audioManager.init(); |
441 } | 399 } |
442 | 400 |
443 // Should be called from UI thread | 401 // Should be called from UI thread |
444 private void callConnected() { | 402 private void callConnected() { |
445 final long delta = System.currentTimeMillis() - callStartedTimeMs; | 403 final long delta = System.currentTimeMillis() - callStartedTimeMs; |
446 Log.i(TAG, "Call connected: delay=" + delta + "ms"); | 404 Log.i(TAG, "Call connected: delay=" + delta + "ms"); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 | 450 |
493 private void disconnectWithErrorMessage(final String errorMessage) { | 451 private void disconnectWithErrorMessage(final String errorMessage) { |
494 if (commandLineRun || !activityRunning) { | 452 if (commandLineRun || !activityRunning) { |
495 Log.e(TAG, "Critical error: " + errorMessage); | 453 Log.e(TAG, "Critical error: " + errorMessage); |
496 disconnect(); | 454 disconnect(); |
497 } else { | 455 } else { |
498 new AlertDialog.Builder(this) | 456 new AlertDialog.Builder(this) |
499 .setTitle(getText(R.string.channel_error_title)) | 457 .setTitle(getText(R.string.channel_error_title)) |
500 .setMessage(errorMessage) | 458 .setMessage(errorMessage) |
501 .setCancelable(false) | 459 .setCancelable(false) |
502 .setNeutralButton(R.string.ok, new DialogInterface.OnClickListener() { | 460 .setNeutralButton(R.string.ok, |
503 @Override | 461 new DialogInterface.OnClickListener() { |
504 public void onClick(DialogInterface dialog, int id) { | 462 @Override |
505 dialog.cancel(); | 463 public void onClick(DialogInterface dialog, int id) { |
506 disconnect(); | 464 dialog.cancel(); |
507 } | 465 disconnect(); |
508 }).create().show(); | 466 } |
| 467 }) |
| 468 .create() |
| 469 .show(); |
509 } | 470 } |
510 } | 471 } |
511 | 472 |
512 // Log |msg| and Toast about it. | 473 // Log |msg| and Toast about it. |
513 private void logAndToast(String msg) { | 474 private void logAndToast(String msg) { |
514 Log.d(TAG, msg); | 475 Log.d(TAG, msg); |
515 if (logToast != null) { | 476 if (logToast != null) { |
516 logToast.cancel(); | 477 logToast.cancel(); |
517 } | 478 } |
518 logToast = Toast.makeText(this, msg, Toast.LENGTH_SHORT); | 479 logToast = Toast.makeText(this, msg, Toast.LENGTH_SHORT); |
(...skipping 13 matching lines...) Expand all Loading... |
532 } | 493 } |
533 | 494 |
534 // -----Implementation of AppRTCClient.AppRTCSignalingEvents --------------- | 495 // -----Implementation of AppRTCClient.AppRTCSignalingEvents --------------- |
535 // All callbacks are invoked from websocket signaling looper thread and | 496 // All callbacks are invoked from websocket signaling looper thread and |
536 // are routed to UI thread. | 497 // are routed to UI thread. |
537 private void onConnectedToRoomInternal(final SignalingParameters params) { | 498 private void onConnectedToRoomInternal(final SignalingParameters params) { |
538 final long delta = System.currentTimeMillis() - callStartedTimeMs; | 499 final long delta = System.currentTimeMillis() - callStartedTimeMs; |
539 | 500 |
540 signalingParameters = params; | 501 signalingParameters = params; |
541 logAndToast("Creating peer connection, delay=" + delta + "ms"); | 502 logAndToast("Creating peer connection, delay=" + delta + "ms"); |
542 peerConnectionClient.createPeerConnection(rootEglBase.getEglBaseContext(), | 503 peerConnectionClient.createPeerConnection( |
543 localRender, remoteRender, signalingParameters); | 504 rootEglBase.getEglBaseContext(), localRender, remoteRender, signalingPar
ameters); |
544 | 505 |
545 if (signalingParameters.initiator) { | 506 if (signalingParameters.initiator) { |
546 logAndToast("Creating OFFER..."); | 507 logAndToast("Creating OFFER..."); |
547 // Create offer. Offer SDP will be sent to answering client in | 508 // Create offer. Offer SDP will be sent to answering client in |
548 // PeerConnectionEvents.onLocalDescription event. | 509 // PeerConnectionEvents.onLocalDescription event. |
549 peerConnectionClient.createOffer(); | 510 peerConnectionClient.createOffer(); |
550 } else { | 511 } else { |
551 if (params.offerSdp != null) { | 512 if (params.offerSdp != null) { |
552 peerConnectionClient.setRemoteDescription(params.offerSdp); | 513 peerConnectionClient.setRemoteDescription(params.offerSdp); |
553 logAndToast("Creating ANSWER..."); | 514 logAndToast("Creating ANSWER..."); |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
709 @Override | 670 @Override |
710 public void run() { | 671 public void run() { |
711 logAndToast("ICE disconnected"); | 672 logAndToast("ICE disconnected"); |
712 iceConnected = false; | 673 iceConnected = false; |
713 disconnect(); | 674 disconnect(); |
714 } | 675 } |
715 }); | 676 }); |
716 } | 677 } |
717 | 678 |
718 @Override | 679 @Override |
719 public void onPeerConnectionClosed() { | 680 public void onPeerConnectionClosed() {} |
720 } | |
721 | 681 |
722 @Override | 682 @Override |
723 public void onPeerConnectionStatsReady(final StatsReport[] reports) { | 683 public void onPeerConnectionStatsReady(final StatsReport[] reports) { |
724 runOnUiThread(new Runnable() { | 684 runOnUiThread(new Runnable() { |
725 @Override | 685 @Override |
726 public void run() { | 686 public void run() { |
727 if (!isError && iceConnected) { | 687 if (!isError && iceConnected) { |
728 hudFragment.updateEncoderStatistics(reports); | 688 hudFragment.updateEncoderStatistics(reports); |
729 } | 689 } |
730 } | 690 } |
731 }); | 691 }); |
732 } | 692 } |
733 | 693 |
734 @Override | 694 @Override |
735 public void onPeerConnectionError(final String description) { | 695 public void onPeerConnectionError(final String description) { |
736 reportError(description); | 696 reportError(description); |
737 } | 697 } |
738 } | 698 } |
OLD | NEW |