mpd

package module
Version: v0.0.0-...-f633ce4 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2020 License: MIT Imports: 7 Imported by: 0

README

Build Status gocover Go Report Card GoDoc

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/unki2aut/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 {
	MimeType                string           `xml:"mimeType,attr"`
	ContentType             *string          `xml:"contentType,attr"`
	SegmentAlignment        ConditionalUint  `xml:"segmentAlignment,attr"`
	SubsegmentAlignment     ConditionalUint  `xml:"subsegmentAlignment,attr"`
	StartWithSAP            ConditionalUint  `xml:"startWithSAP,attr"`
	SubsegmentStartsWithSAP ConditionalUint  `xml:"subsegmentStartsWithSAP,attr"`
	BitstreamSwitching      *bool            `xml:"bitstreamSwitching,attr"`
	Lang                    *string          `xml:"lang,attr"`
	Par                     *string          `xml:"par,attr"`
	Codecs                  *string          `xml:"codecs,attr"`
	Role                    []*Descriptor    `xml:"Role,omitempty"`
	BaseURL                 []*BaseURL       `xml:"BaseURL,omitempty"`
	SegmentTemplate         *SegmentTemplate `xml:"SegmentTemplate,omitempty"`
	ContentProtections      []Descriptor     `xml:"ContentProtection,omitempty"`
	Representations         []Representation `xml:"Representation,omitempty"`
}

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 Descriptor

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

Descriptor represents XSD's DescriptorType.

type MPD

type MPD struct {
	XMLNS                      *string       `xml:"xmlns,attr"`
	Type                       *string       `xml:"type,attr"`
	MinimumUpdatePeriod        *xsd.Duration `xml:"minimumUpdatePeriod,attr"`
	AvailabilityStartTime      *xsd.DateTime `xml:"availabilityStartTime,attr"`
	AvailabilityEndTime        *xsd.DateTime `xml:"availabilityEndTime,attr"`
	MediaPresentationDuration  *xsd.Duration `xml:"mediaPresentationDuration,attr"`
	MinBufferTime              *xsd.Duration `xml:"minBufferTime,attr"`
	SuggestedPresentationDelay *xsd.Duration `xml:"suggestedPresentationDelay,attr"`
	TimeShiftBufferDepth       *xsd.Duration `xml:"timeShiftBufferDepth,attr"`
	PublishTime                *xsd.DateTime `xml:"publishTime,attr"`
	Profiles                   string        `xml:"profiles,attr"`
	BaseURL                    []*BaseURL    `xml:"BaseURL,omitempty"`
	Period                     []*Period     `xml:"Period,omitempty"`
}

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 Period

type Period struct {
	Start          *xsd.Duration    `xml:"start,attr"`
	ID             *string          `xml:"id,attr"`
	Duration       *xsd.Duration    `xml:"duration,attr"`
	AdaptationSets []*AdaptationSet `xml:"AdaptationSet,omitempty"`
	BaseURL        []*BaseURL       `xml:"BaseURL,omitempty"`
}

Period represents XSD's PeriodType.

type Representation

type Representation struct {
	ID                 *string          `xml:"id,attr"`
	Width              *uint64          `xml:"width,attr"`
	Height             *uint64          `xml:"height,attr"`
	FrameRate          *string          `xml:"frameRate,attr"`
	Bandwidth          *uint64          `xml:"bandwidth,attr"`
	AudioSamplingRate  *string          `xml:"audioSamplingRate,attr"`
	Codecs             *string          `xml:"codecs,attr"`
	SAR                *string          `xml:"sar,attr"`
	ScanType           *string          `xml:"scanType,attr"`
	ContentProtections []Descriptor     `xml:"ContentProtection,omitempty"`
	SegmentTemplate    *SegmentTemplate `xml:"SegmentTemplate,omitempty"`
	BaseURL            []*BaseURL       `xml:"BaseURL,omitempty"`
}

Representation represents XSD's RepresentationType.

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.

Jump to

Keyboard shortcuts

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