mirror of
https://github.com/pion/webrtc.git
synced 2025-10-31 02:36:46 +08:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user