Commit graph

82 commits

Author SHA1 Message Date
Romain Vimont
d744837f13 Bump version to 1.1 2018-03-14 09:34:00 +01:00
Romain Vimont
c2ac6fe7bd Upgrade version to 1.0 2018-03-08 09:21:06 +01:00
Romain Vimont
fffeedffda Expose High DPI support configuration flag
The High DPI support is enabled by default, so that the renderer use the
full definition of High DPI screens.

However, there are still mouse coordinates problems on some MacOS having
High DPI support (but not all), so expose a way to disable it.
2018-03-07 18:07:02 +01:00
Romain Vimont
e3f5d3b49b Double the default bitrate
Set the default video bitrate to 8Mbps. This greatly increase quality on
fast motion, without negative side effects.
2018-03-07 18:04:38 +01:00
Romain Vimont
089378926b Rename SCRCPY_SERVER_JAR to SCRCPY_SERVER_PATH
The server is currently a JAR, but it may ba an APK or a DEX, so the
variable name should not contain the type.

Rename the environment variable, the Meson options and the C
definitions.
2018-02-16 15:36:25 +01:00
Romain Vimont
9b056f5091 Replace SDL_net by custom implementation
SDL_net is not very suitable for scrcpy.

For example, SDLNet_TCP_Accept() is non-blocking, so we have to wrap it
by calling many SDL_Net-specific functions to make it blocking.

But above all, SDLNet_TCP_Open() is a server socket only when no IP is
provided; otherwise, it's a client socket. Therefore, it is not possible
to create a server socket bound to localhost, so it accepts connections
from anywhere.

This is a problem for scrcpy, because on start, the application listens
for nearly 1 second until it accepts the first connection, supposedly
from the device. If someone on the local network manages to connect to
the server socket first, then they can stream arbitrary H.264 video.
This may be troublesome, for example during a public presentation ;-)

Provide our own simplified API (net.h) instead, implemented for the
different platforms.
2018-02-16 00:56:58 +01:00
Romain Vimont
000ced9ba8 Refactor screencontrol to inputmanager
The "screen control" handled user input, which happened to be only
used to control the screen.

The controller and screen were passed to every function. Instead, group
them in a struct input_manager.

The purpose is to add a new shortcut to enable/disable FPS counter. This
feature is not related to "screen control", and will require access to
the "frames" instance.
2018-02-15 12:07:47 +01:00
Romain Vimont
42882702d7 Expose skip_frames as a build option
It can be initially configured by:

    meson builddir -Dskip_frames=false

Or on an existing builddir by:

    mesonconf builddir -Dskip_frames=false
2018-02-15 11:24:18 +01:00
Romain Vimont
38e6682875 Add FPS counter
Remove frame counter from scrcpy.c and add a new FPS counter, logging as
INFO the measured frame rate every second (on new frame).
2018-02-15 11:22:48 +01:00
Romain Vimont
0efa9305eb Require Meson 0.37
Older versions of Meson are too limited, and it's simple to install a
newer version ("pip3 install meson").
2018-02-14 14:03:56 +01:00
Romain Vimont
c2127d0819 Replace meson subprojects by subdir
Since Meson 0.44, subproject_dir may not be '.' anymore. This implies we
must move app/ and server/ to a subprojects/ directory, which requires
to also change some gradle files.

Instead, just use subdir(), with options to disable building of the app
or the server.
2018-02-14 14:03:56 +01:00
Romain Vimont
ff94462d8a Refactor build system
The client was built with Meson, the server with Gradle, and were run by
a Makefile.

Add a Meson script for the server (which delegates to Gradle), and a
parent script to build and install both the client and the server to the
system, typically with:

    meson --buildtype release build
    cd build
    ninja
    sudo ninja install

In addition, use a separate Makefile to build a "portable" version of
the application (where the client expects the server to be in the
current directory). Typically:

    make release-portable
    cd dist/scrcpy
    ./scrcpy

This is especially useful for Windows builds, which are not "installed".
2018-02-14 09:23:14 +01:00
Romain Vimont
396df8a9d8 Provide config.h.in for old meson versions
The current meson version is able to generate a config.h from a
configuration data object without any template.

