Commit graph

2430 commits

Author SHA1 Message Date
Romain Vimont
77ebafd96c Retrieve icon decoder directly
The call to av_find_best_stream() gives the decoder directly, there is
no need to retrieve it afterwards in a separate step.
2024-06-11 08:58:19 +02:00
Romain Vimont
9ea4446369 Release the audio lock early
The final write from the writer thread does not require a lock: it is
guaranteed that enough space is available since the reader thread never
writes.
2024-06-09 19:25:32 +02:00
Romain Vimont
5d1d5bdc16 Fix thread leak on Windows
Fixes #4973 <https://github.com/Genymobile/scrcpy/issues/4973>
2024-06-09 18:27:30 +02:00
Romain Vimont
fd9498e07c Avoid zero-length copies
Return early if there is nothing to read/write.
2024-05-30 15:56:37 +02:00
Romain Vimont
09e8c20168 Rename streamScreen() to streamCapture()
The capture source may be either the screen or the camera.
2024-05-14 08:23:57 +02:00
Romain Vimont
da484b7ab9 Reject recording with control only
If video and audio are disabled, there is nothing to record.
2024-05-12 10:44:27 +02:00
Romain Vimont
063a8339ed Terminate on controller error
This is particularly important to react to server socket disconnection
since video and audio may be disabled.

PR #4868 <https://github.com/Genymobile/scrcpy/pull/4868>
2024-05-11 17:12:00 +02:00
Romain Vimont
b5c8de08e0 Update documentation for --no-window
PR #4868 <https://github.com/Genymobile/scrcpy/pull/4868>
2024-05-11 17:12:00 +02:00
Romain Vimont
45fe6b602b Add scrcpy window without video playback
Add the possibility to solely control the device without screen
mirroring:

    scrcpy --no-video --no-audio

This is different from OTG mode, which does not require USB debugging at
all. Here, the standard mode is used but with the possibility to disable
video playback.

By default, always open a window (even without video playback), and add
an option --no-window.

Fixes #4727 <https://github.com/Genymobile/scrcpy/issues/4727>
Fixes #4793 <https://github.com/Genymobile/scrcpy/issues/4793>
PR #4868 <https://github.com/Genymobile/scrcpy/pull/4868>
2024-05-11 17:06:16 +02:00
Romain Vimont
cca2c9ffb7 Disable FPS counter when no video playback
There is no frame rate to count.
2024-04-19 12:57:18 +02:00
Romain Vimont
22d78e8a82 Fix boolean condition
Use the short-circuit operator && between booleans.
2024-04-19 12:49:03 +02:00
Romain Vimont
bcb8503b26 Handle reported camera sizes array is null
The array of sizes may be null. Handle this case gracefully.

Fixes #4852 <https://github.com/Genymobile/scrcpy/issues/4852>
2024-04-17 10:45:18 +02:00
Romain Vimont
9aa6cc71be Forbid --no-control in OTG mode
The whole purpose of OTG is to only control the device.
2024-04-16 15:50:44 +02:00
Romain Vimont
54e08b4eae Fix code style
Limit to 80 columns.
2024-04-16 15:50:41 +02:00
Romain Vimont
bd8b945bb3 Register rotation watcher only when possible
Old Android versions may not be able to register a rotation watcher for
a secondary display. In that case, report the error instead of
registering a rotation watcher for the default display.

Refs <https://github.com/Genymobile/scrcpy/pull/4740#issuecomment-2051245633>

Suggested by: Kaiming Hu <huxxx1234@gmail.com>
2024-04-12 17:22:45 +02:00
Kaiming Hu
a73bf932d6 Fix could not rotate secondary display
The version of the methods with the display id parameter must be tried
first, otherwise they will never be used (since the old versions without
the display id are still present).

Regression introduced by ee6620d123.

Refs #4740 <https://github.com/Genymobile/scrcpy/pull/4740>
PR #4841 <https://github.com/Genymobile/scrcpy/pull/4841>

Signed-off-by: Romain Vimont <rom@rom1v.com>
2024-04-12 17:20:15 +02:00
Stepan Salenikovich
7011dd1ef0 Fix freeze and thaw rotation for Android 14
Changed since AOSP/framework_base commit
670fb7f5c0d23cf51ead25538bcb017e03ed73ac, included in tag
android-14.0.0_r29.

Refs <670fb7f5c0%5E%21/>
PR #4740 <https://github.com/Genymobile/scrcpy/pull/4740>

Signed-off-by: Romain Vimont <rom@rom1v.com>
2024-04-06 17:38:24 +02:00
Romain Vimont
ee6620d123 Refactor WindowManager methods
Select the available method to invoke the same way as in other wrappers
(using a version field).

