Romain Vimont
ffe0417228
Update platform-tools (29.0.1) for Windows
...
Include the latest version of adb in Windows releases.
2019-06-11 19:19:47 +02:00
Romain Vimont
e3afb67e7f
Downgrade SDL to 2.0.8 for Windows
...
Revert "Update SDL (2.0.9) for Windows"
Several users experienced freezes with SDL 2.0.9.
This reverts commit a5787dccd6 .
See:
- <https://github.com/Genymobile/scrcpy/issues/425 >
- <https://discourse.libsdl.org/t/unstable-frame-rate-unexpectedly/25783 >
2019-06-11 19:18:45 +02:00
Romain Vimont
4ee1391361
Upgrade FFmpeg (4.1.3) for Windows
...
Include the latest version of FFmpeg in Windows releases.
2019-06-11 19:18:45 +02:00
Romain Vimont
2755bfc255
Improve portable builds
...
In portable builds, scrcpy-server.jar was supposed to be present in the
current directory, so in practice it worked only if scrcpy was launched
from its own directory.
Instead, find the absolute path of the executable and build a suitable
path to use scrcpy-server.jar from the same directory.
2019-06-11 17:44:07 +02:00
Romain Vimont
3b17ff7c86
Add functions to convert wide char to UTF-8
...
There was already utf8_to_wide_char(), used to correctly execute
commands on Windows.
Add the reverse converter: utf8_from_wide_char(). We will need it to
build the scrcpy-server path based on the executable directory.
2019-06-11 17:44:07 +02:00
Romain Vimont
4eb6b26c93
Extract "scrcpy-server.jar" string
...
The filename is used at several places.
2019-06-11 17:44:07 +02:00
Romain Vimont
eb34098add
Simplify portable build configuration
...
To create a portable build (with scrcpy-server.jar accessible from the
scrcpy directory), replace OVERRIDE_SERVER_PATH by a simple compilation
flag: PORTABLE.
This paves the way to use more complex rules to determine the path of
scrcpy-server.jar in portable builds.
2019-06-11 17:44:07 +02:00
Romain Vimont
b777760bca
Simplify scrcpy-server path configuration
...
The full path of scrcpy-server.jar was partially configured from
meson.build then concatenated by C code.
Instead, directly write the path in C.
2019-06-11 17:44:07 +02:00
Romain Vimont
72bdfbc7a6
Never return 0 for stream protocol
...
On socket disconnection, on Linux, recv() returns -1 and errno is set.
But on Windows, errno is 0.
In that case, AVERROR(errno) == 0, leading to the warning:
> Invalid return value 0 for stream protocol
To avoid the problem, if errno is 0, return AVERROR_EOF.
Ref: commit 2876463d39
2019-06-11 17:44:07 +02:00
Romain Vimont
8604f16b30
Truncate device name at UTF-8 code point boundary
...
Just in case.
2019-06-07 17:45:03 +02:00
Romain Vimont
5d11339259
Inline lock_util functions
...
They are just tiny wrappers.
2019-06-07 17:19:00 +02:00
Romain Vimont
e2a272bf99
Improve framerate counting
...
The FPS counter was called only on new frames, so it could not print
values regularly, especially when there are very few FPS (when the
device surface does not change).
To the extreme, it was never able to display 0 fps.
Add a separate thread to print framerate every second.
2019-06-07 17:16:26 +02:00
Romain Vimont
d104d3bda9
Add cond_wait_timeout()
...
Add a "timed out" version of cond_wait().
2019-06-07 16:54:31 +02:00
Romain Vimont
eda44b6068
Fix controller cleanup
...
After commit bfb86ca2c2 , the controller
was not stopped and destroyed on quit.
2019-06-07 00:03:21 +02:00
Romain Vimont
ebccb9f6cc
Add runtime option to render expired frames
...
Replace the compilation flag SKIP_FRAMES by a runtime flag to force
rendering of expired frames. By default, the expired frames are skipped.
2019-06-05 21:39:42 +02:00
Romain Vimont
a143b8b07a
Indent command-line options
...
Prepare indentation for --render-expired-frames.
2019-06-05 19:02:42 +02:00
Romain Vimont
9253996873
Add README section explaining --turn-screen-off
2019-06-05 19:02:42 +02:00
Romain Vimont
8e66b33000
Add option to turn device screen off
...
In addition to the shortcut (Ctrl+o) to turn the device screen off, add
a command-line argument to turn it off on start.
2019-06-05 00:55:46 +02:00
Romain Vimont
7f07b13446
Indent command-line options
...
Preparse indentation for --turn-screen-off.
2019-06-05 00:55:39 +02:00
Romain Vimont
acc4dcd520
Disable server controller if --no-control
...
If --no-control is disabled, there is no need for a controller.
It also avoids to power on the device on start if control is disabled.
2019-06-05 00:25:57 +02:00
Romain Vimont
ca767ba364
Group server params in a struct
...
Starting the server requires more and more parameters. For clarity,
group them in a struct.
2019-06-05 00:25:57 +02:00
Romain Vimont
c8a6783494
Use positive options names internally
...
For clarity, store the flag resulting of the command-line options
--no-control and --no-display into "control" and "display".
2019-06-05 00:25:15 +02:00
Romain Vimont
5b56900e2b
Rename unused field
...
The flag is used only in the server_start() implementation, there is no
need to store it in the structure.
2019-06-04 21:29:14 +02:00
Romain Vimont
8c8649cfcd
Remove "turn device screen on" feature
...
Only keep "turn device screen off" and POWER button.
After we turn the device screen off (with Ctrl+o), turning it back on
does not always work, and leaves the device in a weird state, where even
the power button may not be sufficient:
<https://github.com/Genymobile/scrcpy/issues/175#issuecomment-497946596 >
This is not an acceptable behavior, so disable the shortcut to turn the
physical device screen on. We can use the POWER button (or Ctrl+p)
instead.
2019-06-03 11:44:39 +02:00
Romain Vimont
e572d81fa2
Rename function to "power on"
...
This will reduce confusion between "power on" when the device is off and
"turn device screen off" while mirroring.
2019-06-02 20:34:52 +02:00
Romain Vimont
41225c3e41
Improve key processing readability
...
The condition "event->type == SDL_KEYDOWN" and the variable
input_manager->controller are used many times. Replace them by local
variables to reduce verbosity.
2019-06-01 07:18:05 +02:00
Romain Vimont
296047d82a
Use net_close() to close sockets
...
So that it also works on Windows.
2019-05-31 23:33:44 +02:00
Romain Vimont
0792998cc2
Remove unused import
...
Introduced by the previous commit.
2019-05-31 23:31:53 +02:00
Romain Vimont
12a3bb25d3
Implement device screen off while mirroring
...
Add two shortcuts:
- Ctrl+o to turn the device screen off while mirroring
- Ctrl+Shift+o to turn it back on
On power on (either via the POWER key or BACK while screen is off), both
the device screen and the mirror are turned on.
<https://github.com/Genymobile/scrcpy/issues/175 >
2019-05-31 23:07:23 +02:00
Romain Vimont
3ee9560ece
Fix comment style
...
For consistency.
2019-05-31 22:57:12 +02:00
Romain Vimont
6537c2ef01
Add clipboard logs
...
Synchronizing local and device clipboards in invisible. Add INFO logs
on success.
2019-05-31 16:18:00 +02:00
Romain Vimont
9712cb8123
Do not minimize on focus loss
...
The default behavior seems annoying.
Fixes <https://github.com/Genymobile/scrcpy/issues/554 >
2019-05-31 16:18:00 +02:00
Romain Vimont
ad55a9addc
Prefix server logs
...
Sometimes, it is not obvious whether a log is generated by the server or
by the client. Prefix server logs for clarity.
2019-05-31 16:18:00 +02:00
Romain Vimont
28980bbc90
Rename "event" to "message"
...
After the recent refactorings, a "control event" is not necessarily an
"event" (it may be a "command"). Similarly, the unique "device event"
used to send the device clipboard content is more a "reponse" to the
request from the client than an "event".
Rename both to "message", and rename the message types to better
describe their intent.
2019-05-31 16:18:00 +02:00
Romain Vimont
f710d76c9e
Merge pull request #568 from npes87184/dev
...
Correct return value type in handle_event
2019-05-31 15:27:35 +02:00
Romain Vimont
0125af1e46
Update DEVELOP after recent refactorings
2019-05-30 22:46:52 +02:00
Romain Vimont
c13a24389c
Implement computer-to-device clipboard copy
...
It was already possible to _paste_ (with Ctrl+v) the content of the
computer clipboard on the device. Technically, it injects a sequence of
events to generate the text.
Add a new feature (Ctrl+Shift+v) to copy to the device clipboard
instead, without injecting the content. Contrary to events injection,
this preserves the UTF-8 content exactly, so the text is not broken by
special characters.
<https://github.com/Genymobile/scrcpy/issues/413 >
2019-05-30 22:46:52 +02:00
Romain Vimont
2322069656
Extract control event String parsing
...
Parsing a String from a serialized control event, encoded as length (2
bytes) + data, will be necessary in several events.
Extract it to a separate method.
2019-05-30 22:46:52 +02:00
Romain Vimont
61f5f96b42
Fix control event String parsing
...
At least 2 bytes must be available to read the length of the String.
2019-05-30 22:46:52 +02:00
Romain Vimont
63c078ee6c
Implement device-to-computer clipboard copy
...
On Ctrl+C:
- the client sends a GET_CLIPBOARD command to the device;
- the device retrieve its current clipboard text and sends it in a
GET_CLIPBOARD device event;
- the client sets this text as the system clipboard text, so that it
can be pasted in another application.
Fixes <https://github.com/Genymobile/scrcpy/issues/145 >
2019-05-30 22:46:52 +02:00
Romain Vimont
3149e2cf4a
Add device event sender
...
Create a separate component to send device events, managed by the
controller.
2019-05-30 22:46:52 +02:00
Romain Vimont
6112095e75
Add device event receiver
...
Create a separate component to handle device events, managed by the
controller.
2019-05-30 22:46:52 +02:00
Romain Vimont
f9d2d99166
Add GET_CLIPBOARD device event
...
Add the first device event, used to forward the device clipboard to the
computer.
2019-05-30 22:36:22 +02:00
Romain Vimont
ec71a3f66a
Use two sockets for video and control
...
The socket used the device-to-computer direction to stream the video and
the computer-to-device direction to send control events.
Some features, like copy-paste from device to computer, require to send
non-video data from the device to the computer.
To make them possible, use two sockets:
- one for streaming the video from the device to the client;
- one for control/events in both directions.
2019-05-30 22:35:41 +02:00
Romain Vimont
69360c7407
Extract control event string serialization
...
A string is serialized as a length (2 bytes) followed by the string data
(non nul-terminated).
For now, it is used only once, but we will need to serialize strings in
other events.
2019-05-30 22:35:04 +02:00
Romain Vimont
6ec2ddd2d1
Truncate UTF-8 properly
...
This will avoid to produce invalid UTF-8 results (although unlikely).
2019-05-30 22:34:59 +02:00
Romain Vimont
0a7fe7ad57
Add helpers to truncate UTF-8 at code points
...
This will help to avoid truncating a UTF-8 string in the middle of a
code point, producing an invalid UTF-8 result.
2019-05-30 22:30:18 +02:00
Romain Vimont
3aa5426cad
Add unit tests for control events serialization
...
Add missing tests for serialization and deserialization of control
events.
2019-05-30 22:30:18 +02:00
Romain Vimont
63207d9cd5
Fix wrong comment in unit test
2019-05-30 22:30:18 +02:00
Romain Vimont
ad4c061cd2
Use custom class Point
...
The framework class android.graphics.Point cannot be used in unit tests.
Implement our own Point.
2019-05-30 22:30:18 +02:00
Romain Vimont
63909fd10d
Merge commands with other control events
...
Several commands were grouped under the same event type "command", with
a separate field to indicate the actual command.
Move these commands at the same level as other control events. It will
allow to implement commands with arguments.
2019-05-30 22:30:18 +02:00
Romain Vimont
3b4366e5bf
Stop stream immediately on quit
...
If the stream is stopped, av_read_frame() will be woken up and yield a
corrupted packet. Do not try to decode or record it.
2019-05-30 22:30:18 +02:00
Romain Vimont
47f1003200
Close server socket before killing process
...
The sockets may be closed and shutdown on server_stop(). This will
interrupt the stream and controller threads more quickly and gracefully.
2019-05-30 22:30:18 +02:00
Romain Vimont
bfb86ca2c2
Simplify cleanup
...
The cleanup is not linear: for example, the server must be stopped and
its sockets must be shutdown after the stream and controller are stopped
(so that they don't continue processing garbage), but before they are
joined, to avoid a deadlock if they are blocked on a socket read.
Simplify the spaghetti-cleanup by keeping trace of initialization at
runtime.
2019-05-30 22:30:18 +02:00
Romain Vimont
0dee9b04b2
Use net_recv() to read only one byte
...
Partial read is impossible for 1 byte, so net_recv_all() is useless.
2019-05-30 22:30:18 +02:00
Romain Vimont
8fc58bde75
Simplify server_connect_to()
...
Only use 2 branches, using either forward or remote tunnel.
2019-05-30 22:30:18 +02:00
Romain Vimont
5a431cdf9b
Make server_connect_to() return a bool
...
The resulting socket is accessible from the server instance, there is no
need to return it.
This paves the way to use several sockets in parallel.
2019-05-30 22:30:18 +02:00
Romain Vimont
6edb1294f0
Add missing return 0 in unit test
2019-05-30 22:30:18 +02:00
Romain Vimont
073181b294
Use cbuf for file handler request queue
...
Replace the file_handler_request_queue implementation by cbuf.
2019-05-30 22:30:18 +02:00
Romain Vimont
241a3dcba5
Use cbuf for control event queue
...
Replace the control_event_queue implementation by cbuf.
2019-05-30 22:30:18 +02:00
Romain Vimont
b38292cd69
Add generic circular buffer
...
Add a circular buffer implementation, to factorize multiple specific
queues implementation.
2019-05-30 22:30:18 +02:00
Romain Vimont
7475550ae8
Add buffer_read16be()
...
Add a function to read 16 bits in big-endian to a uint16_t.
2019-05-30 22:30:18 +02:00
Romain Vimont
7fc8793d5b
Make buffer util functions accept const buffers
...
So that they can be used both on const and non-const input buffers.
2019-05-30 22:30:18 +02:00
Romain Vimont
bf5e54b2e9
Make control_event_serialize() return size_t
...
control_event_serialize() returns the number of bytes written, so the
type should be size_t.
2019-05-30 22:30:18 +02:00
Romain Vimont
507b0bcccf
Fix memory leak on error
...
The variable condition was not destroyed on strdup() failure.
2019-05-30 22:30:18 +02:00
Romain Vimont
e1afd9f8b0
Fix event ownership comment
2019-05-30 22:30:18 +02:00
Romain Vimont
b08dada6c1
Prefix control event constants by namespace
...
This will avoid conflicts with future device events.
2019-05-30 22:30:18 +02:00
Romain Vimont
999c964689
Make macro expansion-safe
...
Use parentheses to avoid unexpected results.
For example, make:
2 * SERIALIZED_EVENT_MAX_SIZE
expand to:
2 * (3 + TEXT_MAX_LENGTH)
instead of:
2 * 3 + TEXT_MAX_LENGTH
2019-05-30 22:30:18 +02:00
Romain Vimont
befe455e44
Remove unused includes
...
The struct control_event does not use mutexes, and net.h does not need
SDL_platform.h.
2019-05-30 22:30:18 +02:00
Romain Vimont
d2504f974c
Fix indentation
...
Previous refactorings broke indentation.
2019-05-30 22:30:18 +02:00
Romain Vimont
0fbab42f8c
Format meson.build for readability
2019-05-30 22:30:18 +02:00
Romain Vimont
08f506b24f
Replace SDL_bool by bool in tests
...
Commit dfed1b250e replaced SDL types by
standard types in sources, but tests were not updated.
2019-05-30 22:30:18 +02:00
Romain Vimont
3bc1c51b91
Always use SDL_malloc() and SDL_free()
...
To avoid mixing SDL_malloc()/SDL_strdup() with free(), or malloc() with
SDL_free(), always use the SDL version.
2019-05-30 22:30:08 +02:00
Romain Vimont
7ed976967f
Fix checkstyle warning
...
Checkstyle wants a specific order of imports.
2019-05-30 00:22:05 +02:00
Romain Vimont
b75f0e9427
Merge branch 'master' into dev
2019-05-28 13:31:37 +02:00
Romain Vimont
5d473efeb5
Bind Home key to MOVE_HOME
...
On pressing Home key on the computer, move the cursor to the beginning
of the line instead of going back to the home screen.
<https://developer.android.com/reference/android/view/KeyEvent.html#KEYCODE_HOME >
<https://developer.android.com/reference/android/view/KeyEvent.html#KEYCODE_MOVE_HOME >
Fixes (part of) <https://github.com/Genymobile/scrcpy/issues/555 >.
2019-05-27 10:24:47 +02:00
Romain Vimont
a41dd6c79f
Make owned filename a pointer-to-non-const
...
The file handler owns the filename string, so it needs to free it.
Therefore, it should not be a pointer-to-const.
2019-05-24 17:25:31 +02:00
Romain Vimont
c3779d8513
Make owned serial a pointer-to-non-const
...
The file handler owns the serial, so it needs to free it. Therefore, it
should not be a pointer-to-const.
2019-05-24 17:24:17 +02:00
Romain Vimont
b3bd5f1b80
Remove useless casts to (void *)
2019-05-24 17:23:21 +02:00
Romain Vimont
a920ba6471
Explain how to customize path in README
2019-05-24 13:25:12 +02:00
Romain Vimont
3133d5d1c7
Continue on icon loading failure
...
If loading the icon from xpm fails, launch scrcpy without window icon.
<https://github.com/Genymobile/scrcpy/issues/539 >
2019-05-23 20:58:08 +02:00
Romain Vimont
2dc1a59471
Check surface returned for icon
...
SDL_CreateRGBSurfaceFrom() may return NULL, causing a segfault.
<https://github.com/Genymobile/scrcpy/issues/539 >
2019-05-20 09:44:45 +02:00
Romain Vimont
3068457b90
Log characters failed to be injected
...
Some characters may not be injected (e.g. '\r`). Log them instead of
ignoring them silently.
2019-05-20 08:40:10 +02:00
Romain Vimont
56f8e78f58
Merge pull request #542 from npes87184/dev
...
Return success count in injectText
2019-05-20 08:39:02 +02:00
Romain Vimont
e443518ed9
Print adb command on error
...
When the execution of an adb command fails, print the command. This will
help to understand what went wrong.
See <https://github.com/Genymobile/scrcpy/issues/530 >.
2019-05-12 15:16:13 +02:00
Romain Vimont
eeb8e8420f
Use size_t for command length
...
The size of an array should have type size_t.
2019-05-12 14:31:18 +02:00
Romain Vimont
39b5893c42
Merge pull request #522 from dos1/compositor
...
Disable X11 compositor bypass
2019-05-05 17:35:10 +02:00
Romain Vimont
c8338b2918
Recover if expand/collapse panels is not available
...
Some devices don't have the required method. Recover gracefully without
crashing the server.
Fixes <https://github.com/Genymobile/scrcpy/issues/506 >.
2019-05-04 14:49:48 +02:00
Romain Vimont
2837c6eaab
Add method to log error without throwable
...
Add Ln.e(message) in addition to Ln.e(message, error).
2019-05-04 14:49:04 +02:00
Romain Vimont
668e54fd4b
Upgrade gradle
2019-05-04 14:49:04 +02:00
Romain Vimont
01664777c8
Merge branch 'master' into dev
2019-05-04 14:48:54 +02:00
Romain Vimont
5254e585c6
Run server tests on release
2019-03-27 21:51:42 +01:00
Romain Vimont
66baf0f95b
Run tests with ASAN enabled
...
This may capture more errors (like
e2ef39fae5 ).
2019-03-27 21:50:25 +01:00
Romain Vimont
f11b0ec204
Fix server checkstyle errors
...
Fix errors reported by:
gradle -p server check
2019-03-27 21:47:54 +01:00
Romain Vimont
e2ef39fae5
Fix overflow in test
...
The serialized text is not nul-terminated (its size is explicitely
provided), but the input text in the event is a nul-terminated string.
The test was failing with ASAN enabled.
2019-03-25 11:33:32 +01:00
Romain Vimont
3eda38e5fc
Do not call codec.stop() on exception
...
On exception, the codec is not in a state were .stop() can be called.
2019-03-21 18:46:22 +01:00
Romain Vimont
71fd238b0a
Update developer documentation for v1.8
2019-03-07 20:48:43 +01:00
Romain Vimont
d795144a36
Add note about Ctrl+C on Windows while recording
...
Ctrl+C kills the app on Windows, so the recorded file is broken.
2019-03-07 20:42:08 +01:00
Romain Vimont
c287826f8e
Update links to v1.8 in README and BUILD
2019-03-07 20:42:02 +01:00
Romain Vimont
1323e3c43e
Bump version to 1.8
2019-03-07 20:21:07 +01:00