webrtcpeer

package
v0.0.0-...-f57fae0 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2024 License: MIT Imports: 17 Imported by: 0

README

This project uses hraban/opus. In order to build and run the project you need to have pkg-config libopus-dev and libopusfile-dev installed.

macOS

brew install pkg-config opus opusfile

Debian

sudo apt-get install pkg-config libopus-dev libopusfile-dev

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Logger = logr.New()

Functions

func New

func New(u url.URL, room string) router.MiddlewareFunc

Types

type AudioEngine

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

AudioEngine is used to convert RTP Opus packets to raw PCM audio to be sent to Whisper and to convert raw PCM audio from Coqui back to RTP Opus packets to be sent back over WebRTC

func NewAudioEngine

func NewAudioEngine(capture chan<- *router.CapturedSample) (*AudioEngine, error)

func (*AudioEngine) Encode

func (a *AudioEngine) Encode(pcm []float32, inputChannelCount, inputSampleRate int) error

Encode takes in raw f32le pcm, encodes it into opus RTP packets and sends those over the rtpOut chan

func (*AudioEngine) MediaOut

func (a *AudioEngine) MediaOut() <-chan media.Sample

func (*AudioEngine) RtpIn

func (a *AudioEngine) RtpIn() chan<- *rtp.Packet

func (*AudioEngine) Start

func (a *AudioEngine) Start()

type Config

type Config struct {
	// ION room name to connect to
	Room string
	// URL for websocket server
	Url url.URL

	CapturedSample chan<- *router.CapturedSample

	StatusStream   <-chan *router.Status
	DocumentStream <-chan router.Document
}

type Join

type Join struct {
	SID    string                    `json:"sid"`
	UID    string                    `json:"uid"`
	Offer  webrtc.SessionDescription `json:"offer,omitempty"`
	Config JoinConfig                `json:"config,omitempty"`
}

TODO move these to core Join message sent when initializing a peer connection

type JoinConfig

type JoinConfig struct {
	// If true the peer will not be allowed to publish tracks to SessionLocal.
	NoPublish bool
	// If true the peer will not be allowed to subscribe to other peers in SessionLocal.
	NoSubscribe bool
	// If true the peer will not automatically subscribe all tracks,
	// and then the peer can use peer.Subscriber().AddDownTrack/RemoveDownTrack
	// to customize the subscrbe stream combination as needed.
	// this parameter depends on NoSubscribe=false.
	NoAutoSubscribe bool
}

JoinConfig allow adding more control to the peers joining a SessionLocal.

type Message

type Message[T Join | Negotiation | Trickle] struct {
	Method string `json:"method"`
	Params T      `json:"params"`
}

type Negotiation

type Negotiation struct {
	Desc webrtc.SessionDescription `json:"desc"`
}

Negotiation message sent when renegotiating the peer connection

type Peer

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

func NewPeer

func NewPeer(config Config) (*Peer, error)

func (*Peer) OnAnswer

func (s *Peer) OnAnswer(answer webrtc.SessionDescription) error

func (*Peer) OnOffer

func (s *Peer) OnOffer(offer webrtc.SessionDescription) error

func (*Peer) Start

func (s *Peer) Start() error

type PeerConn

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

func NewPeerConn

func NewPeerConn(onICECandidate func(candidate *webrtc.ICECandidate)) PeerConn

func (PeerConn) AddIceCandidate

func (c PeerConn) AddIceCandidate(candidate webrtc.ICECandidateInit) error

func (PeerConn) Answer

func (c PeerConn) Answer() (webrtc.SessionDescription, error)

func (PeerConn) GetOffer

func (c PeerConn) GetOffer() (webrtc.SessionDescription, error)

func (PeerConn) Offer

func (c PeerConn) Offer(offer webrtc.SessionDescription) error

func (PeerConn) SetAnswer

func (c PeerConn) SetAnswer(answer webrtc.SessionDescription) error

type RTCConnection

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

func NewRTCConnection

func NewRTCConnection(params RTCConnectionParams) (*RTCConnection, error)

FIXME if documentStream AND mediaIn are not provided this will blow up

func (*RTCConnection) GetOffer

func (r *RTCConnection) GetOffer() (webrtc.SessionDescription, error)

func (*RTCConnection) OnOffer

func (r *RTCConnection) OnOffer(offer webrtc.SessionDescription) (webrtc.SessionDescription, error)

func (*RTCConnection) OnTrickle

func (r *RTCConnection) OnTrickle(candidate webrtc.ICECandidateInit, target int) error

func (*RTCConnection) SetAnswer

func (r *RTCConnection) SetAnswer(answer webrtc.SessionDescription) error

type RTCConnectionParams

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

type SocketConnection

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

func NewSocketConnection

func NewSocketConnection(url url.URL) *SocketConnection

func (*SocketConnection) Connect

func (s *SocketConnection) Connect() error

func (*SocketConnection) Join

func (s *SocketConnection) Join(room string, offer webrtc.SessionDescription) error

func (*SocketConnection) SendAnswer

func (s *SocketConnection) SendAnswer(answer webrtc.SessionDescription) error

func (*SocketConnection) SendTrickle

func (s *SocketConnection) SendTrickle(candidate *webrtc.ICECandidate, target int) error

func (*SocketConnection) SetOnAnswer

func (s *SocketConnection) SetOnAnswer(onAnswer func(ans webrtc.SessionDescription) error)

func (*SocketConnection) SetOnOffer

func (s *SocketConnection) SetOnOffer(onOffer func(offer webrtc.SessionDescription) error)

func (*SocketConnection) SetOnTrickle

func (s *SocketConnection) SetOnTrickle(onTrickle func(candidate webrtc.ICECandidateInit, target int) error)

func (*SocketConnection) WaitForDone

func (s *SocketConnection) WaitForDone()

type Trickle

type Trickle struct {
	Target    int                     `json:"target"`
	Candidate webrtc.ICECandidateInit `json:"candidate"`
}

Trickle message sent when renegotiating the peer connection

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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