Romain Vimont
8c3e2bae7b
Simplify Application instantiation
...
The constructor is public.
2023-11-03 19:05:28 +01:00
Romain Vimont
c3c7bf7af3
Bump version to v2.2
2023-11-01 18:36:33 +01:00
Romain Vimont
ff579990c2
Shutdown connection before joining threads
...
Interrupting async processors may require to shutdown the connection to
wake up blocking calls.
Therefore, shutdown the connection first, then join the threads, then
close the connection.
Refs commit 9c08eb79cb
2023-11-01 18:36:10 +01:00
Romain Vimont
b8c5853aa6
Disable default stdout/stderr
...
Some devices (mostly Xiaomi) print internal errors using
e.printStackTrace(), flooding the console with irrelevant errors.
Disable system streams used via System.out and System.err streams, to
print only the logs from scrcpy.
Refs #994 <https://github.com/Genymobile/scrcpy/issues/994 >
Refs #4213 <https://github.com/Genymobile/scrcpy/pull/4213 >
2023-11-01 18:36:04 +01:00
Romain Vimont
5580803406
Always print device model and version
...
Print the log before checking for --list-* options so that it is
printed in all cases.
2023-10-31 19:19:33 +01:00
Andrew Gunnerson
6af4bd601f
Add support for high frame rate camera capture
...
Add --camera-high-speed to enable high frame rate camera capture. If
the option is enabled, then --camera-fps is mandatory.
PR #4213 <https://github.com/Genymobile/scrcpy/pull/4213 >
Co-authored-by: Romain Vimont <rom@rom1v.com >
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com >
Signed-off-by: Romain Vimont <rom@rom1v.com >
2023-10-31 15:57:06 +01:00
Andrew Gunnerson
4722bff423
Add --camera-fps
...
Add a new option for specifying the camera frame rate.
By default, Android's default frame rate (30 fps) is used.
PR #4213 <https://github.com/Genymobile/scrcpy/pull/4213 >
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com >
Signed-off-by: Romain Vimont <rom@rom1v.com >
2023-10-31 15:57:06 +01:00
Simon Chan
9fc5835485
Fail-fast camera mirroring on Android 11 and older
...
PR #4213 <https://github.com/Genymobile/scrcpy/pull/4213 >
Co-authored-by: Romain Vimont <rom@rom1v.com >
Signed-off-by: Romain Vimont <rom@rom1v.com >
2023-10-31 15:57:06 +01:00
Romain Vimont
dd36d6135f
Support camera size selection using -m/--camera-ar
...
In addition to --camera-size to specify an explicit size, make it
possible to select the camera size automatically, respecting the maximum
size (already used for display mirroring) and an aspect ratio.
For example, "scrcpy --video-source=camera" followed by:
- (no additional arguments)
: mirrors at the maximum size, any a-r
- -m1920
: only consider valid sizes having both dimensions not above 1920
- --camera-ar=4:3
: only consider valid sizes having an aspect ratio of 4:3 (+/- 10%)
- -m2048 --camera-ar=1.6
: only consider valid sizes having both dimensions not above 2048
and an aspect ratio of 1.6 (+/- 10%)
PR #4213 <https://github.com/Genymobile/scrcpy/pull/4213 >
Co-authored-by: Simon Chan <1330321+yume-chan@users.noreply.github.com >
2023-10-31 15:57:06 +01:00
Simon Chan
faebb7d70a
Add --camera-facing
...
Add an option to select the camera by its lens facing (front, back or
external).
PR #4213 <https://github.com/Genymobile/scrcpy/pull/4213 >
Co-authored-by: Romain Vimont <rom@rom1v.com >
Signed-off-by: Romain Vimont <rom@rom1v.com >
2023-10-31 15:57:06 +01:00
Romain Vimont
7f8d079c8c
Make camera id optional
...
If no camera id is provided, use the first camera available.
PR #4213 <https://github.com/Genymobile/scrcpy/pull/4213 >
2023-10-31 15:57:06 +01:00
Romain Vimont
64930e71b9
Handle camera disconnection
...
Stop mirroring on camera disconnection.
PR #4213 <https://github.com/Genymobile/scrcpy/pull/4213 >
2023-10-31 15:57:06 +01:00
Simon Chan
bfeecc0131
Add camera mirroring
...
Add --video-source=camera, and related options:
- --camera-id=<id>: select the camera by its id (see --list-cameras);
- --camera-size=<width>x<height>: select the capture size.
Fixed #241 <https://github.com/Genymobile/scrcpy/issues/241 >
PR #4213 <https://github.com/Genymobile/scrcpy/pull/4213 >
Co-authored-by: Romain Vimont <rom@rom1v.com >
Signed-off-by: Romain Vimont <rom@rom1v.com >
2023-10-31 15:57:06 +01:00
Romain Vimont
f032262cd7
Add --list-camera-sizes
...
Add an option to list the device camera declared sizes.
PR #4213 <https://github.com/Genymobile/scrcpy/pull/4213 >
2023-10-31 15:57:06 +01:00
Simon Chan
cd63896d63
Add --list-cameras
...
Add an option to list the device cameras.
PR #4213 <https://github.com/Genymobile/scrcpy/pull/4213 >
Co-authored-by: Romain Vimont <rom@rom1v.com >
Signed-off-by: Romain Vimont <rom@rom1v.com >
2023-10-31 15:56:25 +01:00
Romain Vimont
f085765e04
Factorize --list- options handling
...
This will limit code duplication as more list options will be added.
PR #4213 <https://github.com/Genymobile/scrcpy/pull/4213 >
2023-10-31 12:45:40 +01:00
Simon Chan
a2fb1b40f6
Extract SurfaceCapture from ScreenEncoder
...
Extract an interface SurfaceCapture from ScreenEncoder, representing a
video source which can be rendered to a Surface for encoding.
Split ScreenEncoder into:
- ScreenCapture, implementing SurfaceCapture to capture the device
screen,
- SurfaceEncoder, to encode any SurfaceCapture.
This separation prepares the introduction of another SurfaceCapture
implementation to capture the camera instead of the device screen.
PR #4213 <https://github.com/Genymobile/scrcpy/pull/4213 >
Co-authored-by: Romain Vimont <rom@rom1v.com >
Signed-off-by: Romain Vimont <rom@rom1v.com >
2023-10-31 12:45:40 +01:00
Romain Vimont
41ccb5883e
Force server exit at the end of main()
...
By default, the Java process exits when all non-daemon threads are
terminated.
The Android SDK might start some non-daemon threads internally,
preventing the scrcpy server to exit in some cases.
So force the process to exit explicitly.
PR #4213 <https://github.com/Genymobile/scrcpy/pull/4213 >
2023-10-31 12:45:40 +01:00
Romain Vimont
23e116064d
Rename --display to --display-id
...
The option is named "display id" everywhere.
This will be consistent with --camera-id (there will be many camera
options, so an option --camera would be confusing).
PR #4213 <https://github.com/Genymobile/scrcpy/pull/4213 >
2023-10-31 12:45:40 +01:00
Romain Vimont
7a2b756f1e
Fix incorrect comment about AV1 constant
...
MediaFormat.MIMETYPE_VIDEO_AV1 has been added in API 29, not 21.
2023-10-31 12:35:04 +01:00
Romain Vimont
b7ad652a75
Move empty string test for crop option parsing
...
For consistency with other options.
2023-10-26 22:42:46 +02:00
Romain Vimont
a7c3c9a54c
Make fillBaseContext() method private
...
This is consistent with fillAppInfo() and fillAppContext(), which are
also private.
2023-08-22 20:10:06 +02:00
Romain Vimont
111d02fca4
Add missing 'final' in Java classes
...
For consistency.
2023-08-22 18:52:29 +02:00
Romain Vimont
d391fc3b69
Bump version to 2.1.1
2023-07-14 18:58:58 +02:00
Romain Vimont
7e936fa879
Fix meizu deadlock
...
Some devices (Meizu) assume that the video encoding thread has a
Looper. By moving video encoding to a separate thread, commit
feab87053a
broke this assumption.
Call Looper.prepare() from this thread to fix the problem.
Fixes #4143 <https://github.com/Genymobile/scrcpy/issues/4143 >
2023-07-13 21:46:50 +02:00
Romain Vimont
01d785d9a3
Increase attempts to start AudioRecord
...
Making the shell app foreground (specific for Android 11) may take more
than 300ms on some devices, so increase the number of attempts from 3 to
5 (separated by 100ms).
Fixes #4147 <https://github.com/Genymobile/scrcpy/issues/4147 >
Refs #3796 <https://github.com/Genymobile/scrcpy/issues/3796 >
Refs 02f4ff7534
2023-07-07 18:21:17 +02:00
Romain Vimont
808bd14e30
Ignore fold change events for other display ids
...
Scrcpy mirrors a specific display id, it must ignore events for other
display ids.
Fixes #4120 <https://github.com/Genymobile/scrcpy/issues/4120 >
2023-06-27 18:43:22 +02:00
Romain Vimont
0049b3ce07
Remove superfluous log
...
This line was committed by error in commit
a52053421a
.
2023-06-23 08:23:29 +02:00
Romain Vimont
2dab1f7024
Bump version to 2.1
2023-06-22 01:15:44 +02:00
Romain Vimont
b9315620e2
Fix adb forward initialization
...
In forward mode, the dummy byte must be written immediately after the
first accept(), otherwise the client will wait indefinitely, causing a
deadlock (or a timeout).
Regression introduced by 8c650e53cd
.
2023-06-22 01:13:53 +02:00
Romain Vimont
0ffcfa0f5c
Accept failure in rotation or fold registration
...
Do not make scrcpy fail if rotation or display fold listeners could not
be registered.
2023-06-22 00:52:54 +02:00
Romain Vimont
c0f3c080b6
Register DisplayFoldListener only for Android 10+
...
This listener does not exist on Android < 10, and it makes scrcpy fail.
2023-06-22 00:49:11 +02:00
Romain Vimont
5061b7e02c
Fix build without gradle
...
Add missing class generation from IDisplayFoldListener.aidl.
Refs 24999d0d32
2023-06-22 00:03:26 +02:00
Romain Vimont
fb21bbf763
Add workarounds for Honor devices
...
Audio did not work on Honor devices.
To make it work, a system context must be set as a base context of
FakeContext (so that a PackageManager is available), and a current
Application and ActivityThread must be set.
These workarounds must not be applied for all devices, because they
might cause other issues.
Fixes #4015 <https://github.com/Genymobile/scrcpy/issues/4015 >
Refs #3085 <https://github.com/Genymobile/scrcpy/issues/3805 >
Co-authored-by: Simon Chan <1330321+yume-chan@users.noreply.github.com >
2023-06-19 18:45:40 +02:00
Romain Vimont
0f1afff7a6
Move workarounds execution
...
Expose a single public static method in the Workarounds class to apply
all necessary workarounds.
2023-06-19 18:45:11 +02:00
Romain Vimont
48a00fb481
Log device BRAND
...
The BRAND value is not always the same as the MANUFACTURER value.
2023-06-17 00:25:01 +02:00
Romain Vimont
3b7e2ca9c8
Fix lint warning
...
Suppress lint "DiscouragedPrivateApi" in Workarounds.java.
2023-06-16 23:24:08 +02:00
wuderek
5bd7514871
Add InputManagerGlobal for Android 14 beta 3
...
Parts of the InputManager class have been moved to a new
InputManagerGlobal class in Android 14 preview.
Fixes #4074 <https://github.com/Genymobile/scrcpy/issues/4074 >
PR #4075 <https://github.com/Genymobile/scrcpy/pull/4075 >
Signed-off-by: Romain Vimont <rom@rom1v.com >
2023-06-13 15:19:24 +02:00
Romain Vimont
7536f95d1c
Rename raw_video_stream to raw_stream
...
This server-specific option impacts both the video and audio streams.
2023-06-10 12:09:43 +02:00
Romain Vimont
6832e8d629
Remove spurious empty line
2023-06-10 12:07:35 +02:00
Romain Vimont
28313631e5
Reformat Java code
...
Fix code style.
2023-06-09 22:28:01 +02:00
Romain Vimont
fdbc9397a7
Name Java threads
...
Give a user-friendly name to Java threads created by the server.
2023-06-09 22:27:35 +02:00
Romain Vimont
ff5ffc892f
Add option to select audio source
...
Pass --audio-source=mic to capture the microphone instead of the device
audio output.
2023-06-01 09:21:09 +02:00
Romain Vimont
360f2fea1e
Extract AudioCapture creation
...
This will allow to pass capture options without code duplication.
2023-06-01 09:21:09 +02:00
Adonis Najimi
24999d0d32
Reset video capture on folding event
...
Handle folding event the same way as rotation events.
Fixes #3960 <https://github.com/Genymobile/scrcpy/issues/3960 >
PR #3979 <https://github.com/Genymobile/scrcpy/pull/3979 >
Signed-off-by: Romain Vimont <rom@rom1v.com >
2023-06-01 09:20:00 +02:00
Romain Vimont
8e2c0d6407
Rename rotationChanged to resetCapture
...
The flag is used to reset the capture (restart the encoding) on rotation
change. It will also be used for other events (on folding change), so
rename it.
PR #3979 <https://github.com/Genymobile/scrcpy/pull/3979 >
2023-06-01 09:20:00 +02:00
Simon Chan
cab354102d
Create AudioRecord by reflection as a fallback
...
Some devices (Vivo phones) fail to create an AudioRecord from an
AudioRecord.Builder (which throws a NullPointerException).
In that case, create an AudioRecord instance directly by reflection.
The AOSP version of AudioRecord constructor code can be found at:
- Android 11 (R):
<https://cs.android.com/android/platform/superproject/+/android-11.0.0_r1:frameworks/base/media/java/android/media/AudioRecord.java;l=335;drc=64ed2ec38a511bbbd048985fe413268335e072f8 >
- Android 12 (S):
<https://cs.android.com/android/platform/superproject/+/android-12.0.0_r1:frameworks/base/media/java/android/media/AudioRecord.java;l=388;drc=2eebf929650e0d320a21f0d13677a27d7ab278e9 >
- Android 13 (T, functionally identical to Android 12):
<https://cs.android.com/android/platform/superproject/+/android-13.0.0_r1:frameworks/base/media/java/android/media/AudioRecord.java;l=382;drc=ed242da52f975a1dd18671afb346b18853d729f2 >
- Android 14 (U): Not released, but expected to change
PR #3862 <https://github.com/Genymobile/scrcpy/pull/3862 >
Fixes #3805 <https://github.com/Genymobile/scrcpy/issues/3805 >
Signed-off-by: Romain Vimont <rom@rom1v.com >
2023-05-26 18:56:43 +02:00
Romain Vimont
597d2ccc01
Rename FORMAT to ENCODING
...
The AudioFormat contains several properties. This specific value is
named "encoding".
2023-05-24 22:13:09 +02:00
Romain Vimont
38900d7730
Extract audio source to a static constant
...
For consistency with the other parameters.
2023-05-24 22:13:09 +02:00
Romain Vimont
8c650e53cd
Add --no-video
...
Similar to --no-audio, add --no-video to play audio only.
Fixes #3842 <https://github.com/Genymobile/scrcpy/issues/3842 >
PR #3978 <https://github.com/Genymobile/scrcpy/pull/3978 >
2023-05-08 17:11:34 +02:00