@@ -93,14 +93,16 @@ type AdaptationSet struct {
9393
9494// Constants for DRM / ContentProtection
9595const (
96- CONTENT_PROTECTION_ROOT_SCHEME_ID_URI = "urn:mpeg:dash:mp4protection:2011"
97- CONTENT_PROTECTION_ROOT_VALUE = "cenc"
98- CENC_XMLNS = "urn:mpeg:cenc:2013"
99- CONTENT_PROTECTION_WIDEVINE_SCHEME_ID = "urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"
100- CONTENT_PROTECTION_WIDEVINE_SCHEME_HEX = "edef8ba979d64acea3c827dcd51d21ed"
101- CONTENT_PROTECTION_PLAYREADY_SCHEME_ID = "urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95"
102- CONTENT_PROTECTION_PLAYREADY_SCHEME_HEX = "9a04f07998404286ab92e65be0885f95"
103- CONTENT_PROTECTION_PLAYREADY_XMLNS = "urn:microsoft:playready"
96+ CONTENT_PROTECTION_ROOT_SCHEME_ID_URI = "urn:mpeg:dash:mp4protection:2011"
97+ CONTENT_PROTECTION_ROOT_VALUE = "cenc"
98+ CENC_XMLNS = "urn:mpeg:cenc:2013"
99+ CONTENT_PROTECTION_WIDEVINE_SCHEME_ID = "urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"
100+ CONTENT_PROTECTION_WIDEVINE_SCHEME_HEX = "edef8ba979d64acea3c827dcd51d21ed"
101+ CONTENT_PROTECTION_PLAYREADY_SCHEME_ID = "urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95"
102+ CONTENT_PROTECTION_PLAYREADY_SCHEME_HEX = "9a04f07998404286ab92e65be0885f95"
103+ CONTENT_PROTECTION_PLAYREADY_SCHEME_V10_ID = "urn:uuid:79f0049a-4098-8642-ab92-e65be0885f95"
104+ CONTENT_PROTECTION_PLAYREADY_SCHEME_V10_HEX = "79f0049a40988642ab92e65be0885f95"
105+ CONTENT_PROTECTION_PLAYREADY_XMLNS = "urn:microsoft:playready"
104106)
105107
106108type ContentProtectioner interface {
@@ -332,7 +334,7 @@ func NewWidevineContentProtection(wvHeader []byte) (*WidevineContentProtection,
332334// AddNewContentProtectionSchemePlayready adds a new content protection scheme for PlayReady DRM.
333335// pro - PlayReady Object Header, as a Base64 encoded string.
334336func (as * AdaptationSet ) AddNewContentProtectionSchemePlayready (pro string ) (* PlayreadyContentProtection , error ) {
335- cp , err := newPlayreadyContentProtection (pro )
337+ cp , err := newPlayreadyContentProtection (pro , CONTENT_PROTECTION_PLAYREADY_SCHEME_ID )
336338 if err != nil {
337339 return nil , err
338340 }
@@ -344,7 +346,22 @@ func (as *AdaptationSet) AddNewContentProtectionSchemePlayready(pro string) (*Pl
344346 return cp , nil
345347}
346348
347- func newPlayreadyContentProtection (pro string ) (* PlayreadyContentProtection , error ) {
349+ // AddNewContentProtectionSchemePlayreadyV10 adds a new content protection scheme for PlayReady v1.0 DRM.
350+ // pro - PlayReady Object Header, as a Base64 encoded string.
351+ func (as * AdaptationSet ) AddNewContentProtectionSchemePlayreadyV10 (pro string ) (* PlayreadyContentProtection , error ) {
352+ cp , err := newPlayreadyContentProtection (pro , CONTENT_PROTECTION_PLAYREADY_SCHEME_V10_ID )
353+ if err != nil {
354+ return nil , err
355+ }
356+ 357+ err = as .AddContentProtection (cp )
358+ if err != nil {
359+ return nil , err
360+ }
361+ return cp , nil
362+ }
363+ 364+ func newPlayreadyContentProtection (pro string , schemeIDURI string ) (* PlayreadyContentProtection , error ) {
348365 if pro == "" {
349366 return nil , ErrPROEmpty
350367 }
@@ -353,7 +370,7 @@ func newPlayreadyContentProtection(pro string) (*PlayreadyContentProtection, err
353370 PlayreadyXMLNS : Strptr (CONTENT_PROTECTION_PLAYREADY_XMLNS ),
354371 PRO : Strptr (pro ),
355372 }
356- cp .SchemeIDURI = Strptr (CONTENT_PROTECTION_PLAYREADY_SCHEME_ID )
373+ cp .SchemeIDURI = Strptr (schemeIDURI )
357374
358375 return cp , nil
359376}
@@ -362,7 +379,7 @@ func newPlayreadyContentProtection(pro string) (*PlayreadyContentProtection, err
362379// will include both ms:pro and cenc:pssh subelements
363380// pro - PlayReady Object Header, as a Base64 encoded string.
364381func (as * AdaptationSet ) AddNewContentProtectionSchemePlayreadyWithPSSH (pro string ) (* PlayreadyContentProtection , error ) {
365- cp , err := newPlayreadyContentProtection (pro )
382+ cp , err := newPlayreadyContentProtection (pro , CONTENT_PROTECTION_PLAYREADY_SCHEME_ID )
366383 if err != nil {
367384 return nil , err
368385 }
@@ -390,6 +407,38 @@ func (as *AdaptationSet) AddNewContentProtectionSchemePlayreadyWithPSSH(pro stri
390407 return cp , nil
391408}
392409
410+ // AddNewContentProtectionSchemePlayreadyV10WithPSSH adds a new content protection scheme for PlayReady v1.0 DRM. The scheme
411+ // will include both ms:pro and cenc:pssh subelements
412+ // pro - PlayReady Object Header, as a Base64 encoded string.
413+ func (as * AdaptationSet ) AddNewContentProtectionSchemePlayreadyV10WithPSSH (pro string ) (* PlayreadyContentProtection , error ) {
414+ cp , err := newPlayreadyContentProtection (pro , CONTENT_PROTECTION_PLAYREADY_SCHEME_V10_ID )
415+ if err != nil {
416+ return nil , err
417+ }
418+ cp .XMLNS = Strptr (CENC_XMLNS )
419+ prSystemID , err := hex .DecodeString (CONTENT_PROTECTION_PLAYREADY_SCHEME_V10_HEX )
420+ if err != nil {
421+ panic (err .Error ())
422+ }
423+ 424+ proBin , err := base64 .StdEncoding .DecodeString (pro )
425+ if err != nil {
426+ return nil , err
427+ }
428+ 429+ psshBox , err := makePSSHBox (prSystemID , proBin )
430+ if err != nil {
431+ return nil , err
432+ }
433+ cp .PSSH = Strptr (base64 .StdEncoding .EncodeToString (psshBox ))
434+ 435+ err = as .AddContentProtection (cp )
436+ if err != nil {
437+ return nil , err
438+ }
439+ return cp , nil
440+ }
441+ 393442// Internal helper method for adding a ContentProtection to an AdaptationSet.
394443func (as * AdaptationSet ) AddContentProtection (cp ContentProtectioner ) error {
395444 if cp == nil {
0 commit comments