MCPcopy Index your code
hub / github.com/TensorWorks/Unreal-PixelStreaming-RTP-Bridge / handleRemoteAnswer

Function handleRemoteAnswer

main.go:143–163  ·  view source on GitHub ↗

Pion has recieved an "answer" from the remote Unreal Engine Pixel Streaming (through Cirrus) Pion will now set its remote session description that it got from the answer. Once Pion has its own local session description and the remote session description set then it should begin signalling the ice ca

(message []byte, peerConnection *webrtc.PeerConnection, wsConn *websocket.Conn, pendingCandidates *[]*webrtc.ICECandidate)

Source from the content-addressed store, hash-verified

141// This flow is based on:
142// https://github.com/pion/webrtc/blob/687d915e05a69441beae1bba0802e28756eecbbc/examples/pion-to-pion/offer/main.go#L90
143func handleRemoteAnswer(message []byte, peerConnection *webrtc.PeerConnection, wsConn *websocket.Conn, pendingCandidates *[]*webrtc.ICECandidate) {
144 sdp := webrtc.SessionDescription{}
145 unmarshalError := json.Unmarshal([]byte(message), &sdp)
146
147 if unmarshalError != nil {
148 log.Printf("Error occured during unmarshaling sdp. Error: %s", unmarshalError.Error())
149 return
150 }
151
152 // Set remote session description we got from UE pixel streaming
153 if sdpErr := peerConnection.SetRemoteDescription(sdp); sdpErr != nil {
154 log.Printf("Error occured setting remote session description. Error: %s", sdpErr.Error())
155 return
156 }
157 fmt.Println("Added session description from UE to Pion.")
158
159 // User websocket to send our local ICE candidates to UE
160 for _, localIceCandidate := range *pendingCandidates {
161 sendLocalIceCandidate(wsConn, localIceCandidate)
162 }
163}
164
165// Pion has received an ice candidate from the remote Unreal Engine Pixel Streaming (through Cirrus).
166// We parse this message and add that ice candidate to our peer connection.

Callers 1

startControlLoopFunction · 0.85

Calls 1

sendLocalIceCandidateFunction · 0.85

Tested by

no test coverage detected