mediaserver

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2025 License: AGPL-3.0-or-later Imports: 18 Imported by: 0

Documentation

Overview

package mediaserver is responsible for managing the media server, which is currently an instance of MediaMTX.

https://github.com/bluenviron/mediamtx

Index

Constants

View Source
const DefaultImageNameMediaMTX = "ghcr.io/rfwatson/mediamtx-alpine:latest"

DefaultImageNameMediaMTX is the default Docker image name for the MediaMTX server.

Variables

This section is empty.

Functions

This section is empty.

Types

type Actor

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

Actor is responsible for managing the media server.

func NewActor added in v0.0.4

func NewActor(ctx context.Context, params NewActorParams) (_ *Actor, err error)

NewActor creates a new media server actor.

Callers must consume the state channel exposed via [C].

func (*Actor) C

func (s *Actor) C() <-chan domain.Source

C returns a channel that will receive the current state of the media server.

func (*Actor) Close

func (s *Actor) Close() error

Close closes the media server actor.

func (*Actor) RTMPInternalURL added in v0.0.4

func (s *Actor) RTMPInternalURL() string

RTMPInternalURL returns the RTMP URL for the media server, accessible from the app network.

func (*Actor) RTMPSURL added in v0.0.8

func (s *Actor) RTMPSURL() string

RTMPSURL returns the RTMPS URL for the media server, accessible from the host.

func (*Actor) RTMPURL added in v0.0.4

func (s *Actor) RTMPURL() string

RTMPURL returns the RTMP URL for the media server, accessible from the host.

func (*Actor) Start added in v0.0.4

func (a *Actor) Start(ctx context.Context) error

func (*Actor) State

func (s *Actor) State() domain.Source

State returns the current state of the media server.

Blocks if the actor is not started yet.

type Config

type Config struct {
	LogLevel          string          `yaml:"logLevel,omitempty"`
	LogDestinations   []string        `yaml:"logDestinations,omitempty"`
	ReadTimeout       string          `yaml:"readTimeout,omitempty"`
	WriteTimeout      string          `yaml:"writeTimeout,omitempty"`
	WriteQueueSize    int             `yaml:"writeQueueSize,omitempty"`
	UDPMaxPayloadSize int             `yaml:"udpMaxPayloadSize,omitempty"`
	AuthMethod        string          `yaml:"authMethod,omitempty"`
	AuthInternalUsers []User          `yaml:"authInternalUsers,omitempty"`
	Metrics           bool            `yaml:"metrics,omitempty"`
	MetricsAddress    string          `yaml:"metricsAddress,omitempty"`
	API               bool            `yaml:"api,omitempty"`
	APIAddress        string          `yaml:"apiAddress,omitempty"`
	APIEncryption     bool            `yaml:"apiEncryption,omitempty"`
	APIServerCert     string          `yaml:"apiServerCert,omitempty"`
	APIServerKey      string          `yaml:"apiServerKey,omitempty"`
	RTMP              bool            `yaml:"rtmp"`
	RTMPEncryption    string          `yaml:"rtmpEncryption,omitempty"`
	RTMPAddress       string          `yaml:"rtmpAddress,omitempty"`
	RTMPSAddress      string          `yaml:"rtmpsAddress,omitempty"`
	RTMPServerCert    string          `yaml:"rtmpServerCert,omitempty"`
	RTMPServerKey     string          `yaml:"rtmpServerKey,omitempty"`
	HLS               bool            `yaml:"hls"`
	RTSP              bool            `yaml:"rtsp"`
	WebRTC            bool            `yaml:"webrtc"`
	SRT               bool            `yaml:"srt"`
	Paths             map[string]Path `yaml:"paths,omitempty"`
}

Config represents the MediaMTX configuration file.

type NewActorParams added in v0.0.5

type NewActorParams struct {
	RTMPAddr            OptionalNetAddr // defaults to disabled, or 127.0.0.1:1935
	RTMPSAddr           OptionalNetAddr // defaults to disabled, or 127.0.0.1:1936
	APIPort             int             // defaults to 9997
	Host                string          // defaults to "localhost"
	StreamKey           StreamKey       // defaults to "live"
	ImageName           string          // defaults to "ghcr.io/rfwatson/mediamtx-alpine:latest"
	ChanSize            int             // defaults to 64
	UpdateStateInterval time.Duration   // defaults to 5 seconds
	KeyPairs            domain.KeyPairs
	ContainerClient     *container.Client
	InDocker            bool
	Logger              *slog.Logger
}

NewActorParams contains the parameters for building a new media server actor.

type OptionalNetAddr added in v0.0.8

type OptionalNetAddr struct {
	domain.NetAddr

	Enabled bool
}

OptionalNetAddr is a wrapper around domain.NetAddr that indicates whether it is enabled or not.

type Path

type Path struct {
	Source string `yaml:"source,omitempty"`
}

Path represents a path configuration in MediaMTX.

type StreamKey

type StreamKey string

StreamKey is the stream key for the media server, which forms the RTMP path component and can be used as a basic form of authentication.

It defaults to "live", in which case the full RTMP URL would be: `rtmp://localhost:1935/live`.

type User

type User struct {
	User        string           `yaml:"user,omitempty"`
	Pass        string           `yaml:"pass,omitempty"`
	IPs         []string         `yaml:"ips,omitempty"`
	Permissions []UserPermission `yaml:"permissions,omitempty"`
}

User represents a user configuration in MediaMTX.

type UserPermission

type UserPermission struct {
	Action string `yaml:"action,omitempty"`
}

UserPermission represents a user permission in MediaMTX.

Jump to

Keyboard shortcuts

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