sessions

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: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSessionAlreadyClosed         = errors.New("session already closed")
	ErrIngressAlreadyExists         = errors.New("ingress resource already exists in session")
	ErrEgressAlreadyExists          = errors.New("egress resource already exists in session")
	ErrNoSignalChannel              = errors.New("no signal channel connection exists in session")
	ErrSessionProcessWaitingTimeout = errors.New("session process waiting timeout")
)

Functions

This section is empty.

Types

type Hub

type Hub struct {
	LiveStreamId uuid.UUID
	// contains filtered or unexported fields
}

func NewHub

func NewHub(ctx context.Context, sessionRepo *SessionRepository, liveStream uuid.UUID, sender liveStreamSender) *Hub

func (*Hub) DispatchAddTrack

func (h *Hub) DispatchAddTrack(ctx context.Context, track *rtp.TrackInfo)

func (*Hub) DispatchMuteTrack

func (h *Hub) DispatchMuteTrack(ctx context.Context, track *rtp.TrackInfo)

func (*Hub) DispatchRemoveTrack

func (h *Hub) DispatchRemoveTrack(ctx context.Context, track *rtp.TrackInfo)

type Item

type Item struct {
	UserId      uuid.UUID
	SessionType SessionType
	Done        chan bool
}

func NewItem

func NewItem(userId uuid.UUID) Item

type RtpEngine

type RtpEngine interface {
	EstablishEndpoint(ctx context.Context, sessionCtx context.Context, sessionId uuid.UUID, liveStream uuid.UUID, offer webrtc.SessionDescription, endpointType rtp.EndpointType, options ...rtp.EndpointOption) (*rtp.Endpoint, error)
	OfferEndpoint(ctx context.Context, sessionCtx context.Context, sessionId uuid.UUID, liveStream uuid.UUID, endpointType rtp.EndpointType, options ...rtp.EndpointOption) (*rtp.Endpoint, error)
}

type Session

type Session struct {
	Id uuid.UUID
	// contains filtered or unexported fields
}

func NewSession

func NewSession(ctx context.Context, user uuid.UUID, hub *Hub, engine RtpEngine, sType SessionType, garbage chan Item) *Session

func (*Session) CreateEgressEndpoint

func (s *Session) CreateEgressEndpoint(ctx context.Context, offer *webrtc.SessionDescription, signalKind SignalChannelKind) (*webrtc.SessionDescription, error)

CreateEgressEndpoint Receives an Offer and generates an Answer to establish an Egress WebRTC connection.

func (*Session) CreateIngressEndpoint

func (s *Session) CreateIngressEndpoint(ctx context.Context, offer *webrtc.SessionDescription, signalKind SignalChannelKind) (*webrtc.SessionDescription, error)

CreateIngressEndpoint Receives an Offer and generates an Answer to establish an Ingress WebRTC connection.

func (*Session) OfferEgressEndpoint

func (s *Session) OfferEgressEndpoint(ctx context.Context, signalKind SignalChannelKind) (*webrtc.SessionDescription, error)

OfferEgressEndpoint Creates an offer and prepares an Egress WebRTC connection. The connection then waits for the response from the other peer.

func (*Session) OfferIngressEndpoint

func (s *Session) OfferIngressEndpoint(ctx context.Context, signalKind SignalChannelKind) (*webrtc.SessionDescription, error)

OfferIngressEndpoint Creates an offer and prepares an Ingress WebRTC connection. The connection then waits for the response from the other peer.

func (*Session) SetEgressAnswer

func (s *Session) SetEgressAnswer(answer *webrtc.SessionDescription) chan struct{}

func (*Session) SetIngressAnswer

func (s *Session) SetIngressAnswer(answer *webrtc.SessionDescription) chan struct{}

type SessionRepository

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

func NewSessionRepository

func NewSessionRepository() *SessionRepository

func (*SessionRepository) Add

func (r *SessionRepository) Add(s *Session)

func (*SessionRepository) All

func (r *SessionRepository) All() map[uuid.UUID]*Session

func (*SessionRepository) Contains

func (r *SessionRepository) Contains(id uuid.UUID) bool

func (*SessionRepository) Delete

func (r *SessionRepository) Delete(id uuid.UUID) bool

func (*SessionRepository) DeleteByUser

func (r *SessionRepository) DeleteByUser(user uuid.UUID) bool

func (*SessionRepository) FindById

func (r *SessionRepository) FindById(id uuid.UUID) (*Session, bool)

func (*SessionRepository) FindByUserId

func (r *SessionRepository) FindByUserId(userId uuid.UUID) (*Session, bool)

func (*SessionRepository) Iter

func (r *SessionRepository) Iter(routine func(*Session))

func (*SessionRepository) Len

func (r *SessionRepository) Len() int

func (*SessionRepository) LenUserSession

func (r *SessionRepository) LenUserSession() int

func (*SessionRepository) New

func (r *SessionRepository) New(s *Session) bool

func (*SessionRepository) Update

func (r *SessionRepository) Update(s *Session) bool

type SessionType

type SessionType int
const (
	// UserSession represents the connection of a user directly connected to this instance
	UserSession SessionType = iota + 1
	// InstanceSession represents the connection to the Shig instance hosting the live stream.
	// When the livestream belongs to another Shig instance, this Shig instance connects to that remote instance.
	InstanceSession
	// RemoteInstanceSession represents the connection of another Shig instance.
	RemoteInstanceSession
)

type SignalChannelKind

type SignalChannelKind int
const (
	SilentSignalChannel SignalChannelKind = iota + 1
	UnidirectionalSignalChannel
	BidirectionalSignalChannel
)

Jump to

Keyboard shortcuts

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