Commit graph

472 commits

Author SHA1 Message Date
Yu-Chen Lin
f9786e5034 Get env in windows correctly
Signed-off-by: Yu-Chen Lin <npes87184@gmail.com>
Signed-off-by: Romain Vimont <rom@rom1v.com>
2019-12-14 18:47:54 +01:00
Yu-Chen Lin
78a320a763 Fix utf-8 char path in windows
The file 'E:\安安\scrcpy-win64-v1.12.1-1-g31bd950\scrcpy-server'
exists, however, it will show msg as follow:

    INFO: scrcpy 1.12.1 <https://github.com/Genymobile/scrcpy>
    stat: No such file or directory
    ERROR: 'E:\安安\scrcpy-win64-v1.12.1-1-g31bd950\scrcpy-server' does
    not exist or is not a regular file
    Press any key to continue...

This patch fixes it.

Signed-off-by: Yu-Chen Lin <npes87184@gmail.com>
Signed-off-by: Romain Vimont <rom@rom1v.com>
2019-12-14 18:47:30 +01:00
Romain Vimont
7d5845196e Fix memory leak on portable builds
The function get_server_path() sometimes returned an owned string,
sometimes a non-owned string.

Always return an allocated (owned) string, and free it after usage.
2019-12-14 18:23:25 +01:00
Romain Vimont
6965d051ae Limit bitrate range to 31 bits integer
A proper solution could be to use "long long" instead (guaranteed to be
at least 64 bits), but it adds its own problems (e.g. "%lld" is not
supported as a printf format on all platforms).

In practice, we don't need such high values, so keep it simple.

Fixes #995 <https://github.com/Genymobile/scrcpy/issues/995>
2019-12-10 09:28:27 +01:00
Romain Vimont
e4cebc8d4c Do not build tests in release mode
Assertions would not be executed.

And as a side effect, it causes "unused variable" warnings.
2019-12-09 23:24:39 +01:00
Romain Vimont
ba1b36758e Define SDL_MAIN_HANDLED in all tests
Each test defines its own main() function. If this flag is not set, then
SDL redefines it to SDL_main(), causing compilation failures.
2019-12-09 23:24:39 +01:00
Romain Vimont
ad92a192b5 Fix meson.build codestyle 2019-12-09 23:00:55 +01:00
Romain Vimont
242e57d69b Merge branch 'master' into dev 2019-12-09 22:37:20 +01:00
Romain Vimont
024c2f7e6b Configure log priority early
The log priority must be configured before parsing command-line
arguments, in order to get logs as expected.
2019-12-09 22:31:14 +01:00
Romain Vimont
1eae139b6e Add missing consts
String parsing functions should not be able to modify their input.
2019-12-09 22:30:48 +01:00
Romain Vimont
419c869c9c Use ARRAY_LEN() macro in tests 2019-12-09 20:59:11 +01:00
Romain Vimont
929bf48c7e Add tests for command-line parsing 2019-12-08 23:19:01 +01:00
Romain Vimont
d950383b72 Move command-line parsing to a separate file 2019-12-08 23:18:57 +01:00
Romain Vimont
61274a7cdb Factorize integer argument parsing
Add util functions for integer parsing (with tests), and factorize
integer argument parsing to avoid code duplication.
2019-12-08 21:19:53 +01:00
Romain Vimont
64bcac9157 Refuse to push a non-regular file server
If SCRCPY_SERVER_PATH points to a directory, then a directory will be
pushed to /data/local/tmp/scrcpy-server.jar.

When executing it, app_process will just abort and leave the directory
on the device, causing scrcpy to always fail.

To avoid the problem, check that the server is a regular file before
pushing it.

Closes #956 <https://github.com/Genymobile/scrcpy/issues/956>
2019-12-05 21:07:11 +01:00
Romain Vimont
3259c60b22 Fix test compilation on mingw
Including SDL2/SDL.h redefines main to SDL_main by default.
2019-12-05 21:06:49 +01:00
Romain Vimont
eb0f339271 Add shortcut to rotate screen
On Ctrl+r, disable auto-rotation (if enabled), set the screen rotation
and re-enable auto-rotation (if it was enabled).

