| 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 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 | 279 |
| 280 boolean loopback = intent.getBooleanExtra(EXTRA_LOOPBACK, false); | 280 boolean loopback = intent.getBooleanExtra(EXTRA_LOOPBACK, false); |
| 281 boolean tracing = intent.getBooleanExtra(EXTRA_TRACING, false); | 281 boolean tracing = intent.getBooleanExtra(EXTRA_TRACING, false); |
| 282 | 282 |
| 283 int videoWidth = intent.getIntExtra(EXTRA_VIDEO_WIDTH, 0); | 283 int videoWidth = intent.getIntExtra(EXTRA_VIDEO_WIDTH, 0); |
| 284 int videoHeight = intent.getIntExtra(EXTRA_VIDEO_HEIGHT, 0); | 284 int videoHeight = intent.getIntExtra(EXTRA_VIDEO_HEIGHT, 0); |
| 285 | 285 |
| 286 screencaptureEnabled = intent.getBooleanExtra(EXTRA_SCREENCAPTURE, false); | 286 screencaptureEnabled = intent.getBooleanExtra(EXTRA_SCREENCAPTURE, false); |
| 287 // If capturing format is not specified for screencapture, use screen resolu
tion. | 287 // If capturing format is not specified for screencapture, use screen resolu
tion. |
| 288 if (screencaptureEnabled && videoWidth == 0 && videoHeight == 0) { | 288 if (screencaptureEnabled && videoWidth == 0 && videoHeight == 0) { |
| 289 DisplayMetrics displayMetrics = new DisplayMetrics(); | 289 DisplayMetrics displayMetrics = getDisplayMetrics(); |
| 290 WindowManager windowManager = | |
| 291 (WindowManager) getApplication().getSystemService(Context.WINDOW_SERVI
CE); | |
| 292 windowManager.getDefaultDisplay().getRealMetrics(displayMetrics); | |
| 293 videoWidth = displayMetrics.widthPixels; | 290 videoWidth = displayMetrics.widthPixels; |
| 294 videoHeight = displayMetrics.heightPixels; | 291 videoHeight = displayMetrics.heightPixels; |
| 295 } | 292 } |
| 296 DataChannelParameters dataChannelParameters = null; | 293 DataChannelParameters dataChannelParameters = null; |
| 297 if (intent.getBooleanExtra(EXTRA_DATA_CHANNEL_ENABLED, false)) { | 294 if (intent.getBooleanExtra(EXTRA_DATA_CHANNEL_ENABLED, false)) { |
| 298 dataChannelParameters = new DataChannelParameters(intent.getBooleanExtra(E
XTRA_ORDERED, true), | 295 dataChannelParameters = new DataChannelParameters(intent.getBooleanExtra(E
XTRA_ORDERED, true), |
| 299 intent.getIntExtra(EXTRA_MAX_RETRANSMITS_MS, -1), | 296 intent.getIntExtra(EXTRA_MAX_RETRANSMITS_MS, -1), |
| 300 intent.getIntExtra(EXTRA_MAX_RETRANSMITS, -1), intent.getStringExtra(E
XTRA_PROTOCOL), | 297 intent.getIntExtra(EXTRA_MAX_RETRANSMITS, -1), intent.getStringExtra(E
XTRA_PROTOCOL), |
| 301 intent.getBooleanExtra(EXTRA_NEGOTIATED, false), intent.getIntExtra(EX
TRA_ID, -1)); | 298 intent.getBooleanExtra(EXTRA_NEGOTIATED, false), intent.getIntExtra(EX
TRA_ID, -1)); |
| 302 } | 299 } |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 peerConnectionClient.createPeerConnectionFactory( | 359 peerConnectionClient.createPeerConnectionFactory( |
| 363 getApplicationContext(), peerConnectionParameters, CallActivity.this); | 360 getApplicationContext(), peerConnectionParameters, CallActivity.this); |
| 364 | 361 |
| 365 if (screencaptureEnabled) { | 362 if (screencaptureEnabled) { |
| 366 startScreenCapture(); | 363 startScreenCapture(); |
| 367 } else { | 364 } else { |
| 368 startCall(); | 365 startCall(); |
| 369 } | 366 } |
| 370 } | 367 } |
| 371 | 368 |
| 369 @TargetApi(17) |
| 370 private DisplayMetrics getDisplayMetrics() { |
| 371 DisplayMetrics displayMetrics = new DisplayMetrics(); |
| 372 WindowManager windowManager = |
| 373 (WindowManager) getApplication().getSystemService(Context.WINDOW_SERVICE
); |
| 374 windowManager.getDefaultDisplay().getRealMetrics(displayMetrics); |
| 375 return displayMetrics; |
| 376 } |
| 377 |
| 372 @TargetApi(19) | 378 @TargetApi(19) |
| 373 private static int getSystemUiVisibility() { | 379 private static int getSystemUiVisibility() { |
| 374 int flags = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSC
REEN; | 380 int flags = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSC
REEN; |
| 375 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { | 381 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { |
| 376 flags |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; | 382 flags |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; |
| 377 } | 383 } |
| 378 return flags; | 384 return flags; |
| 379 } | 385 } |
| 380 | 386 |
| 381 @TargetApi(21) | 387 @TargetApi(21) |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 | 435 |
| 430 if (videoCapturer != null) { | 436 if (videoCapturer != null) { |
| 431 return videoCapturer; | 437 return videoCapturer; |
| 432 } | 438 } |
| 433 } | 439 } |
| 434 } | 440 } |
| 435 | 441 |
| 436 return null; | 442 return null; |
| 437 } | 443 } |
| 438 | 444 |
| 445 @TargetApi(21) |
| 446 private VideoCapturer createScreenCapturer() { |
| 447 if (mediaProjectionPermissionResultCode != Activity.RESULT_OK) { |
| 448 reportError("User didn't give permission to capture the screen."); |
| 449 return null; |
| 450 } |
| 451 return new ScreenCapturerAndroid( |
| 452 mediaProjectionPermissionResultData, new MediaProjection.Callback() { |
| 453 @Override |
| 454 public void onStop() { |
| 455 reportError("User revoked permission to capture the screen."); |
| 456 } |
| 457 }); |
| 458 } |
| 459 |
| 439 // Activity interfaces | 460 // Activity interfaces |
| 440 @Override | 461 @Override |
| 441 public void onStop() { | 462 public void onStop() { |
| 442 super.onStop(); | 463 super.onStop(); |
| 443 activityRunning = false; | 464 activityRunning = false; |
| 444 // Don't stop the video when using screencapture to allow user to show other
apps to the remote | 465 // Don't stop the video when using screencapture to allow user to show other
apps to the remote |
| 445 // end. | 466 // end. |
| 446 if (peerConnectionClient != null && !screencaptureEnabled) { | 467 if (peerConnectionClient != null && !screencaptureEnabled) { |
| 447 peerConnectionClient.stopVideoSource(); | 468 peerConnectionClient.stopVideoSource(); |
| 448 } | 469 } |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 680 VideoCapturer videoCapturer = null; | 701 VideoCapturer videoCapturer = null; |
| 681 String videoFileAsCamera = getIntent().getStringExtra(EXTRA_VIDEO_FILE_AS_CA
MERA); | 702 String videoFileAsCamera = getIntent().getStringExtra(EXTRA_VIDEO_FILE_AS_CA
MERA); |
| 682 if (videoFileAsCamera != null) { | 703 if (videoFileAsCamera != null) { |
| 683 try { | 704 try { |
| 684 videoCapturer = new FileVideoCapturer(videoFileAsCamera); | 705 videoCapturer = new FileVideoCapturer(videoFileAsCamera); |
| 685 } catch (IOException e) { | 706 } catch (IOException e) { |
| 686 reportError("Failed to open video file for emulated camera"); | 707 reportError("Failed to open video file for emulated camera"); |
| 687 return null; | 708 return null; |
| 688 } | 709 } |
| 689 } else if (screencaptureEnabled) { | 710 } else if (screencaptureEnabled) { |
| 690 if (mediaProjectionPermissionResultCode != Activity.RESULT_OK) { | 711 return createScreenCapturer(); |
| 691 reportError("User didn't give permission to capture the screen."); | |
| 692 return null; | |
| 693 } | |
| 694 return new ScreenCapturerAndroid( | |
| 695 mediaProjectionPermissionResultData, new MediaProjection.Callback() { | |
| 696 @Override | |
| 697 public void onStop() { | |
| 698 reportError("User revoked permission to capture the screen."); | |
| 699 } | |
| 700 }); | |
| 701 } else if (useCamera2()) { | 712 } else if (useCamera2()) { |
| 702 if (!captureToTexture()) { | 713 if (!captureToTexture()) { |
| 703 reportError(getString(R.string.camera2_texture_only_error)); | 714 reportError(getString(R.string.camera2_texture_only_error)); |
| 704 return null; | 715 return null; |
| 705 } | 716 } |
| 706 | 717 |
| 707 Logging.d(TAG, "Creating capturer using camera2 API."); | 718 Logging.d(TAG, "Creating capturer using camera2 API."); |
| 708 videoCapturer = createCameraCapturer(new Camera2Enumerator(this)); | 719 videoCapturer = createCameraCapturer(new Camera2Enumerator(this)); |
| 709 } else { | 720 } else { |
| 710 Logging.d(TAG, "Creating capturer using camera1 API."); | 721 Logging.d(TAG, "Creating capturer using camera1 API."); |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 918 } | 929 } |
| 919 } | 930 } |
| 920 }); | 931 }); |
| 921 } | 932 } |
| 922 | 933 |
| 923 @Override | 934 @Override |
| 924 public void onPeerConnectionError(final String description) { | 935 public void onPeerConnectionError(final String description) { |
| 925 reportError(description); | 936 reportError(description); |
| 926 } | 937 } |
| 927 } | 938 } |
| OLD | NEW |