Skip to content
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

Merged

Conversation

gscragg
Copy link
Contributor

@gscragg gscragg commented Jun 13, 2017

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.

@googlebot
Copy link

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. I signed it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If your company signed a CLA, they designated a Point of Contact who decides which employees are authorized to participate. You may need to contact the Point of Contact for your company and ask to be added to the group of authorized contributors. If you don't know who your Point of Contact is, direct the project maintainer to go/cla#troubleshoot.
  • In order to pass this check, please resolve this problem and have the pull request author add another comment and the bot will run again.

Copy link
Member

@joeyparrish joeyparrish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks okay otherwise.

@@ -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();
Copy link
Member

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.

@@ -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
Copy link
Member

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.

@googlebot
Copy link

CLAs look good, thanks!

Copy link
Member

@joeyparrish joeyparrish left a 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.

@gscragg
Copy link
Contributor Author

gscragg commented Jun 13, 2017

Working on tests now. I appreciate the quick feedback.

@gscragg
Copy link
Contributor Author

gscragg commented Jun 14, 2017

Added some tests in.
I had a go at testing whether the underlying DrmEngine inside Storage#store was getting initialized correctly but I couldn't figure it out.

@@ -157,4 +157,45 @@ describe('Offline', function() {
.catch(fail)
.then(done);
});

it('stores, plays, and deletes protected content with a temporary license', function(done) {
Copy link
Member

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).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Thanks.

describe('temporary license', function(){

beforeEach(function(){
storage.configure({ isPersistentLicense: false });
Copy link
Member

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.

})
.then(function(manifestDb) {
expect(manifestDb).toBeTruthy();
expect(manifestDb.sessionIds.length).toEqual(0);
Copy link
Member

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).

expect(data.duration).toBe(0); // There are no segments.
expect(data.size).toEqual(0);
expect(data.tracks).toEqual(tracks);
})
Copy link
Member

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.

Copy link
Contributor Author

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?

Copy link
Member

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").

Copy link
Contributor Author

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?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either way.

Copy link
Contributor Author

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.

Copy link
Member

@joeyparrish joeyparrish left a 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!

@shaka-bot
Copy link
Collaborator

Test Failure:

Generating Closure dependencies...
Running Closure linter...
----- FILE  :  /var/lib/jenkins/jobs/Manual PR Test (local-tests)/workspace/lib/offline/storage.js -----
Line 301, E:0110: Line too long (90 characters).
Line 425, E:0110: Line too long (90 characters).
----- FILE  :  /var/lib/jenkins/jobs/Manual PR Test (local-tests)/workspace/test/offline/offline_integration.js -----
Line 161, E:0110: Line too long (98 characters).
Line 201, E:0010: Missing semicolon at end of line
----- FILE  :  /var/lib/jenkins/jobs/Manual PR Test (local-tests)/workspace/test/offline/storage_unit.js -----
Line 873, E:0002: Missing space before "{"
Line 876, E:0002: Missing space before "{"
Line 998, E:0002: Missing space before "{"
Found 7 errors, including 1 new errors, in 3 files (183 files OK).
Build step 'Execute shell' marked build as failure

Copy link
Member

@joeyparrish joeyparrish left a 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.

Copy link
Member

@joeyparrish joeyparrish left a 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.

@shaka-bot
Copy link
Collaborator

All tests passed!

@joeyparrish joeyparrish merged commit 59fe4e5 into shaka-project:master Jun 21, 2017
shaka-bot pushed a commit that referenced this pull request Jun 21, 2017
The new isPersistentLicense option was not documented in #878.
This adds docs and renames it to usePersistentLicense.

Closes #873

Change-Id: I59ed32c98660ad7c155392a1708eab98f63131c3
@github-actions github-actions bot added the status: archived Archived and locked; will not be updated label Jul 25, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: archived Archived and locked; will not be updated
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants