2750 Commits

Author SHA1 Message Date
Romain Vimont
7fc6943284 Preserve file permissions in GitHub Actions
The upload-artifact action does not preserve file permissions:
<https://github.com/actions/upload-artifact?#permission-loss>

Even if it is not critical for Windows releases, it will be for other
platforms. Wrap everything in a tarball to keep original permissions.

PR #5515 <https://github.com/Genymobile/scrcpy/pull/5515>
2024-11-24 15:41:13 +01:00
Romain Vimont
a57180047c Split packaging for each target on CI
Create separate jobs for packaging win32 and win64 releases.

PR #5515 <https://github.com/Genymobile/scrcpy/pull/5515>
2024-11-24 15:41:13 +01:00
Romain Vimont
5df218d8f9 Test scrcpy-server in a separate CI job
Use a separate GitHub Action job to build and test the server.

PR #5515 <https://github.com/Genymobile/scrcpy/pull/5515>
2024-11-24 15:41:13 +01:00
Romain Vimont
26bf209617 Replace release.mk by release scripts
Since commit 2687d202809dfaafe8f40f613aec131ad9501433, the Makefile
named release.mk stopped handling dependencies between recipes, because
they have to be executed separately (from different Github Actions
jobs).

Using a Makefile no longer provides any real benefit. Replace it by
several individual release scripts for simplicity and readability.

Refs #5306 <https://github.com/Genymobile/scrcpy/pull/5306>
PR #5515 <https://github.com/Genymobile/scrcpy/pull/5515>
2024-11-24 15:40:34 +01:00
Enno Boland
dc82425769 Add debugging method for Android >= 11
Fixes #5346 <https://github.com/Genymobile/scrcpy/issues/5346>
PR #5466 <https://github.com/Genymobile/scrcpy/pull/5466>

Signed-off-by: Romain Vimont <rom@rom1v.com>
2024-11-24 12:24:32 +01:00
Romain Vimont
9f39a5f2d6 Determine debugger command at runtime
When server_debugger is enabled, retrieve the device SDK version to
execute the correct command.

PR #5466 <https://github.com/Genymobile/scrcpy/pull/5466>
2024-11-22 11:04:32 +01:00
Romain Vimont
24588cb637 Add missing aidl in build_without_gradle.sh
Refs 39d51ff2cc2f3e201ad433d48372b548e5dd11d3
Fixes #5512 <https://github.com/Genymobile/scrcpy/issues/5512>
2024-11-22 07:48:48 +01:00
Romain Vimont
0e50d1e7db Extract PLATFORM_TOOLS in build_without_gradle.sh
Refs #5512 <https://github.com/Genymobile/scrcpy/issues/5512>
2024-11-22 07:47:24 +01:00
Romain Vimont
264110fd70 Dissociate virtual display size and capture size
Allow capturing virtual displays at a lower resolution using
-m/--max-size.

In the original implementation in #5370, the virtual display size was
necessarily the same as the capture size. The --max-size value was only
allowed to determine the virtual display size when no explicit size was
provided.

Since the dpi was scaled down accordingly, it is often better to create
a virtual display at the target capture size directly. However, not
everything is rendered according to the virtual display DPI. For
example, a page in Firefox is rendered too big on small virtual
displays. Thus, it makes sense to be able create a virtual display at a
given size, and capture it at a lower resolution with --max-size. This
is now possible using OpenGL filters.

Therefore, change the behavior of --max-size for virtual displays:
 - --max-size does not impact --new-display without size argument
   anymore (the virtual display size is the main display size);
 - it is used to limit the capture size (whether an explicit size is
   provided or not).

This new behavior is consistent with main display capture.

Refs #5370 comment <https://github.com/Genymobile/scrcpy/pull/5370#issuecomment-2438944401>
Refs #5370 <https://github.com/Genymobile/scrcpy/pull/5370>
PR #5506 <https://github.com/Genymobile/scrcpy/pull/5506>
2024-11-21 18:36:23 +01:00
Romain Vimont
4608a19a13 Upgrade platform-tools (35.0.2) for Windows
Since 35.0.1, the filename has changed on the server from -windows.zip
to -win.zip

The links are referenced from this file:
<https://dl.google.com/android/repository/repository2-2.xml>

Refs <https://www.reddit.com/r/Android/comments/1fhbs7w/download_links_to_platformtoolsadb/>
2024-11-20 08:14:04 +01:00
Gutem
f1f2711626 Document missing --cask option for macOS
Installing android-platform-tools via brew install requires the option
--cask.

