rtp

package
v0.0.0-...-4c68550 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2024 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	VideoQuality_name = map[int32]string{
		0: "LOW",
		1: "MEDIUM",
		2: "HIGH",
		3: "OFF",
	}
	VideoQuality_value = map[string]int32{
		"LOW":    0,
		"MEDIUM": 1,
		"HIGH":   2,
		"OFF":    3,
	}
)

Enum value maps for VideoQuality.

View Source
var ErrIceGatheringInterruption = errors.New("getting ice gathering interrupted")
View Source
var ErrSessionClosed = errors.New("process interrupted because session closed")

Functions

func EndpointWithDataChannel

func EndpointWithDataChannel(f func(dc *webrtc.DataChannel)) func(endpoint *Endpoint)

func EndpointWithGetCurrentTrackCbk

func EndpointWithGetCurrentTrackCbk(ckk func(ctx context.Context, sessionId uuid.UUID) ([]*TrackInfo, error)) func(endpoint *Endpoint)

func EndpointWithLostConnectionListener

func EndpointWithLostConnectionListener(f func()) func(endpoint *Endpoint)

func EndpointWithNegotiationNeededListener

func EndpointWithNegotiationNeededListener(f func(sdp webrtc.SessionDescription)) func(endpoint *Endpoint)

func EndpointWithONNSetupTrigger

func EndpointWithONNSetupTrigger(waitBeforeONNSetup <-chan struct{}) func(endpoint *Endpoint)

func EndpointWithOnEstablishedListener

func EndpointWithOnEstablishedListener(onEstablished func()) func(endpoint *Endpoint)

func EndpointWithTrack

func EndpointWithTrack(track webrtc.TrackLocal, purpose Purpose) func(endpoint *Endpoint)

func EndpointWithTrackDispatcher

func EndpointWithTrackDispatcher(dispatcher TrackDispatcher) func(endpoint *Endpoint)

func EndpointWithonIceStateConnectedListener

func EndpointWithonIceStateConnectedListener(onIceStateConnected func()) func(endpoint *Endpoint)

func MarkStreamAsMain

func MarkStreamAsMain(sdpOrigin *webrtc.SessionDescription, streamID string) (*webrtc.SessionDescription, error)

func ValidateRtpConfig

func ValidateRtpConfig(config *RtpConfig) error

Types

type Connection

type Connection struct {
	PeerConnection *webrtc.PeerConnection
	GatherComplete <-chan struct{}
}

func (*Connection) GetLocalDescription

func (c *Connection) GetLocalDescription(ctx context.Context) (*webrtc.SessionDescription, error)

type Endpoint

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

func EstablishEgressEndpoint

func EstablishEgressEndpoint(sessionCxt context.Context, e *Engine, sessionId uuid.UUID, liveStream uuid.UUID, options ...EndpointOption) (*Endpoint, error)

EstablishEgressEndpoint Deprecated: Because the Endpoint API is getting simpler

func EstablishEndpoint

func EstablishEndpoint(ctx context.Context, sessionCxt context.Context, e *Engine, sessionId uuid.UUID, liveStream uuid.UUID, offer webrtc.SessionDescription, endpointType EndpointType, options ...EndpointOption) (*Endpoint, error)

func EstablishIngressEndpoint

func EstablishIngressEndpoint(sessionCxt context.Context, e *Engine, sessionId uuid.UUID, liveStream uuid.UUID, offer webrtc.SessionDescription, options ...EndpointOption) (*Endpoint, error)

EstablishIngressEndpoint Deprecated: Because the Endpoint API is getting simpler

func EstablishStaticEgressEndpoint

func EstablishStaticEgressEndpoint(ctx context.Context, e *Engine, sessionId uuid.UUID, liveStream uuid.UUID, offer webrtc.SessionDescription, options ...EndpointOption) (*Endpoint, error)

EstablishStaticEgressEndpoint Deprecated: Because the Endpoint API is getting simpler

func EstablishStaticIngressEndpoint

func EstablishStaticIngressEndpoint(ctx context.Context, e *Engine, sendingTracks []webrtc.TrackLocal, options ...EndpointOption) (*Endpoint, error)

EstablishStaticIngressEndpoint This is used from cmd line toll to start a webrtc connection in a running lobby Deprecated: Because the Endpoint API is getting simpler

func NewMockConnection

func NewMockConnection(ops MockConnectionOps) *Endpoint

func (*Endpoint) AddTrack

