mpd

package module
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2024 License: MIT Imports: 4 Imported by: 0

README

go-mpd

Go library for parsing and generating MPEG-DASH Media Presentation Description (MPD) files.

This project is based on https://github.com/mc2soft/mpd.

Usage

package main

import (
	"fmt"
	"github.com/bitmovin-engineering/go-mpd"
)

func main() {
	mpd := new(mpd.MPD)
	mpd.Decode([]byte(`<MPD type="static" mediaPresentationDuration="PT3M30S">
  <Period>
    <AdaptationSet mimeType="video/mp4" codecs="avc1.42c00d">
      <SegmentTemplate media="../video/$RepresentationID$/dash/segment_$Number$.m4s" initialization="../video/$RepresentationID$/dash/init.mp4" duration="100000" startNumber="0" timescale="25000"/>
      <Representation id="180_250000" bandwidth="250000" width="320" height="180" frameRate="25"/>
      <Representation id="270_400000" bandwidth="400000" width="480" height="270" frameRate="25"/>
      <Representation id="360_800000" bandwidth="800000" width="640" height="360" frameRate="25"/>
      <Representation id="540_1200000" bandwidth="1200000" width="960" height="540" frameRate="25"/>
      <Representation id="720_2400000" bandwidth="2400000" width="1280" height="720" frameRate="25"/>
      <Representation id="1080_4800000" bandwidth="4800000" width="1920" height="1080" frameRate="25"/>
    </AdaptationSet>
    <AdaptationSet lang="en" mimeType="audio/mp4" codecs="mp4a.40.2" bitmovin:label="English stereo">
      <AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2"/>
      <SegmentTemplate media="../audio/$RepresentationID$/dash/segment_$Number$.m4s" initialization="../audio/$RepresentationID$/dash/init.mp4" duration="191472" startNumber="0" timescale="48000"/>
      <Representation id="1_stereo_128000" bandwidth="128000" audioSamplingRate="48000"/>
    </AdaptationSet>
  </Period>
</MPD>`))

	fmt.Println(mpd.MediaPresentationDuration)
}

MPD parsing/generation in other languages

Documentation

Overview

Package mpd implements parsing and generating of MPEG-DASH Media Presentation Description (MPD) files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AdaptationSet

type AdaptationSet struct {
	ID               *string `xml:"id,attr,omitempty"`
	ContentType      *string `xml:"contentType,attr,omitempty"`
	MimeType         *string `xml:"mimeType,attr,omitempty"`
	SegmentAlignment *string `xml:"segmentAlignment,attr,omitempty"`

	Href         *string `xml:"href,attr,omitempty"`
	Actuate      *string `xml:"actuate,attr,omitempty"`
	Group        *int64  `xml:"group,attr,omitempty"`
	Lang         *string `xml:"lang,attr,omitempty"`
	Par          *string `xml:"par,attr,omitempty"`
	MinBandwidth *int64  `xml:"minBandwidth,attr,omitempty"`
	MaxBandwidth *int64  `xml:"maxBandwidth,attr,omitempty"`
	MinWidth     *int64  `xml:"minWidth,attr,omitempty"`
	MaxWidth     *int64  `xml:"maxWidth,attr,omitempty"`
	MinHeight    *int64  `xml:"minHeight,attr,omitempty"`
	MaxHeight    *int64  `xml:"maxHeight,attr,omitempty"`
	MinFrameRate *string `xml:"minFrameRate,attr,omitempty"`
	MaxFrameRate *string `xml:"maxFrameRate,attr,omitempty"`

	Labels                     []*Label             `xml:"Label,omitempty"`
	FramePackings              []*Descriptor        `xml:"FramePacking,omitempty"`
	AudioChannelConfigurations []*Descriptor        `xml:"AudioChannelConfiguration,omitempty"`
	ContentProtections         []*ContentProtection `xml:"ContentProtection,omitempty"`
	EssentialProperties        []*Descriptor        `xml:"EssentialProperty,omitempty"`
	SupplementalProperties     []*Descriptor        `xml:"SupplementalProperty,omitempty"`
	InbandEventStreams         []*EventStream       `xml:"InbandEventStream,omitempty"`

	Accessibilities   []*Descriptor       `xml:"Accessibility,omitempty"`
	Roles             []*Descriptor       `xml:"Role,omitempty"`
	Ratings           []*Descriptor       `xml:"Rating,omitempty"`
	Viewpoints        []*Descriptor       `xml:"Viewpoint,omitempty"`
	ContentComponents []*ContentComponent `xml:"ContentComponent,omitempty"`
	BaseURLs          []*BaseURL          `xml:"BaseURL,omitempty"`
	SegmentBase       *SegmentBase        `xml:"SegmentBase,omitempty"`
	SegmentList       *SegmentList        `xml:"SegmentList,omitempty"`
	SegmentTemplate   *SegmentTemplate    `xml:"SegmentTemplate,omitempty"`
	Representations   []*Representation   `xml:"Representation,omitempty"`

	SubsegmentAlignment     *string `xml:"subsegmentAlignment,attr,omitempty"`
	SubsegmentStartsWithSAP *int64  `xml:"subsegmentStartsWithSAP,attr,omitempty"`
	BitstreamSwitching      *bool   `xml:"bitstreamSwitching,attr,omitempty"`

	Profiles *string `xml:"profiles,attr"`
	Width    *uint64 `xml:"width,attr"`
	Height   *uint64 `xml:"height,attr"`
	// Sample Aspect Ratio: aspect ratio of one pixel (typically 1:1)
	SAR               *string  `xml:"sar,attr"`
	FrameRate         *string  `xml:"frameRate,attr"`
	AudioSamplingRate *string  `xml:"audioSamplingRate,attr"`
	SegmentProfiles   *string  `xml:"segmentProfiles,attr"`
	Codecs            *string  `xml:"codecs,attr"`
	MaximumSapPeriod  *float64 `xml:"maximumSAPPeriod,attr"`
	StartWithSap      *uint64  `xml:"startWithSAP,attr"`
	MaxPlayoutRate    *float64 `xml:"maxPlayoutRate,attr"`
	CodingDependency  *bool    `xml:"codingDependency,attr"`
	ScanType          *string  `xml:"scanType,attr"`
}

