From c77d2b03059cac4bcdaa075d4145f2c38c630232 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20=C5=A0ediv=C3=BD?= Date: Fri, 30 Oct 2020 22:20:23 +0100 Subject: [PATCH] ScreenConfigurationsList API. --- internal/api/room/screen.go | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/internal/api/room/screen.go b/internal/api/room/screen.go index 3c6ed3eb..64289fa5 100644 --- a/internal/api/room/screen.go +++ b/internal/api/room/screen.go @@ -16,6 +16,14 @@ type ScreenConfiguration struct { } func (a *ScreenConfiguration) Bind(r *http.Request) error { + // Bind will run after the unmarshalling is complete, its a + // good time to focus some post-processing after a decoding. + return nil +} + +func (a *ScreenConfiguration) Render(w http.ResponseWriter, r *http.Request) error { + // Pre-processing before a response is marshalled and sent + // across the wire return nil } @@ -55,5 +63,18 @@ func (h *RoomHandler) ScreenConfigurationChange(w http.ResponseWriter, r *http.R } func (h *RoomHandler) ScreenConfigurationsList(w http.ResponseWriter, r *http.Request) { - render.Render(w, r, utils.ErrMessage(500, "Not implmented.")) + list := []render.Renderer{} + + ScreenConfigurations := h.remote.ScreenConfigurations() + for _, size := range ScreenConfigurations { + for _, fps := range size.Rates { + list = append(list, &ScreenConfiguration{ + Width: size.Width, + Height: size.Height, + Rate: int(fps), + }) + } + } + + render.RenderList(w, r, list) }