Romain Vimont
ebecbe6bc6
Fix inconsistent quotes
...
The encoder name started with a simple quote but ended with a
double quote. Use a single quote for both.
2023-02-19 16:18:19 +01:00
Romain Vimont
d5dff239c8
Suggest commands with an explicit '='
2023-02-19 16:18:19 +01:00
Romain Vimont
5cf86ef7ff
Move finally-block to fix deadlock on stop
...
DesktopConnection implements Closeable, so it is implicitly closed after
its try-with-resources block. Closing the DesktopConnection shutdowns
the sockets, so it is necessary in particular to wake up blocking read()
calls from the controller.
But the controller thread was joined before the DesktopConnection was
closed, causing a deadlock. To fix the problem, join the controller
thread only after the DesktopConnection is closed.
Refs 400a1c69b1
2023-02-19 15:59:05 +01:00
Romain Vimont
e02f30f895
Remove unnecessary error logs
...
When a call to a packet or frame sink fails, do not log the error on the
caller side: either the "failure" is expected (explicitly stopped) or it
must be logged by the packet or frame sink implementation.
2023-02-19 02:10:14 +01:00
Romain Vimont
25e2eb7d7c
Document default video codec
...
Mention the default option value, like for other commands.
2023-02-18 19:10:25 +01:00
Romain Vimont
280a9afda8
Fix command-line help typo
2023-02-18 18:11:34 +01:00
Romain Vimont
e91618586c
Prefix receiver by sc_
...
Like all other components in scrcpy.
2023-02-18 09:37:31 +01:00
Romain Vimont
680ddf64be
Fix demuxer error message
...
Now that there are several possible codecs, do not hardcode H.264 in the
error message.
Refs 3e517cd40e
2023-02-18 09:31:06 +01:00
Romain Vimont
f4e7085c34
Log non-EPIPE I/O exceptions
...
On close, the client closes the socket. This wakes up socket blocking
calls on the server-side, by throwing an exception. Since this exception
is expected, it was not logged.
However, other IOExceptions might occur, which must not be ignored. For
that purpose, log only IOException when they are not caused by an EPIPE
error.
2023-02-17 08:33:16 +01:00
Romain Vimont
439a1fd4ed
Rename 'uid' to 'scid'
...
A random identifier is generated to differentiate multiple running
scrcpy instances. Rename it from 'uid' to 'scid' (scrcpy id) not to
confuse it with Linux UID.
Fixes #3729 <https://github.com/Genymobile/scrcpy/issues/3729 >
Refs 4315be1648
2023-02-11 09:58:40 +01:00
Romain Vimont
49eb326ce9
Extract packet merging
...
Config packets must be prepended to the next media packet. Extract the
logic to a new sc_packet_merger helper to simplify the demuxer code.
2023-02-11 09:44:33 +01:00
Romain Vimont
f03f32267e
Remove unused parser
...
Since 1c02b58412 , the parser is not used
anymore.
2023-02-10 23:18:11 +01:00
Romain Vimont
45b2e6db5c
Log component stopped in finally clause
...
The message must be logged even when no exception occurs.
2023-02-10 19:06:17 +01:00
Romain Vimont
400a1c69b1
Join all threads before end of main
...
Some calls from separate threads may throw exceptions once the main()
method has returned.
2023-02-10 19:04:56 +01:00
Romain Vimont
730eb1086a
Properly report demuxer errors
...
All demuxer errors were reported as "device disconnected", even if the
failure was not related to device socket read.
2023-02-10 18:55:43 +01:00
Romain Vimont
4f9e9c6619
Prefix UI events constants by SC_
2023-02-10 18:55:43 +01:00
Romain Vimont
953edfd1df
Split codec_id reading
...
Receive codec id and convert it to AVCodecID separately.
This will allow the caller to distinguish between EOS and unknown codec
id.
2023-02-10 18:55:43 +01:00
Romain Vimont
230b8274b9
Fix error return value
...
The function returns an enum AVCodecID, not a bool.
2023-02-10 18:55:43 +01:00
Romain Vimont
40866ddc10
Fix demuxer error message
...
The message applies to all packets, not only config packets.
2023-02-10 18:55:39 +01:00
Romain Vimont
bd56c0abf7
Remove unused codec context
...
The demuxer does not need any codec context.
2023-02-10 18:46:01 +01:00
Romain Vimont
6524e90c68
Remove unused constant
...
This line was committed by error.
Refs 3e517cd40e
2023-02-07 23:11:42 +01:00
Romain Vimont
f2dee20a20
Set power mode on all physical displays
...
Android 10 and above support multiple physical displays. Apply power
mode to all of them.
Fixes #3716 <https://github.com/Genymobile/scrcpy/issues/3716 >
2023-02-06 11:07:14 +01:00
Romain Vimont
d2dce51038
Add support for AV1
...
Add option --codec=av1.
PR #3713 <https://github.com/Genymobile/scrcpy/pull/3713 >
2023-02-06 11:00:49 +01:00
Romain Vimont
4342c5637d
Add support for H265
...
Add option --codec=h265.
PR #3713 <https://github.com/Genymobile/scrcpy/pull/3713 >
Fixes #3092 <https://github.com/Genymobile/scrcpy/issues/3092 >
2023-02-06 11:00:49 +01:00
Romain Vimont
3e517cd40e
Add option to select video codec
...
Introduce the selection mechanism. Alternative codecs will be added in
further commits.
PR #3713 <https://github.com/Genymobile/scrcpy/pull/3713 >
2023-02-06 10:58:45 +01:00
Romain Vimont
f70f6cdd3e
Simplify server info initialization
...
Use sc_read16be() to read 16-bit integer fields.
2023-02-03 12:31:28 +01:00
Romain Vimont
87972e2022
Extract video streaming to a separate class
...
ScreenEncoder handled both capture/encoding and sending over the
network.
Move the streaming part to a separate VideoStreamer.
2023-02-03 12:31:28 +01:00
Romain Vimont
3aac74e9e9
Move variable assignment
...
Computing eof flag is not necessary if rotation changed.
2023-02-03 12:31:28 +01:00
Romain Vimont
1c82c3923d
Compute relative PTS on the client-side
...
The PTS received from 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-03 12:31:28 +01:00
Romain Vimont
36d656e91f
Improve workarounds call comments
2023-02-03 12:31:28 +01:00
Romain Vimont and Simon Chan
bdbf1f4eb7
Move Workarounds call
...
Workarounds are not specific to the screen encoder.
Co-authored-by: Simon Chan <1330321+yume-chan@users.noreply.github.com >
2023-02-03 12:31:28 +01:00
Romain Vimont
4177de5880
Do not expose controller threads
...
The way the controller executes its events asynchronously is an
implementation detail.
2023-02-03 12:31:28 +01:00
Romain Vimont
6a07e3d470
Fix manpage formatting
...
Only the option arguments must be underlined.
2023-02-03 12:31:28 +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