Refs #2004 <https://github.com/Genymobile/scrcpy/pull/2004>
Refs #2231 <https://github.com/Genymobile/scrcpy/pull/2231>
PR #5398 <https://github.com/Genymobile/scrcpy/pull/5398>
Signed-off-by: Romain Vimont <rom@rom1v.com>
2024-11-20 08:04:47 +01:00
Romain Vimont
eeb04292a4 Upgrade SDL (2.30.9) for Windows 2024-11-20 07:57:35 +01:00
backryun
2ec30bdf80 Upgrade FFmpeg (7.1) for Windows
PR #5332 <https://github.com/Genymobile/scrcpy/pull/5332>

Signed-off-by: Romain Vimont <rom@rom1v.com>
2024-11-20 07:55:13 +01:00
Romain Vimont
145b823b1d Add --no-vd-system-decorations
Add an option to disable the following flag for virtual displays:

    DisplayManager.VIRTUAL_DISPLAY_FLAG_SHOULD_SHOW_SYSTEM_DECORATIONS

Some devices render a broken UI when this flag is enabled.

Fixes #5494 <https://github.com/Genymobile/scrcpy/issues/5494>
2024-11-20 07:50:45 +01:00
Romain Vimont
28d64ef319 Fix --new-display bash completion
The option --new-display accepts an optional argument, but bash must not
try to auto-complete it with unrelated content.
2024-11-20 07:49:58 +01:00
Romain Vimont
36d61f9ecd Reference virtual display documentation
Reference the documentation about virtual displays from the "Display"
section of video.md.
2024-11-19 21:31:04 +01:00
Romain Vimont
f95a5f97b1 Document filter order
Matrix multiplication is not commutative, so the order of filters
matters.

PR #5455 <https://github.com/Genymobile/scrcpy/pull/5455>
2024-11-19 21:31:04 +01:00
Romain Vimont
adb674a5c8 Add --angle
Add an option to rotate the video content by a custom angle.

Fixes #4135 <https://github.com/Genymobile/scrcpy/issues/4135>
Fixes #4345 <https://github.com/Genymobile/scrcpy/issues/4345>
Refs #4658 <https://github.com/Genymobile/scrcpy/pull/4658>
PR #5455 <https://github.com/Genymobile/scrcpy/pull/5455>
2024-11-19 21:31:04 +01:00
Romain Vimont
d19045628e Remove deprecated options
PR #5455 <https://github.com/Genymobile/scrcpy/pull/5455>
2024-11-19 21:31:04 +01:00
Romain Vimont
443f315f60 Use natural device orientation for --new-display
If no size is provided with --new-display, the main display size is
used. But the actual size depended on the current device orientation.

To make it deterministic, use the size of the natural device orientation
(portrait for phones, landscape for tablets).

PR #5455 <https://github.com/Genymobile/scrcpy/pull/5455>
2024-11-19 21:31:04 +01:00
Romain Vimont
0904880816 Log event size mismatch as verbose
On rotation, it is expected that many successive events are ignored due
to size mismatch, when an event was generated from the mirroring window
having the old size, but was received on the device with the new size
(especially since mouse hover events are forwarded).

Do not flood the console with warnings.

PR #5455 <https://github.com/Genymobile/scrcpy/pull/5455>
2024-11-19 21:31:04 +01:00
Romain Vimont
4348f12194 Improve mismatching event size warning
Include both the event size and the current size in the warning message.

PR #5455 <https://github.com/Genymobile/scrcpy/pull/5455>
2024-11-19 21:31:04 +01:00
Romain Vimont
371ff31225 Apply filters to virtual display capture
Apply crop and orientation to virtual display capture.

PR #5455 <https://github.com/Genymobile/scrcpy/pull/5455>
2024-11-19 21:31:04 +01:00
Romain Vimont
456fa510f2 Apply filters to camera capture
Apply crop and orientation to camera capture.

Fixes #4426 <https://github.com/Genymobile/scrcpy/issues/4426>
PR #5455 <https://github.com/Genymobile/scrcpy/pull/5455>
2024-11-19 21:31:04 +01:00
Romain Vimont
45382e3f01 Add --capture-orientation
Deprecate --lock-video-orientation in favor of a more general option
--capture-orientation, which supports all possible orientations
(0, 90, 180, 270, flip0, flip90, flip180, flip270), and a "locked" flag
via a '@' prefix.

All the old "locked video orientations" are supported:
 - --lock-video-orientation      ->  --capture-orientation=@
 - --lock-video-orientation=0    ->  --capture-orientation=@0
 - --lock-video-orientation=90   ->  --capture-orientation=@90
 - --lock-video-orientation=180  ->  --capture-orientation=@180
 - --lock-video-orientation=270  ->  --capture-orientation=@270

In addition, --capture-orientation can rotate/flip the display without
locking, so that it follows the physical device rotation.

