-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move common code in offline to offline_utils.
Added new offline_utils.js to hold utility methods for offline support. This also removes a circular dependency between Storage and DownloadManager. Closes #431 Change-Id: I98842c63c7ba57d4d02d7fe6bace57227982317c
- Loading branch information
1 parent
ed15d46
commit beb902e
Showing
8 changed files
with
69 additions
and
44 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
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,56 @@ | ||
/** | ||
* @license | ||
* Copyright 2016 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.offline.OfflineUtils'); | ||
|
||
goog.require('goog.asserts'); | ||
|
||
|
||
/** @const {!Object.<string, string>} */ | ||
shaka.offline.OfflineUtils.DB_SCHEME = {'manifest': 'key', 'segment': 'key'}; | ||
|
||
|
||
/** | ||
* Converts the given database manifest to a storedContent structure. | ||
* | ||
* @param {shakaExtern.ManifestDB} manifest | ||
* @return {shakaExtern.StoredContent} | ||
*/ | ||
shaka.offline.OfflineUtils.getStoredContent = function(manifest) { | ||
goog.asserts.assert(manifest.periods.length > 0, | ||
'Must be at least one Period.'); | ||
return { | ||
offlineUri: 'offline:' + manifest.key, | ||
originalManifestUri: manifest.originalManifestUri, | ||
duration: manifest.duration, | ||
size: manifest.size, | ||
tracks: manifest.periods[0].streams.map(function(stream) { | ||
return { | ||
id: stream.id, | ||
active: false, | ||
type: stream.contentType, | ||
bandwidth: 0, | ||
language: stream.language, | ||
kind: stream.kind || null, | ||
width: stream.width, | ||
height: stream.height, | ||
hasOutputRestrictions: false | ||
}; | ||
}), | ||
appMetadata: manifest.appMetadata | ||
}; | ||
}; |
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