cds

package
v0.0.0-...-bf4a537 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2018 License: BSD-3-Clause Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FileServerRoute        = "fileserver"
	RouteObjectIDParameter = "objectID"
	RouteObjectIDTemplate  = "{objectID:/.*}"
)
View Source
const (
	NoSuchObjectErrorCode = 701

	// Service identifier URN
	ServiceID = "urn:upnp-org:serviceId:ContentDirectory"

	// Service type URN
	ServiceType = "urn:schemas-upnp-org:service:ContentDirectory:1"
)
View Source
const LoaderTimeout = 5 * time.Second
View Source
const RootID = filesystem.RootID

RootID is the identifier of the root of any ContentDirectory

Variables

View Source
var FolderType = types.NewMIME("application/vnd.container")

Functions

func FileServerURLSpec

func FileServerURLSpec(id filesystem.ID) *adi_http.URLSpec

Types

type AddInfoKey

type AddInfoKey struct {
	OrgName string
	Token   string
}

type Cache

type Cache struct {
	ContentDirectory
	// contains filtered or unexported fields
}

func NewCache

func NewCache(d ContentDirectory, cm *cache.Manager, l logging.Logger) *Cache

func (*Cache) Get

func (c *Cache) Get(id filesystem.ID, ctx context.Context) (*Object, error)

func (*Cache) GetChildren

func (c *Cache) GetChildren(id filesystem.ID, ctx context.Context) ([]*Object, error)

type ContentDirectory

type ContentDirectory interface {
	Get(filesystem.ID, context.Context) (*Object, error)
	GetChildren(filesystem.ID, context.Context) ([]*Object, error)
	LastModTime() time.Time
}

ContentDirectory is the generic ContentDirectory interface (no s**t, sherlock !).

type DirectoryHandler

type DirectoryHandler struct {
	Directory ContentDirectory
	Handler   ObjectHandler
}

DirectoryHandler

func (*DirectoryHandler) ServeHTTP

func (h *DirectoryHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP parses and resolves the object ID and passes the object to the

type FileServer

type FileServer struct {
	DirectoryHandler
}

func NewFileServer

func NewFileServer(d ContentDirectory) *FileServer

func (*FileServer) Process

func (s *FileServer) Process(obj *Object, _ context.Context)

func (*FileServer) ServeObject

func (s *FileServer) ServeObject(w http.ResponseWriter, r *http.Request, obj *Object)

func (FileServer) String

func (FileServer) String() string

type FilesystemContentDirectory

type FilesystemContentDirectory struct {
	FS *filesystem.Filesystem
}

FilesystemContentDirectory is a filesystem-based ContentDirectory with processors

func (*FilesystemContentDirectory) Get

func (d *FilesystemContentDirectory) Get(id filesystem.ID, ctx context.Context) (obj *Object, err error)

func (*FilesystemContentDirectory) GetChildren

func (d *FilesystemContentDirectory) GetChildren(id filesystem.ID, ctx context.Context) ([]*Object, error)

func (*FilesystemContentDirectory) LastModTime

func (d *FilesystemContentDirectory) LastModTime() time.Time

type Object

type Object struct {
	filesystem.Object
	Title string

	Album       string
	AlbumArtURI *http.URLSpec
	Artist      string
	Date        time.Time
	Genre       string
	Icon        *http.URLSpec

	Resources []Resource

	MimeType types.MIME
}

func (*Object) AddResource

func (o *Object) AddResource(rs ...Resource)

func (*Object) IsContainer

func (o *Object) IsContainer() bool

func (*Object) MarshalDIDLLite

func (o *Object) MarshalDIDLLite(gen http.URLGenerator) (res didl_lite.Object, err error)

type ObjectHandler

type ObjectHandler interface {
	ServeObject(http.ResponseWriter, *http.Request, *Object)
}

ObjectHandler

type ObjectHandlerFunc

type ObjectHandlerFunc func(http.ResponseWriter, *http.Request, *Object)

ObjectHandlerFunc

func (ObjectHandlerFunc) ServeObject

func (f ObjectHandlerFunc) ServeObject(w http.ResponseWriter, r *http.Request, o *Object)

type ProcessingDirectory

type ProcessingDirectory struct {
	ContentDirectory
	logging.Logger
	// contains filtered or unexported fields
}

ProcessingDirectory uses processors to enrich the objects

func (*ProcessingDirectory) AddProcessor

func (pl *ProcessingDirectory) AddProcessor(priority int, p Processor)

func (*ProcessingDirectory) Get

func (d *ProcessingDirectory) Get(id filesystem.ID, ctx context.Context) (obj *Object, err error)

Get fetchs the Object from the underlying Directory and applies the processors to it

func (*ProcessingDirectory) GetChildren

func (d *ProcessingDirectory) GetChildren(id filesystem.ID, ctx context.Context) ([]*Object, error)

Get fetchs the Object from the underlying Directory and applies the processors to it

func (ProcessingDirectory) Len

func (pl ProcessingDirectory) Len() int

func (ProcessingDirectory) Less

func (pl ProcessingDirectory) Less(i, j int) bool

func (ProcessingDirectory) Swap

func (pl ProcessingDirectory) Swap(i, j int)

type Processor

type Processor interface {
	Process(*Object, context.Context)
}

Processor adds information to Object

type ProtocolInfo

type ProtocolInfo struct {
	MimeType       types.MIME
	AdditionalInfo map[AddInfoKey]string
}

func (ProtocolInfo) String

func (p ProtocolInfo) String() string

type Resource

type Resource struct {
	URL  *http.URLSpec
	Size uint64
	ProtocolInfo

	Duration        time.Duration
	Bitrate         uint32
	SampleFrequency uint32
	BitsPerSample   uint8
	NrAudioChannels uint8
	Resolution      didl_lite.Resolution
	ColorDepth      uint8

	FilePath string
	// contains filtered or unexported fields
}

func (*Resource) MarshalDIDLLite

func (r *Resource) MarshalDIDLLite(gen http.URLGenerator) (res didl_lite.Resource, err error)

func (*Resource) Owner

func (r *Resource) Owner() *Object

type Service

type Service struct {
	ContentDirectory
	*upnp.Service
}

Service implements the Content Directory Service

func NewService

func NewService(directory ContentDirectory) *Service

New initializes a content-directory service

func (*Service) Browse

func (s *Service) Browse(q browseQuery, req *http.Request) (r browseReply, err error)

func (*Service) GetSearchCapabilities

func (s *Service) GetSearchCapabilities(q empty, _ *http.Request) (getSearchCapabilitiesResponse, error)

func (*Service) GetSortCapabilities

func (s *Service) GetSortCapabilities(q empty, _ *http.Request) (getSortCapabilitiesResponse, error)

func (*Service) GetSystemUpdateID

func (s *Service) GetSystemUpdateID(q empty, _ *http.Request) (systemUpdateIDResponse, error)

Jump to

Keyboard shortcuts

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