Merge branch 'support-rm2fb' of https://github.com/danshick/reStream into danshick-support-rm2fb
This commit is contained in:
commit
322dbfa4e4
15
README.md
15
README.md
@ -16,11 +16,20 @@ reMarkable screen sharing over SSH.
|
||||
2. [Set up an SSH key and add it to the ssh-agent](https://help.github.com/en/github/authenticating-to-github/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent), then add your key to the reMarkable with `ssh-copy-id root@10.11.99.1`. **Note:** the reMarkable 2 doesn't support `ed25519` keys, those users should generate and `rsa` key. Try out `ssh root@10.11.99.1`, it should **not** prompt for a password.
|
||||
3. Clone this repository: `git clone https://github.com/rien/reStream`.
|
||||
4. Copy the `restream` executable to the reMarkable and make it executable.
|
||||
|
||||
```
|
||||
# scp restream.arm.static root@10.11.99.1:/home/root/restream
|
||||
# ssh root@10.11.99.1 'chmod +x /home/root/restream'
|
||||
```
|
||||
|
||||
--or--
|
||||
|
||||
Install via [toltec](https://github.com/toltec-dev/toltec) if you use it (currently in the [testing branch](https://github.com/toltec-dev/toltec/blob/testing/docs/branches.md)).
|
||||
|
||||
```
|
||||
# ssh root@10.11.99.1 'opkg install restream'
|
||||
```
|
||||
|
||||
### Windows
|
||||
|
||||
1. Install [git for windows](https://gitforwindows.org/), which includes `Git BASH`.
|
||||
@ -60,6 +69,7 @@ If you have problems, don't hesitate to [open an issue](https://github.com/rien/
|
||||
## Requirements
|
||||
|
||||
On your **host** machine:
|
||||
|
||||
- Any POSIX-shell (e.g. bash)
|
||||
- ffmpeg (with ffplay)
|
||||
- ssh
|
||||
@ -77,13 +87,13 @@ apt install v4l2loopback-utils v4l2loopback-dkms
|
||||
|
||||
In some package managers `v4l2loopback-utils` is found in `v4l-utils`.
|
||||
|
||||
After installing the module you must enable it with
|
||||
After installing the module you must enable it with
|
||||
|
||||
```
|
||||
modprobe v4l2loopback
|
||||
```
|
||||
|
||||
To verify that this worked, execute:
|
||||
To verify that this worked, execute:
|
||||
|
||||
```
|
||||
v4l2-ctl --list-devices
|
||||
@ -94,6 +104,7 @@ The result should contain a line with "platform:v4l2loopback".
|
||||
## Troubleshooting
|
||||
|
||||
Steps you can try if the script isn't working:
|
||||
|
||||
- [Set up an SSH key](#installation)
|
||||
- Update `ffmpeg` to version 4.
|
||||
|
||||
|
22
reStream.sh
22
reStream.sh
@ -104,10 +104,16 @@ case "$rm_version" in
|
||||
pixel_format="rgb565le"
|
||||
;;
|
||||
"reMarkable 2.0")
|
||||
pixel_format="gray8"
|
||||
width=1872
|
||||
height=1404
|
||||
video_filters="$video_filters,transpose=2"
|
||||
if ssh_cmd "[ -f /dev/shm/swtfb.01 ]"; then
|
||||
width=1404
|
||||
height=1872
|
||||
pixel_format="rgb565le"
|
||||
else
|
||||
width=1872
|
||||
height=1404
|
||||
pixel_format="gray8"
|
||||
video_filters="$video_filters,transpose=2"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported reMarkable version: $rm_version."
|
||||
@ -129,7 +135,7 @@ if ! lz4 -V >/dev/null; then
|
||||
fi
|
||||
|
||||
# check if restream binay is present on remarkable
|
||||
if ssh_cmd "[ ! -f ~/restream ]"; then
|
||||
if ssh_cmd "[ ! -f ~/restream ] && [ ! -f /opt/bin/restream ]"; then
|
||||
echo "The restream binary is not installed on your reMarkable."
|
||||
echo "Please install it using the instruction in the README:"
|
||||
echo "https://github.com/rien/reStream/#installation"
|
||||
@ -185,13 +191,15 @@ fi
|
||||
|
||||
set -e # stop if an error occurs
|
||||
|
||||
restream_rs='PATH="$PATH:/opt/bin/:." restream'
|
||||
|
||||
if $unsecure_connection; then
|
||||
listen_port=16789
|
||||
ssh_cmd "./restream --listen $listen_port" &
|
||||
ssh_cmd "$restream_rs --listen $listen_port" &
|
||||
sleep 1 # give some time to restream.rs to start listening
|
||||
receive_cmd="nc 10.11.99.1 $listen_port"
|
||||
else
|
||||
receive_cmd="ssh_cmd ./restream"
|
||||
receive_cmd="ssh_cmd $restream_rs"
|
||||
fi
|
||||
|
||||
# shellcheck disable=SC2086
|
||||
|
20
src/main.rs
20
src/main.rs
@ -8,6 +8,7 @@ use lz_fear::CompressionSettings;
|
||||
|
||||
use std::default::Default;
|
||||
use std::fs::File;
|
||||
use std::path::Path;
|
||||
use std::io::{BufRead, BufReader, Read, Seek, SeekFrom, Write};
|
||||
use std::net::{TcpStream, TcpListener};
|
||||
use std::process::Command;
|
||||
@ -31,20 +32,23 @@ fn main() -> Result<()> {
|
||||
let ref opts: Opts = Opts::parse();
|
||||
|
||||
let version = remarkable_version()?;
|
||||
let height = 1872;
|
||||
let streamer = if version == "reMarkable 1.0\n" {
|
||||
let width = 1408;
|
||||
let height = 1872;
|
||||
let bytes_per_pixel = 2;
|
||||
ReStreamer::init("/dev/fb0", 0, width, height, bytes_per_pixel)?
|
||||
} else if version == "reMarkable 2.0\n" {
|
||||
let width = 1404;
|
||||
let height = 1872;
|
||||
let bytes_per_pixel = 1;
|
||||
|
||||
let pid = xochitl_pid()?;
|
||||
let offset = rm2_fb_offset(pid)?;
|
||||
let mem = format!("/proc/{}/mem", pid);
|
||||
ReStreamer::init(&mem, offset, width, height, bytes_per_pixel)?
|
||||
if Path::new("/dev/shm/swtfb.01").exists() {
|
||||
let bytes_per_pixel = 2;
|
||||
ReStreamer::init("/dev/shm/swtfb.01", 0, width, height, bytes_per_pixel)?
|
||||
} else {
|
||||
let bytes_per_pixel = 1;
|
||||
let pid = xochitl_pid()?;
|
||||
let offset = rm2_fb_offset(pid)?;
|
||||
let mem = format!("/proc/{}/mem", pid);
|
||||
ReStreamer::init(&mem, offset, width, height, bytes_per_pixel)?
|
||||
}
|
||||
} else {
|
||||
Err(anyhow!(
|
||||
"Unknown reMarkable version: {}\nPlease open a feature request to support your device.",
|
||||
|
Loading…
x
Reference in New Issue
Block a user