func (c *Endpoint) AddTrack(ctx context.Context, info *TrackInfo)

func (*Endpoint) Destruct

func (c *Endpoint) Destruct() error

func (*Endpoint) GetLocalDescription

func (c *Endpoint) GetLocalDescription(ctx context.Context) (*webrtc.SessionDescription, error)

func (*Endpoint) IsInitComplete

func (c *Endpoint) IsInitComplete() bool

func (*Endpoint) RemoveTrack

func (c *Endpoint) RemoveTrack(ctx context.Context, info *TrackInfo)

func (*Endpoint) SetAnswer

func (c *Endpoint) SetAnswer(sdp *webrtc.SessionDescription) error

func (*Endpoint) SetEgressMute

func (c *Endpoint) SetEgressMute(infoId uuid.UUID, mute bool) (*TrackInfo, bool)

func (*Endpoint) SetIngressMute

func (c *Endpoint) SetIngressMute(ingressMid string, mute bool) (*TrackInfo, bool)

func (*Endpoint) SetInitComplete

func (c *Endpoint) SetInitComplete()

func (*Endpoint) SetNewOffer

func (c *Endpoint) SetNewOffer(sdp *webrtc.SessionDescription) (*webrtc.SessionDescription, error)

type EndpointOption

type EndpointOption func(*Endpoint)

type EndpointType

type EndpointType int
const (
	IngressEndpoint EndpointType = iota + 1
	EgressEndpoint
)

func (EndpointType) ToString

func (et EndpointType) ToString() string

type Engine

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

func NewEngine

func NewEngine(rtpConfig *RtpConfig) (*Engine, error)

func (*Engine) EstablishEgressEndpoint

func (e *Engine) EstablishEgressEndpoint(ctx context.Context, sessionId uuid.UUID, liveStream uuid.UUID, options ...EndpointOption) (*Endpoint, error)

EstablishEgressEndpoint Deprecated: Because the Endpoint API is getting simpler

func (*Engine) EstablishEndpoint

func (e *Engine) EstablishEndpoint(ctx context.Context, sessionCtx context.Context, sessionId uuid.UUID, liveStream uuid.UUID, offer webrtc.SessionDescription, endpointType EndpointType, options ...EndpointOption) (*Endpoint, error)

func (*Engine) EstablishIngressEndpoint

func (e *Engine) EstablishIngressEndpoint(ctx context.Context, sessionId uuid.UUID, liveStream uuid.UUID, offer webrtc.SessionDescription, options ...EndpointOption) (*Endpoint, error)

EstablishIngressEndpoint Deprecated: Because the Endpoint API is getting simpler

func (*Engine) EstablishStaticEgressEndpoint

func (e *Engine) EstablishStaticEgressEndpoint(ctx context.Context, sessionId uuid.UUID, liveStream uuid.UUID, offer webrtc.SessionDescription, options ...EndpointOption) (*Endpoint, error)

EstablishStaticEgressEndpoint Deprecated: Because the Endpoint API is getting simpler

func (*Engine) NewReceiverConnection

func (e *Engine) NewReceiverConnection(ctx context.Context, offer webrtc.SessionDescription, handler StateEventHandler, rtmpEndpoint string) (*Connection, error)

NewReceiverConnection Deprecated: Because the Endpoint API is getting simpler

func (*Engine) NewSignalConnection

func (e *Engine) NewSignalConnection(ctx context.Context, handler StateEventHandler) (*Connection, error)

NewSignalConnection can be used to listen on lobby events. Deprecated: Because the Endpoint API is getting simpler

func (*Engine) NewStaticMediaSenderEndpoint

func (e *Engine) NewStaticMediaSenderEndpoint(media *static.MediaFile) (*Endpoint, error)

NewStaticMediaSenderEndpoint can be used to send static streams from file in a lobby. Deprecated: Because the Endpoint API is getting simpler

func (*Engine) OfferEndpoint

func (e *Engine) OfferEndpoint(ctx context.Context, sessionCtx context.Context, sessionId uuid.UUID, liveStream uuid.UUID, endpointType EndpointType, options ...EndpointOption) (*Endpoint, error)

type ICEServer

type ICEServer struct {
	Urls           []string `mapstructure:"urls"`
	Username       string   `mapstructure:"username"`
	Credential     string   `mapstructure:"credential"`
	CredentialType string   `mapstructure:"credentialType"`
}

type LiveStreamSender

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

func NewLiveStreamSender

func NewLiveStreamSender(lobbyContext context.Context, id uuid.UUID) (*LiveStreamSender, error)

