func (s *Session) CreateOffer() error {
	offer, err := s.peerConnection.CreateOffer(nil)
	if err != nil {
		return err
	}
	if err := s.createSessionDescription(offer, SDP_OFFER_PROMPT); err != nil {
		return err
	}
	return nil
}
CreateOffer set the local description and print the offer SDP
package streamer
import (
	"bufio"
	"fmt"
	"io"
	"strings"
	"sync"
	webrtc "github.com/pion/webrtc/v3"
	log "github.com/sirupsen/logrus"
)
const (
	SDP_OFFER_PROMPT          = "Send this offer:"
	SDP_OFFER_WAITING_PROMPT  = "Please, paste the remote offer:"
	SDP_ANSWER_PROMPT         = "Send this answer:"
	SDP_ANSWER_WAITING_PROMPT = "Please, paste the remote answer:"
)
var (
	ICEServerList = []webrtc.ICEServer{
		{
			URLs: []string{
				"stun:stun.l.google.com:19302",
			},
		},
	}
)
type CompletionHandler func()
type Session struct {
	sdpReader      io.Reader
	sdpWriter      io.Writer
	peerConnection *webrtc.PeerConnection
	onCompletion   CompletionHandler
	encoding       FrameEncoding
}
func NewSession(SDPReader io.Reader, SDPWriter io.Writer) Session {
	sess := Session{
		sdpReader: SDPReader,
		sdpWriter: SDPWriter,
		encoding:  FrameEncodingProto,
	}
	return sess
}
func (s *Session) Close() error {
	if s.peerConnection != nil {
		return s.peerConnection.Close()
	}
	return nil
}
func (s *Session) SetEncoding(enc FrameEncoding) {
	s.encoding = enc
}
func (s *Session) CreateConnection(onConnectionStateChange func(connectionState webrtc.ICEConnectionState)) error {
	config := webrtc.Configuration{
		ICEServers:         ICEServerList,
		ICETransportPolicy: webrtc.ICETransportPolicyAll,
		BundlePolicy:       webrtc.BundlePolicyBalanced,
	}
	peerConnection, err := webrtc.NewPeerConnection(config)
	if err != nil {
		return err
	}
	s.peerConnection = peerConnection
	peerConnection.OnICEConnectionStateChange(onConnectionStateChange)
	return nil
}
func (s *Session) ReadSDP() error {
	var sdp webrtc.SessionDescription
	for {
		encoded, err := MustReadStream(s.sdpReader)
		if err == nil {
			if err := Decode(encoded, &sdp); err == nil {
				break
			}
		}
		return err
	}
	return s.peerConnection.SetRemoteDescription(sdp)
}
func (s *Session) OnDataChannel(handler func(d *webrtc.DataChannel)) {
	s.peerConnection.OnDataChannel(handler)
}
func (s *Session) CreateAnswer() error {
	answer, err := s.peerConnection.CreateAnswer(nil)
	if err != nil {
		return err
	}
	if err := s.createSessionDescription(answer, SDP_ANSWER_PROMPT); err != nil {
		return err
	}
	return nil
}