コード例 #1
0
/*
CreateAnswer prepares an SDP "answer" message. This should only happen in
response to an offer received and set as the remote description. Once generated,
this answer should then be set as the local description and sent back over the
signaling channel to the remote peer.

This method is blocking, and should occur within a separate goroutine.
*/
func (pc *PeerConnection) CreateAnswer() (*SessionDescription, error) {
	sdp := C.CGO_CreateAnswer(pc.cgoPeer)
	if nil == sdp {
		return nil, errors.New("CreateAnswer failed: could not prepare SDP offer.")
	}
	answer := new(SessionDescription)
	answer.cgoSdp = sdp
	answer.Type = "answer"
	answer.Sdp = C.GoString(C.CGO_SerializeSDP(sdp))
	return answer, nil
}
コード例 #2
0
// readonly localDescription
func (pc *PeerConnection) LocalDescription() (sdp *SessionDescription) {
	// Refresh SDP; it might have changed by ICE candidate gathering.
	pc.localDescription.Sdp = C.GoString(C.CGO_SerializeSDP(
		pc.localDescription.cgoSdp))
	return pc.localDescription
}