func (*LiveStreamSender) AddTrack

func (f *LiveStreamSender) AddTrack(track webrtc.TrackLocal)

func (*LiveStreamSender) GetConnData

func (f *LiveStreamSender) GetConnData() UdpShare

func (*LiveStreamSender) RemoveTrack

func (f *LiveStreamSender) RemoveTrack(_ webrtc.TrackLocal)

func (*LiveStreamSender) Run

func (f *LiveStreamSender) Run()

func (*LiveStreamSender) Stop

func (f *LiveStreamSender) Stop()

type MockConnectionOps

type MockConnectionOps struct {
	Answer         *webrtc.SessionDescription
	GatherComplete chan struct{}
}

type Purpose

type Purpose int
const (
	PurposeGuest Purpose = iota + 1
	PurposeMain
)

func (Purpose) ToString

func (p Purpose) ToString() string

type RtpConfig

type RtpConfig struct {
	ICEServer []ICEServer `mapstructure:"iceServer"`
}

type SimulcastLayer

type SimulcastLayer struct {
	Quality VideoQuality `json:"quality,omitempty"`
	Width   uint32       `json:"width,omitempty"`
	Height  uint32       `json:"height,omitempty"`
	// target bitrate in bit per second (bps), server will measure actual
	Bitrate uint32 `json:"bitrate,omitempty"`
	Ssrc    uint32 `json:"ssrc,omitempty"`
}

func (*SimulcastLayer) GetBitrate

func (sl *SimulcastLayer) GetBitrate() uint32

func (*SimulcastLayer) GetHeight

func (sl *SimulcastLayer) GetHeight() uint32

func (*SimulcastLayer) GetQuality

func (sl *SimulcastLayer) GetQuality() VideoQuality

func (*SimulcastLayer) GetSsrc

func (sl *SimulcastLayer) GetSsrc() uint32

func (*SimulcastLayer) GetWidth

func (sl *SimulcastLayer) GetWidth() uint32

func (*SimulcastLayer) Reset

func (sl *SimulcastLayer) Reset()

type StateEventHandler

type StateEventHandler interface {
	OnConnectionStateChange(state webrtc.ICEConnectionState)
	OnNegotiationNeeded(offer webrtc.SessionDescription)
	OnChannel(dc *webrtc.DataChannel)
}

type TrackDispatcher

type TrackDispatcher interface {
	DispatchAddTrack(ctx context.Context, track *TrackInfo)
	DispatchRemoveTrack(ctx context.Context, track *TrackInfo)
}

type TrackInfo

type TrackInfo struct {
	TrackSdpInfo
	Track *webrtc.TrackLocalStaticRTP
}

func (*TrackInfo) GetEgressMid

func (t *TrackInfo) GetEgressMid() string

func (*TrackInfo) GetId

func (t *TrackInfo) GetId() uuid.UUID

func (*TrackInfo) GetIngressMid

func (t *TrackInfo) GetIngressMid() string

func (*TrackInfo) GetMute

func (t *TrackInfo) GetMute() bool

func (*TrackInfo) GetPurpose

func (t *TrackInfo) GetPurpose() Purpose

func (*TrackInfo) GetSessionId

func (t *TrackInfo) GetSessionId() uuid.UUID

func (*TrackInfo) GetTrack

func (t *TrackInfo) GetTrack() *webrtc.TrackLocalStaticRTP

func (*TrackInfo) GetTrackLocal

func (t *TrackInfo) GetTrackLocal() webrtc.TrackLocal

func (*TrackInfo) SetMute

func (t *TrackInfo) SetMute(mute bool)

type TrackSdpInfo

type TrackSdpInfo struct {
	Id uuid.UUID
	// source ----------
	SessionId      uuid.UUID
	IngressMid     string
	IngressTrackId string

	// sink ------------
	EgressMid     string
	EgressTrackId string

	Purpose Purpose
	Mute    bool
	Info    string
}

type UdpConnection

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

type UdpShare

type UdpShare struct {
	Audio UdpShareInfo
	Video UdpShareInfo
}

type UdpShareInfo

type UdpShareInfo struct {
	Port        int
	PayloadType uint8
}

type VideoQuality

type VideoQuality int32
const (
	VideoQuality_LOW    VideoQuality = 0
	VideoQuality_MEDIUM VideoQuality = 1
	VideoQuality_HIGH   VideoQuality = 2
	VideoQuality_OFF    VideoQuality = 3
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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