Commit Graph

1303 Commits (db484d82dbb41f3aeca6a02e4b818ad54af03a47)
 

Author SHA1 Message Date
Romain Vimont 9b89b7ab72 Center the window on resize-to-fit
When removing the black borders (by double-clicking on them, or by
pressing MOD+w), the window is resized to fit the device screen, but its
top-left position was left unchanged.

Instead, move the window so that the new window area is at the center of
the old window area.

Refs #2387 <https://github.com/Genymobile/scrcpy/issues/2387>
3 years ago
Romain Vimont 7343b233e4 Render screen on window restored
It should not be necessary, since screen_render() is called just after
on SDL_WINDOWEVENT_EXPOSED, but in practice the window content might not
be correctly displayed on restored if a rotation occurred while
minimized.

Note that calling screen_render() twice in a row on
SDL_WINDOWEVENT_EXPOSED also "fixes" the issue.
3 years ago
Romain Vimont cd2894570d Allocate AVPacket for v4l2_sink
From FFmpeg/doc/APIchanges:

    2021-03-17 - f7db77bd87 - lavc 58.133.100 - codec.h
      Deprecated av_init_packet(). Once removed, sizeof(AVPacket) will
      no longer be a part of the public ABI.

Refs #2302 <https://github.com/Genymobile/scrcpy/issues/2302>
3 years ago
Romain Vimont 4af317d40d Allocate AVPacket for recorder
From FFmpeg/doc/APIchanges:

    2021-03-17 - f7db77bd87 - lavc 58.133.100 - codec.h
      Deprecated av_init_packet(). Once removed, sizeof(AVPacket) will
      no longer be a part of the public ABI.

Refs #2302 <https://github.com/Genymobile/scrcpy/issues/2302>
3 years ago
Romain Vimont 318b6a572e Allocate AVPacket for local stream packet
From FFmpeg/doc/APIchanges:

    2021-03-17 - f7db77bd87 - lavc 58.133.100 - codec.h
      Deprecated av_init_packet(). Once removed, sizeof(AVPacket) will
      no longer be a part of the public ABI.

Refs #2302 <https://github.com/Genymobile/scrcpy/issues/2302>
3 years ago
Romain Vimont e8b053ad2f Allocate AVPacket for stream->pending
From FFmpeg/doc/APIchanges:

    2021-03-17 - f7db77bd87 - lavc 58.133.100 - codec.h
      Deprecated av_init_packet(). Once removed, sizeof(AVPacket) will
      no longer be a part of the public ABI.

Remove the has_pending boolean, which can be replaced by:

    stream->pending != NULL

Refs #2302 <https://github.com/Genymobile/scrcpy/issues/2302>
3 years ago
Romain Vimont a5d71eee45 Clarify --no-display usage with v4l2 3 years ago
Romain Vimont af228706f1 Fix compatibility with old FFmpeg
V4L2 sink used a "url" field format AVFormatContext which has been
introduced in lavf 58.7.100.

Fixes #2382 <https://github.com/Genymobile/scrcpy/issues/2382>

Refs <ea3672b7d6>
Refs <fa8308d3d4>
3 years ago
Romain Vimont f76fe2c0d4 Fix --lock-video-orientation syntax
The argument for option --lock-video-orientation has been made optional
by 5af9d0ee0f.

With getopt_long(), contrary to mandatory arguments, optional arguments
must be given with a '=':

    --lock-video-orientation 2   # wrong, parse error
    --lock-video-orientation=2   # correct
