Commit graph

1223 commits

Author SHA1 Message Date
Romain Vimont
e6e011baaf Add stream layer
The decoder initially read from the socket, decoded the video and sent
the decoded frames to the screen:

              +---------+      +----------+
  socket ---> | decoder | ---> |  screen  |
              +---------+      +----------+

The design was simple, but the decoder had several responsabilities.

Then we added the recording feature, so we added a recorder, which
reused the packets received from the socket managed by the decoder:

                                    +----------+
                               ---> |  screen  |
              +---------+     /     +----------+
  socket ---> | decoder | ----
              +---------+     \     +----------+
                               ---> | recorder |
                                    +----------+

This lack of separation of concerns now have concrete implications: we
could not (properly) disable the decoder/display to only record the
video.

Therefore, split the decoder to extract the stream:

                                    +----------+      +----------+
                               ---> | decoder  | ---> |  screen  |
              +---------+     /     +----------+      +----------+
  socket ---> | stream  | ----
              +---------+     \     +----------+
                               ---> | recorder |
                                    +----------+

This will allow to record the stream without decoding the video.
2019-03-02 18:45:45 +01:00
Romain Vimont
e7b7b083aa Store the recording request in a local bool
This avoids to test explicitly whether options->record_filename is NULL.
2019-03-02 18:21:20 +01:00
Romain Vimont
8aeb5c0e3c Fix cleanup order
The order of cleanup was not the reverse as the initialization order. As
a consequence, recorder_destroy() could theoretically be called even if
recorder_init() failed.
2019-03-02 18:13:11 +01:00
Romain Vimont
bcd4090d51 Fix recording with old decoding/encoding API
The deprecated avcodec_decode_video2() should always the whole packet,
so there is no need to loop (cf doc/examples/demuxing_decoding.c in
FFmpeg).

This hack changed the packet size and data pointer. This broke recording
which used the same packet.
2019-03-02 17:03:15 +01:00
Romain Vimont
84270e2d18 Rename "stop" to "interrupt"
The purpose of video_buffer_stop() is to interrupt any blocking call, so
rename it to video_buffer_interrupt().
2019-03-02 17:03:15 +01:00
Romain Vimont
fff87095d9 Rename "frames" to "video_buffer"
It better describes the purpose of the structure.
2019-03-02 15:24:33 +01:00
Romain Vimont
aacb09a3d6 Remove unused mutex field in decoder 2019-03-02 14:48:34 +01:00
Romain Vimont
7d10ec2b5a Add shortcut to expand/collapse notification panel
Use Ctrl+n to expand, Ctrl+Shift+n to collapse.

Fixes <https://github.com/Genymobile/scrcpy/issues/392>
2019-02-26 20:35:37 +01:00
Romain Vimont
1c1fe5ec53 Use "always on top" only for SDL >= 2.0.5
The flag SDL_WINDOW_ALWAYS_ON_TOP is available since SDL 2.0.5.

Do not use it if SDL is older, to fix compilation failure.

Fixes <https://github.com/Genymobile/scrcpy/issues/432>
2019-02-16 15:28:56 +01:00
Romain Vimont
751600a7f9 Move all compat ifdefs definitions to compat.h
This allows to give a proper name to features requirements.
2019-02-16 15:28:56 +01:00
Romain Vimont
3fc11ee465 Update links to v1.7 in README and BUILD 2019-02-16 01:07:15 +01:00
Romain Vimont
b7472a545e Bump version to 1.7 2019-02-16 00:53:19 +01:00
Romain Vimont
f5f4e6b1c5 Allocate extradata with av_malloc()
The extradata buffer is owned by libav, so it must be allocated with
av_malloc(), not SDL_malloc().

This fixes a crash on Windows during avformat_free_context().
2019-02-16 00:53:12 +01:00
Romain Vimont
6c40dbd27d Regroup Windows-ifdefs in command.h 2019-02-10 14:33:59 +01:00
Romain Vimont
477c0a2cab Create process with wide chars on Windows
Windows does not support UTF-8, so pushing a file with non-ASCII
characters failed.

Convert the UTF-8 command line to a wide characters string and call
CreateProcessW().

Fixes <https://github.com/Genymobile/scrcpy/issues/422>
2019-02-10 13:08:28 +01:00
Romain Vimont
c0b65b14df Merge branch 'master' into dev 2019-02-10 12:23:47 +01:00
Romain Vimont
b23cacfc1a Add recording logs
Log when recording is started and stopped.
2019-02-10 11:29:34 +01:00
Romain Vimont
0ed2373952 Support recording to MKV
Implement recording to Matroska files.

The format to use is determined by the option -F/--record-format if set,
or by the file extension (".mp4" or ".mkv").
2019-02-09 15:56:24 +01:00
Romain Vimont
1aaad6ba35 Rescale packet timestamp to container time base
Some containers force their own time base. For example, matroska
overwrite time_base to (AVRational) {1, 1000}.

Therefore, rescale our packet timestamps to the output stream time base.

Suggested-by: Steve Lhomme <robux4@ycbcr.xyz>
2019-02-09 15:51:18 +01:00
Romain Vimont
c8f0805b89 Write header file with correct extradata
When recording, the header must be written with extradata set to the
content of the very first packet.