For example:

    scrcpy --capture-orientation=flip90

always flips and rotates the capture by 90° clockwise.

The arguments are consistent with --display-orientation and
--record-orientation and --orientation (which provide separate
client-side orientation settings).

Refs #4011 <https://github.com/Genymobile/scrcpy/issues/4011>
PR #5455 <https://github.com/Genymobile/scrcpy/pull/5455>
2024-11-19 21:31:04 +01:00
Romain Vimont
9b03bfc3ae Handle virtual display rotation
Listen to display size changes and rotate the virtual display
accordingly.

Note: use `git show -b` to Show this commit ignoring whitespace changes.

Fixes #5428 <https://github.com/Genymobile/scrcpy/issues/5428>
Refs #5370 <https://github.com/Genymobile/scrcpy/pull/5370>
PR #5455 <https://github.com/Genymobile/scrcpy/pull/5455>
2024-11-19 21:31:04 +01:00
Anric
39d51ff2cc Use DisplayWindowListener for Android 14
On Android 14, DisplayListener may be broken (it never sends events).
This is fixed in recent Android 14 upgrades, but we can't really detect
it directly.

As a workaround, a RotationWatcher and DisplayFoldListener were
registered as a fallback, until a first "display changed" event was
triggered.

To simplify, on Android 14, register a DisplayWindowListener (introduced
in Android 11) to listen to configuration changes instead.

Refs #5455 comment <https://github.com/Genymobile/scrcpy/pull/5455#issuecomment-2481302084>
PR #5455 <https://github.com/Genymobile/scrcpy/pull/5455>

Co-authored-by: Romain Vimont <rom@rom1v.com>
Signed-off-by: Romain Vimont <rom@rom1v.com>
2024-11-19 21:31:04 +01:00
Romain Vimont
d72686c867 Extract display size monitor
Detecting display size changes is not straightforward:
 - from a DisplayListener, "display changed" events are received, but
   this does not imply that the size has changed (it must be checked);
 - on Android 14 (see e26bdb07a21493d096ea5c8cfd870fc5a3f015dc),
   "display changed" events are not received on some versions, so as a
   fallback, a RotationWatcher and a DisplayFoldListener are registered,
   but unregistered as soon as a "display changed" event is actually
   received, which means that the problem is fixed.

Extract a "display size monitor" to share the code between screen
capture and virtual display capture.

PR #5455 <https://github.com/Genymobile/scrcpy/pull/5455>
2024-11-19 21:31:04 +01:00
Romain Vimont
06385ce83b Reimplement lock orientation using transforms
Reimplement the --lock-video-orientation feature using affine
transforms.

Fixes #4011 <https://github.com/Genymobile/scrcpy/issues/4011>
PR #5455 <https://github.com/Genymobile/scrcpy/pull/5455>
2024-11-19 21:31:04 +01:00
Romain Vimont
9fb0a3dac1 Reimplement crop using transforms
Reimplement the --crop feature using affine transforms.

Fixes #4162 <https://github.com/Genymobile/scrcpy/issues/4162>
PR #5455 <https://github.com/Genymobile/scrcpy/pull/5455>
2024-11-19 21:31:04 +01:00
Romain Vimont
23960ca11a Ignore signalEndOfStream() error
This may be called at any time to interrupt the current encoding,
including when MediaCodec is in an expected state.

PR #5455 <https://github.com/Genymobile/scrcpy/pull/5455>
2024-11-19 21:31:04 +01:00
Romain Vimont
904f86152e Move mediaCodec.stop() to finally block
This will allow stopping MediaCodec only after the cleanup of other
components which must be performed beforehand.

PR #5455 <https://github.com/Genymobile/scrcpy/pull/5455>
2024-11-19 21:31:04 +01:00
Romain Vimont
e226950cfa Make PositionMapper use affine transforms
This will allow applying transformations performed by video filters.

PR #5455 <https://github.com/Genymobile/scrcpy/pull/5455>
2024-11-19 21:31:04 +01:00
Romain Vimont
019ce5eea4 Temporarily ignore lock video orientation and crop
Get rid of old code implementing --lock-video-orientation and --crop
features on the device side.

They will be reimplemented differently.

Refs #4011 <https://github.com/Genymobile/scrcpy/issues/4011>
Refs #4162 <https://github.com/Genymobile/scrcpy/issues/4162>
PR #5455 <https://github.com/Genymobile/scrcpy/pull/5455>
2024-11-19 21:31:04 +01:00
Romain Vimont
d6033d28f5 Split computeVideoSize() into limit() and round8()
Expose two methods on Size directly:
 - limit() to downscale a size;
 - round8() to round both dimensions to multiples of 8.

This will allow removing ScreenInfo completely.

