Commit Graph

384 Commits (1fdde490fd2a0b89680a2b5da5e5274192398023)
 

Author SHA1 Message Date
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>
6 years ago
Romain Vimont 39c5e71605 Make the server unlink itself
To clean up the device, the client executed "adb shell rm" once the
server was guaranteed to be started (after the connection succeeded).

This implied to track whether the installation state, and failed if an
additional tunnel was used in "forward" mode:
<https://github.com/Genymobile/scrcpy/issues/386#issuecomment-453936034>

Instead, make the server unlink itself on start.
6 years ago
Romain Vimont fefb9816a9 Handle mouse events outside device screen
Mouse events position were unsigned (so negative values could not be
handled properly).

To avoid issues with negative values, mouse events outside the device
screen were ignored (commit a7fe9ad779).

But as a consequence, drag&drop were "broken" if the "drop" occurred
outside the device screen.

Instead, use signed 32-bits to store the position, and forward events
outside the device screen.

Fixes <https://github.com/Genymobile/scrcpy/issues/357>.
6 years ago
Romain Vimont 7830859c21 Merge branch 'master' into dev 6 years ago
Romain Vimont 0e019f8ab8 Add a note to allow simulating input in README 6 years ago
Romain Vimont f7d02cad4b Add ninja-build to the packages list to install
The package ninja-build should be installed automatically as a meson
dependency, but some users need to install a newer meson from pip3, so
ninja must be installed explicitly.
6 years ago
Romain Vimont a7fe9ad779 Ignore mouse events outside device screen
Never create a "struct point" with a position possibly outside the
device screen (i.e. in the black borders area), and do not transmit such
events.

This fixes an assertion failure on mouse wheel events outside the device
screen area.
6 years ago
Romain Vimont 1e22ebcac2 Always use non-empty arguments
The client passes parameters to the server via "adb shell" arguments.

Use "-" instead of "" when no crop is specified to avoid empty
arguments, which are not handled the same way on all devices.

Fixed <https://github.com/Genymobile/scrcpy/issues/337>.
6 years ago
Romain Vimont d81729ba39 Always expect 5 parameters for the server
The client always sends all the arguments, so there is no need to check.
6 years ago
Romain Vimont b2c3df7550 Point out that ninja must not be run as root
See https://github.com/Genymobile/scrcpy/issues/335.
6 years ago
Romain Vimont 46fec41b7b Move drag&drop features in README
Present how to install an APK and how to push a file in the "features"
section (instead of "shortcuts").
6 years ago
Romain Vimont 2876463d39 Fix read_packet() return value on error or EOF
Fix warning on error or EOF:

> Invalid return value 0 for stream protocol

See <http://git.videolan.org/?p=ffmpeg.git;a=commitdiff;h=a606f27f4c610708fa96e35eed7b7537d3d8f712>.

Fixes <https://github.com/Genymobile/scrcpy/issues/333>.
6 years ago
Romain Vimont 6dc6ec05d5 Configure version at meson project level
Make meson aware of the project version, so that it does not print:

    Project version: undefined
