Help us shape the future of Go! Take the 2026 Go Developer Survey

dlna

package
v0.31.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: AGPL-3.0 Imports: 29 Imported by: 0

Documentation

Overview

Package dlna provides the DLNA functionality for the application. Much of this code is adapted from https://github.com/anacrolix/dms

Index

Constants

View Source
const (
	// DefaultSessionTimeout is the time after which a session is considered complete
	// if no new requests are received.
	// This is set high (5 minutes) because DLNA clients buffer aggressively and may not
	// send any HTTP requests for extended periods while the user is still watching.
	DefaultSessionTimeout = 5 * time.Minute
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ActivityConfig added in v0.31.0

type ActivityConfig interface {
	// GetDLNAActivityTrackingEnabled returns true if activity tracking should be enabled.
	// If not implemented, defaults to true.
	GetDLNAActivityTrackingEnabled() bool

	// GetMinimumPlayPercent returns the minimum percentage of a video that must be
	// watched before incrementing the play count. Uses UI setting if available.
	GetMinimumPlayPercent() int
}

ActivityConfig provides configuration options for DLNA activity tracking.

type ActivityTracker added in v0.31.0

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

ActivityTracker tracks DLNA streaming activity and saves it to the database.

func NewActivityTracker added in v0.31.0

func NewActivityTracker(
	txnManager txn.Manager,
	sceneWriter SceneActivityWriter,
	config ActivityConfig,
) *ActivityTracker

NewActivityTracker creates a new ActivityTracker.

func (*ActivityTracker) RecordRequest added in v0.31.0

func (t *ActivityTracker) RecordRequest(sceneID int, clientIP string, videoDuration float64)

RecordRequest records a streaming request for activity tracking. Each request updates the session's LastActivity time, which is used for time-based tracking of watch progress.

func (*ActivityTracker) Stop added in v0.31.0

func (t *ActivityTracker) Stop()

Stop stops the activity tracker and processes any remaining sessions.

type Cache

type Cache interface {
	Set(key interface{}, value interface{})
	Get(key interface{}) (value interface{}, ok bool)
}

type Config

type Config interface {
	GetDLNAInterfaces() []string
	GetDLNAServerName() string
	GetDLNADefaultIPWhitelist() []string
	GetVideoSortOrder() string
	GetDLNAPortAsString() string
	GetDLNAActivityTrackingEnabled() bool
}

type Dlnaip added in v0.17.0

type Dlnaip struct {
	IPAddress string `json:"ipAddress"`
	// Time until IP will be no longer allowed/disallowed
	Until *time.Time `json:"until"`
}

type GroupFinder added in v0.27.0

type GroupFinder interface {
	All(ctx context.Context) ([]*models.Group, error)
}

type Icon

type Icon struct {
	Width, Height, Depth int
	Mimetype             string
	io.ReadSeeker
}

type PerformerFinder added in v0.17.0

type PerformerFinder interface {
	All(ctx context.Context) ([]*models.Performer, error)
}

type Repository added in v0.17.0

type Repository struct {
	TxnManager models.TxnManager

	SceneFinder     SceneFinder
	FileGetter      models.FileGetter
	StudioFinder    StudioFinder
	TagFinder       TagFinder
	PerformerFinder PerformerFinder
	GroupFinder     GroupFinder
}

func NewRepository added in v0.24.0

func NewRepository(repo models.Repository) Repository

func (*Repository) WithReadTxn added in v0.24.0

func (r *Repository) WithReadTxn(ctx context.Context, fn txn.TxnFunc) error

type SceneActivityWriter added in v0.31.0

type SceneActivityWriter interface {
	SaveActivity(ctx context.Context, sceneID int, resumeTime *float64, playDuration *float64) (bool, error)
	AddViews(ctx context.Context, sceneID int, dates []time.Time) ([]time.Time, error)
}

SceneActivityWriter provides methods for saving scene activity.

type SceneFinder added in v0.17.0

type SceneFinder interface {
	models.SceneGetter
	models.SceneQueryer
}

type Server

type Server struct {
	HTTPConn     net.Listener
	FriendlyName string
	Interfaces   []net.Interface

	RootObjectPath string

	LogHeaders bool
	Icons      []Icon
	// Stall event subscription requests until they drop. A workaround for
	// some bad clients.
	StallEventSubscribe bool
	// Time interval between SSPD announces
	NotifyInterval time.Duration

	VideoSortOrder string
	// contains filtered or unexported fields
}

func (*Server) Close

func (me *Server) Close() (err error)

func (*Server) Serve

func (me *Server) Serve() (err error)

type Service

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

func NewService

func NewService(repo Repository, cfg Config, sceneServer sceneServer, sceneWriter SceneActivityWriter, minPlayPercent int) *Service

NewService initialises and returns a new DLNA service. The sceneWriter parameter should implement SceneActivityWriter (typically models.SceneReaderWriter). The minPlayPercent parameter is the minimum percentage of video that must be played to increment play count.

func (*Service) AddTempDLNAIP

func (s *Service) AddTempDLNAIP(pattern string, duration *time.Duration)

func (*Service) IsRunning

func (s *Service) IsRunning() bool

IsRunning returns true if the DLNA service is running.

func (*Service) RemoveTempDLNAIP

func (s *Service) RemoveTempDLNAIP(pattern string) bool

func (*Service) Start

func (s *Service) Start(duration *time.Duration) error

Start starts the DLNA service. If duration is provided, then the service is stopped after the duration has elapsed.

func (*Service) Status

func (s *Service) Status() *Status

func (*Service) Stop

func (s *Service) Stop(duration *time.Duration)

Stop stops the DLNA service. If duration is provided, then the service is started after the duration has elapsed.

type Status added in v0.17.0

type Status struct {
	Running bool `json:"running"`
	// If not currently running, time until it will be started. If running, time until it will be stopped
	Until              *time.Time `json:"until"`
	RecentIPAddresses  []string   `json:"recentIPAddresses"`
	AllowedIPAddresses []*Dlnaip  `json:"allowedIPAddresses"`
}

type StudioFinder added in v0.17.0

type StudioFinder interface {
	All(ctx context.Context) ([]*models.Studio, error)
}

type TagFinder added in v0.17.0

type TagFinder interface {
	All(ctx context.Context) ([]*models.Tag, error)
}

type UPnPService

type UPnPService interface {
	Handle(action string, argsXML []byte, r *http.Request) (respArgs map[string]string, err error)
	Subscribe(callback []*url.URL, timeoutSeconds int) (sid string, actualTimeout int, err error)
	Unsubscribe(sid string) error
}

UPnP SOAP service.

Jump to

Keyboard shortcuts

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