icetransport_js.go 877 B

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