From 38d0a13762b843735760361be5f26fbf7beda6f9 Mon Sep 17 00:00:00 2001 From: Chase C <13863948+ChaseCares@users.noreply.github.com> Date: Wed, 21 Feb 2024 08:37:47 -0500 Subject: [PATCH] Add firstSeenEpoch to StreamStatus --- internal/webrtc/webrtc.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/internal/webrtc/webrtc.go b/internal/webrtc/webrtc.go index 0f5895e..a914fbf 100644 --- a/internal/webrtc/webrtc.go +++ b/internal/webrtc/webrtc.go @@ -13,6 +13,7 @@ import ( "strings" "sync" "sync/atomic" + "time" "github.com/pion/dtls/v2/pkg/crypto/elliptic" "github.com/pion/ice/v2" @@ -35,6 +36,8 @@ type ( // If stream was created by a WHEP request hasWHIPClient == false hasWHIPClient atomic.Bool + firstSeenEpoch uint64 + videoTracks []*videoTrack audioTrack *webrtc.TrackLocalStaticRTP @@ -98,6 +101,7 @@ func getStream(streamKey string, forWHIP bool) (*stream, error) { whepSessions: map[string]*whepSession{}, whipActiveContext: whipActiveContext, whipActiveContextCancel: whipActiveContextCancel, + firstSeenEpoch: uint64(time.Now().Unix()), } streamMap[streamKey] = foundStream } @@ -355,6 +359,7 @@ type StreamStatusVideo struct { type StreamStatus struct { StreamKey string `json:"streamKey"` + FirstSeenEpoch uint64 `json:"firstSeenEpoch"` AudioPacketsReceived uint64 `json:"audioPacketsReceived"` VideoStreams []StreamStatusVideo `json:"videoStreams"` WHEPSessions []whepSessionStatus `json:"whepSessions"` @@ -403,6 +408,7 @@ func GetStreamStatuses() []StreamStatus { out = append(out, StreamStatus{ StreamKey: streamKey, + FirstSeenEpoch: stream.firstSeenEpoch, AudioPacketsReceived: stream.audioPacketsReceived.Load(), VideoStreams: streamStatusVideo, WHEPSessions: whepSessions,