Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added examples/images/fazantix.pdf
Binary file not shown.
86 changes: 86 additions & 0 deletions examples/pdfslides.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
sources:
background:
type: image
path: images/background.png
slides:
tag: SLD
type: pdf
path: images/fazantix.pdf
width: 1920
height: 1080
makescene: true
camera:
tag: CAM
type: image
path: images/testsrc1.png
makescene: true


scenes:
side-by-side:
layers:
- source: background
transform:
x: 0
y: 0
scale: 1
opacity: 1
- source: slides
transform:
cx: 0.25
cy: 0.5
left: 0.01
opacity: 1
- source: camera
transform:
cx: 0.75
cy: 0.5
right: 0.01
opacity: 1
default:
tag: "dflt"
layers:
- source: background
transform:
x: 0
y: 0
scale: 1
opacity: 1
- source: slides
transform:
left: -0.04
top: -0.04
scale: 0.79
opacity: 1
warp:
opacity: 0
cx: 0.5
cy: 0.5
scale: 0.1
- source: camera
transform:
right: -0.04
bottom: -0.1
scale: 0.25
opacity: 1
warp:
opacity: 1
scale: 0.001
right: -0.04
bottom: -0.1

sinks:
projector:
type: window
frames:
width: 1280
height: 720
default_scene: default
transition_time_ms: 1500

api:
bind: ':8000'
enable_profiler: true

fallback_colour: '#ebac54'
bg_colour: '#54aceb'
15 changes: 10 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module github.com/fosdem/fazantix
go 1.24.4

