upnpav

package
v0.0.0-...-0df88b9 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProtocolHTTP = Protocol("http-get")
	ProtocolRTSP = Protocol("rtsp-rtp-udp")
)

Variables

View Source
var (
	AudioItem = Class("object.item.audioItem")
	ImageItem = Class("object.item.imageItem")
	VideoItem = Class("object.item.videoItem")

	AudioBook      = Class("object.item.audioItem.audioBook")
	AudioBroadcast = Class("object.item.audioItem.audioBroadcast")
	MusicTrack     = Class("object.item.audioItem.musicTrack")
	Photo          = Class("object.item.imageItem.photo")
	Movie          = Class("object.item.videoItem.movie")
	VideoBroadcast = Class("object.item.videoItem.videoBroadcast")
	MusicVideo     = Class("object.item.videoItem.musicVideoClip")
	PlaylistItem   = Class("object.item.playlistItem")
	TextItem       = Class("object.item.textItem")

	Artist        = Class("object.container.person.musicArtist")
	Playlist      = Class("object.container.playlistContainer")
	MusicAlbum    = Class("object.container.album.musicAlbum")
	PhotoAlbum    = Class("object.container.album.photoAlbum")
	MusicGenre    = Class("object.container.genre.musicGenre")
	MovieGenre    = Class("object.container.genre.movieGenre")
	StorageSystem = Class("object.container.storageSystem")
	StorageVolume = Class("object.container.storageVolume")
	StorageFolder = Class("object.container.storageFolder")
)
View Source
var (
	ErrInvalidAction = Error{Code: 401, Description: "Invalid action"}
	ErrInvalidArgs   = Error{Code: 402, Description: "Invalid args"}
	ErrActionFailed  = Error{Code: 501, Description: "Action failed"}
)
View Source
var (
	ErrUnknownMIMEType = errors.New("could not find valid MIME-type for URI")
)

Functions

func MaybeError

func MaybeError(err error) error

Types

type Class

type Class string

Class is a UPnP AV object class. Classes are defined in ContentDirectory v1, Appendix C.

func ClassForMIMEType

func ClassForMIMEType(mimetype string) (Class, error)

type Container

type Container struct {
	ID     ObjectID `xml:"id,attr"`
	Parent ObjectID `xml:"parentID,attr"`

	// Restricted == !writable.
	Restricted xmltypes.IntBool `xml:"restricted,attr"`
	Searchable xmltypes.IntBool `xml:"searchable,attr"`

	Title string `xml:"http://purl.org/dc/elements/1.1/ title,omitempty"`
	Class Class  `xml:"urn:schemas-upnp-org:metadata-1-0/upnp/ class,omitempty"`

	Description     string   `xml:"http://purl.org/dc/elements/1.1/ description,omitempty"`
	LongDescription string   `xml:"urn:schemas-upnp-org:metadata-1-0/upnp/ longDescription,omitempty"`
	Icon            *url.URL `xml:"urn:schemas-upnp-org:metadata-1-0/upnp/ icon,omitempty"`
	Region          string   `xml:"urn:schemas-upnp-org:metadata-1-0/upnp/ region,omitempty"`
	AgeRating       string   `xml:"urn:schemas-upnp-org:metadata-1-0/upnp/ rating,omitempty"`
	Rights          []string `xml:"http://purl.org/dc/elements/1.1/ rights,omitempty"`
	Date            *Date    `xml:"http://purl.org/dc/elements/1.1/ date,omitempty"`

	// Language is an RFC1766 language, e.g. "en-US".
	Language string `xml:"http://purl.org/dc/elements/1.1/ language,omitempty"`

	// UserAnnotations is a "general-purpose tag where a user can annotate an object with some user-specific information".
	UserAnnotations []string `xml:"urn:schemas-upnp-org:metadata-1-0/upnp/ userAnnotation,omitempty"`

	// TOC is an "identifier of an audio CD".
	TOC string `xml:"urn:schemas-upnp-org:metadata-1-0/upnp/ toc,omitempty"`

	// WriteStatus can be one of: WRITEABLE, PROTECTED, NOT_WRITEABLE, UNKNOWN, MIXED.
	WriteStatus string `xml:"urn:schemas-upnp-org:metadata-1-0/upnp/ writeStatus,omitempty"`

	ChildCount int `xml:"childCount,attr"`

	// Storage has a special value "-1" to represent "unknown".
	StorageTotalBytes        int    `xml:"urn:schemas-upnp-org:metadata-1-0/upnp/ storageTotal,omitempty"`
	StorageUsedBytes         int    `xml:"urn:schemas-upnp-org:metadata-1-0/upnp/ storageUsed,omitempty"`
	StorageFreeBytes         int    `xml:"urn:schemas-upnp-org:metadata-1-0/upnp/ storageFree,omitempty"`
	StorageMaxPartitionBytes int    `xml:"urn:schemas-upnp-org:metadata-1-0/upnp/ storageMaxPartition,omitempty"`
	StorageMedium            string `xml:"urn:schemas-upnp-org:metadata-1-0/upnp/ storageMedium,omitempty"`
}