AdaptationSet represents XSD's AdaptationSetType.

type BaseURL

type BaseURL struct {
	Value                    string  `xml:",chardata"`
	ServiceLocation          *string `xml:"serviceLocation,attr"`
	ByteRange                *string `xml:"byteRange,attr"`
	AvailabilityTimeOffset   *uint64 `xml:"availabilityTimeOffset,attr"`
	AvailabilityTimeComplete *bool   `xml:"availabilityTimeComplete,attr"`
}

BaseURL represents XSD's BaseURLType.

type ConditionalUint

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

ConditionalUint (ConditionalUintType) defined in XSD as a union of unsignedInt and boolean.

func (ConditionalUint) MarshalXMLAttr

func (c ConditionalUint) MarshalXMLAttr(name xml.Name) (xml.Attr, error)

MarshalXMLAttr encodes ConditionalUint.

func (*ConditionalUint) UnmarshalXMLAttr

func (c *ConditionalUint) UnmarshalXMLAttr(attr xml.Attr) error

UnmarshalXMLAttr decodes ConditionalUint.

type ContentComponent

type ContentComponent struct {
	Accessibilities []*Descriptor `xml:"Accessibility,omitempty"`
	Roles           []*Descriptor `xml:"Role,omitempty"`
	Ratings         []*Descriptor `xml:"Rating,omitempty"`
	Viewpoints      []*Descriptor `xml:"Viewpoint,omitempty"`
	ID              *int64        `xml:"id,attr,omitempty"`
	Lang            *string       `xml:"lang,attr,omitempty"`
	ContentType     *string       `xml:"contentType,attr,omitempty"`
	Par             *string       `xml:"par,attr,omitempty"`
}

ContentComponent represents XSD's ContentComponentType.

type ContentProtection

type ContentProtection struct {
	SchemeIDURI         *string             `xml:"schemeIdUri,attr"`
	Value               *string             `xml:"value,attr"`
	Cenc                *string             `xml:"cenc,attr"`
	CencPSSH            *string             `xml:"cenc:pssh,attr"`
	CencDefaultKID      *string             `xml:"cenc:default_KID,attr"`
	DefaultKID          *string             `xml:"default_KID,attr"`
	CencPsshBody        *string             `xml:"cenc:pssh,omitempty"`
	PsshBody            *Pssh               `xml:"pssh,omitempty"`
	Pro                 *Pro                `xml:"pro,omitempty"`
	MsprPro             *string             `xml:"mspr:pro,omitempty"`
	MarlinContentIds    []*MarlinContentIds `xml:"MarlinContentIds,omitempty"`
	MasMarlinContentIds []*MarlinContentIds `xml:"mas:MarlinContentIds,omitempty"`
}

