Skip to content

Commit

Permalink
Merge pull request #31 from owulveryck/orientation
Browse files Browse the repository at this point in the history
Orientation
  • Loading branch information
owulveryck authored Dec 23, 2021
2 parents b5a6f09 + 9eb3124 commit 77b5ea4
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,15 @@ Note: The processus is fault tolerant and should resume automatically on sleep/w

- Point your browser to [`http://localhost:8080/`](http://localhost:8080/)

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

_Note_: there is also an experimental (and ugly) [/conf`](http://localhost:8080/conf) endpoint to activate some features on the fly.
- `/screenshot` takes a screenshot in png
- `/orientation?orientation=[landscape|portrait]` to change the orientation
- `/conf` ugly and incomplete configuration panel
- `/gob` to get a gob encoded picture (for development purpose)
- `/raw` to get a raw picture (a gray bitmap image)

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

### Configuration

Expand Down
1 change: 1 addition & 0 deletions client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func main() {
})
mux.HandleFunc("/favicon.ico", faviconHandler)
mux.HandleFunc("/screenshot", g.GetScreenshot)
mux.HandleFunc("/orientation", g.Rotate)
mux.Handle("/conf", &c)
mux.HandleFunc("/gob", g.GetGob)
mux.HandleFunc("/raw", g.GetRaw)
Expand Down
20 changes: 20 additions & 0 deletions internal/client/grabber.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,26 @@ func (g *Grabber) GetGob(w http.ResponseWriter, r *http.Request) {
}
}

// Rotate the picture
func (g *Grabber) Rotate(w http.ResponseWriter, r *http.Request) {
orientations, ok := r.URL.Query()["orientation"]
if !ok || len(orientations[0]) < 1 {
http.Error(w, "Url Param 'orientation' is missing", http.StatusBadRequest)
return
}
orientation := orientations[0]
switch orientation {
case "landscape":
g.rot.orientation = landscape
case "portrait":
g.rot.orientation = portrait
default:
http.Error(w, "Unknown orientation "+orientation, http.StatusBadRequest)
return

}
}

// GetScreenshot sends a png encoded version of the image currently in the grabber
func (g *Grabber) GetScreenshot(w http.ResponseWriter, r *http.Request) {
tick := time.NewTicker(1 * time.Second)
Expand Down

0 comments on commit 77b5ea4

Please sign in to comment.