Introduce a new packet type, a "session" packet, containing metadata
about the encoding session. It is used only for the video stream,
and currently includes the video resolution.
For illustration, here is a sequence of packets on the video stream:
device rotation
v
CODEC | SESSION | MEDIA | MEDIA | … | SESSION | MEDIA | MEDIA | …
1920x1080 <-----------------> 1080x1920 <------------------
encoding session 1 encoding session 2
This metadata is not strictly necessary, since the video resolution can
be determined after decoding. However, it allows detection of cases
where the encoder does not respect the requested size (and logs a
warning), even without decoding (e.g., when there is no video playback).
Additional metadata could be added later if necessary, for example the
actual device rotation.
Refs #5918 <https://github.com/Genymobile/scrcpy/pull/5918>
Refs #5894 <https://github.com/Genymobile/scrcpy/pull/5894>
Co-authored-by: gz0119 <liyong2@4399.com>
The stream metadata will contain both:
- the codec id at the start of the stream
- the session metadata (video width and height) at the start of every
"session" (typically on rotation)
Between the calls to CONSOLE_ERR.print() and
printStackTrace(CONSOLE_ERR), logs from other threads may be inserted.
Synchronizing access to CONSOLE_ERR ensures that logs from different
threads do not mix.
PR #6487 <https://github.com/Genymobile/scrcpy/pull/6487>
Signed-off-by: valord577 <valord577@gmail.com>
Signed-off-by: Romain Vimont <rom@rom1v.com>
The default handler was mistakenly retrieved after our custom handler
was set, causing it to reference itself. As a result, this led to
infinite recursion.
Bug introduced by eee3f24739.
ANDROID_PLATFORM is not always an integer; it can also be a value like
"36.1". Handle such cases properly.
This fixes the following error:
server/build_without_gradle.sh: line 89:
[[: 36.1: syntax error: invalid arithmetic operator (error token is ".1")
PR #6408 <https://github.com/Genymobile/scrcpy/pull/6408>
Signed-off-by: Romain Vimont <rom@rom1v.com>
New Android versions may add methods to IDisplayWindowListener.aidl.
When these methods are called by the system, they result in an
AbstractMethodError because they are not implemented on the scrcpy side.
To avoid releasing a new version for each newly added method, ignore
them at the Binder level.
Refs afaca80b37Fixes#6362 <https://github.com/Genymobile/scrcpy/issues/6362>
For Android >= 12, scrcpy executed "settings" commands (in a new
process) rather than using the ContentProvider directly, due to
permission issues [1].
However, these permission issues were resolved by introducing
FakeContext.getContentResolver() [2].
Therefore, remove the use of "settings" commands and use the
ContentProvider directly in all cases.
Refs [1] cc0902b13c
Refs [2] 91373d906b
Refs #6224 comment <https://github.com/Genymobile/scrcpy/issues/6224#issuecomment-3078418268>
SDL precise scrolling can sometimes produce values greater than 1 or
less than -1.
On the wire, the value is encoded as a 16-bit fixed-point number.
Previously, the range was interpreted as [-1, 1], using 1 bit for the
integral part (the sign) and 15 bits for the fractional part.
To support larger values, interpret the range as [-16, 16] instead,
using 5 bits for the integral part and 11 bits for the fractional part
(which is more than enough).
PR #6172 <https://github.com/Genymobile/scrcpy/pull/6172>
The ClipboardManager is instantiated by the first call to
ServiceManager.getClipboardManager().
Now that scrcpy uses android.content.ClipboardManager directly, it must
ensure that it is created on the main thread (or at least on a thread
with a Looper), to avoid the following error:
> Can't create handler inside thread that has not called
> Looper.prepare()
Refs 8a02e3c2f5Fixes#6151 <https://github.com/Genymobile/scrcpy/issues/6151>
Since a main looper is explicitly run in the main process, the
initialization of workarounds no longer calls
Looper.prepareMainLooper(), leading to a crash:
java.lang.RuntimeException: Can't create handler inside thread
Thread[main,5,main] that has not called Looper.prepare()
As a result, --power-off-on-close was broken.
Refs 283326b2f6Fixes#6146 <https://github.com/Genymobile/scrcpy/issues/6146>
Some devices require a specific option to be enabled in Developer
Options to avoid a permission issue when injecting input events.
When this error occurs, hide the stack trace and print a human-readable
message explaining how to fix the issue.
PR #6080 <https://github.com/Genymobile/scrcpy/pull/6080>
Store the target audio source integer (one of the constants from
android.media.MediaRecorder.AudioSource) in the AudioSource enum (or -1
if not relevant).
This will simplify adding new audio sources.
PR #5870 <https://github.com/Genymobile/scrcpy/pull/5870>
The default OPUS and FLAC encoders on Android rewrite the input PTS so
that they exactly match the number of samples.
As a consequence:
- audio clock drift is not compensated
- implicit silences (without packets) are ignored
To work around this behavior, generate new PTS based on the current time
(after encoding) and the packet duration.
PR #5870 <https://github.com/Genymobile/scrcpy/pull/5870>