type Descriptor

type Descriptor struct {
	SchemeIDURI *string `xml:"schemeIdUri,attr"`
	Value       *string `xml:"value,attr"`
}

Descriptor represents XSD's DescriptorType.

type Event

type Event struct {
	Value            string  `xml:",chardata"`
	PresentationTime *uint64 `xml:"presentationTime,attr"`
	Duration         *uint64 `xml:"duration,attr"`
	ID               *uint64 `xml:"id,attr"`
	MessageData      *string `xml:"messageData,attr"`
}

type EventStream

type EventStream struct {
	Events      []*Event `xml:"Event,omitempty"`
	Href        *string  `xml:"href,attr"`
	Actuate     *string  `xml:"actuate,attr"`
	SchemeIDURI *string  `xml:"schemeIdUri,attr"`
	Value       *string  `xml:"value,attr"`
	Timescale   *uint64  `xml:"timescale,attr"`
	MessageData *string  `xml:"messageData,attr"`
}

type Label

type Label struct {
	Value string  `xml:",chardata"`
	ID    *int64  `xml:"id,attr,omitempty"`
	Lang  *string `xml:"lang,attr,omitempty"`
}

type MPD

type MPD struct {
	XMLNS                      *string               `xml:"xmlns,attr"`
	XMLNSXSI                   *string               `xml:"xmlns:xsi,attr"`
	Ns2                        *string               `xml:"ns2,attr"`
	Xsi                        *string               `xml:"xsi,attr"`
	XsiSchemaLocation          *string               `xml:"xsi:schemaLocation,attr"`
	SchemaLocation             *string               `xml:"schemaLocation,attr"`
	Type                       *string               `xml:"type,attr"`
	MinimumUpdatePeriod        *string               `xml:"minimumUpdatePeriod,attr"`
	AvailabilityStartTime      *string               `xml:"availabilityStartTime,attr"`
	AvailabilityEndTime        *string               `xml:"availabilityEndTime,attr"`
	MediaPresentationDuration  *string               `xml:"mediaPresentationDuration,attr"`
	MinBufferTime              *string               `xml:"minBufferTime,attr"`
	SuggestedPresentationDelay *string               `xml:"suggestedPresentationDelay,attr"`
	TimeShiftBufferDepth       *string               `xml:"timeShiftBufferDepth,attr"`
	PublishTime                *string               `xml:"publishTime,attr"`
	Profiles                   *string               `xml:"profiles,attr"`
	Id                         *string               `xml:"id,attr"`
	MaxSegmentDuration         *string               `xml:"maxSegmentDuration,attr"`
	MaxSubsegmentDuration      *string               `xml:"maxSubsegmentDuration,attr"`
	BaseURL                    []*BaseURL            `xml:"BaseURL,omitempty"`
	Period                     []*Period             `xml:"Period,omitempty"`
	ProgramInformations        []*ProgramInformation `xml:"ProgramInformation,omitempty"`
	Locations                  []*string             `xml:"Location,omitempty"`
	Metrics                    []*Metrics            `xml:"Metrics,omitempty"`
	EssentialProperties        []*Descriptor         `xml:"EssentialProperty,omitempty"`
	SupplementalProperties     []*Descriptor         `xml:"SupplementalProperty,omitempty"`
	UtcTimings                 []*UtcTiming          `xml:"UTCTiming,omitempty"`
	XmlnsCenc                  *string               `xml:"xmlns:cenc,attr"`
	Cenc                       *string               `xml:"cenc,attr"`
	Mspr                       *string               `xml:"mspr,attr"`
	XmlnsMspr                  *string               `xml:"xmlns:mspr,attr"`
	Mas                        *string               `xml:"mas,attr"`
	XmlnsMas                   *string               `xml:"xmlns:mas,attr"`
}

MPD represents root XML element.

func (*MPD) Decode

func (m *MPD) Decode(b []byte) error

Decode parses MPD XML.

func (*MPD) Encode

