Romain Vimont
0ffcfa0f5c
Accept failure in rotation or fold registration
...
Do not make scrcpy fail if rotation or display fold listeners could not
be registered.
2023-06-22 00:52:54 +02:00
Romain Vimont
c0f3c080b6
Register DisplayFoldListener only for Android 10+
...
This listener does not exist on Android < 10, and it makes scrcpy fail.
2023-06-22 00:49:11 +02:00
Romain Vimont
d046678f85
Upgrade platform-tools (34.0.3) for Windows
...
Include the latest version of adb in Windows releases.
2023-06-22 00:10:37 +02:00
Romain Vimont
fae3fbc934
Update developer documentation
2023-06-22 00:03:26 +02:00
Romain Vimont
5061b7e02c
Fix build without gradle
...
Add missing class generation from IDisplayFoldListener.aidl.
Refs 24999d0d32
2023-06-22 00:03:26 +02:00
Romain Vimont
09009c2aa7
Upgrade SDL (2.28.0) for Windows
...
Include the latest version of SDL in Windows releases.
Fixes #3825 <https://github.com/Genymobile/scrcpy/issues/3825 >
Refs libsdl/#7478 <https://github.com/libsdl-org/SDL/issues/7478 >
2023-06-20 21:45:14 +02:00
Romain Vimont and Simon Chan
fb21bbf763
Add workarounds for Honor devices
...
Audio did not work on Honor devices.
To make it work, a system context must be set as a base context of
FakeContext (so that a PackageManager is available), and a current
Application and ActivityThread must be set.
These workarounds must not be applied for all devices, because they
might cause other issues.
Fixes #4015 <https://github.com/Genymobile/scrcpy/issues/4015 >
Refs #3085 <https://github.com/Genymobile/scrcpy/issues/3805 >
Co-authored-by: Simon Chan <1330321+yume-chan@users.noreply.github.com >
2023-06-19 18:45:40 +02:00
Romain Vimont
0f1afff7a6
Move workarounds execution
...
Expose a single public static method in the Workarounds class to apply
all necessary workarounds.
2023-06-19 18:45:11 +02:00
Romain Vimont
48a00fb481
Log device BRAND
...
The BRAND value is not always the same as the MANUFACTURER value.
2023-06-17 00:25:01 +02:00
Romain Vimont
3b7e2ca9c8
Fix lint warning
...
Suppress lint "DiscouragedPrivateApi" in Workarounds.java.
2023-06-16 23:24:08 +02:00
Romain Vimont
d3c2955fb9
Add --time-limit
...
Add an option to stop scrcpy automatically after a given delay.
PR #4052 <https://github.com/Genymobile/scrcpy/pull/4052 >
Fixes #3752 <https://github.com/Genymobile/scrcpy/issues/3752 >
2023-06-10 16:04:51 +02:00
Romain Vimont
5042f8de93
Improve recording documentation
2023-06-10 16:03:27 +02:00
Romain Vimont
7536f95d1c
Rename raw_video_stream to raw_stream
...
This server-specific option impacts both the video and audio streams.
2023-06-10 12:09:43 +02:00
Romain Vimont
6832e8d629
Remove spurious empty line
2023-06-10 12:07:35 +02:00
Romain Vimont
28313631e5
Reformat Java code
...
Fix code style.
2023-06-09 22:28:01 +02:00
Romain Vimont
fdbc9397a7
Name Java threads
...
Give a user-friendly name to Java threads created by the server.
2023-06-09 22:27:35 +02:00
Romain Vimont
a3cdf1a6b8
Add option to kill adb on close
...
Killing adb on close by default would be incorrect, since it would break
any other usage of adb in parallel.
It could be easily done manually by calling "adb kill-server" once
scrcpy terminates, but add an option --kill-adb-on-close for
convenience.
Fixes #205 <https://github.com/Genymobile/scrcpy/issues/205 >
Fixes #2580 <https://github.com/Genymobile/scrcpy/issues/2580 >
Fixes #4049 <https://github.com/Genymobile/scrcpy/issues/4049 >
2023-06-05 19:48:21 +02:00
Romain Vimont
b16d4d1835
Fix adb server vs adb daemon confusion
...
The adb daemon runs on the device, the adb server runs as a background
process on the computer.
2023-06-05 19:45:20 +02:00
Romain Vimont
b8d43866d2
Fix options alphabetical order
...
Commit fc52b24503 missed this one.
2023-06-05 19:44:15 +02:00
Romain Vimont
2d79aeb117
Simplify command in documentation
...
If --no-video is passed, --no-playback is equivalent to
--no-audio-playback.
2023-06-04 18:43:35 +02:00
Romain Vimont
888a5aae7d
Fix typo in recording documentation
...
The option is --record, not --record-file.
2023-06-04 18:40:55 +02:00
Romain Vimont
323ea2f1d9
Fix PTS when not monotonically increasing
...
Some decoders fail to guarantee that PTS is strictly monotonically
increasing. Fix the (rescaled) PTS when it does not respect this
constraint.
Fixes #4054 <https://github.com/Genymobile/scrcpy/issues/4054 >
2023-06-03 18:50:28 +02:00
Romain Vimont
9ca554ca41
Extract stream-specific structure in recorder
...
For now, it only contains the stream index, but more fields will be
added.
2023-06-03 18:48:01 +02:00
Romain Vimont
9d3c656414
Fix recorder waiting when stream disabled
...
In the recorder, if the video or audio stream is disabled, do not wait
for its initialization (it will never happen) to process the header.
In that case (scrcpy --no-audio --record=file.mp4), this caused the
whole content to be buffered in memory, and written only on exit.
2023-06-03 18:46:39 +02:00
Romain Vimont
379caf8551
Use a single condvar in recorder
...
The sc_cond_wait() in sc_recorder_process_header() needs to be notified
of changes to video_init/audio_init (protected by stream_cond) and
video_queue/audio_queue (protected by queue_cond).
Use only one condition variable to simplify.
2023-06-03 15:10:42 +02:00
Romain Vimont
2aec7b4c9d
Mention how to interrupt scrcpy without video
...
There is no window to close if video playback is disabled.
2023-06-02 09:00:33 +02:00
Romain Vimont
fc52b24503
Reorder options in alphabetical order
...
Fix the options order, using the short option as key first (if any) in
all cases for consistency.
2023-06-01 12:52:48 +02:00
Romain Vimont
ff5ffc892f
Add option to select audio source
...
Pass --audio-source=mic to capture the microphone instead of the device
audio output.
2023-06-01 09:21:09 +02:00
Romain Vimont
360f2fea1e
Extract AudioCapture creation
...
This will allow to pass capture options without code duplication.
2023-06-01 09:21:09 +02:00
Romain Vimont
8e2c0d6407
Rename rotationChanged to resetCapture
...
The flag is used to reset the capture (restart the encoding) on rotation
change. It will also be used for other events (on folding change), so
rename it.
PR #3979 <https://github.com/Genymobile/scrcpy/pull/3979 >
2023-06-01 09:20:00 +02:00
Romain Vimont
9a2abba098
Update demuxer comment
...
The comment was outdated:
- the "meta" header is now always present (not only when recording is
enabled);
- it is not only used for the video stream, but also for the audio
stream.
2023-06-01 09:04:00 +02:00
Romain Vimont
4c4a03ebe1
Reorder options to maintain alphabetical order
2023-05-30 21:36:48 +02:00
Romain Vimont
c4caa6b81d
Document --no-{video,audio}-playback
...
PR #4033 <https://github.com/Genymobile/scrcpy/pull/4033 >
2023-05-27 10:08:10 +02:00
Romain Vimont
1efbfe1175
Add separate video and audio playback options
...
Add --no-video-playback and --no-audio-playback. The option
--no-playback is now an alias for both.
PR #4033 <https://github.com/Genymobile/scrcpy/pull/4033 >
2023-05-27 10:08:10 +02:00
Romain Vimont
751c09f47a
Simplify V4L2/USB ifdefs
...
Define local variables whose value depends on ifdefs, to avoid
cluttering all conditions with ifdefs.
2023-05-27 09:55:49 +02:00
Romain Vimont
6ad46d70b8
Define v4l2_buffer only if HAVE_V4L2
...
If V4L2 support is disabled, there is no v4l2 buffer option.
2023-05-27 09:55:49 +02:00
Romain Vimont
f46758d1c5
Fix V4L2 error message when disabled
...
For consistency, use the same error message for --v4l2-sink and
--v4l2-buffer.
2023-05-27 09:55:49 +02:00
Romain Vimont
e71f5358b3
Reorder command line options checks
...
Perform checks that impact the options first.
2023-05-27 09:55:49 +02:00
Romain Vimont
a2c8910006
Rename --no-mirror to --no-playback
...
This option impacts video and audio _playback_. For example, if we use
V4L2, the device is still "mirrored" (via V4L2), even if playback is
disabled. Therefore, "playback" is more approriate than "mirror".
The initial option --no-display option was renamed to --no-mirror by
commit 6928acdeac , but this has never been
released, so it is ok to rename it one more time.
Refs #3978 <https://github.com/Genymobile/scrcpy/pull/3978#issuecomment-1549420103 >
PR #4033 <https://github.com/Genymobile/scrcpy/pull/4033 >
2023-05-27 09:55:38 +02:00
Romain Vimont
597d2ccc01
Rename FORMAT to ENCODING
...
The AudioFormat contains several properties. This specific value is
named "encoding".
2023-05-24 22:13:09 +02:00
Romain Vimont
38900d7730
Extract audio source to a static constant
...
For consistency with the other parameters.
2023-05-24 22:13:09 +02:00
Romain Vimont
e926bf1fe8
Delay window resize when minimized
...
On some window managers (e.g. on Windows), performing a resize while the
window is minimized does nothing (the restored window keeps its old
size).
Therefore, like for maximized and fullscreen states, wait for the window
to be restored to apply a resize.
Refs #3947 <https://github.com/Genymobile/scrcpy/issues/3947 >
2023-05-22 18:22:45 +02:00
Romain Vimont
6298ef095f
Accept texture failures
...
When the scrcpy window is minimized on Windows with D3D9, texture
creation and update fail.
In that case, do not terminate scrcpy. Instead, store the pending size
or frame to update, to attempt again during the next update or
rendering.
Fixes #3947 <https://github.com/Genymobile/scrcpy/issues/3947 >
2023-05-22 18:21:10 +02:00
Romain Vimont
7d33798b40
Upgrade FFmpeg build to 6.0-scrcpy-4
...
Use FFmpeg DLLs which do not depend on zlib1.dll.
2023-05-15 21:55:22 +02:00
Romain Vimont
d500550212
Update audio recording documentation
...
Document how to record audio-only to .opus and .aac files.
PR #3978 <https://github.com/Genymobile/scrcpy/pull/3978 >
2023-05-15 14:28:55 +02:00
Romain Vimont
a166eee909
Upgrade FFmpeg build to 6.0-scrcpy-3
...
Use a build which includes the opus muxer, to support recording to .opus
files.
Refs <https://github.com/rom1v/scrcpy-deps/commits/6.0-scrcpy-3 >
PR #3978 <https://github.com/Genymobile/scrcpy/pull/3978 >
2023-05-15 14:28:53 +02:00
Romain Vimont
b11b363e8e
Add recording to aac file
...
It is just an alias for mp4.
PR #3978 <https://github.com/Genymobile/scrcpy/pull/3978 >
2023-05-08 17:11:34 +02:00
Romain Vimont
7321db6f28
Add recording to opus file
...
Use the FFmpeg opus muxer to record an opus file.
PR #3978 <https://github.com/Genymobile/scrcpy/pull/3978 >
2023-05-08 17:11:34 +02:00
Romain Vimont
d6bcde565f
Accept .m4a and .mka
...
These are just aliases for mp4 and mkv when there is no video stream.
PR #3978 <https://github.com/Genymobile/scrcpy/pull/3978 >
2023-05-08 17:11:34 +02:00
Romain Vimont
98f4f4e68a
Refactor command line checks
...
Several checks are performed when opts->record_filename is not NULL.
Group them in a single block.
PR #3978 <https://github.com/Genymobile/scrcpy/pull/3978 >
2023-05-08 17:11:34 +02:00
Romain Vimont
be86e14e05
Factorize record format parsing
...
Convert either the filename extension or the explicit record format
to a sc_record_format using the same function.
PR #3978 <https://github.com/Genymobile/scrcpy/pull/3978 >
2023-05-08 17:11:34 +02:00
Romain Vimont
8c650e53cd
Add --no-video
...
Similar to --no-audio, add --no-video to play audio only.
Fixes #3842 <https://github.com/Genymobile/scrcpy/issues/3842 >
PR #3978 <https://github.com/Genymobile/scrcpy/pull/3978 >
2023-05-08 17:11:34 +02:00
Romain Vimont
e89e772c7c
Remove unnecessary 'else'
...
Some server parameters may depend on one another. For example,
audio_bit_rate is meaningless if audio is false.
But it is inconsistent to disable some parameters based on these
dependencies checks, but not others. Handling all dependencies between
parameters would add too much complexity for no benefit.
So just pass individual parameters independently.
PR #3978 <https://github.com/Genymobile/scrcpy/pull/3978 >
2023-05-08 16:41:12 +02:00
Romain Vimont
feab87053a
Convert screen encoder to async processor
...
Contrary to the other tasks (controller and audio capture/encoding), the
screen encoder was executed synchronously. As a consequence,
scrcpy-server could not terminate until the screen encoder returned.
Convert it to an async processor. This allows to terminate on controller
error, and this paves the way to disable video mirroring.
PR #3978 <https://github.com/Genymobile/scrcpy/pull/3978 >
2023-05-08 16:41:09 +02:00
Romain Vimont
751a3653a0
Add missing @Override annotations
...
PR #3978 <https://github.com/Genymobile/scrcpy/pull/3978 >
2023-05-08 16:41:06 +02:00
Romain Vimont
9c08eb79cb
Close connection at the end of finally-block
...
The async processors use the socket file descriptors from the
connection. Therefore, the connection must not be closed before all
async processor threads are joined.
PR #3978 <https://github.com/Genymobile/scrcpy/pull/3978 >
2023-05-08 16:41:04 +02:00
Romain Vimont
92483fe11b
Disable controls on --no-mirror
...
If mirroring is disabled, control must also be disabled.
PR #3978 <https://github.com/Genymobile/scrcpy/pull/3978 >
2023-05-08 16:41:01 +02:00
Romain Vimont
6928acdeac
Rename --no-display to --no-mirror
...
The option impacts both video and audio playback, so "no display" is not
an appropriate name.
PR #3978 <https://github.com/Genymobile/scrcpy/pull/3978 >
2023-05-08 16:40:58 +02:00
Romain Vimont
0f3af2d20b
Fix build for FFmpeg < 3.3
...
The constant AV_CODEC_ID_AV1 was introduced in FFmpeg 3.3. Add an ifdef
to support older versions.
Fixes #3939 <https://github.com/Genymobile/scrcpy/issues/3939 >
2023-04-23 12:26:46 +02:00
Romain Vimont
9eb6591913
Add missing --no-audio option in manpage
2023-04-10 19:30:04 +02:00
Romain Vimont
9cfea347d0
Remove Options setters
...
Now that options parsing is performed from the Options class, setters
are not necessary anymore.
2023-04-09 20:02:39 +02:00
Romain Vimont
ce064fb5e0
Move options parsing to Options class
2023-04-09 20:02:39 +02:00
Romain Vimont
afcdfc7fd7
Fix checkstyle violation
...
Checkstyle reported this error:
[ant:checkstyle] [ERROR] AudioCapture.java:89:145: '+' should be on
a new line. [OperatorWrap]
2023-04-09 20:01:58 +02:00
Romain Vimont
051b74c883
Extract sc_display from sc_screen
...
Move the display code to a separate component.
2023-04-06 19:48:26 +02:00
Romain Vimont
2e532afd2b
Pass const pointers to events
...
SDL_Events are only read.
2023-04-06 19:48:01 +02:00
Romain Vimont
669e9a8d1e
Fix "ip route" parsing
...
If a line did not end with '\r', then the final `\n' was replaced by
'\0' for parsing the current line. This `\0` was then mistakenly
considered as the end of the whole "ip route" output, so the remaining
lines were not parsed, causing "scrcpy --tcpip" to fail in some cases.
To fix the issue, read the final character of the current line before it
is (possibly) overwritten by '\0'.
2023-04-02 19:30:23 +02:00
Romain Vimont
f77e1c474e
Fix copy-paste for some devices
...
On Honor Magic 5 Pro, the method to get the clipboard content has been
modified in the framework.
Adapt the call to make it work also on this device.
Fixes #3885 <https://github.com/Genymobile/scrcpy/issues/3885 >
2023-04-01 11:52:37 +02:00
Romain Vimont
2f9396e24a
Simplify clock estimation
...
The slope encodes the drift between the device clock and the computer
clock. Its real value is expected very close to 1.
To estimate it, just assume it is exactly 1.
Since the clock is used to estimate very close points in the future, the
error caused by clock drift is totally negligible, and in practice it is
way lower than the slope estimation error.
Therefore, only estimate the offset.
2023-03-30 20:58:33 +02:00
Romain Vimont
2fff9b9edf
Adapt FakeContext for Android 14
...
This fixes audio for Android 14 developer preview 2.
Fixes #3784 <https://github.com/Genymobile/scrcpy/issues/3784 >
Suggested-by: Namelesswonder <Namelesswonder@users.noreply.github.com >
2023-03-20 08:40:34 +01:00
Romain Vimont
57f879d68a
Adapt clipboard wrappers to Android 14
...
A new deviceId parameter has been added.
Fixes #3784 <https://github.com/Genymobile/scrcpy/issues/3784 >
2023-03-20 08:40:25 +01:00
Romain Vimont
3626d90004
Use separate audio capture code for Android 11
...
The code to start audio capture is more complicated for Android 11
(launch a fake popup, wait, make several attempts, close the shell
package).
Use a distinct code path specific to Android 11.
2023-03-17 21:30:04 +01:00
Romain Vimont
02f4ff7534
Make 3 attempts to start AudioRecord
...
On Android 11, a fake popup must be briefly opened to make the system
think that the shell app is in the foreground so that audio may be
recorded.
Making the shell app foreground may take some time depending on the
device, so make 3 attempts, waiting 100ms before each.
Fixes #3796 <https://github.com/Genymobile/scrcpy/issues/3796 >
2023-03-17 21:30:04 +01:00
Romain Vimont
a3871130cc
List available encoders on failure
...
When the creation of an encoder fails, log an explicit error message
with the list of available encoders.
2023-03-17 21:29:45 +01:00
Romain Vimont
d7841664f4
Simplify logic in setScreenPowerMode()
...
Refs <https://github.com/Genymobile/scrcpy/commit/f2dee20a207b9906574d9b3d62a0ab2585dade20#r104417398 >
Suggested-by: brunoais <brunoaiss@gmail.com >
2023-03-15 19:53:58 +01:00
Romain Vimont
39544f34b4
Add --audio-output-buffer
...
On some systems, the SDL audio callback is not called frequently enough
(for example it requests 5ms of samples every 10ms), because the output
buffer is too small.
By default, we want to use a small value (5ms) to minimize latency and
buffer underrun, but if it does not work well, users need a way to
increase it.
Refs #3793 <https://github.com/Genymobile/scrcpy/issues/3793 >
2023-03-14 23:54:07 +01:00
Romain Vimont
4755b97908
Fix bash auto-completion handling
...
Options having an argument impossible to auto-complete must be handled
separately.
2023-03-14 23:51:48 +01:00
Romain Vimont
cba2501254
Add missing auto-completion for --audio-buffer
2023-03-14 23:41:06 +01:00
Romain Vimont
6ba99a62ff
Split workarounds to fix audio on some devices
...
There were several workarounds applied in a single method. Some of them
are specific to Meizu phones, but cause issues on other devices.
Split the method to be able to only fill the app context for audio
capture without applying the Meizu workarounds.
Fixes #3801 <https://github.com/Genymobile/scrcpy/issues/3801 >
2023-03-14 23:23:57 +01:00
Romain Vimont
337d6c2fd3
Fail on empty AudioRecord read()
...
If read() returns 0, then there is no data. According to the
documentation, it happens if the buffer is not a direct buffer:
<https://developer.android.com/reference/android/media/AudioRecord#read(java.nio.ByteBuffer,%20int) >
Refs #3812 <https://github.com/Genymobile/scrcpy/issues/3812 >
2023-03-14 19:27:11 +01:00
Romain Vimont
2eced46a37
Update broken link in documentation
...
The Android documentation has been updated.
2023-03-14 19:21:43 +01:00
Romain Vimont
1a80333747
Replace link to enable USB debugging in README
...
Link to a more relevant page in the official documentation to enable USB
debugging.
2023-03-13 10:19:22 +01:00
Romain Vimont
fb61b779a6
Add references to prerequisites
...
Users sometimes only read the OS-specific instructions, they must be
aware of the prerequisites.
2023-03-13 08:43:54 +01:00
Romain Vimont
5899af6a2f
Add blogpost link about scrcpy 2.0
2023-03-12 21:08:51 +01:00
Romain Vimont
cbca79b95b
Fix v4l2 sink
...
The codec id to write as codec parameters is the one from the v4l2
encoder, not from the decoder.
Regression introduced by be985b8242 .
Fixes #3795 <https://github.com/Genymobile/scrcpy/issues/3795 >
2023-03-12 12:45:49 +01:00
Romain Vimont
02586cf21f
Fix build issue on FFmpeg < 5.1
...
An include was missing.
Fixes #3783 <https://github.com/Genymobile/scrcpy/issues/3783 >
2023-03-12 08:54:42 +01:00
Romain Vimont
80a6fa7a01
Fix comparison warning
...
An int was compared with an unsigned:
../app/src/audio_player.c:290:27: warning: comparison of integers of
different signs: 'int' and 'unsigned int' [-Wsign-compare]
if (abs(diff) < ap->sample_rate / 1000) {
~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~
2023-03-12 08:37:08 +01:00
Romain Vimont
e5aa2ce01f
Fix broken link in Windows download page
2023-03-12 02:59:44 +01:00
Romain Vimont
cbc638c6ba
Fix broken link in shortcuts documentation
2023-03-12 02:50:10 +01:00
Romain Vimont
abc1be4872
Update links to v2.0
2023-03-12 02:49:28 +01:00
Romain Vimont
f1b2d6bbbb
Bump version to 2.0
2023-03-12 02:05:37 +01:00
Romain Vimont
90926d40ad
Merge branch 'master' into dev
2023-03-12 02:05:24 +01:00
Romain Vimont
f12590ed08
Rework README and documentation
...
The README.md page is HUGE. Split it up.
Also document audio forwarding and improve installation instructions for
each platform and user documentation.
PR #3774 <https://github.com/Genymobile/scrcpy/pull/3774 >
2023-03-12 02:04:58 +01:00
Romain Vimont
05a55e3687
Happy new year 2023!
2023-03-12 02:04:58 +01:00
Romain Vimont
affda26bfa
Document audio player
...
Add some high-level documentation on the audio player implementation.
2023-03-12 02:04:58 +01:00
Romain Vimont
0bf866fa8d
Apply new compensation only if it changed
...
If the compensation is the same (typically when it is 0), do not reapply
it.
2023-03-12 02:04:58 +01:00
Romain Vimont
73727e7fdf
Disable clock drift compensation for tiny values
...
For less than 1ms, the estimated drift is just noise.
2023-03-12 02:04:58 +01:00
Romain Vimont
c22c87eded
Fail on deprecated options
...
Suggest the video and audio specific options instead.
2023-03-12 02:04:58 +01:00
Romain Vimont
426dfbf21d
Remove dead code about the deprecated -F option
...
The -F option was already removed.
2023-03-12 02:04:58 +01:00
Romain Vimont
5512777404
Remove deprecated option --render-expired-frames
...
This option did nothing since it was deprecated. Totally remove it.
2023-03-12 02:04:58 +01:00
Romain Vimont
cc07f8dac4
Upgrade platform-tools (34.0.1) for Windows
...
Include the latest version of adb in Windows releases.
2023-03-12 02:04:58 +01:00