From ad7b8896f5477d49d6938b55ce4cef6c1a0101ff Mon Sep 17 00:00:00 2001 From: Yohan Totting Date: Fri, 19 Apr 2024 17:21:29 +0700 Subject: [PATCH] remove track id cleanup --- client.go | 1 + track.go | 21 ++++++--------------- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/client.go b/client.go index 22fe632..4d5a98e 100644 --- a/client.go +++ b/client.go @@ -445,6 +445,7 @@ func NewClient(s *SFU, id string, name string, peerConnectionConfig webrtc.Confi defer glog.Info("client: ", client.ID(), " new track ", remoteTrackID, " Kind:", remoteTrack.Kind(), " Codec: ", remoteTrack.Codec().MimeType, " RID: ", remoteTrack.RID(), " Direction: ", receiver.RTPTransceiver().Direction()) + // make sure the remote track ID is not empty if remoteTrackID == "" { glog.Error("client: error remote track id is empty") return diff --git a/track.go b/track.go index e91fb1d..cf54930 100644 --- a/track.go +++ b/track.go @@ -3,7 +3,6 @@ package sfu import ( "context" "errors" - "strings" "sync" "sync/atomic" "time" @@ -78,15 +77,11 @@ type Track struct { func newTrack(ctx context.Context, client *Client, trackRemote IRemoteTrack, minWait, maxWait, pliInterval time.Duration, onPLI func(), stats stats.Getter, onStatsUpdated func(*stats.Stats)) ITrack { ctList := newClientTrackList() - remoteTrackID := strings.ReplaceAll(strings.ReplaceAll(trackRemote.ID(), "{", ""), "}", "") - streamID := strings.ReplaceAll(strings.ReplaceAll(trackRemote.StreamID(), "{", ""), "}", "") - msid := strings.ReplaceAll(strings.ReplaceAll(trackRemote.Msid(), "{", ""), "}", "") - baseTrack := &baseTrack{ - id: remoteTrackID, + id: trackRemote.ID(), isScreen: &atomic.Bool{}, - msid: msid, - streamid: streamID, + msid: trackRemote.Msid(), + streamid: trackRemote.StreamID(), client: client, kind: trackRemote.Kind(), codec: trackRemote.Codec(), @@ -363,17 +358,13 @@ type SimulcastTrack struct { } func newSimulcastTrack(client *Client, track IRemoteTrack, minWait, maxWait, pliInterval time.Duration, onPLI func(), stats stats.Getter, onStatsUpdated func(*stats.Stats)) ITrack { - remoteTrackID := strings.ReplaceAll(strings.ReplaceAll(track.ID(), "{", ""), "}", "") - streamID := strings.ReplaceAll(strings.ReplaceAll(track.StreamID(), "{", ""), "}", "") - msid := strings.ReplaceAll(strings.ReplaceAll(track.Msid(), "{", ""), "}", "") - t := &SimulcastTrack{ mu: sync.RWMutex{}, base: &baseTrack{ - id: remoteTrackID, + id: track.ID(), isScreen: &atomic.Bool{}, - msid: msid, - streamid: streamID, + msid: track.Msid(), + streamid: track.StreamID(), client: client, kind: track.Kind(), codec: track.Codec(),