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.
feat(offline): Changed store order of operations.
This changes the order that things happen when the offline storage mechanism stores a manifest, so that the manifest is made and the segments are downloaded in separate steps. This is in preparation for adding background fetch support. Issue shaka-project#879 Change-Id: I4451db839b654f6134f06a58c240a9ca98d31a4e
- Loading branch information
Showing
10 changed files
with
432 additions
and
279 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
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,68 @@ | ||
/*! @license | ||
* Shaka Player | ||
* Copyright 2016 Google LLC | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
goog.provide('shaka.offline.DownloadInfo'); | ||
|
||
goog.require('shaka.util.Networking'); | ||
goog.requireType('shaka.media.InitSegmentReference'); | ||
goog.requireType('shaka.media.SegmentReference'); | ||
|
||
|
||
/** | ||
* An object that represents a single segment, that the storage system will soon | ||
* download, but has not yet started downloading. | ||
*/ | ||
shaka.offline.DownloadInfo = class { | ||
/** | ||
* @param {shaka.media.SegmentReference|shaka.media.InitSegmentReference} ref | ||
* @param {number} estimateId | ||
* @param {number} groupId | ||
* @param {boolean} isInitSegment | ||
*/ | ||
constructor(ref, estimateId, groupId, isInitSegment) { | ||
/** @type {shaka.media.SegmentReference|shaka.media.InitSegmentReference} */ | ||
this.ref = ref; | ||
|
||
/** @type {number} */ | ||
this.estimateId = estimateId; | ||
|
||
/** @type {number} */ | ||
this.groupId = groupId; | ||
|
||
/** @type {boolean} */ | ||
this.isInitSegment = isInitSegment; | ||
} | ||
|
||
/** | ||
* Creates an ID that encapsulates all important information in the ref, which | ||
* can then be used to check for equality. | ||
* @param {shaka.media.SegmentReference|shaka.media.InitSegmentReference} ref | ||
* @return {string} | ||
*/ | ||
static idForSegmentRef(ref) { | ||
// Escape the URIs using encodeURI, to make sure that a weirdly formed URI | ||
// cannot cause two unrelated refs to be considered equivalent. | ||
return ref.getUris().map((uri) => '{' + encodeURI(uri) + '}').join('') + | ||
':' + ref.startByte + ':' + ref.endByte; | ||
} | ||
|
||
/** @return {string} */ | ||
getRefId() { | ||
return shaka.offline.DownloadInfo.idForSegmentRef(this.ref); | ||
} | ||
|
||
/** | ||
* @param {shaka.extern.PlayerConfiguration} config | ||
* @return {!shaka.extern.Request} | ||
*/ | ||
makeSegmentRequest(config) { | ||
return shaka.util.Networking.createSegmentRequest( | ||
this.ref.getUris(), | ||
this.ref.startByte, | ||
this.ref.endByte, | ||
config.streaming.retryParameters); | ||
} | ||
}; |
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
Oops, something went wrong.