Call RTCPeerConnection.Ontrack with a new goroutine

Every implementation should do this anyway. Also
new users might not understand and block all events for
RTCPeerConnections
This commit is contained in:
Sean DuBois
2018-06-13 00:02:00 -07:00
parent c7ca757fa8
commit d46382e382
3 changed files with 17 additions and 21 deletions

View File

@@ -37,18 +37,16 @@ func main() {
// an ivf file, since we could have multiple video tracks we provide a counter.
// In your application this is where you would handle/process video
peerConnection.Ontrack = func(mediaType webrtc.TrackType, packets <-chan *rtp.Packet) {
go func() {
track := atomic.AddUint64(&trackCount, 1)
fmt.Printf("Track %d has started \n", track)
track := atomic.AddUint64(&trackCount, 1)
fmt.Printf("Track %d has started \n", track)
i, err := newIVFWriter(fmt.Sprintf("output-%d.ivf", track))
if err != nil {
panic(err)
}
for {
i.addPacket(<-packets)
}
}()
i, err := newIVFWriter(fmt.Sprintf("output-%d.ivf", track))
if err != nil {
panic(err)
}
for {
i.addPacket(<-packets)
}
}
// Set the remote SessionDescription