Skip to content

Commit

Permalink
expose some private functions
Browse files Browse the repository at this point in the history
  • Loading branch information
tyohan committed Jan 14, 2025
1 parent 3a52945 commit a3ca7e2
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion clienttrack.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func (t *clientTrack) IsScaleable() bool {
}

func (t *clientTrack) RequestPLI() {
t.remoteTrack.sendPLI()
t.remoteTrack.SendPLI()
}

func (t *clientTrack) SetMaxQuality(_ QualityLevel) {
Expand Down
6 changes: 3 additions & 3 deletions clienttracksimulcast.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,15 +180,15 @@ func (t *simulcastClientTrack) push(p *rtp.Packet, quality QualityLevel) {
// check if it's a first packet to send
if currentQuality == QualityNone && t.sequenceNumber.Load() == 0 {
// we try to send the low quality first if the track is active and fallback to upper quality if not
if t.remoteTrack.getRemoteTrack(QualityLow) != nil && quality == QualityLow {
if t.remoteTrack.GetRemoteTrack(QualityLow) != nil && quality == QualityLow {
t.lastQuality.Store(uint32(QualityLow))
// send PLI to make sure the client will receive the first frame
t.remoteTrack.sendPLI()
} else if t.remoteTrack.getRemoteTrack(QualityMid) != nil && quality == QualityMid {
} else if t.remoteTrack.GetRemoteTrack(QualityMid) != nil && quality == QualityMid {
t.lastQuality.Store(uint32(QualityMid))
// send PLI to make sure the client will receive the first frame
t.remoteTrack.sendPLI()
} else if t.remoteTrack.getRemoteTrack(QualityHigh) != nil && quality == QualityHigh {
} else if t.remoteTrack.GetRemoteTrack(QualityHigh) != nil && quality == QualityHigh {
t.lastQuality.Store(uint32(QualityHigh))
// send PLI to make sure the client will receive the first frame
t.remoteTrack.sendPLI()
Expand Down
2 changes: 1 addition & 1 deletion clienttracksvc.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,5 +313,5 @@ func (t *scaleableClientTrack) IsScaleable() bool {
}

func (t *scaleableClientTrack) RequestPLI() {
go t.remoteTrack.sendPLI()
go t.remoteTrack.SendPLI()
}
1 change: 1 addition & 0 deletions examples/http-websocket/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ func clientHandler(isDebug bool, conn *websocket.Conn, messageChan chan Request,
// add a new client to room
// you can also get the client by using r.GetClient(clientID)
opts := sfu.DefaultClientOptions()
opts.EnableOpusDTX = true
opts.EnableVoiceDetection = true
opts.ReorderPackets = false
client, err := r.AddClient(clientID, clientID, opts)
Expand Down
4 changes: 2 additions & 2 deletions remotetrack.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func (t *remoteTrack) Track() IRemoteTrack {
return t.track
}

func (t *remoteTrack) sendPLI() {
func (t *remoteTrack) SendPLI() {
t.mu.Lock()
defer t.mu.Unlock()

Expand Down Expand Up @@ -208,7 +208,7 @@ func (t *remoteTrack) enableIntervalPLI(interval time.Duration) {
case <-ctx.Done():
return
case <-ticker.C:
t.sendPLI()
t.SendPLI()
}
}
}()
Expand Down
10 changes: 5 additions & 5 deletions track.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ func (t *Track) subscribe(c *Client) iClientTrack {
}

if t.Kind() == webrtc.RTPCodecTypeVideo {
t.remoteTrack.sendPLI()
t.remoteTrack.SendPLI()
}

t.base.clientTracks.Add(ct)
Expand Down Expand Up @@ -652,7 +652,7 @@ func (t *SimulcastTrack) AddRemoteTrack(track IRemoteTrack, minWait, maxWait tim
return remoteTrack
}

func (t *SimulcastTrack) getRemoteTrack(q QualityLevel) *remoteTrack {
func (t *SimulcastTrack) GetRemoteTrack(q QualityLevel) *remoteTrack {
t.mu.Lock()
defer t.mu.Unlock()

Expand Down Expand Up @@ -784,19 +784,19 @@ func (t *SimulcastTrack) sendPLI() {
defer t.mu.RUnlock()

if t.remoteTrackHigh != nil {
t.remoteTrackHigh.sendPLI()
t.remoteTrackHigh.SendPLI()
} else {
t.base.client.log.Warnf("track: remote track high is nil")
}

if t.remoteTrackMid != nil {
t.remoteTrackMid.sendPLI()
t.remoteTrackMid.SendPLI()
} else {
t.base.client.log.Warnf("track: remote track mid is nil")
}

if t.remoteTrackLow != nil {
t.remoteTrackLow.sendPLI()
t.remoteTrackLow.SendPLI()
} else {
t.base.client.log.Warnf("track: remote track low is nil")
}
Expand Down

0 comments on commit a3ca7e2

Please sign in to comment.