Refactor media track subscriptions

- To enable re-use of common bits
- Add max quality from other nodes
This commit is contained in:
boks1971
2022-01-04 16:40:47 +05:30
parent 995c1e8676
commit 9ca85454ed
10 changed files with 959 additions and 498 deletions
+6 -4
View File
@@ -94,7 +94,7 @@ type DownTrack struct {
receiver TrackReceiver
transceiver *webrtc.RTPTransceiver
writeStream webrtc.TrackLocalWriter
onCloseHandler func()
onCloseHandlers []func()
onBind func()
receiverReportListeners []ReceiverReportListener
listenerLock sync.RWMutex
@@ -438,8 +438,8 @@ func (d *DownTrack) Close() {
d.closeOnce.Do(func() {
Logger.V(1).Info("Closing sender", "peer_id", d.peerID, "kind", d.kind)
if d.onCloseHandler != nil {
d.onCloseHandler()
for _, f := range d.onCloseHandlers {
f()
}
close(d.done)
})
@@ -485,7 +485,9 @@ func (d *DownTrack) UptrackLayersChange(availableLayers []uint16) {
// OnCloseHandler method to be called on remote tracked removed
func (d *DownTrack) OnCloseHandler(fn func()) {
d.onCloseHandler = fn
if fn != nil {
d.onCloseHandlers = append(d.onCloseHandlers, fn)
}
}
func (d *DownTrack) OnBind(fn func()) {