diff --git a/.circleci/config.yml b/.circleci/config.yml index 5aa178c..f8b6ee8 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,50 +1,26 @@ --- version: 2 -executorType: docker -containerInfo: - - image: library/golang - environment: - AWS_ACCESS_KEY_ID: 1 - AWS_SECRET_ACCESS_KEY: 1 - GLIDE_VERSION: 0.12.3 jobs: build: - workdir: "/go/src/github.com/zencoder/go-dash" + docker: + - image: circleci/golang + working_directory: "/go/src/github.com/zencoder/go-dash" steps: - checkout - run: name: Install Glide command: | set -eux - curl -sSLfO https://github.com/Masterminds/glide/releases/download/v${GLIDE_VERSION}/glide-v${GLIDE_VERSION}-linux-amd64.tar.gz - mkdir glide - tar -xzf glide-v${GLIDE_VERSION}-linux-amd64.tar.gz -C ./glide - cp ./glide/linux-amd64/glide /usr/local/bin/glide - rm -r glide glide-v${GLIDE_VERSION}-linux-amd64.tar.gz + curl -sSLfO https://github.com/Masterminds/glide/releases/download/v0.12.3/glide-v0.12.3-linux-amd64.tar.gz + mkdir -p /go/bin glide + tar -xzf glide-v0.12.3-linux-amd64.tar.gz -C ./glide + cp ./glide/linux-amd64/glide /go/bin/glide + rm -rf glide glide-v0.12.3-linux-amd64.tar.gz - restore_cache: key: glide-{{ checksum "glide.lock" }} - - run: - name: Download vendored Go dependencies - command: glide install + - run: /go/bin/glide install - save_cache: key: glide-{{ checksum "glide.lock" }} paths: - vendor - - run: - name: Install required tooling - command: | - go get golang.org/x/tools/cmd/cover - go get github.com/mattn/goveralls - go get github.com/modocache/gover - - run: - name: Run unit tests - command: | - make test - - run: - name: Collect coverage reports - command: | - make cover - - run: - name: Submit coverage to coveralls.io - command: | - make coveralls + - run: make test diff --git a/Makefile b/Makefile index 0d3d8c7..3857362 100644 --- a/Makefile +++ b/Makefile @@ -1,41 +1,31 @@ -COVERAGEDIR = coverage -ifdef CIRCLE_ARTIFACTS - COVERAGEDIR = $(CIRCLE_ARTIFACTS) -endif - ifdef VERBOSE V = -v +X = -x else .SILENT: endif -all: test cover +.DEFAULT_GOAL := all -fmt: - find . -not -path "./vendor/*" -name '*.go' -type f | sed 's#\(.*\)/.*#\1#' | sort -u | xargs -n1 -I {} bash -c "cd {} && goimports -w *.go && gofmt -w -s -l *.go" +.PHONY: all +all: test -test: - mkdir -p coverage - go test $(V) ./mpd -race -cover -coverprofile=$(COVERAGEDIR)/mpd.coverprofile +vendor: + glide install -cover: - go tool cover -html=$(COVERAGEDIR)/mpd.coverprofile -o $(COVERAGEDIR)/mpd.html +.PHONY: test +test: vendor + go test $(V) ./... -race -tc: test cover +.PHONY: generate +generate: vendor + GENERATE_FIXTURES=true $(MAKE) test -coveralls: - gover $(COVERAGEDIR) $(COVERAGEDIR)/coveralls.coverprofile - goveralls -coverprofile=$(COVERAGEDIR)/coveralls.coverprofile -service=circle-ci -repotoken=$(COVERALLS_TOKEN) +.PHONY: fmt +fmt: + find . -not -path "./vendor/*" -name '*.go' -type f | sed 's#\(.*\)/.*#\1#' | sort -u | xargs -n1 -I {} bash -c "cd {} && goimports -w *.go && gofmt -w -s -l *.go" +.PHONY: clean clean: - go clean - rm -rf coverage/ - -examples-live: - go run examples/live.go - -examples-ondemand: - go run examples/ondemand.go - -generate: - GENERATE_FIXTURES=true $(MAKE) test + rm -rf vendor/ + go clean -i $(X) -cache -testcache diff --git a/README.md b/README.md index 1bc429d..89887f0 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,11 @@ -# go-dash +# go-dash [![godoc](https://godoc.org/github.com/zencoder/go-dash/mpd?status.svg)](http://godoc.org/github.com/zencoder/go-dash/mpd) -[![godoc](https://godoc.org/github.com/zencoder/go-dash/mpd?status.svg)](http://godoc.org/github.com/zencoder/go-dash/mpd) - -A Go library for generating MPEG-DASH manifests. +A [Go](https://golang.org) library for generating [MPEG-DASH](https://en.wikipedia.org/wiki/Dynamic_Adaptive_Streaming_over_HTTP) manifests. ## Install -This library uses [Glide](https://github.com/Masterminds/glide) to manage it's dependencies. Please refer to the Glide documentation to see how to install glide. - -```bash -mkdir -p $GOPATH/src/github.com/zencoder -cd $GOPATH/src/github.com/zencoder -git clone https://github.com/zencoder/go-dash -cd go-dash -glide install -go install ./... +``` +go get -u github.com/zencoder/go-dash ``` ## Supported Features @@ -38,31 +29,17 @@ go install ./... ## Example Usage -See [examples/](https://github.com/zencoder/go-dash/tree/master/examples) +See the [examples/](https://github.com/zencoder/go-dash/tree/master/examples) directory. -To run (Live Profile example): -``` -make examples-live -``` +## Development -To run (OnDemand Profile example): ``` -make examples-ondemand +make test ``` -## Development - -### Dependencies - -Tested on go 1.9.2. - -### Build and run unit tests - - make test - ### CI -[This library builds on Circle CI, here.](https://circleci.com/gh/zencoder/go-dash/) +[This project builds in Circle CI](https://circleci.com/gh/zencoder/go-dash/) ## License diff --git a/examples/live.go b/examples/live.go index 3fcba0d..f3be132 100644 --- a/examples/live.go +++ b/examples/live.go @@ -6,34 +6,29 @@ import ( "github.com/zencoder/go-dash/mpd" ) -func main() { - +func exampleLive() { m := mpd.NewMPD(mpd.DASH_PROFILE_LIVE, "PT6M16S", "PT1.97S") audioAS, _ := m.AddNewAdaptationSetAudio(mpd.DASH_MIME_TYPE_AUDIO_MP4, true, 1, "und") - - audioAS.AddNewContentProtectionRoot("08e367028f33436ca5dd60ffe5571e60") - audioAS.AddNewContentProtectionSchemeWidevineWithPSSH() - audioAS.AddNewContentProtectionSchemePlayready("mgIAAAEAAQCQAjwAVwBSAE0ASABFAEEARABFAFIAIAB4AG0AbABuAHMAPQAiAGgAdAB0AHAAOgAvAC8AcwBjAGgAZQBtAGEAcwAuAG0AaQBjAHIAbwBzAG8AZgB0AC4AYwBvAG0ALwBEAFIATQAvADIAMAAwADcALwAwADMALwBQAGwAYQB5AFIAZQBhAGQAeQBIAGUAYQBkAGUAcgAiACAAdgBlAHIAcwBpAG8AbgA9ACIANAAuADAALgAwAC4AMAAiAD4APABEAEEAVABBAD4APABQAFIATwBUAEUAQwBUAEkATgBGAE8APgA8AEsARQBZAEwARQBOAD4AMQA2ADwALwBLAEUAWQBMAEUATgA+ADwAQQBMAEcASQBEAD4AQQBFAFMAQwBUAFIAPAAvAEEATABHAEkARAA+ADwALwBQAFIATwBUAEUAQwBUAEkATgBGAE8APgA8AEsASQBEAD4AQQBtAGYAagBDAFQATwBQAGIARQBPAGwAMwBXAEQALwA1AG0AYwBlAGMAQQA9AD0APAAvAEsASQBEAD4APABDAEgARQBDAEsAUwBVAE0APgBCAEcAdwAxAGEAWQBaADEAWQBYAE0APQA8AC8AQwBIAEUAQwBLAFMAVQBNAD4APABMAEEAXwBVAFIATAA+AGgAdAB0AHAAOgAvAC8AcABsAGEAeQByAGUAYQBkAHkALgBkAGkAcgBlAGMAdAB0AGEAcABzAC4AbgBlAHQALwBwAHIALwBzAHYAYwAvAHIAaQBnAGgAdABzAG0AYQBuAGEAZwBlAHIALgBhAHMAbQB4ADwALwBMAEEAXwBVAFIATAA+ADwALwBEAEEAVABBAD4APAAvAFcAUgBNAEgARQBBAEQARQBSAD4A") - - audioAS.SetNewSegmentTemplate(1968, "$RepresentationID$/audio/en/init.mp4", "$RepresentationID$/audio/en/seg-$Number$.m4f", 0, 1000) - audioAS.AddNewRepresentationAudio(44100, 67095, "mp4a.40.2", "800") + _, _ = audioAS.AddNewContentProtectionRoot("08e367028f33436ca5dd60ffe5571e60") + _, _ = audioAS.AddNewContentProtectionSchemeWidevineWithPSSH([]byte{}) + _, _ = audioAS.AddNewContentProtectionSchemePlayready("mgIAAAEAAQCQAjwAVwBSAE0ASABFAEEARABFAFIAIAB4AG0AbABuAHMAPQAiAGgAdAB0AHAAOgAvAC8AcwBjAGgAZQBtAGEAcwAuAG0AaQBjAHIAbwBzAG8AZgB0AC4AYwBvAG0ALwBEAFIATQAvADIAMAAwADcALwAwADMALwBQAGwAYQB5AFIAZQBhAGQAeQBIAGUAYQBkAGUAcgAiACAAdgBlAHIAcwBpAG8AbgA9ACIANAAuADAALgAwAC4AMAAiAD4APABEAEEAVABBAD4APABQAFIATwBUAEUAQwBUAEkATgBGAE8APgA8AEsARQBZAEwARQBOAD4AMQA2ADwALwBLAEUAWQBMAEUATgA+ADwAQQBMAEcASQBEAD4AQQBFAFMAQwBUAFIAPAAvAEEATABHAEkARAA+ADwALwBQAFIATwBUAEUAQwBUAEkATgBGAE8APgA8AEsASQBEAD4AQQBtAGYAagBDAFQATwBQAGIARQBPAGwAMwBXAEQALwA1AG0AYwBlAGMAQQA9AD0APAAvAEsASQBEAD4APABDAEgARQBDAEsAUwBVAE0APgBCAEcAdwAxAGEAWQBaADEAWQBYAE0APQA8AC8AQwBIAEUAQwBLAFMAVQBNAD4APABMAEEAXwBVAFIATAA+AGgAdAB0AHAAOgAvAC8AcABsAGEAeQByAGUAYQBkAHkALgBkAGkAcgBlAGMAdAB0AGEAcABzAC4AbgBlAHQALwBwAHIALwBzAHYAYwAvAHIAaQBnAGgAdABzAG0AYQBuAGEAZwBlAHIALgBhAHMAbQB4ADwALwBMAEEAXwBVAFIATAA+ADwALwBEAEEAVABBAD4APAAvAFcAUgBNAEgARQBBAEQARQBSAD4A") + _, _ = audioAS.SetNewSegmentTemplate(1968, "$RepresentationID$/audio/en/init.mp4", "$RepresentationID$/audio/en/seg-$Number$.m4f", 0, 1000) + _, _ = audioAS.AddNewRepresentationAudio(44100, 67095, "mp4a.40.2", "800") videoAS, _ := m.AddNewAdaptationSetVideo(mpd.DASH_MIME_TYPE_VIDEO_MP4, "progressive", true, 1) - - videoAS.AddNewContentProtectionRoot("08e367028f33436ca5dd60ffe5571e60") - videoAS.AddNewContentProtectionSchemeWidevineWithPSSH() - videoAS.AddNewContentProtectionSchemePlayready("mgIAAAEAAQCQAjwAVwBSAE0ASABFAEEARABFAFIAIAB4AG0AbABuAHMAPQAiAGgAdAB0AHAAOgAvAC8AcwBjAGgAZQBtAGEAcwAuAG0AaQBjAHIAbwBzAG8AZgB0AC4AYwBvAG0ALwBEAFIATQAvADIAMAAwADcALwAwADMALwBQAGwAYQB5AFIAZQBhAGQAeQBIAGUAYQBkAGUAcgAiACAAdgBlAHIAcwBpAG8AbgA9ACIANAAuADAALgAwAC4AMAAiAD4APABEAEEAVABBAD4APABQAFIATwBUAEUAQwBUAEkATgBGAE8APgA8AEsARQBZAEwARQBOAD4AMQA2ADwALwBLAEUAWQBMAEUATgA+ADwAQQBMAEcASQBEAD4AQQBFAFMAQwBUAFIAPAAvAEEATABHAEkARAA+ADwALwBQAFIATwBUAEUAQwBUAEkATgBGAE8APgA8AEsASQBEAD4AQQBtAGYAagBDAFQATwBQAGIARQBPAGwAMwBXAEQALwA1AG0AYwBlAGMAQQA9AD0APAAvAEsASQBEAD4APABDAEgARQBDAEsAUwBVAE0APgBCAEcAdwAxAGEAWQBaADEAWQBYAE0APQA8AC8AQwBIAEUAQwBLAFMAVQBNAD4APABMAEEAXwBVAFIATAA+AGgAdAB0AHAAOgAvAC8AcABsAGEAeQByAGUAYQBkAHkALgBkAGkAcgBlAGMAdAB0AGEAcABzAC4AbgBlAHQALwBwAHIALwBzAHYAYwAvAHIAaQBnAGgAdABzAG0AYQBuAGEAZwBlAHIALgBhAHMAbQB4ADwALwBMAEEAXwBVAFIATAA+ADwALwBEAEEAVABBAD4APAAvAFcAUgBNAEgARQBBAEQARQBSAD4A") - - videoAS.SetNewSegmentTemplate(1968, "$RepresentationID$/video/1/init.mp4", "$RepresentationID$/video/1/seg-$Number$.m4f", 0, 1000) - videoAS.AddNewRepresentationVideo(1518664, "avc1.4d401f", "800", "30000/1001", 960, 540) - videoAS.AddNewRepresentationVideo(1911775, "avc1.4d401f", "1000", "30000/1001", 1024, 576) - videoAS.AddNewRepresentationVideo(2295158, "avc1.4d401f", "1200", "30000/1001", 1024, 576) - videoAS.AddNewRepresentationVideo(2780732, "avc1.4d401f", "1500", "30000/1001", 1280, 720) + _, _ = videoAS.AddNewContentProtectionRoot("08e367028f33436ca5dd60ffe5571e60") + _, _ = videoAS.AddNewContentProtectionSchemeWidevineWithPSSH([]byte{}) + _, _ = videoAS.AddNewContentProtectionSchemePlayready("mgIAAAEAAQCQAjwAVwBSAE0ASABFAEEARABFAFIAIAB4AG0AbABuAHMAPQAiAGgAdAB0AHAAOgAvAC8AcwBjAGgAZQBtAGEAcwAuAG0AaQBjAHIAbwBzAG8AZgB0AC4AYwBvAG0ALwBEAFIATQAvADIAMAAwADcALwAwADMALwBQAGwAYQB5AFIAZQBhAGQAeQBIAGUAYQBkAGUAcgAiACAAdgBlAHIAcwBpAG8AbgA9ACIANAAuADAALgAwAC4AMAAiAD4APABEAEEAVABBAD4APABQAFIATwBUAEUAQwBUAEkATgBGAE8APgA8AEsARQBZAEwARQBOAD4AMQA2ADwALwBLAEUAWQBMAEUATgA+ADwAQQBMAEcASQBEAD4AQQBFAFMAQwBUAFIAPAAvAEEATABHAEkARAA+ADwALwBQAFIATwBUAEUAQwBUAEkATgBGAE8APgA8AEsASQBEAD4AQQBtAGYAagBDAFQATwBQAGIARQBPAGwAMwBXAEQALwA1AG0AYwBlAGMAQQA9AD0APAAvAEsASQBEAD4APABDAEgARQBDAEsAUwBVAE0APgBCAEcAdwAxAGEAWQBaADEAWQBYAE0APQA8AC8AQwBIAEUAQwBLAFMAVQBNAD4APABMAEEAXwBVAFIATAA+AGgAdAB0AHAAOgAvAC8AcABsAGEAeQByAGUAYQBkAHkALgBkAGkAcgBlAGMAdAB0AGEAcABzAC4AbgBlAHQALwBwAHIALwBzAHYAYwAvAHIAaQBnAGgAdABzAG0AYQBuAGEAZwBlAHIALgBhAHMAbQB4ADwALwBMAEEAXwBVAFIATAA+ADwALwBEAEEAVABBAD4APAAvAFcAUgBNAEgARQBBAEQARQBSAD4A") + _, _ = videoAS.SetNewSegmentTemplate(1968, "$RepresentationID$/video/1/init.mp4", "$RepresentationID$/video/1/seg-$Number$.m4f", 0, 1000) + _, _ = videoAS.AddNewRepresentationVideo(1518664, "avc1.4d401f", "800", "30000/1001", 960, 540) + _, _ = videoAS.AddNewRepresentationVideo(1911775, "avc1.4d401f", "1000", "30000/1001", 1024, 576) + _, _ = videoAS.AddNewRepresentationVideo(2295158, "avc1.4d401f", "1200", "30000/1001", 1024, 576) + _, _ = videoAS.AddNewRepresentationVideo(2780732, "avc1.4d401f", "1500", "30000/1001", 1280, 720) subtitleAS, _ := m.AddNewAdaptationSetSubtitle(mpd.DASH_MIME_TYPE_SUBTITLE_VTT, "en") subtitleRep, _ := subtitleAS.AddNewRepresentationSubtitle(256, "subtitle_en") - subtitleRep.SetNewBaseURL("http://example.com/content/sintel/subtitles/subtitles_en.vtt") + _ = subtitleRep.SetNewBaseURL("http://example.com/content/sintel/subtitles/subtitles_en.vtt") mpdStr, _ := m.WriteToString() fmt.Println(mpdStr) diff --git a/examples/live.mpd b/examples/live.mpd index 566d539..dc26c93 100644 --- a/examples/live.mpd +++ b/examples/live.mpd @@ -29,4 +29,3 @@ - diff --git a/examples/ondemand.go b/examples/ondemand.go index fde78f9..ca1326f 100644 --- a/examples/ondemand.go +++ b/examples/ondemand.go @@ -6,36 +6,34 @@ import ( "github.com/zencoder/go-dash/mpd" ) -func main() { +func exampleOndemand() { m := mpd.NewMPD(mpd.DASH_PROFILE_ONDEMAND, "PT30S", "PT1.97S") audioAS, _ := m.AddNewAdaptationSetAudio(mpd.DASH_MIME_TYPE_AUDIO_MP4, true, 1, "und") - - audioAS.AddNewContentProtectionRoot("08e367028f33436ca5dd60ffe5571e60") - audioAS.AddNewContentProtectionSchemeWidevineWithPSSH() - audioAS.AddNewContentProtectionSchemePlayready("mgIAAAEAAQCQAjwAVwBSAE0ASABFAEEARABFAFIAIAB4AG0AbABuAHMAPQAiAGgAdAB0AHAAOgAvAC8AcwBjAGgAZQBtAGEAcwAuAG0AaQBjAHIAbwBzAG8AZgB0AC4AYwBvAG0ALwBEAFIATQAvADIAMAAwADcALwAwADMALwBQAGwAYQB5AFIAZQBhAGQAeQBIAGUAYQBkAGUAcgAiACAAdgBlAHIAcwBpAG8AbgA9ACIANAAuADAALgAwAC4AMAAiAD4APABEAEEAVABBAD4APABQAFIATwBUAEUAQwBUAEkATgBGAE8APgA8AEsARQBZAEwARQBOAD4AMQA2ADwALwBLAEUAWQBMAEUATgA+ADwAQQBMAEcASQBEAD4AQQBFAFMAQwBUAFIAPAAvAEEATABHAEkARAA+ADwALwBQAFIATwBUAEUAQwBUAEkATgBGAE8APgA8AEsASQBEAD4AQQBtAGYAagBDAFQATwBQAGIARQBPAGwAMwBXAEQALwA1AG0AYwBlAGMAQQA9AD0APAAvAEsASQBEAD4APABDAEgARQBDAEsAUwBVAE0APgBCAEcAdwAxAGEAWQBaADEAWQBYAE0APQA8AC8AQwBIAEUAQwBLAFMAVQBNAD4APABMAEEAXwBVAFIATAA+AGgAdAB0AHAAOgAvAC8AcABsAGEAeQByAGUAYQBkAHkALgBkAGkAcgBlAGMAdAB0AGEAcABzAC4AbgBlAHQALwBwAHIALwBzAHYAYwAvAHIAaQBnAGgAdABzAG0AYQBuAGEAZwBlAHIALgBhAHMAbQB4ADwALwBMAEEAXwBVAFIATAA+ADwALwBEAEEAVABBAD4APAAvAFcAUgBNAEgARQBBAEQARQBSAD4A") + _, _ = audioAS.AddNewContentProtectionRoot("08e367028f33436ca5dd60ffe5571e60") + _, _ = audioAS.AddNewContentProtectionSchemeWidevineWithPSSH([]byte{}) + _, _ = audioAS.AddNewContentProtectionSchemePlayready("mgIAAAEAAQCQAjwAVwBSAE0ASABFAEEARABFAFIAIAB4AG0AbABuAHMAPQAiAGgAdAB0AHAAOgAvAC8AcwBjAGgAZQBtAGEAcwAuAG0AaQBjAHIAbwBzAG8AZgB0AC4AYwBvAG0ALwBEAFIATQAvADIAMAAwADcALwAwADMALwBQAGwAYQB5AFIAZQBhAGQAeQBIAGUAYQBkAGUAcgAiACAAdgBlAHIAcwBpAG8AbgA9ACIANAAuADAALgAwAC4AMAAiAD4APABEAEEAVABBAD4APABQAFIATwBUAEUAQwBUAEkATgBGAE8APgA8AEsARQBZAEwARQBOAD4AMQA2ADwALwBLAEUAWQBMAEUATgA+ADwAQQBMAEcASQBEAD4AQQBFAFMAQwBUAFIAPAAvAEEATABHAEkARAA+ADwALwBQAFIATwBUAEUAQwBUAEkATgBGAE8APgA8AEsASQBEAD4AQQBtAGYAagBDAFQATwBQAGIARQBPAGwAMwBXAEQALwA1AG0AYwBlAGMAQQA9AD0APAAvAEsASQBEAD4APABDAEgARQBDAEsAUwBVAE0APgBCAEcAdwAxAGEAWQBaADEAWQBYAE0APQA8AC8AQwBIAEUAQwBLAFMAVQBNAD4APABMAEEAXwBVAFIATAA+AGgAdAB0AHAAOgAvAC8AcABsAGEAeQByAGUAYQBkAHkALgBkAGkAcgBlAGMAdAB0AGEAcABzAC4AbgBlAHQALwBwAHIALwBzAHYAYwAvAHIAaQBnAGgAdABzAG0AYQBuAGEAZwBlAHIALgBhAHMAbQB4ADwALwBMAEEAXwBVAFIATAA+ADwALwBEAEEAVABBAD4APAAvAFcAUgBNAEgARQBBAEQARQBSAD4A") audioRep, _ := audioAS.AddNewRepresentationAudio(44100, 128558, "mp4a.40.5", "800k/audio-und") - audioRep.SetNewBaseURL("800k/output-audio-und.mp4") - audioRep.AddNewSegmentBase("629-756", "0-628") + _ = audioRep.SetNewBaseURL("800k/output-audio-und.mp4") + _, _ = audioRep.AddNewSegmentBase("629-756", "0-628") videoAS, _ := m.AddNewAdaptationSetVideo(mpd.DASH_MIME_TYPE_VIDEO_MP4, "progressive", true, 1) - - videoAS.AddNewContentProtectionRoot("08e367028f33436ca5dd60ffe5571e60") - videoAS.AddNewContentProtectionSchemeWidevineWithPSSH() - videoAS.AddNewContentProtectionSchemePlayready("mgIAAAEAAQCQAjwAVwBSAE0ASABFAEEARABFAFIAIAB4AG0AbABuAHMAPQAiAGgAdAB0AHAAOgAvAC8AcwBjAGgAZQBtAGEAcwAuAG0AaQBjAHIAbwBzAG8AZgB0AC4AYwBvAG0ALwBEAFIATQAvADIAMAAwADcALwAwADMALwBQAGwAYQB5AFIAZQBhAGQAeQBIAGUAYQBkAGUAcgAiACAAdgBlAHIAcwBpAG8AbgA9ACIANAAuADAALgAwAC4AMAAiAD4APABEAEEAVABBAD4APABQAFIATwBUAEUAQwBUAEkATgBGAE8APgA8AEsARQBZAEwARQBOAD4AMQA2ADwALwBLAEUAWQBMAEUATgA+ADwAQQBMAEcASQBEAD4AQQBFAFMAQwBUAFIAPAAvAEEATABHAEkARAA+ADwALwBQAFIATwBUAEUAQwBUAEkATgBGAE8APgA8AEsASQBEAD4AQQBtAGYAagBDAFQATwBQAGIARQBPAGwAMwBXAEQALwA1AG0AYwBlAGMAQQA9AD0APAAvAEsASQBEAD4APABDAEgARQBDAEsAUwBVAE0APgBCAEcAdwAxAGEAWQBaADEAWQBYAE0APQA8AC8AQwBIAEUAQwBLAFMAVQBNAD4APABMAEEAXwBVAFIATAA+AGgAdAB0AHAAOgAvAC8AcABsAGEAeQByAGUAYQBkAHkALgBkAGkAcgBlAGMAdAB0AGEAcABzAC4AbgBlAHQALwBwAHIALwBzAHYAYwAvAHIAaQBnAGgAdABzAG0AYQBuAGEAZwBlAHIALgBhAHMAbQB4ADwALwBMAEEAXwBVAFIATAA+ADwALwBEAEEAVABBAD4APAAvAFcAUgBNAEgARQBBAEQARQBSAD4A") + _, _ = videoAS.AddNewContentProtectionRoot("08e367028f33436ca5dd60ffe5571e60") + _, _ = videoAS.AddNewContentProtectionSchemeWidevineWithPSSH([]byte{}) + _, _ = videoAS.AddNewContentProtectionSchemePlayready("mgIAAAEAAQCQAjwAVwBSAE0ASABFAEEARABFAFIAIAB4AG0AbABuAHMAPQAiAGgAdAB0AHAAOgAvAC8AcwBjAGgAZQBtAGEAcwAuAG0AaQBjAHIAbwBzAG8AZgB0AC4AYwBvAG0ALwBEAFIATQAvADIAMAAwADcALwAwADMALwBQAGwAYQB5AFIAZQBhAGQAeQBIAGUAYQBkAGUAcgAiACAAdgBlAHIAcwBpAG8AbgA9ACIANAAuADAALgAwAC4AMAAiAD4APABEAEEAVABBAD4APABQAFIATwBUAEUAQwBUAEkATgBGAE8APgA8AEsARQBZAEwARQBOAD4AMQA2ADwALwBLAEUAWQBMAEUATgA+ADwAQQBMAEcASQBEAD4AQQBFAFMAQwBUAFIAPAAvAEEATABHAEkARAA+ADwALwBQAFIATwBUAEUAQwBUAEkATgBGAE8APgA8AEsASQBEAD4AQQBtAGYAagBDAFQATwBQAGIARQBPAGwAMwBXAEQALwA1AG0AYwBlAGMAQQA9AD0APAAvAEsASQBEAD4APABDAEgARQBDAEsAUwBVAE0APgBCAEcAdwAxAGEAWQBaADEAWQBYAE0APQA8AC8AQwBIAEUAQwBLAFMAVQBNAD4APABMAEEAXwBVAFIATAA+AGgAdAB0AHAAOgAvAC8AcABsAGEAeQByAGUAYQBkAHkALgBkAGkAcgBlAGMAdAB0AGEAcABzAC4AbgBlAHQALwBwAHIALwBzAHYAYwAvAHIAaQBnAGgAdABzAG0AYQBuAGEAZwBlAHIALgBhAHMAbQB4ADwALwBMAEEAXwBVAFIATAA+ADwALwBEAEEAVABBAD4APAAvAFcAUgBNAEgARQBBAEQARQBSAD4A") videoRep1, _ := videoAS.AddNewRepresentationVideo(1100690, "avc1.4d401e", "800k/video-1", "30000/1001", 640, 360) - videoRep1.SetNewBaseURL("800k/output-video-1.mp4") - videoRep1.AddNewSegmentBase("686-813", "0-685") + _ = videoRep1.SetNewBaseURL("800k/output-video-1.mp4") + _, _ = videoRep1.AddNewSegmentBase("686-813", "0-685") videoRep2, _ := videoAS.AddNewRepresentationVideo(1633516, "avc1.4d401f", "1200k/video-1", "30000/1001", 960, 540) - videoRep2.SetNewBaseURL("1200k/output-video-1.mp4") - videoRep2.AddNewSegmentBase("686-813", "0-685") + _ = videoRep2.SetNewBaseURL("1200k/output-video-1.mp4") + _, _ = videoRep2.AddNewSegmentBase("686-813", "0-685") subtitleAS, _ := m.AddNewAdaptationSetSubtitle(mpd.DASH_MIME_TYPE_SUBTITLE_VTT, "en") subtitleRep, _ := subtitleAS.AddNewRepresentationSubtitle(256, "captions_en") - subtitleRep.SetNewBaseURL("http://example.com/content/sintel/subtitles/subtitles_en.vtt") + _ = subtitleRep.SetNewBaseURL("http://example.com/content/sintel/subtitles/subtitles_en.vtt") mpdStr, _ := m.WriteToString() fmt.Println(mpdStr) diff --git a/examples/ondemand.mpd b/examples/ondemand.mpd index bfb1528..8798100 100644 --- a/examples/ondemand.mpd +++ b/examples/ondemand.mpd @@ -1,4 +1,3 @@ -go run examples/ondemand.go @@ -41,4 +40,3 @@ go run examples/ondemand.go - diff --git a/glide.lock b/glide.lock index 266b209..c25466f 100644 --- a/glide.lock +++ b/glide.lock @@ -1,18 +1,17 @@ -hash: 03a3a0f3a893e72bb8006477779f714f09db0bb5559af0d8c836e334d8506061 -updated: 2017-08-11T10:19:07.010912144-07:00 +hash: fa28369eecce691920c5e11d3c66f10a46cf5875614aacda800ca66099ba95cd +updated: 2019-01-08T14:40:31.686615Z imports: -- name: github.com/stretchr/testify - version: 890a5c3458b43e6104ff5da8dfa139d013d77544 - subpackages: - - assert - - require - - suite -testImports: - name: github.com/davecgh/go-spew - version: 04cdfd42973bb9c8589fd6a731800cf222fde1a9 + version: 8991bc29aa16c548c550c7ff78260e27b9ab7c73 subpackages: - spew - name: github.com/pmezard/go-difflib - version: d8ed2627bdf02c080bf22230dbb337003b7aba2d + version: 792786c7400a136282c1664665ae0a8db921c6c2 subpackages: - difflib +- name: github.com/stretchr/testify + version: ffdc059bfe9ce6a4e144ba849dbedead332c6053 + subpackages: + - assert + - require +testImports: [] diff --git a/glide.yaml b/glide.yaml index fdd8d6f..03445c8 100644 --- a/glide.yaml +++ b/glide.yaml @@ -1,4 +1,6 @@ package: github.com/zencoder/go-dash import: - - package: github.com/stretchr/testify - version: 890a5c3458b43e6104ff5da8dfa139d013d77544 +- package: github.com/stretchr/testify + version: ^1.3.0 + subpackages: + - require diff --git a/helpers/testfixtures/testfixtures.go b/helpers/testfixtures/testfixtures.go index 7f08d2d..e8298ab 100644 --- a/helpers/testfixtures/testfixtures.go +++ b/helpers/testfixtures/testfixtures.go @@ -21,9 +21,9 @@ func LoadFixture(path string) (js string) { func CompareFixture(t *testing.T, fixturePath string, actualContent string) { expectedContent := LoadFixture(fixturePath) if os.Getenv("GENERATE_FIXTURES") != "" { - ioutil.WriteFile(fixturePath, []byte(actualContent), os.ModePerm) + _ = ioutil.WriteFile(fixturePath, []byte(actualContent), os.ModePerm) fmt.Println("Wrote fixture: " + fixturePath) - } else { - require.Equal(t, expectedContent, actualContent) + return } + require.Equal(t, expectedContent, actualContent) } diff --git a/mpd/mpd.go b/mpd/mpd.go index d1e7194..e490abb 100644 --- a/mpd/mpd.go +++ b/mpd/mpd.go @@ -156,11 +156,11 @@ func (as *AdaptationSet) UnmarshalXML(d *xml.Decoder, start xml.StartElement) er var ( contentProtectionTags []ContentProtectioner - roles []*Role - segmentBase *SegmentBase - segmentList *SegmentList - segmentTemplate *SegmentTemplate - representations []*Representation + roles []*Role + segmentBase *SegmentBase + segmentList *SegmentList + segmentTemplate *SegmentTemplate + representations []*Representation ) // decode inner elements @@ -176,7 +176,7 @@ func (as *AdaptationSet) UnmarshalXML(d *xml.Decoder, start xml.StartElement) er case "ContentProtection": var ( schemeUri string - cp ContentProtectioner + cp ContentProtectioner ) for _, attr := range tt.Attr { @@ -240,7 +240,7 @@ func (as *AdaptationSet) UnmarshalXML(d *xml.Decoder, start xml.StartElement) er } case xml.EndElement: if tt == start.End() { - d.DecodeElement(&adaptationSet, &start) + _ = d.DecodeElement(&adaptationSet, &start) *as = adaptationSet as.ContentProtection = contentProtectionTags as.Roles = roles @@ -277,7 +277,8 @@ type ContentProtection struct { AdaptationSet *AdaptationSet `xml:"-"` XMLName xml.Name `xml:"ContentProtection"` SchemeIDURI *string `xml:"schemeIdUri,attr"` // Default: urn:mpeg:dash:mp4protection:2011 - XMLNS *string `xml:"cenc,attr"` // Default: urn:mpeg:cenc:2013 + XMLNS *string `xml:"cenc,attr"` // Default: urn:mpeg:cenc:2013 + Attrs []*xml.Attr `xml:",any,attr"` } type CENCContentProtection struct { @@ -303,6 +304,7 @@ type ContentProtectionMarshal struct { XMLName xml.Name `xml:"ContentProtection"` SchemeIDURI *string `xml:"schemeIdUri,attr"` // Default: urn:mpeg:dash:mp4protection:2011 XMLNS *string `xml:"xmlns:cenc,attr"` // Default: urn:mpeg:cenc:2013 + Attrs []*xml.Attr `xml:",any,attr"` } type CENCContentProtectionMarshal struct { @@ -331,6 +333,7 @@ func (s ContentProtection) MarshalXML(e *xml.Encoder, start xml.StartElement) er s.XMLName, s.SchemeIDURI, s.XMLNS, + s.Attrs, }) if err != nil { return err @@ -345,6 +348,7 @@ func (s CENCContentProtection) MarshalXML(e *xml.Encoder, start xml.StartElement s.XMLName, s.SchemeIDURI, s.XMLNS, + s.Attrs, }, s.DefaultKID, s.Value, @@ -362,6 +366,7 @@ func (s PlayreadyContentProtection) MarshalXML(e *xml.Encoder, start xml.StartEl s.XMLName, s.SchemeIDURI, s.XMLNS, + s.Attrs, }, s.PlayreadyXMLNS, s.PRO, @@ -380,6 +385,7 @@ func (s WidevineContentProtection) MarshalXML(e *xml.Encoder, start xml.StartEle s.XMLName, s.SchemeIDURI, s.XMLNS, + s.Attrs, }, s.PSSH, }) @@ -438,9 +444,9 @@ type AudioChannelConfiguration struct { func NewMPD(profile DashProfile, mediaPresentationDuration, minBufferTime string, attributes ...AttrMPD) *MPD { period := &Period{} mpd := &MPD{ - XMLNs: Strptr("urn:mpeg:dash:schema:mpd:2011"), - Profiles: Strptr((string)(profile)), - Type: Strptr("static"), + XMLNs: Strptr("urn:mpeg:dash:schema:mpd:2011"), + Profiles: Strptr((string)(profile)), + Type: Strptr("static"), MediaPresentationDuration: Strptr(mediaPresentationDuration), MinBufferTime: Strptr(minBufferTime), period: period, @@ -465,9 +471,9 @@ func NewMPD(profile DashProfile, mediaPresentationDuration, minBufferTime string func NewDynamicMPD(profile DashProfile, availabilityStartTime, minBufferTime string, attributes ...AttrMPD) *MPD { period := &Period{} mpd := &MPD{ - XMLNs: Strptr("urn:mpeg:dash:schema:mpd:2011"), - Profiles: Strptr((string)(profile)), - Type: Strptr("dynamic"), + XMLNs: Strptr("urn:mpeg:dash:schema:mpd:2011"), + Profiles: Strptr((string)(profile)), + Type: Strptr("dynamic"), AvailabilityStartTime: Strptr(availabilityStartTime), MinBufferTime: Strptr(minBufferTime), period: period, diff --git a/mpd/mpd_read_write.go b/mpd/mpd_read_write.go index 04f3228..2187c98 100644 --- a/mpd/mpd_read_write.go +++ b/mpd/mpd_read_write.go @@ -80,8 +80,8 @@ func (m *MPD) Write(w io.Writer) error { return err } - w.Write([]byte(xml.Header)) - w.Write(b) - w.Write([]byte("\n")) + _, _ = w.Write([]byte(xml.Header)) + _, _ = w.Write(b) + _, _ = w.Write([]byte("\n")) return nil } diff --git a/mpd/mpd_read_write_test.go b/mpd/mpd_read_write_test.go index e94ef73..3cc16a1 100644 --- a/mpd/mpd_read_write_test.go +++ b/mpd/mpd_read_write_test.go @@ -83,7 +83,7 @@ func TestNewMPDOnDemandWriteToString(t *testing.T) { func TestAddNewAdaptationSetAudioWriteToString(t *testing.T) { m := NewMPD(DASH_PROFILE_LIVE, VALID_MEDIA_PRESENTATION_DURATION, VALID_MIN_BUFFER_TIME) - m.AddNewAdaptationSetAudioWithID("7357", DASH_MIME_TYPE_AUDIO_MP4, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP, VALID_LANG) + _, _ = m.AddNewAdaptationSetAudioWithID("7357", DASH_MIME_TYPE_AUDIO_MP4, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP, VALID_LANG) xmlStr, err := m.WriteToString() require.Nil(t, err) @@ -100,7 +100,7 @@ func TestAddNewAdaptationSetAudioWriteToString(t *testing.T) { func TestAddNewAdaptationSetVideoWriteToString(t *testing.T) { m := NewMPD(DASH_PROFILE_LIVE, VALID_MEDIA_PRESENTATION_DURATION, VALID_MIN_BUFFER_TIME) - m.AddNewAdaptationSetVideoWithID("7357", DASH_MIME_TYPE_VIDEO_MP4, VALID_SCAN_TYPE, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP) + _, _ = m.AddNewAdaptationSetVideoWithID("7357", DASH_MIME_TYPE_VIDEO_MP4, VALID_SCAN_TYPE, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP) xmlStr, err := m.WriteToString() require.Nil(t, err) @@ -117,7 +117,7 @@ func TestAddNewAdaptationSetVideoWriteToString(t *testing.T) { func TestAddNewAdaptationSetSubtitleWriteToString(t *testing.T) { m := NewMPD(DASH_PROFILE_LIVE, VALID_MEDIA_PRESENTATION_DURATION, VALID_MIN_BUFFER_TIME) - m.AddNewAdaptationSetSubtitleWithID("7357", DASH_MIME_TYPE_SUBTITLE_VTT, VALID_LANG) + _, _ = m.AddNewAdaptationSetSubtitleWithID("7357", DASH_MIME_TYPE_SUBTITLE_VTT, VALID_LANG) xmlStr, err := m.WriteToString() require.Nil(t, err) @@ -138,20 +138,20 @@ func TestExampleAddNewPeriod(t *testing.T) { // you can add content to the Period p := m.GetCurrentPeriod() as, _ := p.AddNewAdaptationSetVideoWithID("1", DASH_MIME_TYPE_VIDEO_MP4, VALID_SCAN_TYPE, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP) - as.SetNewSegmentTemplate(1968, "$RepresentationID$/video-1.mp4", "$RepresentationID$/video-1/seg-$Number$.m4f", 0, 1000) + _, _ = as.SetNewSegmentTemplate(1968, "$RepresentationID$/video-1.mp4", "$RepresentationID$/video-1/seg-$Number$.m4f", 0, 1000) // or directly to the MPD, which will use the current Period. as, _ = m.AddNewAdaptationSetAudioWithID("1", DASH_MIME_TYPE_AUDIO_MP4, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP, VALID_LANG) - as.SetNewSegmentTemplate(1968, "$RepresentationID$/audio-1.mp4", "$RepresentationID$/audio-1/seg-$Number$.m4f", 0, 1000) + _, _ = as.SetNewSegmentTemplate(1968, "$RepresentationID$/audio-1.mp4", "$RepresentationID$/audio-1/seg-$Number$.m4f", 0, 1000) // add a second period p = m.AddNewPeriod() p.SetDuration(3 * time.Minute) as, _ = p.AddNewAdaptationSetVideoWithID("2", DASH_MIME_TYPE_VIDEO_MP4, VALID_SCAN_TYPE, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP) - as.SetNewSegmentTemplate(1968, "$RepresentationID$/video-2.mp4", "$RepresentationID$/video-2/seg-$Number$.m4f", 0, 1000) + _, _ = as.SetNewSegmentTemplate(1968, "$RepresentationID$/video-2.mp4", "$RepresentationID$/video-2/seg-$Number$.m4f", 0, 1000) as, _ = m.AddNewAdaptationSetAudioWithID("2", DASH_MIME_TYPE_AUDIO_MP4, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP, VALID_LANG) - as.SetNewSegmentTemplate(1968, "$RepresentationID$/audio-2.mp4", "$RepresentationID$/audio-2/seg-$Number$.m4f", 0, 1000) + _, _ = as.SetNewSegmentTemplate(1968, "$RepresentationID$/audio-2.mp4", "$RepresentationID$/audio-2/seg-$Number$.m4f", 0, 1000) xmlStr, err := m.WriteToString() require.Nil(t, err) @@ -164,32 +164,32 @@ func LiveProfile() *MPD { audioAS, _ := m.AddNewAdaptationSetAudioWithID("7357", DASH_MIME_TYPE_AUDIO_MP4, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP, VALID_LANG) - audioAS.AddNewContentProtectionRoot("08e367028f33436ca5dd60ffe5571e60") - audioAS.AddNewContentProtectionSchemeWidevineWithPSSH(getValidWVHeaderBytes()) - audioAS.AddNewContentProtectionSchemePlayreadyWithPSSH(VALID_PLAYREADY_PRO) + _, _ = audioAS.AddNewContentProtectionRoot("08e367028f33436ca5dd60ffe5571e60") + _, _ = audioAS.AddNewContentProtectionSchemeWidevineWithPSSH(getValidWVHeaderBytes()) + _, _ = audioAS.AddNewContentProtectionSchemePlayreadyWithPSSH(VALID_PLAYREADY_PRO) - audioAS.AddNewRole("urn:mpeg:dash:role:2011", VALID_ROLE) + _, _ = audioAS.AddNewRole("urn:mpeg:dash:role:2011", VALID_ROLE) - audioAS.SetNewSegmentTemplate(1968, "$RepresentationID$/audio/en/init.mp4", "$RepresentationID$/audio/en/seg-$Number$.m4f", 0, 1000) - audioAS.AddNewRepresentationAudio(44100, 67095, "mp4a.40.2", "800") + _, _ = audioAS.SetNewSegmentTemplate(1968, "$RepresentationID$/audio/en/init.mp4", "$RepresentationID$/audio/en/seg-$Number$.m4f", 0, 1000) + _, _ = audioAS.AddNewRepresentationAudio(44100, 67095, "mp4a.40.2", "800") videoAS, _ := m.AddNewAdaptationSetVideoWithID("7357", DASH_MIME_TYPE_VIDEO_MP4, VALID_SCAN_TYPE, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP) - videoAS.AddNewContentProtectionRoot("08e367028f33436ca5dd60ffe5571e60") - videoAS.AddNewContentProtectionSchemeWidevineWithPSSH(getValidWVHeaderBytes()) - videoAS.AddNewContentProtectionSchemePlayreadyWithPSSH(VALID_PLAYREADY_PRO) + _, _ = videoAS.AddNewContentProtectionRoot("08e367028f33436ca5dd60ffe5571e60") + _, _ = videoAS.AddNewContentProtectionSchemeWidevineWithPSSH(getValidWVHeaderBytes()) + _, _ = videoAS.AddNewContentProtectionSchemePlayreadyWithPSSH(VALID_PLAYREADY_PRO) - videoAS.AddNewRole("urn:mpeg:dash:role:2011", VALID_ROLE) + _, _ = videoAS.AddNewRole("urn:mpeg:dash:role:2011", VALID_ROLE) - videoAS.SetNewSegmentTemplate(1968, "$RepresentationID$/video/1/init.mp4", "$RepresentationID$/video/1/seg-$Number$.m4f", 0, 1000) - videoAS.AddNewRepresentationVideo(1518664, "avc1.4d401f", "800", "30000/1001", 960, 540) - videoAS.AddNewRepresentationVideo(1911775, "avc1.4d401f", "1000", "30000/1001", 1024, 576) - videoAS.AddNewRepresentationVideo(2295158, "avc1.4d401f", "1200", "30000/1001", 1024, 576) - videoAS.AddNewRepresentationVideo(2780732, "avc1.4d401f", "1500", "30000/1001", 1280, 720) + _, _ = videoAS.SetNewSegmentTemplate(1968, "$RepresentationID$/video/1/init.mp4", "$RepresentationID$/video/1/seg-$Number$.m4f", 0, 1000) + _, _ = videoAS.AddNewRepresentationVideo(1518664, "avc1.4d401f", "800", "30000/1001", 960, 540) + _, _ = videoAS.AddNewRepresentationVideo(1911775, "avc1.4d401f", "1000", "30000/1001", 1024, 576) + _, _ = videoAS.AddNewRepresentationVideo(2295158, "avc1.4d401f", "1200", "30000/1001", 1024, 576) + _, _ = videoAS.AddNewRepresentationVideo(2780732, "avc1.4d401f", "1500", "30000/1001", 1280, 720) subtitleAS, _ := m.AddNewAdaptationSetSubtitleWithID("7357", DASH_MIME_TYPE_SUBTITLE_VTT, VALID_LANG) subtitleRep, _ := subtitleAS.AddNewRepresentationSubtitle(VALID_SUBTITLE_BANDWIDTH, VALID_SUBTITLE_ID) - subtitleRep.SetNewBaseURL(VALID_SUBTITLE_URL) + _ = subtitleRep.SetNewBaseURL(VALID_SUBTITLE_URL) return m } @@ -220,32 +220,32 @@ func LiveProfileDynamic() *MPD { audioAS, _ := m.AddNewAdaptationSetAudioWithID("7357", DASH_MIME_TYPE_AUDIO_MP4, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP, VALID_LANG) - audioAS.AddNewContentProtectionRoot("08e367028f33436ca5dd60ffe5571e60") - audioAS.AddNewContentProtectionSchemeWidevineWithPSSH(getValidWVHeaderBytes()) - audioAS.AddNewContentProtectionSchemePlayreadyWithPSSH(VALID_PLAYREADY_PRO) + _, _ = audioAS.AddNewContentProtectionRoot("08e367028f33436ca5dd60ffe5571e60") + _, _ = audioAS.AddNewContentProtectionSchemeWidevineWithPSSH(getValidWVHeaderBytes()) + _, _ = audioAS.AddNewContentProtectionSchemePlayreadyWithPSSH(VALID_PLAYREADY_PRO) - audioAS.AddNewRole("urn:mpeg:dash:role:2011", VALID_ROLE) + _, _ = audioAS.AddNewRole("urn:mpeg:dash:role:2011", VALID_ROLE) - audioAS.SetNewSegmentTemplate(1968, "$RepresentationID$/audio/en/init.mp4", "$RepresentationID$/audio/en/seg-$Number$.m4f", 0, 1000) - audioAS.AddNewRepresentationAudio(44100, 67095, "mp4a.40.2", "800") + _, _ = audioAS.SetNewSegmentTemplate(1968, "$RepresentationID$/audio/en/init.mp4", "$RepresentationID$/audio/en/seg-$Number$.m4f", 0, 1000) + _, _ = audioAS.AddNewRepresentationAudio(44100, 67095, "mp4a.40.2", "800") videoAS, _ := m.AddNewAdaptationSetVideoWithID("7357", DASH_MIME_TYPE_VIDEO_MP4, VALID_SCAN_TYPE, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP) - videoAS.AddNewContentProtectionRoot("08e367028f33436ca5dd60ffe5571e60") - videoAS.AddNewContentProtectionSchemeWidevineWithPSSH(getValidWVHeaderBytes()) - videoAS.AddNewContentProtectionSchemePlayreadyWithPSSH(VALID_PLAYREADY_PRO) + _, _ = videoAS.AddNewContentProtectionRoot("08e367028f33436ca5dd60ffe5571e60") + _, _ = videoAS.AddNewContentProtectionSchemeWidevineWithPSSH(getValidWVHeaderBytes()) + _, _ = videoAS.AddNewContentProtectionSchemePlayreadyWithPSSH(VALID_PLAYREADY_PRO) - videoAS.AddNewRole("urn:mpeg:dash:role:2011", VALID_ROLE) + _, _ = videoAS.AddNewRole("urn:mpeg:dash:role:2011", VALID_ROLE) - videoAS.SetNewSegmentTemplate(1968, "$RepresentationID$/video/1/init.mp4", "$RepresentationID$/video/1/seg-$Number$.m4f", 0, 1000) - videoAS.AddNewRepresentationVideo(1518664, "avc1.4d401f", "800", "30000/1001", 960, 540) - videoAS.AddNewRepresentationVideo(1911775, "avc1.4d401f", "1000", "30000/1001", 1024, 576) - videoAS.AddNewRepresentationVideo(2295158, "avc1.4d401f", "1200", "30000/1001", 1024, 576) - videoAS.AddNewRepresentationVideo(2780732, "avc1.4d401f", "1500", "30000/1001", 1280, 720) + _, _ = videoAS.SetNewSegmentTemplate(1968, "$RepresentationID$/video/1/init.mp4", "$RepresentationID$/video/1/seg-$Number$.m4f", 0, 1000) + _, _ = videoAS.AddNewRepresentationVideo(1518664, "avc1.4d401f", "800", "30000/1001", 960, 540) + _, _ = videoAS.AddNewRepresentationVideo(1911775, "avc1.4d401f", "1000", "30000/1001", 1024, 576) + _, _ = videoAS.AddNewRepresentationVideo(2295158, "avc1.4d401f", "1200", "30000/1001", 1024, 576) + _, _ = videoAS.AddNewRepresentationVideo(2780732, "avc1.4d401f", "1500", "30000/1001", 1280, 720) subtitleAS, _ := m.AddNewAdaptationSetSubtitleWithID("7357", DASH_MIME_TYPE_SUBTITLE_VTT, VALID_LANG) subtitleRep, _ := subtitleAS.AddNewRepresentationSubtitle(VALID_SUBTITLE_BANDWIDTH, VALID_SUBTITLE_ID) - subtitleRep.SetNewBaseURL(VALID_SUBTITLE_URL) + _ = subtitleRep.SetNewBaseURL(VALID_SUBTITLE_URL) return m } @@ -274,33 +274,33 @@ func HbbTVProfile() *MPD { audioAS, _ := m.AddNewAdaptationSetAudioWithID("7357", DASH_MIME_TYPE_AUDIO_MP4, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP, VALID_LANG) - audioAS.AddNewContentProtectionRoot("08e367028f33436ca5dd60ffe5571e60") - audioAS.AddNewContentProtectionSchemeWidevineWithPSSH(getValidWVHeaderBytes()) - audioAS.AddNewContentProtectionSchemePlayreadyWithPSSH(VALID_PLAYREADY_PRO) + _, _ = audioAS.AddNewContentProtectionRoot("08e367028f33436ca5dd60ffe5571e60") + _, _ = audioAS.AddNewContentProtectionSchemeWidevineWithPSSH(getValidWVHeaderBytes()) + _, _ = audioAS.AddNewContentProtectionSchemePlayreadyWithPSSH(VALID_PLAYREADY_PRO) - audioAS.AddNewRole("urn:mpeg:dash:role:2011", VALID_ROLE) + _, _ = audioAS.AddNewRole("urn:mpeg:dash:role:2011", VALID_ROLE) - audioAS.SetNewSegmentTemplate(1968, "$RepresentationID$/audio/en/init.mp4", "$RepresentationID$/audio/en/seg-$Number$.m4f", 0, 1000) + _, _ = audioAS.SetNewSegmentTemplate(1968, "$RepresentationID$/audio/en/init.mp4", "$RepresentationID$/audio/en/seg-$Number$.m4f", 0, 1000) r, _ := audioAS.AddNewRepresentationAudio(44100, 67095, "mp4a.40.2", "800") - r.AddNewAudioChannelConfiguration(AUDIO_CHANNEL_CONFIGURATION_MPEG_DASH, "2") + _, _ = r.AddNewAudioChannelConfiguration(AUDIO_CHANNEL_CONFIGURATION_MPEG_DASH, "2") videoAS, _ := m.AddNewAdaptationSetVideoWithID("7357", DASH_MIME_TYPE_VIDEO_MP4, VALID_SCAN_TYPE, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP) - videoAS.AddNewContentProtectionRoot("08e367028f33436ca5dd60ffe5571e60") - videoAS.AddNewContentProtectionSchemeWidevineWithPSSH(getValidWVHeaderBytes()) - videoAS.AddNewContentProtectionSchemePlayreadyWithPSSH(VALID_PLAYREADY_PRO) + _, _ = videoAS.AddNewContentProtectionRoot("08e367028f33436ca5dd60ffe5571e60") + _, _ = videoAS.AddNewContentProtectionSchemeWidevineWithPSSH(getValidWVHeaderBytes()) + _, _ = videoAS.AddNewContentProtectionSchemePlayreadyWithPSSH(VALID_PLAYREADY_PRO) - videoAS.AddNewRole("urn:mpeg:dash:role:2011", VALID_ROLE) + _, _ = videoAS.AddNewRole("urn:mpeg:dash:role:2011", VALID_ROLE) - videoAS.SetNewSegmentTemplate(1968, "$RepresentationID$/video/1/init.mp4", "$RepresentationID$/video/1/seg-$Number$.m4f", 0, 1000) - videoAS.AddNewRepresentationVideo(1518664, "avc1.4d401f", "800", "30000/1001", 960, 540) - videoAS.AddNewRepresentationVideo(1911775, "avc1.4d401f", "1000", "30000/1001", 1024, 576) - videoAS.AddNewRepresentationVideo(2295158, "avc1.4d401f", "1200", "30000/1001", 1024, 576) - videoAS.AddNewRepresentationVideo(2780732, "avc1.4d401f", "1500", "30000/1001", 1280, 720) + _, _ = videoAS.SetNewSegmentTemplate(1968, "$RepresentationID$/video/1/init.mp4", "$RepresentationID$/video/1/seg-$Number$.m4f", 0, 1000) + _, _ = videoAS.AddNewRepresentationVideo(1518664, "avc1.4d401f", "800", "30000/1001", 960, 540) + _, _ = videoAS.AddNewRepresentationVideo(1911775, "avc1.4d401f", "1000", "30000/1001", 1024, 576) + _, _ = videoAS.AddNewRepresentationVideo(2295158, "avc1.4d401f", "1200", "30000/1001", 1024, 576) + _, _ = videoAS.AddNewRepresentationVideo(2780732, "avc1.4d401f", "1500", "30000/1001", 1280, 720) subtitleAS, _ := m.AddNewAdaptationSetSubtitleWithID("7357", DASH_MIME_TYPE_SUBTITLE_VTT, VALID_LANG) subtitleRep, _ := subtitleAS.AddNewRepresentationSubtitle(VALID_SUBTITLE_BANDWIDTH, VALID_SUBTITLE_ID) - subtitleRep.SetNewBaseURL(VALID_SUBTITLE_URL) + _ = subtitleRep.SetNewBaseURL(VALID_SUBTITLE_URL) return m } @@ -328,31 +328,31 @@ func OnDemandProfile() *MPD { audioAS, _ := m.AddNewAdaptationSetAudioWithID("7357", DASH_MIME_TYPE_AUDIO_MP4, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP, "und") - audioAS.AddNewContentProtectionRoot("08e367028f33436ca5dd60ffe5571e60") - audioAS.AddNewContentProtectionSchemeWidevineWithPSSH(getValidWVHeaderBytes()) - audioAS.AddNewContentProtectionSchemePlayreadyWithPSSH(VALID_PLAYREADY_PRO) + _, _ = audioAS.AddNewContentProtectionRoot("08e367028f33436ca5dd60ffe5571e60") + _, _ = audioAS.AddNewContentProtectionSchemeWidevineWithPSSH(getValidWVHeaderBytes()) + _, _ = audioAS.AddNewContentProtectionSchemePlayreadyWithPSSH(VALID_PLAYREADY_PRO) audioRep, _ := audioAS.AddNewRepresentationAudio(44100, 128558, "mp4a.40.5", "800k/audio-und") - audioRep.SetNewBaseURL("800k/output-audio-und.mp4") - audioRep.AddNewSegmentBase("629-756", "0-628") + _ = audioRep.SetNewBaseURL("800k/output-audio-und.mp4") + _, _ = audioRep.AddNewSegmentBase("629-756", "0-628") videoAS, _ := m.AddNewAdaptationSetVideoWithID("7357", DASH_MIME_TYPE_VIDEO_MP4, VALID_SCAN_TYPE, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP) - videoAS.AddNewContentProtectionRoot("08e367028f33436ca5dd60ffe5571e60") - videoAS.AddNewContentProtectionSchemeWidevineWithPSSH(getValidWVHeaderBytes()) - videoAS.AddNewContentProtectionSchemePlayreadyWithPSSH(VALID_PLAYREADY_PRO) + _, _ = videoAS.AddNewContentProtectionRoot("08e367028f33436ca5dd60ffe5571e60") + _, _ = videoAS.AddNewContentProtectionSchemeWidevineWithPSSH(getValidWVHeaderBytes()) + _, _ = videoAS.AddNewContentProtectionSchemePlayreadyWithPSSH(VALID_PLAYREADY_PRO) videoRep1, _ := videoAS.AddNewRepresentationVideo(1100690, "avc1.4d401e", "800k/video-1", "30000/1001", 640, 360) - videoRep1.SetNewBaseURL("800k/output-video-1.mp4") - videoRep1.AddNewSegmentBase("686-813", "0-685") + _ = videoRep1.SetNewBaseURL("800k/output-video-1.mp4") + _, _ = videoRep1.AddNewSegmentBase("686-813", "0-685") videoRep2, _ := videoAS.AddNewRepresentationVideo(1633516, "avc1.4d401f", "1200k/video-1", "30000/1001", 960, 540) - videoRep2.SetNewBaseURL("1200k/output-video-1.mp4") - videoRep2.AddNewSegmentBase("686-813", "0-685") + _ = videoRep2.SetNewBaseURL("1200k/output-video-1.mp4") + _, _ = videoRep2.AddNewSegmentBase("686-813", "0-685") subtitleAS, _ := m.AddNewAdaptationSetSubtitleWithID("7357", DASH_MIME_TYPE_SUBTITLE_VTT, VALID_LANG) subtitleRep, _ := subtitleAS.AddNewRepresentationSubtitle(VALID_SUBTITLE_BANDWIDTH, VALID_SUBTITLE_ID) - subtitleRep.SetNewBaseURL(VALID_SUBTITLE_URL) + _ = subtitleRep.SetNewBaseURL(VALID_SUBTITLE_URL) return m } diff --git a/mpd/mpd_test.go b/mpd/mpd_test.go index f646fce..ef51966 100644 --- a/mpd/mpd_test.go +++ b/mpd/mpd_test.go @@ -55,9 +55,9 @@ func TestNewMPDLive(t *testing.T) { AttrAvailabilityStartTime(VALID_AVAILABILITY_START_TIME)) require.NotNil(t, m) expectedMPD := &MPD{ - XMLNs: Strptr("urn:mpeg:dash:schema:mpd:2011"), - Profiles: Strptr((string)(DASH_PROFILE_LIVE)), - Type: Strptr("static"), + XMLNs: Strptr("urn:mpeg:dash:schema:mpd:2011"), + Profiles: Strptr((string)(DASH_PROFILE_LIVE)), + Type: Strptr("static"), MediaPresentationDuration: Strptr(VALID_MEDIA_PRESENTATION_DURATION), MinBufferTime: Strptr(VALID_MIN_BUFFER_TIME), AvailabilityStartTime: Strptr(VALID_AVAILABILITY_START_TIME), @@ -73,9 +73,9 @@ func TestNewDynamicMPDLive(t *testing.T) { AttrMinimumUpdatePeriod(VALID_MINIMUM_UPDATE_PERIOD)) require.NotNil(t, m) expectedMPD := &MPD{ - XMLNs: Strptr("urn:mpeg:dash:schema:mpd:2011"), - Profiles: Strptr((string)(DASH_PROFILE_LIVE)), - Type: Strptr("dynamic"), + XMLNs: Strptr("urn:mpeg:dash:schema:mpd:2011"), + Profiles: Strptr((string)(DASH_PROFILE_LIVE)), + Type: Strptr("dynamic"), MediaPresentationDuration: Strptr(VALID_MEDIA_PRESENTATION_DURATION), MinBufferTime: Strptr(VALID_MIN_BUFFER_TIME), AvailabilityStartTime: Strptr(VALID_AVAILABILITY_START_TIME), @@ -115,9 +115,9 @@ func TestNewMPDLiveWithBaseURLInMPD(t *testing.T) { m.BaseURL = VALID_BASE_URL_VIDEO require.NotNil(t, m) expectedMPD := &MPD{ - XMLNs: Strptr("urn:mpeg:dash:schema:mpd:2011"), - Profiles: Strptr((string)(DASH_PROFILE_LIVE)), - Type: Strptr("static"), + XMLNs: Strptr("urn:mpeg:dash:schema:mpd:2011"), + Profiles: Strptr((string)(DASH_PROFILE_LIVE)), + Type: Strptr("static"), MediaPresentationDuration: Strptr(VALID_MEDIA_PRESENTATION_DURATION), MinBufferTime: Strptr(VALID_MIN_BUFFER_TIME), period: &Period{}, @@ -135,9 +135,9 @@ func TestNewMPDLiveWithBaseURLInPeriod(t *testing.T) { BaseURL: VALID_BASE_URL_VIDEO, } expectedMPD := &MPD{ - XMLNs: Strptr("urn:mpeg:dash:schema:mpd:2011"), - Profiles: Strptr((string)(DASH_PROFILE_LIVE)), - Type: Strptr("static"), + XMLNs: Strptr("urn:mpeg:dash:schema:mpd:2011"), + Profiles: Strptr((string)(DASH_PROFILE_LIVE)), + Type: Strptr("static"), MediaPresentationDuration: Strptr(VALID_MEDIA_PRESENTATION_DURATION), MinBufferTime: Strptr(VALID_MIN_BUFFER_TIME), period: period, @@ -150,9 +150,9 @@ func TestNewMPDHbbTV(t *testing.T) { m := NewMPD(DASH_PROFILE_HBBTV_1_5_LIVE, VALID_MEDIA_PRESENTATION_DURATION, VALID_MIN_BUFFER_TIME) require.NotNil(t, m) expectedMPD := &MPD{ - XMLNs: Strptr("urn:mpeg:dash:schema:mpd:2011"), - Profiles: Strptr((string)(DASH_PROFILE_HBBTV_1_5_LIVE)), - Type: Strptr("static"), + XMLNs: Strptr("urn:mpeg:dash:schema:mpd:2011"), + Profiles: Strptr((string)(DASH_PROFILE_HBBTV_1_5_LIVE)), + Type: Strptr("static"), MediaPresentationDuration: Strptr(VALID_MEDIA_PRESENTATION_DURATION), MinBufferTime: Strptr(VALID_MIN_BUFFER_TIME), period: &Period{}, @@ -165,9 +165,9 @@ func TestNewMPDOnDemand(t *testing.T) { m := NewMPD(DASH_PROFILE_ONDEMAND, VALID_MEDIA_PRESENTATION_DURATION, VALID_MIN_BUFFER_TIME) require.NotNil(t, m) expectedMPD := &MPD{ - XMLNs: Strptr("urn:mpeg:dash:schema:mpd:2011"), - Profiles: Strptr((string)(DASH_PROFILE_ONDEMAND)), - Type: Strptr("static"), + XMLNs: Strptr("urn:mpeg:dash:schema:mpd:2011"), + Profiles: Strptr((string)(DASH_PROFILE_ONDEMAND)), + Type: Strptr("static"), MediaPresentationDuration: Strptr(VALID_MEDIA_PRESENTATION_DURATION), MinBufferTime: Strptr(VALID_MIN_BUFFER_TIME), period: &Period{}, @@ -404,7 +404,7 @@ func TestAddNewContentProtection_Proprietary(t *testing.T) { pcp := &TestProprietaryContentProtection{*cp, "foo", "bar"} x, _ := xml.Marshal(pcp) require.Equal(t, ``, string(x)) - as.AddContentProtection(pcp) + _ = as.AddContentProtection(pcp) require.Equal(t, as.ContentProtection, []ContentProtectioner{pcp}) } @@ -553,15 +553,15 @@ func TestSetNewSegmentTemplate(t *testing.T) { func TestSetNewSegmentTemplateErrorNoDASHProfile(t *testing.T) { m := &MPD{ - XMLNs: Strptr("urn:mpeg:dash:schema:mpd:2011"), - Profiles: nil, - Type: Strptr("static"), + XMLNs: Strptr("urn:mpeg:dash:schema:mpd:2011"), + Profiles: nil, + Type: Strptr("static"), MediaPresentationDuration: Strptr(VALID_MEDIA_PRESENTATION_DURATION), MinBufferTime: Strptr(VALID_MIN_BUFFER_TIME), period: &Period{}, } audioAS, _ := m.AddNewAdaptationSetAudioWithID("7357", DASH_MIME_TYPE_AUDIO_MP4, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP, VALID_LANG) - audioAS.SetNewSegmentTemplate(VALID_DURATION, VALID_INIT_PATH_AUDIO, VALID_MEDIA_PATH_AUDIO, VALID_START_NUMBER, VALID_TIMESCALE) + _, _ = audioAS.SetNewSegmentTemplate(VALID_DURATION, VALID_INIT_PATH_AUDIO, VALID_MEDIA_PATH_AUDIO, VALID_START_NUMBER, VALID_TIMESCALE) err := m.Validate() require.Equal(t, ErrNoDASHProfileSet, err) } @@ -660,9 +660,9 @@ func TestSetNewBaseURLSubtitle(t *testing.T) { func TestSetNewBaseURLErrorNoDASHProfile(t *testing.T) { m := &MPD{ - XMLNs: Strptr("urn:mpeg:dash:schema:mpd:2011"), - Profiles: nil, - Type: Strptr("static"), + XMLNs: Strptr("urn:mpeg:dash:schema:mpd:2011"), + Profiles: nil, + Type: Strptr("static"), MediaPresentationDuration: Strptr(VALID_MEDIA_PRESENTATION_DURATION), MinBufferTime: Strptr(VALID_MIN_BUFFER_TIME), period: &Period{}, @@ -671,7 +671,7 @@ func TestSetNewBaseURLErrorNoDASHProfile(t *testing.T) { r, _ := videoAS.AddNewRepresentationVideo(VALID_VIDEO_BITRATE, VALID_VIDEO_CODEC, VALID_VIDEO_ID, VALID_VIDEO_FRAMERATE, VALID_VIDEO_WIDTH, VALID_VIDEO_HEIGHT) - r.SetNewBaseURL(VALID_BASE_URL_VIDEO) + _ = r.SetNewBaseURL(VALID_BASE_URL_VIDEO) err := m.Validate() require.NotNil(t, err) @@ -703,9 +703,9 @@ func TestSetNewSegmentBase(t *testing.T) { func TestSetNewSegmentBaseErrorNoDASHProfile(t *testing.T) { m := &MPD{ - XMLNs: Strptr("urn:mpeg:dash:schema:mpd:2011"), - Profiles: nil, - Type: Strptr("static"), + XMLNs: Strptr("urn:mpeg:dash:schema:mpd:2011"), + Profiles: nil, + Type: Strptr("static"), MediaPresentationDuration: Strptr(VALID_MEDIA_PRESENTATION_DURATION), MinBufferTime: Strptr(VALID_MIN_BUFFER_TIME), period: &Period{}, @@ -714,7 +714,7 @@ func TestSetNewSegmentBaseErrorNoDASHProfile(t *testing.T) { r, _ := videoAS.AddNewRepresentationVideo(VALID_VIDEO_BITRATE, VALID_VIDEO_CODEC, VALID_VIDEO_ID, VALID_VIDEO_FRAMERATE, VALID_VIDEO_WIDTH, VALID_VIDEO_HEIGHT) - r.AddNewSegmentBase(VALID_INDEX_RANGE, VALID_INIT_RANGE) + _, _ = r.AddNewSegmentBase(VALID_INDEX_RANGE, VALID_INIT_RANGE) err := m.Validate() require.Equal(t, ErrNoDASHProfileSet, err) diff --git a/mpd/segment_timeline_test.go b/mpd/segment_timeline_test.go index 2ef5a39..5522c58 100644 --- a/mpd/segment_timeline_test.go +++ b/mpd/segment_timeline_test.go @@ -59,7 +59,7 @@ func getMultiPeriodSegmentTimelineMPD() *MPD { p.ID = strconv.Itoa(i) p.Duration = Duration(30 * time.Second) aas, _ := p.AddNewAdaptationSetAudioWithID("1", "audio/mp4", true, 1, "en") - aas.AddNewRepresentationAudio(48000, 92000, "mp4a.40.2", "audio_1") + _, _ = aas.AddNewRepresentationAudio(48000, 92000, "mp4a.40.2", "audio_1") aas.SegmentTemplate = &SegmentTemplate{ Timescale: ptrs.Int64ptr(48000), Initialization: ptrs.Strptr("audio/init.m4f"), @@ -72,8 +72,8 @@ func getMultiPeriodSegmentTimelineMPD() *MPD { }, } vas, _ := p.AddNewAdaptationSetVideoWithID("2", "video/mp4", "progressive", true, 1) - vas.AddNewRepresentationVideo(3532000, "avc1.640028", "video_1", "2997/100", 2048, 854) - vas.AddNewRepresentationVideo(453000, "avc1.420016", "video_2", "2997/100", 648, 270) + _, _ = vas.AddNewRepresentationVideo(3532000, "avc1.640028", "video_1", "2997/100", 2048, 854) + _, _ = vas.AddNewRepresentationVideo(453000, "avc1.420016", "video_2", "2997/100", 648, 270) vas.SegmentTemplate = &SegmentTemplate{ Timescale: ptrs.Int64ptr(30000), Initialization: ptrs.Strptr("video/$RepresentationID$/init.m4f"),