mirror of
https://github.com/livekit/livekit.git
synced 2026-08-04 15:19:50 +00:00
clean up
This commit is contained in:
@@ -379,6 +379,9 @@ func (p *ParticipantImpl) setCodecPreferencesForPublisherMedia(
|
||||
// configure publisher answer for audio track's dtx and stereo settings
|
||||
func (p *ParticipantImpl) configurePublisherAnswer(answer webrtc.SessionDescription) webrtc.SessionDescription {
|
||||
offer := p.TransportManager.LastPublisherOffer()
|
||||
if offer == nil {
|
||||
return answer
|
||||
}
|
||||
parsedOffer, err := offer.Unmarshal()
|
||||
if err != nil {
|
||||
return answer
|
||||
|
||||
@@ -1003,22 +1003,24 @@ func (t *PCTransport) RemoveTrack(sender *webrtc.RTPSender) error {
|
||||
return t.pc.RemoveTrack(sender)
|
||||
}
|
||||
|
||||
func (t *PCTransport) CurrentLocalDescription() webrtc.SessionDescription {
|
||||
func (t *PCTransport) CurrentLocalDescription() *webrtc.SessionDescription {
|
||||
cld := t.pc.CurrentLocalDescription()
|
||||
if cld == nil {
|
||||
return webrtc.SessionDescription{}
|
||||
return nil
|
||||
}
|
||||
|
||||
return *cld
|
||||
ld := *cld
|
||||
return &ld
|
||||
}
|
||||
|
||||
func (t *PCTransport) CurrentRemoteDescription() webrtc.SessionDescription {
|
||||
func (t *PCTransport) CurrentRemoteDescription() *webrtc.SessionDescription {
|
||||
crd := t.pc.CurrentRemoteDescription()
|
||||
if crd == nil {
|
||||
return webrtc.SessionDescription{}
|
||||
return nil
|
||||
}
|
||||
|
||||
return *crd
|
||||
rd := *crd
|
||||
return &rd
|
||||
}
|
||||
|
||||
func (t *PCTransport) GetMid(rtpReceiver *webrtc.RTPReceiver) string {
|
||||
|
||||
+15
-13
@@ -404,25 +404,27 @@ func (t *TransportManager) createDataChannelsForSubscriber(pendingDataChannels [
|
||||
|
||||
func (t *TransportManager) GetUnmatchMediaForOffer(parsedOffer *sdp.SessionDescription, mediaType string) (unmatched []*sdp.MediaDescription, err error) {
|
||||
var lastMatchedMid string
|
||||
var lastAnswer webrtc.SessionDescription
|
||||
var lastAnswer *webrtc.SessionDescription
|
||||
if t.params.SinglePeerConnection {
|
||||
lastAnswer = t.subscriber.CurrentLocalDescription()
|
||||
} else {
|
||||
lastAnswer = t.publisher.CurrentLocalDescription()
|
||||
}
|
||||
|
||||
parsedAnswer, err1 := lastAnswer.Unmarshal()
|
||||
if err1 != nil {
|
||||
// should not happen
|
||||
t.params.Logger.Errorw("failed to parse last answer", err1)
|
||||
return unmatched, err1
|
||||
}
|
||||
if lastAnswer != nil {
|
||||
parsedAnswer, err1 := lastAnswer.Unmarshal()
|
||||
if err1 != nil {
|
||||
// should not happen
|
||||
t.params.Logger.Errorw("failed to parse last answer", err1)
|
||||
return unmatched, err1
|
||||
}
|
||||
|
||||
for i := len(parsedAnswer.MediaDescriptions) - 1; i >= 0; i-- {
|
||||
media := parsedAnswer.MediaDescriptions[i]
|
||||
if media.MediaName.Media == mediaType {
|
||||
lastMatchedMid, _ = media.Attribute(sdp.AttrKeyMID)
|
||||
break
|
||||
for i := len(parsedAnswer.MediaDescriptions) - 1; i >= 0; i-- {
|
||||
media := parsedAnswer.MediaDescriptions[i]
|
||||
if media.MediaName.Media == mediaType {
|
||||
lastMatchedMid, _ = media.Attribute(sdp.AttrKeyMID)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -440,7 +442,7 @@ func (t *TransportManager) GetUnmatchMediaForOffer(parsedOffer *sdp.SessionDescr
|
||||
return
|
||||
}
|
||||
|
||||
func (t *TransportManager) LastPublisherOffer() webrtc.SessionDescription {
|
||||
func (t *TransportManager) LastPublisherOffer() *webrtc.SessionDescription {
|
||||
return t.publisher.CurrentRemoteDescription()
|
||||
}
|
||||
|
||||
|
||||
@@ -81,8 +81,8 @@ type RTCClient struct {
|
||||
publisherFullyEstablished atomic.Bool
|
||||
subscriberFullyEstablished atomic.Bool
|
||||
pongReceivedAt atomic.Int64
|
||||
lastOffer atomic.Pointer[webrtc.SessionDescription]
|
||||
lastAnswer atomic.Pointer[webrtc.SessionDescription]
|
||||
lastOffer atomic.Pointer[webrtc.SessionDescription] // RAJA-REMOVE
|
||||
lastAnswer atomic.Pointer[webrtc.SessionDescription] // RAJA-REMOVE
|
||||
|
||||
// tracks waiting to be acked, cid => trackInfo
|
||||
pendingPublishedTracks map[string]*livekit.TrackInfo
|
||||
@@ -869,12 +869,14 @@ func (c *RTCClient) GetPublishedTrackIDs() []string {
|
||||
|
||||
// LastOffer return SDP of the last offer for the subscriber connection
|
||||
func (c *RTCClient) LastOffer() *webrtc.SessionDescription {
|
||||
return c.lastOffer.Load()
|
||||
// RAJA-REMOVE return c.lastOffer.Load()
|
||||
return c.subscriber.CurrentRemoteDescription()
|
||||
}
|
||||
|
||||
// LastAnswer return SDP of the last answer for the publisher connection
|
||||
func (c *RTCClient) LastAnswer() *webrtc.SessionDescription {
|
||||
return c.lastAnswer.Load()
|
||||
// RAJA-REMOVE return c.lastAnswer.Load()
|
||||
return c.publisher.CurrentRemoteDescription()
|
||||
}
|
||||
|
||||
func (c *RTCClient) ensurePublisherConnected() error {
|
||||
@@ -923,7 +925,7 @@ func (c *RTCClient) handleDataMessageUnlabeled(data []byte) {
|
||||
// handles a server initiated offer, handle on subscriber PC
|
||||
func (c *RTCClient) handleOffer(desc webrtc.SessionDescription, offerId uint32) {
|
||||
logger.Infow("handling server offer", "participant", c.localParticipant.Identity)
|
||||
c.lastOffer.Store(&desc)
|
||||
// RAJA-REMOVE c.lastOffer.Store(&desc)
|
||||
c.subscriber.HandleRemoteDescription(desc, offerId)
|
||||
}
|
||||
|
||||
@@ -931,7 +933,7 @@ func (c *RTCClient) handleOffer(desc webrtc.SessionDescription, offerId uint32)
|
||||
func (c *RTCClient) handleAnswer(desc webrtc.SessionDescription, answerId uint32) {
|
||||
logger.Infow("handling server answer", "participant", c.localParticipant.Identity)
|
||||
|
||||
c.lastAnswer.Store(&desc)
|
||||
// RAJA-REMOVE c.lastAnswer.Store(&desc)
|
||||
// remote answered the offer, establish connection
|
||||
c.publisher.HandleRemoteDescription(desc, answerId)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user