icetransport_js.go 775 B

123456789101112131415161718192021222324252627
  1. //go:build js && wasm
  2. // +build js,wasm
  3. package webrtc
  4. import "syscall/js"
  5. // ICETransport allows an application access to information about the ICE
  6. // transport over which packets are sent and received.
  7. type ICETransport struct {
  8. // Pointer to the underlying JavaScript ICETransport object.
  9. underlying js.Value
  10. }
  11. // GetSelectedCandidatePair returns the selected candidate pair on which packets are sent
  12. // if there is no selected pair nil is returned
  13. func (t *ICETransport) GetSelectedCandidatePair() (*ICECandidatePair, error) {
  14. val := t.underlying.Call("getSelectedCandidatePair")
  15. if val.IsNull() || val.IsUndefined() {
  16. return nil, nil
  17. }
  18. return NewICECandidatePair(
  19. valueToICECandidate(val.Get("local")),
  20. valueToICECandidate(val.Get("remote")),
  21. ), nil
  22. }