-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for offline data with an online license request #878
Support for offline data with an online license request #878
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed, please reply here (e.g.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks okay otherwise.
lib/offline/storage.js
Outdated
@@ -298,6 +298,9 @@ shaka.offline.Storage.prototype.remove = function(content) { | |||
drmEngine = new shaka.media.DrmEngine( | |||
netEngine, onError, function() {}, function() {}); | |||
drmEngine.configure(this.player_.getConfiguration().drm); | |||
// if the license is not stored, we dont need to enlist drmEngine in removing the license | |||
if (!this.config_.isPersistentLicense) return Promise.resolve(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Current config should not affect the remove() operation. If the content you're removing has persistent licenses, you should still call drmEngine.init()
and do the rest.
In particular, if there is no persistent license stored, sessionIds
will be empty and drmEngine.removeSessions()
will do nothing. So I think this check can be removed.
lib/offline/storage.js
Outdated
@@ -378,13 +381,14 @@ shaka.offline.Storage.prototype.list = function() { | |||
* @param {string} manifestUri | |||
* @param {function(*)} onError | |||
* @param {!shakaExtern.ManifestParser.Factory=} opt_manifestParserFactory | |||
* @param {!boolean=} opt_storeDataOnly |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This parameter appears to be unused.
CLAs look good, thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! Can you also update the tests?
See test/offline/*.js
and run python build/test.py
to run the tests locally.
Working on tests now. I appreciate the quick feedback. |
Added some tests in. |
test/offline/offline_integration.js
Outdated
@@ -157,4 +157,45 @@ describe('Offline', function() { | |||
.catch(fail) | |||
.then(done); | |||
}); | |||
|
|||
it('stores, plays, and deletes protected content with a temporary license', function(done) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change these it()
calls to drm_it()
. We only run DRM tests with the --drm flag, and drm_it()
does the filtering for us.
We do it this way so that tests can still be run without solid network connectivity. --drm enables DRM tests (some networking required for licensing) and --external enables external asset tests (solid network required to pull content from the internet).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. Thanks.
test/offline/storage_unit.js
Outdated
describe('temporary license', function(){ | ||
|
||
beforeEach(function(){ | ||
storage.configure({ isPersistentLicense: false }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't configure DRM, so the tests below are all exercising clear content paths. See the drmEngine
setup in the 'stores DRM info'
test and do the same here in beforeEach
.
test/offline/storage_unit.js
Outdated
}) | ||
.then(function(manifestDb) { | ||
expect(manifestDb).toBeTruthy(); | ||
expect(manifestDb.sessionIds.length).toEqual(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also verify that manifestDb.drmInfo
exists and matches the one you create in beforeEach, or else this is passing for the wrong reasons (clear content).
test/offline/storage_unit.js
Outdated
expect(data.duration).toBe(0); // There are no segments. | ||
expect(data.size).toEqual(0); | ||
expect(data.tracks).toEqual(tracks); | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should also load the content again and verify that is has drmInfo
(see below) so that you know you aren't just testing clear content.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added a new 'stores drm info' test (along with the additions to beforeEach
) to check the drmInfo.
Is this what you meant?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kind of. I was thinking of putting checks for drmInfo
into the offline sessions test below. Otherwise, running that test in isolation could result in a pass even if it was clear content.
Since the feature under test is that we do temporary licenses instead of persistent licenses, I think all three of these could be one test. In my opinion, the test above ("stores basic manifest") is irrelevant, and these other two should be combined into "does not store offline sessions").
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, that makes sense. As this creates a describe
with a single it
in it, would you like that to be flattened into a standalone it
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dropped down to the single test inside the describe
group.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! Thanks!
Test Failure:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The build bot found some linter errors. Run python build/all.py
to see this locally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. I'll have the build bot take another look.
All tests passed! |
Carrying on from the discussion in Issue #873
Currently only ChromeOS truly supports offline storage and playback.
This change allows other browsers to support offline storage of media only. A remote/temporary license request will be made during playback, so the user must still be online.
This will help users to pre-download content before traveling to a location with a patchy/expensive internet connection.