Skip to content

Commit

Permalink
Add firstSeenEpoch to StreamStatus
Browse files Browse the repository at this point in the history
  • Loading branch information
ChaseCares authored and Sean-Der committed Feb 21, 2024
1 parent 9c489f8 commit 38d0a13
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions internal/webrtc/webrtc.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"strings"
"sync"
"sync/atomic"
"time"

"github.com/pion/dtls/v2/pkg/crypto/elliptic"
"github.com/pion/ice/v2"
Expand All @@ -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
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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"`
Expand Down Expand Up @@ -403,6 +408,7 @@ func GetStreamStatuses() []StreamStatus {

out = append(out, StreamStatus{
StreamKey: streamKey,
FirstSeenEpoch: stream.firstSeenEpoch,
AudioPacketsReceived: stream.audioPacketsReceived.Load(),
VideoStreams: streamStatusVideo,
WHEPSessions: whepSessions,
Expand Down

0 comments on commit 38d0a13

Please sign in to comment.