Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 0256ea1

Browse files
update tests
1 parent b365506 commit 0256ea1

File tree

5 files changed

+35
-82
lines changed

5 files changed

+35
-82
lines changed

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ go install ./...
2727
* Audio
2828
* Video
2929
* Subtitles
30+
* Multiple periods (multi-part playlist)
3031
* DRM (ContentProtection)
3132
* PlayReady
3233
* Widevine
3334

3435
## Known Limitations (for now) (PRs welcome)
3536

36-
* Single Period
3737
* No PSSH/PRO generation
3838
* Limited Profile Support
3939

‎mpd/mpd.go‎

Lines changed: 10 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -158,15 +158,15 @@ type SegmentTemplate struct {
158158
type Representation struct {
159159
AdaptationSet *AdaptationSet `xml:"-"`
160160
AudioChannelConfiguration *AudioChannelConfiguration `xml:"AudioChannelConfiguration,omitempty"`
161-
AudioSamplingRate *int64 `xml:"audioSamplingRate,attr"` // Audio
162-
Bandwidth *int64 `xml:"bandwidth,attr"` // Audio + Video
163-
Codecs *string `xml:"codecs,attr"` // Audio + Video
164-
FrameRate *string `xml:"frameRate,attr"` // Video
165-
Height *int64 `xml:"height,attr"` // Video
166-
ID *string `xml:"id,attr"` // Audio + Video
167-
Width *int64 `xml:"width,attr"` // Video
168-
BaseURL *string `xml:"BaseURL,omitempty"` // On-Demand Profile
169-
SegmentBase *SegmentBase `xml:"SegmentBase,omitempty"` // On-Demand Profile
161+
AudioSamplingRate *int64 `xml:"audioSamplingRate,attr"` // Audio
162+
Bandwidth *int64 `xml:"bandwidth,attr"` // Audio + Video
163+
Codecs *string `xml:"codecs,attr"` // Audio + Video
164+
FrameRate *string `xml:"frameRate,attr,omitempty"` // Video
165+
Height *int64 `xml:"height,attr"` // Video
166+
ID *string `xml:"id,attr"` // Audio + Video
167+
Width *int64 `xml:"width,attr"` // Video
168+
BaseURL *string `xml:"BaseURL,omitempty"` // On-Demand Profile
169+
SegmentBase *SegmentBase `xml:"SegmentBase,omitempty"` // On-Demand Profile
170170
SegmentList *SegmentList `xml:"SegmentList,omitempty"`
171171
SegmentTemplate *SegmentTemplate `xml:"SegmentTemplate,omitempty"`
172172
}
@@ -517,15 +517,6 @@ func (as *AdaptationSet) SetNewSegmentTemplate(duration int64, init string, medi
517517

518518
// Internal helper method for setting the Segment Template on an AdaptationSet.
519519
func (as *AdaptationSet) setSegmentTemplate(st *SegmentTemplate) error {
520-
/*
521-
XXX move error checks to a helper on the mpd instance
522-
if as.MPD == nil || as.MPD.Profiles == nil {
523-
return ErrNoDASHProfileSet
524-
}
525-
if *as.MPD.Profiles != string(DASH_PROFILE_LIVE) {
526-
return ErrSegmentTemplateLiveProfileOnly
527-
}
528-
*/
529520
if st == nil {
530521
return ErrSegmentTemplateNil
531522
}
@@ -620,12 +611,6 @@ func (as *AdaptationSet) AddNewRole(schemeIDURI string, value string) (*Role, er
620611
// Sets the BaseURL for a Representation.
621612
// baseURL - Base URL as a string (i.e. 800k/output-audio-und.mp4)
622613
func (r *Representation) SetNewBaseURL(baseURL string) error {
623-
/*
624-
XXX move error check someplace else
625-
if r.AdaptationSet == nil || r.AdaptationSet.MPD == nil || r.AdaptationSet.MPD.Profiles == nil {
626-
return ErrNoDASHProfileSet
627-
}
628-
*/
629614
if baseURL == "" {
630615
return ErrBaseURLEmpty
631616
}
@@ -652,15 +637,9 @@ func (r *Representation) AddNewSegmentBase(indexRange string, initRange string)
652637

653638
// Internal helper method for setting the SegmentBase on a Representation.
654639
func (r *Representation) setSegmentBase(sb *SegmentBase) error {
655-
if r.AdaptationSet == nil /*|| r.AdaptationSet.MPD == nil || r.AdaptationSet.MPD.Profiles == nil*/{
640+
if r.AdaptationSet == nil {
656641
return ErrNoDASHProfileSet
657642
}
658-
/*
659-
XXX move checks someplace else
660-
if *r.AdaptationSet.MPD.Profiles != (string)(DASH_PROFILE_ONDEMAND) {
661-
return ErrSegmentBaseOnDemandProfileOnly
662-
}
663-
*/
664643
if sb == nil {
665644
return ErrSegmentBaseNil
666645
}
@@ -688,11 +667,6 @@ func (r *Representation) AddNewAudioChannelConfiguration(scheme AudioChannelConf
688667

689668
// Internal helper method for setting the SegmentBase on a Representation.
690669
func (r *Representation) setAudioChannelConfiguration(acc *AudioChannelConfiguration) error {
691-
/* XXX move checks elsewhere
692-
if r.AdaptationSet == nil || r.AdaptationSet.MPD == nil || r.AdaptationSet.MPD.Profiles == nil {
693-
return ErrNoDASHProfileSet
694-
}
695-
*/
696670
if acc == nil {
697671
return ErrAudioChannelConfigurationNil
698672
}

‎mpd/mpd_read_write_test.go‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,20 +146,21 @@ func ExampleAddNewPeriod() {
146146
// a new MPD is created with a single Period
147147
m := NewMPD(DASH_PROFILE_LIVE, VALID_MEDIA_PRESENTATION_DURATION, VALID_MIN_BUFFER_TIME)
148148

149-
as, _ := m.AddNewAdaptationSetVideo(DASH_MIME_TYPE_VIDEO_MP4, VALID_SCAN_TYPE, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP)
149+
// you can add content to the Period
150+
p := m.GetCurrentPeriod()
151+
as, _ := p.AddNewAdaptationSetVideo(DASH_MIME_TYPE_VIDEO_MP4, VALID_SCAN_TYPE, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP)
150152
as.SetNewSegmentTemplate(1968, "$RepresentationID$/video-1.mp4", "$RepresentationID$/video-1/seg-$Number$.m4f", 0, 1000)
151153

154+
// or directly to the MPD, which will use the current Period.
152155
as, _ = m.AddNewAdaptationSetAudio(DASH_MIME_TYPE_AUDIO_MP4, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP, VALID_LANG)
153156
as.SetNewSegmentTemplate(1968, "$RepresentationID$/audio-1.mp4", "$RepresentationID$/audio-1/seg-$Number$.m4f", 0, 1000)
154157

155158
// add a second period
156-
p := m.AddNewPeriod()
159+
p = m.AddNewPeriod()
157160
p.SetDuration(3 * time.Minute)
158-
// you can add content to the Period
159161
as, _ = p.AddNewAdaptationSetVideo(DASH_MIME_TYPE_VIDEO_MP4, VALID_SCAN_TYPE, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP)
160162
as.SetNewSegmentTemplate(1968, "$RepresentationID$/video-2.mp4", "$RepresentationID$/video-2/seg-$Number$.m4f", 0, 1000)
161163

162-
// or directly to the MPD, which will use the current Period.
163164
as, _ = m.AddNewAdaptationSetAudio(DASH_MIME_TYPE_AUDIO_MP4, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP, VALID_LANG)
164165
as.SetNewSegmentTemplate(1968, "$RepresentationID$/audio-2.mp4", "$RepresentationID$/audio-2/seg-$Number$.m4f", 0, 1000)
165166

‎mpd/mpd_test.go‎

Lines changed: 10 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -403,34 +403,20 @@ func (s *MPDSuite) TestSetNewSegmentTemplate() {
403403
assert.Nil(s.T(), err)
404404
}
405405

406-
/*
407-
func (s *MPDSuite) TestSetNewSegmentTemplateErrorInvalidProfile() {
408-
m := NewMPD(DASH_PROFILE_ONDEMAND, VALID_MEDIA_PRESENTATION_DURATION, VALID_MIN_BUFFER_TIME)
409-
audioAS, _ := m.AddNewAdaptationSetAudio(DASH_MIME_TYPE_AUDIO_MP4, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP, VALID_LANG)
410-
st, err := audioAS.SetNewSegmentTemplate(VALID_DURATION, VALID_INIT_PATH_AUDIO, VALID_MEDIA_PATH_AUDIO, VALID_START_NUMBER, VALID_TIMESCALE)
411-
assert.Nil(s.T(), st)
412-
assert.NotNil(s.T(), err)
413-
assert.Equal(s.T(), ErrSegmentTemplateLiveProfileOnly, err)
414-
}
415-
*/
416-
417-
/*
418406
func (s *MPDSuite) TestSetNewSegmentTemplateErrorNoDASHProfile() {
419407
m := &MPD{
420408
XMLNs: Strptr("urn:mpeg:dash:schema:mpd:2011"),
421409
Profiles: nil,
422410
Type: Strptr("static"),
423411
MediaPresentationDuration: Strptr(VALID_MEDIA_PRESENTATION_DURATION),
424412
MinBufferTime: Strptr(VALID_MIN_BUFFER_TIME),
425-
Period: &Period{},
413+
period: &Period{},
426414
}
427415
audioAS, _ := m.AddNewAdaptationSetAudio(DASH_MIME_TYPE_AUDIO_MP4, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP, VALID_LANG)
428-
st, err := audioAS.SetNewSegmentTemplate(VALID_DURATION, VALID_INIT_PATH_AUDIO, VALID_MEDIA_PATH_AUDIO, VALID_START_NUMBER, VALID_TIMESCALE)
429-
assert.Nil(s.T(), st)
430-
assert.NotNil(s.T(), err)
416+
audioAS.SetNewSegmentTemplate(VALID_DURATION, VALID_INIT_PATH_AUDIO, VALID_MEDIA_PATH_AUDIO, VALID_START_NUMBER, VALID_TIMESCALE)
417+
err := m.Validate()
431418
assert.Equal(s.T(), ErrNoDASHProfileSet, err)
432419
}
433-
*/
434420

435421
func (s *MPDSuite) TestAddRepresentationAudio() {
436422
m := NewMPD(DASH_PROFILE_LIVE, VALID_MEDIA_PRESENTATION_DURATION, VALID_MIN_BUFFER_TIME)
@@ -524,26 +510,25 @@ func (s *MPDSuite) TestSetNewBaseURLSubtitle() {
524510
assert.Nil(s.T(), err)
525511
}
526512

527-
/*
528513
func (s *MPDSuite) TestSetNewBaseURLErrorNoDASHProfile() {
529514
m := &MPD{
530515
XMLNs: Strptr("urn:mpeg:dash:schema:mpd:2011"),
531516
Profiles: nil,
532517
Type: Strptr("static"),
533518
MediaPresentationDuration: Strptr(VALID_MEDIA_PRESENTATION_DURATION),
534519
MinBufferTime: Strptr(VALID_MIN_BUFFER_TIME),
535-
Period: &Period{},
520+
period: &Period{},
536521
}
537522
videoAS, _ := m.AddNewAdaptationSetVideo(DASH_MIME_TYPE_VIDEO_MP4, VALID_SCAN_TYPE, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP)
538523

539524
r, _ := videoAS.AddNewRepresentationVideo(VALID_VIDEO_BITRATE, VALID_VIDEO_CODEC, VALID_VIDEO_ID, VALID_VIDEO_FRAMERATE, VALID_VIDEO_WIDTH, VALID_VIDEO_HEIGHT)
540525

541-
err := r.SetNewBaseURL(VALID_BASE_URL_VIDEO)
526+
r.SetNewBaseURL(VALID_BASE_URL_VIDEO)
527+
err := m.Validate()
542528

543529
assert.NotNil(s.T(), err)
544530
assert.Equal(s.T(), ErrNoDASHProfileSet, err)
545531
}
546-
*/
547532

548533
func (s *MPDSuite) TestSetNewBaseURLErrorEmpty() {
549534
m := NewMPD(DASH_PROFILE_ONDEMAND, VALID_MEDIA_PRESENTATION_DURATION, VALID_MIN_BUFFER_TIME)
@@ -568,40 +553,24 @@ func (s *MPDSuite) TestSetNewSegmentBase() {
568553
assert.Nil(s.T(), err)
569554
}
570555

571-
/*
572-
func (s *MPDSuite) TestSetNewSegmentBaseErrorInvalidDASHProfile() {
573-
m := NewMPD(DASH_PROFILE_LIVE, VALID_MEDIA_PRESENTATION_DURATION, VALID_MIN_BUFFER_TIME)
574-
videoAS, _ := m.AddNewAdaptationSetVideo(DASH_MIME_TYPE_VIDEO_MP4, VALID_SCAN_TYPE, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP)
575-
576-
r, _ := videoAS.AddNewRepresentationVideo(VALID_VIDEO_BITRATE, VALID_VIDEO_CODEC, VALID_VIDEO_ID, VALID_VIDEO_FRAMERATE, VALID_VIDEO_WIDTH, VALID_VIDEO_HEIGHT)
577-
578-
sb, err := r.AddNewSegmentBase(VALID_INDEX_RANGE, VALID_INIT_RANGE)
579-
assert.Nil(s.T(), sb)
580-
assert.NotNil(s.T(), err)
581-
assert.Equal(s.T(), ErrSegmentBaseOnDemandProfileOnly, err)
582-
}
583-
*/
584-
585-
/*
586556
func (s *MPDSuite) TestSetNewSegmentBaseErrorNoDASHProfile() {
587557
m := &MPD{
588558
XMLNs: Strptr("urn:mpeg:dash:schema:mpd:2011"),
589559
Profiles: nil,
590560
Type: Strptr("static"),
591561
MediaPresentationDuration: Strptr(VALID_MEDIA_PRESENTATION_DURATION),
592562
MinBufferTime: Strptr(VALID_MIN_BUFFER_TIME),
593-
Period: &Period{},
563+
period: &Period{},
594564
}
595565
videoAS, _ := m.AddNewAdaptationSetVideo(DASH_MIME_TYPE_VIDEO_MP4, VALID_SCAN_TYPE, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP)
596566

597567
r, _ := videoAS.AddNewRepresentationVideo(VALID_VIDEO_BITRATE, VALID_VIDEO_CODEC, VALID_VIDEO_ID, VALID_VIDEO_FRAMERATE, VALID_VIDEO_WIDTH, VALID_VIDEO_HEIGHT)
598568

599-
sb, err := r.AddNewSegmentBase(VALID_INDEX_RANGE, VALID_INIT_RANGE)
600-
assert.Nil(s.T(), sb)
601-
assert.NotNil(s.T(), err)
569+
r.AddNewSegmentBase(VALID_INDEX_RANGE, VALID_INIT_RANGE)
570+
571+
err:=m.Validate()
602572
assert.Equal(s.T(), ErrNoDASHProfileSet, err)
603573
}
604-
*/
605574

606575
func (s *MPDSuite) TestSetSegmentBaseErrorNil() {
607576
m := NewMPD(DASH_PROFILE_ONDEMAND, VALID_MEDIA_PRESENTATION_DURATION, VALID_MIN_BUFFER_TIME)

‎mpd/validate.go‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package mpd
2+
3+
// Validate checks for incomplete MPD object
4+
func (m *MPD) Validate() error {
5+
if m.Profiles == nil {
6+
return ErrNoDASHProfileSet
7+
}
8+
return nil
9+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /