| 76 | } |
| 77 | |
| 78 | func createOffer(peerConnection *webrtc.PeerConnection) (string, error) { |
| 79 | offer, err := peerConnection.CreateOffer(nil) |
| 80 | if err != nil { |
| 81 | log.Println("Error creating peer connection offer: ", err) |
| 82 | return "", err |
| 83 | } |
| 84 | |
| 85 | if err = peerConnection.SetLocalDescription(offer); err != nil { |
| 86 | log.Println("Error setting local description of peer connection: ", err) |
| 87 | return "", err |
| 88 | } |
| 89 | |
| 90 | offerStringBytes, err := json.Marshal(offer) |
| 91 | if err != nil { |
| 92 | log.Println("Error unmarshalling json from offer object: ", err) |
| 93 | return "", err |
| 94 | } |
| 95 | offerString := string(offerStringBytes) |
| 96 | return offerString, err |
| 97 | } |
| 98 | |
| 99 | func createPeerConnection() (*webrtc.PeerConnection, error) { |
| 100 | // Create a MediaEngine object to configure the supported codec |