From 5d39620f6fc532ebb5ed32e6f9a58513c09affb2 Mon Sep 17 00:00:00 2001 From: Ingo Oppermann Date: Fri, 1 Dec 2023 12:08:56 +0100 Subject: [PATCH] Parse out avstream debug infos --- ffmpeg/parse/types.go | 101 +++++++++++++++++++++++++++++++++------ restream/app/avstream.go | 22 +++++++++ 2 files changed, 108 insertions(+), 15 deletions(-) diff --git a/ffmpeg/parse/types.go b/ffmpeg/parse/types.go index db73bd4c..9b8b866a 100644 --- a/ffmpeg/parse/types.go +++ b/ffmpeg/parse/types.go @@ -56,22 +56,69 @@ func (avio *ffmpegAVstreamIO) export() AVstreamIO { } } +type ffmpegAVStreamDebug struct { + Sentinel struct { + Reopen uint64 `json:"reopen"` + } `json:"sentinel"` + Track struct { + FPS int `json:"fps"` + Bitrate uint64 `json:"bitrate"` + } `json:"track"` + Counter []uint64 `json:"counter"` + Locks []int `json:"locks"` + Version string `json:"version"` +} + +func (avdebug *ffmpegAVStreamDebug) export() AVStreamDebug { + debug := AVStreamDebug{ + Version: avdebug.Version, + } + + debug.Counter = append(debug.Counter, avdebug.Counter...) + debug.Locks = append(debug.Locks, avdebug.Locks...) + + debug.Sentinel.Reopen = avdebug.Sentinel.Reopen + + debug.Track.FPS = avdebug.Track.FPS + debug.Track.Bitrate = avdebug.Track.Bitrate + + return debug +} + +type ffmpegAVStreamSwap struct { + URL string `json:"url"` + Status string `json:"status"` + LastURL string `json:"lasturl"` + LastError string `json:"lasterror"` +} + +func (avswap *ffmpegAVStreamSwap) export() AVStreamSwap { + return AVStreamSwap{ + URL: avswap.URL, + Status: avswap.Status, + LastURL: avswap.LastURL, + LastError: avswap.LastError, + } +} + type ffmpegAVstream struct { - Input ffmpegAVstreamIO `json:"input"` - Output ffmpegAVstreamIO `json:"output"` - Address string `json:"id"` - URL string `json:"url"` - Stream uint64 `json:"stream"` - Aqueue uint64 `json:"aqueue"` - Queue uint64 `json:"queue"` - Dup uint64 `json:"dup"` - Drop uint64 `json:"drop"` - Enc uint64 `json:"enc"` - Looping bool `json:"looping"` - LoopingRuntime uint64 `json:"looping_runtime"` - Duplicating bool `json:"duplicating"` - GOP string `json:"gop"` - Mode string `json:"mode"` + Input ffmpegAVstreamIO `json:"input"` + Output ffmpegAVstreamIO `json:"output"` + Address string `json:"id"` + URL string `json:"url"` + Stream uint64 `json:"stream"` + Aqueue uint64 `json:"aqueue"` + Queue uint64 `json:"queue"` + Dup uint64 `json:"dup"` + Drop uint64 `json:"drop"` + Enc uint64 `json:"enc"` + Looping bool `json:"looping"` + LoopingRuntime uint64 `json:"looping_runtime"` + Duplicating bool `json:"duplicating"` + GOP string `json:"gop"` + Mode string `json:"mode"` + Debug ffmpegAVStreamDebug `json:"debug"` + Swap ffmpegAVStreamSwap `json:"swap"` } func (av *ffmpegAVstream) export() *AVstream { @@ -88,6 +135,8 @@ func (av *ffmpegAVstream) export() *AVstream { Mode: av.Mode, Input: av.Input.export(), Output: av.Output.export(), + Debug: av.Debug.export(), + Swap: av.Swap.export(), } } @@ -453,6 +502,26 @@ type AVstreamIO struct { Size uint64 } +type AVStreamDebug struct { + Sentinel struct { + Reopen uint64 + } + Track struct { + FPS int + Bitrate uint64 + } + Counter []uint64 + Locks []int + Version string +} + +type AVStreamSwap struct { + URL string + Status string + LastURL string + LastError string +} + type AVstream struct { Input AVstreamIO Output AVstreamIO @@ -466,6 +535,8 @@ type AVstream struct { Duplicating bool GOP string Mode string + Debug AVStreamDebug + Swap AVStreamSwap } type Usage struct { diff --git a/restream/app/avstream.go b/restream/app/avstream.go index f671d453..0df3ff63 100644 --- a/restream/app/avstream.go +++ b/restream/app/avstream.go @@ -7,6 +7,26 @@ type AVstreamIO struct { Size uint64 // bytes } +type AVStreamDebug struct { + Sentinel struct { + Reopen uint64 + } + Track struct { + FPS int + Bitrate uint64 + } + Counter []uint64 + Locks []int + Version string +} + +type AVStreamSwap struct { + URL string + Status string + LastURL string + LastError string +} + type AVstream struct { Input AVstreamIO Output AVstreamIO @@ -20,4 +40,6 @@ type AVstream struct { Duplicating bool GOP string Mode string // "file" or "live" + Debug AVStreamDebug + Swap AVStreamSwap }