Romain Vimont
db5751a76a
Move previous packet to a local variable
...
It is only used from run_recorder().
2023-03-10 22:22:15 +01:00
Romain Vimont
b6744e7887
Move pts_origin to a local variable
...
It is only used from run_recorder().
2023-03-10 22:22:15 +01:00
Romain Vimont
181fb555bb
Change PTS origin type from uint64_t to int64_t
...
It is initialized from AVPacket.pts, which is an int64_t.
2023-03-10 22:22:15 +01:00
Romain Vimont
fa99763668
Fix --encoder documentation
...
Mention that it depends on the codec provided by --codec (which is not
necessarily H264 anymore).
2023-03-10 22:22:15 +01:00
Romain Vimont
9f8e96e895
Fix --no-clipboard-autosync bash completion
...
Fix typo.
2023-03-10 22:22:15 +01:00
Romain Vimont
c78254fcd1
Split server stop() and join()
...
For consistency with the other components, call stop() and join()
separately.
This allows to stop all components, then join them all.
2023-03-10 22:22:15 +01:00
Romain Vimont
e30e692b36
Print FFmpeg logs
...
FFmpeg logs are redirected to a specific SDL log category.
Initialize the log level for this category to print them as expected.
2023-03-10 22:22:15 +01:00
Romain Vimont
10e8295aea
Move FFmpeg callback initialization
...
Configure FFmpeg log redirection on start from a log helper.
2023-03-10 22:22:15 +01:00
Romain Vimont
f30fd963a1
Upgrade FFmpeg custom builds for Windows
...
Use a build which includes the pcm_s16le decoder, to support RAW audio.
Refs <https://github.com/rom1v/scrcpy-deps/commits/6.0-scrcpy-2 >
2023-03-10 22:22:15 +01:00
Romain Vimont
9d60d7880b
Upgrade FFmpeg (6.0) for Windows
...
Use the latest version (specifically built for scrcpy).
Refs <https://www.ffmpeg.org/download.html#release_6.0 >
2023-03-10 22:22:15 +01:00
Romain Vimont
0fc62bfcd6
Use minimal prebuilt FFmpeg for Windows
...
On the scrcpy-deps repo, I built FFmpeg 5.1.2 binaries for Windows with
only the features used by scrcpy.
For comparison, here are the sizes of the dll for FFmpeg 5.1.2:
- before: 89M
- after: 4.7M
It also allows to upgrade the old FFmpeg version (4.3.1) used for win32.
Refs <https://github.com/rom1v/scrcpy-deps >
Refs <https://github.com/Genymobile/scrcpy/issues/1753 >
2023-03-10 22:22:15 +01:00
Romain Vimont
a20615066d
Simplify libusb prebuilt scripts
...
In theory, include/ might be slightly different for win32 and win64
builds. Use each one separately to simplify.
2023-03-10 22:22:15 +01:00
Romain Vimont
b5d41ad4f6
Fix useless garbage initialization
...
The variable `p` was initialized with a garbage value (a `const char **`
casted to `char *`). Fortunately, it was never read.
Refs <https://github.com/Genymobile/scrcpy/issues/3765 >
2023-03-03 11:12:31 +01:00
Romain Vimont
389dd77b50
Fix MIN/MAX macros
...
Expressions like "x < MAX(y, z)" were broken.
2023-03-03 01:18:10 +01:00
Romain Vimont
3c3c07db05
Initialize server->serial in all cases
...
Running scrcpy --tcpip on a device already connected via TCP/IP did not
initialize server->serial.
As a consequence, in debug mode, an assertion failed:
scrcpy: ../app/src/server.c:770: run_server: Assertion
`server->serial' failed.
In release mode, scrcpy failed with this error:
adb: -s requires an argument
2023-02-28 12:34:34 +01:00
Romain Vimont
6b422e21bf
Fix error message on icon loading failure
2023-02-27 20:51:54 +01:00
Romain Vimont
8e8b039a63
Do not use avformat network
...
Scrcpy does not use FFmpeg network features. Initialize network locally
instead (useful only for Windows).
The include block has been moved to fix the following warning:
Please include winsock2.h before windows.h
2023-02-27 20:51:54 +01:00
Romain Vimont
0702be86d8
Accept Windows Sockets from version 1.1
...
Version 2.2 is probably not necessary (1.1 is the version required by
FFmpeg when network is enabled).
Refs <891ed24f77/libavformat/network.c (L63) >
Refs <https://learn.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-wsastartup >
2023-02-27 20:51:54 +01:00
Romain Vimont
0cea7fb24c
Fix WSAStartup() error check on Windows
2023-02-27 20:51:35 +01:00
Romain Vimont
3d10fbd9b4
Fix --bit-rate option in bash completion script
...
The option is --bit-rate, not --bitrate.
2023-02-21 19:50:01 +01:00
Romain Vimont
3e3756a323
Add auto-completion for --codec option
...
Add missing command to bash and zsh completion scripts.
2023-02-21 19:48:28 +01:00
Romain Vimont
5d6bcc5966
Use enum for long options constants
...
This avoids to manually assign values.
2023-02-21 19:47:27 +01:00
Romain Vimont
5973d4cdd7
Initialize mouse_input_mode explicitly
...
The explicit initialization was missing. It had no consequences because
SC_MOUSE_INPUT_MODE_INJECT == 0.
Fixes #3749 <https://github.com/Genymobile/scrcpy/issues/3749 >
2023-02-21 12:11:39 +01:00
Romain Vimont
0a151b96fe
Accept muxing AV1 into MP4 container
...
MP4 supports AV1.
Refs d2dce51038
2023-02-20 20:49:56 +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
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
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
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
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
6a07e3d470
Fix manpage formatting
...
Only the option arguments must be underlined.
2023-02-03 12:31:28 +01:00
Simon Chan
0afef0c634
Forward action button to device
...
On click event, only the whole buttons state was passed to the device.
In addition, on ACTION_DOWN and ACTION_UP, pass the button associated to
the action.
Refs #3635 <https://github.com/Genymobile/scrcpy/issues/3635 >
Co-authored-by: Romain Vimont <rom@rom1v.com >
Signed-off-by: Romain Vimont <rom@rom1v.com >
2023-01-30 20:57:54 +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
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