io.go 621 B

1234567891011121314151617181920212223242526272829
  1. package webrtc
  2. import (
  3. . "github.com/pion/webrtc/v4"
  4. )
  5. type WebRTCIO struct {
  6. *PeerConnection
  7. SDP string
  8. // LocalSDP *sdp.SessionDescription
  9. }
  10. func (IO *WebRTCIO) GetAnswer() (string, error) {
  11. // Sets the LocalDescription, and starts our UDP listeners
  12. answer, err := IO.CreateAnswer(nil)
  13. if err != nil {
  14. return "", err
  15. }
  16. // IO.LocalSDP, err = answer.Unmarshal()
  17. // if err != nil {
  18. // return "", err
  19. // }
  20. gatherComplete := GatheringCompletePromise(IO.PeerConnection)
  21. if err := IO.SetLocalDescription(answer); err != nil {
  22. return "", err
  23. }
  24. <-gatherComplete
  25. return IO.LocalDescription().SDP, nil
  26. }