Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f24d488ca2 |
+10
-10
@@ -100,11 +100,11 @@ dist-win32: build-server build-win32 build-win32-noconsole
|
|||||||
cp "$(SERVER_BUILD_DIR)"/server/scrcpy-server "$(DIST)/$(WIN32_TARGET_DIR)/"
|
cp "$(SERVER_BUILD_DIR)"/server/scrcpy-server "$(DIST)/$(WIN32_TARGET_DIR)/"
|
||||||
cp "$(WIN32_BUILD_DIR)"/app/scrcpy.exe "$(DIST)/$(WIN32_TARGET_DIR)/"
|
cp "$(WIN32_BUILD_DIR)"/app/scrcpy.exe "$(DIST)/$(WIN32_TARGET_DIR)/"
|
||||||
cp "$(WIN32_NOCONSOLE_BUILD_DIR)"/app/scrcpy.exe "$(DIST)/$(WIN32_TARGET_DIR)/scrcpy-noconsole.exe"
|
cp "$(WIN32_NOCONSOLE_BUILD_DIR)"/app/scrcpy.exe "$(DIST)/$(WIN32_TARGET_DIR)/scrcpy-noconsole.exe"
|
||||||
cp prebuilt-deps/ffmpeg-4.2.1-win32-shared/bin/avutil-56.dll "$(DIST)/$(WIN32_TARGET_DIR)/"
|
cp prebuilt-deps/ffmpeg-4.1.4-win32-shared/bin/avutil-56.dll "$(DIST)/$(WIN32_TARGET_DIR)/"
|
||||||
cp prebuilt-deps/ffmpeg-4.2.1-win32-shared/bin/avcodec-58.dll "$(DIST)/$(WIN32_TARGET_DIR)/"
|
cp prebuilt-deps/ffmpeg-4.1.4-win32-shared/bin/avcodec-58.dll "$(DIST)/$(WIN32_TARGET_DIR)/"
|
||||||
cp prebuilt-deps/ffmpeg-4.2.1-win32-shared/bin/avformat-58.dll "$(DIST)/$(WIN32_TARGET_DIR)/"
|
cp prebuilt-deps/ffmpeg-4.1.4-win32-shared/bin/avformat-58.dll "$(DIST)/$(WIN32_TARGET_DIR)/"
|
||||||
cp prebuilt-deps/ffmpeg-4.2.1-win32-shared/bin/swresample-3.dll "$(DIST)/$(WIN32_TARGET_DIR)/"
|
cp prebuilt-deps/ffmpeg-4.1.4-win32-shared/bin/swresample-3.dll "$(DIST)/$(WIN32_TARGET_DIR)/"
|
||||||
cp prebuilt-deps/ffmpeg-4.2.1-win32-shared/bin/swscale-5.dll "$(DIST)/$(WIN32_TARGET_DIR)/"
|
cp prebuilt-deps/ffmpeg-4.1.4-win32-shared/bin/swscale-5.dll "$(DIST)/$(WIN32_TARGET_DIR)/"
|
||||||
cp prebuilt-deps/platform-tools/adb.exe "$(DIST)/$(WIN32_TARGET_DIR)/"
|
cp prebuilt-deps/platform-tools/adb.exe "$(DIST)/$(WIN32_TARGET_DIR)/"
|
||||||
cp prebuilt-deps/platform-tools/AdbWinApi.dll "$(DIST)/$(WIN32_TARGET_DIR)/"
|
cp prebuilt-deps/platform-tools/AdbWinApi.dll "$(DIST)/$(WIN32_TARGET_DIR)/"
|
||||||
cp prebuilt-deps/platform-tools/AdbWinUsbApi.dll "$(DIST)/$(WIN32_TARGET_DIR)/"
|
cp prebuilt-deps/platform-tools/AdbWinUsbApi.dll "$(DIST)/$(WIN32_TARGET_DIR)/"
|
||||||
@@ -115,11 +115,11 @@ dist-win64: build-server build-win64 build-win64-noconsole
|
|||||||
cp "$(SERVER_BUILD_DIR)"/server/scrcpy-server "$(DIST)/$(WIN64_TARGET_DIR)/"
|
cp "$(SERVER_BUILD_DIR)"/server/scrcpy-server "$(DIST)/$(WIN64_TARGET_DIR)/"
|
||||||
cp "$(WIN64_BUILD_DIR)"/app/scrcpy.exe "$(DIST)/$(WIN64_TARGET_DIR)/"
|
cp "$(WIN64_BUILD_DIR)"/app/scrcpy.exe "$(DIST)/$(WIN64_TARGET_DIR)/"
|
||||||
cp "$(WIN64_NOCONSOLE_BUILD_DIR)"/app/scrcpy.exe "$(DIST)/$(WIN64_TARGET_DIR)/scrcpy-noconsole.exe"
|
cp "$(WIN64_NOCONSOLE_BUILD_DIR)"/app/scrcpy.exe "$(DIST)/$(WIN64_TARGET_DIR)/scrcpy-noconsole.exe"
|
||||||
cp prebuilt-deps/ffmpeg-4.2.1-win64-shared/bin/avutil-56.dll "$(DIST)/$(WIN64_TARGET_DIR)/"
|
cp prebuilt-deps/ffmpeg-4.1.4-win64-shared/bin/avutil-56.dll "$(DIST)/$(WIN64_TARGET_DIR)/"
|
||||||
cp prebuilt-deps/ffmpeg-4.2.1-win64-shared/bin/avcodec-58.dll "$(DIST)/$(WIN64_TARGET_DIR)/"
|
cp prebuilt-deps/ffmpeg-4.1.4-win64-shared/bin/avcodec-58.dll "$(DIST)/$(WIN64_TARGET_DIR)/"
|
||||||
cp prebuilt-deps/ffmpeg-4.2.1-win64-shared/bin/avformat-58.dll "$(DIST)/$(WIN64_TARGET_DIR)/"
|
cp prebuilt-deps/ffmpeg-4.1.4-win64-shared/bin/avformat-58.dll "$(DIST)/$(WIN64_TARGET_DIR)/"
|
||||||
cp prebuilt-deps/ffmpeg-4.2.1-win64-shared/bin/swresample-3.dll "$(DIST)/$(WIN64_TARGET_DIR)/"
|
cp prebuilt-deps/ffmpeg-4.1.4-win64-shared/bin/swresample-3.dll "$(DIST)/$(WIN64_TARGET_DIR)/"
|
||||||
cp prebuilt-deps/ffmpeg-4.2.1-win64-shared/bin/swscale-5.dll "$(DIST)/$(WIN64_TARGET_DIR)/"
|
cp prebuilt-deps/ffmpeg-4.1.4-win64-shared/bin/swscale-5.dll "$(DIST)/$(WIN64_TARGET_DIR)/"
|
||||||
cp prebuilt-deps/platform-tools/adb.exe "$(DIST)/$(WIN64_TARGET_DIR)/"
|
cp prebuilt-deps/platform-tools/adb.exe "$(DIST)/$(WIN64_TARGET_DIR)/"
|
||||||
cp prebuilt-deps/platform-tools/AdbWinApi.dll "$(DIST)/$(WIN64_TARGET_DIR)/"
|
cp prebuilt-deps/platform-tools/AdbWinApi.dll "$(DIST)/$(WIN64_TARGET_DIR)/"
|
||||||
cp prebuilt-deps/platform-tools/AdbWinUsbApi.dll "$(DIST)/$(WIN64_TARGET_DIR)/"
|
cp prebuilt-deps/platform-tools/AdbWinUsbApi.dll "$(DIST)/$(WIN64_TARGET_DIR)/"
|
||||||
|
|||||||
@@ -108,9 +108,8 @@ scrcpy --help
|
|||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
### Capture configuration
|
|
||||||
|
|
||||||
#### Reduce size
|
### Reduce size
|
||||||
|
|
||||||
Sometimes, it is useful to mirror an Android device at a lower definition to
|
Sometimes, it is useful to mirror an Android device at a lower definition to
|
||||||
increase performance.
|
increase performance.
|
||||||
@@ -126,7 +125,7 @@ The other dimension is computed to that the device aspect ratio is preserved.
|
|||||||
That way, a device in 1920×1080 will be mirrored at 1024×576.
|
That way, a device in 1920×1080 will be mirrored at 1024×576.
|
||||||
|
|
||||||
|
|
||||||
#### Change bit-rate
|
### Change bit-rate
|
||||||
|
|
||||||
The default bit-rate is 8 Mbps. To change the video bitrate (e.g. to 2 Mbps):
|
The default bit-rate is 8 Mbps. To change the video bitrate (e.g. to 2 Mbps):
|
||||||
|
|
||||||
@@ -135,15 +134,8 @@ scrcpy --bit-rate 2M
|
|||||||
scrcpy -b 2M # short version
|
scrcpy -b 2M # short version
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Limit frame rate
|
|
||||||
|
|
||||||
On devices with Android >= 10, the capture frame rate can be limited:
|
### Crop
|
||||||
|
|
||||||
```bash
|
|
||||||
scrcpy --max-fps 15
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Crop
|
|
||||||
|
|
||||||
The device screen may be cropped to mirror only part of the screen.
|
The device screen may be cropped to mirror only part of the screen.
|
||||||
|
|
||||||
@@ -156,7 +148,29 @@ scrcpy --crop 1224:1440:0:0 # 1224x1440 at offset (0,0)
|
|||||||
If `--max-size` is also specified, resizing is applied after cropping.
|
If `--max-size` is also specified, resizing is applied after cropping.
|
||||||
|
|
||||||
|
|
||||||
### Recording
|
### Wireless
|
||||||
|
|
||||||
|
_Scrcpy_ uses `adb` to communicate with the device, and `adb` can [connect] to a
|
||||||
|
device over TCP/IP:
|
||||||
|
|
||||||
|
1. Connect the device to the same Wi-Fi as your computer.
|
||||||
|
2. Get your device IP address (in Settings → About phone → Status).
|
||||||
|
3. Enable adb over TCP/IP on your device: `adb tcpip 5555`.
|
||||||
|
4. Unplug your device.
|
||||||
|
5. Connect to your device: `adb connect DEVICE_IP:5555` _(replace `DEVICE_IP`)_.
|
||||||
|
6. Run `scrcpy` as usual.
|
||||||
|
|
||||||
|
It may be useful to decrease the bit-rate and the definition:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --bit-rate 2M --max-size 800
|
||||||
|
scrcpy -b2M -m800 # short version
|
||||||
|
```
|
||||||
|
|
||||||
|
[connect]: https://developer.android.com/studio/command-line/adb.html#wireless
|
||||||
|
|
||||||
|
|
||||||
|
### Record screen
|
||||||
|
|
||||||
It is possible to record the screen while mirroring:
|
It is possible to record the screen while mirroring:
|
||||||
|
|
||||||
@@ -181,31 +195,7 @@ variation] does not impact the recorded file.
|
|||||||
[packet delay variation]: https://en.wikipedia.org/wiki/Packet_delay_variation
|
[packet delay variation]: https://en.wikipedia.org/wiki/Packet_delay_variation
|
||||||
|
|
||||||
|
|
||||||
### Connection
|
### Multi-devices
|
||||||
|
|
||||||
#### Wireless
|
|
||||||
|
|
||||||
_Scrcpy_ uses `adb` to communicate with the device, and `adb` can [connect] to a
|
|
||||||
device over TCP/IP:
|
|
||||||
|
|
||||||
1. Connect the device to the same Wi-Fi as your computer.
|
|
||||||
2. Get your device IP address (in Settings → About phone → Status).
|
|
||||||
3. Enable adb over TCP/IP on your device: `adb tcpip 5555`.
|
|
||||||
4. Unplug your device.
|
|
||||||
5. Connect to your device: `adb connect DEVICE_IP:5555` _(replace `DEVICE_IP`)_.
|
|
||||||
6. Run `scrcpy` as usual.
|
|
||||||
|
|
||||||
It may be useful to decrease the bit-rate and the definition:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
scrcpy --bit-rate 2M --max-size 800
|
|
||||||
scrcpy -b2M -m800 # short version
|
|
||||||
```
|
|
||||||
|
|
||||||
[connect]: https://developer.android.com/studio/command-line/adb.html#wireless
|
|
||||||
|
|
||||||
|
|
||||||
#### Multi-devices
|
|
||||||
|
|
||||||
If several devices are listed in `adb devices`, you must specify the _serial_:
|
If several devices are listed in `adb devices`, you must specify the _serial_:
|
||||||
|
|
||||||
@@ -216,65 +206,8 @@ scrcpy -s 0123456789abcdef # short version
|
|||||||
|
|
||||||
You can start several instances of _scrcpy_ for several devices.
|
You can start several instances of _scrcpy_ for several devices.
|
||||||
|
|
||||||
#### SSH tunnel
|
|
||||||
|
|
||||||
To connect to a remote device, it is possible to connect a local `adb` client to
|
### Fullscreen
|
||||||
a remote `adb` server (provided they use the same version of the _adb_
|
|
||||||
protocol):
|
|
||||||
|
|
||||||
```bash
|
|
||||||
adb kill-server # kill the local adb server on 5037
|
|
||||||
ssh -CN -L5037:localhost:5037 -R27183:localhost:27183 your_remote_computer
|
|
||||||
# keep this open
|
|
||||||
```
|
|
||||||
|
|
||||||
From another terminal:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
scrcpy
|
|
||||||
```
|
|
||||||
|
|
||||||
Like for wireless connections, it may be useful to reduce quality:
|
|
||||||
|
|
||||||
```
|
|
||||||
scrcpy -b2M -m800 --max-fps 15
|
|
||||||
```
|
|
||||||
|
|
||||||
### Window configuration
|
|
||||||
|
|
||||||
#### Title
|
|
||||||
|
|
||||||
By default, the window title is the device model. It can be changed:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
scrcpy --window-title 'My device'
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Position and size
|
|
||||||
|
|
||||||
The initial window position and size may be specified:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
scrcpy --window-x 100 --window-y 100 --window-width 800 --window-height 600
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Borderless
|
|
||||||
|
|
||||||
To disable window decorations:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
scrcpy --window-borderless
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Always on top
|
|
||||||
|
|
||||||
To keep the scrcpy window always on top:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
scrcpy --always-on-top
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Fullscreen
|
|
||||||
|
|
||||||
The app may be started directly in fullscreen:
|
The app may be started directly in fullscreen:
|
||||||
|
|
||||||
@@ -286,45 +219,16 @@ scrcpy -f # short version
|
|||||||
Fullscreen can then be toggled dynamically with `Ctrl`+`f`.
|
Fullscreen can then be toggled dynamically with `Ctrl`+`f`.
|
||||||
|
|
||||||
|
|
||||||
### Other mirroring options
|
### Always on top
|
||||||
|
|
||||||
#### Read-only
|
The window of app can always be above others by:
|
||||||
|
|
||||||
To disable controls (everything which can interact with the device: input keys,
|
|
||||||
mouse events, drag&drop files):
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
scrcpy --no-control
|
scrcpy --always-on-top
|
||||||
scrcpy -n
|
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Turn screen off
|
|
||||||
|
|
||||||
It is possible to turn the device screen off while mirroring on start with a
|
### Show touches
|
||||||
command-line option:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
scrcpy --turn-screen-off
|
|
||||||
scrcpy -S
|
|
||||||
```
|
|
||||||
|
|
||||||
Or by pressing `Ctrl`+`o` at any time.
|
|
||||||
|
|
||||||
To turn it back on, press `POWER` (or `Ctrl`+`p`).
|
|
||||||
|
|
||||||
#### Render expired frames
|
|
||||||
|
|
||||||
By default, to minimize latency, _scrcpy_ always renders the last decoded frame
|
|
||||||
available, and drops any previous one.
|
|
||||||
|
|
||||||
To force the rendering of all frames (at a cost of a possible increased
|
|
||||||
latency), use:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
scrcpy --render-expired-frames
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Show touches
|
|
||||||
|
|
||||||
For presentations, it may be useful to show physical touches (on the physical
|
For presentations, it may be useful to show physical touches (on the physical
|
||||||
device).
|
device).
|
||||||
@@ -341,43 +245,7 @@ scrcpy -t
|
|||||||
Note that it only shows _physical_ touches (with the finger on the device).
|
Note that it only shows _physical_ touches (with the finger on the device).
|
||||||
|
|
||||||
|
|
||||||
### Input control
|
### Install APK
|
||||||
|
|
||||||
#### Copy-paste
|
|
||||||
|
|
||||||
It is possible to synchronize clipboards between the computer and the device, in
|
|
||||||
both directions:
|
|
||||||
|
|
||||||
- `Ctrl`+`c` copies the device clipboard to the computer clipboard;
|
|
||||||
- `Ctrl`+`Shift`+`v` copies the computer clipboard to the device clipboard;
|
|
||||||
- `Ctrl`+`v` _pastes_ the computer clipboard as a sequence of text events (but
|
|
||||||
breaks non-ASCII characters).
|
|
||||||
|
|
||||||
#### Text injection preference
|
|
||||||
|
|
||||||
There are two kinds of [events][textevents] generated when typing text:
|
|
||||||
- _key events_, signaling that a key is pressed or released;
|
|
||||||
- _text events_, signaling that a text has been entered.
|
|
||||||
|
|
||||||
By default, letters are injected using key events, so that the keyboard behaves
|
|
||||||
as expected in games (typically for WASD keys).
|
|
||||||
|
|
||||||
But this may [cause issues][prefertext]. If you encounter such a problem, you
|
|
||||||
can avoid it by:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
scrcpy --prefer-text
|
|
||||||
```
|
|
||||||
|
|
||||||
(but this will break keyboard behavior in games)
|
|
||||||
|
|
||||||
[textevents]: https://blog.rom1v.com/2018/03/introducing-scrcpy/#handle-text-input
|
|
||||||
[prefertext]: https://github.com/Genymobile/scrcpy/issues/650#issuecomment-512945343
|
|
||||||
|
|
||||||
|
|
||||||
### File drop
|
|
||||||
|
|
||||||
#### Install APK
|
|
||||||
|
|
||||||
To install an APK, drag & drop an APK file (ending with `.apk`) to the _scrcpy_
|
To install an APK, drag & drop an APK file (ending with `.apk`) to the _scrcpy_
|
||||||
window.
|
window.
|
||||||
@@ -385,7 +253,7 @@ window.
|
|||||||
There is no visual feedback, a log is printed to the console.
|
There is no visual feedback, a log is printed to the console.
|
||||||
|
|
||||||
|
|
||||||
#### Push file to device
|
### Push file to device
|
||||||
|
|
||||||
To push a file to `/sdcard/` on the device, drag & drop a (non-APK) file to the
|
To push a file to `/sdcard/` on the device, drag & drop a (non-APK) file to the
|
||||||
_scrcpy_ window.
|
_scrcpy_ window.
|
||||||
@@ -398,8 +266,53 @@ The target directory can be changed on start:
|
|||||||
scrcpy --push-target /sdcard/foo/bar/
|
scrcpy --push-target /sdcard/foo/bar/
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Read-only
|
||||||
|
|
||||||
### Audio forwarding
|
To disable controls (everything which can interact with the device: input keys,
|
||||||
|
mouse events, drag&drop files):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --no-control
|
||||||
|
scrcpy -n
|
||||||
|
```
|
||||||
|
|
||||||
|
### Turn screen off
|
||||||
|
|
||||||
|
It is possible to turn the device screen off while mirroring on start with a
|
||||||
|
command-line option:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --turn-screen-off
|
||||||
|
scrcpy -S
|
||||||
|
```
|
||||||
|
|
||||||
|
Or by pressing `Ctrl`+`o` at any time.
|
||||||
|
|
||||||
|
To turn it back on, press `POWER` (or `Ctrl`+`p`).
|
||||||
|
|
||||||
|
|
||||||
|
### Render expired frames
|
||||||
|
|
||||||
|
By default, to minimize latency, _scrcpy_ always renders the last decoded frame
|
||||||
|
available, and drops any previous one.
|
||||||
|
|
||||||
|
To force the rendering of all frames (at a cost of a possible increased
|
||||||
|
latency), use:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --render-expired-frames
|
||||||
|
```
|
||||||
|
|
||||||
|
### Custom window title
|
||||||
|
|
||||||
|
By default, the window title is the device model. It can be changed:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --window-title 'My device'
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### Forward audio
|
||||||
|
|
||||||
Audio is not forwarded by _scrcpy_. Use [USBaudio] (Linux-only).
|
Audio is not forwarded by _scrcpy_. Use [USBaudio] (Linux-only).
|
||||||
|
|
||||||
|
|||||||
+4
-2
@@ -123,8 +123,10 @@ configure_file(configuration: conf, output: 'config.h')
|
|||||||
src_dir = include_directories('src')
|
src_dir = include_directories('src')
|
||||||
|
|
||||||
if get_option('windows_noconsole')
|
if get_option('windows_noconsole')
|
||||||
link_args = [ '-Wl,--subsystem,windows' ]
|
c_args = [ '-mwindows' ]
|
||||||
|
link_args = [ '-mwindows' ]
|
||||||
else
|
else
|
||||||
|
c_args = []
|
||||||
link_args = []
|
link_args = []
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -132,7 +134,7 @@ executable('scrcpy', src,
|
|||||||
dependencies: dependencies,
|
dependencies: dependencies,
|
||||||
include_directories: src_dir,
|
include_directories: src_dir,
|
||||||
install: true,
|
install: true,
|
||||||
c_args: [],
|
c_args: c_args,
|
||||||
link_args: link_args)
|
link_args: link_args)
|
||||||
|
|
||||||
install_man('scrcpy.1')
|
install_man('scrcpy.1')
|
||||||
|
|||||||
+10
-41
@@ -15,10 +15,6 @@ provides display and control of Android devices connected on USB (or over TCP/IP
|
|||||||
|
|
||||||
.SH OPTIONS
|
.SH OPTIONS
|
||||||
|
|
||||||
.TP
|
|
||||||
.B \-\-always\-on\-top
|
|
||||||
Make scrcpy window always on top (above other windows).
|
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.BI "\-b, \-\-bit\-rate " value
|
.BI "\-b, \-\-bit\-rate " value
|
||||||
Encode the video at the given bit\-rate, expressed in bits/s. Unit suffixes are supported: '\fBK\fR' (x1000) and '\fBM\fR' (x1000000).
|
Encode the video at the given bit\-rate, expressed in bits/s. Unit suffixes are supported: '\fBK\fR' (x1000) and '\fBM\fR' (x1000000).
|
||||||
@@ -26,7 +22,7 @@ Encode the video at the given bit\-rate, expressed in bits/s. Unit suffixes are
|
|||||||
Default is 8000000.
|
Default is 8000000.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.BI \-\-crop " width\fR:\fIheight\fR:\fIx\fR:\fIy
|
.BI "\-c, \-\-crop " width\fR:\fIheight\fR:\fIx\fR:\fIy
|
||||||
Crop the device screen on the server.
|
Crop the device screen on the server.
|
||||||
|
|
||||||
The values are expressed in the device natural orientation (typically, portrait for a phone, landscape for a tablet). Any
|
The values are expressed in the device natural orientation (typically, portrait for a phone, landscape for a tablet). Any
|
||||||
@@ -38,12 +34,12 @@ value is computed on the cropped size.
|
|||||||
Start in fullscreen.
|
Start in fullscreen.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B \-h, \-\-help
|
.BI "\-F, \-\-record\-format " format
|
||||||
Print this help.
|
Force recording format (either mp4 or mkv).
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.BI \-\-max\-fps " value
|
.B \-h, \-\-help
|
||||||
Limit the framerate of screen capture (only supported on devices with Android >= 10).
|
Print this help.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.BI "\-m, \-\-max\-size " value
|
.BI "\-m, \-\-max\-size " value
|
||||||
@@ -84,13 +80,9 @@ Record screen to
|
|||||||
.IR file .
|
.IR file .
|
||||||
|
|
||||||
The format is determined by the
|
The format is determined by the
|
||||||
.B \-\-record\-format
|
.B \-F/\-\-record\-format
|
||||||
option if set, or by the file extension (.mp4 or .mkv).
|
option if set, or by the file extension (.mp4 or .mkv).
|
||||||
|
|
||||||
.TP
|
|
||||||
.BI \-\-record\-format " format
|
|
||||||
Force recording format (either mp4 or mkv).
|
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B \-\-render\-expired\-frames
|
.B \-\-render\-expired\-frames
|
||||||
By default, to minimize latency, scrcpy always renders the last available decoded frame, and drops any previous ones. This flag forces to render all frames, at a cost of a possible increased latency.
|
By default, to minimize latency, scrcpy always renders the last available decoded frame, and drops any previous ones. This flag forces to render all frames, at a cost of a possible increased latency.
|
||||||
@@ -110,40 +102,17 @@ Enable "show touches" on start, disable on quit.
|
|||||||
It only shows physical touches (not clicks from scrcpy).
|
It only shows physical touches (not clicks from scrcpy).
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B \-v, \-\-version
|
.B \-T, \-\-always\-on\-top
|
||||||
Print the version of scrcpy.
|
Make scrcpy window always on top (above other windows).
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B \-\-window\-borderless
|
.B \-v, \-\-version
|
||||||
Disable window decorations (display borderless window).
|
Print the version of scrcpy.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.BI \-\-window\-title " text
|
.BI \-\-window\-title " text
|
||||||
Set a custom window title.
|
Set a custom window title.
|
||||||
|
|
||||||
.TP
|
|
||||||
.BI \-\-window\-x " value
|
|
||||||
Set the initial window horizontal position.
|
|
||||||
|
|
||||||
Default is -1 (automatic).\n
|
|
||||||
|
|
||||||
.TP
|
|
||||||
.BI \-\-window\-y " value
|
|
||||||
Set the initial window vertical position.
|
|
||||||
|
|
||||||
Default is -1 (automatic).\n
|
|
||||||
|
|
||||||
.TP
|
|
||||||
.BI \-\-window\-width " value
|
|
||||||
Set the initial window width.
|
|
||||||
|
|
||||||
Default is 0 (automatic).\n
|
|
||||||
|
|
||||||
.TP
|
|
||||||
.BI \-\-window\-height " value
|
|
||||||
Set the initial window height.
|
|
||||||
|
|
||||||
Default is 0 (automatic).\n
|
|
||||||
|
|
||||||
.SH SHORTCUTS
|
.SH SHORTCUTS
|
||||||
|
|
||||||
|
|||||||
+11
-138
@@ -30,15 +30,12 @@ static void usage(const char *arg0) {
|
|||||||
"\n"
|
"\n"
|
||||||
"Options:\n"
|
"Options:\n"
|
||||||
"\n"
|
"\n"
|
||||||
" --always-on-top\n"
|
|
||||||
" Make scrcpy window always on top (above other windows).\n"
|
|
||||||
"\n"
|
|
||||||
" -b, --bit-rate value\n"
|
" -b, --bit-rate value\n"
|
||||||
" Encode the video at the given bit-rate, expressed in bits/s.\n"
|
" Encode the video at the given bit-rate, expressed in bits/s.\n"
|
||||||
" Unit suffixes are supported: 'K' (x1000) and 'M' (x1000000).\n"
|
" Unit suffixes are supported: 'K' (x1000) and 'M' (x1000000).\n"
|
||||||
" Default is %d.\n"
|
" Default is %d.\n"
|
||||||
"\n"
|
"\n"
|
||||||
" --crop width:height:x:y\n"
|
" -c, --crop width:height:x:y\n"
|
||||||
" Crop the device screen on the server.\n"
|
" Crop the device screen on the server.\n"
|
||||||
" The values are expressed in the device natural orientation\n"
|
" The values are expressed in the device natural orientation\n"
|
||||||
" (typically, portrait for a phone, landscape for a tablet).\n"
|
" (typically, portrait for a phone, landscape for a tablet).\n"
|
||||||
@@ -47,13 +44,12 @@ static void usage(const char *arg0) {
|
|||||||
" -f, --fullscreen\n"
|
" -f, --fullscreen\n"
|
||||||
" Start in fullscreen.\n"
|
" Start in fullscreen.\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
" -F, --record-format format\n"
|
||||||
|
" Force recording format (either mp4 or mkv).\n"
|
||||||
|
"\n"
|
||||||
" -h, --help\n"
|
" -h, --help\n"
|
||||||
" Print this help.\n"
|
" Print this help.\n"
|
||||||
"\n"
|
"\n"
|
||||||
" --max-fps value\n"
|
|
||||||
" Limit the frame rate of screen capture (only supported on\n"
|
|
||||||
" devices with Android >= 10).\n"
|
|
||||||
"\n"
|
|
||||||
" -m, --max-size value\n"
|
" -m, --max-size value\n"
|
||||||
" Limit both the width and height of the video to value. The\n"
|
" Limit both the width and height of the video to value. The\n"
|
||||||
" other dimension is computed so that the device aspect-ratio\n"
|
" other dimension is computed so that the device aspect-ratio\n"
|
||||||
@@ -85,12 +81,9 @@ static void usage(const char *arg0) {
|
|||||||
"\n"
|
"\n"
|
||||||
" -r, --record file.mp4\n"
|
" -r, --record file.mp4\n"
|
||||||
" Record screen to file.\n"
|
" Record screen to file.\n"
|
||||||
" The format is determined by the --record-format option if\n"
|
" The format is determined by the -F/--record-format option if\n"
|
||||||
" set, or by the file extension (.mp4 or .mkv).\n"
|
" set, or by the file extension (.mp4 or .mkv).\n"
|
||||||
"\n"
|
"\n"
|
||||||
" --record-format format\n"
|
|
||||||
" Force recording format (either mp4 or mkv).\n"
|
|
||||||
"\n"
|
|
||||||
" --render-expired-frames\n"
|
" --render-expired-frames\n"
|
||||||
" By default, to minimize latency, scrcpy always renders the\n"
|
" By default, to minimize latency, scrcpy always renders the\n"
|
||||||
" last available decoded frame, and drops any previous ones.\n"
|
" last available decoded frame, and drops any previous ones.\n"
|
||||||
@@ -108,31 +101,15 @@ static void usage(const char *arg0) {
|
|||||||
" Enable \"show touches\" on start, disable on quit.\n"
|
" Enable \"show touches\" on start, disable on quit.\n"
|
||||||
" It only shows physical touches (not clicks from scrcpy).\n"
|
" It only shows physical touches (not clicks from scrcpy).\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
" -T, --always-on-top\n"
|
||||||
|
" Make scrcpy window always on top (above other windows).\n"
|
||||||
|
"\n"
|
||||||
" -v, --version\n"
|
" -v, --version\n"
|
||||||
" Print the version of scrcpy.\n"
|
" Print the version of scrcpy.\n"
|
||||||
"\n"
|
"\n"
|
||||||
" --window-borderless\n"
|
|
||||||
" Disable window decorations (display borderless window).\n"
|
|
||||||
"\n"
|
|
||||||
" --window-title text\n"
|
" --window-title text\n"
|
||||||
" Set a custom window title.\n"
|
" Set a custom window title.\n"
|
||||||
"\n"
|
"\n"
|
||||||
" --window-x value\n"
|
|
||||||
" Set the initial window horizontal position.\n"
|
|
||||||
" Default is -1 (automatic).\n"
|
|
||||||
"\n"
|
|
||||||
" --window-y value\n"
|
|
||||||
" Set the initial window vertical position.\n"
|
|
||||||
" Default is -1 (automatic).\n"
|
|
||||||
"\n"
|
|
||||||
" --window-width value\n"
|
|
||||||
" Set the initial window width.\n"
|
|
||||||
" Default is 0 (automatic).\n"
|
|
||||||
"\n"
|
|
||||||
" --window-height value\n"
|
|
||||||
" Set the initial window width.\n"
|
|
||||||
" Default is 0 (automatic).\n"
|
|
||||||
"\n"
|
|
||||||
"Shortcuts:\n"
|
"Shortcuts:\n"
|
||||||
"\n"
|
"\n"
|
||||||
" " CTRL_OR_CMD "+f\n"
|
" " CTRL_OR_CMD "+f\n"
|
||||||
@@ -273,75 +250,11 @@ parse_max_size(char *optarg, uint16_t *max_size) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
|
||||||
parse_max_fps(const char *optarg, uint16_t *max_fps) {
|
|
||||||
char *endptr;
|
|
||||||
if (*optarg == '\0') {
|
|
||||||
LOGE("Max FPS parameter is empty");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
long value = strtol(optarg, &endptr, 0);
|
|
||||||
if (*endptr != '\0') {
|
|
||||||
LOGE("Invalid max FPS: %s", optarg);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (value & ~0xffff) {
|
|
||||||
// in practice, it should not be higher than 60
|
|
||||||
LOGE("Max FPS value is invalid: %ld", value);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
*max_fps = (uint16_t) value;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool
|
|
||||||
parse_window_position(char *optarg, int16_t *position) {
|
|
||||||
char *endptr;
|
|
||||||
if (*optarg == '\0') {
|
|
||||||
LOGE("Window position parameter is empty");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
long value = strtol(optarg, &endptr, 0);
|
|
||||||
if (*endptr != '\0') {
|
|
||||||
LOGE("Invalid window position: %s", optarg);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (value < -1 || value > 0x7fff) {
|
|
||||||
LOGE("Window position must be between -1 and 32767: %ld", value);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
*position = (int16_t) value;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool
|
|
||||||
parse_window_dimension(char *optarg, uint16_t *dimension) {
|
|
||||||
char *endptr;
|
|
||||||
if (*optarg == '\0') {
|
|
||||||
LOGE("Window dimension parameter is empty");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
long value = strtol(optarg, &endptr, 0);
|
|
||||||
if (*endptr != '\0') {
|
|
||||||
LOGE("Invalid window dimension: %s", optarg);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (value & ~0xffff) {
|
|
||||||
LOGE("Window position must be between 0 and 65535: %ld", value);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
*dimension = (uint16_t) value;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
parse_port(char *optarg, uint16_t *port) {
|
parse_port(char *optarg, uint16_t *port) {
|
||||||
char *endptr;
|
char *endptr;
|
||||||
if (*optarg == '\0') {
|
if (*optarg == '\0') {
|
||||||
LOGE("Port parameter is empty");
|
LOGE("Invalid port parameter is empty");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
long value = strtol(optarg, &endptr, 0);
|
long value = strtol(optarg, &endptr, 0);
|
||||||
@@ -395,12 +308,6 @@ guess_record_format(const char *filename) {
|
|||||||
#define OPT_CROP 1004
|
#define OPT_CROP 1004
|
||||||
#define OPT_RECORD_FORMAT 1005
|
#define OPT_RECORD_FORMAT 1005
|
||||||
#define OPT_PREFER_TEXT 1006
|
#define OPT_PREFER_TEXT 1006
|
||||||
#define OPT_WINDOW_X 1007
|
|
||||||
#define OPT_WINDOW_Y 1008
|
|
||||||
#define OPT_WINDOW_WIDTH 1009
|
|
||||||
#define OPT_WINDOW_HEIGHT 1010
|
|
||||||
#define OPT_WINDOW_BORDERLESS 1011
|
|
||||||
#define OPT_MAX_FPS 1012
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
parse_args(struct args *args, int argc, char *argv[]) {
|
parse_args(struct args *args, int argc, char *argv[]) {
|
||||||
@@ -410,7 +317,6 @@ parse_args(struct args *args, int argc, char *argv[]) {
|
|||||||
{"crop", required_argument, NULL, OPT_CROP},
|
{"crop", required_argument, NULL, OPT_CROP},
|
||||||
{"fullscreen", no_argument, NULL, 'f'},
|
{"fullscreen", no_argument, NULL, 'f'},
|
||||||
{"help", no_argument, NULL, 'h'},
|
{"help", no_argument, NULL, 'h'},
|
||||||
{"max-fps", required_argument, NULL, OPT_MAX_FPS},
|
|
||||||
{"max-size", required_argument, NULL, 'm'},
|
{"max-size", required_argument, NULL, 'm'},
|
||||||
{"no-control", no_argument, NULL, 'n'},
|
{"no-control", no_argument, NULL, 'n'},
|
||||||
{"no-display", no_argument, NULL, 'N'},
|
{"no-display", no_argument, NULL, 'N'},
|
||||||
@@ -425,13 +331,8 @@ parse_args(struct args *args, int argc, char *argv[]) {
|
|||||||
{"turn-screen-off", no_argument, NULL, 'S'},
|
{"turn-screen-off", no_argument, NULL, 'S'},
|
||||||
{"prefer-text", no_argument, NULL, OPT_PREFER_TEXT},
|
{"prefer-text", no_argument, NULL, OPT_PREFER_TEXT},
|
||||||
{"version", no_argument, NULL, 'v'},
|
{"version", no_argument, NULL, 'v'},
|
||||||
{"window-title", required_argument, NULL, OPT_WINDOW_TITLE},
|
{"window-title", required_argument, NULL,
|
||||||
{"window-x", required_argument, NULL, OPT_WINDOW_X},
|
OPT_WINDOW_TITLE},
|
||||||
{"window-y", required_argument, NULL, OPT_WINDOW_Y},
|
|
||||||
{"window-width", required_argument, NULL, OPT_WINDOW_WIDTH},
|
|
||||||
{"window-height", required_argument, NULL, OPT_WINDOW_HEIGHT},
|
|
||||||
{"window-borderless", no_argument, NULL,
|
|
||||||
OPT_WINDOW_BORDERLESS},
|
|
||||||
{NULL, 0, NULL, 0 },
|
{NULL, 0, NULL, 0 },
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -466,11 +367,6 @@ parse_args(struct args *args, int argc, char *argv[]) {
|
|||||||
case 'h':
|
case 'h':
|
||||||
args->help = true;
|
args->help = true;
|
||||||
break;
|
break;
|
||||||
case OPT_MAX_FPS:
|
|
||||||
if (!parse_max_fps(optarg, &opts->max_fps)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'm':
|
case 'm':
|
||||||
if (!parse_max_size(optarg, &opts->max_size)) {
|
if (!parse_max_size(optarg, &opts->max_size)) {
|
||||||
return false;
|
return false;
|
||||||
@@ -514,29 +410,6 @@ parse_args(struct args *args, int argc, char *argv[]) {
|
|||||||
case OPT_WINDOW_TITLE:
|
case OPT_WINDOW_TITLE:
|
||||||
opts->window_title = optarg;
|
opts->window_title = optarg;
|
||||||
break;
|
break;
|
||||||
case OPT_WINDOW_X:
|
|
||||||
if (!parse_window_position(optarg, &opts->window_x)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case OPT_WINDOW_Y:
|
|
||||||
if (!parse_window_position(optarg, &opts->window_y)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case OPT_WINDOW_WIDTH:
|
|
||||||
if (!parse_window_dimension(optarg, &opts->window_width)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case OPT_WINDOW_HEIGHT:
|
|
||||||
if (!parse_window_dimension(optarg, &opts->window_height)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case OPT_WINDOW_BORDERLESS:
|
|
||||||
opts->window_borderless = true;
|
|
||||||
break;
|
|
||||||
case OPT_PUSH_TARGET:
|
case OPT_PUSH_TARGET:
|
||||||
opts->push_target = optarg;
|
opts->push_target = optarg;
|
||||||
break;
|
break;
|
||||||
|
|||||||
+2
-6
@@ -301,12 +301,8 @@ run_recorder(void *data) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// config packets have no PTS, we must ignore them
|
// we now know the duration of the previous packet
|
||||||
if (rec->packet.pts != AV_NOPTS_VALUE
|
previous->packet.duration = rec->packet.pts - previous->packet.pts;
|
||||||
&& previous->packet.pts != AV_NOPTS_VALUE) {
|
|
||||||
// we now know the duration of the previous packet
|
|
||||||
previous->packet.duration = rec->packet.pts - previous->packet.pts;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ok = recorder_write(recorder, &previous->packet);
|
bool ok = recorder_write(recorder, &previous->packet);
|
||||||
record_packet_delete(previous);
|
record_packet_delete(previous);
|
||||||
|
|||||||
+7
-6
@@ -144,7 +144,12 @@ handle_event(SDL_Event *event, bool control) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SDL_WINDOWEVENT:
|
case SDL_WINDOWEVENT:
|
||||||
screen_handle_window_event(&screen, &event->window);
|
switch (event->window.event) {
|
||||||
|
case SDL_WINDOWEVENT_EXPOSED:
|
||||||
|
case SDL_WINDOWEVENT_SIZE_CHANGED:
|
||||||
|
screen_render(&screen);
|
||||||
|
break;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case SDL_TEXTINPUT:
|
case SDL_TEXTINPUT:
|
||||||
if (!control) {
|
if (!control) {
|
||||||
@@ -280,7 +285,6 @@ scrcpy(const struct scrcpy_options *options) {
|
|||||||
.local_port = options->port,
|
.local_port = options->port,
|
||||||
.max_size = options->max_size,
|
.max_size = options->max_size,
|
||||||
.bit_rate = options->bit_rate,
|
.bit_rate = options->bit_rate,
|
||||||
.max_fps = options->max_fps,
|
|
||||||
.control = options->control,
|
.control = options->control,
|
||||||
};
|
};
|
||||||
if (!server_start(&server, options->serial, ¶ms)) {
|
if (!server_start(&server, options->serial, ¶ms)) {
|
||||||
@@ -388,10 +392,7 @@ scrcpy(const struct scrcpy_options *options) {
|
|||||||
options->window_title ? options->window_title : device_name;
|
options->window_title ? options->window_title : device_name;
|
||||||
|
|
||||||
if (!screen_init_rendering(&screen, window_title, frame_size,
|
if (!screen_init_rendering(&screen, window_title, frame_size,
|
||||||
options->always_on_top, options->window_x,
|
options->always_on_top)) {
|
||||||
options->window_y, options->window_width,
|
|
||||||
options->window_height,
|
|
||||||
options->window_borderless)) {
|
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,11 +18,6 @@ struct scrcpy_options {
|
|||||||
uint16_t port;
|
uint16_t port;
|
||||||
uint16_t max_size;
|
uint16_t max_size;
|
||||||
uint32_t bit_rate;
|
uint32_t bit_rate;
|
||||||
uint16_t max_fps;
|
|
||||||
int16_t window_x;
|
|
||||||
int16_t window_y;
|
|
||||||
uint16_t window_width;
|
|
||||||
uint16_t window_height;
|
|
||||||
bool show_touches;
|
bool show_touches;
|
||||||
bool fullscreen;
|
bool fullscreen;
|
||||||
bool always_on_top;
|
bool always_on_top;
|
||||||
@@ -31,7 +26,6 @@ struct scrcpy_options {
|
|||||||
bool turn_screen_off;
|
bool turn_screen_off;
|
||||||
bool render_expired_frames;
|
bool render_expired_frames;
|
||||||
bool prefer_text;
|
bool prefer_text;
|
||||||
bool window_borderless;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#define SCRCPY_OPTIONS_DEFAULT { \
|
#define SCRCPY_OPTIONS_DEFAULT { \
|
||||||
@@ -44,11 +38,6 @@ struct scrcpy_options {
|
|||||||
.port = DEFAULT_LOCAL_PORT, \
|
.port = DEFAULT_LOCAL_PORT, \
|
||||||
.max_size = DEFAULT_LOCAL_PORT, \
|
.max_size = DEFAULT_LOCAL_PORT, \
|
||||||
.bit_rate = DEFAULT_BIT_RATE, \
|
.bit_rate = DEFAULT_BIT_RATE, \
|
||||||
.max_fps = 0, \
|
|
||||||
.window_x = -1, \
|
|
||||||
.window_y = -1, \
|
|
||||||
.window_width = 0, \
|
|
||||||
.window_height = 0, \
|
|
||||||
.show_touches = false, \
|
.show_touches = false, \
|
||||||
.fullscreen = false, \
|
.fullscreen = false, \
|
||||||
.always_on_top = false, \
|
.always_on_top = false, \
|
||||||
@@ -57,7 +46,6 @@ struct scrcpy_options {
|
|||||||
.turn_screen_off = false, \
|
.turn_screen_off = false, \
|
||||||
.render_expired_frames = false, \
|
.render_expired_frames = false, \
|
||||||
.prefer_text = false, \
|
.prefer_text = false, \
|
||||||
.window_borderless = false, \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|||||||
+32
-114
@@ -30,28 +30,23 @@ get_window_size(SDL_Window *window) {
|
|||||||
// get the windowed window size
|
// get the windowed window size
|
||||||
static struct size
|
static struct size
|
||||||
get_windowed_window_size(const struct screen *screen) {
|
get_windowed_window_size(const struct screen *screen) {
|
||||||
if (screen->fullscreen || screen->maximized) {
|
if (screen->fullscreen) {
|
||||||
return screen->windowed_window_size;
|
return screen->windowed_window_size;
|
||||||
}
|
}
|
||||||
return get_window_size(screen->window);
|
return get_window_size(screen->window);
|
||||||
}
|
}
|
||||||
|
|
||||||
// apply the windowed window size if fullscreen and maximized are disabled
|
|
||||||
static void
|
|
||||||
apply_windowed_size(struct screen *screen) {
|
|
||||||
if (!screen->fullscreen && !screen->maximized) {
|
|
||||||
SDL_SetWindowSize(screen->window, screen->windowed_window_size.width,
|
|
||||||
screen->windowed_window_size.height);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// set the window size to be applied when fullscreen is disabled
|
// set the window size to be applied when fullscreen is disabled
|
||||||
static void
|
static void
|
||||||
set_window_size(struct screen *screen, struct size new_size) {
|
set_window_size(struct screen *screen, struct size new_size) {
|
||||||
// setting the window size during fullscreen is implementation defined,
|
// setting the window size during fullscreen is implementation defined,
|
||||||
// so apply the resize only after fullscreen is disabled
|
// so apply the resize only after fullscreen is disabled
|
||||||
screen->windowed_window_size = new_size;
|
if (screen->fullscreen) {
|
||||||
apply_windowed_size(screen);
|
// SDL_SetWindowSize will be called when fullscreen will be disabled
|
||||||
|
screen->windowed_window_size = new_size;
|
||||||
|
} else {
|
||||||
|
SDL_SetWindowSize(screen->window, new_size.width, new_size.height);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the preferred display bounds (i.e. the screen bounds with some margins)
|
// get the preferred display bounds (i.e. the screen bounds with some margins)
|
||||||
@@ -122,30 +117,9 @@ get_optimal_window_size(const struct screen *screen, struct size frame_size) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// initially, there is no current size, so use the frame size as current size
|
// initially, there is no current size, so use the frame size as current size
|
||||||
// req_width and req_height, if not 0, are the sizes requested by the user
|
|
||||||
static inline struct size
|
static inline struct size
|
||||||
get_initial_optimal_size(struct size frame_size, uint16_t req_width,
|
get_initial_optimal_size(struct size frame_size) {
|
||||||
uint16_t req_height) {
|
return get_optimal_size(frame_size, frame_size);
|
||||||
struct size window_size;
|
|
||||||
if (!req_width && !req_height) {
|
|
||||||
window_size = get_optimal_size(frame_size, frame_size);
|
|
||||||
} else {
|
|
||||||
if (req_width) {
|
|
||||||
window_size.width = req_width;
|
|
||||||
} else {
|
|
||||||
// compute from the requested height
|
|
||||||
window_size.width = (uint32_t) req_height * frame_size.width
|
|
||||||
/ frame_size.height;
|
|
||||||
}
|
|
||||||
if (req_height) {
|
|
||||||
window_size.height = req_height;
|
|
||||||
} else {
|
|
||||||
// compute from the requested width
|
|
||||||
window_size.height = (uint32_t) req_width * frame_size.height
|
|
||||||
/ frame_size.width;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return window_size;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -162,13 +136,10 @@ create_texture(SDL_Renderer *renderer, struct size frame_size) {
|
|||||||
|
|
||||||
bool
|
bool
|
||||||
screen_init_rendering(struct screen *screen, const char *window_title,
|
screen_init_rendering(struct screen *screen, const char *window_title,
|
||||||
struct size frame_size, bool always_on_top,
|
struct size frame_size, bool always_on_top) {
|
||||||
int16_t window_x, int16_t window_y, uint16_t window_width,
|
|
||||||
uint16_t window_height, bool window_borderless) {
|
|
||||||
screen->frame_size = frame_size;
|
screen->frame_size = frame_size;
|
||||||
|
|
||||||
struct size window_size =
|
struct size window_size = get_initial_optimal_size(frame_size);
|
||||||
get_initial_optimal_size(frame_size, window_width, window_height);
|
|
||||||
uint32_t window_flags = SDL_WINDOW_HIDDEN | SDL_WINDOW_RESIZABLE;
|
uint32_t window_flags = SDL_WINDOW_HIDDEN | SDL_WINDOW_RESIZABLE;
|
||||||
#ifdef HIDPI_SUPPORT
|
#ifdef HIDPI_SUPPORT
|
||||||
window_flags |= SDL_WINDOW_ALLOW_HIGHDPI;
|
window_flags |= SDL_WINDOW_ALLOW_HIGHDPI;
|
||||||
@@ -181,13 +152,9 @@ screen_init_rendering(struct screen *screen, const char *window_title,
|
|||||||
"(compile with SDL >= 2.0.5 to enable it)");
|
"(compile with SDL >= 2.0.5 to enable it)");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if (window_borderless) {
|
|
||||||
window_flags |= SDL_WINDOW_BORDERLESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
int x = window_x != -1 ? window_x : SDL_WINDOWPOS_UNDEFINED;
|
screen->window = SDL_CreateWindow(window_title, SDL_WINDOWPOS_UNDEFINED,
|
||||||
int y = window_y != -1 ? window_y : SDL_WINDOWPOS_UNDEFINED;
|
SDL_WINDOWPOS_UNDEFINED,
|
||||||
screen->window = SDL_CreateWindow(window_title, x, y,
|
|
||||||
window_size.width, window_size.height,
|
window_size.width, window_size.height,
|
||||||
window_flags);
|
window_flags);
|
||||||
if (!screen->window) {
|
if (!screen->window) {
|
||||||
@@ -227,8 +194,6 @@ screen_init_rendering(struct screen *screen, const char *window_title,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
screen->windowed_window_size = window_size;
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -322,6 +287,10 @@ screen_render(struct screen *screen) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
screen_switch_fullscreen(struct screen *screen) {
|
screen_switch_fullscreen(struct screen *screen) {
|
||||||
|
if (!screen->fullscreen) {
|
||||||
|
// going to fullscreen, store the current windowed window size
|
||||||
|
screen->windowed_window_size = get_window_size(screen->window);
|
||||||
|
}
|
||||||
uint32_t new_mode = screen->fullscreen ? 0 : SDL_WINDOW_FULLSCREEN_DESKTOP;
|
uint32_t new_mode = screen->fullscreen ? 0 : SDL_WINDOW_FULLSCREEN_DESKTOP;
|
||||||
if (SDL_SetWindowFullscreen(screen->window, new_mode)) {
|
if (SDL_SetWindowFullscreen(screen->window, new_mode)) {
|
||||||
LOGW("Could not switch fullscreen mode: %s", SDL_GetError());
|
LOGW("Could not switch fullscreen mode: %s", SDL_GetError());
|
||||||
@@ -329,7 +298,11 @@ screen_switch_fullscreen(struct screen *screen) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
screen->fullscreen = !screen->fullscreen;
|
screen->fullscreen = !screen->fullscreen;
|
||||||
apply_windowed_size(screen);
|
if (!screen->fullscreen) {
|
||||||
|
// fullscreen disabled, restore expected windowed window size
|
||||||
|
SDL_SetWindowSize(screen->window, screen->windowed_window_size.width,
|
||||||
|
screen->windowed_window_size.height);
|
||||||
|
}
|
||||||
|
|
||||||
LOGD("Switched to %s mode", screen->fullscreen ? "fullscreen" : "windowed");
|
LOGD("Switched to %s mode", screen->fullscreen ? "fullscreen" : "windowed");
|
||||||
screen_render(screen);
|
screen_render(screen);
|
||||||
@@ -337,75 +310,20 @@ screen_switch_fullscreen(struct screen *screen) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
screen_resize_to_fit(struct screen *screen) {
|
screen_resize_to_fit(struct screen *screen) {
|
||||||
if (screen->fullscreen) {
|
if (!screen->fullscreen) {
|
||||||
return;
|
struct size optimal_size = get_optimal_window_size(screen,
|
||||||
|
screen->frame_size);
|
||||||
|
SDL_SetWindowSize(screen->window, optimal_size.width,
|
||||||
|
optimal_size.height);
|
||||||
|
LOGD("Resized to optimal size");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (screen->maximized) {
|
|
||||||
SDL_RestoreWindow(screen->window);
|
|
||||||
screen->maximized = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct size optimal_size =
|
|
||||||
get_optimal_window_size(screen, screen->frame_size);
|
|
||||||
SDL_SetWindowSize(screen->window, optimal_size.width, optimal_size.height);
|
|
||||||
LOGD("Resized to optimal size");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
screen_resize_to_pixel_perfect(struct screen *screen) {
|
screen_resize_to_pixel_perfect(struct screen *screen) {
|
||||||
if (screen->fullscreen) {
|
if (!screen->fullscreen) {
|
||||||
return;
|
SDL_SetWindowSize(screen->window, screen->frame_size.width,
|
||||||
}
|
screen->frame_size.height);
|
||||||
|
LOGD("Resized to pixel-perfect");
|
||||||
if (screen->maximized) {
|
|
||||||
SDL_RestoreWindow(screen->window);
|
|
||||||
screen->maximized = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
SDL_SetWindowSize(screen->window, screen->frame_size.width,
|
|
||||||
screen->frame_size.height);
|
|
||||||
LOGD("Resized to pixel-perfect");
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
screen_handle_window_event(struct screen *screen,
|
|
||||||
const SDL_WindowEvent *event) {
|
|
||||||
switch (event->event) {
|
|
||||||
case SDL_WINDOWEVENT_EXPOSED:
|
|
||||||
screen_render(screen);
|
|
||||||
break;
|
|
||||||
case SDL_WINDOWEVENT_SIZE_CHANGED:
|
|
||||||
if (!screen->fullscreen && !screen->maximized) {
|
|
||||||
// Backup the previous size: if we receive the MAXIMIZED event,
|
|
||||||
// then the new size must be ignored (it's the maximized size).
|
|
||||||
// We could not rely on the window flags due to race conditions
|
|
||||||
// (they could be updated asynchronously, at least on X11).
|
|
||||||
screen->windowed_window_size_backup =
|
|
||||||
screen->windowed_window_size;
|
|
||||||
|
|
||||||
// Save the windowed size, so that it is available once the
|
|
||||||
// window is maximized or fullscreen is enabled.
|
|
||||||
screen->windowed_window_size = get_window_size(screen->window);
|
|
||||||
}
|
|
||||||
screen_render(screen);
|
|
||||||
break;
|
|
||||||
case SDL_WINDOWEVENT_MAXIMIZED:
|
|
||||||
// The backup size must be non-nul.
|
|
||||||
SDL_assert(screen->windowed_window_size_backup.width);
|
|
||||||
SDL_assert(screen->windowed_window_size_backup.height);
|
|
||||||
// Revert the last size, it was updated while screen was maximized.
|
|
||||||
screen->windowed_window_size = screen->windowed_window_size_backup;
|
|
||||||
#ifdef DEBUG
|
|
||||||
// Reset the backup to invalid values to detect unexpected usage
|
|
||||||
screen->windowed_window_size_backup.width = 0;
|
|
||||||
screen->windowed_window_size_backup.height = 0;
|
|
||||||
#endif
|
|
||||||
screen->maximized = true;
|
|
||||||
break;
|
|
||||||
case SDL_WINDOWEVENT_RESTORED:
|
|
||||||
screen->maximized = false;
|
|
||||||
apply_windowed_size(screen);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+16
-31
@@ -15,37 +15,28 @@ struct screen {
|
|||||||
SDL_Renderer *renderer;
|
SDL_Renderer *renderer;
|
||||||
SDL_Texture *texture;
|
SDL_Texture *texture;
|
||||||
struct size frame_size;
|
struct size frame_size;
|
||||||
// The window size the last time it was not maximized or fullscreen.
|
//used only in fullscreen mode to know the windowed window size
|
||||||
struct size windowed_window_size;
|
struct size windowed_window_size;
|
||||||
// Since we receive the event SIZE_CHANGED before MAXIMIZED, we must be
|
|
||||||
// able to revert the size to its non-maximized value.
|
|
||||||
struct size windowed_window_size_backup;
|
|
||||||
bool has_frame;
|
bool has_frame;
|
||||||
bool fullscreen;
|
bool fullscreen;
|
||||||
bool maximized;
|
|
||||||
bool no_window;
|
bool no_window;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define SCREEN_INITIALIZER { \
|
#define SCREEN_INITIALIZER { \
|
||||||
.window = NULL, \
|
.window = NULL, \
|
||||||
.renderer = NULL, \
|
.renderer = NULL, \
|
||||||
.texture = NULL, \
|
.texture = NULL, \
|
||||||
.frame_size = { \
|
.frame_size = { \
|
||||||
.width = 0, \
|
.width = 0, \
|
||||||
.height = 0, \
|
.height = 0, \
|
||||||
}, \
|
}, \
|
||||||
.windowed_window_size = { \
|
.windowed_window_size = { \
|
||||||
.width = 0, \
|
.width = 0, \
|
||||||
.height = 0, \
|
.height = 0, \
|
||||||
}, \
|
}, \
|
||||||
.windowed_window_size_backup = { \
|
.has_frame = false, \
|
||||||
.width = 0, \
|
.fullscreen = false, \
|
||||||
.height = 0, \
|
.no_window = false, \
|
||||||
}, \
|
|
||||||
.has_frame = false, \
|
|
||||||
.fullscreen = false, \
|
|
||||||
.maximized = false, \
|
|
||||||
.no_window = false, \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// initialize default values
|
// initialize default values
|
||||||
@@ -55,9 +46,7 @@ screen_init(struct screen *screen);
|
|||||||
// initialize screen, create window, renderer and texture (window is hidden)
|
// initialize screen, create window, renderer and texture (window is hidden)
|
||||||
bool
|
bool
|
||||||
screen_init_rendering(struct screen *screen, const char *window_title,
|
screen_init_rendering(struct screen *screen, const char *window_title,
|
||||||
struct size frame_size, bool always_on_top,
|
struct size frame_size, bool always_on_top);
|
||||||
int16_t window_x, int16_t window_y, uint16_t window_width,
|
|
||||||
uint16_t window_height, bool window_borderless);
|
|
||||||
|
|
||||||
// show the window
|
// show the window
|
||||||
void
|
void
|
||||||
@@ -87,8 +76,4 @@ screen_resize_to_fit(struct screen *screen);
|
|||||||
void
|
void
|
||||||
screen_resize_to_pixel_perfect(struct screen *screen);
|
screen_resize_to_pixel_perfect(struct screen *screen);
|
||||||
|
|
||||||
// react to window events
|
|
||||||
void
|
|
||||||
screen_handle_window_event(struct screen *screen, const SDL_WindowEvent *event);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+1
-4
@@ -118,10 +118,8 @@ static process_t
|
|||||||
execute_server(struct server *server, const struct server_params *params) {
|
execute_server(struct server *server, const struct server_params *params) {
|
||||||
char max_size_string[6];
|
char max_size_string[6];
|
||||||
char bit_rate_string[11];
|
char bit_rate_string[11];
|
||||||
char max_fps_string[6];
|
|
||||||
sprintf(max_size_string, "%"PRIu16, params->max_size);
|
sprintf(max_size_string, "%"PRIu16, params->max_size);
|
||||||
sprintf(bit_rate_string, "%"PRIu32, params->bit_rate);
|
sprintf(bit_rate_string, "%"PRIu32, params->bit_rate);
|
||||||
sprintf(max_fps_string, "%"PRIu16, params->max_fps);
|
|
||||||
const char *const cmd[] = {
|
const char *const cmd[] = {
|
||||||
"shell",
|
"shell",
|
||||||
"CLASSPATH=/data/local/tmp/" SERVER_FILENAME,
|
"CLASSPATH=/data/local/tmp/" SERVER_FILENAME,
|
||||||
@@ -136,7 +134,6 @@ execute_server(struct server *server, const struct server_params *params) {
|
|||||||
SCRCPY_VERSION,
|
SCRCPY_VERSION,
|
||||||
max_size_string,
|
max_size_string,
|
||||||
bit_rate_string,
|
bit_rate_string,
|
||||||
max_fps_string,
|
|
||||||
server->tunnel_forward ? "true" : "false",
|
server->tunnel_forward ? "true" : "false",
|
||||||
params->crop ? params->crop : "-",
|
params->crop ? params->crop : "-",
|
||||||
"true", // always send frame meta (packet boundaries + timestamp)
|
"true", // always send frame meta (packet boundaries + timestamp)
|
||||||
@@ -281,7 +278,7 @@ server_connect_to(struct server *server) {
|
|||||||
|
|
||||||
server->control_socket = net_accept(server->server_socket);
|
server->control_socket = net_accept(server->server_socket);
|
||||||
if (server->control_socket == INVALID_SOCKET) {
|
if (server->control_socket == INVALID_SOCKET) {
|
||||||
// the video_socket will be cleaned up on destroy
|
// the video_socket will be clean up on destroy
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ struct server_params {
|
|||||||
uint16_t local_port;
|
uint16_t local_port;
|
||||||
uint16_t max_size;
|
uint16_t max_size;
|
||||||
uint32_t bit_rate;
|
uint32_t bit_rate;
|
||||||
uint16_t max_fps;
|
|
||||||
bool control;
|
bool control;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ page at http://checkstyle.sourceforge.net/config.html -->
|
|||||||
<module name="SuppressWarningsHolder"/>
|
<module name="SuppressWarningsHolder"/>
|
||||||
|
|
||||||
<!-- Checks for imports -->
|
<!-- Checks for imports -->
|
||||||
<!-- See http://checkstyle.sf.net/config_imports.html -->
|
<!-- See http://checkstyle.sf.net/config_import.html -->
|
||||||
<module name="AvoidStarImport">
|
<module name="AvoidStarImport">
|
||||||
<property name="allowStaticMemberImports" value="true" />
|
<property name="allowStaticMemberImports" value="true" />
|
||||||
</module>
|
</module>
|
||||||
@@ -99,7 +99,7 @@ page at http://checkstyle.sourceforge.net/config.html -->
|
|||||||
<module name="WhitespaceAround" />
|
<module name="WhitespaceAround" />
|
||||||
|
|
||||||
<!-- Modifier Checks -->
|
<!-- Modifier Checks -->
|
||||||
<!-- See http://checkstyle.sf.net/config_modifier.html -->
|
<!-- See http://checkstyle.sf.net/config_modifiers.html -->
|
||||||
<module name="ModifierOrder" />
|
<module name="ModifierOrder" />
|
||||||
<module name="RedundantModifier" />
|
<module name="RedundantModifier" />
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -15,6 +15,6 @@ cpu = 'i686'
|
|||||||
endian = 'little'
|
endian = 'little'
|
||||||
|
|
||||||
[properties]
|
[properties]
|
||||||
prebuilt_ffmpeg_shared = 'ffmpeg-4.2.1-win32-shared'
|
prebuilt_ffmpeg_shared = 'ffmpeg-4.1.4-win32-shared'
|
||||||
prebuilt_ffmpeg_dev = 'ffmpeg-4.2.1-win32-dev'
|
prebuilt_ffmpeg_dev = 'ffmpeg-4.1.4-win32-dev'
|
||||||
prebuilt_sdl2 = 'SDL2-2.0.10/i686-w64-mingw32'
|
prebuilt_sdl2 = 'SDL2-2.0.10/i686-w64-mingw32'
|
||||||
|
|||||||
+2
-2
@@ -15,6 +15,6 @@ cpu = 'x86_64'
|
|||||||
endian = 'little'
|
endian = 'little'
|
||||||
|
|
||||||
[properties]
|
[properties]
|
||||||
prebuilt_ffmpeg_shared = 'ffmpeg-4.2.1-win64-shared'
|
prebuilt_ffmpeg_shared = 'ffmpeg-4.1.4-win64-shared'
|
||||||
prebuilt_ffmpeg_dev = 'ffmpeg-4.2.1-win64-dev'
|
prebuilt_ffmpeg_dev = 'ffmpeg-4.1.4-win64-dev'
|
||||||
prebuilt_sdl2 = 'SDL2-2.0.10/x86_64-w64-mingw32'
|
prebuilt_sdl2 = 'SDL2-2.0.10/x86_64-w64-mingw32'
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
project('scrcpy', 'c',
|
project('scrcpy', 'c',
|
||||||
version: '1.11',
|
version: '1.10',
|
||||||
meson_version: '>= 0.37',
|
meson_version: '>= 0.37',
|
||||||
default_options: 'c_std=c11')
|
default_options: 'c_std=c11')
|
||||||
|
|
||||||
|
|||||||
+14
-14
@@ -10,24 +10,24 @@ prepare-win32: prepare-sdl2 prepare-ffmpeg-shared-win32 prepare-ffmpeg-dev-win32
|
|||||||
prepare-win64: prepare-sdl2 prepare-ffmpeg-shared-win64 prepare-ffmpeg-dev-win64 prepare-adb
|
prepare-win64: prepare-sdl2 prepare-ffmpeg-shared-win64 prepare-ffmpeg-dev-win64 prepare-adb
|
||||||
|
|
||||||
prepare-ffmpeg-shared-win32:
|
prepare-ffmpeg-shared-win32:
|
||||||
@./prepare-dep https://ffmpeg.zeranoe.com/builds/win32/shared/ffmpeg-4.2.1-win32-shared.zip \
|
@./prepare-dep https://ffmpeg.zeranoe.com/builds/win32/shared/ffmpeg-4.1.4-win32-shared.zip \
|
||||||
9208255f409410d95147151d7e829b5699bf8d91bfe1e81c3f470f47c2fa66d2 \
|
596608277f6b937c3dea7c46e854665d75b3de56790bae07f655ca331440f003 \
|
||||||
ffmpeg-4.2.1-win32-shared
|
ffmpeg-4.1.4-win32-shared
|
||||||
|
|
||||||
prepare-ffmpeg-dev-win32:
|
prepare-ffmpeg-dev-win32:
|
||||||
@./prepare-dep https://ffmpeg.zeranoe.com/builds/win32/dev/ffmpeg-4.2.1-win32-dev.zip \
|
@./prepare-dep https://ffmpeg.zeranoe.com/builds/win32/dev/ffmpeg-4.1.4-win32-dev.zip \
|
||||||
c3469e6c5f031cbcc8cba88dee92d6548c5c6b6ff14f4097f18f72a92d0d70c4 \
|
a80c86e263cfad26e202edfa5e6e939a2c88843ae26f031d3e0d981a39fd03fb \
|
||||||
ffmpeg-4.2.1-win32-dev
|
ffmpeg-4.1.4-win32-dev
|
||||||
|
|
||||||
prepare-ffmpeg-shared-win64:
|
prepare-ffmpeg-shared-win64:
|
||||||
@./prepare-dep https://ffmpeg.zeranoe.com/builds/win64/shared/ffmpeg-4.2.1-win64-shared.zip \
|
@./prepare-dep https://ffmpeg.zeranoe.com/builds/win64/shared/ffmpeg-4.1.4-win64-shared.zip \
|
||||||
55063d3cf750a75485c7bf196031773d81a1b25d0980c7db48ecfc7701a42331 \
|
a90889871de2cab8a79b392591313a188189a353f69dde1db98aebe20b280989 \
|
||||||
ffmpeg-4.2.1-win64-shared
|
ffmpeg-4.1.4-win64-shared
|
||||||
|
|
||||||
prepare-ffmpeg-dev-win64:
|
prepare-ffmpeg-dev-win64:
|
||||||
@./prepare-dep https://ffmpeg.zeranoe.com/builds/win64/dev/ffmpeg-4.2.1-win64-dev.zip \
|
@./prepare-dep https://ffmpeg.zeranoe.com/builds/win64/dev/ffmpeg-4.1.4-win64-dev.zip \
|
||||||
5af393be5f25c0a71aa29efce768e477c35347f7f8e0d9696767d5b9d405b74e \
|
6c9d53f9e94ce1821e975ec668e5b9d6e9deb4a45d0d7e30264685d3dfbbb068 \
|
||||||
ffmpeg-4.2.1-win64-dev
|
ffmpeg-4.1.4-win64-dev
|
||||||
|
|
||||||
prepare-sdl2:
|
prepare-sdl2:
|
||||||
@./prepare-dep https://libsdl.org/release/SDL2-devel-2.0.10-mingw.tar.gz \
|
@./prepare-dep https://libsdl.org/release/SDL2-devel-2.0.10-mingw.tar.gz \
|
||||||
@@ -35,6 +35,6 @@ prepare-sdl2:
|
|||||||
SDL2-2.0.10
|
SDL2-2.0.10
|
||||||
|
|
||||||
prepare-adb:
|
prepare-adb:
|
||||||
@./prepare-dep https://dl.google.com/android/repository/platform-tools_r29.0.5-windows.zip \
|
@./prepare-dep https://dl.google.com/android/repository/platform-tools_r29.0.2-windows.zip \
|
||||||
2df06160056ec9a84c7334af2a1e42740befbb1a2e34370e7af544a2cc78152c \
|
d78f02e5e2c9c4c1d046dcd4e6fbdf586e5f57ef66eb0da5c2b49d745d85d5ee \
|
||||||
platform-tools
|
platform-tools
|
||||||
|
|||||||
+2
-2
@@ -6,8 +6,8 @@ android {
|
|||||||
applicationId "com.genymobile.scrcpy"
|
applicationId "com.genymobile.scrcpy"
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 29
|
targetSdkVersion 29
|
||||||
versionCode 12
|
versionCode 11
|
||||||
versionName "1.11"
|
versionName "1.10"
|
||||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
|
|||||||
@@ -11,9 +11,6 @@
|
|||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
SCRCPY_DEBUG=false
|
|
||||||
SCRCPY_VERSION_NAME=1.11
|
|
||||||
|
|
||||||
PLATFORM=${ANDROID_PLATFORM:-29}
|
PLATFORM=${ANDROID_PLATFORM:-29}
|
||||||
BUILD_TOOLS=${ANDROID_BUILD_TOOLS:-29.0.2}
|
BUILD_TOOLS=${ANDROID_BUILD_TOOLS:-29.0.2}
|
||||||
|
|
||||||
@@ -33,8 +30,7 @@ mkdir -p "$CLASSES_DIR/com/genymobile/scrcpy"
|
|||||||
package com.genymobile.scrcpy;
|
package com.genymobile.scrcpy;
|
||||||
|
|
||||||
public final class BuildConfig {
|
public final class BuildConfig {
|
||||||
public static final boolean DEBUG = $SCRCPY_DEBUG;
|
public static final boolean DEBUG = false;
|
||||||
public static final String VERSION_NAME = "$SCRCPY_VERSION_NAME";
|
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import android.graphics.Rect;
|
|||||||
public class Options {
|
public class Options {
|
||||||
private int maxSize;
|
private int maxSize;
|
||||||
private int bitRate;
|
private int bitRate;
|
||||||
private int maxFps;
|
|
||||||
private boolean tunnelForward;
|
private boolean tunnelForward;
|
||||||
private Rect crop;
|
private Rect crop;
|
||||||
private boolean sendFrameMeta; // send PTS so that the client may record properly
|
private boolean sendFrameMeta; // send PTS so that the client may record properly
|
||||||
@@ -27,14 +26,6 @@ public class Options {
|
|||||||
this.bitRate = bitRate;
|
this.bitRate = bitRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMaxFps() {
|
|
||||||
return maxFps;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMaxFps(int maxFps) {
|
|
||||||
this.maxFps = maxFps;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isTunnelForward() {
|
public boolean isTunnelForward() {
|
||||||
return tunnelForward;
|
return tunnelForward;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ import android.graphics.Rect;
|
|||||||
import android.media.MediaCodec;
|
import android.media.MediaCodec;
|
||||||
import android.media.MediaCodecInfo;
|
import android.media.MediaCodecInfo;
|
||||||
import android.media.MediaFormat;
|
import android.media.MediaFormat;
|
||||||
import android.os.Build;
|
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
|
import android.os.Looper;
|
||||||
import android.view.Surface;
|
import android.view.Surface;
|
||||||
|
|
||||||
import java.io.FileDescriptor;
|
import java.io.FileDescriptor;
|
||||||
@@ -17,29 +17,32 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||||||
|
|
||||||
public class ScreenEncoder implements Device.RotationListener {
|
public class ScreenEncoder implements Device.RotationListener {
|
||||||
|
|
||||||
|
private static final int DEFAULT_FRAME_RATE = 60; // fps
|
||||||
private static final int DEFAULT_I_FRAME_INTERVAL = 10; // seconds
|
private static final int DEFAULT_I_FRAME_INTERVAL = 10; // seconds
|
||||||
private static final int REPEAT_FRAME_DELAY_US = 100_000; // repeat after 100ms
|
|
||||||
|
|
||||||
|
private static final int REPEAT_FRAME_DELAY = 6; // repeat after 6 frames
|
||||||
|
|
||||||
|
private static final int MICROSECONDS_IN_ONE_SECOND = 1_000_000;
|
||||||
private static final int NO_PTS = -1;
|
private static final int NO_PTS = -1;
|
||||||
|
|
||||||
private final AtomicBoolean rotationChanged = new AtomicBoolean();
|
private final AtomicBoolean rotationChanged = new AtomicBoolean();
|
||||||
private final ByteBuffer headerBuffer = ByteBuffer.allocate(12);
|
private final ByteBuffer headerBuffer = ByteBuffer.allocate(12);
|
||||||
|
|
||||||
private int bitRate;
|
private int bitRate;
|
||||||
private int maxFps;
|
private int frameRate;
|
||||||
private int iFrameInterval;
|
private int iFrameInterval;
|
||||||
private boolean sendFrameMeta;
|
private boolean sendFrameMeta;
|
||||||
private long ptsOrigin;
|
private long ptsOrigin;
|
||||||
|
|
||||||
public ScreenEncoder(boolean sendFrameMeta, int bitRate, int maxFps, int iFrameInterval) {
|
public ScreenEncoder(boolean sendFrameMeta, int bitRate, int frameRate, int iFrameInterval) {
|
||||||
this.sendFrameMeta = sendFrameMeta;
|
this.sendFrameMeta = sendFrameMeta;
|
||||||
this.bitRate = bitRate;
|
this.bitRate = bitRate;
|
||||||
this.maxFps = maxFps;
|
this.frameRate = frameRate;
|
||||||
this.iFrameInterval = iFrameInterval;
|
this.iFrameInterval = iFrameInterval;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ScreenEncoder(boolean sendFrameMeta, int bitRate, int maxFps) {
|
public ScreenEncoder(boolean sendFrameMeta, int bitRate) {
|
||||||
this(sendFrameMeta, bitRate, maxFps, DEFAULT_I_FRAME_INTERVAL);
|
this(sendFrameMeta, bitRate, DEFAULT_FRAME_RATE, DEFAULT_I_FRAME_INTERVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -52,10 +55,17 @@ public class ScreenEncoder implements Device.RotationListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void streamScreen(Device device, FileDescriptor fd) throws IOException {
|
public void streamScreen(Device device, FileDescriptor fd) throws IOException {
|
||||||
Workarounds.prepareMainLooper();
|
// Some devices internally create a Handler when creating an input Surface, causing an exception:
|
||||||
Workarounds.fillAppInfo();
|
// "Can't create handler inside thread that has not called Looper.prepare()"
|
||||||
|
// <https://github.com/Genymobile/scrcpy/issues/240>
|
||||||
|
//
|
||||||
|
// Use Looper.prepareMainLooper() instead of Looper.prepare() to avoid a NullPointerException:
|
||||||
|
// "Attempt to read from field 'android.os.MessageQueue android.os.Looper.mQueue'
|
||||||
|
// on a null object reference"
|
||||||
|
// <https://github.com/Genymobile/scrcpy/issues/921>
|
||||||
|
Looper.prepareMainLooper();
|
||||||
|
|
||||||
MediaFormat format = createFormat(bitRate, maxFps, iFrameInterval);
|
MediaFormat format = createFormat(bitRate, frameRate, iFrameInterval);
|
||||||
device.setRotationListener(this);
|
device.setRotationListener(this);
|
||||||
boolean alive;
|
boolean alive;
|
||||||
try {
|
try {
|
||||||
@@ -138,24 +148,15 @@ public class ScreenEncoder implements Device.RotationListener {
|
|||||||
return MediaCodec.createEncoderByType("video/avc");
|
return MediaCodec.createEncoderByType("video/avc");
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("checkstyle:MagicNumber")
|
private static MediaFormat createFormat(int bitRate, int frameRate, int iFrameInterval) throws IOException {
|
||||||
private static MediaFormat createFormat(int bitRate, int maxFps, int iFrameInterval) {
|
|
||||||
MediaFormat format = new MediaFormat();
|
MediaFormat format = new MediaFormat();
|
||||||
format.setString(MediaFormat.KEY_MIME, "video/avc");
|
format.setString(MediaFormat.KEY_MIME, "video/avc");
|
||||||
format.setInteger(MediaFormat.KEY_BIT_RATE, bitRate);
|
format.setInteger(MediaFormat.KEY_BIT_RATE, bitRate);
|
||||||
// must be present to configure the encoder, but does not impact the actual frame rate, which is variable
|
format.setInteger(MediaFormat.KEY_FRAME_RATE, frameRate);
|
||||||
format.setInteger(MediaFormat.KEY_FRAME_RATE, 60);
|
|
||||||
format.setInteger(MediaFormat.KEY_COLOR_FORMAT, MediaCodecInfo.CodecCapabilities.COLOR_FormatSurface);
|
format.setInteger(MediaFormat.KEY_COLOR_FORMAT, MediaCodecInfo.CodecCapabilities.COLOR_FormatSurface);
|
||||||
format.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, iFrameInterval);
|
format.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, iFrameInterval);
|
||||||
// display the very first frame, and recover from bad quality when no new frames
|
// display the very first frame, and recover from bad quality when no new frames
|
||||||
format.setLong(MediaFormat.KEY_REPEAT_PREVIOUS_FRAME_AFTER, REPEAT_FRAME_DELAY_US); // µs
|
format.setLong(MediaFormat.KEY_REPEAT_PREVIOUS_FRAME_AFTER, MICROSECONDS_IN_ONE_SECOND * REPEAT_FRAME_DELAY / frameRate); // µs
|
||||||
if (maxFps > 0) {
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
|
||||||
format.setFloat(MediaFormat.KEY_MAX_FPS_TO_ENCODER, maxFps);
|
|
||||||
} else {
|
|
||||||
Ln.w("Max FPS is only supported since Android 10, the option has been ignored");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return format;
|
return format;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ public final class Server {
|
|||||||
final Device device = new Device(options);
|
final Device device = new Device(options);
|
||||||
boolean tunnelForward = options.isTunnelForward();
|
boolean tunnelForward = options.isTunnelForward();
|
||||||
try (DesktopConnection connection = DesktopConnection.open(device, tunnelForward)) {
|
try (DesktopConnection connection = DesktopConnection.open(device, tunnelForward)) {
|
||||||
ScreenEncoder screenEncoder = new ScreenEncoder(options.getSendFrameMeta(), options.getBitRate(), options.getMaxFps());
|
ScreenEncoder screenEncoder = new ScreenEncoder(options.getSendFrameMeta(), options.getBitRate());
|
||||||
|
|
||||||
if (options.getControl()) {
|
if (options.getControl()) {
|
||||||
Controller controller = new Controller(device, connection);
|
Controller controller = new Controller(device, connection);
|
||||||
@@ -77,8 +77,8 @@ public final class Server {
|
|||||||
+ "(" + BuildConfig.VERSION_NAME + ")");
|
+ "(" + BuildConfig.VERSION_NAME + ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.length != 8) {
|
if (args.length != 7) {
|
||||||
throw new IllegalArgumentException("Expecting 8 parameters");
|
throw new IllegalArgumentException("Expecting 7 parameters");
|
||||||
}
|
}
|
||||||
|
|
||||||
Options options = new Options();
|
Options options = new Options();
|
||||||
@@ -89,20 +89,17 @@ public final class Server {
|
|||||||
int bitRate = Integer.parseInt(args[2]);
|
int bitRate = Integer.parseInt(args[2]);
|
||||||
options.setBitRate(bitRate);
|
options.setBitRate(bitRate);
|
||||||
|
|
||||||
int maxFps = Integer.parseInt(args[3]);
|
|
||||||
options.setMaxFps(maxFps);
|
|
||||||
|
|
||||||
// use "adb forward" instead of "adb tunnel"? (so the server must listen)
|
// use "adb forward" instead of "adb tunnel"? (so the server must listen)
|
||||||
boolean tunnelForward = Boolean.parseBoolean(args[4]);
|
boolean tunnelForward = Boolean.parseBoolean(args[3]);
|
||||||
options.setTunnelForward(tunnelForward);
|
options.setTunnelForward(tunnelForward);
|
||||||
|
|
||||||
Rect crop = parseCrop(args[5]);
|
Rect crop = parseCrop(args[4]);
|
||||||
options.setCrop(crop);
|
options.setCrop(crop);
|
||||||
|
|
||||||
boolean sendFrameMeta = Boolean.parseBoolean(args[6]);
|
boolean sendFrameMeta = Boolean.parseBoolean(args[5]);
|
||||||
options.setSendFrameMeta(sendFrameMeta);
|
options.setSendFrameMeta(sendFrameMeta);
|
||||||
|
|
||||||
boolean control = Boolean.parseBoolean(args[7]);
|
boolean control = Boolean.parseBoolean(args[6]);
|
||||||
options.setControl(control);
|
options.setControl(control);
|
||||||
|
|
||||||
return options;
|
return options;
|
||||||
|
|||||||
@@ -1,64 +0,0 @@
|
|||||||
package com.genymobile.scrcpy;
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.content.pm.ApplicationInfo;
|
|
||||||
import android.os.Looper;
|
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
|
|
||||||
public final class Workarounds {
|
|
||||||
private Workarounds() {
|
|
||||||
// not instantiable
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void prepareMainLooper() {
|
|
||||||
// Some devices internally create a Handler when creating an input Surface, causing an exception:
|
|
||||||
// "Can't create handler inside thread that has not called Looper.prepare()"
|
|
||||||
// <https://github.com/Genymobile/scrcpy/issues/240>
|
|
||||||
//
|
|
||||||
// Use Looper.prepareMainLooper() instead of Looper.prepare() to avoid a NullPointerException:
|
|
||||||
// "Attempt to read from field 'android.os.MessageQueue android.os.Looper.mQueue'
|
|
||||||
// on a null object reference"
|
|
||||||
// <https://github.com/Genymobile/scrcpy/issues/921>
|
|
||||||
Looper.prepareMainLooper();
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressLint("PrivateApi")
|
|
||||||
public static void fillAppInfo() {
|
|
||||||
try {
|
|
||||||
// ActivityThread activityThread = new ActivityThread();
|
|
||||||
Class<?> activityThreadClass = Class.forName("android.app.ActivityThread");
|
|
||||||
Constructor<?> activityThreadConstructor = activityThreadClass.getDeclaredConstructor();
|
|
||||||
activityThreadConstructor.setAccessible(true);
|
|
||||||
Object activityThread = activityThreadConstructor.newInstance();
|
|
||||||
|
|
||||||
// ActivityThread.sCurrentActivityThread = activityThread;
|
|
||||||
Field sCurrentActivityThreadField = activityThreadClass.getDeclaredField("sCurrentActivityThread");
|
|
||||||
sCurrentActivityThreadField.setAccessible(true);
|
|
||||||
sCurrentActivityThreadField.set(null, activityThread);
|
|
||||||
|
|
||||||
// ActivityThread.AppBindData appBindData = new ActivityThread.AppBindData();
|
|
||||||
Class<?> appBindDataClass = Class.forName("android.app.ActivityThread$AppBindData");
|
|
||||||
Constructor<?> appBindDataConstructor = appBindDataClass.getDeclaredConstructor();
|
|
||||||
appBindDataConstructor.setAccessible(true);
|
|
||||||
Object appBindData = appBindDataConstructor.newInstance();
|
|
||||||
|
|
||||||
ApplicationInfo applicationInfo = new ApplicationInfo();
|
|
||||||
applicationInfo.packageName = "com.genymobile.scrcpy";
|
|
||||||
|
|
||||||
// appBindData.appInfo = applicationInfo;
|
|
||||||
Field appInfo = appBindDataClass.getDeclaredField("appInfo");
|
|
||||||
appInfo.setAccessible(true);
|
|
||||||
appInfo.set(appBindData, applicationInfo);
|
|
||||||
|
|
||||||
// activityThread.mBoundApplication = appBindData;
|
|
||||||
Field mBoundApplicationField = activityThreadClass.getDeclaredField("mBoundApplication");
|
|
||||||
mBoundApplicationField.setAccessible(true);
|
|
||||||
mBoundApplicationField.set(activityThread, appBindData);
|
|
||||||
} catch (Throwable throwable) {
|
|
||||||
// this is a workaround, so failing is not an error
|
|
||||||
Ln.w("Could not fill app info: " + throwable.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user