Add Simulcast support

Resolves #1016
This commit is contained in:
Jason
2020-07-23 02:25:15 -07:00
committed by Sean DuBois
parent 570ddd0b1c
commit 6ee528d349
10 changed files with 408 additions and 138 deletions

View File

@@ -3,7 +3,6 @@ package main
import (
"fmt"
"io"
"log"
"math/rand"
"net/url"
"time"
@@ -103,17 +102,13 @@ func main() {
panic(err)
}
// fmt.Printf("offer: %s\n", offer.SDP)
// Set the remote SessionDescription
err = peerConnection.SetRemoteDescription(offer)
if err != nil {
if err = peerConnection.SetRemoteDescription(offer); err != nil {
panic(err)
}
// Set a handler for when a new remote track starts
peerConnection.OnTrack(func(track *webrtc.Track, receiver *webrtc.RTPReceiver) {
fmt.Printf("Track has started\n")
log.Println("Track has started", track)
fmt.Println("Track has started")
// Start reading from all the streams and sending them to the related output track
rid := track.RID()
@@ -132,10 +127,9 @@ func main() {
}
}()
for {
var readErr error
// Read RTP packets being sent to Pion
packet, readErr := track.ReadRTP()
if err != nil {
if readErr != nil {
panic(readErr)
}
@@ -157,8 +151,6 @@ func main() {
panic(err)
}
fmt.Printf("answer: %s\n", answer.SDP)
// Sets the LocalDescription, and starts our UDP listeners
err = peerConnection.SetLocalDescription(answer)
if err != nil {