Documentation
¶
Index ¶
- type AdaptationSet
- type ContentProtection
- type Initialization
- type MPD
- type Period
- type Representation
- func (r *Representation) GetCodecs() string
- func (r *Representation) GetContentProtection() []*ContentProtection
- func (r *Representation) GetHeight() int
- func (r *Representation) GetMimeType() string
- func (r *Representation) GetSegmentTemplate() *SegmentTemplate
- func (r *Representation) GetWidth() int
- func (r *Representation) ResolveBaseURL() (*url.URL, error)
- func (r *Representation) String() string
- type Role
- type S
- type SegmentBase
- type SegmentList
- type SegmentTemplate
- func (st *SegmentTemplate) GetDurationBasedNumbers() ([]uint, error)
- func (st *SegmentTemplate) GetNumberRange() []uint
- func (st *SegmentTemplate) GetSegmentURLs(rep *Representation) ([]*url.URL, error)
- func (st *SegmentTemplate) GetStartNumber() uint
- func (st *SegmentTemplate) GetTimelineNumbers() []uint
- func (st *SegmentTemplate) GetTimelineTimes() []uint
- func (st *SegmentTemplate) GetTimescale() uint
- func (st *SegmentTemplate) ResolveInitialization(rep *Representation) (*url.URL, error)
- func (st *SegmentTemplate) ResolveMedia(rep *Representation, number int) (*url.URL, error)
- func (st *SegmentTemplate) ResolveMediaTime(rep *Representation, timeVal int) (*url.URL, error)
- type SegmentTimeline
- type SegmentURL
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AdaptationSet ¶
type AdaptationSet struct {
Codecs string `xml:"codecs,attr"`
Height int `xml:"height,attr"`
Lang string `xml:"lang,attr"`
MimeType string `xml:"mimeType,attr"`
Width int `xml:"width,attr"`
ContentProtection []*ContentProtection `xml:"ContentProtection"`
Role *Role `xml:"Role"`
SegmentTemplate *SegmentTemplate `xml:"SegmentTemplate"`
Representations []*Representation `xml:"Representation"`
// Navigation
Parent *Period `xml:"-"`
}
AdaptationSet groups Representations.
type ContentProtection ¶
type ContentProtection struct {
SchemeIdUri string `xml:"schemeIdUri,attr"`
// DefaultKID maps to cenc:default_KID (urn:mpeg:cenc:2013)
DefaultKID string `xml:"urn:mpeg:cenc:2013 default_KID,attr"`
// Pssh maps to the cenc:pssh element (urn:mpeg:cenc:2013)
Pssh string `xml:"urn:mpeg:cenc:2013 pssh"`
}
ContentProtection specifies DRM schemes.
func (*ContentProtection) GetDefaultKID ¶ added in v1.29.5
func (cp *ContentProtection) GetDefaultKID() ([]byte, error)
GetDefaultKID returns the DefaultKID as a byte slice. It strips hyphens from the UUID string before decoding the hex.
func (*ContentProtection) GetPSSH ¶ added in v1.29.5
func (cp *ContentProtection) GetPSSH() ([]byte, error)
GetPSSH returns the PSSH data as a byte slice. It decodes the Base64 content of the element.
type Initialization ¶ added in v1.25.4
type Initialization struct {
// Used in SegmentBase
Range string `xml:"range,attr"`
// Used in SegmentList
SourceURL string `xml:"sourceURL,attr"`
// Navigation
Parent *SegmentList `xml:"-"`
}
Initialization contains URL and byte range information for initialization segments.
func (*Initialization) ResolveSourceURL ¶ added in v1.28.4
func (i *Initialization) ResolveSourceURL() (*url.URL, error)
ResolveSourceURL resolves the @sourceURL attribute against the parent SegmentList's context.
type MPD ¶ added in v1.28.4
type MPD struct {
MediaPresentationDuration string `xml:"mediaPresentationDuration,attr"`
BaseURL string `xml:"BaseURL"`
Periods []*Period `xml:"Period"`
// MPDURL is the source URL of the MPD file itself.
// It is used as the root for resolving relative BaseURLs.
MPDURL *url.URL `xml:"-"`
}
MPD represents the root element of the DASH MPD file. XMLName is omitted here to prevent SA5008 conflicts.
func Parse ¶ added in v1.28.4
Parse takes a byte slice of an MPD file, unmarshals it, and populates the navigation parent pointers.
func (*MPD) GetRepresentations ¶ added in v1.28.7
func (m *MPD) GetRepresentations() map[string][]*Representation
GetRepresentations returns a map of all Representations in the MPD, keyed by their ID attribute.
type Period ¶
type Period struct {
Duration string `xml:"duration,attr"`
ID string `xml:"id,attr"`
BaseURL string `xml:"BaseURL"`
AdaptationSets []*AdaptationSet `xml:"AdaptationSet"`
// Navigation
Parent *MPD `xml:"-"`
}
Period represents a temporal part of the media content.
func (*Period) GetDuration ¶ added in v1.28.4
GetDuration parses the ISO 8601 Duration attribute. If Period@duration is missing, it falls back to MPD@mediaPresentationDuration.
type Representation ¶
type Representation struct {
Bandwidth int `xml:"bandwidth,attr"`
Codecs string `xml:"codecs,attr"`
Height int `xml:"height,attr"`
ID string `xml:"id,attr"`
MimeType string `xml:"mimeType,attr"`
Width int `xml:"width,attr"`
BaseURL string `xml:"BaseURL"`
SegmentTemplate *SegmentTemplate `xml:"SegmentTemplate"`
ContentProtection []*ContentProtection `xml:"ContentProtection"`
SegmentBase *SegmentBase `xml:"SegmentBase"`
SegmentList *SegmentList `xml:"SegmentList"`
// Navigation
Parent *AdaptationSet `xml:"-"`
}
Representation describes a version of the media content.
func (*Representation) GetCodecs ¶ added in v1.28.4
func (r *Representation) GetCodecs() string
GetCodecs returns the codecs for this Representation. If the Codecs attribute is empty on the Representation, it returns the Codecs attribute from the parent AdaptationSet.
func (*Representation) GetContentProtection ¶ added in v1.28.8
func (r *Representation) GetContentProtection() []*ContentProtection
GetContentProtection returns the ContentProtection elements for this Representation. If the Representation has its own ContentProtection elements, they are returned. Otherwise, it returns the ContentProtection elements from the parent AdaptationSet.
func (*Representation) GetHeight ¶ added in v1.28.4
func (r *Representation) GetHeight() int
GetHeight returns the height for this Representation. If the Height attribute is 0 on the Representation, it returns the Height attribute from the parent AdaptationSet.
func (*Representation) GetMimeType ¶ added in v1.25.2
func (r *Representation) GetMimeType() string
GetMimeType returns the mimeType for this Representation. If the MimeType attribute is empty on the Representation, it returns the MimeType attribute from the parent AdaptationSet.
func (*Representation) GetSegmentTemplate ¶ added in v1.28.4
func (r *Representation) GetSegmentTemplate() *SegmentTemplate
GetSegmentTemplate returns the SegmentTemplate for this Representation. If the SegmentTemplate is nil on the Representation, it returns the SegmentTemplate from the parent AdaptationSet.
func (*Representation) GetWidth ¶ added in v1.28.4
func (r *Representation) GetWidth() int
GetWidth returns the width for this Representation. If the Width attribute is 0 on the Representation, it returns the Width attribute from the parent AdaptationSet.
func (*Representation) ResolveBaseURL ¶ added in v1.28.4
func (r *Representation) ResolveBaseURL() (*url.URL, error)
ResolveBaseURL resolves the Representation's BaseURL against the parent hierarchy.
func (*Representation) String ¶
func (r *Representation) String() string
String returns a multi-line summary of the Representation. Fields: bandwidth, width, height, codecs, mimeType, lang, role, period, id. Optional fields are omitted if empty/zero.
type Role ¶ added in v1.28.4
type Role struct {
Value string `xml:"value,attr"`
}
Role defines the role of the media content.
type SegmentBase ¶
type SegmentBase struct {
IndexRange string `xml:"indexRange,attr"`
Initialization *Initialization `xml:"Initialization"`
}
SegmentBase defines base information for segments.
type SegmentList ¶ added in v1.26.1
type SegmentList struct {
Duration uint `xml:"duration,attr"`
Timescale *uint `xml:"timescale,attr"`
Initialization *Initialization `xml:"Initialization"`
SegmentURLs []*SegmentURL `xml:"SegmentURL"`
// Navigation
Parent *Representation `xml:"-"`
}
SegmentList contains a list of SegmentURLs.
func (*SegmentList) GetTimescale ¶ added in v1.29.7
func (sl *SegmentList) GetTimescale() uint
GetTimescale returns the Timescale if present, otherwise returns default 1.
type SegmentTemplate ¶
type SegmentTemplate struct {
Duration uint `xml:"duration,attr"`
EndNumber uint `xml:"endNumber,attr"`
Initialization string `xml:"initialization,attr"`
Media string `xml:"media,attr"`
PresentationTimeOffset uint `xml:"presentationTimeOffset,attr"`
// StartNumber is a pointer to distinguish between missing (nil) and explicitly 0.
StartNumber *uint `xml:"startNumber,attr"`
// Timescale is a pointer to distinguish between missing (nil) and explicitly 0.
Timescale *uint `xml:"timescale,attr"`
SegmentTimeline *SegmentTimeline `xml:"SegmentTimeline"`
// Navigation
ParentAdaptationSet *AdaptationSet `xml:"-"`
ParentRepresentation *Representation `xml:"-"`
}
SegmentTemplate defines specific rules for generating segment URLs.
func (*SegmentTemplate) GetDurationBasedNumbers ¶ added in v1.28.4
func (st *SegmentTemplate) GetDurationBasedNumbers() ([]uint, error)
GetDurationBasedNumbers calculates segment numbers based on Period duration.
func (*SegmentTemplate) GetNumberRange ¶ added in v1.28.4
func (st *SegmentTemplate) GetNumberRange() []uint
GetNumberRange returns a slice of numbers from StartNumber to EndNumber (inclusive).
func (*SegmentTemplate) GetSegmentURLs ¶ added in v1.28.4
func (st *SegmentTemplate) GetSegmentURLs(rep *Representation) ([]*url.URL, error)
GetSegmentURLs returns all segment URLs defined by this template.
func (*SegmentTemplate) GetStartNumber ¶ added in v1.28.4
func (st *SegmentTemplate) GetStartNumber() uint
GetStartNumber returns the StartNumber if present, otherwise returns default 1.
func (*SegmentTemplate) GetTimelineNumbers ¶ added in v1.28.4
func (st *SegmentTemplate) GetTimelineNumbers() []uint
GetTimelineNumbers returns a slice of segment numbers derived from the SegmentTimeline.
func (*SegmentTemplate) GetTimelineTimes ¶ added in v1.28.4
func (st *SegmentTemplate) GetTimelineTimes() []uint
GetTimelineTimes returns a slice of start times for segments derived from the SegmentTimeline.
func (*SegmentTemplate) GetTimescale ¶ added in v1.28.4
func (st *SegmentTemplate) GetTimescale() uint
GetTimescale returns the Timescale if present, otherwise returns default 1.
func (*SegmentTemplate) ResolveInitialization ¶ added in v1.28.4
func (st *SegmentTemplate) ResolveInitialization(rep *Representation) (*url.URL, error)
ResolveInitialization resolves the @initialization attribute.
func (*SegmentTemplate) ResolveMedia ¶ added in v1.28.4
func (st *SegmentTemplate) ResolveMedia(rep *Representation, number int) (*url.URL, error)
ResolveMedia resolves the @media attribute for number-based addressing.
func (*SegmentTemplate) ResolveMediaTime ¶ added in v1.28.4
func (st *SegmentTemplate) ResolveMediaTime(rep *Representation, timeVal int) (*url.URL, error)
ResolveMediaTime resolves the @media attribute for time-based addressing.
type SegmentTimeline ¶ added in v1.28.4
type SegmentTimeline struct {
S []*S `xml:"S"`
}
SegmentTimeline defines specific timing for segments.
type SegmentURL ¶ added in v1.28.4
type SegmentURL struct {
Media string `xml:"media,attr"`
// Navigation
Parent *SegmentList `xml:"-"`
}
SegmentURL defines a specific media segment source.
func (*SegmentURL) ResolveMedia ¶ added in v1.28.4
func (su *SegmentURL) ResolveMedia() (*url.URL, error)
ResolveMedia resolves the @media attribute against the parent SegmentList's context.