forked from shaka-project/shaka-player
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support testing is hierarchical. Player.support returns an object mapping out the support present in various parts of the system. This creates a shell for Player and DrmEngine, and introduces support tests for MediaSourceEngine, ManifestParser, and DrmEngine. This also adjusts the way support checks are done for text types, to allow for expansion into MP4-embedded text types and other segmented subtitle types. Text changes related to shaka-project#150 and shaka-project#146 Change-Id: I707f01ba52cba6262ee89bee2c1f28d24aca4655
- Loading branch information
1 parent
3e7014d
commit c9235f8
Showing
8 changed files
with
403 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/** | ||
* @license | ||
* Copyright 2015 Google Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
goog.provide('shaka.media.DrmEngine'); | ||
|
||
goog.require('shaka.asserts'); | ||
goog.require('shaka.log'); | ||
goog.require('shaka.media.Manifest'); | ||
goog.require('shaka.util.IDestroyable'); | ||
|
||
|
||
|
||
/** | ||
* @constructor | ||
* @struct | ||
* @implements {shaka.util.IDestroyable} | ||
*/ | ||
shaka.media.DrmEngine = function() { | ||
// TODO | ||
}; | ||
|
||
|
||
/** | ||
* @override | ||
*/ | ||
shaka.media.DrmEngine.prototype.destroy = function() { | ||
// TODO | ||
}; | ||
|
||
|
||
/** | ||
* Returns a Promise to map of EME support for well-known key systems. | ||
* | ||
* @return {!Promise.<!Object.<string, boolean>>} | ||
*/ | ||
shaka.media.DrmEngine.support = function() { | ||
// Every object in the support hierarchy has a "basic" member. | ||
// All "basic" members must be true for the library to be usable. | ||
var basic = | ||
!!window.MediaKeys && | ||
!!window.navigator && | ||
!!window.navigator.requestMediaKeySystemAccess && | ||
!!window.MediaKeySystemAccess && | ||
!!window.MediaKeySystemAccess.prototype.getConfiguration; | ||
|
||
var support = {'basic': basic}; | ||
|
||
var tests = []; | ||
if (support['basic']) { | ||
var testKeySystems = [ | ||
'org.w3.clearkey', | ||
'com.widevine.alpha', | ||
'com.microsoft.playready', | ||
'com.apple.fps.2_0', | ||
'com.apple.fps.1_0', | ||
'com.apple.fps', | ||
'com.adobe.primetime' | ||
]; | ||
|
||
testKeySystems.forEach(function(keySystem) { | ||
var p = navigator.requestMediaKeySystemAccess(keySystem, [{}]) | ||
.then(function() { | ||
support[keySystem] = true; | ||
}, function() { | ||
support[keySystem] = false; | ||
}); | ||
tests.push(p); | ||
}); | ||
} | ||
|
||
return Promise.all(tests).then(function() { | ||
return support; | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/** | ||
* @license | ||
* Copyright 2015 Google Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
goog.provide('shaka.Player'); | ||
|
||
goog.require('shaka.media.DrmEngine'); | ||
goog.require('shaka.media.ManifestParser'); | ||
goog.require('shaka.media.MediaSourceEngine'); | ||
goog.require('shaka.util.IDestroyable'); | ||
|
||
|
||
|
||
/** | ||
* @constructor | ||
* @struct | ||
* @implements {shaka.util.IDestroyable} | ||
* @export | ||
*/ | ||
shaka.Player = function() { | ||
// TODO | ||
}; | ||
|
||
|
||
/** | ||
* @override | ||
*/ | ||
shaka.Player.prototype.destroy = function() { | ||
// TODO | ||
}; | ||
|
||
|
||
/** | ||
* @define {string} A version number taken from git at compile time. | ||
*/ | ||
goog.define('GIT_VERSION', 'v1.9.9-alpha-debug'); | ||
|
||
|
||
/** | ||
* @const {string} | ||
* @export | ||
*/ | ||
shaka.Player.version = GIT_VERSION; | ||
|
||
|
||
/** | ||
* @typedef {{ | ||
* manifest: (!Object.<string, boolean>|undefined), | ||
* media: (!Object.<string, boolean>|undefined), | ||
* drm: (!Object.<string, boolean>|undefined), | ||
* supported: boolean | ||
* }} | ||
* @exportDoc | ||
*/ | ||
shaka.Player.SupportType; | ||
|
||
|
||
/** | ||
* @return {!Promise.<!shaka.Player.SupportType>} | ||
* @export | ||
*/ | ||
shaka.Player.support = function() { | ||
// Basic features needed for the library to be usable. | ||
var basic = !!window.Promise && !!window.Uint8Array && | ||
!!Array.prototype.forEach; | ||
|
||
if (basic) { | ||
var manifest = shaka.media.ManifestParser.support(); | ||
var media = shaka.media.MediaSourceEngine.support(); | ||
return shaka.media.DrmEngine.support().then(function(drm) { | ||
return { | ||
'manifest': manifest, | ||
'media': media, | ||
'drm': drm, | ||
'supported': manifest['basic'] && media['basic'] && drm['basic'] | ||
}; | ||
}); | ||
} else { | ||
// Return something Promise-like so that the application can still check | ||
// for support. | ||
return /** @type {!Promise.<!shaka.Player.SupportType>} */({ | ||
'then': function(fn) { | ||
fn({'supported': false}); | ||
} | ||
}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/** | ||
* @license | ||
* Copyright 2015 Google Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
// Require all exported classes. | ||
goog.require('shaka.Player'); | ||
goog.require('shaka.media.ManifestParser'); | ||
goog.require('shaka.media.PresentationTimeline'); | ||
goog.require('shaka.media.TextSourceBuffer'); | ||
goog.require('shaka.polyfill.installAll'); | ||
goog.require('shaka.util.Error'); | ||
goog.require('shaka.util.StringUtils'); | ||
goog.require('shaka.util.Uint8ArrayUtils'); | ||
|
||
// Require logging. | ||
goog.require('shaka.log'); | ||
|
||
// Require standard plugins. | ||
goog.require('shaka.media.VttTextParser'); | ||
goog.require('shaka.net.DataUriPlugin'); | ||
goog.require('shaka.net.HttpPlugin'); |
Oops, something went wrong.