Suggested-by: Steve Lhomme <robux4@ycbcr.xyz>

Fixes <https://github.com/Genymobile/scrcpy/issues/351>
Fixes <https://github.com/Genymobile/scrcpy/issues/416>
2019-02-09 15:50:24 +01:00
Romain Vimont
ee3cba57a8 Forward FFmpeg logs
FFmpeg logs can be useful to understand the cause of issues.
2019-02-09 12:27:13 +01:00
Romain Vimont
c11905b860 Add log verbose macro
This was the only log priority missing.
2019-02-09 12:27:13 +01:00
Romain Vimont
1a5ba59504 Fix memory leak on close
The buffer associated to the AVIOContext must be freed.
2019-02-09 12:27:13 +01:00
Romain Vimont
aa07dfd2ca
Merge pull request #412 from npes87184/dev
app: add always_on_top
2019-01-27 14:09:19 +01:00
Yu-Chen Lin
eca82e09c3 app: add always_on_top
It is very convenient when I play mobile game and watch video at the
same time.

Tested on Linux mint Cinnamon as well as Windows 10.

Signed-off-by: Yu-Chen Lin <npes87184@gmail.com>
2019-01-27 20:54:24 +08:00
Romain Vimont
eea478b9dc Add release script
Add a script to generate the whole release properly.

It first builds locally in release mode, then execute tests. Then it
builds archives for Windows. Finally, it puts all release files (Windows
archives, prebuilt server and checksums) in a separate release
directory.
2019-01-26 15:31:14 +01:00
Romain Vimont
43ad402356
Merge pull request #411 from npes87184/master
tests: fix test_control_event_serialize
2019-01-26 13:22:42 +01:00
Yu-Chen Lin
4d30fa93ba tests: fix test_control_event_serialize
commit fefb9816a changed the protocol, fix the related testing case.

Signed-off-by: Yu-Chen Lin <npes87184@gmail.com>
2019-01-26 20:09:32 +08:00
Romain Vimont
b35733edb6 Fix expected mouse event sizes
Commit fefb9816a9 modified mouse events
serialization. The server-side parsing was updated to correctly read the
position, but the expected size of these events was not updated.

As a result, the server might try to parse incomplete events, leading
to BufferUnderflowException.

Fixes
<https://github.com/Genymobile/scrcpy/issues/350#issuecomment-456298816>.
2019-01-22 09:47:26 +01:00
Romain Vimont
7764a836f1 Fix incorrect comment
Comment had not been updated along with the code.
2019-01-22 09:38:51 +01:00
Romain Vimont
0bfaf7b7ff Update links to v1.6 in README and BUILD 2019-01-20 22:05:32 +01:00
Romain Vimont
446c682374 Bump version to 1.6 2019-01-20 21:35:42 +01:00
Romain Vimont
3aacb7967d Merge branch 'dev' into master 2019-01-19 21:40:55 +01:00
Romain Vimont
06a0bbbc71 Update FFmpeg (4.1) for Windows
Include the last version of FFmpeg in Windows releases.
2019-01-19 18:14:05 +01:00
Romain Vimont
d71e036f3a Do not disable screensaver
Keep screensaver enabled while scrcpy is running.

Fixes <https://github.com/Genymobile/scrcpy/issues/380>.
2019-01-18 23:17:31 +01:00
Romain Vimont
b343a5dc59
Merge pull request #401 from npes87184/dev
input_manager: don't ignore double click event when clicking inside device
2019-01-18 13:34:41 +01:00
Yu-Chen Lin
c5ec1a194c input_manager: don't ignore double click event when clicking inside device
Signed-off-by: Yu-Chen Lin <npes87184@gmail.com>
2019-01-18 20:21:25 +08:00
Romain Vimont
4f254d8232
Merge pull request #396 from npes87184/master
prepare-dep: use variable for better readability
2019-01-16 21:16:04 +01:00
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>
2019-01-16 14:21:18 +01:00
yuchenlin
fb73aa101a prepare-dep: use variable for better readability
The arguments are saved to variable when script started. Instead of
using $1, $2 and $3, we can use these variables.

Signed-off-by: yuchenlin <npes87184@gmail.com>
2019-01-15 21:32:46 +08:00
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.
2019-01-14 21:12:23 +01:00
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>.
2018-11-27 08:59:22 +01:00
Romain Vimont
7830859c21 Merge branch 'master' into dev 2018-11-27 08:38:57 +01:00
Romain Vimont
0e019f8ab8 Add a note to allow simulating input in README 2018-11-25 11:29:27 +01:00
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.
2018-11-19 09:43:05 +01:00
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.
2018-11-18 21:31:57 +01:00
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>.
2018-11-16 18:39:41 +01:00
Romain Vimont
d81729ba39 Always expect 5 parameters for the server
The client always sends all the arguments, so there is no need to check.
2018-11-16 18:36:01 +01:00
Romain Vimont
b2c3df7550 Point out that ninja must not be run as root
See https://github.com/Genymobile/scrcpy/issues/335.
2018-11-15 21:11:58 +01:00
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").
2018-11-13 20:39:18 +01:00