domain

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnknown               = errors.New("unknown error")
	ErrBroadcastNotFound     = errors.New("broadcast not found")
	ErrBroadcastInvalidEvent = errors.New("broadcast invalid event")

	ErrViewerNotFound = errors.New("viewer not found")
)

Functions

This section is empty.

Types

type BroadcastCreate

type BroadcastCreate struct {
	Title string
}

type BroadcastEvent added in v0.0.12

type BroadcastEvent struct {
	Response chan<- string
	Data     any
	Event    string
}

type BroadcastSession

type BroadcastSession struct {
	Track    *webrtc.TrackLocalStaticRTP
	Viewers  map[*Viewer]struct{}
	EventOut chan BroadcastEvent
	EventIn  chan BroadcastEvent

	ID    string
	Title string
	// contains filtered or unexported fields
}

func (*BroadcastSession) AddViewer

func (b *BroadcastSession) AddViewer(viewer *Viewer)

func (*BroadcastSession) Close

func (b *BroadcastSession) Close(cause error)

func (*BroadcastSession) ContextClose

func (b *BroadcastSession) ContextClose() <-chan struct{}

func (*BroadcastSession) ListenEvent added in v0.0.12

func (b *BroadcastSession) ListenEvent() <-chan BroadcastEvent

func (*BroadcastSession) MakeRTCConnection added in v0.0.12

func (b *BroadcastSession) MakeRTCConnection(config *config.Config)

func (*BroadcastSession) RemoveViewer

func (b *BroadcastSession) RemoveViewer(viewer *Viewer)

func (*BroadcastSession) SendEvent added in v0.0.12

func (b *BroadcastSession) SendEvent(event BroadcastEvent)

func (*BroadcastSession) SendEventToViewers added in v0.0.13

func (b *BroadcastSession) SendEventToViewers(event ViewerEvent)

func (*BroadcastSession) SetTrack added in v0.0.12

func (b *BroadcastSession) SetTrack(trackChan <-chan *webrtc.TrackLocalStaticRTP)

type BroadcastUpdate

type BroadcastUpdate struct {
	Title string
}

type BroadcastsRepository

type BroadcastsRepository interface {
	GetBroadcast(id string) (*BroadcastSession, error)
	GetBroadcasts() ([]*BroadcastSession, error)
	CreateBroadcast(broadcast BroadcastCreate) (*BroadcastSession, error)
	UpdateBroadcast(id string, broadcast BroadcastUpdate) (*BroadcastSession, error)
	DeleteBroadcast(id string) error

	// Viewer related repository methods
	GetViewer(id string) (*Viewer, error)
	CreateViewer(viewer ViewerCreate) (*Viewer, error)
	DeleteViewer(id string) error
}

type BroadcastsUsecases

type BroadcastsUsecases interface {
	Get(id string) (*BroadcastSession, error)
	GetBroadcasts() ([]*BroadcastSession, error)
	Create(broadcastTitle string) (*BroadcastSession, error)
	SaveICECandidate(id string, candidate any) error
	SaveOffer(id, sdp string) (string, error)
	Delete(id string) error

	// Viewer related use cases
	Connect(broadcastId string) (*Viewer, error)
	SaveViewerICECandidate(broadcastId string, candidate any) error
	SaveViewerOffer(broadcastId, sdp string) (string, error)
	DeleteViewer(viewerId string) error
}

FIXME: Use cases should receive a context.Context to handle timeouts and cancellations.

type Viewer

type Viewer struct {
	EventOut chan ViewerEvent
	EventIn  chan ViewerEvent

	BroadcastID string
	ID          string
	// contains filtered or unexported fields
}

func (*Viewer) Close added in v0.0.13

func (v *Viewer) Close(cause error)

func (*Viewer) ContextClose added in v0.0.13

func (v *Viewer) ContextClose() <-chan struct{}

func (*Viewer) HandleViewer added in v0.0.13

func (v *Viewer) HandleViewer(track *webrtc.TrackLocalStaticRTP, config *config.Config)

func (*Viewer) ListenEvent added in v0.0.13

func (v *Viewer) ListenEvent() <-chan ViewerEvent

func (*Viewer) SendEvent added in v0.0.13

func (v *Viewer) SendEvent(event ViewerEvent)

type ViewerCreate added in v0.1.0

type ViewerCreate struct {
	BroadcastID string
}

type ViewerEvent added in v0.0.13

type ViewerEvent struct {
	Response chan<- string
	Data     any
	Event    string
}

Jump to

Keyboard shortcuts

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