@@ -32,7 +32,7 @@ func mustReadStdin(reader *bufio.Reader) string {
32
32
return rawSd
33
33
}
34
34
35
- func mustReadHttp (sdp chan string ) string {
35
+ func mustReadHTTP (sdp chan string ) string {
36
36
ret := <- sdp
37
37
return ret
38
38
}
@@ -58,7 +58,7 @@ func main() {
58
58
}()
59
59
60
60
offer := webrtc.RTCSessionDescription {}
61
- util .Decode (mustReadHttp (sdp ), & offer )
61
+ util .Decode (mustReadHTTP (sdp ), & offer )
62
62
fmt .Println ("" )
63
63
64
64
/* Everything below is the pion-WebRTC API, thanks for using it! */
@@ -67,7 +67,7 @@ func main() {
67
67
webrtc .RegisterCodec (webrtc .NewRTCRtpVP8Codec (webrtc .DefaultPayloadTypeVP8 , 90000 ))
68
68
69
69
// Create a new RTCPeerConnection
70
- peerConnection , err := webrtc .New (peerConnectionConfig )
70
+ peerConnection , err := webrtc .NewRTCPeerConnection (peerConnectionConfig )
71
71
util .Check (err )
72
72
73
73
inboundSSRC := make (chan uint32 )
@@ -111,10 +111,14 @@ func main() {
111
111
// Set the remote SessionDescription
112
112
util .Check (peerConnection .SetRemoteDescription (offer ))
113
113
114
- // Sets the LocalDescription, and starts our UDP listeners
114
+ // Create answer
115
115
answer , err := peerConnection .CreateAnswer (nil )
116
116
util .Check (err )
117
117
118
+ // Sets the LocalDescription, and starts our UDP listeners
119
+ err = peerConnection .SetLocalDescription (answer )
120
+ util .Check (err )
121
+
118
122
// Get the LocalDescription and take it to base64 so we can paste in browser
119
123
fmt .Println (util .Encode (answer ))
120
124
@@ -125,10 +129,10 @@ func main() {
125
129
fmt .Println ("Curl an base64 SDP to start sendonly peer connection" )
126
130
127
131
recvOnlyOffer := webrtc.RTCSessionDescription {}
128
- util .Decode (mustReadHttp (sdp ), & recvOnlyOffer )
132
+ util .Decode (mustReadHTTP (sdp ), & recvOnlyOffer )
129
133
130
134
// Create a new RTCPeerConnection
131
- peerConnection , err := webrtc .New (peerConnectionConfig )
135
+ peerConnection , err := webrtc .NewRTCPeerConnection (peerConnectionConfig )
132
136
util .Check (err )
133
137
134
138
// Create a single VP8 Track to send videa
@@ -146,10 +150,14 @@ func main() {
146
150
err = peerConnection .SetRemoteDescription (recvOnlyOffer )
147
151
util .Check (err )
148
152
149
- // Sets the LocalDescription, and starts our UDP listeners
153
+ // Create answer
150
154
answer , err := peerConnection .CreateAnswer (nil )
151
155
util .Check (err )
152
156
157
+ // Sets the LocalDescription, and starts our UDP listeners
158
+ err = peerConnection .SetLocalDescription (answer )
159
+ util .Check (err )
160
+
153
161
// Get the LocalDescription and take it to base64 so we can paste in browser
154
162
fmt .Println (util .Encode (answer ))
155
163
}
0 commit comments