func (m *MPD) Encode() ([]byte, error)

Encode generates MPD XML.

type MarlinContentId added in v0.1.4

type MarlinContentId struct {
	Value string `xml:",chardata"`
}

type MarlinContentIds added in v0.1.4

type MarlinContentIds struct {
	MarlinContentId    *MarlinContentId `xml:"MarlinContentId,omitempty"`
	MasMarlinContentId *MarlinContentId `xml:"mas:MarlinContentId,omitempty"`
}

type Metrics

type Metrics struct {
	Reportings []*Descriptor `xml:"Reporting,omitempty"`
	Ranges     []*Range      `xml:"Range,omitempty"`
	Metrics    string        `xml:"metrics,attr"`
}

type Period

type Period struct {
	ID                 *string `xml:"id,attr"`
	Start              *string `xml:"start,attr"`
	Duration           *string `xml:"duration,attr"`
	Href               *string `xml:"href,attr"`
	Actuate            *string `xml:"actuate,attr"`
	BitStreamSwitching *bool   `xml:"bitstreamSwitching,attr"`
	Label              *string `xml:"label,attr"`
	BitmovinCustomXml  *string `xml:"bitmovinCustomXml,attr"`

	AdaptationSets         []*AdaptationSet `xml:"AdaptationSet,omitempty"`
	BaseURL                []*BaseURL       `xml:"BaseURL,omitempty"`
	SegmentBase            *SegmentBase     `xml:"SegmentBase,omitempty"`
	SegmentList            *SegmentList     `xml:"SegmentList,omitempty"`
	SegmentTemplate        *SegmentTemplate `xml:"SegmentTemplate,omitempty"`
	AssetIdentifier        *Descriptor      `xml:"AssetIdentifier,omitempty"`
	EventStreams           []*EventStream   `xml:"EventStream,omitempty"`
	Subsets                []*Subset        `xml:"Subset,omitempty"`
	SupplementalProperties []*Descriptor    `xml:"SupplementalProperty,omitempty"`
}

Period represents XSD's PeriodType.

type Pro

type Pro struct {
	Value string  `xml:",chardata"`
	Mspr  *string `xml:"mspr,attr"`
}

type ProgramInformation

type ProgramInformation struct {
	Title              string  `xml:"Title,omitempty"`
	Source             string  `xml:"Source,omitempty"`
	Copyright          string  `xml:"Copyright,omitempty"`
	Lang               *string `xml:"lang,attr,omitempty"`
	MoreInformationURL *string `xml:"moreInformationURL,attr,omitempty"`
}

type Pssh

type Pssh struct {
	Value string  `xml:",chardata"`
	Cenc  *string `xml:"cenc,attr"`
}

type Range

type Range struct {
	StartTime *string `xml:"starttime,attr"`
	Duration  *string `xml:"duration,attr"`
}

type Representation

type Representation struct {
	ID                         *string              `xml:"id,attr"`
	Bandwidth                  *uint64              `xml:"bandwidth,attr"`
	Width                      *uint64              `xml:"width,attr"`
	Height                     *uint64              `xml:"height,attr"`
	Codecs                     *string              `xml:"codecs,attr"`
	FramePackings              []*Descriptor        `xml:"framePacking,omitempty"`
	AudioChannelConfigurations []*Descriptor        `xml:"AudioChannelConfiguration,omitempty"`
	InbandEventStreams         []*EventStream       `xml:"InbandEventStream,omitempty"`
	BaseURL                    []*BaseURL           `xml:"BaseURL,omitempty"`
	SubRepresentations         []*SubRepresentation `xml:"SubRepresentation,omitempty"`
	SegmentBase                *SegmentBase         `xml:"SegmentBase,omitempty"`
	EssentialProperties        []*Descriptor        `xml:"EssentialProperty,omitempty"`
	SupplementalProperties     []*Descriptor        `xml:"SupplementalProperty,omitempty"`
	SegmentList                *SegmentList         `xml:"SegmentList,omitempty"`
	ContentProtections         []*ContentProtection `xml:"ContentProtection,omitempty"`
	SegmentTemplate            *SegmentTemplate     `xml:"SegmentTemplate,omitempty"`

	FrameRate              *string  `xml:"frameRate,attr"`
	AudioSamplingRate      *string  `xml:"audioSamplingRate,attr"`
	SAR                    *string  `xml:"sar,attr"`
	ScanType               *string  `xml:"scanType,attr"`
	QualityRanking         *uint64  `xml:"qualityRanking,attr"`
	DependencyId           *string  `xml:"dependencyId,attr"`
	MediaStreamStructureId *string  `xml:"mediaStreamStructureId,attr"`
	Profiles               *string  `xml:"profiles,attr"`
	MimeType               *string  `xml:"mimeType,attr"`
	SegmentProfiles        *string  `xml:"segmentProfiles,attr"`
	MaximumSapPeriod       *float64 `xml:"maximumSAPPeriod,attr"`
	StartWithSap           *uint64  `xml:"startWithSAP,attr"`
	MaxPlayoutRate         *float64 `xml:"maxPlayoutRate,attr"`
	CodingDependency       *bool    `xml:"codingDependency,attr"`
}

