videojs / m3u8-parser

An m3u8 parser.
Other
481 stars 101 forks source link

Wiseplay support with videojs #154

Open djpavlovic opened 2 years ago

djpavlovic commented 2 years ago

Hi, can you please add support (or any kind of skipping) for wiseplay in playlist?

example:


var wisePlayUri = 'urn:uuid:3d5e6d35-9b9a-41e8-b843-dd3c6e72c42c';
var widevineUuid = 'urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed'; // group segments into numbered timelines delineated by discontinuities`

if (entry.attributes.KEYFORMAT === wisePlayUri) {
  this.trigger('warn', {
    message: 'wiseplay support should be implemented!'
  });
  return;
}

if (entry.attributes.KEYFORMAT === widevineUuid) {
  var VALID_METHODS = ['SAMPLE-AES', 'SAMPLE-AES-CTR', 'SAMPLE-AES-CENC'];

  if (VALID_METHODS.indexOf(entry.attributes.METHOD) === -1) {
    this.trigger('warn', {
      message: 'invalid key method provided for Widevine'
    });
    return;
  }

  if (entry.attributes.METHOD === 'SAMPLE-AES-CENC') {
    this.trigger('warn', {
      message: 'SAMPLE-AES-CENC is deprecated, please use SAMPLE-AES-CTR instead'
    });
  }

  if (entry.attributes.URI.substring(0, 23) !== 'data:text/plain;base64,') {
    this.trigger('warn', {
      message: 'invalid key URI provided for Widevine'
    });
    return;
  }

  if (!(entry.attributes.KEYID && entry.attributes.KEYID.substring(0, 2) === '0x')) {
    this.trigger('warn', {
      message: 'invalid key ID provided for Widevine'
    });
    return;
  }
  // if Widevine key attributes are valid, store them as `contentProtection`
  // on the manifest to emulate Widevine tag structure in a DASH mpd

  this.manifest.contentProtection = this.manifest.contentProtection || {};
  this.manifest.contentProtection['com.widevine.alpha'] = {
    attributes: {
      schemeIdUri: entry.attributes.KEYFORMAT,
      // remove '0x' from the key id string
      keyId: entry.attributes.KEYID.substring(2)
    },
    // decode the base64-encoded PSSH box
    pssh: decodeB64ToUint8Array(entry.attributes.URI.split(',')[1])
  };
  console.debug('::: ', this.manifest.contentProtection['com.widevine.alpha'])
  return;
}
djpavlovic commented 2 years ago

For maintainers: Please take a look at https://github.com/videojs/m3u8-parser/pull/155 where PR has fixing this issue.

djpavlovic commented 2 years ago

@gkatsev can you please take a look at this issue, thanks

djpavlovic commented 2 years ago

anyone can look into this please