Skip to content

Commit

Permalink
DRM types
Browse files Browse the repository at this point in the history
A prelude to a more complete DrmEngine.  Should allow development of
DRM-related DASH parsing to proceed in parallel with DrmEngine
development.

Change-Id: Ie51504955f530898469fcacd897cb51588caa7d4
  • Loading branch information
joeyparrish committed Jan 14, 2016
1 parent 075af4e commit 736fe9e
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 4 deletions.
22 changes: 18 additions & 4 deletions externs/mediakeys.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,20 @@
*/


/**
* @typedef {string}
* 'optional', 'required', 'not-allowed'
*/
var MediaKeysRequirement;


/**
* @typedef {string}
* 'temporary', 'persistent-license', 'persistent-usage-record'
*/
var MediaKeySessionType;


/**
* @typedef {{contentType: string, robustness: string}}
* gjslint: disable=900
Expand All @@ -35,9 +49,9 @@ var MediaKeySystemMediaCapability;
* initDataTypes: (Array.<string>|undefined),
* audioCapabilities: (Array.<!MediaKeySystemMediaCapability>|undefined),
* videoCapabilities: (Array.<!MediaKeySystemMediaCapability>|undefined),
* distinctiveIdentifier: (string|undefined),
* persistentState: (string|undefined),
* sessionTypes: (Array.<string>|undefined)
* distinctiveIdentifier: (MediaKeysRequirement|undefined),
* persistentState: (MediaKeysRequirement|undefined),
* sessionTypes: (Array.<MediaKeySessionType>|undefined)
* }}
* gjslint: disable=900
*/
Expand Down Expand Up @@ -87,7 +101,7 @@ function MediaKeys() {}


/**
* @param {string=} opt_sessionType defaults to "temporary"
* @param {MediaKeySessionType=} opt_sessionType defaults to "temporary"
* @return {!MediaKeySession}
* @throws {TypeError} if opt_sessionType is invalid.
*/
Expand Down
73 changes: 73 additions & 0 deletions externs/shaka/manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,80 @@ shakaExtern.Manifest;
shakaExtern.Period;


/**
* @typedef {{
* initData: !Uint8Array,
* initDataType: string
* }}
*
* @description
* Explicit initialization data, which override any initialization data in the
* content. The initDataType values and the formats that they correspond to
* are specified {@link http://goo.gl/hKBdff here}.
*
* @property {!Uint8Array} initData
* Initialization data in the format indicated by initDataType.
* @property {string} initDataType
* A string to indicate what format initData is in.
*
* @exportDoc
*/
shakaExtern.InitDataOverride;


/**
* @typedef {{
* keySystem: string,
* licenseServerUri: string,
* distinctiveIdentifierRequired: boolean,
* persistentStateRequired: boolean,
* robustness: string,
* serverCertificate: Uint8Array,
* initData: Array.<!shakaExtern.InitDataOverride>
* }}
*
* @description
* DRM configuration for a single key system.
*
* @property {string} keySystem
* <i>Required.</i> <br>
* The key system, e.g., "com.widevine.alpha".
* @property {string} licenseServerUri
* <i>Required.</i> <br>
* The license server URI.
* @property {boolean} distinctiveIdentifierRequired
* <i>Defaults to false.</i> <br>
* True if the application requires the key system to support distinctive
* identifiers.
* @property {boolean} persistentStateRequired
* <i>Defaults to false.</i> <br>
* True if the application requires the key system to support persistent
* state, e.g., for persistent license storage.
* @property {string} robustness
* A key-system-specific string that specifies a required security level.
* <i>Defaults to '', e.g., no specific robustness required.</i> <br>
* @property {Uint8Array} serverCertificate
* <i>Defaults to null, e.g., certificate will be requested from the license
* server if required.</i> <br>
* A key-system-specific server certificate used to encrypt license requests.
* Its use is optional and is meant as an optimization to avoid a round-trip
* to request a certificate.
* @property {Array.<!shakaExtern.InitDataOverride>} initData
* <i>Defaults to [], e.g., no override.</i> <br>
* A list of initialization data which override any initialization data found
* in the content. See also shakaExtern.InitDataOverride.
*
* @exportDoc
*/
shakaExtern.DrmInfo;