Representation represents XSD's RepresentationType.

type SegmentBase

type SegmentBase struct {
	Initialization           *UrlType `xml:"Initialization,omitempty"`
	RepresentationIndex      *UrlType `xml:"RepresentationIndex,omitempty"`
	Timescale                *uint64  `xml:"timescale,attr,omitempty"`
	PresentationTimeOffset   *uint64  `xml:"presentationTimeOffset,attr,omitempty"`
	IndexRange               *string  `xml:"indexRange,attr,omitempty"`
	IndexRangeExact          *bool    `xml:"indexRangeExact,attr,omitempty"`
	AvailabilityTimeOffset   *float64 `xml:"availabilityTimeOffset,attr,omitempty"`
	AvailabilityTimeComplete *bool    `xml:"availabilityTimeComplete,attr,omitempty"`
}

type SegmentList

type SegmentList struct {
	SegmentBase
	SegmentURLs []*SegmentURL `xml:"SegmentURL,omitempty"`
	Href        *string       `xml:"href,attr"`
	Actuate     *string       `xml:"actuate,attr"`
}

type SegmentTemplate

type SegmentTemplate struct {
	Duration               *uint64          `xml:"duration,attr"`
	Timescale              *uint64          `xml:"timescale,attr"`
	Media                  *string          `xml:"media,attr"`
	Initialization         *string          `xml:"initialization,attr"`
	StartNumber            *uint64          `xml:"startNumber,attr"`
	PresentationTimeOffset *uint64          `xml:"presentationTimeOffset,attr"`
	SegmentTimeline        *SegmentTimeline `xml:"SegmentTimeline,omitempty"`
}

SegmentTemplate represents XSD's SegmentTemplateType.

type SegmentTimeline

type SegmentTimeline struct {
	S []*SegmentTimelineS `xml:"S"`
}

SegmentTimeline represents XSD's SegmentTimelineType.

type SegmentTimelineS

type SegmentTimelineS struct {
	T *uint64 `xml:"t,attr"`
	D uint64  `xml:"d,attr"`
	R *int64  `xml:"r,attr"`
}

SegmentTimelineS represents XSD's SegmentTimelineType's inner S elements.

type SegmentURL

type SegmentURL struct {
	Media      *string `xml:"media,attr"`
	MediaRange *string `xml:"mediaRange,attr"`
	Index      *string `xml:"index,attr"`
	IndexRange *string `xml:"indexRange,attr"`
}

type SubRepresentation

type SubRepresentation struct {
	ID               *string `xml:"id,attr,omitempty"`
	Level            *int64  `xml:"level,attr,omitempty"`
	DependencyLevel  *string `xml:"dependencyLevel,attr,omitempty"`
	Bandwidth        *int64  `xml:"bandwidth,attr,omitempty"`
	ContentComponent *string `xml:"contentComponent,attr,omitempty"`
}

type Subset

type Subset struct {
	Contains []int64 `xml:"contains,attr"`
	ID       *string `xml:"id,attr"`
}

type UrlType

type UrlType struct {
	Value     string  `xml:",chardata"`
	SourceURL *string `xml:"sourceURL,attr"`
	Range     *string `xml:"range,attr"`
}

type UtcTiming

type UtcTiming struct {
	ID          *string `xml:"id,attr"`
	Value       *string `xml:"value,attr"`
	SchemeIDURI *string `xml:"schemeIdUri,attr"`
}

Jump to

Keyboard shortcuts

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