Refs d894e270a7
Refs #4740 <https://github.com/Genymobile/scrcpy/pull/4740>
2024-04-06 17:38:21 +02:00
Romain Vimont
aa34d63171 Fix segfault on close with --no-video
Do not call sc_screen_hide_window() if screen is not initialized.

To reproduce:

    scrcpy --no-video --record=file.mp4

This only segfaults in debug mode since commit
fd0f432e87.
2024-04-04 08:52:32 +02:00
Simon Chan
bf625790fa Request limited color range by default
Most devices currently use limited color range, but some recent devices
encode in full color range, which is currently not supported by the SDL
opengl render driver.

Fixes #4756 <https://github.com/Genymobile/scrcpy/issues/4756>
Refs <https://github.com/Genymobile/scrcpy/issues/4756#issuecomment-2003710860>
Refs libusb/#9311 <https://github.com/libsdl-org/SDL/issues/9311>

Signed-off-by: Romain Vimont <rom@rom1v.com>
2024-03-30 15:28:57 +01:00
Romain Vimont
db55edb196 Fix YUV conversion for full color range
Take the color range (full vs limited) into account to render the
picture.

Note that with the current version of SDL, it has no impact with the SDL
opengl render driver.

Fixes #4756 <https://github.com/Genymobile/scrcpy/issues/4756>
Refs <https://github.com/Genymobile/scrcpy/issues/4756#issuecomment-2003228916>
Refs libusb/#9311 <https://github.com/libsdl-org/SDL/issues/9311>

Suggested-by: Simon Chan <1330321+yume-chan@users.noreply.github.com>
2024-03-30 15:28:09 +01:00
Romain Vimont
1c3801a0b1 Add a shortcut to pause/unpause display
Pause/unpause display on MOD+z and MOD+Shift+z.

It only impacts rendering, the device is still captured, the video
stream continues to be transmitted to the device and recorded (if
recording is enabled).

Fixes #1632 <https://github.com/Genymobile/scrcpy/issues/1632>
PR #4748 <https://github.com/Genymobile/scrcpy/pull/4748>
2024-03-30 14:20:51 +01:00
Romain Vimont
be3d357a6d Use source repo tarball for libusb
Legitimate or not, we should not use sources that do not match the
repository.

Refs <https://github.com/libusb/libusb/issues/1468#issuecomment-1974787595>
Refs <https://news.ycombinator.com/item?id=39866309>
Refs #4713 <https://github.com/Genymobile/scrcpy/pull/4713>
2024-03-30 14:18:47 +01:00
Romain Vimont
79968a0ae6 Reorder documentation
Present the --tcpip option without arguments first.
2024-03-11 18:05:27 +01:00
Romain Vimont
7f23ff3f2c Add videos for pinch-to-zoom and tilt
A video is worth a thousand words.
2024-03-03 00:06:54 +01:00
Romain Vimont
cc7719079a Italicize coordinates letters in documentation 2024-03-03 00:05:26 +01:00
Romain Vimont
0c94b75eef Update links to 2.4 2024-03-03 00:00:24 +01:00
Romain Vimont
af57309074 Bump version to 2.4 2024-03-02 23:22:09 +01:00
Romain Vimont
a720c946a6 Merge branch 'master' into release 2024-03-02 23:21:32 +01:00
Romain Vimont
8d87b91f69 Build dependencies from sources
The project has 3 build dependencies:
 - SDL
 - FFmpeg
 - libusb

For Windows, the release script downloaded pre-built build dependencies
(either from upstream, or from the scrcpy-deps repository).

Instead, download the source releases and build locally. This offers
more flexibility.

The official adb release is still downloaded and included as is in the
release archive (it is not a build dependency).

Also upgrade FFmpeg to 6.1.1 and libusb to 1.0.27.

PR #4713 <https://github.com/Genymobile/scrcpy/pull/4713>
2024-03-02 22:52:54 +01:00
inson1
125b1103e1 Happy new year 2024!
PR #4716 <https://github.com/Genymobile/scrcpy/pull/4716>

Signed-off-by: Romain Vimont <rom@rom1v.com>
2024-03-02 16:48:21 +01:00
Romain Vimont
36189b90ea Remove spurious line 2024-03-01 09:57:10 +01:00
Romain Vimont
4dca08cfe3 Set SDL hints before creating any thread
To avoid race conditions in SDL (reported by TSAN).
2024-03-01 09:57:10 +01:00
Romain Vimont
fd0f432e87 Detect missing initializations
Write invalid data in memory to easily detect missing initializations in
debug mode.
2024-03-01 00:52:35 +01:00
Romain Vimont
cdf09805c0 Add missing initialization 2024-03-01 00:52:34 +01:00
Romain Vimont
bf069bd37b Document usage examples
This exposes several common options on the front page.
2024-03-01 00:52:31 +01:00
Romain Vimont
b9d244b4c9 Document UHID
Rework the documentation to present the keyboard and mouse input modes.

