add session & metrics to webrtc peer.

This commit is contained in:
Miroslav Šedivý 2023-04-10 21:37:39 +02:00
parent 9928feefef
commit ec8560b290
3 changed files with 8 additions and 4 deletions

View File

@ -452,6 +452,8 @@ func (manager *WebRTCManagerCtx) CreatePeer(session types.Session, bitrate int,
peer := &WebRTCPeerCtx{
logger: logger,
session: session,
metrics: metrics,
connection: connection,
// tracks & channels
audioTrack: audioTrack,

View File

@ -13,16 +13,16 @@ import (
type metricsManager struct {
mu sync.Mutex
sessions map[string]metrics
sessions map[string]*metrics
}
func newMetricsManager() *metricsManager {
return &metricsManager{
sessions: map[string]metrics{},
sessions: map[string]*metrics{},
}
}
func (m *metricsManager) getBySession(session types.Session) metrics {
func (m *metricsManager) getBySession(session types.Session) *metrics {
m.mu.Lock()
defer m.mu.Unlock()
@ -33,7 +33,7 @@ func (m *metricsManager) getBySession(session types.Session) metrics {
return met
}
met = metrics{
met = &metrics{
sessionId: sessionId,
connectionState: promauto.NewGauge(prometheus.GaugeOpts{

View File

@ -16,6 +16,8 @@ import (
type WebRTCPeerCtx struct {
mu sync.Mutex
logger zerolog.Logger
session types.Session
metrics *metrics
connection *webrtc.PeerConnection
// tracks & channels
audioTrack *Track