Commit Graph

2274 Commits (camerafpsranges)
 

Author SHA1 Message Date
Romain Vimont dedbc3f8cd Recover on invalid camera FPS ranges
Some devices may provide invalid ranges, causing an
IllegalArgumentException "lower must be less than or equal to upper".

Catch the exception to list the cameras anyway.

Refs #4403 <https://github.com/Genymobile/scrcpy/issues/4403>
7 months ago
Romain Vimont ad8ced5b1e Log physical cameras 7 months ago
Romain Vimont 36b17ee068 Simplify --list-cameras ouptut
Remove --video-source=camera from the output of --list-cameras (this is
implicit).
7 months ago
Romain Vimont 4e4ddc499f Return the FakeContext as application context
This avoids getApplicationContext() to return null and cause
NullPointerException.

Fixes #4392 <https://github.com/Genymobile/scrcpy/issues/4392#issuecomment-1792806080>
7 months ago
Romain Vimont 8d76b3e06d Fill application context for camera
Using the camera fails on some devices without a proper application
context.

Fixes #4392 <https://github.com/Genymobile/scrcpy/issues/4392>
7 months ago
Romain Vimont 85a0b935c9 Always assign a system context as base context
FakeContext used ActivityThread.getSystemContext() as base context only
in some cases, because it caused problems on some devices:
 - warnings on Xiaomi devices [1], which are now fixed by
   b8c5853aa6
 - issues related to Looper [2], which are solved by just calling
   Looper.prepare*()

