Stop using Player inside Storage

We store the references to player's networking engine and
configuration in Storage, so there is no reason to call player
anymore. This change removes those lingering calls.

Issue #1297

Change-Id: I3486ffcb60cd80fd765259d690091cc3267bb8ba
This commit is contained in:
Aaron Vaage
2018-08-01 16:58:00 -07:00
parent 803347e0da
commit 34fe983ea0
+9 -18
View File
@@ -69,9 +69,6 @@ shaka.offline.Storage = function(player) {
shaka.util.Error.Code.LOCAL_PLAYER_INSTANCE_REQUIRED);
}
/** @private {shaka.Player} */
this.player_ = player;
/** @private {?shaka.extern.PlayerConfiguration} */
this.config_ = player.getSharedConfiguration();
@@ -126,7 +123,6 @@ shaka.offline.Storage.support = function() {
shaka.offline.Storage.prototype.destroy = function() {
this.config_ = null;
this.networkingEngine_ = null;
this.player_ = null;
// Wait for all the open operations to end. Wrap each operations so that a
// single rejected promise won't cause |Promise.all| to return early or to
@@ -222,7 +218,7 @@ shaka.offline.Storage.prototype.store = function(uri, appMetadata, mimeType) {
new Factory() :
await this.getParser_(uri, contentMimeType);
parser.configure(this.player_.getConfiguration().manifest);
parser.configure(this.config_.manifest);
return parser;
};
@@ -443,7 +439,7 @@ shaka.offline.Storage.prototype.removeFromDRM_ = function(uri, manifestDB) {
onEvent: () => {},
});
drmEngine.configure(this.player_.getConfiguration().drm);
drmEngine.configure(this.config_.drm);
let converter = new shaka.offline.ManifestConverter(
uri.mechanism(), uri.cell());
@@ -565,7 +561,7 @@ shaka.offline.Storage.prototype.loadInternal = function(
'Cannot call |loadInternal| after calling |destroy|');
const netEngine = this.networkingEngine_;
let config = this.player_.getConfiguration();
const config = this.config_;
/** @type {shaka.extern.Manifest} */
let manifest;
@@ -691,7 +687,7 @@ shaka.offline.Storage.prototype.filterPeriod_ = function(drmEngine, period) {
StreamUtils.filterNewPeriod(
drmEngine, activeAudio, activeVideo, period);
StreamUtils.applyRestrictions(
period.variants, this.player_.getConfiguration().restrictions, maxHwRes);
period.variants, this.config_.restrictions, maxHwRes);
};
@@ -961,7 +957,7 @@ shaka.offline.Storage.forEachSegment_ = function(stream, startTime, callback) {
* @private
*/
shaka.offline.Storage.prototype.checkDestroyed_ = function() {
if (!this.player_) {
if (!this.networkingEngine_) {
throw new shaka.util.Error(
shaka.util.Error.Severity.CRITICAL,
shaka.util.Error.Category.STORAGE,
@@ -994,7 +990,7 @@ shaka.offline.Storage.prototype.requireSupport_ = function() {
* @private
*/
shaka.offline.Storage.prototype.createRequest_ = function(segment) {
let retryParams = this.player_.getConfiguration().streaming.retryParameters;
const retryParams = this.config_.streaming.retryParameters;
let request = shaka.net.NetworkingEngine.makeRequest(
segment.getUris(), retryParams);
@@ -1040,19 +1036,14 @@ shaka.offline.Storage.prototype.startOperation_ = async function(action) {
*/
shaka.offline.Storage.prototype.getParser_ = async function(
assetUri, mimeType) {
const networkingEngine = this.networkingEngine_;
goog.asserts.assert(
this.player_,
'Cannot call |getParser_| after calling |destroy|.');
const networkingEngine = this.player_.getNetworkingEngine();
goog.asserts.assert(
networkingEngine,
'Cannot called |getParser_| after calling |destroy| on Player.');
networkingEngine, 'Cannot called |getParser_| after calling |destroy|');
const Factory = await shaka.media.ManifestParser.getFactory(
assetUri,
networkingEngine,
this.player_.getConfiguration().manifest.retryParameters,
this.config_.manifest.retryParameters,
mimeType);
return new Factory();