@@ -47,6 +47,8 @@ const (
4747 DASH_MIME_TYPE_SUBTITLE_TTML string = "application/ttaf+xml"
4848 DASH_MIME_TYPE_SUBTITLE_SRT string = "application/x-subrip"
4949 DASH_MIME_TYPE_SUBTITLE_DFXP string = "application/ttaf+xml"
50+ DASH_MIME_TYPE_IMAGE_JPEG string = "image/jpeg"
51+ DASH_CONTENT_TYPE_IMAGE string = "image"
5052)
5153
5254// Known error variables
@@ -462,6 +464,45 @@ func (period *Period) SetDuration(d time.Duration) {
462464 period .Duration = Duration (d )
463465}
464466
467+ // Create a new Adaptation Set for thumbnails.
468+ // mimeType - e.g. (image/jpeg)
469+ func (m * MPD ) AddNewAdaptationSetThumbnails (mimeType string ) (* AdaptationSet , error ) {
470+ return m .period .AddNewAdaptationSetThumbnails (mimeType )
471+ }
472+
473+ func (period * Period ) AddNewAdaptationSetThumbnails (mimeType string ) (* AdaptationSet , error ) {
474+ as := & AdaptationSet {
475+ ContentType : Strptr (DASH_CONTENT_TYPE_IMAGE ),
476+ CommonAttributesAndElements : CommonAttributesAndElements {
477+ MimeType : Strptr (mimeType ),
478+ },
479+ }
480+ err := period .addAdaptationSet (as )
481+ if err != nil {
482+ return nil , err
483+ }
484+ return as , nil
485+ }
486+
487+ func (m * MPD ) AddNewAdaptationSetThumbnailsWithID (id , mimeType string ) (* AdaptationSet , error ) {
488+ return m .period .AddNewAdaptationSetThumbnailsWithID (id , mimeType )
489+ }
490+
491+ func (period * Period ) AddNewAdaptationSetThumbnailsWithID (id , mimeType string ) (* AdaptationSet , error ) {
492+ as := & AdaptationSet {
493+ ID : Strptr (id ),
494+ ContentType : Strptr (DASH_CONTENT_TYPE_IMAGE ),
495+ CommonAttributesAndElements : CommonAttributesAndElements {
496+ MimeType : Strptr (mimeType ),
497+ },
498+ }
499+ err := period .addAdaptationSet (as )
500+ if err != nil {
501+ return nil , err
502+ }
503+ return as , nil
504+ }
505+
465506// Create a new Adaptation Set for Audio Assets.
466507// mimeType - MIME Type (i.e. audio/mp4).
467508// segmentAlignment - Segment Alignment(i.e. true).
@@ -896,6 +937,55 @@ func (as *AdaptationSet) setSegmentTemplate(st *SegmentTemplate) error {
896937 return nil
897938}
898939
940+ // Adds a new SegmentTemplate to a thumbnail AdaptationSet
941+ // duration - relative to timescale (i.e. 2000).
942+ // media - template string for media segments.
943+ // startNumber - the number to start segments from ($Number$) (i.e. 0).
944+ // timescale - sets the timescale for duration (i.e. 1000, represents milliseconds).
945+ func (as * AdaptationSet ) SetNewSegmentTemplateThumbnails (duration int64 , media string , startNumber int64 , timescale int64 ) (* SegmentTemplate , error ) {
946+ st := & SegmentTemplate {
947+ Duration : Int64ptr (duration ),
948+ Media : Strptr (media ),
949+ StartNumber : Int64ptr (startNumber ),
950+ Timescale : Int64ptr (timescale ),
951+ }
952+
953+ err := as .setSegmentTemplate (st )
954+ if err != nil {
955+ return nil , err
956+ }
957+ return st , nil
958+ }
959+
960+ // Adds a new Thumbnail representation to an AdaptationSet.
961+ // bandwidth - in Bits/s (i.e. 1518664).
962+ // id - ID for this representation, will get used as $RepresentationID$ in template strings.
963+ // width - width of the video (i.e. 1280).
964+ // height - height of the video (i.e 720).
965+ // uri -
966+ func (as * AdaptationSet ) AddNewRepresentationThumbnails (id , val , uri string ,bandwidth , width , height int64 ) (* Representation , error ) {
967+ r := & Representation {
968+ Bandwidth : Int64ptr (bandwidth ),
969+ ID : Strptr (id ),
970+ Width : Int64ptr (width ),
971+ Height : Int64ptr (height ),
972+ CommonAttributesAndElements : CommonAttributesAndElements {
973+ EssentialProperty : []DescriptorType {
974+ {
975+ SchemeIDURI : Strptr (uri ),
976+ Value : Strptr (val ),
977+ },
978+ },
979+ },
980+ }
981+
982+ err := as .addRepresentation (r )
983+ if err != nil {
984+ return nil , err
985+ }
986+ return r , nil
987+ }
988+
899989// Adds a new Audio representation to an AdaptationSet.
900990// samplingRate - in Hz (i.e. 44100).
901991// bandwidth - in Bits/s (i.e. 67095).
0 commit comments