type DIDLLite

type DIDLLite struct {
	Containers []Container `xml:"container,omitempty"`
	Items      []Item      `xml:"item,omitempty"`
}

func DIDLForURI

func DIDLForURI(uri string) (*DIDLLite, error)

DIDLForURI returns a minimal DIDL sufficient to get media to play with just a URI.

NB: It may not be enough, e.g. my TV needs more information about the video codec than can be inferred from just the URI.

func ParseDIDLLite

func ParseDIDLLite(src string) (*DIDLLite, error)

func (DIDLLite) IsSingleContainer

func (d DIDLLite) IsSingleContainer() bool

func (DIDLLite) IsSingleItem

func (d DIDLLite) IsSingleItem() bool

func (DIDLLite) String

func (d DIDLLite) String() string

type Date

type Date struct {
	time.Time
}

func ParseDate

func ParseDate(raw string) (Date, error)

func (Date) MarshalText

func (d Date) MarshalText() ([]byte, error)

func (Date) String

func (d Date) String() string

func (*Date) UnmarshalText

func (d *Date) UnmarshalText(raw []byte) error

type Duration

type Duration struct {
	time.Duration
}

Duration is of the form H+:MM:SS[.F+] or H+:MM:SS[.F0/F1], where: H+ is 0 or more digits for hours, MM is exactly 2 digits for minutes, SS is exactly 2 digits for seconds, F+ is 0 or more digits for fractional seconds, F0/F1 is a fraction, F0 & F1 are at least 1 digit, and F0/F1 < 1.

func ParseDuration

func ParseDuration(raw string) (Duration, error)

func (Duration) MarshalText

func (d Duration) MarshalText() ([]byte, error)

func (Duration) String

func (d Duration) String() string

func (*Duration) UnmarshalText

func (d *Duration) UnmarshalText(raw []byte) error

type EncodedDIDLLite

type EncodedDIDLLite struct {
	DIDLLite
}

EncodedDIDLLite wraps DIDLLites for inclusion in UPnP AV messages. DIDLLite is not inserted as an XML fragment, but is encoded as text for UPnP AV RPCs.

func (EncodedDIDLLite) MarshalText

func (ed EncodedDIDLLite) MarshalText() ([]byte, error)

func (*EncodedDIDLLite) UnmarshalText

func (ed *EncodedDIDLLite) UnmarshalText(raw []byte) error

type Error

type Error struct {
	XMLName     xml.Name `xml:"urn:schemas-upnp-org:control-1-0 UPnPError"`
	Code        int      `xml:"errorCode"`
	Description string   `xml:"errorDescription"`
}

func (Error) Detail

func (e Error) Detail() string

func (Error) Error

func (e Error) Error() string

func (Error) FaultCode

func (e Error) FaultCode() soap.FaultCode

func (Error) FaultString

func (e Error) FaultString() string

type Item

