Skip to content

Commit

Permalink
fix simulcast track
Browse files Browse the repository at this point in the history
  • Loading branch information
Yohan Totting committed Jan 24, 2024
1 parent 8565980 commit 339fed9
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 8 deletions.
3 changes: 1 addition & 2 deletions clienttrack.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func newClientTrack(c *Client, t *Track, isScreen bool) *clientTrack {
localTrack: t.createLocalTrack(),
remoteTrack: t.remoteTrack,
isScreen: isScreen,
packetChan: make(chan rtp.Packet, 1024),
packetChan: make(chan rtp.Packet, 1),
}

ct.startWorker()
Expand All @@ -65,7 +65,6 @@ func (t *clientTrack) startWorker() {
for {
select {
case <-t.context.Done():
close(t.packetChan)
return
case p := <-t.packetChan:
t.processPacket(p)
Expand Down
1 change: 0 additions & 1 deletion clienttrackred.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ func (t *clientTrackRed) startWorker() {
for {
select {
case <-t.context.Done():
close(t.packetChan)
return
case p := <-t.packetChan:
t.processPacket(p)
Expand Down
2 changes: 1 addition & 1 deletion clienttracksimulcast.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ func newSimulcastClientTrack(c *Client, t *SimulcastTrack) *simulcastClientTrack
isScreen: isScreen,
isEnded: &atomic.Bool{},
onTrackEndedCallbacks: make([]func(), 0),
packetChan: make(chan simulcastPacket, 1),
}

ct.startWorker()
Expand All @@ -92,7 +93,6 @@ func (t *simulcastClientTrack) startWorker() {
for {
select {
case <-t.context.Done():
close(t.packetChan)
return
case p := <-t.packetChan:

Expand Down
1 change: 0 additions & 1 deletion clienttracksvc.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ func (t *scaleableClientTrack) startWorker() {
for {
select {
case <-t.context.Done():
close(t.packetChan)
return
case p := <-t.packetChan:
t.processPacket(p)
Expand Down
4 changes: 1 addition & 3 deletions remotetrack.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,14 @@ func (t *remoteTrack) Context() context.Context {
func (t *remoteTrack) readRTP() {
go func() {
defer t.cancel()

for {
select {
case <-t.context.Done():
return
default:
if err := t.track.SetReadDeadline(time.Now().Add(100 * time.Millisecond)); err != nil {
glog.Error("error setting read deadline: ", err.Error())
return
continue
}

rtp, _, readErr := t.track.ReadRTP()
Expand All @@ -89,7 +88,6 @@ func (t *remoteTrack) readRTP() {
go t.updateStats()
}
}

}
}
}()
Expand Down

0 comments on commit 339fed9

Please sign in to comment.