3 years ago
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 969bfd4374 Serialize clean-up configuration
This avoids to pass each option as individual parameter and parse them
manually (it's still "manual" in the Parcelable implementation).

Refs #824 <https://github.com/Genymobile/scrcpy/pull/824#issuecomment-780319422>

Reviewed-by: Yu-Chen Lin <npes87184@gmail.com>
3 years ago
Romain Vimont 506f918fb7 Group components into struct scrcpy
This avoids to refer to many structs globally.
3 years ago
Romain Vimont 6fd7e89da1 Explicitly initialize decoder sink_count
The zero-initialization relied on the fact that the decoder instance is
static.
3 years ago
Romain Vimont 4c31911df2 Pass serial within struct server_params
This was the only option passed separately.
3 years ago
Secreto31126 d3d955f67b Translate README.md into Spanish
PR #2318 <https://github.com/Genymobile/scrcpy/pull/2318>

Signed-off-by: Romain Vimont <rom@rom1v.com>
3 years ago
Alberto Pasqualetto 8121b0b7e7 FAQ in Italian
PR #2316 <https://github.com/Genymobile/scrcpy/pull/2316>

Signed-off-by: Romain Vimont <rom@rom1v.com>
3 years ago
Alberto Pasqualetto 2e9d520080 README in Italian
PR #2316 <https://github.com/Genymobile/scrcpy/pull/2316>

Signed-off-by: Romain Vimont <rom@rom1v.com>
3 years ago
Romain Vimont 1b7c9b3e1c Reference translations from FAQ.md 3 years ago
Romain Vimont 9bed8cf3f4 Fix syntax highlighting in README 3 years ago
Romain Vimont 6adc97198b Provide device info directly on server connection
This avoids to retrieve them in a separate step.
3 years ago
Romain Vimont 6a2cd089a1 Initialize input manager dynamically
The input manager was partially initialized statically, but a call to
input_manager_init() was needed anyway, so initialize all the fields
from the "constructor".

This is consistent with the initialization of the other structs.
3 years ago
Romain Vimont dcee7c0f7f Factorize screen_init() error management 3 years ago
Romain Vimont e604e8a752 Move fps_counter to screen
The FPS counter specifically count frames from the screen video buffer,
so it is specific to the screen.
3 years ago
Romain Vimont f19c455110 Fix leak on error
Destroy video buffer if screen window creation failed.
3 years ago
Romain Vimont 83116fc199 Notify end-of-stream via callback
Do not send a SDL event directly, to make stream independent of SDL.
3 years ago
Alberto Pasqualetto 72081a241b Fix visualization of comment in code block
PR #2315 <https://github.com/Genymobile/scrcpy/pull/2315>

Signed-off-by: Romain Vimont <rom@rom1v.com>
3 years ago
LYK 42b3d1e66e Reformat README.ko.md
PR #2311 <https://github.com/Genymobile/scrcpy/pull/2311>

Signed-off-by: Romain Vimont <rom@rom1v.com>
3 years ago
Romain Vimont 1e64f0f931 Use ARRAY_LEN() macro 3 years ago
Romain Vimont 8fb5715740 Add libavdevice-dev in BUILD instructions
On Linux, scrcpy now depends on libavdevice for v4l2.
3 years ago
Romain Vimont f062dfd30b Merge branch 'master' into dev 3 years ago
Haren S 644a5ef14a Add MacPorts documentation
PR #2299 <https://github.com/Genymobile/scrcpy/pull/2299>

Signed-off-by: Romain Vimont <rom@rom1v.com>
3 years ago
Romain Vimont 1b9dcce23c Fix double-free on error
On error, server->serial was freed twice: immediately and in
server_destroy().

Refs #2292 <https://github.com/Genymobile/scrcpy/issues/2292#issuecomment-831424820>
3 years ago
Romain Vimont 233f8e6cc4 Rename keycode injection method
Make it explicit that it injects both "press" and "release" events.
3 years ago
Romain Vimont 9a7d351d67 Simplify non-static injectEvent() implementation
Just call the static version (having a displayId) from the non-static
version (using the displayId field).
3 years ago
Romain Vimont d00ee640c0 Simplify Device.java
Remove useless intermediate method with a "mode" parameter (it's always
called with the same mode).

This also avoids the need for a specific injectEventOnDisplay() method,
since it does not conflict with another injectEvent() method anymore.
3 years ago
Romain Vimont ae6ec7a194 Unref decoder AVFrame immediately
The frame can be unref immediately after it is pushed to the frame
sinks.

It was not really a memory leak because the frame was unref every time
by avcodec_receive_frame() (and freed on close), but a reference was
unnecessarily kept for too long.
3 years ago
Romain Vimont 84f17fdeab Fix v4l2 AVPacket memory leak on error
Unref v4l2 AVPacket even if writing failed.
3 years ago
Romain Vimont 1cde68a1fa Fix v4l2 AVFrame memory leak
Unref frame immediately once encoded.

Fixes #2279 <https://github.com/Genymobile/scrcpy/pull/2279>
3 years ago
Romain Vimont 45e7280148 Rename --v4l2_sink to --v4l2-sink
This was a rebase issue, the previous version in #2268 was correct.

Refs #2268 <https://github.com/Genymobile/scrcpy/pull/2268>
3 years ago
Romain Vimont 41a0383d7c Document v4l2 sink in README 3 years ago
Marco Martinelli d39161f753 Add support for v4l2loopback
It allows to send the video stream to /dev/videoN, so that it can be
captured (like a webcam) by any v4l2-capable tool.

PR #2232 <https://github.com/Genymobile/scrcpy/pull/2232>
PR #2233 <https://github.com/Genymobile/scrcpy/pull/2233>
PR #2268 <https://github.com/Genymobile/scrcpy/pull/2268>

Co-authored-by: Romain Vimont <rom@rom1v.com>
3 years ago
Romain Vimont 5af9d0ee0f Make --lock-video-orientation argument optional
If the option is set without argument, lock the initial device
orientation (as if the value "initial" was passed).
3 years ago
Romain Vimont fd0dc6c0cd Add --lock-video-orientation=initial
Add a new mode to the --lock-video-orientation option, to lock the
initial orientation of the device.

This avoids to pass an explicit value (0, 1, 2 or 3) and think about
which is the right one.
3 years ago
Romain Vimont 151bc16644 Use strlist_contains() to find a muxer
The AVOutputFormat name is a string list: it contains names separated by
',' (possibly only one).
3 years ago
Romain Vimont ffc00210e9 Add strlist_contains()
Add a function to know if a string list, using some separator, contains
a specific string.
3 years ago
Romain Vimont 243854a408 Fix recorder comment 3 years ago
Romain Vimont 8b90dc61b9 Handle EAGAIN on send_packet in decoder
EAGAIN was only handled on receive_frame.

In practice, it should not be necessary, since one packet always
contains one frame. But just in case.
3 years ago
Romain Vimont 2a5dfc1c17 Handle errors using gotos in recorder_open()
There are many initializations in recorder_open(). Handle RAII-like
deinitialization using gotos.
3 years ago
Romain Vimont e3fccc5a5e Initialize recorder fields on open
Only initialize ops and parameters copy from recorder_init(). It was
inconsistent to initialize some fields from _init() and some others from
_open().
3 years ago