Romain Vimont
6231f683af
Fix compilation error for old decoding API
...
Commits cb9c42bdcb and
441d3fb119 updated the code only for the
new decoding API.
2021-04-05 22:35:14 +02:00
Romain Vimont
9826c5c4a4
Remove HiDPI compilation flag
...
Always enable HiDPI support, there is no reason to expose a compilation
flag.
2021-04-04 15:00:13 +02:00
Romain Vimont
0308ef43f2
Do not set buttons on touch events
...
BUTTON_PRIMARY must not be set for touch events:
> This button constant is not set in response to simple touches with a
> finger or stylus tip. The user must actually push a button.
<https://developer.android.com/reference/android/view/MotionEvent#BUTTON_PRIMARY >
Fixes #2169 <https://github.com/Genymobile/scrcpy/issues/2169 >
2021-03-15 18:46:56 +01:00
Romain Vimont
40febf4a91
Use device id 0 for touch/mouse events
...
Virtual device is only for keyboard sources, not mouse or touchscreen
sources. Here is the value of InputDevice.getDevice(-1).toString():
Input Device -1: Virtual
Descriptor: ...
Generation: 2
Location: built-in
Keyboard Type: alphabetic
Has Vibrator: false
Has mic: false
Sources: 0x301 ( keyboard dpad )
InputDevice.getDeviceId() documentation says:
> An id of zero indicates that the event didn't come from a physical
> device and maps to the default keymap.
<https://developer.android.com/reference/android/view/InputEvent#getDeviceId() >
However, injecting events with a device id of 0 causes event.getDevice()
to be null on the client-side.
Commit 26529d377f used -1 as a workaround
to avoid a NPE on a specific Android TV device. But this is a bug in the
device system, which wrongly assumes that input device may not be null.
A similar issue was present in Flutter, but it is now fixed:
- <https://github.com/flutter/flutter/issues/30665 >
- <https://github.com/flutter/engine/pull/7986 >
On the other hand, using an id of -1 for touchscreen events (which is
invalid) causes issues for some apps:
<https://github.com/Genymobile/scrcpy/issues/2125#issuecomment-790535792 >
Therefore, use a device id of 0.
An alternative could be to find an existing device matching the source,
like "adb shell input" does. See getInputDeviceId():
<https://android.googlesource.com/platform/frameworks/base.git/+/master/cmds/input/src/com/android/commands/input/Input.java >
But it seems better to indicate that the event didn't come from a
physical device, and it would not solve #962 anyway, because an Android
TV has no touchscreen.
Refs #962 <https://github.com/Genymobile/scrcpy/issues/962 >
Fixes #2125 <https://github.com/Genymobile/scrcpy/issues/2125 >
2021-03-14 18:30:56 +01:00
Romain Vimont
429fdef04f
Fix encoder parameter suggestion
...
The option is --encoder, not --encoder-name.
2021-03-11 10:55:12 +01:00
Romain Vimont
eb7e1070cf
Release frame data as soon as possible
...
During a frame swap, one of the two frames involved can be released.
2021-03-06 22:58:03 +01:00
Romain Vimont
386f017ba9
Factorize frame swap
2021-03-06 22:58:03 +01:00
Romain Vimont
cc48b24324
Simplify screen initialization
...
Use a single function to initialize the screen instance.
2021-03-06 22:58:03 +01:00
Romain Vimont
597c54f049
Group screen parameters into a struct
...
The function screen_init_rendering had too many parameters.
2021-03-06 22:58:03 +01:00
Romain Vimont
955da3b578
Remove screen static initializer
...
Most of the fields are initialized dynamically.
2021-03-06 22:58:03 +01:00
Romain Vimont
cb9c42bdcb
Use a callback to notify frame skip
...
A skipped frame is detected when the producer offers a frame while the
current pending frame has not been consumed.
However, the producer (in practice the decoder) is not interested in the
fact that a frame has been skipped, only the consumer (the renderer) is.
Therefore, notify frame skip via a consumer callback. This allows to
manage the skipped and rendered frames count at the same place, and
remove fps_counter from decoder.
2021-03-06 22:58:03 +01:00
Romain Vimont
fb9f9848bd
Use a callback to notify a new frame
...
Make the decoder independant of the SDL even mechanism, by making the
consumer register a callback on the video_buffer.
2021-03-06 22:58:03 +01:00
Romain Vimont
c50b958ee4
Initialize screen before starting the stream
...
As soon as the stream is started, the video buffer could notify a new
frame available.
In order to pass this event to the screen without race condition, the
screen must be initialized before the screen is started.
2021-03-06 22:58:03 +01:00
Romain Vimont
441d3fb119
Make video buffer more generic
...
Video buffer is a tool between a frame producer and a frame consumer.
For now, it is used between a decoder and a renderer, but in the future
another instance might be used to swscale decoded frames.
2021-03-06 22:58:03 +01:00
Romain Vimont
cb197ee3a2
Move fps counter out of video buffer
...
In order to make video buffer more generic, move out its specific
responsibility to count the fps between the decoder and the renderer.
2021-03-06 22:58:03 +01:00
Romain Vimont
218636dc10
Inject touch events with smallest detectable size
...
A value of 1 means the "largest detectable size", a value of 0 means the
"smallest detectable size".
https://developer.android.com/reference/android/view/MotionEvent.PointerCoords#size
https://developer.android.com/reference/android/view/MotionEvent#AXIS_SIZE
Fixes #2125 <https://github.com/Genymobile/scrcpy/issues/2125 >
2021-03-03 18:22:54 +01:00
Romain Vimont
b16b65a715
Simplify default values
...
It makes sense to extract default values for bitrate and port range
(which are arbitrary and might be changed in the future).
However, the default values for "max size" and "lock video orientation"
are naturally unlimited/unlocked, and will never be changed. Extracting
these options just added complexity for no benefit, so hardcode them.
2021-02-25 22:19:05 +01:00
Romain Vimont
a3aa5ac95e
Insert numerical values statically in usage string
2021-02-25 22:19:05 +01:00
Romain Vimont
0207e3df33
Remove unused no_window field
2021-02-25 22:19:05 +01:00
Romain Vimont
9cd1a7380d
Enable NDEBUG via Meson built-in option
2021-02-25 22:19:05 +01:00
Romain Vimont
24b637b972
Handle im-related events from input_manager.c
2021-02-25 22:19:05 +01:00
Romain Vimont
76a3d9805b
Inline window events handling
...
Now that all screen-related events are handled from screen.c, there is
no need for a separate method for window events.
2021-02-25 22:19:05 +01:00
Romain Vimont
50b4a730e3
Handle screen-related events from screen.c
2021-02-25 22:19:05 +01:00
Romain Vimont
ea2369f568
Reference video buffer from screen
...
This paves the way to handle EVENT_NEW_FRAME from screen.c, by allowing
to call screen_update_frame() without an explicit video_buffer instance.
2021-02-25 22:19:05 +01:00
Romain Vimont
0538e9645b
Improve error handling in screen initialization
...
After the struct screen is initialized, the window, the renderer and the
texture are necessarily valid, so there is no need to check in
screen_destroy().
2021-02-25 22:18:51 +01:00
Romain Vimont
626094ad13
Handle window events only once visible
...
This will avoid corner cases where we need to resize while no frame has
been received yet.
2021-02-17 09:54:03 +01:00
Romain Vimont
a566635c43
Log mipmaps error only if mipmaps are enabled
2021-02-17 09:54:03 +01:00
Romain Vimont
862948b132
Make use_opengl local
...
The flag is used only locally, there is no need to store it in the
screen structure.
2021-02-17 09:54:03 +01:00
Romain Vimont
c0c4ba7009
Add intermediate frame in video buffer
...
There were only two frames simultaneously:
- one used by the decoder;
- one used by the renderer.
When the decoder finished decoding a frame, it swapped it with the
rendering frame.
Adding a third frame provides several benefits:
- the decoder do not have to wait for the renderer to release the
mutex;
- it simplifies the video_buffer API;
- it makes the rendering frame valid until the next call to
video_buffer_take_rendering_frame(), which will be useful for
swscaling on window resize.
2021-02-17 09:54:03 +01:00
Romain Vimont
c53bd4d8b6
Assert non-recursive usage of mutexes
2021-02-17 09:54:03 +01:00
Romain Vimont
54f5c42d7b
Add mutex assertions
2021-02-17 09:54:03 +01:00
Romain Vimont
21d206f360
Expose mutex assertions
...
Add a function to assert that the mutex is held (or not).
2021-02-17 09:54:03 +01:00
Romain Vimont
d2689fc168
Expose thread id
2021-02-17 09:54:03 +01:00
Romain Vimont
f6320c7e31
Wrap SDL thread functions into scrcpy-specific API
...
The goal is to expose a consistent API for system tools, and paves the
way to make the "core" independant of SDL in the future.
2021-02-17 09:54:03 +01:00
Romain Vimont
30e619d37f
Replace SDL_strdup() by strdup()
...
The functions SDL_malloc(), SDL_free() and SDL_strdup() were used only
because strdup() was not available everywhere.
Now that it is available, use the native version of these functions.
2021-02-17 09:54:03 +01:00
Romain Vimont
c0dde0fade
Provide strdup() compat
...
Make strdup() available on all platforms.
2021-02-17 09:53:25 +01:00
Romain Vimont
ace438e52a
Remove unused port_range field
...
The port_range is used from "struct server_params", the copy in
"struct server" was unused.
2021-02-14 14:47:49 +01:00
Romain Vimont
8e83f3e8af
Remove unused custom event
2021-02-14 14:44:05 +01:00
Romain Vimont
97b001e7c0
Fix undefined left shift
...
Small unsigned integers promote to signed int. As a consequence, if v is
a uint8_t, then (v << 24) yields an int, so the left shift is undefined
if the MSB is 1.
Cast to uint32_t to yield an unsigned value.
Reported by USAN (meson x -Db_sanitize=undefined):
runtime error: left shift of 255 by 24 places cannot be represented
in type 'int'
2021-01-24 15:31:21 +01:00
Romain Vimont
d8e9ad20b0
Improve file handler error message
...
Terminating the file handler current process may be either a "push" or
"install" command.
2021-01-24 14:24:24 +01:00
Romain Vimont
b566700bfd
Kill process with SIGKILL signal
...
An "adb push" command is not terminated by SIGTERM.
2021-01-24 14:24:24 +01:00
Romain Vimont
7afd149f4b
Fix file_handler process race condition
...
The current process could be waited both by run_file_handler() and
file_handler_stop().
To avoid the race condition, wait the process without closing, then
close with mutex locked.
2021-01-24 14:24:24 +01:00
Romain Vimont
6a50231698
Expose a single process_wait()
...
There were two versions: process_wait() and process_wait_noclose().
Expose a single version with a flag (it was already implemented that way
internally).
2021-01-24 14:24:18 +01:00
Romain Vimont
b8edcf52b0
Simplify process_wait()
...
The function process_wait() returned a bool (true if the process
terminated successfully) and provided the exit code via an output
parameter exit_code.
But the returned value was always equivalent to exit_code == 0, so just
return the exit code instead.
2021-01-22 18:29:21 +01:00
Romain Vimont
94eff0a4bb
Fix size_t incorrectly assigned to int
...
The function control_msg_serialize() returns a size_t.
2021-01-17 19:44:23 +01:00
Romain Vimont
8dbb1676b7
Factorize meson compiler variable initialization
2021-01-17 19:44:23 +01:00
Romain Vimont
ab912c23e7
Define feature test macros in common.h
...
This enables necessary functions once for all.
As a consequence, define common.h before any other header.
2021-01-17 14:08:48 +01:00
Romain Vimont
59feb2a15c
Group common includes into common.h
...
Include config.h and compat.h in common.h, and include common.h from all
source files.
2021-01-08 19:22:10 +01:00
Romain Vimont
6385b8c162
Move common structs to coords.h
...
The size, point and position structs were defined in common.h. Move them
to coords.h so that common.h could be used for generic code to be
included in all source files.
2021-01-08 19:22:10 +01:00
Romain Vimont
037be4af21
Fix compat missing include
...
The header libavformat/version.h was included, but not
libavcodec/version.h.
As a consequence, the LIBAVCODEC_VERSION_INT definition depended on the
caller includes.
2021-01-08 19:21:54 +01:00
Romain Vimont
1e215199dc
Remove unused struct port_range
...
It had been replaced by struct sc_port_range in scrcpy.h.
2021-01-08 19:13:53 +01:00
Romain Vimont
d580ee30f1
Separate process wait and close
...
On Linux, waitpid() both waits for the process to terminate and reaps it
(closes its handle). On Windows, these actions are separated into
WaitForSingleObject() and CloseHandle().
Expose these actions separately, so that it is possible to send a signal
to a process while waiting for its termination without race condition.
This allows to wait for server termination normally, but kill the
process without race condition if it is not terminated after some delay.
2021-01-08 16:44:21 +01:00
Romain Vimont
821c175730
Rename process_simple_wait to process_wait
...
Adding "simple" in the function name brings no benefit.
2021-01-08 16:44:21 +01:00
Romain Vimont
cc6f5020d8
Move conditional src files in meson.build
...
Declare all the source files (including the platform-specific ones) at
the beginning.
2021-01-08 16:44:21 +01:00
Romain Vimont
4bd9da4c93
Split command into process and adb
...
The process API provides the system-specific implementation, the adb API
uses it to expose adb commands.
2021-01-08 16:44:21 +01:00
Romain Vimont
aa8b571389
Increase display id range
...
Some devices use big display id values.
Refs #2009 <https://github.com/Genymobile/scrcpy/issues/2009 >
2021-01-04 08:16:32 +01:00
Romain Vimont
ed130e05d5
Fix possibly uninitialized value
...
Due to gotos, "ret" may be returned uninitialized.
2021-01-03 22:41:51 +01:00
Romain Vimont
c5c5fc18ae
Update links to v1.17 in README and BUILD
2021-01-02 01:26:23 +01:00
Romain Vimont
f682b87ba5
Bump version to 1.17
2021-01-02 00:53:32 +01:00
Romain Vimont
10b749e27d
Kill the server only after a small delay
...
Let the server terminate properly once all the sockets are closed.
If it does not terminate (this can happen if the device is asleep), then
kill it.
Note: since the server process termination is detected by a flag set
after waitpid() returns, there is a small chance that the process
terminates (and the PID assigned to a new process) before the flag is
set but before the kill() call. This race condition already existed
before this commit.
Fixes #1992 <https://github.com/Genymobile/scrcpy/issues/1992 >
2021-01-01 23:57:01 +01:00
Romain Vimont
05e8c1a3c5
Call CloseHandle() after wait on Windows
...
TerminateProcess() is "equivalent" to kill(), while
WaitForSingleObject() is "equivalent" to waitpid(), so the handle must
be closed after WaitForSingleObject().
2021-01-01 23:57:01 +01:00
Romain Vimont
83910d3b9c
Initialize server struct dynamically
...
This will allow to add mutex/cond fields.
2021-01-01 17:40:52 +01:00
Romain Vimont
90f8356630
Interrupt device threads on stop
...
The (non-daemon) threads were not interrupted on video stream stopped,
leaving the server process alive.
Interrupt them to wake up their blocking call so that they terminate
properly.
Refs #1992 <https://github.com/Genymobile/scrcpy/issues/1992 >
2021-01-01 17:32:34 +01:00
Romain Vimont
3ba51211d6
Mention how to add default arguments on Windows
...
Mention that it is possible to add default arguments by editing the
wrapper scripts.
2021-01-01 17:31:07 +01:00
Romain Vimont
ea3582d2c3
Merge branch 'master' into dev
2021-01-01 17:18:13 +01:00
Romain Vimont
112adbba87
Happy new year 2021!
2021-01-01 17:16:44 +01:00
Romain Vimont
d039a7a39a
Upgrade SDL (2.0.14) for Windows
...
Include the latest version of SDL in Windows releases.
2021-01-01 16:08:58 +01:00
Romain Vimont
6ab80e4ce8
Rename release.make to release.mk
...
It's more standard, and benefits from syntax coloration in vi.
2021-01-01 15:51:10 +01:00
Romain Vimont
230afd8966
Unify release makefile
...
Before this change, release.sh built some native stuff, and
Makefile.CrossWindows built the Windows releases.
Instead, use a single release.make to build the whole release. It also
avoids to build the server one more time.
2020-12-22 18:52:05 +01:00
Romain Vimont
a46733906a
Replace noconsole binary by a wrapper script
...
This simplifies the build system.
Refs <https://github.com/Genymobile/scrcpy/issues/1975#issuecomment-745314161 >
2020-12-22 18:51:59 +01:00
Romain Vimont
431c9ee33b
Improve rotation documentation
2020-12-22 01:48:01 +01:00
Romain Vimont
43d3dcbd97
Document Windows command line usage
...
PR #1973 <https://github.com/Genymobile/scrcpy/pull/1973 >
Reviewed-by: Yu-Chen Lin <npes87184@gmail.com >
2020-12-22 01:44:55 +01:00
Romain Vimont
a5f4f58295
Remove duplicate include
2020-12-22 01:14:30 +01:00
Romain Vimont
ea12783bbc
Upgrade JUnit to 4.13
2020-12-17 10:53:35 +01:00
Romain Vimont
904d470579
Pause on error from a wrapper script
...
On Windows, scrcpy paused on error before exiting to give the user a
chance to see the user message.
This was a hack and causes issues when using scrcpy from batch scripts.
Disable this pause from the scrcpy binary, and provide a batch wrapper
(scrcpy-console.bat) to pause on error.
Fixes #1875 <https://github.com/Genymobile/scrcpy/issues/1875 >
2020-12-14 09:44:17 +01:00
Romain Vimont
6d151eaef9
Reference encoder section from FAQ
2020-12-14 09:04:14 +01:00
Romain Vimont
5dc3285dbf
Reference FFmpeg Windows builds from GitHub
...
Refs #1753 <https://github.com/Genymobile/scrcpy/issues/1753 >
2020-12-12 16:26:08 +01:00
Romain Vimont
c9a4bdb890
Upgrade platform-tools (30.0.5) for Windows
...
Include the latest version of adb in Windows releases.
2020-12-12 15:56:32 +01:00
Romain Vimont
d60ac65b32
Merge branch 'master' into dev
2020-12-12 15:55:29 +01:00
Romain Vimont
30434afc0a
Upgrade gradle build tools to 4.0.1
2020-11-24 09:45:18 +01:00
Romain Vimont
868e762d71
Fix size_t format specifier for Windows
...
Use "%Iu" on Windows. This fixes the following warning:
../app/src/sys/win/command.c:17:14: warning: unknown conversion type character ‘l’ in format [-Wformat=]
17 | LOGE("Command too long (%" PRIsizet " chars)", len - 1);
2020-11-14 22:10:11 +01:00
Romain Vimont
576814bcec
Document --encoder option
...
Add documentation for the new option --encoder in the manpage and in
README.md.
2020-11-08 21:11:12 +01:00
Romain Vimont
42ab8fd611
List available encoders on invalid name specified
...
If an invalid encoder name is given via the --encoder option, list all
the H.264 encoders available on the device.
2020-11-08 21:07:20 +01:00
Romain Vimont
363eeea19e
Log encoder name
...
When the encoder is selected automatically, log the name of the selected
encoder.
2020-11-08 21:07:20 +01:00
Romain Vimont
d5f059c7cb
Add option to force legacy method for pasting
...
Some devices do not behave as expected when setting the device clipboard
programmatically.
Add an option --legacy-paste to change the behavior of Ctrl+v and MOD+v
so that they inject the computer clipboard text as a sequence of key
events (the same way as MOD+Shift+v).
Fixes #1750 <https://github.com/Genymobile/scrcpy/issues/1750 >
Fixes #1771 <https://github.com/Genymobile/scrcpy/issues/1771 >
2020-11-07 15:16:51 +01:00
Romain Vimont
adc547fa6e
Add an option to forward all clicks
...
Add --forward-all-clicks to disable mouse shortcuts and forward middle
and right clicks to the device instead.
Fixes #1302 <https://github.com/Genymobile/scrcpy/issues/1302 >
Fixes #1613 <https://github.com/Genymobile/scrcpy/issues/1613 >
2020-11-03 17:12:26 +01:00
Romain Vimont
5dcfc0ebab
Add local.properties to gitignore
2020-11-03 17:09:03 +01:00
Romain Vimont
ad5f567f07
Remove spurious space
2020-11-03 17:08:21 +01:00
Romain Vimont
25aff00935
Mention version of Indonesian translation
2020-10-05 21:24:59 +02:00
Romain Vimont
83082406d3
Enable Java deprecation warnings details
...
Without the option, gradle reports a lint issue, but without any
details.
2020-10-05 21:11:50 +02:00
Romain Vimont
2edf192e3a
Remove deprecation warning
...
As a workaround for some devices, we need to prepare the main looper.
The method is now deprecated, but we still want to call it.
2020-10-05 21:09:47 +02:00
Romain Vimont
d50ecf40b6
Fix options order
2020-10-01 15:08:18 +02:00
Romain Vimont
acc65f8c9d
Remove unused field
...
Fixes #1775 <https://github.com/Genymobile/scrcpy/issues/1775 >
Reported-by: lordnn
2020-09-20 01:11:22 +02:00
Romain Vimont
a65ebceac1
Add missing mutex unlock on error
...
Fixes #1770 <https://github.com/Genymobile/scrcpy/issues/1770 >
Reported-by: lordnn
2020-09-20 01:11:13 +02:00
Romain Vimont
52560faa34
Fix README indentation
2020-09-17 13:03:40 +02:00
Romain Vimont
d662f73bdc
Upgrade Android SDK to 30
2020-09-15 14:54:22 +02:00
Romain Vimont
1c44dc2259
Use portable shebang for all bash scripts
...
Refs #426 <https://github.com/Genymobile/scrcpy/pull/426 >
Refs #1716 <https://github.com/Genymobile/scrcpy/pull/1716 >
2020-09-15 13:54:00 +02:00
Romain Vimont
ae758f99d6
Adapt call() on ContentProvider for Android 11
...
This commit in AOSP framework_base added a parameter "attributionTag" to
the call() method:
https://android.googlesource.com/platform/frameworks/base.git/+/12ac3f406fed87cb9cd3a28b9947e7202a2d14bd%5E%21/#F17
As a consequence, the method did not exist, so scrcpy used the legacy
call() method (using the authority "unknown") as a fallback, which fails
for security reasons.
Fixes #1468 <https://github.com/Genymobile/scrcpy/issues/1468 >
2020-09-15 13:31:10 +02:00
Romain Vimont
bd9f656933
Fix feature test macro
...
The expected feature test macro is _POSIX_C_SOURCE having a value
greater or equal to 200809L.
Fixes #1726 <https://github.com/Genymobile/scrcpy/issues/1726 >
2020-08-31 14:02:51 +02:00
Romain Vimont
c243fd4c3f
Fix more log format warning
...
The expression port + 1 is promoted to int, but printed as uint16_t.
This is the same mistake fixed for a different log by
7eb16ce364 .
Refs #1726 <https://github.com/Genymobile/scrcpy/issues/1726 >
2020-08-31 13:40:32 +02:00