rtc

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RTC

type RTC struct {
	Id             string                    // the id of the connection (e.g. the client id)
	Pc             *webrtc.PeerConnection    // the actual webRTC connection
	Candidates     []webrtc.ICECandidateInit // the **local** ICE candidates (that can be transmitted to the other peers)
	CandidatesLock *sync.Mutex               // to make sure ICE candidates can be managed concurrently
	// Data channels
	MetaChannel    *webrtc.DataChannel // the data channel used to send meta information about requests made (such as requesting a video stream)
	ControlChannel *webrtc.DataChannel // the data channel used to send controller data (e.g. steering wheel angle)
	FrameChannel   *webrtc.DataChannel // the data channel used to send frames with video data and other meta information (such as sensoric data)
}

func NewRTC

func NewRTC(id string) *RTC

func (*RTC) AddLocalCandidate

func (r *RTC) AddLocalCandidate(candidate webrtc.ICECandidateInit)

Add a local ICE candidate to the list of candidates fetched so far

func (*RTC) Destroy

func (r *RTC) Destroy()

Destroy an RTC object and the underlying webRTC connection

func (*RTC) GetAllLocalCandidates

func (r *RTC) GetAllLocalCandidates() []webrtc.ICECandidateInit

Get a copy of all local ICE candidates (concurrency-safe)

func (*RTC) IsConnected

func (r *RTC) IsConnected() bool

Utility function to check if the connection is still active

func (*RTC) Log

func (r *RTC) Log() zerolog.Logger

Create an easy function to get a logger with the context and connection id already set

func (*RTC) SendControlBytes

func (r *RTC) SendControlBytes(data []byte) error

func (*RTC) SendFrameBytes

func (r *RTC) SendFrameBytes(data []byte) error

func (*RTC) SendMetaMessage

func (r *RTC) SendMetaMessage(protobuffer proto.Message) error

type RTCMap

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

func NewRTCMap

func NewRTCMap() *RTCMap

func (*RTCMap) Add

func (m *RTCMap) Add(id string, rtc *RTC, isCar bool) error

func (*RTCMap) ForEach

func (m *RTCMap) ForEach(f func(id string, rtc *RTC))

Executes a function for each RTC connection in the map Because the RTCMap is read locked during execution, this is concurrency-safe

func (*RTCMap) Get

func (m *RTCMap) Get(id string) *RTC

Returns a pointer to the RTC connection with the given id (concurrency-safe)

func (*RTCMap) GetAllIds

func (m *RTCMap) GetAllIds() []string

Returns a copy of all Ids in the map (concurrency-safe)

func (*RTCMap) Remove

func (m *RTCMap) Remove(id string) error

Remove an RTC connection from the map

func (*RTCMap) UnsafeGetAll

func (m *RTCMap) UnsafeGetAll() []*RTC

Returns a list of all RTC connections in the map. Locks when reading the map but returns a list of pointers. If you want to execute a function for each RTC connection, use ForEach instead.

type RequestICE

type RequestICE struct {
	Candidate webrtc.ICECandidateInit `json:"candidate"`
	Id        string                  `json:"id"` // to distinguish between clients
}

The data format used by connecting clients (and the car) to send ICE candidates to the server

type RequestSDP

type RequestSDP struct {
	Offer webrtc.SessionDescription `json:"offer"`
	Id    string                    `json:"id"` // to distinguish between clients
}

The data format used for SDP requests

Jump to

Keyboard shortcuts

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