| 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 |
| 11 package org.appspot.apprtc; | 11 package org.appspot.apprtc; |
| 12 | 12 |
| 13 import org.appspot.apprtc.AppRTCClient.RoomConnectionParameters; | |
| 14 import org.appspot.apprtc.AppRTCClient.SignalingParameters; | |
| 15 import org.appspot.apprtc.PeerConnectionClient.PeerConnectionParameters; | |
| 16 | |
| 17 import android.app.Activity; | 13 import android.app.Activity; |
| 18 import android.app.AlertDialog; | 14 import android.app.AlertDialog; |
| 19 import android.app.FragmentTransaction; | 15 import android.app.FragmentTransaction; |
| 16 import android.content.Context; |
| 20 import android.content.DialogInterface; | 17 import android.content.DialogInterface; |
| 21 import android.content.Intent; | 18 import android.content.Intent; |
| 22 import android.content.pm.PackageManager; | 19 import android.content.pm.PackageManager; |
| 20 import android.media.projection.MediaProjection; |
| 21 import android.media.projection.MediaProjectionManager; |
| 23 import android.net.Uri; | 22 import android.net.Uri; |
| 24 import android.os.Bundle; | 23 import android.os.Bundle; |
| 25 import android.os.Handler; | 24 import android.os.Handler; |
| 25 import android.util.DisplayMetrics; |
| 26 import android.util.Log; | 26 import android.util.Log; |
| 27 import android.view.View; | 27 import android.view.View; |
| 28 import android.view.Window; | 28 import android.view.Window; |
| 29 import android.view.WindowManager; |
| 29 import android.view.WindowManager.LayoutParams; | 30 import android.view.WindowManager.LayoutParams; |
| 30 import android.widget.Toast; | 31 import android.widget.Toast; |
| 31 | |
| 32 import java.io.IOException; | 32 import java.io.IOException; |
| 33 import java.lang.RuntimeException; | 33 import java.lang.RuntimeException; |
| 34 import java.util.ArrayList; | 34 import java.util.ArrayList; |
| 35 import java.util.List; | 35 import java.util.List; |
| 36 | 36 import org.appspot.apprtc.AppRTCClient.RoomConnectionParameters; |
| 37 import org.appspot.apprtc.AppRTCClient.SignalingParameters; |
| 38 import org.appspot.apprtc.PeerConnectionClient.PeerConnectionParameters; |
| 37 import org.webrtc.Camera1Enumerator; | 39 import org.webrtc.Camera1Enumerator; |
| 38 import org.webrtc.Camera2Enumerator; | 40 import org.webrtc.Camera2Enumerator; |
| 39 import org.webrtc.CameraEnumerator; | 41 import org.webrtc.CameraEnumerator; |
| 40 import org.webrtc.EglBase; | 42 import org.webrtc.EglBase; |
| 41 import org.webrtc.FileVideoCapturer; | 43 import org.webrtc.FileVideoCapturer; |
| 42 import org.webrtc.VideoFileRenderer; | |
| 43 import org.webrtc.IceCandidate; | 44 import org.webrtc.IceCandidate; |
| 44 import org.webrtc.Logging; | 45 import org.webrtc.Logging; |
| 45 import org.webrtc.PeerConnectionFactory; | 46 import org.webrtc.PeerConnectionFactory; |
| 46 import org.webrtc.RendererCommon.ScalingType; | 47 import org.webrtc.RendererCommon.ScalingType; |
| 48 import org.webrtc.ScreenCapturerAndroid; |
| 47 import org.webrtc.SessionDescription; | 49 import org.webrtc.SessionDescription; |
| 48 import org.webrtc.StatsReport; | 50 import org.webrtc.StatsReport; |
| 49 import org.webrtc.SurfaceViewRenderer; | 51 import org.webrtc.SurfaceViewRenderer; |
| 50 import org.webrtc.VideoCapturer; | 52 import org.webrtc.VideoCapturer; |
| 53 import org.webrtc.VideoFileRenderer; |
| 51 import org.webrtc.VideoRenderer; | 54 import org.webrtc.VideoRenderer; |
| 52 | 55 |
| 53 /** | 56 /** |
| 54 * Activity for peer connection call setup, call waiting | 57 * Activity for peer connection call setup, call waiting |
| 55 * and call view. | 58 * and call view. |
| 56 */ | 59 */ |
| 57 public class CallActivity extends Activity implements AppRTCClient.SignalingEven
ts, | 60 public class CallActivity extends Activity implements AppRTCClient.SignalingEven
ts, |
| 58 PeerConnectionClient.PeerC
onnectionEvents, | 61 PeerConnectionClient.PeerC
onnectionEvents, |
| 59 CallFragment.OnCallEvents
{ | 62 CallFragment.OnCallEvents
{ |
| 60 public static final String EXTRA_ROOMID = "org.appspot.apprtc.ROOMID"; | 63 public static final String EXTRA_ROOMID = "org.appspot.apprtc.ROOMID"; |
| 61 public static final String EXTRA_LOOPBACK = "org.appspot.apprtc.LOOPBACK"; | 64 public static final String EXTRA_LOOPBACK = "org.appspot.apprtc.LOOPBACK"; |
| 62 public static final String EXTRA_VIDEO_CALL = "org.appspot.apprtc.VIDEO_CALL"; | 65 public static final String EXTRA_VIDEO_CALL = "org.appspot.apprtc.VIDEO_CALL"; |
| 66 public static final String EXTRA_SCREENCAPTURE = "org.appspot.apprtc.SCREENCAP
TURE"; |
| 63 public static final String EXTRA_CAMERA2 = "org.appspot.apprtc.CAMERA2"; | 67 public static final String EXTRA_CAMERA2 = "org.appspot.apprtc.CAMERA2"; |
| 64 public static final String EXTRA_VIDEO_WIDTH = "org.appspot.apprtc.VIDEO_WIDTH
"; | 68 public static final String EXTRA_VIDEO_WIDTH = "org.appspot.apprtc.VIDEO_WIDTH
"; |
| 65 public static final String EXTRA_VIDEO_HEIGHT = "org.appspot.apprtc.VIDEO_HEIG
HT"; | 69 public static final String EXTRA_VIDEO_HEIGHT = "org.appspot.apprtc.VIDEO_HEIG
HT"; |
| 66 public static final String EXTRA_VIDEO_FPS = "org.appspot.apprtc.VIDEO_FPS"; | 70 public static final String EXTRA_VIDEO_FPS = "org.appspot.apprtc.VIDEO_FPS"; |
| 67 public static final String EXTRA_VIDEO_CAPTUREQUALITYSLIDER_ENABLED = | 71 public static final String EXTRA_VIDEO_CAPTUREQUALITYSLIDER_ENABLED = |
| 68 "org.appsopt.apprtc.VIDEO_CAPTUREQUALITYSLIDER"; | 72 "org.appsopt.apprtc.VIDEO_CAPTUREQUALITYSLIDER"; |
| 69 public static final String EXTRA_VIDEO_BITRATE = "org.appspot.apprtc.VIDEO_BIT
RATE"; | 73 public static final String EXTRA_VIDEO_BITRATE = "org.appspot.apprtc.VIDEO_BIT
RATE"; |
| 70 public static final String EXTRA_VIDEOCODEC = "org.appspot.apprtc.VIDEOCODEC"; | 74 public static final String EXTRA_VIDEOCODEC = "org.appspot.apprtc.VIDEOCODEC"; |
| 71 public static final String EXTRA_HWCODEC_ENABLED = "org.appspot.apprtc.HWCODEC
"; | 75 public static final String EXTRA_HWCODEC_ENABLED = "org.appspot.apprtc.HWCODEC
"; |
| 72 public static final String EXTRA_CAPTURETOTEXTURE_ENABLED = "org.appspot.apprt
c.CAPTURETOTEXTURE"; | 76 public static final String EXTRA_CAPTURETOTEXTURE_ENABLED = "org.appspot.apprt
c.CAPTURETOTEXTURE"; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 87 public static final String EXTRA_VIDEO_FILE_AS_CAMERA = "org.appspot.apprtc.VI
DEO_FILE_AS_CAMERA"; | 91 public static final String EXTRA_VIDEO_FILE_AS_CAMERA = "org.appspot.apprtc.VI
DEO_FILE_AS_CAMERA"; |
| 88 public static final String EXTRA_SAVE_REMOTE_VIDEO_TO_FILE = | 92 public static final String EXTRA_SAVE_REMOTE_VIDEO_TO_FILE = |
| 89 "org.appspot.apprtc.SAVE_REMOTE_VIDEO_TO_FILE"; | 93 "org.appspot.apprtc.SAVE_REMOTE_VIDEO_TO_FILE"; |
| 90 public static final String EXTRA_SAVE_REMOTE_VIDEO_TO_FILE_WIDTH = | 94 public static final String EXTRA_SAVE_REMOTE_VIDEO_TO_FILE_WIDTH = |
| 91 "org.appspot.apprtc.SAVE_REMOTE_VIDEO_TO_FILE_WIDTH"; | 95 "org.appspot.apprtc.SAVE_REMOTE_VIDEO_TO_FILE_WIDTH"; |
| 92 public static final String EXTRA_SAVE_REMOTE_VIDEO_TO_FILE_HEIGHT = | 96 public static final String EXTRA_SAVE_REMOTE_VIDEO_TO_FILE_HEIGHT = |
| 93 "org.appspot.apprtc.SAVE_REMOTE_VIDEO_TO_FILE_HEIGHT"; | 97 "org.appspot.apprtc.SAVE_REMOTE_VIDEO_TO_FILE_HEIGHT"; |
| 94 public static final String EXTRA_USE_VALUES_FROM_INTENT = | 98 public static final String EXTRA_USE_VALUES_FROM_INTENT = |
| 95 "org.appspot.apprtc.USE_VALUES_FROM_INTENT"; | 99 "org.appspot.apprtc.USE_VALUES_FROM_INTENT"; |
| 96 private static final String TAG = "CallRTCClient"; | 100 private static final String TAG = "CallRTCClient"; |
| 101 private static final int CAPTURE_PERMISSION_REQUEST_CODE = 1; |
| 97 | 102 |
| 98 // List of mandatory application permissions. | 103 // List of mandatory application permissions. |
| 99 private static final String[] MANDATORY_PERMISSIONS = {"android.permission.MOD
IFY_AUDIO_SETTINGS", | 104 private static final String[] MANDATORY_PERMISSIONS = {"android.permission.MOD
IFY_AUDIO_SETTINGS", |
| 100 "android.permission.RECORD_AUDIO", "android.permission.INTERNET"}; | 105 "android.permission.RECORD_AUDIO", "android.permission.INTERNET"}; |
| 101 | 106 |
| 102 // Peer connection statistics callback period in ms. | 107 // Peer connection statistics callback period in ms. |
| 103 private static final int STAT_CALLBACK_PERIOD = 1000; | 108 private static final int STAT_CALLBACK_PERIOD = 1000; |
| 104 // Local preview screen position before call is connected. | 109 // Local preview screen position before call is connected. |
| 105 private static final int LOCAL_X_CONNECTING = 0; | 110 private static final int LOCAL_X_CONNECTING = 0; |
| 106 private static final int LOCAL_Y_CONNECTING = 0; | 111 private static final int LOCAL_Y_CONNECTING = 0; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 133 private boolean commandLineRun; | 138 private boolean commandLineRun; |
| 134 private int runTimeMs; | 139 private int runTimeMs; |
| 135 private boolean activityRunning; | 140 private boolean activityRunning; |
| 136 private RoomConnectionParameters roomConnectionParameters; | 141 private RoomConnectionParameters roomConnectionParameters; |
| 137 private PeerConnectionParameters peerConnectionParameters; | 142 private PeerConnectionParameters peerConnectionParameters; |
| 138 private boolean iceConnected; | 143 private boolean iceConnected; |
| 139 private boolean isError; | 144 private boolean isError; |
| 140 private boolean callControlFragmentVisible = true; | 145 private boolean callControlFragmentVisible = true; |
| 141 private long callStartedTimeMs = 0; | 146 private long callStartedTimeMs = 0; |
| 142 private boolean micEnabled = true; | 147 private boolean micEnabled = true; |
| 148 private boolean screencaptureEnabled = false; |
| 149 private static Intent mediaProjectionPermissionResultData; |
| 150 private static int mediaProjectionPermissionResultCode; |
| 143 | 151 |
| 144 // Controls | 152 // Controls |
| 145 private CallFragment callFragment; | 153 private CallFragment callFragment; |
| 146 private HudFragment hudFragment; | 154 private HudFragment hudFragment; |
| 147 private CpuMonitor cpuMonitor; | 155 private CpuMonitor cpuMonitor; |
| 148 | 156 |
| 149 @Override | 157 @Override |
| 150 public void onCreate(Bundle savedInstanceState) { | 158 public void onCreate(Bundle savedInstanceState) { |
| 151 super.onCreate(savedInstanceState); | 159 super.onCreate(savedInstanceState); |
| 152 Thread.setDefaultUncaughtExceptionHandler(new UnhandledExceptionHandler(this
)); | 160 Thread.setDefaultUncaughtExceptionHandler(new UnhandledExceptionHandler(this
)); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 logAndToast(getString(R.string.missing_url)); | 244 logAndToast(getString(R.string.missing_url)); |
| 237 Log.e(TAG, "Incorrect room ID in intent!"); | 245 Log.e(TAG, "Incorrect room ID in intent!"); |
| 238 setResult(RESULT_CANCELED); | 246 setResult(RESULT_CANCELED); |
| 239 finish(); | 247 finish(); |
| 240 return; | 248 return; |
| 241 } | 249 } |
| 242 | 250 |
| 243 boolean loopback = intent.getBooleanExtra(EXTRA_LOOPBACK, false); | 251 boolean loopback = intent.getBooleanExtra(EXTRA_LOOPBACK, false); |
| 244 boolean tracing = intent.getBooleanExtra(EXTRA_TRACING, false); | 252 boolean tracing = intent.getBooleanExtra(EXTRA_TRACING, false); |
| 245 | 253 |
| 254 int videoWidth = intent.getIntExtra(EXTRA_VIDEO_WIDTH, 0); |
| 255 int videoHeight = intent.getIntExtra(EXTRA_VIDEO_HEIGHT, 0); |
| 256 |
| 257 screencaptureEnabled = intent.getBooleanExtra(EXTRA_SCREENCAPTURE, false); |
| 258 // If capturing format is not specified for screencapture, use screen resolu
tion. |
| 259 if (screencaptureEnabled && videoWidth == 0 && videoHeight == 0) { |
| 260 DisplayMetrics displayMetrics = new DisplayMetrics(); |
| 261 WindowManager windowManager = |
| 262 (WindowManager) getApplication().getSystemService(Context.WINDOW_SERVI
CE); |
| 263 windowManager.getDefaultDisplay().getRealMetrics(displayMetrics); |
| 264 videoWidth = displayMetrics.widthPixels; |
| 265 videoHeight = displayMetrics.heightPixels; |
| 266 } |
| 267 |
| 246 peerConnectionParameters = | 268 peerConnectionParameters = |
| 247 new PeerConnectionParameters(intent.getBooleanExtra(EXTRA_VIDEO_CALL, tr
ue), loopback, | 269 new PeerConnectionParameters(intent.getBooleanExtra(EXTRA_VIDEO_CALL, tr
ue), loopback, |
| 248 tracing, intent.getIntExtra(EXTRA_VIDEO_WIDTH, 0), | 270 tracing, videoWidth, videoHeight, intent.getIntExtra(EXTRA_VIDEO_FPS
, 0), |
| 249 intent.getIntExtra(EXTRA_VIDEO_HEIGHT, 0), intent.getIntExtra(EXTRA_
VIDEO_FPS, 0), | |
| 250 intent.getIntExtra(EXTRA_VIDEO_BITRATE, 0), intent.getStringExtra(EX
TRA_VIDEOCODEC), | 271 intent.getIntExtra(EXTRA_VIDEO_BITRATE, 0), intent.getStringExtra(EX
TRA_VIDEOCODEC), |
| 251 intent.getBooleanExtra(EXTRA_HWCODEC_ENABLED, true), | 272 intent.getBooleanExtra(EXTRA_HWCODEC_ENABLED, true), |
| 252 intent.getIntExtra(EXTRA_AUDIO_BITRATE, 0), intent.getStringExtra(EX
TRA_AUDIOCODEC), | 273 intent.getIntExtra(EXTRA_AUDIO_BITRATE, 0), intent.getStringExtra(EX
TRA_AUDIOCODEC), |
| 253 intent.getBooleanExtra(EXTRA_NOAUDIOPROCESSING_ENABLED, false), | 274 intent.getBooleanExtra(EXTRA_NOAUDIOPROCESSING_ENABLED, false), |
| 254 intent.getBooleanExtra(EXTRA_AECDUMP_ENABLED, false), | 275 intent.getBooleanExtra(EXTRA_AECDUMP_ENABLED, false), |
| 255 intent.getBooleanExtra(EXTRA_OPENSLES_ENABLED, false), | 276 intent.getBooleanExtra(EXTRA_OPENSLES_ENABLED, false), |
| 256 intent.getBooleanExtra(EXTRA_DISABLE_BUILT_IN_AEC, false), | 277 intent.getBooleanExtra(EXTRA_DISABLE_BUILT_IN_AEC, false), |
| 257 intent.getBooleanExtra(EXTRA_DISABLE_BUILT_IN_AGC, false), | 278 intent.getBooleanExtra(EXTRA_DISABLE_BUILT_IN_AGC, false), |
| 258 intent.getBooleanExtra(EXTRA_DISABLE_BUILT_IN_NS, false), | 279 intent.getBooleanExtra(EXTRA_DISABLE_BUILT_IN_NS, false), |
| 259 intent.getBooleanExtra(EXTRA_ENABLE_LEVEL_CONTROL, false)); | 280 intent.getBooleanExtra(EXTRA_ENABLE_LEVEL_CONTROL, false)); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 278 hudFragment.setCpuMonitor(cpuMonitor); | 299 hudFragment.setCpuMonitor(cpuMonitor); |
| 279 | 300 |
| 280 // Send intent arguments to fragments. | 301 // Send intent arguments to fragments. |
| 281 callFragment.setArguments(intent.getExtras()); | 302 callFragment.setArguments(intent.getExtras()); |
| 282 hudFragment.setArguments(intent.getExtras()); | 303 hudFragment.setArguments(intent.getExtras()); |
| 283 // Activate call and HUD fragments and start the call. | 304 // Activate call and HUD fragments and start the call. |
| 284 FragmentTransaction ft = getFragmentManager().beginTransaction(); | 305 FragmentTransaction ft = getFragmentManager().beginTransaction(); |
| 285 ft.add(R.id.call_fragment_container, callFragment); | 306 ft.add(R.id.call_fragment_container, callFragment); |
| 286 ft.add(R.id.hud_fragment_container, hudFragment); | 307 ft.add(R.id.hud_fragment_container, hudFragment); |
| 287 ft.commit(); | 308 ft.commit(); |
| 288 startCall(); | |
| 289 | 309 |
| 290 // For command line execution run connection for <runTimeMs> and exit. | 310 // For command line execution run connection for <runTimeMs> and exit. |
| 291 if (commandLineRun && runTimeMs > 0) { | 311 if (commandLineRun && runTimeMs > 0) { |
| 292 (new Handler()).postDelayed(new Runnable() { | 312 (new Handler()).postDelayed(new Runnable() { |
| 293 @Override | 313 @Override |
| 294 public void run() { | 314 public void run() { |
| 295 disconnect(); | 315 disconnect(); |
| 296 } | 316 } |
| 297 }, runTimeMs); | 317 }, runTimeMs); |
| 298 } | 318 } |
| 299 | 319 |
| 300 peerConnectionClient = PeerConnectionClient.getInstance(); | 320 peerConnectionClient = PeerConnectionClient.getInstance(); |
| 301 if (loopback) { | 321 if (loopback) { |
| 302 PeerConnectionFactory.Options options = new PeerConnectionFactory.Options(
); | 322 PeerConnectionFactory.Options options = new PeerConnectionFactory.Options(
); |
| 303 options.networkIgnoreMask = 0; | 323 options.networkIgnoreMask = 0; |
| 304 peerConnectionClient.setPeerConnectionFactoryOptions(options); | 324 peerConnectionClient.setPeerConnectionFactoryOptions(options); |
| 305 } | 325 } |
| 306 peerConnectionClient.createPeerConnectionFactory( | 326 peerConnectionClient.createPeerConnectionFactory( |
| 307 CallActivity.this, peerConnectionParameters, CallActivity.this); | 327 CallActivity.this, peerConnectionParameters, CallActivity.this); |
| 328 |
| 329 if (screencaptureEnabled) { |
| 330 MediaProjectionManager mediaProjectionManager = |
| 331 (MediaProjectionManager) getApplication().getSystemService( |
| 332 Context.MEDIA_PROJECTION_SERVICE); |
| 333 startActivityForResult( |
| 334 mediaProjectionManager.createScreenCaptureIntent(), CAPTURE_PERMISSION
_REQUEST_CODE); |
| 335 } else { |
| 336 startCall(); |
| 337 } |
| 338 } |
| 339 |
| 340 @Override |
| 341 public void onActivityResult(int requestCode, int resultCode, Intent data) { |
| 342 if (requestCode != CAPTURE_PERMISSION_REQUEST_CODE) |
| 343 return; |
| 344 mediaProjectionPermissionResultCode = resultCode; |
| 345 mediaProjectionPermissionResultData = data; |
| 346 startCall(); |
| 308 } | 347 } |
| 309 | 348 |
| 310 private boolean useCamera2() { | 349 private boolean useCamera2() { |
| 311 return Camera2Enumerator.isSupported(this) && getIntent().getBooleanExtra(EX
TRA_CAMERA2, true); | 350 return Camera2Enumerator.isSupported(this) && getIntent().getBooleanExtra(EX
TRA_CAMERA2, true); |
| 312 } | 351 } |
| 313 | 352 |
| 314 private boolean captureToTexture() { | 353 private boolean captureToTexture() { |
| 315 return getIntent().getBooleanExtra(EXTRA_CAPTURETOTEXTURE_ENABLED, false); | 354 return getIntent().getBooleanExtra(EXTRA_CAPTURETOTEXTURE_ENABLED, false); |
| 316 } | 355 } |
| 317 | 356 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 345 } | 384 } |
| 346 | 385 |
| 347 return null; | 386 return null; |
| 348 } | 387 } |
| 349 | 388 |
| 350 // Activity interfaces | 389 // Activity interfaces |
| 351 @Override | 390 @Override |
| 352 public void onPause() { | 391 public void onPause() { |
| 353 super.onPause(); | 392 super.onPause(); |
| 354 activityRunning = false; | 393 activityRunning = false; |
| 355 if (peerConnectionClient != null) { | 394 // Don't stop the video when using screencapture to allow user to show other
apps to the remote |
| 395 // end. |
| 396 if (peerConnectionClient != null && !screencaptureEnabled) { |
| 356 peerConnectionClient.stopVideoSource(); | 397 peerConnectionClient.stopVideoSource(); |
| 357 } | 398 } |
| 358 cpuMonitor.pause(); | 399 cpuMonitor.pause(); |
| 359 } | 400 } |
| 360 | 401 |
| 361 @Override | 402 @Override |
| 362 public void onResume() { | 403 public void onResume() { |
| 363 super.onResume(); | 404 super.onResume(); |
| 364 activityRunning = true; | 405 activityRunning = true; |
| 365 if (peerConnectionClient != null) { | 406 // Video is not paused for screencapture. See onPause. |
| 407 if (peerConnectionClient != null && !screencaptureEnabled) { |
| 366 peerConnectionClient.startVideoSource(); | 408 peerConnectionClient.startVideoSource(); |
| 367 } | 409 } |
| 368 cpuMonitor.resume(); | 410 cpuMonitor.resume(); |
| 369 } | 411 } |
| 370 | 412 |
| 371 @Override | 413 @Override |
| 372 protected void onDestroy() { | 414 protected void onDestroy() { |
| 373 disconnect(); | 415 disconnect(); |
| 374 if (logToast != null) { | 416 if (logToast != null) { |
| 375 logToast.cancel(); | 417 logToast.cancel(); |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 581 private VideoCapturer createVideoCapturer() { | 623 private VideoCapturer createVideoCapturer() { |
| 582 VideoCapturer videoCapturer = null; | 624 VideoCapturer videoCapturer = null; |
| 583 String videoFileAsCamera = getIntent().getStringExtra(EXTRA_VIDEO_FILE_AS_CA
MERA); | 625 String videoFileAsCamera = getIntent().getStringExtra(EXTRA_VIDEO_FILE_AS_CA
MERA); |
| 584 if (videoFileAsCamera != null) { | 626 if (videoFileAsCamera != null) { |
| 585 try { | 627 try { |
| 586 videoCapturer = new FileVideoCapturer(videoFileAsCamera); | 628 videoCapturer = new FileVideoCapturer(videoFileAsCamera); |
| 587 } catch (IOException e) { | 629 } catch (IOException e) { |
| 588 reportError("Failed to open video file for emulated camera"); | 630 reportError("Failed to open video file for emulated camera"); |
| 589 return null; | 631 return null; |
| 590 } | 632 } |
| 633 } else if (screencaptureEnabled) { |
| 634 if (mediaProjectionPermissionResultCode != Activity.RESULT_OK) { |
| 635 reportError("User didn't give permission to capture the screen."); |
| 636 return null; |
| 637 } |
| 638 return new ScreenCapturerAndroid( |
| 639 mediaProjectionPermissionResultData, new MediaProjection.Callback() { |
| 640 @Override |
| 641 public void onStop() { |
| 642 reportError("User revoked permission to capture the screen."); |
| 643 } |
| 644 }); |
| 591 } else if (useCamera2()) { | 645 } else if (useCamera2()) { |
| 592 if (!captureToTexture()) { | 646 if (!captureToTexture()) { |
| 593 reportError(getString(R.string.camera2_texture_only_error)); | 647 reportError(getString(R.string.camera2_texture_only_error)); |
| 594 return null; | 648 return null; |
| 595 } | 649 } |
| 596 | 650 |
| 597 Logging.d(TAG, "Creating capturer using camera2 API."); | 651 Logging.d(TAG, "Creating capturer using camera2 API."); |
| 598 videoCapturer = createCameraCapturer(new Camera2Enumerator(this)); | 652 videoCapturer = createCameraCapturer(new Camera2Enumerator(this)); |
| 599 } else { | 653 } else { |
| 600 Logging.d(TAG, "Creating capturer using camera1 API."); | 654 Logging.d(TAG, "Creating capturer using camera1 API."); |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 808 } | 862 } |
| 809 } | 863 } |
| 810 }); | 864 }); |
| 811 } | 865 } |
| 812 | 866 |
| 813 @Override | 867 @Override |
| 814 public void onPeerConnectionError(final String description) { | 868 public void onPeerConnectionError(final String description) { |
| 815 reportError(description); | 869 reportError(description); |
| 816 } | 870 } |
| 817 } | 871 } |
| OLD | NEW |