Chromium Code Reviews| 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...) Expand 10 before | Expand all | Expand 10 after 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 private boolean isSwappedFeeds; | |
|
magjed_webrtc
2017/02/10 13:23:38
Can you comment what it means when this is true vs
sakal
2017/02/10 14:05:36
Done.
| |
| 179 | 183 |
| 180 // Controls | 184 // Controls |
| 181 private CallFragment callFragment; | 185 private CallFragment callFragment; |
| 182 private HudFragment hudFragment; | 186 private HudFragment hudFragment; |
| 183 private CpuMonitor cpuMonitor; | 187 private CpuMonitor cpuMonitor; |
| 184 | 188 |
| 189 | |
|
magjed_webrtc
2017/02/10 13:23:38
nit: remove unnecessary empty line
sakal
2017/02/10 14:05:36
Done.
| |
| 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 setSwappedFeeds(true /* isSwappedFeeds */); |
|
magjed_webrtc
2017/02/10 13:23:38
Add a comment why we start with local in fullscree
sakal
2017/02/10 14:05:36
Done.
| |
| 249 | 260 |
| 250 // Check for mandatory permissions. | 261 // Check for mandatory permissions. |
| 251 for (String permission : MANDATORY_PERMISSIONS) { | 262 for (String permission : MANDATORY_PERMISSIONS) { |
| 252 if (checkCallingOrSelfPermission(permission) != PackageManager.PERMISSION_ GRANTED) { | 263 if (checkCallingOrSelfPermission(permission) != PackageManager.PERMISSION_ GRANTED) { |
| 253 logAndToast("Permission " + permission + " is not granted"); | 264 logAndToast("Permission " + permission + " is not granted"); |
| 254 setResult(RESULT_CANCELED); | 265 setResult(RESULT_CANCELED); |
| 255 finish(); | 266 finish(); |
| 256 return; | 267 return; |
| 257 } | 268 } |
| 258 } | 269 } |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 501 | 512 |
| 502 @Override | 513 @Override |
| 503 public void onCameraSwitch() { | 514 public void onCameraSwitch() { |
| 504 if (peerConnectionClient != null) { | 515 if (peerConnectionClient != null) { |
| 505 peerConnectionClient.switchCamera(); | 516 peerConnectionClient.switchCamera(); |
| 506 } | 517 } |
| 507 } | 518 } |
| 508 | 519 |
| 509 @Override | 520 @Override |
| 510 public void onVideoScalingSwitch(ScalingType scalingType) { | 521 public void onVideoScalingSwitch(ScalingType scalingType) { |
| 511 this.scalingType = scalingType; | 522 fullscreenRenderer.setScalingType(scalingType); |
| 512 updateVideoView(); | |
| 513 } | 523 } |
| 514 | 524 |
| 515 @Override | 525 @Override |
| 516 public void onCaptureFormatChange(int width, int height, int framerate) { | 526 public void onCaptureFormatChange(int width, int height, int framerate) { |
| 517 if (peerConnectionClient != null) { | 527 if (peerConnectionClient != null) { |
| 518 peerConnectionClient.changeCaptureFormat(width, height, framerate); | 528 peerConnectionClient.changeCaptureFormat(width, height, framerate); |
| 519 } | 529 } |
| 520 } | 530 } |
| 521 | 531 |
| 522 @Override | 532 @Override |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 540 ft.show(callFragment); | 550 ft.show(callFragment); |
| 541 ft.show(hudFragment); | 551 ft.show(hudFragment); |
| 542 } else { | 552 } else { |
| 543 ft.hide(callFragment); | 553 ft.hide(callFragment); |
| 544 ft.hide(hudFragment); | 554 ft.hide(hudFragment); |
| 545 } | 555 } |
| 546 ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); | 556 ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); |
| 547 ft.commit(); | 557 ft.commit(); |
| 548 } | 558 } |
| 549 | 559 |
| 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() { | 560 private void startCall() { |
| 571 if (appRtcClient == null) { | 561 if (appRtcClient == null) { |
| 572 Log.e(TAG, "AppRTC client is not allocated for a call."); | 562 Log.e(TAG, "AppRTC client is not allocated for a call."); |
| 573 return; | 563 return; |
| 574 } | 564 } |
| 575 callStartedTimeMs = System.currentTimeMillis(); | 565 callStartedTimeMs = System.currentTimeMillis(); |
| 576 | 566 |
| 577 // Start room connection. | 567 // Start room connection. |
| 578 logAndToast(getString(R.string.connecting_to, roomConnectionParameters.roomU rl)); | 568 logAndToast(getString(R.string.connecting_to, roomConnectionParameters.roomU rl)); |
| 579 appRtcClient.connectToRoom(roomConnectionParameters); | 569 appRtcClient.connectToRoom(roomConnectionParameters); |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 596 } | 586 } |
| 597 | 587 |
| 598 // Should be called from UI thread | 588 // Should be called from UI thread |
| 599 private void callConnected() { | 589 private void callConnected() { |
| 600 final long delta = System.currentTimeMillis() - callStartedTimeMs; | 590 final long delta = System.currentTimeMillis() - callStartedTimeMs; |
| 601 Log.i(TAG, "Call connected: delay=" + delta + "ms"); | 591 Log.i(TAG, "Call connected: delay=" + delta + "ms"); |
| 602 if (peerConnectionClient == null || isError) { | 592 if (peerConnectionClient == null || isError) { |
| 603 Log.w(TAG, "Call is connected in closed or error state"); | 593 Log.w(TAG, "Call is connected in closed or error state"); |
| 604 return; | 594 return; |
| 605 } | 595 } |
| 606 // Update video view. | |
| 607 updateVideoView(); | |
| 608 // Enable statistics callback. | 596 // Enable statistics callback. |
| 609 peerConnectionClient.enableStatsEvents(true, STAT_CALLBACK_PERIOD); | 597 peerConnectionClient.enableStatsEvents(true, STAT_CALLBACK_PERIOD); |
| 598 setSwappedFeeds(false /* isSwappedFeeds */); | |
| 610 } | 599 } |
| 611 | 600 |
| 612 // This method is called when the audio manager reports audio device change, | 601 // This method is called when the audio manager reports audio device change, |
| 613 // e.g. from wired headset to speakerphone. | 602 // e.g. from wired headset to speakerphone. |
| 614 private void onAudioManagerDevicesChanged( | 603 private void onAudioManagerDevicesChanged( |
| 615 final AudioDevice device, final Set<AudioDevice> availableDevices) { | 604 final AudioDevice device, final Set<AudioDevice> availableDevices) { |
| 616 Log.d(TAG, "onAudioManagerDevicesChanged: " + availableDevices + ", " | 605 Log.d(TAG, "onAudioManagerDevicesChanged: " + availableDevices + ", " |
| 617 + "selected: " + device); | 606 + "selected: " + device); |
| 618 // TODO(henrika): add callback handler. | 607 // TODO(henrika): add callback handler. |
| 619 } | 608 } |
| 620 | 609 |
| 621 // Disconnect from remote resources, dispose of local resources, and exit. | 610 // Disconnect from remote resources, dispose of local resources, and exit. |
| 622 private void disconnect() { | 611 private void disconnect() { |
| 623 activityRunning = false; | 612 activityRunning = false; |
| 613 remoteProxyRenderer.setTarget(null); | |
| 614 localProxyRenderer.setTarget(null); | |
| 624 if (appRtcClient != null) { | 615 if (appRtcClient != null) { |
| 625 appRtcClient.disconnectFromRoom(); | 616 appRtcClient.disconnectFromRoom(); |
| 626 appRtcClient = null; | 617 appRtcClient = null; |
| 627 } | 618 } |
| 628 if (peerConnectionClient != null) { | 619 if (peerConnectionClient != null) { |
| 629 peerConnectionClient.close(); | 620 peerConnectionClient.close(); |
| 630 peerConnectionClient = null; | 621 peerConnectionClient = null; |
| 631 } | 622 } |
| 632 if (localRender != null) { | 623 if (pipRenderer != null) { |
| 633 localRender.release(); | 624 pipRenderer.release(); |
| 634 localRender = null; | 625 pipRenderer = null; |
| 635 } | 626 } |
| 636 if (videoFileRenderer != null) { | 627 if (videoFileRenderer != null) { |
| 637 videoFileRenderer.release(); | 628 videoFileRenderer.release(); |
| 638 videoFileRenderer = null; | 629 videoFileRenderer = null; |
| 639 } | 630 } |
| 640 if (remoteRenderScreen != null) { | 631 if (fullscreenRenderer != null) { |
| 641 remoteRenderScreen.release(); | 632 fullscreenRenderer.release(); |
| 642 remoteRenderScreen = null; | 633 fullscreenRenderer = null; |
| 643 } | 634 } |
| 644 if (audioManager != null) { | 635 if (audioManager != null) { |
| 645 audioManager.stop(); | 636 audioManager.stop(); |
| 646 audioManager = null; | 637 audioManager = null; |
| 647 } | 638 } |
| 648 if (iceConnected && !isError) { | 639 if (iceConnected && !isError) { |
| 649 setResult(RESULT_OK); | 640 setResult(RESULT_OK); |
| 650 } else { | 641 } else { |
| 651 setResult(RESULT_CANCELED); | 642 setResult(RESULT_CANCELED); |
| 652 } | 643 } |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 721 Logging.d(TAG, "Creating capturer using camera1 API."); | 712 Logging.d(TAG, "Creating capturer using camera1 API."); |
| 722 videoCapturer = createCameraCapturer(new Camera1Enumerator(captureToTextur e())); | 713 videoCapturer = createCameraCapturer(new Camera1Enumerator(captureToTextur e())); |
| 723 } | 714 } |
| 724 if (videoCapturer == null) { | 715 if (videoCapturer == null) { |
| 725 reportError("Failed to open camera"); | 716 reportError("Failed to open camera"); |
| 726 return null; | 717 return null; |
| 727 } | 718 } |
| 728 return videoCapturer; | 719 return videoCapturer; |
| 729 } | 720 } |
| 730 | 721 |
| 722 private void setSwappedFeeds(boolean isSwappedFeeds) { | |
| 723 Logging.d(TAG, "setSwappedFeeds: " + isSwappedFeeds); | |
| 724 this.isSwappedFeeds = isSwappedFeeds; | |
| 725 localProxyRenderer.setTarget(isSwappedFeeds ? fullscreenRenderer : pipRender er); | |
| 726 remoteProxyRenderer.setTarget(isSwappedFeeds ? pipRenderer : fullscreenRende rer); | |
| 727 fullscreenRenderer.setMirror(isSwappedFeeds); | |
| 728 pipRenderer.setMirror(!isSwappedFeeds); | |
| 729 } | |
| 730 | |
| 731 // -----Implementation of AppRTCClient.AppRTCSignalingEvents --------------- | 731 // -----Implementation of AppRTCClient.AppRTCSignalingEvents --------------- |
| 732 // All callbacks are invoked from websocket signaling looper thread and | 732 // All callbacks are invoked from websocket signaling looper thread and |
| 733 // are routed to UI thread. | 733 // are routed to UI thread. |
| 734 private void onConnectedToRoomInternal(final SignalingParameters params) { | 734 private void onConnectedToRoomInternal(final SignalingParameters params) { |
| 735 final long delta = System.currentTimeMillis() - callStartedTimeMs; | 735 final long delta = System.currentTimeMillis() - callStartedTimeMs; |
| 736 | 736 |
| 737 signalingParameters = params; | 737 signalingParameters = params; |
| 738 logAndToast("Creating peer connection, delay=" + delta + "ms"); | 738 logAndToast("Creating peer connection, delay=" + delta + "ms"); |
| 739 VideoCapturer videoCapturer = null; | 739 VideoCapturer videoCapturer = null; |
| 740 if (peerConnectionParameters.videoCallEnabled) { | 740 if (peerConnectionParameters.videoCallEnabled) { |
| 741 videoCapturer = createVideoCapturer(); | 741 videoCapturer = createVideoCapturer(); |
| 742 } | 742 } |
| 743 peerConnectionClient.createPeerConnection(rootEglBase.getEglBaseContext(), l ocalRender, | 743 peerConnectionClient.createPeerConnection(rootEglBase.getEglBaseContext(), l ocalProxyRenderer, |
| 744 remoteRenderers, videoCapturer, signalingParameters); | 744 remoteRenderers, videoCapturer, signalingParameters); |
| 745 | 745 |
| 746 if (signalingParameters.initiator) { | 746 if (signalingParameters.initiator) { |
| 747 logAndToast("Creating OFFER..."); | 747 logAndToast("Creating OFFER..."); |
| 748 // Create offer. Offer SDP will be sent to answering client in | 748 // Create offer. Offer SDP will be sent to answering client in |
| 749 // PeerConnectionEvents.onLocalDescription event. | 749 // PeerConnectionEvents.onLocalDescription event. |
| 750 peerConnectionClient.createOffer(); | 750 peerConnectionClient.createOffer(); |
| 751 } else { | 751 } else { |
| 752 if (params.offerSdp != null) { | 752 if (params.offerSdp != null) { |
| 753 peerConnectionClient.setRemoteDescription(params.offerSdp); | 753 peerConnectionClient.setRemoteDescription(params.offerSdp); |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 929 } | 929 } |
| 930 } | 930 } |
| 931 }); | 931 }); |
| 932 } | 932 } |
| 933 | 933 |
| 934 @Override | 934 @Override |
| 935 public void onPeerConnectionError(final String description) { | 935 public void onPeerConnectionError(final String description) { |
| 936 reportError(description); | 936 reportError(description); |
| 937 } | 937 } |
| 938 } | 938 } |
| OLD | NEW |