added routes and auth for devices and users for MediaMTX server
This commit is contained in:
45
server/internal/dto/mediamtx.go
Normal file
45
server/internal/dto/mediamtx.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package dto
|
||||
|
||||
import "github.com/golang-jwt/jwt/v5"
|
||||
|
||||
type MediaClaims struct {
|
||||
Act string `json:"act"` // "publish" or "read"
|
||||
Path string `json:"path"` // e.g. "live/<guid>"
|
||||
jwt.RegisteredClaims
|
||||
}
|
||||
|
||||
// MediaMTX external-auth POST body (exact keys per mediamtx.yml sample)
|
||||
type MediaMTXAuthReq struct {
|
||||
User string `json:"user"` // optional
|
||||
Password string `json:"password"` // optional
|
||||
Token string `json:"token"` // from Authorization: Bearer or query (?token=)
|
||||
IP string `json:"ip"`
|
||||
Action string `json:"action"` // publish|read|playback|api|metrics|pprof
|
||||
Path string `json:"path"` // e.g. "live/<guid>"
|
||||
Protocol string `json:"protocol"` // rtsp|rtmp|hls|webrtc|srt
|
||||
ID string `json:"id"` // session id
|
||||
Query string `json:"query"` // raw query string
|
||||
}
|
||||
|
||||
type MediaMTXAuthResp struct {
|
||||
// empty 200 means allowed; add fields if you want to return JSON
|
||||
// to mediamtx (not required)
|
||||
}
|
||||
|
||||
// Token minting
|
||||
type PublishTokenReq struct {
|
||||
GUID string `json:"guid" binding:"required,uuid4"`
|
||||
}
|
||||
|
||||
type PublishTokenResp struct {
|
||||
WHIP string `json:"whipUrl"` // http://mediamtx:8889/whip/live/<guid>?token=...
|
||||
}
|
||||
|
||||
type ReadTokenReq struct {
|
||||
GUID string `json:"guid" binding:"required,uuid4"`
|
||||
}
|
||||
|
||||
type ReadTokenResp struct {
|
||||
HLS string `json:"hlsUrl"` // http://<host>/hls/live/<guid>/index.m3u8?token=...
|
||||
WHEP string `json:"whepUrl"` // http://<host>/webrtc/play/live/<guid>?token=...
|
||||
}
|
||||
Reference in New Issue
Block a user