Romain Vimont
15a206b7fc
Assert return value of mutex functions
...
Mutex functions may only fail due to a programming error.
Use assertions in debug builds, and ignore the value in release builds.
6 years ago
Romain Vimont
d0f5a7fd9f
Remove unused includes
...
No mutex is used in decoder.c and stream.c.
6 years ago
Romain Vimont
510caff0cd
Replace SDL_assert() by assert()
...
SDL_assert() open a dialog on assertion failure.
There is no reason not to use assert() directly.
6 years ago
Romain Vimont
b5ebb234dd
Replace BUILD_DEBUG by NDEBUG
...
Use the "standard" NDEBUG definition, which is used by assert().
6 years ago
Romain Vimont
73e8ec1b35
Remove path argument from cmd_execute()
...
It is always equal to argv[0] (or not used on Windows).
6 years ago
Romain Vimont
8dc11a0286
Fix warnings on Windows
...
fix warnings reported with -Dwarning_level=2 on Windows.
6 years ago
Romain Vimont
06104a701b
Fix windows build
...
Utilities have been moved to util/, but includes had not been updated
in Windows-specific files.
Ref: dfd0707a29
6 years ago
yangfl
8bc056b9c6
Fix manpage format
6 years ago
Romain Vimont
31d9d56117
Fix warnings
...
Fix warnings reported with -Dwarning_level=2.
6 years ago
Romain Vimont
dfd0707a29
Move utilities to util/
6 years ago
Romain Vimont
83ace84280
Restore the .jar extension on the device side
...
Commit 3da95b52bd renamed
'scrcpy-server.jar' to 'scrcpy-server' to avoid issues on the client
side.
However, removing the extension may cause issues with app_process, so
restore the extension only on the device side.
Fixes <https://github.com/Genymobile/scrcpy/issues/944 >
6 years ago
Romain Vimont
c9d886f38b
Use the existing constants for device server path
6 years ago
Romain Vimont
c2116082ab
Remove deprecated options from help and manpage
...
Ref: ff061b4f30
6 years ago
Romain Vimont
3599fcaae5
Fix help for --window-width and --window-height
...
The default value is 0 (automatic), not -1.
6 years ago
Romain Vimont
18f2e33a8b
Fix noconsole.exe
...
The linker flag "-mwindows" has no effect on my current MinGW.
Instead, passing "-Wl,--subsystem,windows" works.
Fixes <https://github.com/Genymobile/scrcpy/issues/691 >
6 years ago
senta2006
7aed5d5b60
Fix typos
...
PR <https://github.com/Genymobile/scrcpy/pull/927 >
Signed-off-by: Romain Vimont <rom@rom1v.com>
6 years ago
Romain Vimont
1d97d7213d
Add option --max-fps
...
Add an option to limit the capture frame rate. It only works for devices
with Android >= 10.
Fixes <https://github.com/Genymobile/scrcpy/issues/488 >
6 years ago
Romain Vimont
1b78a77962
Fix error message
6 years ago
Romain Vimont
59073223aa
Update manpage for --window-borderless option
6 years ago
Diego Fernando Díaz A
59bc5bc1f5
Add option to disable window decoration
...
Add --window-borderless parameter.
Signed-off-by: Romain Vimont <rom@rom1v.com>
6 years ago
Romain Vimont
9fd7a80a89
Add option to specify the initial window size
...
Add --window-width and --window-height parameters.
If only one is provided, the other is computed so that the aspect ratio
is preserved.
6 years ago
Romain Vimont
b6e2f8ae00
Update manpage for --window-{x,y} options
6 years ago
Diego Fernando Díaz A
ce5635f28c
Add option to specify the initial window position
...
Add --window-x and --window-y parameters.
Signed-off-by: Romain Vimont <rom@rom1v.com>
6 years ago
Romain Vimont
771bd8404d
Do not write invalid packet duration
...
Configuration packets have no PTS. Do not compute a packet duration from
their PTS.
Fixes recording to mp4 on device rotation.
6 years ago
Yu-Chen Lin
b963a3b9d5
Check client and server mismatch
...
Send client version as first parameter and check it at server start.
Signed-off-by: Yu-Chen Lin <npes87184@gmail.com>
Signed-off-by: Romain Vimont <rom@rom1v.com>
6 years ago
Romain Vimont
aa0f77c898
Accept resize shortcuts on maximized window
...
Allow "resize to fit" and "resize to pixel-perfect" on maximized window:
restore the window to normal size then resize.
6 years ago
Romain Vimont
35c05bb3ce
Fix rotation while the window is maximized
...
Keep the windowed window size to handle maximized window the same way as
fullscreen window.
Fixes <https://github.com/Genymobile/scrcpy/issues/750 >
6 years ago
Romain Vimont
f6f2868868
Handle window events from screen.c
...
Only the screen knows what to do on window events.
This paves the way to handle more window events.
6 years ago
Romain Vimont
6996cbf5d3
Log device disconnection
...
If scrcpy closes due to socket disconnection, log a warning.
6 years ago
Romain Vimont
b08a98324d
Fix segfault on empty file recorded
...
Write the file trailer only if the file header have been written, to
avoid a segfault in libav.
Fixes <https://github.com/Genymobile/scrcpy/issues/918 >.
6 years ago
Romain Vimont
c916af0984
Add --prefer-text option
...
Expose an option to configure how key/text events are forwarded to the
Android device.
Enabling the option avoids issues when combining multiple keys to enter
special characters, but breaks the expected behavior of alpha keys in
games (typically WASD).
Fixes <https://github.com/Genymobile/scrcpy/issues/650 >
6 years ago
Romain Vimont
ff061b4f30
Deprecate short options for advanced features
...
The short options will be removed in the future (and may be reused for
other features).
6 years ago
Romain Vimont
157c60feb4
Fix indentation
6 years ago
Romain Vimont
2d90e1befd
Fix include recorder.h
6 years ago
Romain Vimont
0e301ddf19
Factorize scrcpy options and command-line args
...
Do not duplicate all scrcpy options fields in the structure storing the
parsed command-line arguments.
6 years ago
Romain Vimont
c42ff75b74
Pass screen to mouse event converters
...
Mouse events coordinates depend on the screen size and location, so the
converter need to access the screen.
The fact that it needs the position or the size is an internal detail,
so pass a pointer to the whole screen structure.
6 years ago
Romain Vimont
b0db1178d1
Move event conversion to input_manager
...
Only keep helper functions separated.
This will help to convert coordinates internally when necessary.
6 years ago
Romain Vimont
8d601d3210
Rename "input_manager" variables to "im"
...
It is used a lot, a short name improves readability.
6 years ago
Romain Vimont
683f7ca848
Document how to attach a debugger to the server
6 years ago
Romain Vimont
120f08ee96
Fix manpage option parameter format
...
The parameter for --window-title was not underlined the same way as
others.
6 years ago
Romain Vimont
0415672a75
Merge branch 'master' into dev
6 years ago
Romain Vimont
95fd64b5de
Add scrcpy version in recorded video metadata
...
It might help to understand problems in recorded videos.
6 years ago
yangfl
4696878a97
Add manpage for scrcpy
6 years ago
Romain Vimont
3da95b52bd
Rename scrcpy-server.jar to scrcpy-server
...
The server name ending with .jar has several drawbacks:
- meson requires the jar executable to attempt to modify it:
<https://github.com/Genymobile/scrcpy/issues/404#issuecomment-456065923 >
<https://github.com/mesonbuild/meson/issues/4844 >
- meson warns during "ninja install"
<https://github.com/Genymobile/scrcpy/issues/458 >
- some users try to execute it on the computer as a java executable
Removing the extension solves all these problems.
6 years ago
Romain Vimont
c72f677435
Merge branch 'master' into dev
6 years ago
Romain Vimont
1380f6e00f
Fix help for --record-format
...
Record format requires a parameter.
6 years ago
Romain Vimont
17d53be3ef
Fix mouse events conversion
...
The conversion from SDL mouse state to Android mouse state used wrong
constants as mask.
Fixes <https://github.com/Genymobile/scrcpy/issues/635 >
6 years ago
Romain Vimont
f6c8460ebb
Rename window size functions for clarity
...
Now, get_window_size() returns the current window size (fullscreen or
not), while get_windowed_window_size() always returned the windowed size
(the size when fullscreen is disabled).
6 years ago
Romain Vimont
6220456def
Merge mouse and touch events
...
Both are handled the very same way on the device.
6 years ago
Romain Vimont
30168f0428
Ignore duplicate mouse events
...
In SDL, a touch event may simulate an identical mouse event. Since we
already handle touch event, ignore these duplicates.
6 years ago
Romain Vimont
b5a2d99bc2
Send touch events from the client
...
On SDL touch events, send control messages to the server.
6 years ago
Romain Vimont
77f876e29c
Add "inject touch" control message
...
Add a control message type in the protocol to forward touch events to
the device.
6 years ago
Romain Vimont
810ff80ba7
Add buffer_write64be()
...
Add a function to write 64 bits in big-endian from a uint64_t.
6 years ago
Romain Vimont
1f8ba1ca79
Include config.h everywhere
...
Ref: <https://github.com/Genymobile/scrcpy/issues/829 >
Suggested-by: Louis Kruger <louisk@gmail.com>
6 years ago
Louis Kruger
129dabcfa4
Include config.h to fix HIDPI support
...
Ref: <https://github.com/Genymobile/scrcpy/issues/829 >
Signed-off-by: Romain Vimont <rom@rom1v.com>
6 years ago
Yu-Chen Lin
795d103032
input_manager.c: Correct log
...
Signed-off-by: Yu-Chen Lin <npes87184@gmail.com>
6 years ago
Ta-da
513d1ac96d
Fix option "record-format" related short opt
6 years ago
Romain Vimont
ffdbf5990b
Rename event converter functions
...
Rename "XXX_from_sdl_to_android" to "convert_XXX", to avoid huge
function names.
6 years ago
Romain Vimont
9463850c24
Rename "convert.h" to "event_converter.h"
...
The filename gave no hint about what was converted.
6 years ago
Romain Vimont
a9c8fa305d
Fix segfault on recording with old FFmpeg
...
The AVPacket fields side_data and side_data_elems were not initialized
by av_packet_ref() in old FFmpeg versions (prior to [1]).
As a consequence, on av_packet_unref(), side_data was freed, causing a
segfault.
Fixes <https://github.com/Genymobile/scrcpy/issues/707 >
[1]: <http://git.videolan.org/gitweb.cgi/ffmpeg.git/?p=ffmpeg.git;a=commitdiff;h=3b4026e15110547892d5d770b6b43c9e34df458f >
6 years ago
Romain Vimont
8507fea271
Record a packet with its duration
...
Record a packet only once the following has been received, so that we
can set its duration before muxing it.
Fixes <https://github.com/Genymobile/scrcpy/issues/702 >
6 years ago
Arne Schwabe
c05056343b
Fix building on OS X (missing NULL in queue.h)
...
Headers seem to be a bit different in Apple land and you need to include
stddef.h explicitly to the NULL declaration.
This also makes the code a bit more correct, as stddef.h is the header
in the C standard that defines NULL
(https://en.cppreference.com/w/cpp/header/cstddef ).
6 years ago
Romain Vimont
b0184f2869
Initialize queue "last" field
...
The compiler is not always able to see that "last" is always initialized
before being used, so always initialize it.
6 years ago
Romain Vimont
e2ac996183
Use Cmd instead of Ctrl on macOS when possible
...
Fixes <https://github.com/Genymobile/scrcpy/issues/642 >
6 years ago
Romain Vimont
5e4ccfd832
Use generic FIFO queue for recording
...
Replace the specific recording queue by the new generic FIFO queue
implementation.
6 years ago
Romain Vimont
53b6ee2cf4
Add generic intrusive FIFO queue
...
We need several FIFO queues (a queue of packets, a queue of messages,
etc.).
Some of them are implemented using cbuf, a generic circular buffer. But
for recording, we need to store the packets in an unbounded queue until
they are written, so the queue was implemented manually.
Create a generic implementation (using macros) to avoid reimplementing
it every time.
6 years ago
Romain Vimont
26213f1031
Fix cbuf documentation
6 years ago
Romain Vimont
96b5067cbf
Remove unnecessary backslash in cbuf
6 years ago
Romain Vimont
6abb4902c6
Log recording failure
...
If recording fails, log "recording failed" instead of "recording
complete".
6 years ago
Romain Vimont
d4ed8b6f26
Log scrcpy version and URL on start
...
Keep --version which also print the version of dependencies.
6 years ago
Romain Vimont
35d9185f6c
Record asynchronously
...
The record file was written from the stream thread. As a consequence,
any blocking I/O to write the file delayed the decoder.
For maximum performance even when recording is enabled, send
(refcounted) packets to a separate recording thread.
6 years ago
Romain Vimont
63af7fbafe
Reduce latency by 1 frame
...
To packetize the H.264 raw stream, av_parser_parse2() (called by
av_read_frame()) knows that it has received a full frame only after it
has received some data for the next frame. As a consequence, the client
always waited until the next frame before sending the current frame to
the decoder!
On the device side, we know packets boundaries. To reduce latency,
make the device always transmit the "frame meta" to packetize the stream
manually (it was already implemented to send PTS, but only enabled on
recording).
On the client side, replace av_read_frame() by manual packetizing and
parsing.
<https://stackoverflow.com/questions/50682518/replacing-av-read-frame-to-reduce-delay >
<https://trac.ffmpeg.org/ticket/3354 >
6 years ago
Romain Vimont
a90ccbdf3b
Add option to change the push target
...
A drag & drop always pushed the file to /sdcard/.
Add an option to customize the target directory.
Fixes <https://github.com/Genymobile/scrcpy/issues/659 >
6 years ago
Romain Vimont
ca970e8aa6
Merge branch 'master' into dev
6 years ago
Romain Vimont
3c55d0c69b
Fix double-free on error
...
If writing the recording header fails, do not clean the resources
immediately to avoid double-free.
7 years ago
Romain Vimont
4961256123
Close decoder on stream ended
...
Add missing call to decoder_close().
7 years ago
beango1
8e65c10720
Add option --window-title
...
Add an option to set a custom window title.
Signed-off-by: Romain Vimont <rom@rom1v.com>
7 years ago
Romain Vimont
056e47e752
Replace "cannot" by "could not"
7 years ago
Romain Vimont
91ecb4f218
Close socket on error
...
Suggested-by: barry-ran
<https://github.com/Genymobile/scrcpy/issues/607 >
7 years ago
Romain Vimont
bfb3f0842f
Prevent to turn screen off if no control
...
If --no-control is set, then the controller is not initialized (both in
the client and the server), so it is not possible to control the device
to turn its screen off.
See <https://github.com/Genymobile/scrcpy/issues/608 >.
7 years ago
Romain Vimont
b91ecf5225
Fix --serial help
...
Make explicit that --serial excepts a parameter.
7 years ago
zzndb
bcd0a876f7
Fix a spell mistake
...
After commented default portable option in `app/meson.build` get some
error and then find this. :)
Signed-off-by: Romain Vimont <rom@rom1v.com>
7 years ago
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.
7 years ago
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.
7 years ago
Romain Vimont
4eb6b26c93
Extract "scrcpy-server.jar" string
...
The filename is used at several places.
7 years ago
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.
7 years ago
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.
7 years ago
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
7 years ago
Romain Vimont
5d11339259
Inline lock_util functions
...
They are just tiny wrappers.
7 years ago
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.
7 years ago
Romain Vimont
d104d3bda9
Add cond_wait_timeout()
...
Add a "timed out" version of cond_wait().
7 years ago
Romain Vimont
eda44b6068
Fix controller cleanup
...
After commit bfb86ca2c2 , the controller
was not stopped and destroyed on quit.
7 years ago
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.
7 years ago
Romain Vimont
a143b8b07a
Indent command-line options
...
Prepare indentation for --render-expired-frames.
7 years ago
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.
7 years ago
Romain Vimont
7f07b13446
Indent command-line options
...
Preparse indentation for --turn-screen-off.
7 years ago
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.
7 years ago
Romain Vimont
ca767ba364
Group server params in a struct
...
Starting the server requires more and more parameters. For clarity,
group them in a struct.
7 years ago
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".
7 years ago
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.
7 years ago