However, older versions of meson require a template, so provide it for
compatibility.
2018-02-13 10:24:02 +01:00
Romain Vimont
d45ef1a295 Do not use too recent set_quoted()
Old versions of meson do not support set_quoted(). Replace the call by
the old-fashioned manual quotation.
2018-02-12 17:27:25 +01:00
Romain Vimont
4dbc450d01 Enable debug logs only for debug builds
In release mode, use the default log priorities.
2018-02-12 14:17:29 +01:00
Romain Vimont
e8dfb723af Move control-related code to screencontrol.c
Move the code handling user input from scrcpy.c to a separate file,
screencontrol.c.
2018-02-08 18:14:50 +01:00
Romain Vimont
3b06e7d500 Move device-related code to device.c
Move the code to read the initial device info from scrcpy.c to a
separate file, device.c.
2018-02-08 17:40:09 +01:00
Romain Vimont
6c578b5caa Move screen-related code to screen.c
The file scrcpy.c contains too many different things in addition to the
main logic, so move the screen code to a separate file, screen.c.
2018-02-08 15:43:28 +01:00
Romain Vimont
ffae15e36a Rename control to controller
The struct decoder is defined in decoder.h.

For naming consistency, define the struct controller in controller.h.
2018-02-08 13:26:01 +01:00
Romain Vimont
9f6464acff Expose application version
Expose scrcpy version via -v or --version.
2018-02-07 15:41:59 +01:00
Romain Vimont
8d30d40b79 Make SKIP_FRAMES a compilation flag
The skip_frames flag was a non-configurable runtime flag. Since it is
not exposed to the user, there is no need for a (possible) runtime cost.

For testing purpose, we still want it to be configurable, so make it a
compilation flag.
2018-02-07 15:40:24 +01:00
Romain Vimont
53ff1aa410 Use meson to configure default values
Make meson generate config.h with configured values.
2018-02-07 12:09:10 +01:00
Romain Vimont
71c2bfdd22 Parse XPM without SDL_image
We encounter some problems with SDL2_image on MSYS2 (Windows), so
implement our own XPM parsing which does not depend on SDL_image.

The input XPM is considered safe (it's in our source repo), so do not
check XPM format errors. This implies that read_xpm() is not safe to
call on any unsafe input.

Although less straightforward, use SDL_CreateRGBSurfaceFrom() instead of
SDL_CreateRGBSurfaceWithFormatFrom() because it is available with SDL
versions older than 2.0.5.
2018-02-05 19:24:33 +01:00
Romain Vimont
52c89c7afb Add window icon
Add a bugdroid icon loaded from an XPM.
2018-02-05 14:46:00 +01:00
Romain Vimont
2c35220618 Rename screen -> scrcpy -> main
Rename scrcpy.c to main.c (this file handles the command line parsing),
and screen.c to scrcpy.c (it exposes the entry point scrcpy()).
2018-01-23 16:44:59 +01:00
Romain Vimont
7d67696b7e Extract server-related functions
To lighten screen.c, move start_server() and stop_server() to a separate
file.
2018-01-22 11:29:44 +01:00
Romain Vimont
52af91f6b0 Add unit tests for control event serialization
Test serialization of the 4 types of events (keycode, text, mouse,
scroll).
2018-01-19 16:55:39 +01:00
Romain Vimont
f75c404a26 Add tests for strutil
Test our custom string handling functions.
2018-01-18 17:25:13 +01:00
Romain Vimont
cabb102a04 Implement keyboard/mouse control
To control the device from the computer:
 - retrieve mouse and keyboard SDL events;
 - convert them to Android events;
 - serialize them;
 - send them on the same socket used by the video stream (but in the
 opposite direction);
 - deserialize the events on the Android side;
 - inject them using the InputManager.
2018-01-18 17:25:13 +01:00
Romain Vimont
95591d2938 Move platform specific to sys/
Move unix/ and win/ to sys/, so that we can use android/ for android
headers without confusion.
2018-01-04 10:22:09 +01:00
Romain Vimont
d5b349f670 Do not inline lockutil functions
This duplicates chars in the final binary.
2017-12-18 11:07:42 +01:00
Romain Vimont
54d9148a36 Initial commit
Start a new clean history from here.
2017-12-12 15:25:15 +01:00