Pion has received an ice candidate from the remote Unreal Engine Pixel Streaming (through Cirrus). We parse this message and add that ice candidate to our peer connection. Flow based on: https://github.com/pion/webrtc/blob/687d915e05a69441beae1bba0802e28756eecbbc/examples/pion-to-pion/offer/main.go#
(message []byte, peerConnection *webrtc.PeerConnection)
| 166 | // We parse this message and add that ice candidate to our peer connection. |
| 167 | // Flow based on: https://github.com/pion/webrtc/blob/687d915e05a69441beae1bba0802e28756eecbbc/examples/pion-to-pion/offer/main.go#L82 |
| 168 | func handleRemoteIceCandidate(message []byte, peerConnection *webrtc.PeerConnection) { |
| 169 | var iceCandidateInit webrtc.ICECandidateInit |
| 170 | jsonErr := json.Unmarshal(message, &iceCandidateInit) |
| 171 | if jsonErr != nil { |
| 172 | log.Printf("Error unmarshaling ice candidate. Error: %s", jsonErr.Error()) |
| 173 | return |
| 174 | } |
| 175 | |
| 176 | // The actual adding of the remote ice candidate happens here. |
| 177 | if candidateErr := peerConnection.AddICECandidate(iceCandidateInit); candidateErr != nil { |
| 178 | log.Printf("Error adding remote ice candidate. Error: %s", candidateErr.Error()) |
| 179 | return |
| 180 | } |
| 181 | |
| 182 | fmt.Println(fmt.Sprintf("Added remote ice candidate from UE - %s", iceCandidateInit.Candidate)) |
| 183 | } |
| 184 | |
| 185 | // Starts an infinite loop where we poll for new websocket messages and react to them. |
| 186 | func startControlLoop(wsConn *websocket.Conn, peerConnection *webrtc.PeerConnection, pendingCandidates *[]*webrtc.ICECandidate) { |