/**
* @typedef {{
* language: string,
* type: string,
* primary: boolean,
* drmInfos: Array.<!shakaExtern.DrmInfo>,
* streams: !Array.<!shakaExtern.Stream>
* }}
*
Expand All @@ -129,6 +198,10 @@ shakaExtern.Period;
* the same type in the same Period. However, the player may use another
* StreamSet to meet application preferences, or to achieve better MIME type
* or DRM compatibility among other StreamSets.
* @property {Array.<!shakaExtern.DrmInfo>} drmInfos
* <i>Defaults to [] (i.e., no DRM).</i> <br>
* An array of DrmInfo objects which describe DRM schemes are compatible with
* the content.
* @property {!Array.<!shakaExtern.Stream>} streams
* <i>Required.</i> <br>
* The StreamSets's Streams. There must be at least one Stream.
Expand Down
1 change: 1 addition & 0 deletions lib/dash/dash_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,7 @@ shaka.dash.DashParser.prototype.createStreamSets_ = function(adaptationSets) {
language: lang,
type: type,
primary: sets.some(function(s) { return s.main; }),
drmInfos: [], // TODO
streams:
sets.map(function(s) { return s.streams; })
.reduce(function(all, part) { return all.concat(part); }, [])
Expand Down
10 changes: 10 additions & 0 deletions spec/dash_parser_manifest_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ describe('DashParser.Manifest', function() {
language: 'en',
type: 'video',
primary: false,
drmInfos: [],
streams: [
jasmine.objectContaining({
id: 1,
Expand Down Expand Up @@ -179,6 +180,7 @@ describe('DashParser.Manifest', function() {
language: 'es',
type: 'text',
primary: false,
drmInfos: [],
streams: [
jasmine.objectContaining({
id: 3,
Expand All @@ -199,6 +201,7 @@ describe('DashParser.Manifest', function() {
language: '',
type: 'audio',
primary: true,
drmInfos: [],
streams: [
jasmine.objectContaining({
id: 4,
Expand Down Expand Up @@ -241,6 +244,7 @@ describe('DashParser.Manifest', function() {
language: 'en',
type: 'video',
primary: false,
drmInfos: [],
streams: [
jasmine.objectContaining({bandwidth: 100}),
jasmine.objectContaining({bandwidth: 200})
Expand Down Expand Up @@ -271,6 +275,7 @@ describe('DashParser.Manifest', function() {
language: 'en',
type: 'video',
primary: false,
drmInfos: [],
streams: [
jasmine.objectContaining({bandwidth: 100})
]
Expand All @@ -279,6 +284,7 @@ describe('DashParser.Manifest', function() {
language: 'en',
type: 'video',
primary: false,
drmInfos: [],
streams: [
jasmine.objectContaining({bandwidth: 200})
]
Expand Down Expand Up @@ -308,6 +314,7 @@ describe('DashParser.Manifest', function() {
language: 'en',
type: 'video',
primary: false,
drmInfos: [],
streams: [
jasmine.objectContaining({bandwidth: 100})
]
Expand All @@ -316,6 +323,7 @@ describe('DashParser.Manifest', function() {
language: 'es',
type: 'video',
primary: false,
drmInfos: [],
streams: [
jasmine.objectContaining({bandwidth: 200})
]
Expand Down Expand Up @@ -345,6 +353,7 @@ describe('DashParser.Manifest', function() {
language: 'en',
type: 'video',
primary: false,
drmInfos: [],
streams: [
jasmine.objectContaining({bandwidth: 100})
]
Expand All @@ -353,6 +362,7 @@ describe('DashParser.Manifest', function() {
language: 'en',
type: 'audio',
primary: false,
drmInfos: [],
streams: [
jasmine.objectContaining({bandwidth: 200})
]
Expand Down

0 comments on commit 736fe9e

Please sign in to comment.