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
Romain Vimont
50dac2eaee
Log "new texture" at INFO level
...
The "initial texture" is logged at INFO level. For consistency, log "new
texture" at the same level.
2019-03-07 20:18:03 +01:00
Romain Vimont
b8ff35efe6
Remove empty line
2019-03-07 19:03:13 +01:00
Romain Vimont
7fad611dfb
Merge branch 'dev'
2019-03-07 19:02:40 +01:00
Romain Vimont
a7b3901c31
Add more consts
...
Some decoder and recorder functions must not write to AVCodec and
AVPacket.
2019-03-03 12:02:41 +01:00
Romain Vimont
fc81d0d771
Merge pull request #442 from npes87184/master
...
server/meson.build: support relative path for prebuilt_server
2019-03-03 11:16:13 +01:00
Romain Vimont
f7efafd846
Explicitly pass control flag to input manager
...
Replace the "global" control flag in the input_manager by a function
parameter to make explicit that the behavior depends whether
--no-control has been set.
2019-03-03 11:05:26 +01:00
Romain Vimont
6baed8a06f
Do not init SDL video subsystem if no display
...
The SDL video subsystem is not necessary if we don't display the video.
Move the sdl_init_and_configure() function from screen.c to scrcpy.c,
because it is not only related to the screen display.
2019-03-03 01:41:35 +01:00
Romain Vimont
8595862005
Use explicit output parameter for skipped frame
...
The function video_buffer_offer_decoded_frame() returned a bool to
indicate whether the previous frame had been consumed.
This was confusing, because we could expect the returned bool report
whether the action succeeded.
Make the semantic explicit by using an output parameter.
Also revert the flag (report if the frame has been skipped instead of
consumed) to avoid confusion for the first frame (the previous is
neither skipped nor consumed because there is no previous frame).
2019-03-03 00:35:20 +01:00
Romain Vimont
9ef345fdd0
Make owned serial a pointer-to-non-const
...
The server owns the serial, so it needs to free it. Therefore, it should
not be a pointer-to-const.
2019-03-03 00:01:16 +01:00
Romain Vimont
dfed1b250e
Replace SDL types by C99 standard types
...
Scrcpy is a C11 project. Use the C99 standard types instead of the
SDL-specific types:
SDL_bool -> bool
SintXX -> intXX_t
UintXX -> uintXX_t
2019-03-02 23:55:23 +01:00
Romain Vimont
8655ba7197
Add option to mirror in read-only
...
Add an option to disable device control: -n/--no-control.
2019-03-02 23:10:21 +01:00
Romain Vimont
163cd36ccc
Rename -n/--no-window to -N/--no-display
...
The description of scrcpy is "Display and control your Android device".
We want an option to disable display, another one to disable control.
For naming consistency, name it --no-display.
Also change the shortname to -N, so that we can use -n for --no-control
later.
2019-03-02 22:46:46 +01:00
Romain Vimont
db6644f1f9
Add missing no_window initialization
...
Initialize the field no_window in "struct args"
2019-03-02 22:42:28 +01:00
Romain Vimont
36191b7eec
Avoid unnecessary call if display is disabled
...
If --no-window is passed, there is no need to register an event watcher.
2019-03-02 21:51:07 +01:00
Romain Vimont
33ccb1368f
Extract event processing out of event_loop()
...
To avoid too many levels of nested blocks, move the event handling logic
in a separate function.
2019-03-02 21:51:07 +01:00
Romain Vimont
aeda583a2c
Update code style
...
Limit source code to 80 chars, and declare functions return type and
modifiers on a separate line.
This allows to avoid very long lines, and all function names are
aligned.
(We do this on VLC, and I like it.)
2019-03-02 20:28:46 +01:00