add screencast to capture.

This commit is contained in:
Miroslav Šedivý
2021-01-22 18:13:32 +01:00
parent 407853eeb1
commit 3161870906
7 changed files with 189 additions and 7 deletions

View File

@ -63,6 +63,7 @@ func (h *RoomHandler) Route(r chi.Router) {
r.Route("/screen", func(r chi.Router) {
r.With(auth.CanWatchOnly).Get("/", h.screenConfiguration)
r.With(auth.CanWatchOnly).Get("/image", h.screenImageGet)
r.With(auth.CanWatchOnly).Get("/cast", h.screenCastGet)
r.With(auth.AdminsOnly).Post("/", h.screenConfigurationChange)
r.With(auth.AdminsOnly).Get("/configurations", h.screenConfigurationsList)

View File

@ -95,3 +95,16 @@ func (h *RoomHandler) screenImageGet(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "image/jpeg")
w.Write(out.Bytes())
}
func (h *RoomHandler) screenCastGet(w http.ResponseWriter, r *http.Request) {
screencast := h.capture.Screencast()
if !screencast.Enabled() {
utils.HttpBadRequest(w, "Screencast pipeline is not enabled.")
return
}
bytes := screencast.Image()
w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
w.Header().Set("Content-Type", "image/jpeg")
w.Write(bytes)
}