Closes #11 <https://github.com/Genymobile/scrcpy/issues/11>
2019-12-04 22:03:25 +01:00
Yu-Chen Lin
fbc86a616c Correct coding style
Signed-off-by: Yu-Chen Lin <npes87184@gmail.com>
2019-12-04 19:24:59 +01:00
Yu-Chen Lin
b2bf25c52c Add test_buffer_util
Signed-off-by: Yu-Chen Lin <npes87184@gmail.com>
2019-12-04 19:24:59 +01:00
Yu-Chen Lin
5eeaed09ae Add test_strquote
Signed-off-by: Yu-Chen Lin <npes87184@gmail.com>
2019-12-04 19:24:59 +01:00
Romain Vimont
3100533e56 Fix "natural scrolling"
> Movements down (scroll backward) generate negative y values and up
> (scroll forward) generate positive y values.

> If direction is SDL_MOUSEWHEEL_FLIPPED the values in x and y will be
> opposite. Multiply by -1 to change them back.

<https://wiki.libsdl.org/SDL_MouseWheelEvent#Remarks>

The x and y values already take the scrolling configuration into
account. Reversing the values when the direction is flipped cancels the
scrolling configuration.

Therefore, just ignore the direction field.

Fixes <https://github.com/Genymobile/scrcpy/issues/966>
2019-12-03 21:10:43 +01:00
Romain Vimont
86fcd89d80 Fix max size default value
Suggested-by: jurkov

Closes <https://github.com/Genymobile/scrcpy/issues/978>
2019-12-03 12:07:36 +01:00
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.
2019-11-27 21:40:58 +01:00
Romain Vimont
d0f5a7fd9f Remove unused includes
No mutex is used in decoder.c and stream.c.
2019-11-27 21:40:54 +01:00
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.
2019-11-27 21:19:46 +01:00
Romain Vimont
b5ebb234dd Replace BUILD_DEBUG by NDEBUG
Use the "standard" NDEBUG definition, which is used by assert().
2019-11-27 21:11:52 +01:00
Romain Vimont
73e8ec1b35 Remove path argument from cmd_execute()
It is always equal to argv[0] (or not used on Windows).
2019-11-27 21:11:52 +01:00
Romain Vimont
8dc11a0286 Fix warnings on Windows
fix warnings reported with -Dwarning_level=2 on Windows.
2019-11-27 21:11:52 +01:00
Romain Vimont
06104a701b Fix windows build
Utilities have been moved to util/, but includes had not been updated
in Windows-specific files.

Ref: dfd0707a29
2019-11-27 13:25:56 +01:00
yangfl
8bc056b9c6 Fix manpage format 2019-11-27 10:58:17 +01:00
Romain Vimont
31d9d56117 Fix warnings
Fix warnings reported with -Dwarning_level=2.
2019-11-26 09:10:41 +01:00
Romain Vimont
dfd0707a29 Move utilities to util/ 2019-11-24 11:53:23 +01:00
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>
2019-11-22 15:23:57 +01:00
Romain Vimont
c9d886f38b Use the existing constants for device server path 2019-11-22 15:16:00 +01:00
Romain Vimont
c2116082ab Remove deprecated options from help and manpage
Ref: ff061b4f30
2019-11-19 23:05:39 +01:00
Romain Vimont
3599fcaae5 Fix help for --window-width and --window-height
The default value is 0 (automatic), not -1.
2019-11-19 22:58:18 +01:00
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>
2019-11-19 12:22:11 +01:00
senta2006
7aed5d5b60 Fix typos
PR <https://github.com/Genymobile/scrcpy/pull/927>

Signed-off-by: Romain Vimont <rom@rom1v.com>
2019-11-18 17:45:52 +01:00
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>
2019-11-17 22:10:39 +01:00
Romain Vimont
1b78a77962 Fix error message 2019-11-17 22:08:34 +01:00
Romain Vimont
59073223aa Update manpage for --window-borderless option 2019-11-15 18:59:47 +01:00
Diego Fernando Díaz A
59bc5bc1f5 Add option to disable window decoration
Add --window-borderless parameter.

Signed-off-by: Romain Vimont <rom@rom1v.com>
2019-11-15 18:59:40 +01:00
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.
2019-11-15 18:52:58 +01:00
Romain Vimont
b6e2f8ae00 Update manpage for --window-{x,y} options 2019-11-15 18:50:49 +01:00
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>
2019-11-15 18:50:49 +01:00
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.
2019-11-13 16:14:46 +01:00
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>
2019-11-13 12:00:50 +01:00
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.
2019-11-11 21:49:23 +01:00
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>
2019-11-11 21:49:23 +01:00
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.
2019-11-11 15:02:26 +01:00