46 lines
1.5 KiB
Go
46 lines
1.5 KiB
Go
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 {
|
|
HLS string `json:"hlsUrl"` // https://<public>/hls/live/<guid>/index.m3u8?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=...
|
|
}
|