Skip to content

Commit

Permalink
feat: add raw endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
owulveryck committed May 20, 2021
1 parent 4f48ddb commit 4458728
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ I use this toy project to stream my remarkable 2 (firmware 2.5) on my laptop usi
[video that shows some features](https://www.youtube.com/watch?v=PzlQ2hEIdCc)

Note: click on the video to take a screenshot. The screenshot is a png file with transparent background.

## Quick start

You need ssh access to your remarkable
Expand All @@ -27,6 +28,9 @@ scp goMarkableStreamServer.arm remarkable:
ssh remarkable './goMarkableStreamServer.arm'
```

Note: The processus is fault tolerant and should resume automatically on sleep/wakup or network failure; therefore, you can, normally, launch the processus in background (with `nohup`)


### The client

- Start the client: `RK_SERVER_ADDR=ip.of.remarkable:2000 ./goMarkableClient`
Expand All @@ -51,6 +55,7 @@ It is possible to tweak the configuration via environment variables:
| RK_CLIENT_AUTOROTATE | true | activate autorotate (see below)
| RK_CLIENT_PAPER_TEXTURE | null | a path to a texture
| RK_CLIENT_COLORIZE | false | try to colorize the highliter

## Features

### Auto-rotate
Expand Down Expand Up @@ -99,7 +104,14 @@ ex:
/tmp/screenshot.png: PNG image data, 1404 x 1872, 8-bit/color RGBA, non-interlaced
```

### Raw picture

the `/raw` endpoind exposes the raw picture without any treatment. It is possible to pipe the result into a thrid party tool such as imageMagick for example.

This generates a pdf from the screen
```shell
curl http://localhost:8080/raw | convert -depth 8 -size 1404x1872+0 gray:- shot.pdf
```

## How it works?

Expand Down
14 changes: 14 additions & 0 deletions client/grabber.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package main

import (
"bytes"
"context"
"encoding/gob"
"image"
"image/png"
"io"
"log"
"net/http"
"time"
Expand Down Expand Up @@ -140,3 +142,15 @@ func (g *grabber) getScreenshot(w http.ResponseWriter, r *http.Request) {
return
}
}

func (g *grabber) getRaw(w http.ResponseWriter, r *http.Request) {
tick := time.Tick(1 * time.Second)
select {
case img := <-g.imageC:
w.Header().Add("Cntent-Type", "application/octet-stream")
io.Copy(w, bytes.NewReader(img.Pix))
case <-tick:
http.Error(w, "no content", http.StatusNoContent)
return
}
}
1 change: 1 addition & 0 deletions client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ func main() {
mux.HandleFunc("/favicon.ico", faviconHandler)
mux.HandleFunc("/screenshot", g.getScreenshot)
mux.HandleFunc("/gob", g.getGob)
mux.HandleFunc("/raw", g.getRaw)
mux.HandleFunc("/video", makeGzipHandler(mjpegStream))
log.Printf("listening on %v", c.BindAddr)
go func() {
Expand Down

0 comments on commit 4458728

Please sign in to comment.