require (
github.com/gen2brain/go-fitz v1.24.15
github.com/go-gl/gl v0.0.0-20231021071112-07e5d0ea2e71
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20250301202403-da16c1255728
github.com/go-gl/mathgl v1.2.0
Expand All @@ -13,19 +14,22 @@ require (
github.com/prometheus/client_golang v1.23.0
github.com/swaggo/http-swagger v1.3.4
github.com/swaggo/swag v1.16.6
golang.org/x/sys v0.33.0
golang.org/x/image v0.34.0
golang.org/x/sys v0.38.0
)

require (
github.com/KyleBanks/depth v1.2.1 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d // indirect
github.com/ebitengine/purego v0.8.4 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.20.0 // indirect
github.com/go-openapi/spec v0.20.6 // indirect
github.com/go-openapi/swag v0.19.15 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/jupiterrider/ffi v0.5.0 // indirect
github.com/mailru/easyjson v0.7.6 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/prometheus/client_model v0.6.2 // indirect
Expand All @@ -35,10 +39,11 @@ require (
github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
github.com/swaggo/files v0.0.0-20220610200504-28940afbdbfe // indirect
github.com/urfave/cli/v2 v2.3.0 // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.40.0 // indirect
golang.org/x/text v0.25.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
golang.org/x/mod v0.30.0 // indirect
golang.org/x/net v0.47.0 // indirect
golang.org/x/sync v0.19.0 // indirect
golang.org/x/text v0.32.0 // indirect
golang.org/x/tools v0.39.0 // indirect
google.golang.org/protobuf v1.36.6 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
Expand Down
32 changes: 20 additions & 12 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/ebitengine/purego v0.8.4 h1:CF7LEKg5FFOsASUj0+QwaXf8Ht6TlFxg09+S9wz0omw=
github.com/ebitengine/purego v0.8.4/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ=
github.com/gen2brain/go-fitz v1.24.15 h1:sJNB1MOWkqnzzENPHggFpgxTwW0+S5WF/rM5wUBpJWo=
github.com/gen2brain/go-fitz v1.24.15/go.mod h1:SftkiVbTHqF141DuiLwBBM65zP7ig6AVDQpf2WlHamo=
github.com/go-gl/gl v0.0.0-20231021071112-07e5d0ea2e71 h1:5BVwOaUSBTlVZowGO6VZGw2H/zl9nrd3eCZfYV+NfQA=
github.com/go-gl/gl v0.0.0-20231021071112-07e5d0ea2e71/go.mod h1:9YTyiznxEY1fVinfM7RvRcjRHbw2xLBJ3AAGIT0I4Nw=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20250301202403-da16c1255728 h1:RkGhqHxEVAvPM0/R+8g7XRwQnHatO0KAuVcwHo8q9W8=
Expand All @@ -37,6 +41,8 @@ github.com/jhenstridge/go-inotify v0.0.0-20221229091821-b0d1463614ad h1:/2F/Btqi
github.com/jhenstridge/go-inotify v0.0.0-20221229091821-b0d1463614ad/go.mod h1:VwIUlT/4zR9maLnQrENDJkTxb971f5N4sXUTVvSa2WU=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/jupiterrider/ffi v0.5.0 h1:j2nSgpabbV1JOwgP4Kn449sJUHq3cVLAZVBoOYn44V8=
github.com/jupiterrider/ffi v0.5.0/go.mod h1:x7xdNKo8h0AmLuXfswDUBxUsd2OqUP4ekC8sCnsmbvo=
github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo=
github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
Expand Down Expand Up @@ -88,24 +94,26 @@ github.com/urfave/cli/v2 v2.3.0 h1:qph92Y649prgesehzOrQjdWyxFOp/QVM+6imKHad91M=
github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA=
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/image v0.34.0 h1:33gCkyw9hmwbZJeZkct8XyR11yH889EQt/QH4VmXMn8=
golang.org/x/image v0.34.0/go.mod h1:2RNFBZRB+vnwwFil8GkMdRvrJOFd1AzdZI6vOY+eJVU=
golang.org/x/mod v0.30.0 h1:fDEXFVZ/fmCKProc/yAXXUijritrDzahmwwefnjoPFk=
golang.org/x/mod v0.30.0/go.mod h1:lAsf5O2EvJeSFMiBxXDki7sCgAxEUcZHXoXMKT4GJKc=
golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.40.0 h1:79Xs7wF06Gbdcg4kdCCIQArK11Z1hr5POQ6+fIYHNuY=
golang.org/x/net v0.40.0/go.mod h1:y0hY0exeL2Pku80/zKK7tpntoX23cqL3Oa6njdgRtds=
golang.org/x/sync v0.14.0 h1:woo0S4Yywslg6hp4eUFjTVOyKt0RookbpAHG4c1HmhQ=
golang.org/x/sync v0.14.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
golang.org/x/net v0.47.0 h1:Mx+4dIFzqraBXUugkia1OOvlD6LemFo1ALMHjrXDOhY=
golang.org/x/net v0.47.0/go.mod h1:/jNxtkgq5yWUGYkaZGqo27cfGZ1c5Nen03aYrrKpVRU=
golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4=
golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw=
golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc=
golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.25.0 h1:qVyWApTSYLk/drJRO5mDlNYskwQznZmkpV2c8q9zls4=
golang.org/x/text v0.25.0/go.mod h1:WEdwpYrmk1qmdHvhkSTNPm3app7v4rsT8F2UD6+VHIA=
golang.org/x/text v0.32.0 h1:ZD01bjUt1FQ9WJ0ClOL5vxgxOI/sVCNgX1YtKwcY0mU=
golang.org/x/text v0.32.0/go.mod h1:o/rUWzghvpD5TXrTIBuJU77MTaN0ljMWE47kxGJQ7jY=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg=
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
golang.org/x/tools v0.39.0 h1:ik4ho21kwuQln40uelmciQPp9SipgNDdrafrYA4TmQQ=
golang.org/x/tools v0.39.0/go.mod h1:JnefbkDPyD8UU2kI5fuf8ZX4/yUeh9W877ZeBONxUqQ=
google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY=
google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down
1 change: 1 addition & 0 deletions lib/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ func (a *Api) Serve() error {
a.mux.HandleFunc("/api/media/source/{source}", a.handleMediaSource)
a.mux.HandleFunc("/api/media/sink/{sink}", a.handleMediaSource)
a.mux.HandleFunc("/api/media/source/{source}/{format}", a.handleMediaSource)
a.mux.HandleFunc("/api/slide/source/{source}/{action}/{num}", a.handleSlidePage)
a.mux.Handle("/swagger/", httpSwagger.Handler())
a.mux.Handle("/metrics", metrics.Handler())
a.mux.Handle("/", http.FileServer(http.FS(contentFS)))
Expand Down
38 changes: 23 additions & 15 deletions lib/api/media.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/fosdem/fazantix/lib/encdec"
"github.com/fosdem/fazantix/lib/layer"
"github.com/fosdem/fazantix/lib/source/imgsource"
"github.com/fosdem/fazantix/lib/source/pdfsource"
)

type FrameForwarderObject interface {
Expand Down Expand Up @@ -124,25 +125,32 @@ func (a *Api) handleMediaSource(w http.ResponseWriter, req *http.Request) {
return
}

imgSource, ok := source.(*imgsource.ImgSource)
if !ok {
http.Error(w, "not a valid image source", http.StatusBadRequest)
return
}

if req.Method == "PUT" {
newImage, ftype, err := image.Decode(req.Body)
if err != nil {
http.Error(w, fmt.Sprintf("not a valid image: %s", err), http.StatusBadRequest)
switch src := source.(type) {
case *imgsource.ImgSource:
newImage, ftype, err := image.Decode(req.Body)
if err != nil {
http.Error(w, fmt.Sprintf("not a valid image: %s", err), http.StatusBadRequest)
return
}
log.Printf("Image source %s was updated with new %s image (%dx%d)\n", sourceName, ftype, newImage.Bounds().Dx(), newImage.Bounds().Dy())
err = src.SetImage(newImage)
if err != nil {
http.Error(w, fmt.Sprintf("could not update image: %s", err), http.StatusBadRequest)
return
}
return
}
log.Printf("Image source %s was updated with new %s image (%dx%d)\n", sourceName, ftype, newImage.Bounds().Dx(), newImage.Bounds().Dy())
err = imgSource.SetImage(newImage)
if err != nil {
http.Error(w, fmt.Sprintf("could not update image: %s", err), http.StatusBadRequest)
case *pdfsource.PdfSource:
err := src.SetDocument(req.Body)
if err != nil {
http.Error(w, fmt.Sprintf("could not update document: %s", err), http.StatusBadRequest)
return
}
return
default:
http.Error(w, "Unsupported source type", http.StatusBadRequest)
return
}
return
}

http.Error(w, "Invalid method, only GET and PUT supported", http.StatusMethodNotAllowed)
Expand Down
72 changes: 72 additions & 0 deletions lib/api/slides.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package api

import (
"fmt"
"net/http"
"strconv"

"github.com/fosdem/fazantix/lib/source/pdfsource"
)

// @Summary fetch a frame from a source or sink
// @Router /api/slides/source/{name}/set-slide/{num} [post]
// @Router /api/slides/source/{name}/move-slide/{num} [post]
// @Tags media
// @Param name path string true "Name of the source to control the slides of"
// @Param num path int true "The slide number to switch to"
// @Success 200
// @Failure 400 {string} string "The {name} parameter was not specified"
// @Failure 400 {string} string "The {num} parameter was out of range"
// @Failure 404 {string} string "The specified source does not exist in the configuration"
func (a *Api) handleSlidePage(w http.ResponseWriter, req *http.Request) {
sourceName := req.PathValue("source")
pageStr := req.PathValue("num")
actionStr := req.PathValue("action")
if sourceName == "" {
http.Error(w, "Missing source name", http.StatusBadRequest)
return
}
if pageStr == "" {
http.Error(w, "Missing page number", http.StatusBadRequest)
return
}
if actionStr != "set-slide" && actionStr != "move-slide" {
http.Error(w, "Invalid action", http.StatusBadRequest)
return
}
page, err := strconv.ParseInt(pageStr, 10, 32)
if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
return
}

var source FrameForwarderObject
source = a.theatre.SourceByName(sourceName)
if source == nil {
http.Error(w, "Source does not exist", http.StatusNotFound)
return
}

if req.Method != "POST" {
http.Error(w, "Unsupported method", http.StatusMethodNotAllowed)
return
}

relative := false
if actionStr == "move-slide" {
relative = true
}

switch src := source.(type) {
case *pdfsource.PdfSource:
err = src.SetPage(int(page), relative)
if err != nil {
http.Error(w, fmt.Sprintf("could not set slide: %s", err), http.StatusBadRequest)
return
}
return
default:
http.Error(w, "Unsupported source type", http.StatusBadRequest)
return
}
}
21 changes: 21 additions & 0 deletions lib/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (

var EnablePlutobook = true
var EnableOmt = true
var EnableMupdf = true

type Config struct {
Sources map[string]*SourceCfg
Expand Down Expand Up @@ -212,6 +213,12 @@ type HtmlSourceCfg struct {
Height int
}

type PdfSourceCfg struct {
Path CfgPath
Width int
Height int
}

type V4LSourceCfg struct {
encdec.FrameCfg `yaml:"frames"`
Path string
Expand Down Expand Up @@ -247,6 +254,10 @@ func (s *SourceCfg) UnmarshalYAML(b []byte) error {
cfg := OmtSourceCfg{}
s.Cfg = &cfg
return yaml.Unmarshal(b, &cfg)
case "pdf":
cfg := PdfSourceCfg{}
s.Cfg = &cfg
return yaml.Unmarshal(b, &cfg)
default:
return fmt.Errorf("unknown source type: %s", s.Type)
}
Expand Down Expand Up @@ -399,3 +410,13 @@ func (s *V4LSourceCfg) Validate() error {
}
return nil
}

func (s *PdfSourceCfg) Validate() error {
if !EnableMupdf {
return fmt.Errorf("MuPDF support is not compiled in")
}
if s.Width == 0 && s.Height == 0 {
return fmt.Errorf("PDF rendering size must be specified")
}
return nil
}
Loading
Loading