type Item struct {
	ID     ObjectID `xml:"id,attr"`
	Parent ObjectID `xml:"parentID,attr"`

	// Restricted == !writable.
	Restricted xmltypes.IntBool `xml:"restricted,attr"`
	Searchable xmltypes.IntBool `xml:"searchable,attr"`

	Title string `xml:"http://purl.org/dc/elements/1.1/ title,omitempty"`
	Class Class  `xml:"urn:schemas-upnp-org:metadata-1-0/upnp/ class,omitempty"`

	Description     string   `xml:"http://purl.org/dc/elements/1.1/ description,omitempty"`
	LongDescription string   `xml:"urn:schemas-upnp-org:metadata-1-0/upnp/ longDescription,omitempty"`
	Icon            *url.URL `xml:"urn:schemas-upnp-org:metadata-1-0/upnp/ icon,omitempty"`
	Region          string   `xml:"urn:schemas-upnp-org:metadata-1-0/upnp/ region,omitempty"`
	AgeRating       string   `xml:"urn:schemas-upnp-org:metadata-1-0/upnp/ rating,omitempty"`
	Rights          []string `xml:"http://purl.org/dc/elements/1.1/ rights,omitempty"`
	Date            *Date    `xml:"http://purl.org/dc/elements/1.1/ date,omitempty"`

	// Language is an RFC1766 language, e.g. "en-US".
	Language string `xml:"http://purl.org/dc/elements/1.1/ language,omitempty"`

	// UserAnnotations is a "general-purpose tag where a user can annotate an object with some user-specific information".
	UserAnnotations []string `xml:"urn:schemas-upnp-org:metadata-1-0/upnp/ userAnnotation,omitempty"`

	// TOC is an "identifier of an audio CD".
	TOC string `xml:"urn:schemas-upnp-org:metadata-1-0/upnp/ toc,omitempty"`

	// WriteStatus can be one of: WRITEABLE, PROTECTED, NOT_WRITEABLE, UNKNOWN, MIXED.
	WriteStatus string `xml:"urn:schemas-upnp-org:metadata-1-0/upnp/ writeStatus,omitempty"`

	// RefID is "ID property of the item being referred to".
	RefID string `xml:"refID,attr,omitempty"`

	Creator string `xml:"http://purl.org/dc/elements/1.1/ creator,omitempty"`

	Artists      []Person `xml:"urn:schemas-upnp-org:metadata-1-0/upnp/ artist,omitempty"`
	Actors       []Person `xml:"urn:schemas-upnp-org:metadata-1-0/upnp/ actor,omitempty"`
	Authors      []Person `xml:"urn:schemas-upnp-org:metadata-1-0/upnp/ author,omitempty"`
	Directors    []string `xml:"urn:schemas-upnp-org:metadata-1-0/upnp/ director,omitempty"`
	Producers    []string `xml:"urn:schemas-upnp-org:metadata-1-0/upnp/ producer,omitempty"`
	Publishers   []string `xml:"http://purl.org/dc/elements/1.1/ publisher,omitempty"`
	Contributors []string `xml:"http://purl.org/dc/elements/1.1/ contributor,omitempty"`

	// The following link to containers by the container title (e.g. object.container.playlist).
	Genres    []string `xml:"urn:schemas-upnp-org:metadata-1-0/upnp/ genre,omitempty"`
	Albums    []string `xml:"urn:schemas-upnp-org:metadata-1-0/upnp/ album",omitempty`
	Playlists []string `xml:"urn:schemas-upnp-org:metadata-1-0/upnp/ playlist,omitempty"`

	AlbumArtURIs         []string `xml:"urn:schemas-upnp-org:metadata-1-0/upnp/ albumArtURI,omitempty"`
	ArtistDiscographyURI string   `xml:"urn:schemas-upnp-org:metadata-1-0/upnp/ artistDiscographyURI,omitempty"`
	LyricsURI            string   `xml:"urn:schemas-upnp-org:metadata-1-0/upnp/ lyricsURI,omitempty"`
	RelationURI          string   `xml:"http://purl.org/dc/elements/1.1/ relation,omitempty"`

	TrackNumber int `xml:"urn:schemas-upnp-org:metadata-1-0/upnp/ originalTrackNumber,omitempty"`

	Resources []Resource `xml:"res,omitempty"`
}

