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

@@ -38,7 +38,6 @@ func startWebrtc(pipeline *gst.Pipeline) {
// Set a handler for when a new remote track starts, this handler starts a gstreamer pipeline
// with the first track and assumes it is VP8 video data.
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)
if track == 1 && mediaType == webrtc.VP8 {
@@ -47,7 +46,6 @@ func startWebrtc(pipeline *gst.Pipeline) {
pipeline.Push(p.Raw)
}
}
}()
}
// Set the remote SessionDescription

View File

@@ -37,7 +37,6 @@ 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)
@@ -48,7 +47,6 @@ func main() {
for {
i.addPacket(<-packets)
}
}()
}
// Set the remote SessionDescription

View File

@@ -92,6 +92,6 @@ func (r *RTCPeerConnection) generateChannel(ssrc uint32) (buffers chan<- *rtp.Pa
}
bufferTransport := make(chan *rtp.Packet, 15)
r.Ontrack(VP8, bufferTransport) // TODO look up media via SSRC in remote SD
go r.Ontrack(VP8, bufferTransport) // TODO look up media via SSRC in remote SD
return bufferTransport
}