Skip to content

Commit

Permalink
Move to pion/ice@v2
Browse files Browse the repository at this point in the history
Removed support for trickle ice

Resolves #1274
  • Loading branch information
Sean-Der committed Jun 28, 2020
1 parent 89d7de1 commit bb3aa97
Show file tree
Hide file tree
Showing 53 changed files with 695 additions and 839 deletions.
12 changes: 9 additions & 3 deletions datachannel_ortc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,18 @@ func (s *testORTCStack) setSignal(sig *testORTCSignal, isOffer bool) error {
}

func (s *testORTCStack) getSignal() (*testORTCSignal, error) {
// Gather candidates
err := s.gatherer.Gather()
if err != nil {
gatherFinished := make(chan struct{})
s.gatherer.OnLocalCandidate(func(i *ICECandidate) {
if i == nil {
close(gatherFinished)
}
})

if err := s.gatherer.Gather(); err != nil {
return nil, err
}

<-gatherFinished
iceCandidates, err := s.gatherer.GetLocalCandidates()
if err != nil {
return nil, err
Expand Down
20 changes: 18 additions & 2 deletions examples/broadcast/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,22 @@ func main() {
panic(err)
}

// Create channel that is blocked until ICE Gathering is complete
gatherComplete := webrtc.GatheringCompletePromise(peerConnection)

// Sets the LocalDescription, and starts our UDP listeners
err = peerConnection.SetLocalDescription(answer)
if err != nil {
panic(err)
}

// Block until ICE Gathering is complete, disabling trickle ICE
// we do this because we only can exchange one signaling message
// in a production application you should exchange ICE Candidates via OnICECandidate
<-gatherComplete

// Get the LocalDescription and take it to base64 so we can paste in browser
fmt.Println(signal.Encode(answer))
fmt.Println(signal.Encode(*peerConnection.LocalDescription()))

localTrack := <-localTrackChan
for {
Expand Down Expand Up @@ -140,13 +148,21 @@ func main() {
panic(err)
}

// Create channel that is blocked until ICE Gathering is complete
gatherComplete = webrtc.GatheringCompletePromise(peerConnection)

// Sets the LocalDescription, and starts our UDP listeners
err = peerConnection.SetLocalDescription(answer)
if err != nil {
panic(err)
}

// Block until ICE Gathering is complete, disabling trickle ICE
// we do this because we only can exchange one signaling message
// in a production application you should exchange ICE Candidates via OnICECandidate
<-gatherComplete

// Get the LocalDescription and take it to base64 so we can paste in browser
fmt.Println(signal.Encode(answer))
fmt.Println(signal.Encode(*peerConnection.LocalDescription()))
}
}
25 changes: 25 additions & 0 deletions examples/custom-logger/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,26 @@ func main() {
panic(err)
}

// Set ICE Candidate handler. As soon as a PeerConnection has gathered a candidate
// send it to the other peer
answerPeerConnection.OnICECandidate(func(i *webrtc.ICECandidate) {
if i != nil {
if iceErr := offerPeerConnection.AddICECandidate(i.ToJSON()); iceErr != nil {
panic(iceErr)
}
}
})

// Set ICE Candidate handler. As soon as a PeerConnection has gathered a candidate
// send it to the other peer
offerPeerConnection.OnICECandidate(func(i *webrtc.ICECandidate) {
if i != nil {
if iceErr := answerPeerConnection.AddICECandidate(i.ToJSON()); iceErr != nil {
panic(iceErr)
}
}
})

// Create an offer for the other PeerConnection
offer, err := offerPeerConnection.CreateOffer(nil)
if err != nil {
Expand All @@ -90,6 +110,11 @@ func main() {
panic(err)
}

// Set the answerer's LocalDescription
if err = answerPeerConnection.SetLocalDescription(answer); err != nil {
panic(err)
}

// SetRemoteDescription on original PeerConnection, this finishes our signaling
// bother PeerConnections should be able to communicate with each other now
if err = offerPeerConnection.SetRemoteDescription(answer); err != nil {
Expand Down
10 changes: 9 additions & 1 deletion examples/data-channels-close/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,22 @@ func main() {
panic(err)
}

// Create channel that is blocked until ICE Gathering is complete
gatherComplete := webrtc.GatheringCompletePromise(peerConnection)

// Sets the LocalDescription, and starts our UDP listeners
err = peerConnection.SetLocalDescription(answer)
if err != nil {
panic(err)
}

// Block until ICE Gathering is complete, disabling trickle ICE
// we do this because we only can exchange one signaling message
// in a production application you should exchange ICE Candidates via OnICECandidate
<-gatherComplete

// Output the answer in base64 so we can paste it in browser
fmt.Println(signal.Encode(answer))
fmt.Println(signal.Encode(*peerConnection.LocalDescription()))

// Block forever
select {}
Expand Down
4 changes: 2 additions & 2 deletions examples/data-channels-create/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ Hit the 'Start Session' button in the browser. You should see `have-remote-offer
Meanwhile text has appeared in the second text area of the jsfiddle. Copy the text and paste it into `data-channels-create` and hit ENTER.
In the browser you'll now see `connected` as the connection is created. If everything worked you should see `New DataChannel data`.

Now you can put whatever you want in the `Message` textarea, and when you hit `Send Message` it should appear in your browser!
Now you can put whatever you want in the `Message` textarea, and when you hit `Send Message` it should appear in your terminal!

You can also type in your terminal, and when you hit enter it will appear in your web browser.
Pion WebRTC will send random messages every 5 seconds that will appear in your browser.

Congrats, you have used Pion WebRTC! Now start building something cool
12 changes: 10 additions & 2 deletions examples/data-channels-create/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,22 @@ func main() {
panic(err)
}

// Create channel that is blocked until ICE Gathering is complete
gatherComplete := webrtc.GatheringCompletePromise(peerConnection)

// Sets the LocalDescription, and starts our UDP listeners
err = peerConnection.SetLocalDescription(offer)
if err != nil {
panic(err)
}

// Output the offer in base64 so we can paste it in browser
fmt.Println(signal.Encode(offer))
// Block until ICE Gathering is complete, disabling trickle ICE
// we do this because we only can exchange one signaling message
// in a production application you should exchange ICE Candidates via OnICECandidate
<-gatherComplete

// Output the answer in base64 so we can paste it in browser
fmt.Println(signal.Encode(*peerConnection.LocalDescription()))

// Wait for the answer to be pasted
answer := webrtc.SessionDescription{}
Expand Down
10 changes: 9 additions & 1 deletion examples/data-channels-detach-create/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,22 @@ func main() {
panic(err)
}

// Create channel that is blocked until ICE Gathering is complete
gatherComplete := webrtc.GatheringCompletePromise(peerConnection)

// Sets the LocalDescription, and starts our UDP listeners
err = peerConnection.SetLocalDescription(offer)
if err != nil {
panic(err)
}

// Block until ICE Gathering is complete, disabling trickle ICE
// we do this because we only can exchange one signaling message
// in a production application you should exchange ICE Candidates via OnICECandidate
<-gatherComplete

// Output the offer in base64 so we can paste it in browser
fmt.Println(signal.Encode(offer))
fmt.Println(signal.Encode(*peerConnection.LocalDescription()))

// Wait for the answer to be pasted
answer := webrtc.SessionDescription{}
Expand Down
10 changes: 9 additions & 1 deletion examples/data-channels-detach/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,22 @@ func main() {
panic(err)
}

// Create channel that is blocked until ICE Gathering is complete
gatherComplete := webrtc.GatheringCompletePromise(peerConnection)

// Sets the LocalDescription, and starts our UDP listeners
err = peerConnection.SetLocalDescription(answer)
if err != nil {
panic(err)
}

// Block until ICE Gathering is complete, disabling trickle ICE
// we do this because we only can exchange one signaling message
// in a production application you should exchange ICE Candidates via OnICECandidate
<-gatherComplete

// Output the answer in base64 so we can paste it in browser
fmt.Println(signal.Encode(answer))
fmt.Println(signal.Encode(*peerConnection.LocalDescription()))

// Block forever
select {}
Expand Down
16 changes: 16 additions & 0 deletions examples/data-channels-flow-control/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,22 @@ func main() {
offerPC := createOfferer()
answerPC := createAnswerer()

// Set ICE Candidate handler. As soon as a PeerConnection has gathered a candidate
// send it to the other peer
answerPC.OnICECandidate(func(i *webrtc.ICECandidate) {
if i != nil {
check(offerPC.AddICECandidate(i.ToJSON()))
}
})

// Set ICE Candidate handler. As soon as a PeerConnection has gathered a candidate
// send it to the other peer
offerPC.OnICECandidate(func(i *webrtc.ICECandidate) {
if i != nil {
check(answerPC.AddICECandidate(i.ToJSON()))
}
})

// Now, create an offer
offer, err := offerPC.CreateOffer(nil)
check(err)
Expand Down
4 changes: 2 additions & 2 deletions examples/data-channels/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ Copy the text that `data-channels` just emitted and copy into second text area
### Hit 'Start Session' in jsfiddle
Under Start Session you should see 'Checking' as it starts connecting. If everything worked you should see `New DataChannel foo 1`

Now you can put whatever you want in the `Message` textarea, and when you hit `Send Message` it should appear in your browser!
Now you can put whatever you want in the `Message` textarea, and when you hit `Send Message` it should appear in your terminal!

You can also type in your terminal, and when you hit enter it will appear in your web browser.
Pion WebRTC will send random messages every 5 seconds that will appear in your browser.

Congrats, you have used Pion WebRTC! Now start building something cool
10 changes: 9 additions & 1 deletion examples/data-channels/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,22 @@ func main() {
panic(err)
}

// Create channel that is blocked until ICE Gathering is complete
gatherComplete := webrtc.GatheringCompletePromise(peerConnection)

// Sets the LocalDescription, and starts our UDP listeners
err = peerConnection.SetLocalDescription(answer)
if err != nil {
panic(err)
}

// Block until ICE Gathering is complete, disabling trickle ICE
// we do this because we only can exchange one signaling message
// in a production application you should exchange ICE Candidates via OnICECandidate
<-gatherComplete

// Output the answer in base64 so we can paste it in browser
fmt.Println(signal.Encode(answer))
fmt.Println(signal.Encode(*peerConnection.LocalDescription()))

// Block forever
select {}
Expand Down
10 changes: 9 additions & 1 deletion examples/insertable-streams/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,21 @@ func main() {
panic(err)
}

// Create channel that is blocked until ICE Gathering is complete
gatherComplete := webrtc.GatheringCompletePromise(peerConnection)

// Sets the LocalDescription, and starts our UDP listeners
if err = peerConnection.SetLocalDescription(answer); err != nil {
panic(err)
}

// Block until ICE Gathering is complete, disabling trickle ICE
// we do this because we only can exchange one signaling message
// in a production application you should exchange ICE Candidates via OnICECandidate
<-gatherComplete

// Output the answer in base64 so we can paste it in browser
fmt.Println(signal.Encode(answer))
fmt.Println(signal.Encode(*peerConnection.LocalDescription()))

// Block forever
select {}
Expand Down
9 changes: 9 additions & 0 deletions examples/ortc-quic/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,21 @@ func main() {
go WriteLoop(stream)
})

gatherFinished := make(chan struct{})
gatherer.OnLocalCandidate(func(i *webrtc.ICECandidate) {
if i == nil {
close(gatherFinished)
}
})

// Gather candidates
err = gatherer.Gather()
if err != nil {
panic(err)
}

<-gatherFinished

iceCandidates, err := gatherer.GetLocalCandidates()
if err != nil {
panic(err)
Expand Down
9 changes: 9 additions & 0 deletions examples/ortc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,21 @@ func main() {
})
})

gatherFinished := make(chan struct{})
gatherer.OnLocalCandidate(func(i *webrtc.ICECandidate) {
if i == nil {
close(gatherFinished)
}
})

// Gather candidates
err = gatherer.Gather()
if err != nil {
panic(err)
}

<-gatherFinished

iceCandidates, err := gatherer.GetLocalCandidates()
if err != nil {
panic(err)
Expand Down
23 changes: 0 additions & 23 deletions examples/pion-to-pion-trickle/README.md

This file was deleted.

Loading

0 comments on commit bb3aa97

Please sign in to comment.