Romain Vimont
4fef4e0484
Compute relative PTS on the client-side
...
The PTS received by MediaCodec are expressed relative to an arbitrary
clock origin. We consider the PTS of the first frame to be 0, and the
PTS of every other frame is relative to this first PTS (note that the
PTS is only used for recording, it is ignored for mirroring).
For simplicity, this relative PTS was computed on the server-side.
To prepare support for multiple stream (video and audio), send the
packet with its original PTS, and handle the PTS offset on the
client-side (by the recorder).
Since we can't know in advance which stream will produce the first
packet with the lowest PTS (a packet received later on one stream may
have a PTS lower than a packet received earlier on another stream),
computing the PTS on the server-side would require unnecessary waiting.
2023-02-01 21:56:43 +01:00
Romain Vimont
07806ba915
Retry on spurious error
...
MediaCodec may fail spuriously, typically when stopping an encoding and
starting a new one immediately (for example on device rotation).
In that case, retry a few times, in many cases it should work.
Refs #3693 <https://github.com/Genymobile/scrcpy/issues/3693 >
2023-01-30 20:55:51 +01:00
Romain Vimont
a52053421a
Extract retry handling
...
Move the code to downscale and retry on error out of the catch-block.
Refs 26b4104844
2023-01-29 14:49:36 +01:00
Romain Vimont
a9b2697f3e
Move local variables declarations
...
This makes it clear that these local variables are only passed to
setDisplaySurface().
2023-01-27 22:43:16 +01:00
Romain Vimont
b53d2c66e0
Remove useless setSize() method
...
Inline its content. It makes the logic of internalStreamScreen() more
readable (it reduces the number of indirections).
2023-01-27 22:39:28 +01:00
Romain Vimont
6cccf3ab2a
Remove useless configure() method
...
Inline its single call.
2023-01-27 22:38:37 +01:00
Romain Vimont
52f85fd6f1
Keep the same MediaCodec instance across sessions
...
Calling codec.reset() is sufficient.
2023-01-27 22:31:09 +01:00
Romain Vimont
91c69ad95c
Remove useless destroyDisplay() method
...
The method made exactly one simple call. Just make the call directly.
2023-01-27 22:28:11 +01:00
Romain Vimont
75d7c01a0c
Keep the same display binder across sessions
...
Do not destroy/recreate the display when starting a new encoding session
(on device rotation for example).
2023-01-27 22:26:01 +01:00
Romain Vimont
74d32e612d
Terminate loop explicitly on interrupted
...
Make explicit that the loop terminates when the current thread is
interrupted.
2023-01-27 22:20:35 +01:00
Romain Vimont
bdba554118
Use Java lambdas where possible
2023-01-27 22:16:36 +01:00
Romain Vimont
234ad7ee78
Support Java lambdas in build_without_gradle.sh
...
Building Java source code using lambdas requires core-lambda-stubs.jar.
Refs #3657 <https://github.com/Genymobile/scrcpy/issues/3657 >
2023-01-27 22:08:25 +01:00
Romain Vimont
8cbbcc939f
Add missing final modifiers
2023-01-27 22:08:17 +01:00
Romain Vimont
b22810b17c
Use try-with-resources
...
Replace an explicit try-finally by a try-with-resources block.
2023-01-27 21:59:26 +01:00
Romain Vimont
4315be1648
Use random name for device socket
...
For the initial connection between the device and the computer, an adb
tunnel is established (with "adb reverse" or "adb forward").
The device-side of the tunnel is a local socket having the hard-coded
name "scrcpy". This may cause issues when several scrcpy instances are
started in a few seconds for the same device, since they will try to
bind the same name.
To avoid conflicts, make the client generate a random UID, and append
this UID to the local socket name ("scrcpy_01234567").
2023-01-27 21:51:59 +01:00
Romain Vimont
74e3f8b253
Add random util
...
Add a user-friendly tool to generate random numbers.
2023-01-27 19:26:19 +01:00
Romain Vimont
059ec45f82
Add jrand48()/nrand48() compat functions
...
These functions are not available on all platforms.
2023-01-26 18:11:23 +01:00
Romain Vimont
e6cd42355b
Use separate gen dir to build without gradle
...
The generated source files were written to the classes dir. Use a
separate gen dir instead.
2023-01-26 10:44:31 +01:00
Romain Vimont
bf8696d02e
Avoid unnecessary copy on config packets demuxing
...
Use av_packet_ref() to reference the packet without copy.
This also simplifies the logic, by making the "offset" variable and the
memcpy() call local to the if-block.
2023-01-02 16:18:23 +01:00
Romain Vimont
d8c2fe6ef2
Revert "Remove continuous resizing workaround for Windows"
...
This reverts commit 18082f6069 .
I can't reproduce, but it seems the workaround improves the behavior on
some Windows versions.
Fixes #3640 <https://github.com/Genymobile/scrcpy/issues/3640 >
Refs #3458 <https://github.com/Genymobile/scrcpy/issues/3458 >
2022-12-26 12:42:59 +01:00
Romain Vimont
54c7baceac
Use "meson setup" from install_release.sh
...
Refs 64821466a1
2022-12-22 13:07:07 +01:00
Romain Vimont
4c43784fd1
Update links to v1.25
2022-12-22 12:44:01 +01:00
Romain Vimont
fe21158c20
Bump version to 1.25
2022-12-22 12:33:29 +01:00
Romain Vimont
8e0c899218
Upgrade FFmpeg (5.1.2) for Windows 64-bit
...
Use the latest version of FFmpeg in Windows 64-bit releases.
2022-12-22 12:33:08 +01:00
Romain Vimont
725a922271
Upgrade SDL (2.26.1) for Windows
...
Include the latest version of SDL in Windows releases.
2022-12-22 12:29:08 +01:00
Romain Vimont
b5773a6fe8
Upgrade platform-tools (33.0.3) for Windows
...
Include the latest version of adb in Windows releases.
2022-12-22 12:29:08 +01:00
Romain Vimont
67fb457dcb
Merge branch 'master' into dev
2022-12-22 12:29:00 +01:00
Romain Vimont
18082f6069
Remove continuous resizing workaround for Windows
...
It turns out that the workaround only worked for MacOS.
Refs #3458 <https://github.com/Genymobile/scrcpy/issues/3458 >
Refs SDL/#1059 <https://github.com/libsdl-org/SDL/issues/1059 >
2022-12-21 22:06:43 +01:00
Romain Vimont
8b38b11875
Add parent directory in release zipfile
...
This avoids to mistakenly extract all the files in the current
directory.
2022-12-21 13:31:18 +01:00
Romain Vimont
64821466a1
Use "meson setup"
...
This fixes the following warning:
> WARNING: Running the setup command as `meson [options]` instead of
> `meson setup [options]` is ambiguous and deprecated.
2022-12-21 13:29:27 +01:00
Romain Vimont
82cb8ab870
Adapt ClipboardManager for Android 13
...
A new "attributionTag" parameter has been added to the methods
getPrimaryClip(), setPrimaryClip() and addPrimaryClipChangedListener()
of IClipboard.aidl.
Refs <https://android.googlesource.com/platform/frameworks/base.git/+/0e3e509b3bf4d561c26d87213387a290dfd688e3%5E%21/ >
Fixes #3497 <https://github.com/Genymobile/scrcpy/issues/3497 >
2022-12-21 13:28:22 +01:00
Romain Vimont
b51841e85d
Upgrade junit to 4.13.2
2022-12-21 13:28:22 +01:00
Romain Vimont
bd1deffa70
Use current adb port (if any) for --tcpip
...
If the current adb port is not 5555 (typically 0 because it is not in
TCP/IP mode), --tcpip automatically executes (among other commands):
adb tcpip 5555
In case adb was already listening on another port, this command forced
to listen on 5555, and the connection should still succeed.
But this reconfiguration might be inconvenient for the user. If adb is
already in TCP/IP mode, use the current enabled port without
reconfiguration.
Fixes #3591 <https://github.com/Genymobile/scrcpy/issues/3591 >
2022-12-02 19:09:53 +01:00
Romain Vimont
6469b55861
Fix CommandParserTest code style
...
Make checkstyle happy.
2022-11-24 09:27:10 +01:00
Romain Vimont
c00a9ead5e
Always use --key=value in README
...
Mandatory arguments may be passed in either of these two forms:
1. --key value
2. --key=value
Optional argument may only be passed in the second form.
For consistency, always document using --key=value.
Refs f76fe2c0d4
2022-11-17 09:27:05 +01:00
Romain Vimont
b62424a98a
Build log.c for test_cli
...
On Windows, sc_log_windows_error() is called from net.c, so log.c must
also be compiled.
Fixes #3542 <https://github.com/Genymobile/scrcpy/issues/3542 >
2022-10-19 15:17:43 +02:00
Romain Vimont
ffc7b91693
Add missing include <string.h> for strlen()
2022-10-19 15:14:56 +02:00
Romain Vimont
cb46e4a64a
Add missing include <string.h> for memmove()
2022-10-19 15:13:55 +02:00
Romain Vimont
40644994e8
Make ServiceManager and Settings methods static
...
There were exactly one instance of ServiceManager and Settings, stored
in Device.
Since a Device instance is not created by the CleanUp executable, it was
not straightforward to call wrapper methods on cleanup.
Remove this artificial restriction and expose them publicly via static
methods (this is equivalent to expose a singleton, but less verbose).
2022-10-02 17:57:35 +02:00
Romain Vimont
7505f7117e
Fix typo in logs
2022-09-27 14:12:37 +02:00
Romain Vimont
00e9e69c2a
Use /dev/null instead of closing fds
...
Some adb commands do not like when stdin, stdout or stderr are closed
(they hang forever). Open /dev/null for each.
2022-09-25 15:42:33 +02:00
Romain Vimont
4a5cdcd390
Extract $BUILD_TOOLS_DIR
...
In the script to build without gradle, the build-tools full path is used
at several places. Use a separate variable for readability.
2022-09-25 14:26:07 +02:00
Romain Vimont
e5e210506f
Add scrcpy-console.desktop
...
Add a launcher which opens a terminal, and keep it open in case of
errors (so that the user has time to read error messages).
The behavior is the same as scrcpy-console.bat on Windows.
PR #3351 <https://github.com/Genymobile/scrcpy/pull/3351 >
2022-09-09 19:06:29 +02:00
Romain Vimont
c1ec1d1023
Replace hardcoded 'share/' by datadir variable
...
Meson defines a variable for the data directory.
PR #3351 <https://github.com/Genymobile/scrcpy/pull/3351 >
2022-09-09 19:06:29 +02:00
Romain Vimont
0a0a446ea6
Upgrade Android SDK to 33
2022-09-02 14:42:37 +02:00
Romain Vimont
fccfc43b9e
Upgrade gradle build tools to 7.2.2
...
Plugin version 7.2.2.
Gradle version 7.3.3.
Refs: <https://developer.android.com/studio/releases/gradle-plugin#updating-gradle >
2022-09-02 14:40:16 +02:00
Romain Vimont
121bb71dfe
Move from jcenter() to mavenCentral()
...
Refs <https://developer.android.com/studio/build/jcenter-migration >
Refs <https://jfrog.com/blog/into-the-sunset-bintray-jcenter-gocenter-and-chartcenter/ >
2022-09-02 14:31:15 +02:00
Romain Vimont
1f138aef41
Add conversion from float to fixed-point i16
...
To encode float values between -1 and 1.
PR #3369 <https://github.com/Genymobile/scrcpy/pull/3369 >
2022-08-28 15:23:08 +02:00
Romain Vimont
1ab6c19486
Add unit test for float encoding
...
PR #3369 <https://github.com/Genymobile/scrcpy/pull/3369 >
2022-08-28 15:23:08 +02:00
Romain Vimont
fd3483c837
Extract conversion from float to u16 fixed-point
...
PR #3369 <https://github.com/Genymobile/scrcpy/pull/3369 >
2022-08-28 15:23:08 +02:00
Romain Vimont
041cdf6cf5
Rename buffer_util.h to binary.h
...
It will allow to expose more binary util functions not related to
buffers.
PR #3369 <https://github.com/Genymobile/scrcpy/pull/3369 >
2022-08-28 15:23:08 +02:00
Romain Vimont
136ab8c199
Add unit test for float decoding
...
PR #3369 <https://github.com/Genymobile/scrcpy/pull/3369 >
2022-08-28 15:23:08 +02:00
Romain Vimont
3848ce86f1
Extract conversion from u16 fixed-point to float
...
PR #3369 <https://github.com/Genymobile/scrcpy/pull/3369 >
2022-08-28 15:23:08 +02:00
Romain Vimont
5b8e9aa0e9
Move toUnsigned() to a Binary util class
...
PR #3369 <https://github.com/Genymobile/scrcpy/pull/3369 >
2022-08-28 15:23:08 +02:00
Romain Vimont
3a66b5fd01
Remove deprecated meson.source_root()
...
This method is deprecated since Meson 0.56.0:
<https://mesonbuild.com/Release-notes-for-0-56-0.html#mesonbuild_root-and-mesonsource_root-are-deprecated >
We could replace it with meson.project_source_root(), but this would
make Meson 0.56 or above mandatory. Since the path in always computed
from the server/ directory, just add '..' to reference the root project
directory.
Refs c456e38264
2022-08-28 15:16:31 +02:00
Romain Vimont
72ba913324
Move README and FAQ translations to the wiki
...
This lowers the barrier to contribute to translations, and frees up my
maintenance time used to review and merge translations and their updates
in many languages.
2022-08-28 15:13:03 +02:00
Romain Vimont
77ebe786ea
Fix FAQ formatting
2022-08-21 13:52:51 +02:00
Romain Vimont
d19606eb0c
Rename net_listen() parameter
...
For consistency with net_accept(), which necessarily uses a server
socket, name the net_listen() parameter "server_socket".
2022-08-17 16:40:45 +02:00
Romain Vimont
d23b3e88a4
Replace '%g' by '%f' as printf format
...
For some reason, '%g' does not work correctly with MinGW.
Refs #3369 <https://github.com/Genymobile/scrcpy/pull/3369 >
PR #3399 <https://github.com/Genymobile/scrcpy/pull/3399 >
2022-08-03 23:25:09 +02:00
Romain Vimont
a47848f304
Detect Windows using _WIN32 in network util
...
For consistency, always use _WIN32 instead of a mix of __WINDOWS__ and
_WIN32.
2022-07-27 14:54:27 +02:00
Romain Vimont
db8c1ce8e1
Fix protocol documentation in comments
...
Flags were in the correct order in the schema, but their description
were reversed.
2022-07-20 11:41:04 +02:00
Romain Vimont
4aeb78ece2
Add missing allocation failure check
2022-07-19 12:17:02 +02:00
Romain Vimont
396e4bd925
Add missing LOG_OOM() on malloc failure
2022-07-19 12:15:06 +02:00
Romain Vimont
7f2f5950f2
Remove useless dependencies reference
...
There is no libs/ directory with local jar files.
2022-06-20 21:23:05 +02:00
Romain Vimont
ed84e18b1a
Document envvars for all platforms
...
Document how to set environment variables from the terminal for bash,
cmd and PowerShell.
2022-06-17 08:44:17 +02:00
Romain Vimont
a83c3e30f3
Fix environment variable configuration in FAQ
...
In bash, the variable is set using "export".
2022-06-17 08:36:58 +02:00
Romain Vimont
af4b7855e1
Remove unused stream.h
...
The file was not removed by 7dec225ceb .
2022-06-09 15:02:42 +02:00
Romain Vimont
b1d8c72780
Rename function to simplify
...
For consistency with sc_adb_parse_device(), do not include "from_output"
in the function name.
2022-06-09 15:02:42 +02:00
Romain Vimont
55e65fa270
Add missing return 0 in tests
2022-06-09 15:02:42 +02:00
Romain Vimont
69fb5f6ee1
Fix function declarations
...
Add missing void in function parameters list.
2022-06-09 15:02:42 +02:00
Romain Vimont
faf4535487
Reduce SHA-256 size in README and BUILD
...
This avoids breaking the page layout on GitHub.
2022-04-28 21:34:56 +02:00
Romain Vimont
3a99e129e6
Update links to v1.24
2022-04-28 21:03:03 +02:00
Romain Vimont
ef13d394fd
Bump version to 1.24
2022-04-28 20:46:28 +02:00
Romain Vimont
0049893e10
Merge branch 'master' into dev
2022-04-28 20:46:19 +02:00
Romain Vimont
2f038c834a
Revert "Make OTG window resizable"
...
On Windows and macOS, resizing blocks the event loop. Handling it
properly would require the same workaround as done in screen.c.
This reverts commit 436b368f9d .
2022-04-28 20:45:46 +02:00
Romain Vimont
76b3fcf986
Fix inverted check
...
SDL_RenderSetLogicalSize() returns 0 on success.
Refs fc8942aa03
2022-04-28 20:45:46 +02:00
Romain Vimont
05d84084ef
Fix release script for platform-tools 33.0.1
...
These paths were not updated by commit
b8d78743f7 .
2022-04-28 20:45:38 +02:00
Romain Vimont
471a360099
Use quotes for commands in documentation
2022-04-28 19:50:35 +02:00
Romain Vimont
349dcd8e7b
Update installed files list in BUILD documentation
2022-04-28 19:49:34 +02:00
Romain Vimont
f9e3275d4e
Upgrade FFmpeg (5.0.1) for Windows 64-bit
...
Use the latest version of FFmpeg in Windows 64-bit releases.
2022-04-28 19:32:14 +02:00
Romain Vimont
91706ae3d0
Upgrade SDL (2.0.22) for Windows
...
Include the latest version of SDL in Windows releases.
2022-04-28 19:23:59 +02:00
Romain Vimont
854a56e588
Enable linear filtering in OTG mode
...
This improves the icon quality with non-standard window size.
PR #3219 <https://github.com/Genymobile/scrcpy/pull/3219 >
2022-04-28 19:18:16 +02:00
Romain Vimont
436b368f9d
Make OTG window resizable
...
PR #3219 <https://github.com/Genymobile/scrcpy/pull/3219 >
2022-04-28 19:18:12 +02:00
Romain Vimont
fc8942aa03
Apply requested window size in OTG mode
...
Fixes #3099 <https://github.com/Genymobile/scrcpy/issues/3099 >
PR #3219 <https://github.com/Genymobile/scrcpy/pull/3219 >
2022-04-28 19:18:09 +02:00
Romain Vimont
c6d9711109
Create OTG window with HIGHDPI flag
...
This will avoid poor quality with HiDPI displays.
PR #3219 <https://github.com/Genymobile/scrcpy/pull/3219 >
2022-04-28 19:17:49 +02:00
Romain Vimont
0fca2ad830
Add option to not power on on start
...
By default, on start, the device is powered on. To prevent this
behavior, add a new option --no-power-on.
Fixes #3148 <https://github.com/Genymobile/scrcpy/issues/3148 >
PR #3210 <https://github.com/Genymobile/scrcpy/pull/3210 >
2022-04-28 19:12:52 +02:00
Romain Vimont
326897a0d4
Add missing mouse shortcuts in --help
...
Document 4th-click and 5th-click shortcuts.
Fixes #3122 <https://github.com/Genymobile/scrcpy/issues/3122 >
2022-04-25 18:35:06 +02:00
Romain Vimont
4db97531e8
Upgrade libusb (1.0.26) for Windows
...
Upgrade and enable libusb support for Windows 32-bit builds.
Refs #3011 <https://github.com/Genymobile/scrcpy/pull/3011 >
Fixes #3204 <https://github.com/Genymobile/scrcpy/issues/3204 >
PR #3206 <https://github.com/Genymobile/scrcpy/pull/3206 >
2022-04-22 13:34:58 +02:00
Romain Vimont
b8d78743f7
Upgrade platform-tools (33.0.1) for Windows
...
PR #3206 <https://github.com/Genymobile/scrcpy/pull/3206 >
2022-04-22 13:34:11 +02:00
Romain Vimont
6a4a4a283d
Remove obsolete alternative injection method
...
The previous commit replaced the IInterface instance (the "input"
service) by the InputManager instance (retrieved by
InputManager.getInstance()).
Both define an "injectInputEvent" method, but the alternate version
(probably) does not concern the InputManager.
This reverts commit b7a06278fe .
PR #3190 <https://github.com/Genymobile/scrcpy/pull/3190 >
2022-04-22 09:52:41 +02:00
Romain Vimont
7d8b72d4a6
Adapt event injection to Android 13
...
Using the "input" service results in a permission error in Android 13.
Use the InputManager instance (retrieved by InputManager.getInstance())
instead.
Fixes #3186 <https://github.com/Genymobile/scrcpy/issues/3186 >
PR #3190 <https://github.com/Genymobile/scrcpy/pull/3190 >
2022-04-22 09:52:41 +02:00
Romain Vimont
fa5b2a29e9
Add missing SC_ prefix to header guards
2022-04-12 23:59:01 +02:00
Romain Vimont
0c94887075
Add missing include
...
Refs c3d45c8397
2022-04-12 23:51:05 +02:00
Romain Vimont
88543cb545
Fix icon path in ./run
...
The data/ directory has been moved to app/data/.
Refs 36c75e15b8
2022-03-30 14:00:05 +02:00
Romain Vimont
aaf3869a54
Fix OpenGL ES prefix skip
2022-03-30 12:01:01 +02:00
Romain Vimont
c3d45c8397
Consider emulators as TCP/IP devices
...
Emulators were wrongly considered as USB devices, so they were selected
using -d instead of -e (which was inconsistent with the adb behavior).
Refs #3005 <https://github.com/Genymobile/scrcpy/issues/3005 >
Refs #3137 <https://github.com/Genymobile/scrcpy/issues/3137 >
2022-03-22 21:08:08 +01:00
Romain Vimont
e56f2ac7a9
Log an error on unexpected device state
...
Refs #3129 <https://github.com/Genymobile/scrcpy/issues/3129 >
2022-03-20 14:56:52 +01:00
Romain Vimont
4ce7af42c6
Use $ANDROID_SERIAL if no selector is specified
...
Like adb, read the ANDROID_SERIAL environment variable to select a
device by serial if no explicit selection (-s, -d, -e or --tcpip=<addr>)
is provided via the command line.
Fixes #3111 <https://github.com/Genymobile/scrcpy/issues/3111 >
PR #3113 <https://github.com/Genymobile/scrcpy/pull/3113 >
2022-03-15 08:32:34 +01:00
Romain Vimont
b1dbc30072
Document exit status in --help
...
Refs #3085 <https://github.com/Genymobile/scrcpy/pull/3085 >
2022-03-10 09:13:21 +01:00
Romain Vimont
1f4c801f3c
Report server connection state
...
We must distinguish 3 cases for await_for_server():
- an error occurred
- no error occurred, the device is connected
- no error occurred, the device is not connected (user requested to
quit)
For this purpose, use an additional output parameter to indicate if the
device is connected (only set when no error occurs).
Refs #3085 <https://github.com/Genymobile/scrcpy/pull/3085 >
2022-03-06 22:16:13 +01:00