Romain Vimont
16a63e0917
Use non-secure display for Android 12 preview
...
Android 12 preview identifies as Android 11, but its codename is "S".
Refs #2129 <https://github.com/Genymobile/scrcpy/issues/2129 >
3 years ago
Romain Vimont
f7533e8896
Use non-secure display for Android >= 12
...
Since Android 12, secure displays could not be created with shell
permissions anymore.
Refs commit 1fdde490fd
Fixes #2129 <https://github.com/Genymobile/scrcpy/issues/2129 >
3 years ago
Romain Vimont
42ab8fd611
List available encoders on invalid name specified
...
If an invalid encoder name is given via the --encoder option, list all
the H.264 encoders available on the device.
4 years ago
Romain Vimont
363eeea19e
Log encoder name
...
When the encoder is selected automatically, log the name of the selected
encoder.
4 years ago
Tzah Mazuz
76c2c6e69d
Adding new option --encoder
...
Some devices have more than one encoder, and some encoders may cause
issues or crash. With this option we can specify which encoder we want
the device to use.
PR #1827 <https://github.com/Genymobile/scrcpy/pull/1827 >
Fixes #1810 <https://github.com/Genymobile/scrcpy/issues/1810 >
Signed-off-by: Romain Vimont <rom@rom1v.com>
4 years ago
Tzah Mazuz
080a4ee365
Add --codec-options
...
Add a command-line parameter to pass custom options to the device
encoder (as a comma-separated list of "key[:type]=value").
The list of possible codec options is available in the Android
documentation:
<https://d.android.com/reference/android/media/MediaFormat >
PR #1325 <https://github.com/Genymobile/scrcpy/pull/1325 >
Refs #1226 <https://github.com/Genymobile/scrcpy/pull/1226 >
Co-authored-by: Romain Vimont <rom@rom1v.com>
4 years ago
Romain Vimont
74ece9b45b
Simplify ScreenEncoder more
...
Commit 927d655ff6
removed the
iFrameInternal field and constructor argument.
Also remove it from createFormat() arguments.
4 years ago
Romain Vimont
62c0c1321f
Apply workarounds only on error
...
To avoid NullPointerException on some devices, workarounds have been
implemented. But these workaround produce (harmless) internal errors
causing exceptions to be printed in the console.
To avoid this problem, apply the workarounds only if it fails without
them.
Fixes #994 <https://github.com/Genymobile/scrcpy/issues/994 >
Refs #365 <https://github.com/Genymobile/scrcpy/issues/365 >
Refs #940 <https://github.com/Genymobile/scrcpy/issues/940 >
4 years ago
Tzah Mazuz
125c5561e8
Use MediaFormat constant for MIME type
...
Replace "video/avc" by MIMETYPE_VIDEO_AVC.
Signed-off-by: Romain Vimont <rom@rom1v.com>
4 years ago
Romain Vimont
927d655ff6
Simplify ScreenEncoder
...
Do not handle iFrameInterval field and parameter, it is never used
dynamically.
4 years ago
Romain Vimont
ee2894779a
Remove unused lockedVideoOrientation field
...
During PR #1151 , this field has been moved to ScreenInfo, but has not
been removed from ScreenEncoder.
4 years ago
e_vigurskiy
4150eedcdf
Add display id parameter
...
Add --display command line parameter to specify a display id.
PR #1238 <https://github.com/Genymobile/scrcpy/pull/1238 >
Signed-off-by: Romain Vimont <rom@rom1v.com>
4 years ago
Romain Vimont
5031b2c8ff
Remove MagicNumber checkstyle
...
There are a lot of "magic numbers" that we really don't want to extract
as a constant.
Until now, many @SuppressWarnings annotations were added, but it makes
no sense to check for magic number if we silent the warnings everywhere.
4 years ago
Romain Vimont
ae2d094362
Handle locked video orientation from ScreenInfo
...
Centralize video size management in ScreenInfo.
This allows to always send the correct initial video size to the client
if the video orientation is locked.
4 years ago
Romain Vimont
c5f5d1e456
Rename "rotation" to "device rotation"
...
This paves the way to reduce confusion in ScreenInfo when it will handle
locked video orientation.
4 years ago
Romain Vimont
da18c9cdab
Remove useles import
4 years ago
George Stamoulis
1982bc439b
Add option to lock video orientation
...
PR #1151 <https://github.com/Genymobile/scrcpy/pull/1151 >
Signed-off-by: Romain Vimont <rom@rom1v.com>
4 years ago
Romain Vimont
ef56cc6ff7
Retrieve screen info once
...
The method getScreenInfo() is synchronized, and the result may change
between calls.
Call it once and store the result in a local variable.
4 years ago
Romain Vimont
83d48267a7
Accept --max-fps before Android 10
...
KEY_MAX_FPS_TO_ENCODER existed privately before Android 10:
<https://github.com/Genymobile/scrcpy/issues/488#issuecomment-567321437 >
5 years ago
act262
90293240cc
Fix meizu 16th NPE
...
Fill AppInfo to avoid NullPointerException on some devices.
Fixes <https://github.com/Genymobile/scrcpy/issues/365 >
Signed-off-by: Romain Vimont <rom@rom1v.com>
5 years ago
Romain Vimont
213c468c20
Move workarounds to a separate class
...
Extract workarounds (currently only one) to a separate class to avoid
polluting the main code.
5 years ago
Romain Vimont
1d97d7213d
Add option --max-fps
...
Add an option to limit the capture frame rate. It only works for devices
with Android >= 10.
Fixes <https://github.com/Genymobile/scrcpy/issues/488 >
5 years ago
Romain Vimont
fb976816f9
Do not expose frame rate in ScreenEncoder
...
The KEY_FRAME_RATE parameter value is necessary for the configuration of
the encoder, but its actual value does not impact the frame rate (only
resources used by the encoder).
Therefore, it's an internal detail and should not be exposed by the
ScreenEncoder class.
5 years ago
olbb
e282100d0b
Call Looper.prepareMainLooper() to avoid exception
...
Some devices internally create a Handler when creating an input Surface,
causing an exception:
> Surface: java.lang.RuntimeException: Can't create handler inside
> thread that has not called Looper.prepare()
As a workaround, call Looper.prepareMainLooper() beforehand.
Fixes:
- <https://github.com/Genymobile/scrcpy/issues/240 >
- <https://github.com/Genymobile/scrcpy/issues/921 >
Signed-off-by: Romain Vimont <rom@rom1v.com>
5 years ago
Romain Vimont
01664777c8
Merge branch 'master' into dev
5 years ago
Romain Vimont
f11b0ec204
Fix server checkstyle errors
...
Fix errors reported by:
gradle -p server check
5 years ago
Romain Vimont
3eda38e5fc
Do not call codec.stop() on exception
...
On exception, the codec is not in a state were .stop() can be called.
5 years ago
Romain Vimont
b8ff35efe6
Remove empty line
5 years ago
Romain Vimont
1fdde490fd
Mirror "secure" content
...
Some applications, like Silence, prevent the content of a window from
being viewed on non-secure displays:
<https://developer.android.com/reference/android/view/WindowManager.LayoutParams.html#FLAG_SECURE >
We can mirror it by just creating a "secure" display:
<https://developer.android.com/reference/android/view/Display#FLAG_SECURE >
5 years ago
Romain Vimont
22ff03f2f7
Do not queue invalid PTS
...
Configuration packets produced by MediaCodec have no valid PTS, and do
not produce frame. Do not queue their (invalid) PTS not to break the
matching between frames and their PTS.
6 years ago
Romain Vimont
345f8858d3
Send frame meta only if recording is enabled
...
The client needs the PTS for each frame only if recording is enabled.
Otherwise, the PTS are not necessary, and the protocol is more
straighforward.
6 years ago
Romain Vimont
475912a39c
Do not transmit MediaCodec flags
...
Since PTS handling has been fixed, the recorder do not associate a PTS
to a wrong frame anymore, so PTS of "configuration packets" (which never
produce a frame), are never read by the recorder. Therefore, there is no
need to ignore them explicitly, so we can remove the MediaCodec flags
completely.
6 years ago
Romain Vimont
2cd99e7205
Only set valid PTS/DTS
...
When the PTS is valid, set both PTS and DTS to avoid FFmpeg warnings.
Since configuration packets have no PTS, do not record these packets.
6 years ago
Ivan Gorinov
d706c5df39
Enable video output file, with pts set by server
6 years ago
Romain Vimont
66def38b73
Avoid additional buffer copy in userspace
...
Directly send the data from MediaCodec buffers to the LocalSocket,
without an intermediate copy in userspace.
6 years ago
Romain Vimont
caa9e30004
Add crop feature
...
Add an option to crop the screen on the server. This allows to mirror
only part of the device screen.
6 years ago
Romain Vimont
e3f5d3b49b
Double the default bitrate
...
Set the default video bitrate to 8Mbps. This greatly increase quality on
fast motion, without negative side effects.
6 years ago
Romain Vimont
a7979e4e74
Rename rotation detection method name
...
The old name checkRotationChanged() did not suggest that the flag was
reset.
6 years ago
Romain Vimont
b61310a257
Initialize eof flag from BufferInfo
...
Stop encoding if the codec signaled the end of stream.
The eof flag was read, but never written.
6 years ago
Romain Vimont
e55e42a442
Apply Genymobile rules for Android projects
...
Apply Genymobile checkstyle and gradle build files organization.
6 years ago
Romain Vimont
5f51d605c0
Recreate codec and display on rotation changed
...
On some devices, we can reuse the same codec and display, but on some
others (e.g. Nexus 5X with Android 7.1.2), it crashes on codec.stop()
with an IllegalStateException.
Therefore, always recreate the codec and display, so that it works on
all devices.
6 years ago
Romain Vimont
d5acc8adc5
Always release output buffer
...
If rotation changed, the dequeued output buffer was never released. Move
it to a finally block to avoid the leak.
6 years ago
Romain Vimont
6b546a87ab
Add bit-rate command-line option
...
Add a command-line option (-b/--bit-rate) to customize the video
bit-rate.
6 years ago
Romain Vimont
865ebb3862
Encode video using MediaCodec API
...
Replace screenrecord execution by manual screen encoding using the
MediaCodec API.
The "screenrecord" solution had several drawbacks:
- screenrecord output is buffered, so tiny frames may not be accessible
immediately;
- it did not output a frame until the surface changed, leading to a
black screen on start;
- it is limited to 3 minutes recording, so it needed to be restarted;
- screenrecord added black borders in the video when the requested
dimensions did not preserve aspect-ratio exactly (sometimes
unavoidable since video dimensions must be multiple of 8);
- rotation handling was hacky (killing the process and starting a new
one).
Handling the encoding manually allows to solve all these problems.
6 years ago