6 years ago
Romain Vimont b5e630eea3 Update links to v1.5-fixversion
I forgot to bump version _before_ the release, so I had to make a new
one which fixes the version string (for scrcpy --help).
6 years ago
Pierre Gordon a17f1116ce Bump version to 1.5
Signed-off-by: Romain Vimont <rom@rom1v.com>
6 years ago
Romain Vimont e4cf152b26 Update links to v1.5 in README and BUILD 6 years ago
Romain Vimont bd32016632 Improve features presentation in README 6 years ago
Romain Vimont 77b620e1d0 Merge branch 'record' into dev (#292)
Record screen to file
6 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 60afb46c8d Store queue of PTS for pending frames
Several frames may be read by read_packet() before they are consumed
(returned by av_read_frame()), so we need to store the PTS of frames in
order, so that the right PTS is assigned to the right frame.
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 22bf0c19d6 Rename --output-file to --record
To record the screen to a local file:

    scrcpy --record file.mp4
6 years ago
Romain Vimont 70579dc709 Wrap receiver state into separate struct
For readability, wrap the state of the receiver in a separate struct
receiver_state.
6 years ago
Romain Vimont e562837c0b Avoid partial header reads
Use net_recv_all() to avoid partial reads for the "meta" header (this
would break the whole stream).
6 years ago
Romain Vimont ebe998cf78 Move buffer reader functions to buffer_util.h 6 years ago
Romain Vimont b98eb7d0fa Support AVStream.codec for old FFmpeg versions
AVStream.codec has been deprecated in favor of AVStream.codecpar.

Due to the FFmpeg/Libav split, this happened in two separate versions:
 - 57.33.100 for FFmpeg
 - 57.5.0 for Libav
6 years ago
yuchenlin e361b49b4a recorder: use av_oformat_next to support older FFmpeg
Signed-off-by: yuchenlin <npes87184@gmail.com>
6 years ago
Romain Vimont d0e090e1f9 Reenable custom SDL signal handlers
This partially reverts commit f00c6c5b13.

On Ctrl+C, we need to execute cleanup code. For instance, if recording
is enabled, we need to write MP4 file trailer on exit.

Custom SDL signal handlers were disabled because it leaded to process
hanging on Ctrl+C during network calls on initialization, but now it
seems to work correctly, the network calls return immediately on signal.
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 27e8a9a79d Assign PTS to the right frame
The PTS was read from the socket and set as the current one even before
the frame was consumed, so it could be assigned to the previous frame
"in advance".

Store the PTS for the current frame and the last PTS read from the
packet header of the next frame in separate fields.

As a side-effect, this fixes the warning on quit:

> Application provided invalid, non monotonically increasing dts to
> muxer in stream 0: 17164020 >= 17164020
6 years ago
Romain Vimont 61db575861 Decode and push frame before recording
Handle display before recording, to reduce latency.
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
Romain Vimont 27686e9361 Add recorder
Implement recording in a separate "class".
6 years ago
Ivan Gorinov d706c5df39 Enable video output file, with pts set by server 6 years ago
Romain Vimont b5c64c0f5a Fix SDL 2.0.9 for Windows
Add missing version upgrade in cross_winXX.txt files.
6 years ago
Romain Vimont a5787dccd6 Update SDL (2.0.9) for Windows
Include the last version of SDL in Windows releases.
6 years ago
Romain Vimont cb3cf801c8 Extract bit operations to buffer_util.h
Move util functions to a reusable separate header.
6 years ago
Romain Vimont b1d2c2c640 Explain how to install up-to-date meson
On Ubuntu 16.04, meson is 0.29, while scrcpy requires >= 0.37.

Explain how to install a newer version from pip3.
6 years ago
Romain Vimont 9160d465ec Add feature test macro to declare kill()
Avoid the following warning on some systems:

> warning: implicit declaration of function 'kill'
> [-Wimplicit-function-declaration]
6 years ago
Romain Vimont 5c739874a4 Fix memory leak on error
On decode error, unref the packet.
6 years ago
Romain Vimont d061c30965 Replace Ctrl by Meta for volume shortcuts on MacOS
Ctrl+UP and Ctrl+DOWN are already used by the window manager on MacOS.

Use Cmd key instead (like on VLC).
6 years ago
Romain Vimont 5bf1261364 Refactor to support Meta in shortcuts
Move the Ctrl and Meta key down checks to each shortcut individually, so
that we can add a shortcut involving Meta.
6 years ago
Romain Vimont facbbced9e
Merge pull request #310 from npes87184/master
fix text memory leak
6 years ago
yuchenlin 96056e3213 input_manager: fix potential memory leak on text
Fix potential memory leak when controller_push_event failed.

Signed-off-by: yuchenlin <npes87184@gmail.com>
6 years ago
Romain Vimont 0b92b93358 Capture Alt and Meta keys
Alt and Meta keys should not be forwarded to the device. For now, they
are not used for shortcuts, but they could be.
6 years ago
Romain Vimont c20245630e Factorize Windows command building
Extract command line building to a separate method.
6 years ago
Romain Vimont b882322f73 Work around Os.write() not updating position
ByteBuffer position is not updated as expected by Os.write() on old
Android versions. Count the remaining bytes manually.

Fixes <https://github.com/Genymobile/scrcpy/issues/291>.
6 years ago
Romain Vimont 8875955921 Support paths containing spaces on Windows
Quote the arguments of "adb push" to support paths which contain spaces
on Windows.

Fixes <https://github.com/Genymobile/scrcpy/issues/288>.
6 years ago
Romain Vimont ff4430b2a3 Declare fun(void) functions with no parameters
This is not C++.
6 years ago
Romain Vimont cea176c210 Update links to v1.4 in README and BUILD 6 years ago