func (Item) HasURI

func (item Item) HasURI(uri string) bool

func (Item) URIForProtocolInfos

func (item Item) URIForProtocolInfos(infos []ProtocolInfo) (string, bool)

URIForProtocolInfos finds a URI from an item that matches a set of valid ProtocolInfos. TODO: Return the "best" supported URI instead of just the first.

type ObjectID

type ObjectID string

type Person

type Person struct {
	Name string `xml:",innerxml"`
	Role string `xml:"role,attr,omitempty"`
}

type Protocol

type Protocol string

type ProtocolInfo

type ProtocolInfo struct {
	Protocol Protocol
	// Network should be "*" for http-get and rtsp-rtp-udp, but can have other values for other
	Network string
	// ContentFormat should be the MIME-type for http-get, or the RTP payload type for rtsp-rtp-udp.
	ContentFormat string
	// AdditionalInfo is frequently "*", but can be used by some formats, e.g. DLNA.ORG_PN extensions.
	AdditionalInfo string
}

ProtocolInfo is a UPnP AV ProtocolInfo string.

func ParseProtocolInfo

func ParseProtocolInfo(raw string) (ProtocolInfo, error)

func ProtocolInfoForURI

func ProtocolInfoForURI(uri string) (*ProtocolInfo, error)

func (ProtocolInfo) MarshalText

func (p ProtocolInfo) MarshalText() ([]byte, error)

func (ProtocolInfo) String

func (p ProtocolInfo) String() string

func (*ProtocolInfo) UnmarshalText

func (p *ProtocolInfo) UnmarshalText(raw []byte) error

type Resolution

type Resolution struct {
	Height, Width int
}

Resolution of the resource of the form [0-9]+x[0-9]+, e.g. 4x2.

func ParseResolution

func ParseResolution(raw string) (Resolution, error)

func (Resolution) MarshalText

func (r Resolution) MarshalText() ([]byte, error)

func (Resolution) String

func (r Resolution) String() string

func (*Resolution) UnmarshalText

func (r *Resolution) UnmarshalText(raw []byte) error

type Resource

type Resource struct {
	URI          string        `xml:",innerxml"`
	ProtocolInfo *ProtocolInfo `xml:"protocolInfo,attr,omitempty"`

	AudioChannels     uint        `xml:"nrAudioChannels,attr,omitempty"`
	BitsPerSample     uint        `xml:"bitsPerSample,attr,omitempty"`
	BitsPerSecond     uint        `xml:"bitrate,attr,omitempty"`
	ColorDepth        uint        `xml:"colorDepth,attr,omitempty"`
	Duration          *Duration   `xml:"duration,attr,omitempty"`
	Resolution        *Resolution `xml:"resolution,attr,omitempty"`
	SampleFrequencyHz uint        `xml:"sampleFrequency,attr,omitempty"`
	SizeBytes         uint        `xml:"size,attr,omitempty"`

	// Protection is "some identification of a protection system used for the resource".
	Protection string `xml:"protection,attr,omitempty"`

	// ImportURI is "URI via which the resource can be imported to the CDS via ImportResource() or HTTP POST".
	ImportURI string `xml:"importURI,attr,omitempty"`
}

Directories

Path Synopsis
fileserver
Package fileserver is a basic "serve a directory" ContentDirectory handler.
Package fileserver is a basic "serve a directory" ContentDirectory handler.
jackalope
Package jackalope is a Jackalope-enhanced ContentDirectory handler.
Package jackalope is a Jackalope-enhanced ContentDirectory handler.
search
Package search implements the DLNA query language, defined in the ContentDirectory spec.
Package search implements the DLNA query language, defined in the ContentDirectory spec.
Package controlpoint is a UPnP AV "Control Point", for mediating ContentDirectories and AVTransports.
Package controlpoint is a UPnP AV "Control Point", for mediating ContentDirectories and AVTransports.

Jump to

Keyboard shortcuts

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