Romain Vimont
c9a4d2b38f
Use up-to-date values on display fold change
...
When a display is folded or unfolded, the maxSize may have been updated
since the option was passed, and deviceSize must be updated.
Refs #4469 <https://github.com/Genymobile/scrcpy/pull/4469 >
2023-12-04 08:50:12 +01:00
Romain Vimont
1beec99f82
Explicitly exit cleanup process
...
This avoids an internal crash reported in `adb logcat`.
Refs #4456 <https://github.com/Genymobile/scrcpy/pull/4456#issuecomment-1837427802 >
2023-12-04 08:45:35 +01:00
Romain Vimont
5ce8672ebc
Add clipboard workaround for IQOO device
...
Fixes #4492 <https://github.com/Genymobile/scrcpy/issues/4492 >
2023-12-04 08:43:31 +01:00
Romain Vimont
3001f8a2d5
Adapt AudioRecord workaround to Android 14
...
Android 14 added a new int parameter "halInputFlags" to an internal
method:
<https://github.com/aosp-mirror/platform_frameworks_base/commit/f6135d75db79b1d48fad3a3b3080d37be20a2313 >
Fixes #4492 <https://github.com/Genymobile/scrcpy/issues/4492 >
2023-12-03 18:01:11 +01:00
Romain Vimont
40f2560d98
Bump version to 2.3.1
2023-12-02 12:30:19 +01:00
Romain Vimont
140a49b8be
Add workaround for Samsung devices issues
...
On some Samsung devices, DisplayManagerGlobal.getDisplayInfoLocked()
calls ActivityThread.currentActivityThread().getConfiguration(), which
requires a non-null ConfigurationController.
Fixes <https://github.com/Genymobile/scrcpy/issues/4467 >
2023-11-27 09:29:06 +01:00
Romain Vimont
5f3fb843f5
Bump version to 2.3
...
The previous version bump to 2.2 was incorrect, it was updated by:
./bump_version v2.2
instead of:
./bump_version 2.2
Correctly bump to version 2.3.
Refs #4433 <https://github.com/Genymobile/scrcpy/issues/4433#issuecomment-1816830875 >
2023-11-25 21:40:27 +01:00
Romain Vimont and Simon Chan
5d4b8a7e6d
Fix turn screen off on Android 14
...
On Android 14, the methods to access the display have been moved to
DisplayControl, which is not in the core framework. Use a specific
ClassLoader to access this class and its native dependencies.
Fixes #3927 <https://github.com/Genymobile/scrcpy/issues/3927 >
Refs #3927 comment <https://github.com/Genymobile/scrcpy/issues/3927#issuecomment-1790031953 >
Refs #4446 comment <https://github.com/Genymobile/scrcpy/pull/4446#issuecomment-1824660915 >
PR #4456 <https://github.com/Genymobile/scrcpy/pull/4456 >
Co-authored-by: Simon Chan <1330321+yume-chan@users.noreply.github.com >
Signed-off-by: Romain Vimont <rom@rom1v.com >
2023-11-25 21:25:26 +01:00
Romain Vimont
c573bd2a33
Fix java code style
2023-11-23 23:50:00 +01:00
sam80180 and Romain Vimont
acb2988837
Do not hardcode server path on the device
...
The path can be retrieved from the classpath.
PR #4416 <https://github.com/Genymobile/scrcpy/pull/4416 >
Co-authored-by: Romain Vimont <rom@rom1v.com >
Signed-off-by: Romain Vimont <rom@rom1v.com >
2023-11-23 23:39:40 +01:00
Romain Vimont
45a073a333
Do not create Device instance for camera
...
The device instance manages the display and the injection of input
events. It is not necessary for camera capture.
2023-11-16 09:10:28 +01:00
Romain Vimont
7e3b935932
Recreate the display on rotation
...
On Android 14 (Pixel 8), a device rotation while the camera app was
running resulted in an incorrect capture.
Destroying and recreating the display fixes the issue.
2023-11-16 08:56:04 +01:00
Romain Vimont
abcb100597
Upgrade Android SDK to 34
2023-11-15 21:13:12 +01:00
Romain Vimont
e8801cc3c0
Upgrade AGP (8.1.3) and Gradle to 8.4
...
Android Gradle Plugin 8.1.3.
Gradle 8.4.
From now on, Java 17 is required.
2023-11-15 21:13:12 +01:00
Romain Vimont
86808e8114
Upgrade Android checkstyle to 10.12.5
...
Upgrade to the latest version.
2023-11-15 21:13:12 +01:00
Romain Vimont
4b4f045e19
Fix audio PTS by the duration of 1 sample
...
If the difference of PTS between two consecutive blocks of audio is less
than 1 sample, then it will be considered as non-increasing by FFmpeg
muxers having a time_base of 1/sample_rate.
Increase the PTS by 1 sample instead.
2023-11-15 12:02:57 +01:00
Romain Vimont
a402eac7f2
Compute PTS of intermediate blocks
...
If several reads are performed for a single captured audio block (e.g.
if the read size is smaller than the captured block), then the provided
timestamp was the same for all packets.
Recompute the timestamp for each of them.
2023-11-15 12:02:57 +01:00
Romain Vimont
3bb6b0cb9f
Read audio by blocks of 1024 samples
...
In practice, the system captures audio samples by blocks of 1024
samples.
Remplace the hardcoded value of 5 milliseconds (240 samples), and let
AudioRecord fill the input buffer provided by MediaCodec (or by
AudioRawRecorder), with a maximum size of 1024 samples (just in case).
2023-11-15 12:02:57 +01:00
megapro17 and Romain Vimont
4857c5dd59
Add support for FLAC audio codec
...
PR #4410 <#https://github.com/Genymobile/scrcpy/pull/4410 >
Co-authored-by: Romain Vimont <rom@rom1v.com >
Signed-off-by: Romain Vimont <rom@rom1v.com >
2023-11-15 12:02:57 +01:00
Romain Vimont
783719c72e
Fix OPUS packet in an endian-independent way
...
Reading the header id as an int assumed that the current endianness was
little endian. Read to a byte array to remove this assumption.
2023-11-15 12:02:57 +01:00
Romain Vimont
80defdd8aa
Suppress private APIs lints to Workarounds class
...
The whole class need them (including the static block).
2023-11-15 12:01:10 +01:00
Romain Vimont
4eb33054cd
Do not log EPIPE on close for raw audio
...
Handle EPIPE the same way in AudioRawRecorder as in AudioEncoder.
This prevents useless errors on close.
2023-11-11 11:24:47 +01:00
Romain Vimont
420d3a40dd
Fix error handling in raw audio recorder
...
It is incorret to ever call:
streamer.writeDisableStream(...);
after:
streamer.writeAudioHeader();
Move the try-catch block so that it can never happen.
2023-11-11 11:24:47 +01:00
Romain Vimont
9d5f53caa7
Stop capture on any RAW audio error
...
The server was stopped only if an IOException occurred during RAW audio
capture, but it did not catch RuntimeExceptions.
2023-11-11 11:24:47 +01:00
Romain Vimont
11d738321f
Recover on invalid camera FPS ranges
...
Some devices may provide invalid ranges, causing an
IllegalArgumentException "lower must be less than or equal to upper".
Catch the exception to list the cameras anyway.
Refs #4403 <https://github.com/Genymobile/scrcpy/issues/4403 >
2023-11-05 21:45:15 +01:00
Romain Vimont
ccaa832f48
Simplify --list-cameras output
...
Remove --video-source=camera from the output of --list-cameras (this is
implicit).
2023-11-05 21:44:33 +01:00
Romain Vimont
4e4ddc499f
Return the FakeContext as application context
...
This avoids getApplicationContext() to return null and cause
NullPointerException.
Fixes #4392 <https://github.com/Genymobile/scrcpy/issues/4392#issuecomment-1792806080 >
2023-11-03 19:07:15 +01:00
Romain Vimont
8d76b3e06d
Fill application context for camera
...
Using the camera fails on some devices without a proper application
context.
Fixes #4392 <https://github.com/Genymobile/scrcpy/issues/4392 >
2023-11-03 19:07:08 +01:00
Romain Vimont
85a0b935c9
Always assign a system context as base context
...
FakeContext used ActivityThread.getSystemContext() as base context only
in some cases, because it caused problems on some devices:
- warnings on Xiaomi devices [1], which are now fixed by
b8c5853aa6
- issues related to Looper [2], which are solved by just calling
Looper.prepare*()
Therefore, we can now always assign a base context, which simplifies and
helps to solve camera issues on some devices (#4392 ).
[1] <https://github.com/Genymobile/scrcpy/issues/4015#issuecomment-1595382142 >
[2] <https://github.com/Genymobile/scrcpy/issues/3805#issuecomment-1596148031 >
Fixes #4392 <https://github.com/Genymobile/scrcpy/issues/4392 >
2023-11-03 19:05:50 +01:00
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 and Romain Vimont
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 and Romain Vimont
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 and Simon Chan
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 and Romain Vimont
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 and Romain Vimont
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 and Romain Vimont
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 and Romain Vimont
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