PR #5455 <https://github.com/Genymobile/scrcpy/pull/5455>
2024-11-19 21:31:04 +01:00
Romain Vimont
89518f49ad Revert "Disable broken options on Android 14"
This reverts commit d62fa8880e03e8823057a5d4d9659d5f19132806.

These options will be reimplemented differently.

Refs #4011 <https://github.com/Genymobile/scrcpy/issues/4011>
Refs #4162 <https://github.com/Genymobile/scrcpy/issues/4162>
PR #5455 <https://github.com/Genymobile/scrcpy/pull/5455>
2024-11-19 21:31:04 +01:00
Romain Vimont
2a04858a22 Add on-device OpenGL video filter architecture
Introduce several key components to perform OpenGL filters:
 - OpenGLRunner: a tool for running a filter to be rendered to a Surface
   from an OpenGL-dedicated thread
 - OpenGLFilter: a simple OpenGL filter API
 - AffineOpenGLFilter: a generic OpenGL implementation to apply any 2D
   affine transform
 - AffineMatrix: an affine transform matrix, with helpers to build
   matrices from semantic transformations (rotate, scale, translate…)

PR #5455 <https://github.com/Genymobile/scrcpy/pull/5455>
2024-11-19 21:31:04 +01:00
Matthias Stock
e411b74a16 Use explicit file protocol for AVIO
AVIO expects a `url` to locate a resource.

Use the file protocol to handle filenames containing colons.

Fixes #5487 <https://github.com/Genymobile/scrcpy/issues/5487>
PR #5499 <https://github.com/Genymobile/scrcpy/pull/5499>
Signed-off-by: Romain Vimont <rom@rom1v.com>
2024-11-18 18:48:26 +01:00
Romain Vimont
5694562a74 Remove duplicate log
The function prepareRetry() already logs a more detailed message:

    Retrying with -mXXXX...
2024-11-18 18:47:57 +01:00
Romain Vimont
bd9d93194b Pass Options instance directly
Many constructors take a lot of parameters copied from Options. For
simplicity, just pass the Options instance.
2024-11-15 20:16:04 +01:00
Romain Vimont
794595e3f0 Set displayId to NONE in Options on new display
If a new display is set, force options.getDisplayId() to return
Device.DISPLAY_ID_NONE, to avoid any confusion between a local displayId
and options.getDisplayId().
2024-11-15 20:16:04 +01:00
Romain Vimont
5e10c37f02 Define all DisplayManager flags locally
For consistency.
2024-11-15 20:16:04 +01:00
Romain Vimont
0e399b65bd Remove [] around app package names
This simplifies copy-pasting from the result of:

    scrcpy --list-apps
2024-11-15 20:16:04 +01:00
Romain Vimont
2337f524d1 Improve error message on unknown camera id
If the camera id is explicitly provided (via --camera-id), report a
user-friendly error if no camera with this id is found.
2024-11-15 20:16:04 +01:00
Romain Vimont
df74cceb6f Use camera prepare() step
For consistency with screen capture.

Refs b60e1747809cce58793a8c0d54b499df87a6a975
2024-11-15 20:16:04 +01:00
Simon Chan
91373d906b Add FakeContext.getContentResolver()
This avoids the following error on some devices:

    Given calling package android does not match caller's uid 2000

Refs #4639 comment <https://github.com/Genymobile/scrcpy/issues/4639#issuecomment-2466081589>
Fixes #4639 <https://github.com/Genymobile/scrcpy/issues/4639>
PR #5476 <https://github.com/Genymobile/scrcpy/pull/5476>

Signed-off-by: Romain Vimont <rom@rom1v.com>
2024-11-14 10:29:03 +01:00
Romain Vimont
04dd72b594 Add "how to run" link for Windows
Reference the documentation explaining how to run scrcpy on Windows
directly in the main README.
2024-11-13 12:56:35 +01:00
Romain Vimont
762816cac6 Remove quotes for --video-encoder in documentation
Refs ec602a0334357982d75b374f7ac753c5bef1216a
2024-11-13 12:54:25 +01:00
Simon Chan
c0e2e27cf9 Force javac to use UTF-8
The source files are encoded in UTF-8.

Refs <https://github.com/Genymobile/scrcpy/issues/4639#issuecomment-2467206100>

Signed-off-by: Romain Vimont <rom@rom1v.com>
2024-11-11 09:00:40 +01:00
Romain Vimont
eff5b4b219 Add --screen-off-timeout
Change the Android "screen off timeout" (the idle delay before the
screen automatically turns off) and restore the initial value on
exit.

PR #5447 <https://github.com/Genymobile/scrcpy/pull/5447>
2024-11-09 10:26:59 +01:00