webrtcclient

package
v0.0.0-...-99ba695 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 13, 2025 License: Apache-2.0, MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RequestOfferMsgType string = "request-offer"
	ICECandidateMsgType string = "ice-candidate"
	OfferMsgType        string = "offer"
	AnswerMsgType       string = "answer"
)

Variables

This section is empty.

Functions

func Reshape

func Reshape[K any](original any) (*K, error)

Allows converting a generic JSON object representation, like map[string]any, to a specific class such as ICECandidateMsg.

Types

type Connection

type Connection struct {
	// contains filtered or unexported fields
}

func NewConnection

func NewConnection(signaling *Signaling, observer Observer) (*Connection, error)

Connects to a device. Blocks until the connection is established successfully or fails. If the returned error is not nil the Connection should be ignored.

func NewConnectionWithLogger

func NewConnectionWithLogger(signaling *Signaling, observer Observer, logger io.Writer) (*Connection, error)

func (*Connection) Close

func (dc *Connection) Close()

type Controller

type Controller struct {
	// contains filtered or unexported fields
}

type ICECandidateMsg

type ICECandidateMsg struct {
	Type      string                  `json:"type"`
	Candidate webrtc.ICECandidateInit `json:"candidate"`
}

func NewICECandidateMsg

func NewICECandidateMsg(candidate webrtc.ICECandidateInit) *ICECandidateMsg

type ICEConfig

type ICEConfig struct {
	ICEServers []webrtc.ICEServer `json:"ice_servers,omitempty"`
}

type Observer

type Observer interface {
	// Called when adb data channel is added to the peer connection
	OnADBDataChannel(*webrtc.DataChannel)
	// Called on signaling error
	OnError(error)
	// Called on peer connection failure
	OnFailure()
	// Called when the peer connection closes
	OnClose()
}

type RequestOfferMsg

type RequestOfferMsg struct {
	Type       string             `json:"type"`
	ICEServers []webrtc.ICEServer `json:"ice_servers,omitempty"`
}

func NewRequestOfferMsg

func NewRequestOfferMsg(servers []webrtc.ICEServer) *RequestOfferMsg

type Signaling

type Signaling struct {
	SendCh chan any
	RecvCh chan map[string]any
	// The ICE servers to use in the webRTC connection.
	ICEServers []webrtc.ICEServer
	// The servers that were created client side and need to be sent to the device.
	// This is typically a subset of Servers. Ignored if empty.
	ClientICEServers []webrtc.ICEServer
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL