File: icetransport_js.go

package info (click to toggle)
golang-github-pion-webrtc.v3 3.1.56-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,392 kB
  • sloc: javascript: 595; sh: 28; makefile: 5
file content (27 lines) | stat: -rw-r--r-- 775 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
//go:build js && wasm
// +build js,wasm

package webrtc

import "syscall/js"

// ICETransport allows an application access to information about the ICE
// transport over which packets are sent and received.
type ICETransport struct {
	// Pointer to the underlying JavaScript ICETransport object.
	underlying js.Value
}

// GetSelectedCandidatePair returns the selected candidate pair on which packets are sent
// if there is no selected pair nil is returned
func (t *ICETransport) GetSelectedCandidatePair() (*ICECandidatePair, error) {
	val := t.underlying.Call("getSelectedCandidatePair")
	if val.IsNull() || val.IsUndefined() {
		return nil, nil
	}

	return NewICECandidatePair(
		valueToICECandidate(val.Get("local")),
		valueToICECandidate(val.Get("remote")),
	), nil
}