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 116 matching lines...) Loading... |
127 public static final String EXTRA_ID = "org.appspot.apprtc.ID"; | 127 public static final String EXTRA_ID = "org.appspot.apprtc.ID"; |
128 | 128 |
129 private static final int CAPTURE_PERMISSION_REQUEST_CODE = 1; | 129 private static final int CAPTURE_PERMISSION_REQUEST_CODE = 1; |
130 | 130 |
131 // List of mandatory application permissions. | 131 // List of mandatory application permissions. |
132 private static final String[] MANDATORY_PERMISSIONS = {"android.permission.MOD
IFY_AUDIO_SETTINGS", | 132 private static final String[] MANDATORY_PERMISSIONS = {"android.permission.MOD
IFY_AUDIO_SETTINGS", |
133 "android.permission.RECORD_AUDIO", "android.permission.INTERNET"}; | 133 "android.permission.RECORD_AUDIO", "android.permission.INTERNET"}; |
134 | 134 |
135 // Peer connection statistics callback period in ms. | 135 // Peer connection statistics callback period in ms. |
136 private static final int STAT_CALLBACK_PERIOD = 1000; | 136 private static final int STAT_CALLBACK_PERIOD = 1000; |
137 // Local preview screen position before call is connected. | 137 |
138 private static final int LOCAL_X_CONNECTING = 0; | 138 private class ProxyRenderer implements VideoRenderer.Callbacks { |
139 private static final int LOCAL_Y_CONNECTING = 0; | 139 private VideoRenderer.Callbacks target; |
140 private static final int LOCAL_WIDTH_CONNECTING = 100; | 140 |
141 private static final int LOCAL_HEIGHT_CONNECTING = 100; | 141 synchronized public void renderFrame(VideoRenderer.I420Frame frame) { |
142 // Local preview screen position after call is connected. | 142 if (target == null) { |
143 private static final int LOCAL_X_CONNECTED = 72; | 143 Logging.d(TAG, "Dropping frame in proxy because target is null."); |
144 private static final int LOCAL_Y_CONNECTED = 72; | 144 VideoRenderer.renderFrameDone(frame); |
145 private static final int LOCAL_WIDTH_CONNECTED = 25; | 145 return; |
146 private static final int LOCAL_HEIGHT_CONNECTED = 25; | 146 } |
147 // Remote video screen position | 147 |
148 private static final int REMOTE_X = 0; | 148 target.renderFrame(frame); |
149 private static final int REMOTE_Y = 0; | 149 } |
150 private static final int REMOTE_WIDTH = 100; | 150 |
151 private static final int REMOTE_HEIGHT = 100; | 151 synchronized public void setTarget(VideoRenderer.Callbacks target) { |
| 152 this.target = target; |
| 153 } |
| 154 } |
| 155 |
| 156 private final ProxyRenderer remoteProxyRenderer = new ProxyRenderer(); |
| 157 private final ProxyRenderer localProxyRenderer = new ProxyRenderer(); |
152 private PeerConnectionClient peerConnectionClient = null; | 158 private PeerConnectionClient peerConnectionClient = null; |
153 private AppRTCClient appRtcClient; | 159 private AppRTCClient appRtcClient; |
154 private SignalingParameters signalingParameters; | 160 private SignalingParameters signalingParameters; |
155 private AppRTCAudioManager audioManager = null; | 161 private AppRTCAudioManager audioManager = null; |
156 private EglBase rootEglBase; | 162 private EglBase rootEglBase; |
157 private SurfaceViewRenderer localRender; | 163 private SurfaceViewRenderer pipRenderer; |
158 private SurfaceViewRenderer remoteRenderScreen; | 164 private SurfaceViewRenderer fullscreenRenderer; |
159 private VideoFileRenderer videoFileRenderer; | 165 private VideoFileRenderer videoFileRenderer; |
160 private final List<VideoRenderer.Callbacks> remoteRenderers = | 166 private final List<VideoRenderer.Callbacks> remoteRenderers = |
161 new ArrayList<VideoRenderer.Callbacks>(); | 167 new ArrayList<VideoRenderer.Callbacks>(); |
162 private PercentFrameLayout localRenderLayout; | |
163 private PercentFrameLayout remoteRenderLayout; | |
164 private ScalingType scalingType; | |
165 private Toast logToast; | 168 private Toast logToast; |
166 private boolean commandLineRun; | 169 private boolean commandLineRun; |
167 private int runTimeMs; | 170 private int runTimeMs; |
168 private boolean activityRunning; | 171 private boolean activityRunning; |
169 private RoomConnectionParameters roomConnectionParameters; | 172 private RoomConnectionParameters roomConnectionParameters; |
170 private PeerConnectionParameters peerConnectionParameters; | 173 private PeerConnectionParameters peerConnectionParameters; |
171 private boolean iceConnected; | 174 private boolean iceConnected; |
172 private boolean isError; | 175 private boolean isError; |
173 private boolean callControlFragmentVisible = true; | 176 private boolean callControlFragmentVisible = true; |
174 private long callStartedTimeMs = 0; | 177 private long callStartedTimeMs = 0; |
175 private boolean micEnabled = true; | 178 private boolean micEnabled = true; |
176 private boolean screencaptureEnabled = false; | 179 private boolean screencaptureEnabled = false; |
177 private static Intent mediaProjectionPermissionResultData; | 180 private static Intent mediaProjectionPermissionResultData; |
178 private static int mediaProjectionPermissionResultCode; | 181 private static int mediaProjectionPermissionResultCode; |
| 182 // True if local view is in the fullscreen renderer. |
| 183 private boolean isSwappedFeeds; |
179 | 184 |
180 // Controls | 185 // Controls |
181 private CallFragment callFragment; | 186 private CallFragment callFragment; |
182 private HudFragment hudFragment; | 187 private HudFragment hudFragment; |
183 private CpuMonitor cpuMonitor; | 188 private CpuMonitor cpuMonitor; |
184 | 189 |
185 @Override | 190 @Override |
186 public void onCreate(Bundle savedInstanceState) { | 191 public void onCreate(Bundle savedInstanceState) { |
187 super.onCreate(savedInstanceState); | 192 super.onCreate(savedInstanceState); |
188 Thread.setDefaultUncaughtExceptionHandler(new UnhandledExceptionHandler(this
)); | 193 Thread.setDefaultUncaughtExceptionHandler(new UnhandledExceptionHandler(this
)); |
189 | 194 |
190 // Set window styles for fullscreen-window size. Needs to be done before | 195 // Set window styles for fullscreen-window size. Needs to be done before |
191 // adding content. | 196 // adding content. |
192 requestWindowFeature(Window.FEATURE_NO_TITLE); | 197 requestWindowFeature(Window.FEATURE_NO_TITLE); |
193 getWindow().addFlags(LayoutParams.FLAG_FULLSCREEN | LayoutParams.FLAG_KEEP_S
CREEN_ON | 198 getWindow().addFlags(LayoutParams.FLAG_FULLSCREEN | LayoutParams.FLAG_KEEP_S
CREEN_ON |
194 | LayoutParams.FLAG_DISMISS_KEYGUARD | LayoutParams.FLAG_SHOW_WHEN_LOCKE
D | 199 | LayoutParams.FLAG_DISMISS_KEYGUARD | LayoutParams.FLAG_SHOW_WHEN_LOCKE
D |
195 | LayoutParams.FLAG_TURN_SCREEN_ON); | 200 | LayoutParams.FLAG_TURN_SCREEN_ON); |
196 getWindow().getDecorView().setSystemUiVisibility(getSystemUiVisibility()); | 201 getWindow().getDecorView().setSystemUiVisibility(getSystemUiVisibility()); |
197 setContentView(R.layout.activity_call); | 202 setContentView(R.layout.activity_call); |
198 | 203 |
199 iceConnected = false; | 204 iceConnected = false; |
200 signalingParameters = null; | 205 signalingParameters = null; |
201 scalingType = ScalingType.SCALE_ASPECT_FILL; | |
202 | 206 |
203 // Create UI controls. | 207 // Create UI controls. |
204 localRender = (SurfaceViewRenderer) findViewById(R.id.local_video_view); | 208 pipRenderer = (SurfaceViewRenderer) findViewById(R.id.pip_video_view); |
205 remoteRenderScreen = (SurfaceViewRenderer) findViewById(R.id.remote_video_vi
ew); | 209 fullscreenRenderer = (SurfaceViewRenderer) findViewById(R.id.fullscreen_vide
o_view); |
206 localRenderLayout = (PercentFrameLayout) findViewById(R.id.local_video_layou
t); | |
207 remoteRenderLayout = (PercentFrameLayout) findViewById(R.id.remote_video_lay
out); | |
208 callFragment = new CallFragment(); | 210 callFragment = new CallFragment(); |
209 hudFragment = new HudFragment(); | 211 hudFragment = new HudFragment(); |
210 | 212 |
211 // Show/hide call control fragment on view click. | 213 // Show/hide call control fragment on view click. |
212 View.OnClickListener listener = new View.OnClickListener() { | 214 View.OnClickListener listener = new View.OnClickListener() { |
213 @Override | 215 @Override |
214 public void onClick(View view) { | 216 public void onClick(View view) { |
215 toggleCallControlFragmentVisibility(); | 217 toggleCallControlFragmentVisibility(); |
216 } | 218 } |
217 }; | 219 }; |
218 | 220 |
219 localRender.setOnClickListener(listener); | 221 // Swap feeds on pip view click. |
220 remoteRenderScreen.setOnClickListener(listener); | 222 pipRenderer.setOnClickListener(new View.OnClickListener() { |
221 remoteRenderers.add(remoteRenderScreen); | 223 @Override |
| 224 public void onClick(View view) { |
| 225 setSwappedFeeds(!isSwappedFeeds); |
| 226 } |
| 227 }); |
| 228 |
| 229 fullscreenRenderer.setOnClickListener(listener); |
| 230 remoteRenderers.add(remoteProxyRenderer); |
222 | 231 |
223 final Intent intent = getIntent(); | 232 final Intent intent = getIntent(); |
224 | 233 |
225 // Create video renderers. | 234 // Create video renderers. |
226 rootEglBase = EglBase.create(); | 235 rootEglBase = EglBase.create(); |
227 localRender.init(rootEglBase.getEglBaseContext(), null); | 236 pipRenderer.init(rootEglBase.getEglBaseContext(), null); |
| 237 pipRenderer.setScalingType(ScalingType.SCALE_ASPECT_FIT); |
228 String saveRemoteVideoToFile = intent.getStringExtra(EXTRA_SAVE_REMOTE_VIDEO
_TO_FILE); | 238 String saveRemoteVideoToFile = intent.getStringExtra(EXTRA_SAVE_REMOTE_VIDEO
_TO_FILE); |
229 | 239 |
230 // When saveRemoteVideoToFile is set we save the video from the remote to a
file. | 240 // When saveRemoteVideoToFile is set we save the video from the remote to a
file. |
231 if (saveRemoteVideoToFile != null) { | 241 if (saveRemoteVideoToFile != null) { |
232 int videoOutWidth = intent.getIntExtra(EXTRA_SAVE_REMOTE_VIDEO_TO_FILE_WID
TH, 0); | 242 int videoOutWidth = intent.getIntExtra(EXTRA_SAVE_REMOTE_VIDEO_TO_FILE_WID
TH, 0); |
233 int videoOutHeight = intent.getIntExtra(EXTRA_SAVE_REMOTE_VIDEO_TO_FILE_HE
IGHT, 0); | 243 int videoOutHeight = intent.getIntExtra(EXTRA_SAVE_REMOTE_VIDEO_TO_FILE_HE
IGHT, 0); |
234 try { | 244 try { |
235 videoFileRenderer = new VideoFileRenderer( | 245 videoFileRenderer = new VideoFileRenderer( |
236 saveRemoteVideoToFile, videoOutWidth, videoOutHeight, rootEglBase.ge
tEglBaseContext()); | 246 saveRemoteVideoToFile, videoOutWidth, videoOutHeight, rootEglBase.ge
tEglBaseContext()); |
237 remoteRenderers.add(videoFileRenderer); | 247 remoteRenderers.add(videoFileRenderer); |
238 } catch (IOException e) { | 248 } catch (IOException e) { |
239 throw new RuntimeException( | 249 throw new RuntimeException( |
240 "Failed to open video file for output: " + saveRemoteVideoToFile, e)
; | 250 "Failed to open video file for output: " + saveRemoteVideoToFile, e)
; |
241 } | 251 } |
242 } | 252 } |
243 remoteRenderScreen.init(rootEglBase.getEglBaseContext(), null); | 253 fullscreenRenderer.init(rootEglBase.getEglBaseContext(), null); |
| 254 fullscreenRenderer.setScalingType(ScalingType.SCALE_ASPECT_FILL); |
244 | 255 |
245 localRender.setZOrderMediaOverlay(true); | 256 pipRenderer.setZOrderMediaOverlay(true); |
246 localRender.setEnableHardwareScaler(true /* enabled */); | 257 pipRenderer.setEnableHardwareScaler(true /* enabled */); |
247 remoteRenderScreen.setEnableHardwareScaler(true /* enabled */); | 258 fullscreenRenderer.setEnableHardwareScaler(true /* enabled */); |
248 updateVideoView(); | 259 // Start with local feed in fullscreen and swap it to the pip when the call
is connected. |
| 260 setSwappedFeeds(true /* isSwappedFeeds */); |
249 | 261 |
250 // Check for mandatory permissions. | 262 // Check for mandatory permissions. |
251 for (String permission : MANDATORY_PERMISSIONS) { | 263 for (String permission : MANDATORY_PERMISSIONS) { |
252 if (checkCallingOrSelfPermission(permission) != PackageManager.PERMISSION_
GRANTED) { | 264 if (checkCallingOrSelfPermission(permission) != PackageManager.PERMISSION_
GRANTED) { |
253 logAndToast("Permission " + permission + " is not granted"); | 265 logAndToast("Permission " + permission + " is not granted"); |
254 setResult(RESULT_CANCELED); | 266 setResult(RESULT_CANCELED); |
255 finish(); | 267 finish(); |
256 return; | 268 return; |
257 } | 269 } |
258 } | 270 } |
(...skipping 242 matching lines...) Loading... |
501 | 513 |
502 @Override | 514 @Override |
503 public void onCameraSwitch() { | 515 public void onCameraSwitch() { |
504 if (peerConnectionClient != null) { | 516 if (peerConnectionClient != null) { |
505 peerConnectionClient.switchCamera(); | 517 peerConnectionClient.switchCamera(); |
506 } | 518 } |
507 } | 519 } |
508 | 520 |
509 @Override | 521 @Override |
510 public void onVideoScalingSwitch(ScalingType scalingType) { | 522 public void onVideoScalingSwitch(ScalingType scalingType) { |
511 this.scalingType = scalingType; | 523 fullscreenRenderer.setScalingType(scalingType); |
512 updateVideoView(); | |
513 } | 524 } |
514 | 525 |
515 @Override | 526 @Override |
516 public void onCaptureFormatChange(int width, int height, int framerate) { | 527 public void onCaptureFormatChange(int width, int height, int framerate) { |
517 if (peerConnectionClient != null) { | 528 if (peerConnectionClient != null) { |
518 peerConnectionClient.changeCaptureFormat(width, height, framerate); | 529 peerConnectionClient.changeCaptureFormat(width, height, framerate); |
519 } | 530 } |
520 } | 531 } |
521 | 532 |
522 @Override | 533 @Override |
(...skipping 17 matching lines...) Loading... |
540 ft.show(callFragment); | 551 ft.show(callFragment); |
541 ft.show(hudFragment); | 552 ft.show(hudFragment); |
542 } else { | 553 } else { |
543 ft.hide(callFragment); | 554 ft.hide(callFragment); |
544 ft.hide(hudFragment); | 555 ft.hide(hudFragment); |
545 } | 556 } |
546 ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); | 557 ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); |
547 ft.commit(); | 558 ft.commit(); |
548 } | 559 } |
549 | 560 |
550 private void updateVideoView() { | |
551 remoteRenderLayout.setPosition(REMOTE_X, REMOTE_Y, REMOTE_WIDTH, REMOTE_HEIG
HT); | |
552 remoteRenderScreen.setScalingType(scalingType); | |
553 remoteRenderScreen.setMirror(false); | |
554 | |
555 if (iceConnected) { | |
556 localRenderLayout.setPosition( | |
557 LOCAL_X_CONNECTED, LOCAL_Y_CONNECTED, LOCAL_WIDTH_CONNECTED, LOCAL_HEI
GHT_CONNECTED); | |
558 localRender.setScalingType(ScalingType.SCALE_ASPECT_FIT); | |
559 } else { | |
560 localRenderLayout.setPosition( | |
561 LOCAL_X_CONNECTING, LOCAL_Y_CONNECTING, LOCAL_WIDTH_CONNECTING, LOCAL_
HEIGHT_CONNECTING); | |
562 localRender.setScalingType(scalingType); | |
563 } | |
564 localRender.setMirror(true); | |
565 | |
566 localRender.requestLayout(); | |
567 remoteRenderScreen.requestLayout(); | |
568 } | |
569 | |
570 private void startCall() { | 561 private void startCall() { |
571 if (appRtcClient == null) { | 562 if (appRtcClient == null) { |
572 Log.e(TAG, "AppRTC client is not allocated for a call."); | 563 Log.e(TAG, "AppRTC client is not allocated for a call."); |
573 return; | 564 return; |
574 } | 565 } |
575 callStartedTimeMs = System.currentTimeMillis(); | 566 callStartedTimeMs = System.currentTimeMillis(); |
576 | 567 |
577 // Start room connection. | 568 // Start room connection. |
578 logAndToast(getString(R.string.connecting_to, roomConnectionParameters.roomU
rl)); | 569 logAndToast(getString(R.string.connecting_to, roomConnectionParameters.roomU
rl)); |
579 appRtcClient.connectToRoom(roomConnectionParameters); | 570 appRtcClient.connectToRoom(roomConnectionParameters); |
(...skipping 16 matching lines...) Loading... |
596 } | 587 } |
597 | 588 |
598 // Should be called from UI thread | 589 // Should be called from UI thread |
599 private void callConnected() { | 590 private void callConnected() { |
600 final long delta = System.currentTimeMillis() - callStartedTimeMs; | 591 final long delta = System.currentTimeMillis() - callStartedTimeMs; |
601 Log.i(TAG, "Call connected: delay=" + delta + "ms"); | 592 Log.i(TAG, "Call connected: delay=" + delta + "ms"); |
602 if (peerConnectionClient == null || isError) { | 593 if (peerConnectionClient == null || isError) { |
603 Log.w(TAG, "Call is connected in closed or error state"); | 594 Log.w(TAG, "Call is connected in closed or error state"); |
604 return; | 595 return; |
605 } | 596 } |
606 // Update video view. | |
607 updateVideoView(); | |
608 // Enable statistics callback. | 597 // Enable statistics callback. |
609 peerConnectionClient.enableStatsEvents(true, STAT_CALLBACK_PERIOD); | 598 peerConnectionClient.enableStatsEvents(true, STAT_CALLBACK_PERIOD); |
| 599 setSwappedFeeds(false /* isSwappedFeeds */); |
610 } | 600 } |
611 | 601 |
612 // This method is called when the audio manager reports audio device change, | 602 // This method is called when the audio manager reports audio device change, |
613 // e.g. from wired headset to speakerphone. | 603 // e.g. from wired headset to speakerphone. |
614 private void onAudioManagerDevicesChanged( | 604 private void onAudioManagerDevicesChanged( |
615 final AudioDevice device, final Set<AudioDevice> availableDevices) { | 605 final AudioDevice device, final Set<AudioDevice> availableDevices) { |
616 Log.d(TAG, "onAudioManagerDevicesChanged: " + availableDevices + ", " | 606 Log.d(TAG, "onAudioManagerDevicesChanged: " + availableDevices + ", " |
617 + "selected: " + device); | 607 + "selected: " + device); |
618 // TODO(henrika): add callback handler. | 608 // TODO(henrika): add callback handler. |
619 } | 609 } |
620 | 610 |
621 // Disconnect from remote resources, dispose of local resources, and exit. | 611 // Disconnect from remote resources, dispose of local resources, and exit. |
622 private void disconnect() { | 612 private void disconnect() { |
623 activityRunning = false; | 613 activityRunning = false; |
| 614 remoteProxyRenderer.setTarget(null); |
| 615 localProxyRenderer.setTarget(null); |
624 if (appRtcClient != null) { | 616 if (appRtcClient != null) { |
625 appRtcClient.disconnectFromRoom(); | 617 appRtcClient.disconnectFromRoom(); |
626 appRtcClient = null; | 618 appRtcClient = null; |
627 } | 619 } |
628 if (peerConnectionClient != null) { | 620 if (peerConnectionClient != null) { |
629 peerConnectionClient.close(); | 621 peerConnectionClient.close(); |
630 peerConnectionClient = null; | 622 peerConnectionClient = null; |
631 } | 623 } |
632 if (localRender != null) { | 624 if (pipRenderer != null) { |
633 localRender.release(); | 625 pipRenderer.release(); |
634 localRender = null; | 626 pipRenderer = null; |
635 } | 627 } |
636 if (videoFileRenderer != null) { | 628 if (videoFileRenderer != null) { |
637 videoFileRenderer.release(); | 629 videoFileRenderer.release(); |
638 videoFileRenderer = null; | 630 videoFileRenderer = null; |
639 } | 631 } |
640 if (remoteRenderScreen != null) { | 632 if (fullscreenRenderer != null) { |
641 remoteRenderScreen.release(); | 633 fullscreenRenderer.release(); |
642 remoteRenderScreen = null; | 634 fullscreenRenderer = null; |
643 } | 635 } |
644 if (audioManager != null) { | 636 if (audioManager != null) { |
645 audioManager.stop(); | 637 audioManager.stop(); |
646 audioManager = null; | 638 audioManager = null; |
647 } | 639 } |
648 if (iceConnected && !isError) { | 640 if (iceConnected && !isError) { |
649 setResult(RESULT_OK); | 641 setResult(RESULT_OK); |
650 } else { | 642 } else { |
651 setResult(RESULT_CANCELED); | 643 setResult(RESULT_CANCELED); |
652 } | 644 } |
(...skipping 68 matching lines...) Loading... |
721 Logging.d(TAG, "Creating capturer using camera1 API."); | 713 Logging.d(TAG, "Creating capturer using camera1 API."); |
722 videoCapturer = createCameraCapturer(new Camera1Enumerator(captureToTextur
e())); | 714 videoCapturer = createCameraCapturer(new Camera1Enumerator(captureToTextur
e())); |
723 } | 715 } |
724 if (videoCapturer == null) { | 716 if (videoCapturer == null) { |
725 reportError("Failed to open camera"); | 717 reportError("Failed to open camera"); |
726 return null; | 718 return null; |
727 } | 719 } |
728 return videoCapturer; | 720 return videoCapturer; |
729 } | 721 } |
730 | 722 |
| 723 private void setSwappedFeeds(boolean isSwappedFeeds) { |
| 724 Logging.d(TAG, "setSwappedFeeds: " + isSwappedFeeds); |
| 725 this.isSwappedFeeds = isSwappedFeeds; |
| 726 localProxyRenderer.setTarget(isSwappedFeeds ? fullscreenRenderer : pipRender
er); |
| 727 remoteProxyRenderer.setTarget(isSwappedFeeds ? pipRenderer : fullscreenRende
rer); |
| 728 fullscreenRenderer.setMirror(isSwappedFeeds); |
| 729 pipRenderer.setMirror(!isSwappedFeeds); |
| 730 } |
| 731 |
731 // -----Implementation of AppRTCClient.AppRTCSignalingEvents --------------- | 732 // -----Implementation of AppRTCClient.AppRTCSignalingEvents --------------- |
732 // All callbacks are invoked from websocket signaling looper thread and | 733 // All callbacks are invoked from websocket signaling looper thread and |
733 // are routed to UI thread. | 734 // are routed to UI thread. |
734 private void onConnectedToRoomInternal(final SignalingParameters params) { | 735 private void onConnectedToRoomInternal(final SignalingParameters params) { |
735 final long delta = System.currentTimeMillis() - callStartedTimeMs; | 736 final long delta = System.currentTimeMillis() - callStartedTimeMs; |
736 | 737 |
737 signalingParameters = params; | 738 signalingParameters = params; |
738 logAndToast("Creating peer connection, delay=" + delta + "ms"); | 739 logAndToast("Creating peer connection, delay=" + delta + "ms"); |
739 VideoCapturer videoCapturer = null; | 740 VideoCapturer videoCapturer = null; |
740 if (peerConnectionParameters.videoCallEnabled) { | 741 if (peerConnectionParameters.videoCallEnabled) { |
741 videoCapturer = createVideoCapturer(); | 742 videoCapturer = createVideoCapturer(); |
742 } | 743 } |
743 peerConnectionClient.createPeerConnection(rootEglBase.getEglBaseContext(), l
ocalRender, | 744 peerConnectionClient.createPeerConnection(rootEglBase.getEglBaseContext(), l
ocalProxyRenderer, |
744 remoteRenderers, videoCapturer, signalingParameters); | 745 remoteRenderers, videoCapturer, signalingParameters); |
745 | 746 |
746 if (signalingParameters.initiator) { | 747 if (signalingParameters.initiator) { |
747 logAndToast("Creating OFFER..."); | 748 logAndToast("Creating OFFER..."); |
748 // Create offer. Offer SDP will be sent to answering client in | 749 // Create offer. Offer SDP will be sent to answering client in |
749 // PeerConnectionEvents.onLocalDescription event. | 750 // PeerConnectionEvents.onLocalDescription event. |
750 peerConnectionClient.createOffer(); | 751 peerConnectionClient.createOffer(); |
751 } else { | 752 } else { |
752 if (params.offerSdp != null) { | 753 if (params.offerSdp != null) { |
753 peerConnectionClient.setRemoteDescription(params.offerSdp); | 754 peerConnectionClient.setRemoteDescription(params.offerSdp); |
(...skipping 175 matching lines...) Loading... |
929 } | 930 } |
930 } | 931 } |
931 }); | 932 }); |
932 } | 933 } |
933 | 934 |
934 @Override | 935 @Override |
935 public void onPeerConnectionError(final String description) { | 936 public void onPeerConnectionError(final String description) { |
936 reportError(description); | 937 reportError(description); |
937 } | 938 } |
938 } | 939 } |
OLD | NEW |