shaka-player
Advanced tools
Comparing version 2.2.1 to 2.2.2
@@ -263,2 +263,42 @@ #!/usr/bin/env node | ||
/** | ||
* Take the original block comment and prep it for the externs by removing | ||
* export annotations and blank lines. | ||
* | ||
* @param {string} | ||
* @return {string} | ||
*/ | ||
function removeExportAnnotationsFromComment(comment) { | ||
// Remove @export annotations. | ||
comment = comment.replace(EXPORT_REGEX, '') | ||
// Split into lines, remove empty comment lines, then recombine. | ||
comment = comment.split('\n') | ||
.filter(function(line) { return !/^ *\*? *$/.test(line); }) | ||
.join('\n'); | ||
return comment; | ||
} | ||
/** | ||
* Recursively find all expression statements in all block nodes. | ||
* @param {ASTNode} node | ||
* @return {!Array.<ASTNode>} | ||
*/ | ||
function getAllExpressionStatements(node) { | ||
console.assert(node.body && node.body.body); | ||
var expressionStatements = []; | ||
node.body.body.forEach(function(childNode) { | ||
if (childNode.type == 'ExpressionStatement') { | ||
expressionStatements.push(childNode); | ||
} else if (childNode.body) { | ||
var childExpressions = getAllExpressionStatements(childNode); | ||
expressionStatements.push.apply(expressionStatements, childExpressions); | ||
} | ||
}); | ||
return expressionStatements; | ||
} | ||
/** | ||
* @param {!Set.<string>} names A set of the names of exported nodes. | ||
@@ -273,11 +313,4 @@ * @param {ASTNode} node An exported node from the abstract syntax tree. | ||
var comment = getLeadingBlockComment(node); | ||
comment = removeExportAnnotationsFromComment(comment); | ||
// Remove @export annotations. | ||
comment = comment.replace(EXPORT_REGEX, '') | ||
// Split into lines, remove empty comment lines, then recombine. | ||
comment = comment.split('\n') | ||
.filter(function(line) { return !/^ *\*? *$/.test(line); }) | ||
.join('\n'); | ||
var name; | ||
@@ -321,3 +354,11 @@ var assignment; | ||
// Generate the actual extern string. | ||
return comment + '\n' + name + assignment + ';\n'; | ||
var externString = comment + '\n' + name + assignment + ';\n'; | ||
// Find this.foo = bar in the constructor, and potentially generate externs | ||
// for that, too. | ||
if (node.expression.type == 'AssignmentExpression' && | ||
comment.includes('@constructor')) { | ||
externString += createExternsFromConstructor(name, node.expression.right); | ||
} | ||
return externString; | ||
} | ||
@@ -380,2 +421,72 @@ | ||
/** | ||
* Look for exports in a constructor body. If we don't do this, we may end up | ||
* with errors about classes not fully implementing their interfaces. In | ||
* reality, the interface is implemented by assigning members on "this". | ||
* | ||
* @param {string} className | ||
* @param {ASTNode} constructorNode | ||
* @return {string} | ||
*/ | ||
function createExternsFromConstructor(className, constructorNode) { | ||
// Example code: | ||
// | ||
// /** @interface @exportInterface */ | ||
// FooLike = function() {}; | ||
// | ||
// /** @exportInterface @type {number} */ | ||
// FooLike.prototype.bar; | ||
// | ||
// /** @constructor @export @implements {FooLike} */ | ||
// Foo = function() { | ||
// /** @override @exportInterface */ | ||
// this.bar = 10; | ||
// }; | ||
// | ||
// Example externs: | ||
// | ||
// /** | ||
// * Generated by createExternFromExportNode: | ||
// * @constructor @implements {FooLike} | ||
// */ | ||
// Foo = function() {} | ||
// | ||
// /** | ||
// * Generated by createExternsFromConstructor: | ||
// * @override | ||
// */ | ||
// Foo.prototype.bar; | ||
var expressionStatements = getAllExpressionStatements(constructorNode); | ||
var externString = ''; | ||
expressionStatements.forEach(function(statement) { | ||
var left = statement.expression.left; | ||
var right = statement.expression.right; | ||
// Skip anything that isn't an assignment to a member of "this". | ||
if (statement.expression.type != 'AssignmentExpression' || | ||
left.type != 'MemberExpression' || | ||
left.object.type != 'ThisExpression') | ||
return; | ||
console.assert(left); | ||
console.assert(right); | ||
// Skip anything that isn't exported. | ||
var comment = getLeadingBlockComment(statement); | ||
if (!EXPORT_REGEX.test(comment)) | ||
return; | ||
comment = removeExportAnnotationsFromComment(comment); | ||
console.assert(left.property.type == 'Identifier'); | ||
var name = className + '.prototype.' + left.property.name; | ||
externString += comment + '\n' + name + ';\n'; | ||
}); | ||
return externString; | ||
} | ||
/** | ||
* @param {!Set.<string>} names A set of the names of exported nodes. | ||
@@ -382,0 +493,0 @@ * @param {string} inputPath |
@@ -177,6 +177,3 @@ /** | ||
ShakaDemoUtils.setupAssetMetadata(asset, player); | ||
shakaDemo.castProxy_.setAppData({ | ||
'asset': asset, | ||
'isYtDrm': asset.drmCallback == shakaAssets.YouTubeCallback | ||
}); | ||
shakaDemo.castProxy_.setAppData({'asset': asset}); | ||
@@ -183,0 +180,0 @@ // Add drm configuration from the UI. |
@@ -106,8 +106,2 @@ /** | ||
var asset = /** @type {shakaAssets.AssetInfo} */(appData['asset']); | ||
// Patch in non-transferable callbacks for YT DRM: | ||
if (appData['isYtDrm']) { | ||
asset.drmCallback = shakaAssets.YouTubeCallback; | ||
asset.requestFilter = shakaAssets.YouTubeRequestFilter; | ||
asset.responseFilter = shakaAssets.YouTubeResponseFilter; | ||
} | ||
ShakaDemoUtils.setupAssetMetadata(asset, this.player_); | ||
@@ -114,0 +108,0 @@ }; |
@@ -31,3 +31,2 @@ /** | ||
SHAKA_PACKAGER: 'Shaka packager', | ||
YOUTUBE: 'YouTube', | ||
AXINOM: 'Axinom', | ||
@@ -48,3 +47,2 @@ UNIFIED_STREAMING: 'Unified Streaming', | ||
SHAKA: 'Shaka', | ||
YOUTUBE: 'YouTube', | ||
AXINOM: 'Axinom', | ||
@@ -198,38 +196,2 @@ UNIFIED_STREAMING: 'Unified Streaming', | ||
/** | ||
* A license request filter for YouTube license requests. | ||
* @param {shaka.net.NetworkingEngine.RequestType} type | ||
* @param {shakaExtern.Request} request | ||
*/ | ||
shakaAssets.YouTubeRequestFilter = function(type, request) { | ||
if (type != shaka.net.NetworkingEngine.RequestType.LICENSE) | ||
return; | ||
// The Playready endpoint does not allow cross-origin requests that include | ||
// the headers we extracted from the Playready XML. Remove them. | ||
request.headers = {}; | ||
}; | ||
/** | ||
* A license response filter for YouTube license responses. | ||
* @param {shaka.net.NetworkingEngine.RequestType} type | ||
* @param {shakaExtern.Response} response | ||
*/ | ||
shakaAssets.YouTubeResponseFilter = function(type, response) { | ||
if (type != shaka.net.NetworkingEngine.RequestType.LICENSE) | ||
return; | ||
// We are extracting an ASCII header and not reading the Stringified version | ||
// of the license thereafter, so this conversion is safe. | ||
var responseArray = new Uint8Array(response.data); | ||
var responseStr = String.fromCharCode.apply(null, responseArray); | ||
var headerIndex = responseStr.indexOf('\r\n\r\n'); | ||
if (responseStr.indexOf('GLS/1.0') == 0 && headerIndex >= 0) { | ||
// Strip off the headers. | ||
response.data = response.data.slice(headerIndex + 4); | ||
} | ||
}; | ||
/** | ||
* A response filter for VDMS Uplynk manifest responses, | ||
@@ -275,49 +237,2 @@ * this allows us to get the license prefix that is necessary | ||
}; | ||
/** | ||
* @param {!Node} node | ||
* @return {Array.<shakaExtern.DrmInfo>} | ||
*/ | ||
shakaAssets.YouTubeCallback = function(node) { | ||
var schemeIdUri = node.getAttribute('schemeIdUri'); | ||
if (schemeIdUri == 'http://youtube.com/drm/2012/10/10') { | ||
/** @type {!Array.<shakaExtern.DrmInfo>} */ | ||
var configs = []; | ||
for (var i = 0; i < node.childNodes.length; ++i) { | ||
var child = node.childNodes[i]; | ||
if (child.nodeName == 'yt:SystemURL') { | ||
// The URL may be http, but the demo app requires https. | ||
var licenseServerUri = child.textContent.replace(/^http:/, 'https:'); | ||
var typeAttr = child.getAttribute('type'); | ||
var keySystem; | ||
// NOTE: Ignoring clearkey type here because this YT demo content does | ||
// not contain PSSHs appropriate for the clearkey CDM. | ||
if (typeAttr == 'widevine') { | ||
keySystem = 'com.widevine.alpha'; | ||
} else if (typeAttr == 'playready') { | ||
keySystem = 'com.microsoft.playready'; | ||
} else { | ||
continue; | ||
} | ||
configs.push({ | ||
keySystem: keySystem, | ||
licenseServerUri: licenseServerUri, | ||
distinctiveIdentifierRequired: false, | ||
persistentStateRequired: false, | ||
audioRobustness: '', | ||
videoRobustness: '', | ||
serverCertificate: null, | ||
initData: null, | ||
keyIds: [] | ||
}); | ||
} | ||
} | ||
return configs; | ||
} | ||
return null; | ||
}; | ||
// }}} | ||
@@ -598,3 +513,2 @@ | ||
shakaAssets.Feature.MP4, | ||
shakaAssets.Feature.PSSH, | ||
shakaAssets.Feature.SEGMENT_BASE, | ||
@@ -606,66 +520,16 @@ shakaAssets.Feature.SUBTITLES, | ||
}, | ||
// }}} | ||
// YouTube assets {{{ | ||
// Src: http://dash-mse-test.appspot.com/media.html | ||
{ | ||
name: 'Car', | ||
manifestUri: '//yt-dash-mse-test.commondatastorage.googleapis.com/media/car-20120827-manifest.mpd', // gjslint: disable=110 | ||
encoder: shakaAssets.Encoder.YOUTUBE, | ||
source: shakaAssets.Source.YOUTUBE, | ||
name: 'Shaka Player History (multicodec, live)', | ||
manifestUri: '//storage.googleapis.com/shaka-live-assets/player-source.mpd', | ||
encoder: shakaAssets.Encoder.SHAKA_PACKAGER, | ||
source: shakaAssets.Source.SHAKA, | ||
drm: [], | ||
features: [ | ||
shakaAssets.Feature.HIGH_DEFINITION, | ||
shakaAssets.Feature.LIVE, | ||
shakaAssets.Feature.MP4, | ||
shakaAssets.Feature.SEGMENT_BASE | ||
] | ||
}, | ||
{ | ||
name: 'Car ClearKey', | ||
manifestUri: '//yt-dash-mse-test.commondatastorage.googleapis.com/media/car_cenc-20120827-manifest.mpd', // gjslint: disable=110 | ||
encoder: shakaAssets.Encoder.YOUTUBE, | ||
source: shakaAssets.Source.YOUTUBE, | ||
drm: [shakaAssets.KeySystem.CLEAR_KEY], | ||
features: [ | ||
shakaAssets.Feature.MP4, | ||
shakaAssets.Feature.SEGMENT_BASE | ||
], | ||
clearKeys: { | ||
'60061e017e477e877e57d00d1ed00d1e': '1a8a2095e4deb2d29ec816ac7bae2082' | ||
} | ||
}, | ||
{ | ||
name: 'Feelings', | ||
manifestUri: '//yt-dash-mse-test.commondatastorage.googleapis.com/media/feelings_vp9-20130806-manifest.mpd', // gjslint: disable=110 | ||
encoder: shakaAssets.Encoder.YOUTUBE, | ||
source: shakaAssets.Source.YOUTUBE, | ||
drm: [], | ||
features: [ | ||
shakaAssets.Feature.SEGMENT_BASE, | ||
shakaAssets.Feature.SEGMENT_TEMPLATE_TIMELINE, | ||
shakaAssets.Feature.WEBM | ||
] | ||
}, | ||
{ | ||
name: 'Oops multi-DRM', | ||
manifestUri: '//yt-dash-mse-test.commondatastorage.googleapis.com/media/oops_cenc-20121114-signedlicenseurl-manifest.mpd', // gjslint: disable=110 | ||
encoder: shakaAssets.Encoder.YOUTUBE, | ||
source: shakaAssets.Source.YOUTUBE, | ||
drm: [ | ||
// TODO: Failing on PlayReady with error 8004b896, investigate | ||
//shakaAssets.KeySystem.PLAYREADY, | ||
shakaAssets.KeySystem.WIDEVINE | ||
], | ||
features: [ | ||
shakaAssets.Feature.MP4, | ||
shakaAssets.Feature.SEGMENT_BASE | ||
], | ||
drmCallback: shakaAssets.YouTubeCallback, | ||
requestFilter: shakaAssets.YouTubeRequestFilter, | ||
responseFilter: shakaAssets.YouTubeResponseFilter | ||
}, | ||
// }}} | ||
@@ -672,0 +536,0 @@ |
@@ -206,2 +206,3 @@ /** | ||
// the URL fragment takes precendence. | ||
/** @type {!Array.<string>} */ | ||
var combined = fields.concat(fragments); | ||
@@ -208,0 +209,0 @@ var params = {}; |
@@ -171,3 +171,3 @@ /** | ||
} | ||
shakaDemo.refreshAssetList_(); | ||
return shakaDemo.refreshAssetList_(); | ||
}); | ||
@@ -177,8 +177,17 @@ } else { | ||
var nameField = document.getElementById('offlineName').value; | ||
var assetName = asset.name ? asset.name + ' (offline)' : null; | ||
var assetName = asset.name ? '[OFFLINE] ' + asset.name : null; | ||
var metadata = {name: assetName || nameField || asset.manifestUri}; | ||
p = storage.store(asset.manifestUri, metadata).then(function() { | ||
shakaDemo.refreshAssetList_(); | ||
if (option.asset) | ||
option.isStored = true; | ||
return shakaDemo.refreshAssetList_().then(function() { | ||
// Auto-select offline copy of asset after storing. | ||
var group = shakaDemo.offlineOptGroup_; | ||
for (var i = 0; i < group.childNodes.length; i++) { | ||
var option = group.childNodes[i]; | ||
if (option.textContent == assetName) { | ||
assetList.selectedIndex = option.index; | ||
} | ||
} | ||
}); | ||
}); | ||
@@ -192,3 +201,3 @@ } | ||
shakaDemo.offlineOperationInProgress_ = false; | ||
shakaDemo.updateButtons_(false); | ||
shakaDemo.updateButtons_(true /* canHide */); | ||
return storage.destroy(); | ||
@@ -199,3 +208,6 @@ }); | ||
/** @private */ | ||
/** | ||
* @return {!Promise} | ||
* @private | ||
*/ | ||
shakaDemo.refreshAssetList_ = function() { | ||
@@ -208,3 +220,3 @@ // Remove all child elements. | ||
shakaDemo.setupOfflineAssets_(); | ||
return shakaDemo.setupOfflineAssets_(); | ||
}; | ||
@@ -211,0 +223,0 @@ |
@@ -63,3 +63,3 @@ // This file was autogenerated by third_party/closure/deps/depswriter.py. | ||
goog.addDependency('../../../lib/text/mp4_vtt_parser.js', ['shaka.text.Mp4VttParser'], ['goog.asserts', 'shaka.log', 'shaka.text.Cue', 'shaka.text.TextEngine', 'shaka.text.VttTextParser', 'shaka.util.DataViewReader', 'shaka.util.Error', 'shaka.util.Functional', 'shaka.util.Mp4Parser', 'shaka.util.StringUtils', 'shaka.util.TextParser']); | ||
goog.addDependency('../../../lib/text/simple_text_displayer.js', ['shaka.text.SimpleTextDisplayer'], ['shaka.log']); | ||
goog.addDependency('../../../lib/text/simple_text_displayer.js', ['shaka.text.SimpleTextDisplayer'], ['goog.asserts', 'shaka.log']); | ||
goog.addDependency('../../../lib/text/text_engine.js', ['shaka.text.TextEngine'], ['goog.asserts', 'shaka.log', 'shaka.util.IDestroyable']); | ||
@@ -66,0 +66,0 @@ goog.addDependency('../../../lib/text/ttml_text_parser.js', ['shaka.text.TtmlTextParser'], ['goog.asserts', 'shaka.text.Cue', 'shaka.text.TextEngine', 'shaka.util.ArrayUtils', 'shaka.util.Error', 'shaka.util.StringUtils']); |
@@ -73,23 +73,14 @@ /** | ||
* @extends {Error} | ||
* @implements {shakaExtern.Error} | ||
*/ | ||
shaka.util.Error = function(severity, category, code, var_args) {}; | ||
/** | ||
* @type {shaka.util.Error.Severity} | ||
*/ | ||
/** @override */ | ||
shaka.util.Error.prototype.severity; | ||
/** | ||
* @const {shaka.util.Error.Category} | ||
*/ | ||
/** @override */ | ||
shaka.util.Error.prototype.category; | ||
/** | ||
* @const {shaka.util.Error.Code} | ||
*/ | ||
/** @override */ | ||
shaka.util.Error.prototype.code; | ||
/** | ||
* @const {!Array.<*>} | ||
*/ | ||
/** @override */ | ||
shaka.util.Error.prototype.data; | ||
/** | ||
* @type {boolean} | ||
*/ | ||
/** @override */ | ||
shaka.util.Error.prototype.handled; | ||
@@ -1277,2 +1268,3 @@ /** | ||
* @param {!string} payload | ||
* @implements {shakaExtern.Cue} | ||
* @constructor | ||
@@ -1282,2 +1274,48 @@ * @struct | ||
shaka.text.Cue = function(startTime, endTime, payload) {}; | ||
/** @override */ | ||
shaka.text.Cue.prototype.startTime; | ||
/** @override */ | ||
shaka.text.Cue.prototype.endTime; | ||
/** @override */ | ||
shaka.text.Cue.prototype.payload; | ||
/** @override */ | ||
shaka.text.Cue.prototype.region; | ||
/** @override */ | ||
shaka.text.Cue.prototype.position; | ||
/** @override */ | ||
shaka.text.Cue.prototype.positionAlign; | ||
/** @override */ | ||
shaka.text.Cue.prototype.size; | ||
/** @override */ | ||
shaka.text.Cue.prototype.textAlign; | ||
/** @override */ | ||
shaka.text.Cue.prototype.writingDirection; | ||
/** @override */ | ||
shaka.text.Cue.prototype.lineInterpretation; | ||
/** @override */ | ||
shaka.text.Cue.prototype.line; | ||
/** @override */ | ||
shaka.text.Cue.prototype.lineHeight; | ||
/** @override */ | ||
shaka.text.Cue.prototype.lineAlign; | ||
/** @override */ | ||
shaka.text.Cue.prototype.displayAlign; | ||
/** @override */ | ||
shaka.text.Cue.prototype.color; | ||
/** @override */ | ||
shaka.text.Cue.prototype.backgroundColor; | ||
/** @override */ | ||
shaka.text.Cue.prototype.fontSize; | ||
/** @override */ | ||
shaka.text.Cue.prototype.fontWeight; | ||
/** @override */ | ||
shaka.text.Cue.prototype.fontStyle; | ||
/** @override */ | ||
shaka.text.Cue.prototype.fontFamily; | ||
/** @override */ | ||
shaka.text.Cue.prototype.textDecoration; | ||
/** @override */ | ||
shaka.text.Cue.prototype.wrapLine; | ||
/** @override */ | ||
shaka.text.Cue.prototype.id; | ||
/** | ||
@@ -1314,6 +1352,6 @@ * @enum {string} | ||
shaka.text.Cue.writingDirection = { | ||
HORIZONTAL_LEFT_TO_RIGHT: 0, | ||
HORIZONTAL_RIGHT_TO_LEFT: 1, | ||
VERTICAL_LEFT_TO_RIGHT: 2, | ||
VERTICAL_RIGHT_TO_LEFT: 3 | ||
'HORIZONTAL_LEFT_TO_RIGHT': 0, | ||
'HORIZONTAL_RIGHT_TO_LEFT': 1, | ||
'VERTICAL_LEFT_TO_RIGHT': 2, | ||
'VERTICAL_RIGHT_TO_LEFT': 3 | ||
}; | ||
@@ -1324,4 +1362,4 @@ /** | ||
shaka.text.Cue.lineInterpretation = { | ||
LINE_NUMBER: 0, | ||
PERCENTAGE: 1 | ||
'LINE_NUMBER': 0, | ||
'PERCENTAGE': 1 | ||
}; | ||
@@ -1342,4 +1380,4 @@ /** | ||
shaka.text.Cue.fontWeight = { | ||
NORMAL: 400, | ||
BOLD: 700 | ||
'NORMAL': 400, | ||
'BOLD': 700 | ||
}; | ||
@@ -1358,5 +1396,5 @@ /** | ||
shaka.text.Cue.textDecoration = { | ||
UNDERLINE: 'underline', | ||
LINE_THROUGH: 'lineThrough', | ||
OVERLINE: 'overline' | ||
'UNDERLINE': 'underline', | ||
'LINE_THROUGH': 'lineThrough', | ||
'OVERLINE': 'overline' | ||
}; | ||
@@ -1363,0 +1401,0 @@ /** |
@@ -73,23 +73,14 @@ /** | ||
* @extends {Error} | ||
* @implements {shakaExtern.Error} | ||
*/ | ||
shaka.util.Error = function(severity, category, code, var_args) {}; | ||
/** | ||
* @type {shaka.util.Error.Severity} | ||
*/ | ||
/** @override */ | ||
shaka.util.Error.prototype.severity; | ||
/** | ||
* @const {shaka.util.Error.Category} | ||
*/ | ||
/** @override */ | ||
shaka.util.Error.prototype.category; | ||
/** | ||
* @const {shaka.util.Error.Code} | ||
*/ | ||
/** @override */ | ||
shaka.util.Error.prototype.code; | ||
/** | ||
* @const {!Array.<*>} | ||
*/ | ||
/** @override */ | ||
shaka.util.Error.prototype.data; | ||
/** | ||
* @type {boolean} | ||
*/ | ||
/** @override */ | ||
shaka.util.Error.prototype.handled; | ||
@@ -1277,2 +1268,3 @@ /** | ||
* @param {!string} payload | ||
* @implements {shakaExtern.Cue} | ||
* @constructor | ||
@@ -1282,2 +1274,48 @@ * @struct | ||
shaka.text.Cue = function(startTime, endTime, payload) {}; | ||
/** @override */ | ||
shaka.text.Cue.prototype.startTime; | ||
/** @override */ | ||
shaka.text.Cue.prototype.endTime; | ||
/** @override */ | ||
shaka.text.Cue.prototype.payload; | ||
/** @override */ | ||
shaka.text.Cue.prototype.region; | ||
/** @override */ | ||
shaka.text.Cue.prototype.position; | ||
/** @override */ | ||
shaka.text.Cue.prototype.positionAlign; | ||
/** @override */ | ||
shaka.text.Cue.prototype.size; | ||
/** @override */ | ||
shaka.text.Cue.prototype.textAlign; | ||
/** @override */ | ||
shaka.text.Cue.prototype.writingDirection; | ||
/** @override */ | ||
shaka.text.Cue.prototype.lineInterpretation; | ||
/** @override */ | ||
shaka.text.Cue.prototype.line; | ||
/** @override */ | ||
shaka.text.Cue.prototype.lineHeight; | ||
/** @override */ | ||
shaka.text.Cue.prototype.lineAlign; | ||
/** @override */ | ||
shaka.text.Cue.prototype.displayAlign; | ||
/** @override */ | ||
shaka.text.Cue.prototype.color; | ||
/** @override */ | ||
shaka.text.Cue.prototype.backgroundColor; | ||
/** @override */ | ||
shaka.text.Cue.prototype.fontSize; | ||
/** @override */ | ||
shaka.text.Cue.prototype.fontWeight; | ||
/** @override */ | ||
shaka.text.Cue.prototype.fontStyle; | ||
/** @override */ | ||
shaka.text.Cue.prototype.fontFamily; | ||
/** @override */ | ||
shaka.text.Cue.prototype.textDecoration; | ||
/** @override */ | ||
shaka.text.Cue.prototype.wrapLine; | ||
/** @override */ | ||
shaka.text.Cue.prototype.id; | ||
/** | ||
@@ -1314,6 +1352,6 @@ * @enum {string} | ||
shaka.text.Cue.writingDirection = { | ||
HORIZONTAL_LEFT_TO_RIGHT: 0, | ||
HORIZONTAL_RIGHT_TO_LEFT: 1, | ||
VERTICAL_LEFT_TO_RIGHT: 2, | ||
VERTICAL_RIGHT_TO_LEFT: 3 | ||
'HORIZONTAL_LEFT_TO_RIGHT': 0, | ||
'HORIZONTAL_RIGHT_TO_LEFT': 1, | ||
'VERTICAL_LEFT_TO_RIGHT': 2, | ||
'VERTICAL_RIGHT_TO_LEFT': 3 | ||
}; | ||
@@ -1324,4 +1362,4 @@ /** | ||
shaka.text.Cue.lineInterpretation = { | ||
LINE_NUMBER: 0, | ||
PERCENTAGE: 1 | ||
'LINE_NUMBER': 0, | ||
'PERCENTAGE': 1 | ||
}; | ||
@@ -1342,4 +1380,4 @@ /** | ||
shaka.text.Cue.fontWeight = { | ||
NORMAL: 400, | ||
BOLD: 700 | ||
'NORMAL': 400, | ||
'BOLD': 700 | ||
}; | ||
@@ -1358,5 +1396,5 @@ /** | ||
shaka.text.Cue.textDecoration = { | ||
UNDERLINE: 'underline', | ||
LINE_THROUGH: 'lineThrough', | ||
OVERLINE: 'overline' | ||
'UNDERLINE': 'underline', | ||
'LINE_THROUGH': 'lineThrough', | ||
'OVERLINE': 'overline' | ||
}; | ||
@@ -1363,0 +1401,0 @@ /** |
@@ -18,15 +18,2 @@ # Shaka Player Exports | ||
## Exposing a symbol | ||
Similar to exporting, the compiler also supports what it calls exposing. This | ||
is similar, but rather than exporting a symbol to an exported namespace, | ||
exposing prevents a symbol from being renamed during compilation. The compiler | ||
uses the `@expose` annotation for this purpose. | ||
This is useful for things that cannot be exported, such as public member | ||
variables. In contrast, exporting can only be applied to static or prototype | ||
methods, since they do not differ per instance and can be attached to the | ||
exported namespace at load time. | ||
## Exporting to the docs | ||
@@ -71,8 +58,15 @@ | ||
In some cases, public member variables need to be preserved when they would | ||
otherwise be renamed by the compiler. `@export` is not sufficient to keep the | ||
names from being renamed and is only useful for static members or prototype | ||
values. `@expose` used to be used for this but is now deprecated. The current | ||
best practice is to write an externs file defining the properties that should | ||
be preserved. | ||
## Summary | ||
- `@export`: truly exported (attached to namespace) by the compiler | ||
- `@expose`: truly exposed (not renamed) by the compiler | ||
- `@expose`: deprecated | ||
- `@exportDoc`: considered part of the exports in the docs | ||
- `@exportInterface`: considered part of the exports in generated externs |
@@ -27,3 +27,5 @@ # Frequently Asked Questions | ||
info. This is usually a [CORS][] error, which means you need particular | ||
headers in the response. | ||
headers in the response. Additionally, with some manifests, we will send a | ||
`Range` header. This will require explicit approval through the CORS header | ||
`Access-Control-Allow-Headers`. | ||
@@ -30,0 +32,0 @@ This can also happen with mixed-content restrictions. If the site is using |
@@ -90,5 +90,29 @@ # Network and Buffering Configuration | ||
#### Server Considerations | ||
Shaka Player makes a number of requests to various servers while streaming. You | ||
need to make sure that Shaka has correct access to those resources. Browsers | ||
impose several restrictions on the content that a webpage has access to. | ||
One restriction is [CORS][] (Cross-Origin Resource Sharing). This requires | ||
network requests to be made to the same origin, or for the server to explicitly | ||
give access. An "origin" refers to the domain name (e.g. `api.example.com`), | ||
the scheme (e.g. `https:`), and the port (e.g. 80). If you host your assets on | ||
a different origin than your web app, then you'll need to set CORS headers on | ||
the asset server to ensure we have access. For some content, this will also | ||
require allowing the `Range` header by sending the CORS header | ||
`Access-Control-Allow-Headers`. | ||
Another restriction is called mixed-content. If your webpage is accessed using | ||
`https:`, then all resources that are loaded also need to be loaded using | ||
`https:`. This means that the manifest and all the media segments need to be | ||
loaded using `https:`. This is most easily done by either having all the | ||
URLs in your manifests always use `https:`, or by having it not include the | ||
scheme (e.g. `//example.com/file.mp4`). | ||
[CORS]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS | ||
#### Continue the Tutorials | ||
Next, check out {@tutorial drm-config}. |
@@ -22,4 +22,211 @@ /** | ||
/** | ||
* @typedef {{ | ||
* x: number, | ||
* y: number, | ||
* width: number, | ||
* height: number | ||
* }} | ||
* | ||
* @description | ||
* The region of the video to render the cues into. | ||
* | ||
* @property {number} x | ||
* The X offset to start the rendering area. This is a percentage (0-100) of | ||
* the video width. | ||
* @property {number} y | ||
* The Y offset to start the rendering area. This is a percentage (0-100) of | ||
* the video height. | ||
* @property {number} width | ||
* The width of the rendering area. This is a percentage (0-100) of the video | ||
* width. | ||
* @property {number} height | ||
* The height of the rendering area. This is a percentage (0-100) of the | ||
* video height. | ||
*/ | ||
shakaExtern.CueRegion; | ||
/** | ||
* @interface | ||
* @exportDoc | ||
*/ | ||
shakaExtern.Cue = function() {}; | ||
/** | ||
* The start time of the cue in seconds and fractions of a second. | ||
* @type {number} | ||
*/ | ||
shakaExtern.Cue.prototype.startTime; | ||
/** | ||
* The end time of the cue in seconds and fractions of a second. | ||
* @type {number} | ||
*/ | ||
shakaExtern.Cue.prototype.endTime; | ||
/** | ||
* The text payload of the cue. | ||
* @type {!string} | ||
*/ | ||
shakaExtern.Cue.prototype.payload; | ||
/** | ||
* The region to render the cue into. | ||
* @type {shakaExtern.CueRegion} | ||
*/ | ||
shakaExtern.Cue.prototype.region; | ||
/** | ||
* The indent (in percent) of the cue box in the direction defined by the | ||
* writing direction. | ||
* @type {?number} | ||
*/ | ||
shakaExtern.Cue.prototype.position; | ||
/** | ||
* Position alignment of the cue. | ||
* @type {shaka.text.Cue.positionAlign} | ||
*/ | ||
shakaExtern.Cue.prototype.positionAlign; | ||
/** | ||
* Size of the cue box (in percents). | ||
* @type {number} | ||
*/ | ||
shakaExtern.Cue.prototype.size; | ||
/** | ||
* Alignment of the text inside the cue box. | ||
* @type {shaka.text.Cue.textAlign} | ||
*/ | ||
shakaExtern.Cue.prototype.textAlign; | ||
/** | ||
* Text writing direction of the cue. | ||
* @type {shaka.text.Cue.writingDirection} | ||
*/ | ||
shakaExtern.Cue.prototype.writingDirection; | ||
/** | ||
* The way to interpret line field. (Either as an integer line number or | ||
* percentage from the display box). | ||
* @type {shaka.text.Cue.lineInterpretation} | ||
*/ | ||
shakaExtern.Cue.prototype.lineInterpretation; | ||
/** | ||
* The offset from the display box in either number of lines or | ||
* percentage depending on the value of lineInterpretation. | ||
* @type {?number} | ||
*/ | ||
shakaExtern.Cue.prototype.line; | ||
/** | ||
* Separation between line areas inside the cue box in px or em | ||
* (e.g. '100px'/'100em'). If not specified, should be no less than | ||
* the largest font size applied to the text in the cue. | ||
* @type {string}. | ||
*/ | ||
shakaExtern.Cue.prototype.lineHeight; | ||
/** | ||
* Line alignment of the cue box. | ||
* @type {shaka.text.Cue.lineAlign} | ||
*/ | ||
shakaExtern.Cue.prototype.lineAlign; | ||
/** | ||
* Vertical alignments of the cues within their extents. | ||
* @type {shaka.text.Cue.displayAlign} | ||
*/ | ||
shakaExtern.Cue.prototype.displayAlign; | ||
/** | ||
* Text color represented by any string that would be | ||
* accepted in CSS. | ||
* E. g. '#FFFFFF' or 'white'. | ||
* @type {!string} | ||
*/ | ||
shakaExtern.Cue.prototype.color; | ||
/** | ||
* Text background color represented by any string that would be | ||
* accepted in CSS. | ||
* E. g. '#FFFFFF' or 'white'. | ||
* @type {!string} | ||
*/ | ||
shakaExtern.Cue.prototype.backgroundColor; | ||
/** | ||
* Text font size in px or em (e.g. '100px'/'100em'). | ||
* @type {string} | ||
*/ | ||
shakaExtern.Cue.prototype.fontSize; | ||
/** | ||
* Text font weight. Either normal or bold. | ||
* @type {shaka.text.Cue.fontWeight} | ||
*/ | ||
shakaExtern.Cue.prototype.fontWeight; | ||
/** | ||
* Text font style. Normal, italic or oblique. | ||
* @type {shaka.text.Cue.fontStyle} | ||
*/ | ||
shakaExtern.Cue.prototype.fontStyle; | ||
/** | ||
* Text font family. | ||
* @type {!string} | ||
*/ | ||
shakaExtern.Cue.prototype.fontFamily; | ||
/** | ||
* Text decoration. A combination of underline, overline | ||
* and line through. Empty array means no decoration. | ||
* @type {!Array.<!shaka.text.Cue.textDecoration>} | ||
*/ | ||
shakaExtern.Cue.prototype.textDecoration; | ||
/** | ||
* Whether or not line wrapping should be applied | ||
* to the cue. | ||
* @type {boolean} | ||
*/ | ||
shakaExtern.Cue.prototype.wrapLine; | ||
/** | ||
* Id of the cue. | ||
* @type {!string} | ||
*/ | ||
shakaExtern.Cue.prototype.id; | ||
/** | ||
* An interface for plugins that parse text tracks. | ||
@@ -74,3 +281,3 @@ * | ||
* for each cue. | ||
* @return {!Array.<!shaka.text.Cue>} | ||
* @return {!Array.<!shakaExtern.Cue>} | ||
* | ||
@@ -77,0 +284,0 @@ * @exportDoc |
@@ -667,4 +667,3 @@ /** | ||
function(contentType, appendWindowEnd) { | ||
var fudge = 1 / 25; // one frame, assuming a low framerate | ||
this.sourceBuffers_[contentType].appendWindowEnd = appendWindowEnd + fudge; | ||
this.sourceBuffers_[contentType].appendWindowEnd = appendWindowEnd; | ||
@@ -671,0 +670,0 @@ // Fake 'updateend' event to resolve the operation. |
@@ -206,4 +206,4 @@ /** | ||
shaka.media.PlayheadObserver.cloneTimelineInfo_ = function(source) { | ||
// cloneObject will ignore non-simple objects like the DOM element. | ||
var copy = shaka.util.ConfigUtils.cloneObject(source); | ||
// cloneObject uses JSON to clone, which won't copy the DOM element. | ||
copy.eventElement = source.eventElement; | ||
@@ -210,0 +210,0 @@ return copy; |
@@ -50,2 +50,3 @@ /** | ||
function(all, part) { | ||
/** @type {!Array.<string>} */ | ||
var header = part.split(': '); | ||
@@ -52,0 +53,0 @@ all[header[0].toLowerCase()] = header.slice(1).join(': '); |
@@ -29,2 +29,3 @@ /** | ||
* | ||
* @implements {shakaExtern.Cue} | ||
* @constructor | ||
@@ -37,143 +38,69 @@ * @struct | ||
/** | ||
* The start time of the cue in seconds and fractions of a second. | ||
* @type {number} | ||
*/ | ||
/** @override @exportInterface */ | ||
this.startTime = startTime; | ||
/** | ||
* The end time of the cue in seconds and fractions of a second. | ||
* @type {number} | ||
*/ | ||
/** @override @exportInterface */ | ||
this.endTime = endTime; | ||
/** | ||
* The text payload of the cue. | ||
* @type {!string} | ||
*/ | ||
/** @override @exportInterface */ | ||
this.payload = payload; | ||
/** | ||
* The indent (in percent) of the cue box in the direction defined by the | ||
* writing direction. | ||
* @type {?number} | ||
*/ | ||
/** @override @exportInterface */ | ||
this.region = {x: 0, y: 0, width: 100, height: 100}; | ||
/** @override @exportInterface */ | ||
this.position = null; | ||
/** | ||
* Position alignment of the cue. | ||
* @type {shaka.text.Cue.positionAlign} | ||
*/ | ||
/** @override @exportInterface */ | ||
this.positionAlign = Cue.positionAlign.AUTO; | ||
/** | ||
* Size of the cue box (in percents). | ||
* @type {number} | ||
*/ | ||
/** @override @exportInterface */ | ||
this.size = 100; | ||
/** | ||
* Alignment of the text inside the cue box. | ||
* @type {shaka.text.Cue.textAlign} | ||
*/ | ||
/** @override @exportInterface */ | ||
this.textAlign = Cue.textAlign.CENTER; | ||
/** | ||
* Text writing direction of the cue. | ||
* @type {shaka.text.Cue.writingDirection} | ||
*/ | ||
/** @override @exportInterface */ | ||
this.writingDirection = Cue.writingDirection.HORIZONTAL_LEFT_TO_RIGHT; | ||
/** | ||
* The way to interpret line field. (Either as an integer line number or | ||
* percentage from the display box). | ||
* @type {shaka.text.Cue.lineInterpretation} | ||
*/ | ||
/** @override @exportInterface */ | ||
this.lineInterpretation = Cue.lineInterpretation.LINE_NUMBER; | ||
/** | ||
* The offset from the display box in either number of lines or | ||
* percentage depending on the value of lineInterpretation. | ||
* @type {?number} | ||
*/ | ||
/** @override @exportInterface */ | ||
this.line = null; | ||
/** | ||
* Separation between line areas inside the cue box in px or em | ||
* (e.g. '100px'/'100em'). If not specified, should be no less than | ||
* the largest font size applied to the text in the cue. | ||
* @type {string}. | ||
*/ | ||
/** @override @exportInterface */ | ||
this.lineHeight = ''; | ||
/** | ||
* Line alignment of the cue box. | ||
* @type {shaka.text.Cue.lineAlign} | ||
*/ | ||
/** @override @exportInterface */ | ||
this.lineAlign = Cue.lineAlign.CENTER; | ||
/** | ||
* Vertical alignments of the cues within their extents. | ||
* @type {shaka.text.Cue.displayAlign} | ||
*/ | ||
/** @override @exportInterface */ | ||
this.displayAlign = Cue.displayAlign.BEFORE; | ||
/** | ||
* Text color represented by any string that would be | ||
* accepted in CSS. | ||
* E. g. '#FFFFFF' or 'white'. | ||
* @type {!string} | ||
*/ | ||
/** @override @exportInterface */ | ||
this.color = ''; | ||
/** | ||
* Text background color represented by any string that would be | ||
* accepted in CSS. | ||
* E. g. '#FFFFFF' or 'white'. | ||
* @type {!string} | ||
*/ | ||
/** @override @exportInterface */ | ||
this.backgroundColor = ''; | ||
/** | ||
* Text font size in px or em (e.g. '100px'/'100em'). | ||
* @type {string} | ||
*/ | ||
/** @override @exportInterface */ | ||
this.fontSize = ''; | ||
/** | ||
* Text font weight. Either normal or bold. | ||
* @type {shaka.text.Cue.fontWeight} | ||
*/ | ||
/** @override @exportInterface */ | ||
this.fontWeight = Cue.fontWeight.NORMAL; | ||
/** | ||
* Text font style. Normal, italic or oblique. | ||
* @type {shaka.text.Cue.fontStyle} | ||
*/ | ||
/** @override @exportInterface */ | ||
this.fontStyle = Cue.fontStyle.NORMAL; | ||
/** | ||
* Text font family. | ||
* @type {!string} | ||
*/ | ||
/** @override @exportInterface */ | ||
this.fontFamily = ''; | ||
/** | ||
* Text decoration. A combination of underline, overline | ||
* and line through. Empty array means no decoration. | ||
* @type {!Array.<!shaka.text.Cue.textDecoration>} | ||
*/ | ||
/** @override @exportInterface */ | ||
this.textDecoration = []; | ||
/** | ||
* Whether or not line wrapping should be applied | ||
* to the cue. | ||
* @type {boolean} | ||
*/ | ||
/** @override @exportInterface */ | ||
this.wrapLine = true; | ||
/** | ||
* Id of the cue. | ||
* @type {!string} | ||
*/ | ||
/** @override @exportInterface */ | ||
this.id = ''; | ||
@@ -224,6 +151,6 @@ }; | ||
shaka.text.Cue.writingDirection = { | ||
HORIZONTAL_LEFT_TO_RIGHT: 0, | ||
HORIZONTAL_RIGHT_TO_LEFT: 1, | ||
VERTICAL_LEFT_TO_RIGHT: 2, | ||
VERTICAL_RIGHT_TO_LEFT: 3 | ||
'HORIZONTAL_LEFT_TO_RIGHT': 0, | ||
'HORIZONTAL_RIGHT_TO_LEFT': 1, | ||
'VERTICAL_LEFT_TO_RIGHT': 2, | ||
'VERTICAL_RIGHT_TO_LEFT': 3 | ||
}; | ||
@@ -237,4 +164,4 @@ | ||
shaka.text.Cue.lineInterpretation = { | ||
LINE_NUMBER: 0, | ||
PERCENTAGE: 1 | ||
'LINE_NUMBER': 0, | ||
'PERCENTAGE': 1 | ||
}; | ||
@@ -261,4 +188,4 @@ | ||
shaka.text.Cue.fontWeight = { | ||
NORMAL: 400, | ||
BOLD: 700 | ||
'NORMAL': 400, | ||
'BOLD': 700 | ||
}; | ||
@@ -283,6 +210,5 @@ | ||
shaka.text.Cue.textDecoration = { | ||
UNDERLINE: 'underline', | ||
LINE_THROUGH: 'lineThrough', | ||
OVERLINE: 'overline' | ||
'UNDERLINE': 'underline', | ||
'LINE_THROUGH': 'lineThrough', | ||
'OVERLINE': 'overline' | ||
}; | ||
@@ -77,3 +77,5 @@ /** | ||
sawMDAT = true; | ||
payload = this.parser_.parseMedia(data.buffer, time); | ||
// Join this to any previous payload, in case the mp4 has multiple | ||
// mdats. | ||
payload = payload.concat(this.parser_.parseMedia(data.buffer, time)); | ||
}.bind(this))).parse(data); | ||
@@ -80,0 +82,0 @@ |
@@ -206,3 +206,4 @@ /** | ||
return cues.filter(shaka.util.Functional.isNotNull); | ||
return /** @type {!Array.<!shakaExtern.Cue>} */ ( | ||
cues.filter(shaka.util.Functional.isNotNull)); | ||
}; | ||
@@ -209,0 +210,0 @@ |
@@ -20,2 +20,3 @@ /** | ||
goog.require('goog.asserts'); | ||
goog.require('shaka.log'); | ||
@@ -68,2 +69,10 @@ | ||
this.textTrack_.mode = 'hidden'; | ||
// Since |textTrack_.cues| can be null if the track is disabled, cache a | ||
// reference to the list so that we can always read it. | ||
/** @private {TextTrackCueList} */ | ||
this.textTrackCues_ = this.textTrack_.cues; | ||
goog.asserts.assert( | ||
this.textTrackCues_, | ||
'Cues should be accessible when mode is set to "hidden".'); | ||
}; | ||
@@ -160,3 +169,3 @@ | ||
/** | ||
* @param {!shaka.text.Cue} shakaCue | ||
* @param {!shakaExtern.Cue} shakaCue | ||
* @return {TextTrackCue} | ||
@@ -176,2 +185,3 @@ * @private | ||
var Cue = shaka.text.Cue; | ||
/** @type {VTTCue} */ | ||
var vttCue = new VTTCue(shakaCue.startTime, | ||
@@ -191,3 +201,2 @@ shakaCue.endTime, | ||
// Safari 10 seems to throw on align='center'. | ||
// Catch any exception and let the workaround below take care of it. | ||
vttCue.align = shakaCue.textAlign; | ||
@@ -197,5 +206,5 @@ } catch (exception) {} | ||
if (shakaCue.textAlign == 'center' && vttCue.align != 'center') { | ||
// Workaround for a Chrome bug http://crbug.com/663797 | ||
// Chrome does not support align = 'center' | ||
vttCue.position = 'auto'; | ||
// We want vttCue.position = 'auto'. By default, |position| is set to | ||
// "auto". If we set it to "auto" safari will throw an exception, so we | ||
// must rely on the default value. | ||
vttCue.align = 'middle'; | ||
@@ -220,2 +229,11 @@ } | ||
if (window.VTTRegion && shakaCue.region) { | ||
var region = new VTTRegion(); | ||
region.viewportAnchorX = shakaCue.region.x; | ||
region.viewportAnchorY = shakaCue.region.y; | ||
region.width = shakaCue.region.width; | ||
region.height = shakaCue.region.height; | ||
vttCue.region = region; | ||
} | ||
return vttCue; | ||
@@ -232,3 +250,3 @@ }; | ||
shaka.text.SimpleTextDisplayer.prototype.removeWhere_ = function(predicate) { | ||
var cues = this.textTrack_.cues; | ||
var cues = this.textTrackCues_; | ||
var removeMe = []; | ||
@@ -235,0 +253,0 @@ |
@@ -350,13 +350,2 @@ /** | ||
var extent = TtmlTextParser.getStyleAttribute_( | ||
cueElement, region, styles, 'tts:extent'); | ||
if (extent) { | ||
results = TtmlTextParser.percentValues_.exec(extent); | ||
if (results != null) { | ||
// Use width value of the extent attribute for size. | ||
// Height value is ignored. | ||
cue.size = Number(results[1]); | ||
} | ||
} | ||
var direction = TtmlTextParser.getStyleAttribute_( | ||
@@ -388,17 +377,14 @@ cueElement, region, styles, 'tts:direction'); | ||
if (results != null) { | ||
// for horizontal text use first coordinate of tts:origin | ||
// to represent position of the cue and second - for line. | ||
// Otherwise (vertical), use them the other way around. | ||
if (cue.writingDirection == | ||
Cue.writingDirection.HORIZONTAL_LEFT_TO_RIGHT || | ||
cue.writingDirection == | ||
Cue.writingDirection.HORIZONTAL_RIGHT_TO_LEFT) { | ||
cue.position = Number(results[1]); | ||
cue.line = Number(results[2]); | ||
} else { | ||
cue.position = Number(results[2]); | ||
cue.line = Number(results[1]); | ||
} | ||
cue.region.x = Number(results[1]); | ||
cue.region.y = Number(results[2]); | ||
} | ||
} | ||
cue.lineInterpretation = Cue.lineInterpretation.PERCENTAGE; | ||
var extent = TtmlTextParser.getStyleAttribute_( | ||
cueElement, region, styles, 'tts:extent'); | ||
if (extent) { | ||
results = TtmlTextParser.percentValues_.exec(extent); | ||
if (results != null) { | ||
cue.region.width = Number(results[1]); | ||
cue.region.height = Number(results[2]); | ||
} | ||
@@ -405,0 +391,0 @@ } |
@@ -99,3 +99,4 @@ /** | ||
* prototypes, custom properties (e.g. read-only), or multiple references to | ||
* the same object. This uses JSON to clone. | ||
* the same object. If the caller needs these fields, it will need to set them | ||
* after this returns. | ||
* | ||
@@ -107,3 +108,40 @@ * @template T | ||
shaka.util.ConfigUtils.cloneObject = function(arg) { | ||
return JSON.parse(JSON.stringify(arg)); | ||
var seenObjects = []; | ||
// This recursively clones the value |val|, using the captured variable | ||
// |seenObjects| to track the objects we have already cloned. | ||
var clone = function(val) { | ||
switch (typeof val) { | ||
case 'undefined': | ||
case 'boolean': | ||
case 'number': | ||
case 'string': | ||
case 'symbol': | ||
case 'function': | ||
return val; | ||
case 'object': | ||
default: | ||
// typeof null === 'object' | ||
if (!val) return val; | ||
if (seenObjects.indexOf(val) >= 0) | ||
return null; | ||
var isArray = val.constructor == Array; | ||
if (val.constructor != Object && !isArray) | ||
return null; | ||
seenObjects.push(val); | ||
var ret = isArray ? [] : {}; | ||
// Note |name| will equal a number for arrays. | ||
for (var name in val) { | ||
ret[name] = clone(val[name]); | ||
} | ||
// Length is a non-enumerable property, but we should copy it over in | ||
// case it is not the default. | ||
if (isArray) | ||
ret.length = val.length; | ||
return ret; | ||
} | ||
}; | ||
return clone(arg); | ||
}; |
@@ -206,4 +206,3 @@ /** | ||
} | ||
var value = this.dataView_.buffer.slice( | ||
this.position_, this.position_ + bytes); | ||
var value = this.createDataSlice_(this.position_, this.position_ + bytes); | ||
this.position_ += bytes; | ||
@@ -243,3 +242,3 @@ return new Uint8Array(value); | ||
var ret = this.dataView_.buffer.slice(start, this.position_); | ||
var ret = this.createDataSlice_(start, this.position_); | ||
// skip string termination | ||
@@ -261,1 +260,19 @@ this.position_ += 1; | ||
}; | ||
/** | ||
* Creates a copy of the DataView in a similar way to ArrayBuffer.slice. | ||
* | ||
* @param {number} start | ||
* @param {number} end | ||
* @return {!ArrayBuffer} | ||
* @private | ||
*/ | ||
shaka.util.DataViewReader.prototype.createDataSlice_ = function(start, end) { | ||
goog.asserts.assert(end >= start, 'Cannot have end < start'); | ||
goog.asserts.assert(this.dataView_.byteOffset == 0, | ||
'Doesn\'t support sub-buffer views'); | ||
var temp = new Uint8Array(end - start); | ||
temp.set(new Uint8Array(this.dataView_.buffer, start, end - start)); | ||
return temp.buffer; | ||
}; |
@@ -34,8 +34,14 @@ /** | ||
* @extends {Error} | ||
* @implements {shakaExtern.Error} | ||
*/ | ||
shaka.util.Error = function(severity, category, code, var_args) { | ||
/** @override @exportInterface */ | ||
this.severity = severity; | ||
/** @override @exportInterface */ | ||
this.category = category; | ||
/** @override @exportInterface */ | ||
this.code = code; | ||
/** @override @exportInterface */ | ||
this.data = Array.prototype.slice.call(arguments, 3); | ||
/** @override @exportInterface */ | ||
this.handled = false; | ||
@@ -83,37 +89,2 @@ | ||
/** | ||
* @type {shaka.util.Error.Severity} | ||
* @expose | ||
*/ | ||
shaka.util.Error.prototype.severity; | ||
/** | ||
* @const {shaka.util.Error.Category} | ||
* @expose | ||
*/ | ||
shaka.util.Error.prototype.category; | ||
/** | ||
* @const {shaka.util.Error.Code} | ||
* @expose | ||
*/ | ||
shaka.util.Error.prototype.code; | ||
/** | ||
* @const {!Array.<*>} | ||
* @expose | ||
*/ | ||
shaka.util.Error.prototype.data; | ||
/** | ||
* @type {boolean} | ||
* @expose | ||
*/ | ||
shaka.util.Error.prototype.handled; | ||
/** | ||
* @return {string} | ||
@@ -120,0 +91,0 @@ * @override |
{ | ||
"name": "shaka-player", | ||
"description": "DASH/EME video player library", | ||
"version": "2.2.1", | ||
"version": "2.2.2", | ||
"homepage": "https://github.com/google/shaka-player", | ||
@@ -6,0 +6,0 @@ "author": "Google", |
@@ -117,2 +117,7 @@ /** | ||
]); | ||
}).then(function() { | ||
// Work-around: allow the Tizen media pipeline to cool down. | ||
// Without this, Tizen's pipeline seems to hang in subsequent tests. | ||
// TODO: file a bug on Tizen | ||
return Util.delay(0.1); | ||
}).catch(fail).then(done); | ||
@@ -119,0 +124,0 @@ }); |
@@ -302,9 +302,13 @@ /** | ||
// Store the first variant. | ||
storage.configure({ | ||
trackSelectionCallback: function(tracks) { | ||
return tracks.slice(0, 1); | ||
} | ||
}); | ||
/** | ||
* @param {!Array.<shakaExtern.Track>} tracks | ||
* @return {!Array.<shakaExtern.Track>} | ||
*/ | ||
var trackSelectionCallback = function(tracks) { | ||
// Store the first variant. | ||
return tracks.slice(0, 1); | ||
}; | ||
storage.configure({trackSelectionCallback: trackSelectionCallback}); | ||
storage.store('') | ||
@@ -311,0 +315,0 @@ .then(function(data) { |
@@ -90,3 +90,8 @@ /** | ||
player.destroy() | ||
]).catch(fail).then(done); | ||
]).then(function() { | ||
// Work-around: allow the Tizen media pipeline to cool down. | ||
// Without this, Tizen's pipeline seems to hang in subsequent tests. | ||
// TODO: file a bug on Tizen | ||
return Util.delay(0.1); | ||
}).catch(fail).then(done); | ||
}); | ||
@@ -204,3 +209,6 @@ | ||
expect(video.currentTime).toBeLessThan(9); | ||
expect(video.buffered.end(0)).toBeGreaterThan(11); | ||
// The two periods might not be in a single contiguous buffer, so don't | ||
// check end(0). Gap-jumping will deal with any discontinuities. | ||
var bufferEnd = video.buffered.end(video.buffered.length - 1); | ||
expect(bufferEnd).toBeGreaterThan(11); | ||
@@ -207,0 +215,0 @@ // Change to a different language; this should clear the buffers and |
@@ -55,3 +55,3 @@ /** | ||
* @param {!shakaExtern.TextParser.TimeContext} time | ||
* @return {!Array.<shaka.text.Cue>} | ||
* @return {!Array.<!shakaExtern.Cue>} | ||
*/ | ||
@@ -58,0 +58,0 @@ function parseVtt(text, time) { |
@@ -23,2 +23,4 @@ /** | ||
var ttmlSegmentUri = '/base/test/test/assets/ttml-segment.mp4'; | ||
var ttmlSegmentMultipleMDATUri = | ||
'/base/test/test/assets/ttml-segment-multiplemdat.mp4'; | ||
var audioInitSegmentUri = '/base/test/test/assets/sintel-audio-init.mp4'; | ||
@@ -28,2 +30,3 @@ | ||
var ttmlSegment; | ||
var ttmlSegmentMultipleMDAT; | ||
var audioInitSegment; | ||
@@ -35,2 +38,3 @@ | ||
shaka.test.Util.fetch(ttmlSegmentUri), | ||
shaka.test.Util.fetch(ttmlSegmentMultipleMDATUri), | ||
shaka.test.Util.fetch(audioInitSegmentUri) | ||
@@ -40,3 +44,4 @@ ]).then(function(responses) { | ||
ttmlSegment = responses[1]; | ||
audioInitSegment = responses[2]; | ||
ttmlSegmentMultipleMDAT = responses[2]; | ||
audioInitSegment = responses[3]; | ||
}).catch(fail).then(done); | ||
@@ -54,5 +59,13 @@ }); | ||
var ret = parser.parseMedia(ttmlSegment, time); | ||
expect(ret.length).toBeGreaterThan(0); | ||
expect(ret.length).toBe(10); | ||
}); | ||
it('handles media segments with multiple mdats', function() { | ||
var parser = new shaka.text.Mp4TtmlParser(); | ||
parser.parseInit(ttmlInitSegment); | ||
var time = {periodStart: 0, segmentStart: 0, segmentEnd: 0 }; | ||
var ret = parser.parseMedia(ttmlSegmentMultipleMDAT, time); | ||
expect(ret.length).toBe(20); | ||
}); | ||
it('accounts for offset', function() { | ||
@@ -59,0 +72,0 @@ var time1 = {periodStart: 0, segmentStart: 0, segmentEnd: 0 }; |
@@ -268,3 +268,5 @@ /** | ||
{ | ||
start: 62.05, end: 3723.2, payload: 'Test', size: 50} | ||
start: 62.05, end: 3723.2, payload: 'Test', | ||
region: {x: 0, y: 0, width: 50, height: 16} | ||
} | ||
], | ||
@@ -282,128 +284,120 @@ '<tt xmlns:tts="ttml#styling">' + | ||
it('supports line and position settings for horizontal text', | ||
function() { | ||
verifyHelper( | ||
[ | ||
{ | ||
start: 62.05, | ||
end: 3723.2, | ||
payload: 'Test', | ||
position: 50, | ||
line: 16 | ||
} | ||
], | ||
'<tt xmlns:tts="ttml#styling">' + | ||
'<layout>' + | ||
'<region xml:id="subtitleArea" tts:origin="50% 16%"/>' + | ||
'</layout>' + | ||
'<body region="subtitleArea">' + | ||
'<p begin="01:02.05" end="01:02:03.200">Test</p>' + | ||
'</body>' + | ||
'</tt>', | ||
{periodStart: 0, segmentStart: 0, segmentEnd: 0 }); | ||
verifyHelper( | ||
[ | ||
{ | ||
start: 62.05, | ||
end: 3723.2, | ||
payload: 'Test', | ||
position: 50, | ||
line: 16 | ||
} | ||
], | ||
'<tt xmlns:tts="ttml#styling">' + | ||
'<layout>' + | ||
'<region xml:id="subtitleArea" tts:origin="50% 16%" ' + | ||
'tts:writingMode="lrtb" />' + | ||
'</layout>' + | ||
'<body region="subtitleArea">' + | ||
'<p begin="01:02.05" end="01:02:03.200">Test</p>' + | ||
'</body>' + | ||
'</tt>', | ||
{periodStart: 0, segmentStart: 0, segmentEnd: 0 }); | ||
verifyHelper( | ||
[ | ||
{ | ||
start: 62.05, | ||
end: 3723.2, | ||
payload: 'Test', | ||
position: 50, | ||
line: 16 | ||
} | ||
], | ||
'<tt xmlns:tts="ttml#styling">' + | ||
'<layout>' + | ||
'<region xml:id="subtitleArea" tts:origin="50% 16%" ' + | ||
'tts:writingMode="lr" />' + | ||
'</layout>' + | ||
'<body region="subtitleArea">' + | ||
'<p begin="01:02.05" end="01:02:03.200">Test</p>' + | ||
'</body>' + | ||
'</tt>', | ||
{periodStart: 0, segmentStart: 0, segmentEnd: 0 }); | ||
}); | ||
it('supports regionsettings for horizontal text', function() { | ||
verifyHelper( | ||
[ | ||
{ | ||
start: 62.05, | ||
end: 3723.2, | ||
payload: 'Test', | ||
region: {x: 50, y: 16, width: 100, height: 100} | ||
} | ||
], | ||
'<tt xmlns:tts="ttml#styling">' + | ||
'<layout>' + | ||
'<region xml:id="subtitleArea" tts:origin="50% 16%"/>' + | ||
'</layout>' + | ||
'<body region="subtitleArea">' + | ||
'<p begin="01:02.05" end="01:02:03.200">Test</p>' + | ||
'</body>' + | ||
'</tt>', | ||
{periodStart: 0, segmentStart: 0, segmentEnd: 0 }); | ||
verifyHelper( | ||
[ | ||
{ | ||
start: 62.05, | ||
end: 3723.2, | ||
payload: 'Test', | ||
region: {x: 50, y: 16, width: 100, height: 100} | ||
} | ||
], | ||
'<tt xmlns:tts="ttml#styling">' + | ||
'<layout>' + | ||
'<region xml:id="subtitleArea" tts:origin="50% 16%" ' + | ||
'tts:writingMode="lrtb" />' + | ||
'</layout>' + | ||
'<body region="subtitleArea">' + | ||
'<p begin="01:02.05" end="01:02:03.200">Test</p>' + | ||
'</body>' + | ||
'</tt>', | ||
{periodStart: 0, segmentStart: 0, segmentEnd: 0 }); | ||
verifyHelper( | ||
[ | ||
{ | ||
start: 62.05, | ||
end: 3723.2, | ||
payload: 'Test', | ||
region: {x: 50, y: 16, width: 100, height: 100} | ||
} | ||
], | ||
'<tt xmlns:tts="ttml#styling">' + | ||
'<layout>' + | ||
'<region xml:id="subtitleArea" tts:origin="50% 16%" ' + | ||
'tts:writingMode="lr" />' + | ||
'</layout>' + | ||
'<body region="subtitleArea">' + | ||
'<p begin="01:02.05" end="01:02:03.200">Test</p>' + | ||
'</body>' + | ||
'</tt>', | ||
{periodStart: 0, segmentStart: 0, segmentEnd: 0 }); | ||
}); | ||
it('supports line and position settings for vertical text', | ||
function() { | ||
verifyHelper( | ||
[ | ||
{ | ||
start: 62.05, | ||
end: 3723.2, | ||
payload: 'Test', | ||
position: 16, | ||
line: 50 | ||
} | ||
], | ||
'<tt xmlns:tts="ttml#styling">' + | ||
'<layout>' + | ||
'<region xml:id="subtitleArea" tts:origin="50% 16%" ' + | ||
'tts:writingMode="tb" />' + | ||
'</layout>' + | ||
'<body region="subtitleArea">' + | ||
'<p begin="01:02.05" end="01:02:03.200">Test</p>' + | ||
'</body>' + | ||
'</tt>', | ||
{periodStart: 0, segmentStart: 0, segmentEnd: 0 }); | ||
verifyHelper( | ||
[ | ||
{ | ||
start: 62.05, | ||
end: 3723.2, | ||
payload: 'Test', | ||
position: 16, | ||
line: 50 | ||
} | ||
], | ||
'<tt xmlns:tts="ttml#styling">' + | ||
'<layout>' + | ||
'<region xml:id="subtitleArea" tts:origin="50% 16%" ' + | ||
'tts:writingMode="tblr" />' + | ||
'</layout>' + | ||
'<body region="subtitleArea">' + | ||
'<p begin="01:02.05" end="01:02:03.200">Test</p>' + | ||
'</body>' + | ||
'</tt>', | ||
{periodStart: 0, segmentStart: 0, segmentEnd: 0 }); | ||
verifyHelper( | ||
[ | ||
{ | ||
start: 62.05, | ||
end: 3723.2, | ||
payload: 'Test', | ||
position: 16, | ||
line: 50 | ||
} | ||
], | ||
'<tt xmlns:tts="ttml#styling">' + | ||
'<layout>' + | ||
'<region xml:id="subtitleArea" tts:origin="50% 16%" ' + | ||
'tts:writingMode="tbrl" />' + | ||
'</layout>' + | ||
'<body region="subtitleArea">' + | ||
'<p begin="01:02.05" end="01:02:03.200">Test</p>' + | ||
'</body>' + | ||
'</tt>', | ||
{periodStart: 0, segmentStart: 0, segmentEnd: 0 }); | ||
}); | ||
it('supports region settings for vertical text', function() { | ||
verifyHelper( | ||
[ | ||
{ | ||
start: 62.05, | ||
end: 3723.2, | ||
payload: 'Test', | ||
region: {x: 50, y: 16, width: 100, height: 100} | ||
} | ||
], | ||
'<tt xmlns:tts="ttml#styling">' + | ||
'<layout>' + | ||
'<region xml:id="subtitleArea" tts:origin="50% 16%" ' + | ||
'tts:writingMode="tb" />' + | ||
'</layout>' + | ||
'<body region="subtitleArea">' + | ||
'<p begin="01:02.05" end="01:02:03.200">Test</p>' + | ||
'</body>' + | ||
'</tt>', | ||
{periodStart: 0, segmentStart: 0, segmentEnd: 0 }); | ||
verifyHelper( | ||
[ | ||
{ | ||
start: 62.05, | ||
end: 3723.2, | ||
payload: 'Test', | ||
region: {x: 50, y: 16, width: 100, height: 100} | ||
} | ||
], | ||
'<tt xmlns:tts="ttml#styling">' + | ||
'<layout>' + | ||
'<region xml:id="subtitleArea" tts:origin="50% 16%" ' + | ||
'tts:writingMode="tblr" />' + | ||
'</layout>' + | ||
'<body region="subtitleArea">' + | ||
'<p begin="01:02.05" end="01:02:03.200">Test</p>' + | ||
'</body>' + | ||
'</tt>', | ||
{periodStart: 0, segmentStart: 0, segmentEnd: 0 }); | ||
verifyHelper( | ||
[ | ||
{ | ||
start: 62.05, | ||
end: 3723.2, | ||
payload: 'Test', | ||
region: {x: 50, y: 16, width: 100, height: 100} | ||
} | ||
], | ||
'<tt xmlns:tts="ttml#styling">' + | ||
'<layout>' + | ||
'<region xml:id="subtitleArea" tts:origin="50% 16%" ' + | ||
'tts:writingMode="tbrl" />' + | ||
'</layout>' + | ||
'<body region="subtitleArea">' + | ||
'<p begin="01:02.05" end="01:02:03.200">Test</p>' + | ||
'</body>' + | ||
'</tt>', | ||
{periodStart: 0, segmentStart: 0, segmentEnd: 0 }); | ||
}); | ||
@@ -714,3 +708,3 @@ it('supports writingDirection setting', function() { | ||
'line', 'position', 'writingDirection', 'color', | ||
'backgroundColor', 'fontWeight', 'fontFamily', | ||
'backgroundColor', 'fontWeight', 'fontFamily', 'region', | ||
'wrapLine', 'lineHeight', 'fontStyle', 'fontSize']; | ||
@@ -726,7 +720,4 @@ expect(result).toBeTruthy(); | ||
var property = properties[j]; | ||
// Workaround a bug in the compiler's externs. | ||
// TODO: Remove when compiler is updated. | ||
if (property in cues[i]) | ||
expect(/** @type {?} */ (result[i])[property]) | ||
.toBe(cues[i][property]); | ||
expect(result[i][property]).toEqual(cues[i][property]); | ||
} | ||
@@ -733,0 +724,0 @@ |
@@ -253,5 +253,8 @@ 'use strict'; | ||
// mark members that implement an interface | ||
member.implements = member.implements || []; | ||
member.implements.push(interfaceMember.longname); | ||
// interfaceMember.longname is undefined on Object.toString for some reason | ||
if (interfaceMember.longname) { | ||
// mark members that implement an interface | ||
member.implements = member.implements || []; | ||
member.implements.push(interfaceMember.longname); | ||
} | ||
@@ -258,0 +261,0 @@ // mark interface members that the symbol implements |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
17434139
529
86673