Therefore, we can now always assign a base context, which simplifies and
helps to solve camera issues on some devices (#4392).

[1] <https://github.com/Genymobile/scrcpy/issues/4015#issuecomment-1595382142>
[2] <https://github.com/Genymobile/scrcpy/issues/3805#issuecomment-1596148031>

Fixes #4392 <https://github.com/Genymobile/scrcpy/issues/4392>
7 months ago
Romain Vimont 8c3e2bae7b Simplify Application instantiation
The constructor is public.
7 months ago
Romain Vimont 446ea818a4 Update links to v2.2 7 months ago
Romain Vimont c3c7bf7af3 Bump version to v2.2 7 months ago
Romain Vimont 5000368c2f Merge branch 'master' into release 7 months ago
Romain Vimont 855ae4adb1 Upgrade SDL (2.28.4) for Windows
Include the latest version of SDL in Windows releases.
7 months ago
Romain Vimont a8db3ec9e2 Upgrade platform-tools (34.0.5) for Windows
Include the latest version of adb in Windows releases.
7 months ago
Romain Vimont ff579990c2 Shutdown connection before joining threads
Interrupting async processors may require to shutdown the connection to
wake up blocking calls.

Therefore, shutdown the connection first, then join the threads, then
close the connection.

Refs commit 9c08eb79cb
7 months ago
Romain Vimont b8c5853aa6 Disable default stdout/stderr
Some devices (mostly Xiaomi) print internal errors using
e.printStackTrace(), flooding the console with irrelevant errors.

Disable system streams used via System.out and System.err streams, to
print only the logs from scrcpy.

Refs #994 <https://github.com/Genymobile/scrcpy/issues/994>
Refs #4213 <https://github.com/Genymobile/scrcpy/pull/4213>
7 months ago
Romain Vimont c64d150202 Improve manpage formatting 7 months ago
Romain Vimont 8350a61926 Simplify URLs in manpage
The .UR-formatted URLs are not always rendered correctly. Use simple
brackets instead.
7 months ago
Romain Vimont 5580803406 Always print device model and version
Print the log before checking for --list-* options so that it is
printed in all cases.
7 months ago
Romain Vimont 9bfc749803 Add camera documentation
PR #4213 <https://github.com/Genymobile/scrcpy/pull/4213>
7 months ago
Andrew Gunnerson 6af4bd601f Add support for high frame rate camera capture
Add --camera-high-speed to enable high frame rate camera capture. If
the option is enabled, then --camera-fps is mandatory.

PR #4213 <https://github.com/Genymobile/scrcpy/pull/4213>

Co-authored-by: Romain Vimont <rom@rom1v.com>
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
Signed-off-by: Romain Vimont <rom@rom1v.com>
7 months ago
Andrew Gunnerson 4722bff423 Add --camera-fps
Add a new option for specifying the camera frame rate.

By default, Android's default frame rate (30 fps) is used.

PR #4213 <https://github.com/Genymobile/scrcpy/pull/4213>

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
Signed-off-by: Romain Vimont <rom@rom1v.com>
7 months ago
Romain Vimont 928f8b8eb3 Do not arbitrary limit --max-fps to 1000
Limit to the variable type size, for consistency.

PR #4213 <https://github.com/Genymobile/scrcpy/pull/4213>
7 months ago
Simon Chan 9fc5835485 Fail-fast camera mirroring on Android 11 and older
PR #4213 <https://github.com/Genymobile/scrcpy/pull/4213>

Co-authored-by: Romain Vimont <rom@rom1v.com>
Signed-off-by: Romain Vimont <rom@rom1v.com>
7 months ago
Romain Vimont dd36d6135f Support camera size selection using -m/--camera-ar
In addition to --camera-size to specify an explicit size, make it
possible to select the camera size automatically, respecting the maximum
size (already used for display mirroring) and an aspect ratio.

For example, "scrcpy --video-source=camera" followed by:
 - (no additional arguments)
    : mirrors at the maximum size, any a-r
 - -m1920
    : only consider valid sizes having both dimensions not above 1920
 - --camera-ar=4:3
    : only consider valid sizes having an aspect ratio of 4:3 (+/- 10%)
 - -m2048 --camera-ar=1.6
    : only consider valid sizes having both dimensions not above 2048
      and an aspect ratio of 1.6 (+/- 10%)

PR #4213 <https://github.com/Genymobile/scrcpy/pull/4213>

Co-authored-by: Simon Chan <1330321+yume-chan@users.noreply.github.com>
7 months ago
Simon Chan faebb7d70a Add --camera-facing
Add an option to select the camera by its lens facing (front, back or
external).

PR #4213 <https://github.com/Genymobile/scrcpy/pull/4213>

Co-authored-by: Romain Vimont <rom@rom1v.com>
Signed-off-by: Romain Vimont <rom@rom1v.com>
7 months ago
Romain Vimont 7f8d079c8c Make camera id optional
If no camera id is provided, use the first camera available.

PR #4213 <https://github.com/Genymobile/scrcpy/pull/4213>
7 months ago
Romain Vimont 64930e71b9 Handle camera disconnection
Stop mirroring on camera disconnection.

PR #4213 <https://github.com/Genymobile/scrcpy/pull/4213>
7 months ago
Romain Vimont d544e577c0 Automatically select audio source
If --audio-source is not specified, select the default value
according to the video source:
 - for display mirroring, use device audio by default;
 - for camera mirroring, use microphone by default.

PR #4213 <https://github.com/Genymobile/scrcpy/pull/4213>
7 months ago
Simon Chan bfeecc0131 Add camera mirroring
Add --video-source=camera, and related options:
 - --camera-id=<id>: select the camera by its id (see --list-cameras);
 - --camera-size=<width>x<height>: select the capture size.

Fixed #241 <https://github.com/Genymobile/scrcpy/issues/241>
PR #4213 <https://github.com/Genymobile/scrcpy/pull/4213>

Co-authored-by: Romain Vimont <rom@rom1v.com>
Signed-off-by: Romain Vimont <rom@rom1v.com>
7 months ago
Romain Vimont f032262cd7 Add --list-camera-sizes
Add an option to list the device camera declared sizes.

PR #4213 <https://github.com/Genymobile/scrcpy/pull/4213>
7 months ago
Simon Chan cd63896d63 Add --list-cameras
Add an option to list the device cameras.

PR #4213 <https://github.com/Genymobile/scrcpy/pull/4213>

Co-authored-by: Romain Vimont <rom@rom1v.com>
Signed-off-by: Romain Vimont <rom@rom1v.com>
7 months ago
Romain Vimont f085765e04 Factorize --list- options handling
This will limit code duplication as more list options will be added.

PR #4213 <https://github.com/Genymobile/scrcpy/pull/4213>
7 months ago
Simon Chan a2fb1b40f6 Extract SurfaceCapture from ScreenEncoder
Extract an interface SurfaceCapture from ScreenEncoder, representing a
video source which can be rendered to a Surface for encoding.

Split ScreenEncoder into:
 - ScreenCapture, implementing SurfaceCapture to capture the device
   screen,
 - SurfaceEncoder, to encode any SurfaceCapture.

This separation prepares the introduction of another SurfaceCapture
implementation to capture the camera instead of the device screen.

PR #4213 <https://github.com/Genymobile/scrcpy/pull/4213>

Co-authored-by: Romain Vimont <rom@rom1v.com>
Signed-off-by: Romain Vimont <rom@rom1v.com>
7 months ago
Romain Vimont 41ccb5883e Force server exit at the end of main()
By default, the Java process exits when all non-daemon threads are
terminated.

The Android SDK might start some non-daemon threads internally,
preventing the scrcpy server to exit in some cases.

So force the process to exit explicitly.

PR #4213 <https://github.com/Genymobile/scrcpy/pull/4213>
7 months ago
Romain Vimont 23e116064d Rename --display to --display-id
The option is named "display id" everywhere.

This will be consistent with --camera-id (there will be many camera
options, so an option --camera would be confusing).

PR #4213 <https://github.com/Genymobile/scrcpy/pull/4213>
7 months ago
Romain Vimont 3432029a3d Make separator configurable for parsing integers
The separator was hardcoded to ':'. This will allow to reuse the
function to parse sizes as WIDTHxHEIGHT.

PR #4213 <https://github.com/Genymobile/scrcpy/pull/4213>
7 months ago
Romain Vimont 7a2b756f1e Fix incorrect comment about AV1 constant
MediaFormat.MIMETYPE_VIDEO_AV1 has been added in API 29, not 21.
7 months ago
Romain Vimont b7ad652a75 Move empty string test for crop option parsing
For consistency with other options.
7 months ago
Avinash Sonawane 76a99a7fcd Replace raw number by its name
PR #4373 <https://github.com/Genymobile/scrcpy/pull/4373>

Signed-off-by: Romain Vimont <rom@rom1v.com>
7 months ago
Avinash Sonawane 68b55ef2fe Replace sprintf() with safer snprintf()
PR #4373 <https://github.com/Genymobile/scrcpy/pull/4373>

Co-authored-by: Romain Vimont <rom@rom1v.com>
Signed-off-by: Romain Vimont <rom@rom1v.com>
7 months ago
Avinash Sonawane bc8913e12b Use `char *` for pointer arithmetic
PR #4374 <https://github.com/Genymobile/scrcpy/pull/4374>

Signed-off-by: Romain Vimont <rom@rom1v.com>
7 months ago
Romain Vimont 3c2013de10 Enable missing-prototypes warning
Warn if a global function is defined without a previous prototype
declaration. It is not enabled by default at warning_level=2.
7 months ago
Avinash Sonawane 8cef8bac94 Declare local functions as static
PR #4374 <https://github.com/Genymobile/scrcpy/pull/4374>

Co-authored-by: Romain Vimont <rom@rom1v.com>
Signed-off-by: Romain Vimont <rom@rom1v.com>
7 months ago
Avinash Sonawane 0bbe8a7007 Wrap macros in do-while(0)
To fix the warnings of stray `;`.

PR #4374 <https://github.com/Genymobile/scrcpy/pull/4374>

Signed-off-by: Romain Vimont <rom@rom1v.com>
7 months ago
Romain Vimont 9fdb882509 Fix --pause-on-exit parsing
The function incorrectly returned `false` instead of a valid (and
expected) enum value.
7 months ago
Romain Vimont 8e7b041f35 Add missing `void`s for empty parameter list 7 months ago
Avinash Sonawane 9ade389069 Make sc_usb_devices_destroy() static
It is only called from the implementation file.

PR #4371 <https://github.com/Genymobile/scrcpy/pull/4371>

Signed-off-by: Romain Vimont <rom@rom1v.com>
7 months ago
Avinash Sonawane 90ba885547 Remove redundant `;`
PR #4371 <https://github.com/Genymobile/scrcpy/pull/4371>

Signed-off-by: Romain Vimont <rom@rom1v.com>
7 months ago
Avinash Sonawane 7adf98e9d4 Use `void` for empty function parameter list
PR #4371 <https://github.com/Genymobile/scrcpy/pull/4371>

Signed-off-by: Romain Vimont <rom@rom1v.com>
7 months ago
AmirSina Mashayekh 90ca46ee41 Add scrcpy-server to .gitignore
The script install_release.sh downloads a file named scrcpy-server to
the repo root directory. Add it to .gitignore so that it is ignored.

PR #4364 <https://github.com/Genymobile/scrcpy/pull/4364>

Signed-off-by: Romain Vimont <rom@rom1v.com>
8 months ago
Romain Vimont 1c864a88eb Use --pause-on-exit from launchers
The terminal opened by scrcpy-console (.bat or .desktop) must not close
if scrcpy terminates with an error, so that error messages can be read.

Refs #3817 <https://github.com/Genymobile/scrcpy/pull/3817>
Refs #3822 <https://github.com/Genymobile/scrcpy/pull/3822>
PR #4130 <https://github.com/Genymobile/scrcpy/pull/4130>
8 months ago