File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -84,6 +84,7 @@ func (s *Session) AddHost(peerConnection *webrtc.PeerConnection) (err error) {
8484 host .RemoveTracks ()
8585 return fmt .Errorf ("session already has a host" )
8686 }
87+ s .resetWHEPSessionsForNewHost ()
8788 host .WHEPSessionsSnapshot .Store (make (map [string ]* whep.WHEPSession ))
8889 s .updateHostWHEPSessionsSnapshot ()
8990 s .HasHost .Store (true )
@@ -237,6 +238,18 @@ func (s *Session) updateHostWHEPSessionsSnapshot() {
237238 host .WHEPSessionsSnapshot .Store (snapshot )
238239}
239240
241+ func (s * Session ) resetWHEPSessionsForNewHost () {
242+ s .WHEPSessionsLock .RLock ()
243+ for _ , whepSession := range s .WHEPSessions {
244+ if whepSession == nil {
245+ continue
246+ }
247+
248+ whepSession .ResetForNewPublisher ()
249+ }
250+ s .WHEPSessionsLock .RUnlock ()
251+ }
252+
240253// Get the status of the current session
241254func (s * Session ) GetStreamStatus () (status whipSessionStatus ) {
242255 s .WHEPSessionsLock .RLock ()
Original file line number Diff line number Diff line change @@ -137,6 +137,18 @@ func (w *WHEPSession) SendPLI() {
137137 w .pliSender ()
138138}
139139
140+ // Reset per-publisher delivery state when a new WHIP publisher connects.
141+ func (w * WHEPSession ) ResetForNewPublisher () {
142+ w .VideoLock .Lock ()
143+ defer w .VideoLock .Unlock ()
144+
145+ w .AudioLayerCurrent .Store ("" )
146+ w .VideoLayerCurrent .Store ("" )
147+ w .videoLayerPriority = 0
148+ w .videoLayerExplicit = false
149+ w .IsWaitingForKeyframe .Store (true )
150+ }
151+
140152func (w * WHEPSession ) updateVideoBitrateLocked (now time.Time ) {
141153 if w .videoBitrateWindowStart .IsZero () {
142154 w .videoBitrateWindowStart = now
You can’t perform that action at this time.
0 commit comments