Romain Vimont
280a9afda8
Fix command-line help typo
2023-02-18 18:11:34 +01:00
Romain Vimont
e91618586c
Prefix receiver by sc_
...
Like all other components in scrcpy.
2023-02-18 09:37:31 +01:00
Romain Vimont
680ddf64be
Fix demuxer error message
...
Now that there are several possible codecs, do not hardcode H.264 in the
error message.
Refs 3e517cd40e
2023-02-18 09:31:06 +01:00
Romain Vimont
439a1fd4ed
Rename 'uid' to 'scid'
...
A random identifier is generated to differentiate multiple running
scrcpy instances. Rename it from 'uid' to 'scid' (scrcpy id) not to
confuse it with Linux UID.
Fixes #3729 <https://github.com/Genymobile/scrcpy/issues/3729 >
Refs 4315be1648
2023-02-11 09:58:40 +01:00
Romain Vimont
49eb326ce9
Extract packet merging
...
Config packets must be prepended to the next media packet. Extract the
logic to a new sc_packet_merger helper to simplify the demuxer code.
2023-02-11 09:44:33 +01:00
Romain Vimont
f03f32267e
Remove unused parser
...
Since 1c02b58412
, the parser is not used
anymore.
2023-02-10 23:18:11 +01:00
Romain Vimont
730eb1086a
Properly report demuxer errors
...
All demuxer errors were reported as "device disconnected", even if the
failure was not related to device socket read.
2023-02-10 18:55:43 +01:00
Romain Vimont
4f9e9c6619
Prefix UI events constants by SC_
2023-02-10 18:55:43 +01:00
Romain Vimont
953edfd1df
Split codec_id reading
...
Receive codec id and convert it to AVCodecID separately.
This will allow the caller to distinguish between EOS and unknown codec
id.
2023-02-10 18:55:43 +01:00
Romain Vimont
230b8274b9
Fix error return value
...
The function returns an enum AVCodecID, not a bool.
2023-02-10 18:55:43 +01:00
Romain Vimont
40866ddc10
Fix demuxer error message
...
The message applies to all packets, not only config packets.
2023-02-10 18:55:39 +01:00
Romain Vimont
bd56c0abf7
Remove unused codec context
...
The demuxer does not need any codec context.
2023-02-10 18:46:01 +01:00
Romain Vimont
d2dce51038
Add support for AV1
...
Add option --codec=av1.
PR #3713 <https://github.com/Genymobile/scrcpy/pull/3713 >
2023-02-06 11:00:49 +01:00
Romain Vimont
4342c5637d
Add support for H265
...
Add option --codec=h265.
PR #3713 <https://github.com/Genymobile/scrcpy/pull/3713 >
Fixes #3092 <https://github.com/Genymobile/scrcpy/issues/3092 >
2023-02-06 11:00:49 +01:00
Romain Vimont
3e517cd40e
Add option to select video codec
...
Introduce the selection mechanism. Alternative codecs will be added in
further commits.
PR #3713 <https://github.com/Genymobile/scrcpy/pull/3713 >
2023-02-06 10:58:45 +01:00
Romain Vimont
f70f6cdd3e
Simplify server info initialization
...
Use sc_read16be() to read 16-bit integer fields.
2023-02-03 12:31:28 +01:00
Romain Vimont
1c82c3923d
Compute relative PTS on the client-side
...
The PTS received from MediaCodec are expressed relative to an arbitrary
clock origin. We consider the PTS of the first frame to be 0, and the
PTS of every other frame is relative to this first PTS (note that the
PTS is only used for recording, it is ignored for mirroring).
For simplicity, this relative PTS was computed on the server-side.
To prepare support for multiple stream (video and audio), send the
packet with its original PTS, and handle the PTS offset on the
client-side (by the recorder).
Since we can't know in advance which stream will produce the first
packet with the lowest PTS (a packet received later on one stream may
have a PTS lower than a packet received earlier on another stream),
computing the PTS on the server-side would require unnecessary waiting.
2023-02-03 12:31:28 +01:00
Romain Vimont
6a07e3d470
Fix manpage formatting
...
Only the option arguments must be underlined.
2023-02-03 12:31:28 +01:00
Simon Chan
0afef0c634
Forward action button to device
...
On click event, only the whole buttons state was passed to the device.
In addition, on ACTION_DOWN and ACTION_UP, pass the button associated to
the action.
Refs #3635 <https://github.com/Genymobile/scrcpy/issues/3635 >
Co-authored-by: Romain Vimont <rom@rom1v.com>
Signed-off-by: Romain Vimont <rom@rom1v.com>
2023-01-30 20:57:54 +01:00
Romain Vimont
4315be1648
Use random name for device socket
...
For the initial connection between the device and the computer, an adb
tunnel is established (with "adb reverse" or "adb forward").
The device-side of the tunnel is a local socket having the hard-coded
name "scrcpy". This may cause issues when several scrcpy instances are
started in a few seconds for the same device, since they will try to
bind the same name.
To avoid conflicts, make the client generate a random UID, and append
this UID to the local socket name ("scrcpy_01234567").
2023-01-27 21:51:59 +01:00
Romain Vimont
74e3f8b253
Add random util
...
Add a user-friendly tool to generate random numbers.
2023-01-27 19:26:19 +01:00
Romain Vimont
059ec45f82
Add jrand48()/nrand48() compat functions
...
These functions are not available on all platforms.
2023-01-26 18:11:23 +01:00
Romain Vimont
bf8696d02e
Avoid unnecessary copy on config packets demuxing
...
Use av_packet_ref() to reference the packet without copy.
This also simplifies the logic, by making the "offset" variable and the
memcpy() call local to the if-block.
2023-01-02 16:18:23 +01:00
Romain Vimont
d8c2fe6ef2
Revert "Remove continuous resizing workaround for Windows"
...
This reverts commit 18082f6069
.
I can't reproduce, but it seems the workaround improves the behavior on
some Windows versions.
Fixes #3640 <https://github.com/Genymobile/scrcpy/issues/3640 >
Refs #3458 <https://github.com/Genymobile/scrcpy/issues/3458 >
2022-12-26 12:42:59 +01:00
Romain Vimont
fe21158c20
Bump version to 1.25
2022-12-22 12:33:29 +01:00
Romain Vimont
8e0c899218
Upgrade FFmpeg (5.1.2) for Windows 64-bit
...
Use the latest version of FFmpeg in Windows 64-bit releases.
2022-12-22 12:33:08 +01:00
Romain Vimont
725a922271
Upgrade SDL (2.26.1) for Windows
...
Include the latest version of SDL in Windows releases.
2022-12-22 12:29:08 +01:00
Romain Vimont
b5773a6fe8
Upgrade platform-tools (33.0.3) for Windows
...
Include the latest version of adb in Windows releases.
2022-12-22 12:29:08 +01:00
Pawel Jasinski
c7b1d0ea9a
Force mouse source when --forward-all-clicks
...
Right click and middle click require the source device to be a mouse,
not a touchscreen. Therefore, the source device was changed only when a
button other than the primary button was pressed (see
adc547fa6e
).
However, this led to inconsistencies between the ACTION_DOWN when a
secondary button is pressed (with a mouse as source device) and the
matching ACTION_UP when the secondary button is released (with a
touchscreen as source device, because then there is no button pressed).
To avoid the problem in all cases, force a mouse as source device when
--forward-all-clicks is set.
Concretely, for mouse events in --forward-all-clicks mode:
- device source is set to InputDevice.SOURCE_MOUSE;
- motion event toolType is set to MotionEvent.TOOL_TYPE_MOUSE;
Otherwise (when --forward-all-clicks is unset, or for real touch
events), finger events are injected:
- device source is set to InputDevice.SOURCE_TOUCHSCREEN;
- motion event toolType is set to MotionEvent.TOOL_TYPE_FINGER.
Fixes #3568 <https://github.com/Genymobile/scrcpy/issues/3568 >
PR #3579 <https://github.com/Genymobile/scrcpy/pull/3579 >
Co-authored-by: Romain Vimont <rom@rom1v.com>
Signed-off-by: Romain Vimont <rom@rom1v.com>
2022-12-22 11:26:26 +01:00
Romain Vimont
18082f6069
Remove continuous resizing workaround for Windows
...
It turns out that the workaround only worked for MacOS.
Refs #3458 <https://github.com/Genymobile/scrcpy/issues/3458 >
Refs SDL/#1059 <https://github.com/libsdl-org/SDL/issues/1059 >
2022-12-21 22:06:43 +01:00
Romain Vimont
bd1deffa70
Use current adb port (if any) for --tcpip
...
If the current adb port is not 5555 (typically 0 because it is not in
TCP/IP mode), --tcpip automatically executes (among other commands):
adb tcpip 5555
In case adb was already listening on another port, this command forced
to listen on 5555, and the connection should still succeed.
But this reconfiguration might be inconvenient for the user. If adb is
already in TCP/IP mode, use the current enabled port without
reconfiguration.
Fixes #3591 <https://github.com/Genymobile/scrcpy/issues/3591 >
2022-12-02 19:09:53 +01:00
Yu-Chen Lin
48bb6f2ea8
Support wchar_t in argv for Windows
...
PR #3547 <https://github.com/Genymobile/scrcpy/pull/3547 >
Fixes #2932 <https://github.com/Genymobile/scrcpy/issues/2932 >
Signed-off-by: Yu-Chen Lin <npes87184@gmail.com>
Signed-off-by: Romain Vimont <rom@rom1v.com>
2022-10-23 23:45:00 +02:00
Romain Vimont
b62424a98a
Build log.c for test_cli
...
On Windows, sc_log_windows_error() is called from net.c, so log.c must
also be compiled.
Fixes #3542 <https://github.com/Genymobile/scrcpy/issues/3542 >
2022-10-19 15:17:43 +02:00
Romain Vimont
ffc7b91693
Add missing include <string.h> for strlen()
2022-10-19 15:14:56 +02:00
Romain Vimont
cb46e4a64a
Add missing include <string.h> for memmove()
2022-10-19 15:13:55 +02:00
Anima C13
16e2c1ce26
Add -s auto-completion for zsh
...
Fixes #3522 <https://github.com/Genymobile/scrcpy/pull/3522 >
PR #3523 <https://github.com/Genymobile/scrcpy/pull/3523 >
Signed-off-by: Romain Vimont <rom@rom1v.com>
2022-10-12 13:24:43 +02:00
Anima C13
1bfbadef96
Add -s auto-completion for bash
...
Fixes #3522 <https://github.com/Genymobile/scrcpy/pull/3522 >
PR #3523 <https://github.com/Genymobile/scrcpy/pull/3523 >
Signed-off-by: Romain Vimont <rom@rom1v.com>
2022-10-12 13:24:43 +02:00
Romain Vimont
7505f7117e
Fix typo in logs
2022-09-27 14:12:37 +02:00
Romain Vimont
00e9e69c2a
Use /dev/null instead of closing fds
...
Some adb commands do not like when stdin, stdout or stderr are closed
(they hang forever). Open /dev/null for each.
2022-09-25 15:42:33 +02:00
Romain Vimont
e5e210506f
Add scrcpy-console.desktop
...
Add a launcher which opens a terminal, and keep it open in case of
errors (so that the user has time to read error messages).
The behavior is the same as scrcpy-console.bat on Windows.
PR #3351 <https://github.com/Genymobile/scrcpy/pull/3351 >
2022-09-09 19:06:29 +02:00
Chih-Hsuan Yen
a2a22f497f
Use shell environment to execute launcher
...
Make Exec= compatible with $PATH configured in .bashrc or .zshrc…
PR #3351 <https://github.com/Genymobile/scrcpy/pull/3351 >
Refs #296 <https://github.com/Genymobile/scrcpy/pull/296#discussion_r224987002 >
Signed-off-by: Romain Vimont <rom@rom1v.com>
2022-09-09 19:06:29 +02:00
Addison Snelling
51a1762cbd
Add desktop entry file for Linux app launchers
...
Refs <https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html >
PR #3351 <https://github.com/Genymobile/scrcpy/pull/3351 >
Replaces PR #296 <https://github.com/Genymobile/scrcpy/pull/296 >
Fixes #295 <https://github.com/Genymobile/scrcpy/issues/295 >
Fixes #748 <https://github.com/Genymobile/scrcpy/issues/748 >
Fixes #1636 <https://github.com/Genymobile/scrcpy/issues/1636 >
Co-authored-by: Chih-Hsuan Yen <yan12125@gmail.com>
Signed-off-by: Romain Vimont <rom@rom1v.com>
2022-09-09 19:06:29 +02:00
Romain Vimont
c1ec1d1023
Replace hardcoded 'share/' by datadir variable
...
Meson defines a variable for the data directory.
PR #3351 <https://github.com/Genymobile/scrcpy/pull/3351 >
2022-09-09 19:06:29 +02:00
Simon Chan
57056d078d
Use precise scrolling values
...
Since SDL 2.0.18, the amount scrolled horizontally or vertically is
exposed as a float (between 0 and 1). Forward a precise value to the
Android device when possible.
Refs <https://wiki.libsdl.org/SDL_MouseWheelEvent >
Fixes #3363 <https://github.com/Genymobile/scrcpy/issues/3363 >
PR #3369 <https://github.com/Genymobile/scrcpy/pull/3369 >
Signed-off-by: Romain Vimont <rom@rom1v.com>
2022-08-28 15:23:08 +02:00
Romain Vimont
1f138aef41
Add conversion from float to fixed-point i16
...
To encode float values between -1 and 1.
PR #3369 <https://github.com/Genymobile/scrcpy/pull/3369 >
2022-08-28 15:23:08 +02:00
Romain Vimont
1ab6c19486
Add unit test for float encoding
...
PR #3369 <https://github.com/Genymobile/scrcpy/pull/3369 >
2022-08-28 15:23:08 +02:00
Romain Vimont
fd3483c837
Extract conversion from float to u16 fixed-point
...
PR #3369 <https://github.com/Genymobile/scrcpy/pull/3369 >
2022-08-28 15:23:08 +02:00
Romain Vimont
041cdf6cf5
Rename buffer_util.h to binary.h
...
It will allow to expose more binary util functions not related to
buffers.
PR #3369 <https://github.com/Genymobile/scrcpy/pull/3369 >
2022-08-28 15:23:08 +02:00
Romain Vimont
d19606eb0c
Rename net_listen() parameter
...
For consistency with net_accept(), which necessarily uses a server
socket, name the net_listen() parameter "server_socket".
2022-08-17 16:40:45 +02:00
Romain Vimont
d23b3e88a4
Replace '%g' by '%f' as printf format
...
For some reason, '%g' does not work correctly with MinGW.
Refs #3369 <https://github.com/Genymobile/scrcpy/pull/3369 >
PR #3399 <https://github.com/Genymobile/scrcpy/pull/3399 >
2022-08-03 23:25:09 +02:00
Romain Vimont
a47848f304
Detect Windows using _WIN32 in network util
...
For consistency, always use _WIN32 instead of a mix of __WINDOWS__ and
_WIN32.
2022-07-27 14:54:27 +02:00
Romain Vimont
db8c1ce8e1
Fix protocol documentation in comments
...
Flags were in the correct order in the schema, but their description
were reversed.
2022-07-20 11:41:04 +02:00
Romain Vimont
4aeb78ece2
Add missing allocation failure check
2022-07-19 12:17:02 +02:00
Romain Vimont
396e4bd925
Add missing LOG_OOM() on malloc failure
2022-07-19 12:15:06 +02:00
Romain Vimont
af4b7855e1
Remove unused stream.h
...
The file was not removed by 7dec225ceb
.
2022-06-09 15:02:42 +02:00
Romain Vimont
b1d8c72780
Rename function to simplify
...
For consistency with sc_adb_parse_device(), do not include "from_output"
in the function name.
2022-06-09 15:02:42 +02:00
Romain Vimont
55e65fa270
Add missing return 0 in tests
2022-06-09 15:02:42 +02:00
Romain Vimont
69fb5f6ee1
Fix function declarations
...
Add missing void in function parameters list.
2022-06-09 15:02:42 +02:00
Romain Vimont
ef13d394fd
Bump version to 1.24
2022-04-28 20:46:28 +02:00
Romain Vimont
2f038c834a
Revert "Make OTG window resizable"
...
On Windows and macOS, resizing blocks the event loop. Handling it
properly would require the same workaround as done in screen.c.
This reverts commit 436b368f9d
.
2022-04-28 20:45:46 +02:00
Romain Vimont
76b3fcf986
Fix inverted check
...
SDL_RenderSetLogicalSize() returns 0 on success.
Refs fc8942aa03
2022-04-28 20:45:46 +02:00
Romain Vimont
f9e3275d4e
Upgrade FFmpeg (5.0.1) for Windows 64-bit
...
Use the latest version of FFmpeg in Windows 64-bit releases.
2022-04-28 19:32:14 +02:00
Romain Vimont
91706ae3d0
Upgrade SDL (2.0.22) for Windows
...
Include the latest version of SDL in Windows releases.
2022-04-28 19:23:59 +02:00
Romain Vimont
854a56e588
Enable linear filtering in OTG mode
...
This improves the icon quality with non-standard window size.
PR #3219 <https://github.com/Genymobile/scrcpy/pull/3219 >
2022-04-28 19:18:16 +02:00
Romain Vimont
436b368f9d
Make OTG window resizable
...
PR #3219 <https://github.com/Genymobile/scrcpy/pull/3219 >
2022-04-28 19:18:12 +02:00
Romain Vimont
fc8942aa03
Apply requested window size in OTG mode
...
Fixes #3099 <https://github.com/Genymobile/scrcpy/issues/3099 >
PR #3219 <https://github.com/Genymobile/scrcpy/pull/3219 >
2022-04-28 19:18:09 +02:00
Romain Vimont
c6d9711109
Create OTG window with HIGHDPI flag
...
This will avoid poor quality with HiDPI displays.
PR #3219 <https://github.com/Genymobile/scrcpy/pull/3219 >
2022-04-28 19:17:49 +02:00
Romain Vimont
0fca2ad830
Add option to not power on on start
...
By default, on start, the device is powered on. To prevent this
behavior, add a new option --no-power-on.
Fixes #3148 <https://github.com/Genymobile/scrcpy/issues/3148 >
PR #3210 <https://github.com/Genymobile/scrcpy/pull/3210 >
2022-04-28 19:12:52 +02:00
Romain Vimont
326897a0d4
Add missing mouse shortcuts in --help
...
Document 4th-click and 5th-click shortcuts.
Fixes #3122 <https://github.com/Genymobile/scrcpy/issues/3122 >
2022-04-25 18:35:06 +02:00
Romain Vimont
4db97531e8
Upgrade libusb (1.0.26) for Windows
...
Upgrade and enable libusb support for Windows 32-bit builds.
Refs #3011 <https://github.com/Genymobile/scrcpy/pull/3011 >
Fixes #3204 <https://github.com/Genymobile/scrcpy/issues/3204 >
PR #3206 <https://github.com/Genymobile/scrcpy/pull/3206 >
2022-04-22 13:34:58 +02:00
Romain Vimont
b8d78743f7
Upgrade platform-tools (33.0.1) for Windows
...
PR #3206 <https://github.com/Genymobile/scrcpy/pull/3206 >
2022-04-22 13:34:11 +02:00
Romain Vimont
fa5b2a29e9
Add missing SC_ prefix to header guards
2022-04-12 23:59:01 +02:00
Romain Vimont
0c94887075
Add missing include
...
Refs c3d45c8397
2022-04-12 23:51:05 +02:00
Romain Vimont
aaf3869a54
Fix OpenGL ES prefix skip
2022-03-30 12:01:01 +02:00
Romain Vimont
c3d45c8397
Consider emulators as TCP/IP devices
...
Emulators were wrongly considered as USB devices, so they were selected
using -d instead of -e (which was inconsistent with the adb behavior).
Refs #3005 <https://github.com/Genymobile/scrcpy/issues/3005 >
Refs #3137 <https://github.com/Genymobile/scrcpy/issues/3137 >
2022-03-22 21:08:08 +01:00
Romain Vimont
e56f2ac7a9
Log an error on unexpected device state
...
Refs #3129 <https://github.com/Genymobile/scrcpy/issues/3129 >
2022-03-20 14:56:52 +01:00
Romain Vimont
4ce7af42c6
Use $ANDROID_SERIAL if no selector is specified
...
Like adb, read the ANDROID_SERIAL environment variable to select a
device by serial if no explicit selection (-s, -d, -e or --tcpip=<addr>)
is provided via the command line.
Fixes #3111 <https://github.com/Genymobile/scrcpy/issues/3111 >
PR #3113 <https://github.com/Genymobile/scrcpy/pull/3113 >
2022-03-15 08:32:34 +01:00
Romain Vimont
b1dbc30072
Document exit status in --help
...
Refs #3085 <https://github.com/Genymobile/scrcpy/pull/3085 >
2022-03-10 09:13:21 +01:00
martin f. krafft
b3f5dfe1de
Add specific exit code for device disconnection
...
Modify the return logic such that exit code 1 is used when the initial
connection fails, but if a session is established, and then the device
disconnects, exit code 2 is emitted.
Fixes #3083 <https://github.com/Genymobile/scrcpy/issues/3083 >
PR #3085 <https://github.com/Genymobile/scrcpy/pull/3085 >
Signed-off-by: martin f. krafft <madduck@madduck.net>
Signed-off-by: Romain Vimont <rom@rom1v.com>
2022-03-06 22:19:46 +01:00
Romain Vimont
1f4c801f3c
Report server connection state
...
We must distinguish 3 cases for await_for_server():
- an error occurred
- no error occurred, the device is connected
- no error occurred, the device is not connected (user requested to
quit)
For this purpose, use an additional output parameter to indicate if the
device is connected (only set when no error occurs).
Refs #3085 <https://github.com/Genymobile/scrcpy/pull/3085 >
2022-03-06 22:16:13 +01:00
Romain Vimont
8d91cda4f6
Improve HID event push error message
...
On HID event push failure, add the event type in the error message.
2022-02-24 23:28:20 +01:00
Romain Vimont
59656fe649
Fix typo in error message
2022-02-24 23:26:12 +01:00
Romain Vimont
e4bb2b8728
Add libusb error log
...
Log libusb_get_string_descriptor_ascii() errors.
Refs #3050 <https://github.com/Genymobile/scrcpy/issues/3050 >
2022-02-24 23:25:02 +01:00
Romain Vimont
7deccef1c2
Bump version to 1.23
2022-02-22 21:01:55 +01:00
Romain Vimont
71ef5cc0a9
Add missing include for vector
...
Include stdlib.h for realloc().
2022-02-22 21:00:43 +01:00
Romain Vimont
3ce6f8ca91
Add Bash completion script
...
Fixes #2930 <https://github.com/Genymobile/scrcpy/issues/2930 >
Refs #3012 <https://github.com/Genymobile/scrcpy/pull/3012 >
2022-02-22 19:22:12 +01:00
hltdev8642
26953784d9
Add ZSH completion script
...
PR #3012 <https://github.com/Genymobile/scrcpy/pull/3012 >
Signed-off-by: Romain Vimont <rom@rom1v.com>
2022-02-22 19:15:27 +01:00
Romain Vimont
79ed83ab68
Reorder --tcpip option in cli
...
To keep options in alphabetic order.
2022-02-22 18:10:30 +01:00
Romain Vimont
e2e76c5d48
Increase adb devices -l
max output size
...
For simplicity, the parsing of `adb devices -l` output is performed in a
single pass on the whole output.
This output was limited to 4096 bytes. Since there are about 100 chars
per device line, this limited the number of connected devices to ~40.
Increase to 65536 bytes to avoid a limitation in practice.
PR #3035 <https://github.com/Genymobile/scrcpy/pull/3035 >
2022-02-21 00:03:45 +01:00
Romain Vimont
4b8cb042c4
Use vector for listing ADB devices
...
This avoids the hardcoded maximum number of ADB devices detected (16).
Refs #3029 <https://github.com/Genymobile/scrcpy/pull/3029 >
PR #3035 <https://github.com/Genymobile/scrcpy/pull/3035 >
Co-authored-by: Daniel Ansorregui <d.ansorregui@samsung.com>
2022-02-20 23:59:35 +01:00
Romain Vimont
1790e88278
Use vector for listing USB devices
...
This avoids the hardcoded maximum number of USB devices detected (16).
Refs #3029 <https://github.com/Genymobile/scrcpy/pull/3029 >
PR #3035 <https://github.com/Genymobile/scrcpy/pull/3035 >
2022-02-20 23:59:35 +01:00
Romain Vimont
c070723bc8
Add sc_vector
...
Adapt vlc_vector [1], that I initially wrote while implementing the VLC
playlist [2].
Change the implementation to use "statement expressions" [3], which are
forbidden in VLC because "non-standard", but:
- they are supported by gcc and clang;
- they are already used in the scrcpy codebase;
- they avoid implementation hacks (VLC_VECTOR_FAILFLAG_);
- they allow a better API (sc_vector_index_of() may return the result
without an output parameter).
PR #3035 <https://github.com/Genymobile/scrcpy/pull/3035 >
[1]: 0857947aba/include/vlc_vector.h
[2]: https://blog.rom1v.com/2019/05/a-new-core-playlist-for-vlc-4
[3]: https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html
2022-02-20 23:59:35 +01:00
Romain Vimont
36c75e15b8
Move data/ to app/
...
The files in data/ are specific to the client app (not the server).
This also avoids to reference the parent directory (../) from
app/meson.build.
Refs 8d583d36e2
2022-02-20 17:56:50 +01:00
Romain Vimont
73a5311ac6
Forbid HID input without OTG on Windows
...
On Windows, if the adb daemon is running, opening the USB device will
necessarily fail, so HID input is not possible.
Refs #2773 <https://github.com/Genymobile/scrcpy/issues/2773 >
PR #3011 <https://github.com/Genymobile/scrcpy/pull/3011 >
2022-02-20 17:39:42 +01:00
Romain Vimont
25296ae167
Kill adb daemon in OTG mode on Windows
...
On Windows, it is not possible to open a USB device from several
process, so HID events may only work if no adb daemon is running.
PR #3011 <https://github.com/Genymobile/scrcpy/pull/3011 >
2022-02-20 17:39:39 +01:00
Romain Vimont
3bb24b3926
Make intr optional for adb commands
...
All adb commands are executed with an "interruptor", so that they can be
interrupted on Ctrl+C.
Make this interruptor optional, so that we could call "adb kill-server"
in OTG mode. This command always returns almost immediately anyway.
Ideally, we should make all blocking calls interruptible (including
libusb calls, by using the asynchronous API), but it's a lot of work,
and in practice it works well enough.
PR #3011 <https://github.com/Genymobile/scrcpy/pull/3011 >
2022-02-20 17:39:36 +01:00
Romain Vimont
6ee75c0cff
Remove obsolete text in error message
...
The HID/OTG features are now available on all platforms.
PR #3011 <https://github.com/Genymobile/scrcpy/pull/3011 >
2022-02-20 17:39:30 +01:00
Romain Vimont
6b65cd405a
Build for Windows with libusb support
...
Fixes #2773 <https://github.com/Genymobile/scrcpy/issues/2773 >
PR #3011 <https://github.com/Genymobile/scrcpy/pull/3011 >
2022-02-20 17:39:12 +01:00
Romain Vimont
ff3cb31cb4
Fix libusb callback for Windows
...
Add LIBUSB_CALL so that the callback has the correct signature on
Windows (including __attribute__((stdcall))).
PR #3011 <https://github.com/Genymobile/scrcpy/pull/3011 >
2022-02-20 17:39:09 +01:00
Romain Vimont
06243e7c3c
Avoid PRIx16 printf format on Windows
...
Convert uint16_t to unsigned to avoid using PRIx16, which may not exist
on Windows.
PR #3011 <https://github.com/Genymobile/scrcpy/pull/3011 >
2022-02-20 17:39:04 +01:00
Romain Vimont
b9b2879789
Remove USB hotplug callback error log
...
If it fails, the error is already logged by sc_usb_register_callback().
PR #3011 <https://github.com/Genymobile/scrcpy/pull/3011 >
2022-02-20 17:38:51 +01:00
Romain Vimont
be1936bb85
Report USB device disconnection when detected
...
USB device disconnection is detected via a hotplug callback when it is
supported.
In addition, report disconnection on libusb calls returning
LIBUSB_ERROR_NO_DEVICE or LIBUSB_ERROR_NOT_FOUND. This allows to detect
disconnection after a libusb call when hotplug is not available.
PR #3011 <https://github.com/Genymobile/scrcpy/pull/3011 >
2022-02-20 17:38:14 +01:00
Romain Vimont
3ee3f8dc02
Work around mouse capture SDL bug on macOS
...
On macOS, SDL relative mouse mode does not work correctly when the
cursor is outside the window.
As a workaround, move the cursor inside the window before setting the
relative mouse mode.
Refs SDL/#5340 <https://github.com/libsdl-org/SDL/issues/5340 >
PR #3031 <https://github.com/Genymobile/scrcpy/pull/3031 >
2022-02-20 17:28:02 +01:00
Romain Vimont
9db42341e4
Pass screen instance to mouse capture functions
...
Using the screen instance or not in these functions is an implementation
detail. Further changes will require the screen instance.
Refs 7848a387c8
PR #3031 <https://github.com/Genymobile/scrcpy/pull/3031 >
2022-02-20 17:27:53 +01:00
Romain Vimont
82a99f69ec
Remove "linux-only" mentions for HID/OTG features
...
HID/OTG features are not limited to Linux anymore.
PR #3031 <https://github.com/Genymobile/scrcpy/pull/3031 >
2022-02-20 17:27:43 +01:00
Romain Vimont
33202491e1
Build on macOS with libusb support
...
Fixes #2774 <https://github.com/Genymobile/scrcpy/issues/2774 >
PR #3031 <https://github.com/Genymobile/scrcpy/pull/3031 >
2022-02-20 17:27:22 +01:00
Romain Vimont
b4fd882ece
Fix typo
2022-02-20 17:21:25 +01:00
Romain Vimont
c4ab65eb79
Remove useless '\n' in log
2022-02-18 21:18:36 +01:00
Romain Vimont
6edf50d447
Remove fprintf() in tests
...
It was committed by mistake.
2022-02-18 19:34:54 +01:00
Romain Vimont
4b018be789
Add --print-fps to enable FPS counter on start
...
The FPS counter could be enabled/disabled via MOD+i.
Add a command line option to enable it on start. This is consistent with
other features like --turn-screen-off or --fullscreen.
Fixes #468 <https://github.com/Genymobile/scrcpy/issues/468 >
PR #3030 <https://github.com/Genymobile/scrcpy/pull/3030 >
2022-02-18 18:16:50 +01:00
Romain Vimont
fa93c8a91b
Move FPS counter start/stop logs
...
This will allow to print the same logs for every start/stop call.
PR #3030 <https://github.com/Genymobile/scrcpy/pull/3030 >
2022-02-18 18:16:12 +01:00
Romain Vimont
03705b828b
Use sc_prefix for fps counter
2022-02-17 19:55:24 +01:00
Romain Vimont
85edba20e7
Enforce deadline reached on timeout
...
The value of sc_tick_now() has microsecond precision, but
sc_cond_timedwait() has only millisecond precision.
To guarantee that sc_tick_now() >= deadline when sc_cond_timedwait()
returns due to timeout, round up to the next millisecond.
This avoids to call a non-blocking sc_cond_timedwait() in a loop for no
reason until a target deadline during up to 1 millisecond.
Refs 682a691173
2022-02-16 18:29:30 +01:00
Romain Vimont
2a872c3865
Fix fps_counter tick type
...
The type uint32_t is not sufficient to store the result of
sc_tick_now().
As a consequence, the FPS counter entered a live loop and caused a lock
starvation (deadlock in practice).
Refs ec871dd3f5
Refs 682a691173
2022-02-16 18:12:57 +01:00
Romain Vimont
ccbe370cc5
Add --no-cleanup option
...
It might be useful not to cleanup on exit, for example to leave the
screen turned off, or keep the server binary on the device (via the
server option "cleanup=false").
Fixes #1764 <https://github.com/Genymobile/scrcpy/issues/1764 >
PR #3020 <https://github.com/Genymobile/scrcpy/pull/3020 >
2022-02-15 19:25:57 +01:00
Romain Vimont
bb991f829c
Fix order of options
...
In alphabetic order, "no-clipboard-autosync" is before
"no-downsize-on-error".
2022-02-13 17:26:34 +01:00
Romain Vimont
ca9e1a0514
Add compilation flag for USB features
...
This allows to disable HID/OTG features on Linux to build without
libusb.
2022-02-12 14:15:07 +01:00
Romain Vimont
cc27771dd1
Add compilation flag for V4L2 feature
...
This allows to disable V4L2 support on Linux to build without
libavdevice.
2022-02-12 14:15:07 +01:00
Romain Vimont
d0ab8c0e7b
Fix double adb tunnel closing
...
On error, close the adb tunnel only if it has not already been closed
beforehand.
2022-02-12 14:15:02 +01:00
Romain Vimont
5c62f3419d
Rename buffer util functions with sc_ prefix
2022-02-12 09:12:46 +01:00
Romain Vimont
044acc2259
Rename HEADER_SIZE to SC_PACKET_HEADER_SIZE
...
Prefix the constant for consistency.
2022-02-11 21:34:58 +01:00
Romain Vimont
6fc388f369
Remove unused BUFSIZE
2022-02-11 21:34:12 +01:00
Romain Vimont
1c02b58412
Remove sc_demuxer_parse()
...
Now that the key frame flag is known, parsing the packet is useless.
2022-02-11 21:33:09 +01:00
Romain Vimont
67068e4e3d
Pass key frame flag from the device
...
MediaCodec indicates when a packet is a key frame. Transmit it to the
client.
2022-02-11 21:32:55 +01:00
Romain Vimont
e3c2398aa2
Store packet flags in PTS most significant bits
...
A special PTS value was used to encode a config packet.
To prepare for adding more flags, use the most significant bits of the
PTS field to store flags.
2022-02-11 21:32:11 +01:00
Romain Vimont
29c163959c
Indent ifdef for clarity
...
Make it explicit that the ifdef is an inner block.
2022-02-10 09:24:19 +01:00
Romain Vimont
4a95c08d56
Improve error message for unsupported usb hotplug
2022-02-10 08:54:43 +01:00
Romain Vimont
7848a387c8
Do not duplicate relative mouse mode state
...
The relative mouse mode is tracked by SDL, and accessible via
SDL_GetRelativeMouseMode().
This is more robust in case SDL changes the relative mouse mode on its
own.
2022-02-10 08:50:18 +01:00
Romain Vimont
43ae418752
Fix USB device leak on connection error
...
If sc_usb_connect() failed, then the sc_usb_device was never destroyed.
The assignment was mistakenly removed by commit
61969aeb80
.
2022-02-10 08:47:39 +01:00
Romain Vimont
8d583d36e2
Move prebuilt-deps/ to app/
...
The prebuilt dependencies are specific to the client app (not the
server).
This also avoids to reference the parent directory (../) from
app/meson.build.
2022-02-09 23:18:34 +01:00
Romain Vimont
f86df817f9
Print libusb version on --version
2022-02-09 10:15:19 +01:00
Romain Vimont
9a546ef1af
Print both compiled and linked versions of libs
...
On --version, print both the version scrcpy had been compiled against,
and the version linked at runtime.
2022-02-09 10:15:19 +01:00
Romain Vimont
9477594f80
Move version handling to a separate file
...
This will avoid to include all dependencies headers from main.c.
2022-02-09 10:15:07 +01:00
Romain Vimont
29828aa330
Log device opening errors during listing
...
Without this log, the user would have no way to know that a USB device
is rejected because it could not be opened (typically due to
insufficient permissions).
2022-02-09 10:04:09 +01:00
Romain Vimont
582161607e
Add option to select USB or TCP/IP devices
...
If several devices are connected (as listed by `adb devices`), it was
necessary to provide the explicit serial via -s/--serial.
If only one device is connected via USB (respectively, via TCP/IP), it
might be convenient to select it automatically. For this purpose, two
new options are introduced:
- -d/--select-usb: select the single device connected over USB
- -e/--select-tcpip: select the single device connected over TCP/IP
PR #3005 <https://github.com/Genymobile/scrcpy/pull/3005 >
2022-02-09 10:00:25 +01:00
Romain Vimont
146f65d7b2
Introduce adb device selector
...
Currently, a device is selected either from a specific serial, or if it
is the only one connected.
In order to support selecting the only device connected via USB or via
TCP/IP separately, introduce a new selection structure.
PR #3005 <https://github.com/Genymobile/scrcpy/pull/3005 >
2022-02-09 10:00:25 +01:00
Romain Vimont
5ed13ef477
Execute adb start-server
...
This does nothing if the adb daemon is already started, but allows to
print any output/errors to the console.
Otherwise, the daemon starting would occur during `adb devices`, which
does not output to the console because the result is parsed.
PR #3005 <https://github.com/Genymobile/scrcpy/pull/3005 >
2022-02-09 10:00:14 +01:00
Romain Vimont
9c545e8c29
Remove sc_adb_get_serialno()
...
The device serial is now retrieved from `adb devices -l`, `adb
get-serialno` is not called anymore.
PR #3005 <https://github.com/Genymobile/scrcpy/pull/3005 >
2022-02-09 09:56:26 +01:00
Romain Vimont
0a619dc9ef
Allow selecting a device from IP without port
...
Since the previous commit, if a serial is given via -s/--serial (either
a real USB serial or an IP:port), a device is selected if its serial
matches exactly.
In addition, if the user pass an IP without a port, then select any
device with this IP, regardless of the port (so that "192.168.1.1"
matches any "192.168.1.1:port"). This is also the default behavior of
adb.
PR #3005 <https://github.com/Genymobile/scrcpy/pull/3005 >
2022-02-09 09:56:26 +01:00
Romain Vimont
4692d13179
Expose simple API to select a single adb device
...
Select an adb device from the output of `adb device -l`.
PR #3005 <https://github.com/Genymobile/scrcpy/pull/3005 >
2022-02-09 09:56:26 +01:00
Romain Vimont
02d46b2262
Expose function to test if a serial is TCP/IP
...
In practice, it just tests if the serial contains a ':', which is
sufficient to distinguish ip:port from a real USB serial.
PR #3005 <https://github.com/Genymobile/scrcpy/pull/3005 >
2022-02-09 09:56:25 +01:00
Romain Vimont
4389de1c23
Add adb devices parser
...
Add a parser of `adb device -l` output, to extract a list of devices
with their serial, state and model.
PR #3005 <https://github.com/Genymobile/scrcpy/pull/3005 >
2022-02-09 09:56:25 +01:00
Romain Vimont
85ff70fc95
Refactor device configuration
...
Depending on the parameters passed to scrcpy, either the initial device
serial is necessary or not. Reorganize to simplify the logic.
PR #3005 <https://github.com/Genymobile/scrcpy/pull/3005 >
2022-02-09 09:55:25 +01:00
Romain Vimont
700503df6c
List and select USB devices separately
...
List all USB devices in a first step, then select the matching one(s).
This allows to report a user-friendly log message containing the list of
devices, with the matching one(s) highlighted.
PR #3005 <https://github.com/Genymobile/scrcpy/pull/3005 >
2022-02-09 09:55:25 +01:00
Romain Vimont
61969aeb80
Expose simple API to select a single USB device
...
The caller just wants a single device. Handle all cases and error
messages internally.
PR #3005 <https://github.com/Genymobile/scrcpy/pull/3005 >
2022-02-09 09:55:25 +01:00
Romain Vimont
b88c4aa75e
Add move-function for sc_usb_device
...
Add a function to "move" a sc_usb_device into another instance.
This will avoid unnecessary copies.
PR #3005 <https://github.com/Genymobile/scrcpy/pull/3005 >
2022-02-09 09:55:23 +01:00
Romain Vimont
8c50342fb2
Move SC_PRIsizet to compat.h
...
Define the printf format macro for size_t in compat.h so that it can be
used from anywhere.
PR #3005 <https://github.com/Genymobile/scrcpy/pull/3005 >
2022-02-09 09:53:19 +01:00
Romain Vimont
0eadf95a3e
Rename function to destroy a list of USB devices
...
Rename from "usb_device_" to "usb_devices_".
PR #3005 <https://github.com/Genymobile/scrcpy/pull/3005 >
2022-02-09 09:53:19 +01:00
Romain Vimont
6df2205cf3
Add generic LOG() macro with level parameter
...
One log macro was provided for each log level (LOGV(), LOGD(), LOGI(),
LOGW(), LOGE()).
Add a generic macro LOG(LEVEL, ...) accepting a log level as parameter,
so that it is possible to write logging wrappers.
PR #3005 <https://github.com/Genymobile/scrcpy/pull/3005 >
2022-02-09 09:53:11 +01:00
Romain Vimont
61b6324ee9
Remove LOGC()
...
It is not clear when to use LOGC() rather than LOGE(). Always use
LOGE().
Moreover, enum sc_log_level has no "critical" log level.
2022-02-09 09:52:15 +01:00