mirror of
				https://github.com/pion/webrtc.git
				synced 2025-11-01 03:04:06 +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:
		| @@ -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 | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
| @@ -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 | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Sean DuBois
					Sean DuBois