PR #4473 <https://github.com/Genymobile/scrcpy/pull/4473>
2024-03-01 00:52:28 +01:00
Romain Vimont
dd479ed176 Check options specific to SDK keyboard
Fail if an option specific to --keyboard=sdk is passed with another
keyboard input mode.

PR #4473 <https://github.com/Genymobile/scrcpy/pull/4473>
2024-03-01 00:52:23 +01:00
Romain Vimont
5f12132c47 Do not fallback keyboard mode if AOA fails
Initially, if AOA initialization failed, default injection method was
used, in order to use the same command/shortcut when the device is
connected via USB or via TCP/IP, without changing the arguments.

Now that there are 3 keyboard modes, it seems unexpected to switch to
another specific mode if AOA fails (and it is inconsistent). If the user
explicitly requests AOA, then use AOA or fail.

Refs #2632 comment <https://github.com/Genymobile/scrcpy/pull/2632#issuecomment-945190859>
PR #4473 <https://github.com/Genymobile/scrcpy/pull/4473>
2024-03-01 00:52:19 +01:00
Romain Vimont
1c5ad0e813 Reassign -K and -M to UHID keyboard and mouse
The options were deprecated, but for convenience, reassign them to
aliases for --keyboard=uhid and --mouse=uhid respectively.

Their long version (--hid-keyboard and --hid-mouse) remain deprecated.

PR #4473 <https://github.com/Genymobile/scrcpy/pull/4473>
2024-03-01 00:52:16 +01:00
Romain Vimont
6a103c809f Add UHID mouse support
Use the following command:

    scrcpy --mouse=uhid

PR #4473 <https://github.com/Genymobile/scrcpy/pull/4473>
2024-03-01 00:52:13 +01:00
Romain Vimont
151a6225d4 Add shortcut to open keyboard settings
The keyboard settings can be opened by:

    adb shell am start -a android.settings.HARD_KEYBOARD_SETTINGS

Add a shortcut (MOD+k) for convenience if the current keyboard is HID.

PR #4473 <https://github.com/Genymobile/scrcpy/pull/4473>
2024-03-01 00:52:10 +01:00
Romain Vimont
54dede3630 Fix startActivity() for supporting API < 30
Call the older startActivityAsUser() instead of
startActivityAsUserWithFeature() so that it also works on older Android
versions.

Fixes #4704 <https://github.com/Genymobile/scrcpy/issues/4704>
PR #4473 <https://github.com/Genymobile/scrcpy/pull/4473>
2024-03-01 00:52:05 +01:00
Romain Vimont
f557188dc8 Create UhidManager only on first use
There is no need to create a UhidManager instance (with its thread) if
no UHID is used.

PR #4473 <https://github.com/Genymobile/scrcpy/pull/4473>
2024-03-01 00:52:03 +01:00
Simon Chan
87da68ee0d Handle UHID output
Use UHID output reports to synchronize CapsLock and VerrNum states.

PR #4473 <https://github.com/Genymobile/scrcpy/pull/4473>

Co-authored-by: Romain Vimont <rom@rom1v.com>
Signed-off-by: Romain Vimont <rom@rom1v.com>
2024-03-01 00:52:00 +01:00
Romain Vimont
021c5d371a Refactor DeviceMessageSender
Refactor DeviceMessage as a queue of message. This will allow to add
other message types.

PR #4473 <https://github.com/Genymobile/scrcpy/pull/4473>
2024-03-01 00:51:57 +01:00
Simon Chan
840680f546 Add UHID keyboard support
Use the following command:

    scrcpy --keyboard=uhid

PR #4473 <https://github.com/Genymobile/scrcpy/pull/4473>

Co-authored-by: Romain Vimont <rom@rom1v.com>
Signed-off-by: Romain Vimont <rom@rom1v.com>
2024-03-01 00:51:54 +01:00
Romain Vimont
4d5b67cc80 Log controller handling errors
On close, the controller is expected to throw an IOException because the
socket is closed, so the exception was ignored.

However, message handling actions may also throw IOException, and they
must not be silently ignored.

PR #4473 <https://github.com/Genymobile/scrcpy/pull/4473>
2024-03-01 00:51:52 +01:00
Romain Vimont
604e59ac7b Initialize controller before keyboards
The UHID keyboard initializer will need the controller.

PR #4473 <https://github.com/Genymobile/scrcpy/pull/4473>
2024-03-01 00:51:50 +01:00
Romain Vimont
4d2c2514fc Initialize controller in two steps
There is a dependency cycle in the initialization order:
 - keyboard depends on controller
 - controller depends on acksync
 - acksync depends on keyboard initialization

To break this cycle, bind the async instance to the controller in a
second step.

PR #4473 <https://github.com/Genymobile/scrcpy/pull/4473>
2024-03-01 00:51:47 +01:00