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

asynchronous request filters #610

Closed
priyajeet opened this issue Nov 29, 2016 · 3 comments
Closed

asynchronous request filters #610

priyajeet opened this issue Nov 29, 2016 · 3 comments
Assignees
Labels
flag: good first issue This might be a relatively easy issue; good for new contributors status: archived Archived and locked; will not be updated type: enhancement New feature or request
Milestone

Comments

@priyajeet
Copy link

I am currently using v1 which allows request intercepting via source.setNetworkCallback(foo) and I believe the v2 equivalent for this is player.getNetworkingEngine().registerRequestFilter(foo)

In both cases I want to make a network request (or some async operation) inside foo, the result of which will be used in the actual filtering.

An example would be that I need to intercept all dash requests and decorate the headers with an authentication token. However this token may have expired half way during playback of the video. So I need to fetch a new token before allowing the next dash network request to happen. Essentially pausing it.

My current workaround is to increase the number of network retries for the dash player, and manage the token refresh outside the scope of the player network interceptor. This isolated token refresh request then alters some scope variable that function foo can eventually read. This works but is hacky and results in bunch of errors, say 401, but having a high retry count (and coupled with the new v2 backoffFactor) gets this going.

Another example would be that the dash player requests for a segment, however that response returns, say a 202, suggesting that the segment is still transcoding on the backend and not ready. One would like to prevent further requests till some async job suggests that the segment is ready and is OK to continue.

Can player.getNetworkingEngine().registerRequestFilter(foo) have foo that returns a promise which resolves to a modified shakaExtern.Requestupon which it should make the actual dash request.

@joeyparrish joeyparrish added the type: enhancement New feature or request label Nov 29, 2016
@joeyparrish joeyparrish changed the title Is there a way to intercept and modify a Request with data that is fetched asynchronously asynchronous request filters Nov 29, 2016
@joeyparrish joeyparrish added this to the v2.1.0 milestone Nov 29, 2016
@joeyparrish
Copy link
Member

Asynchronous networking filters seems like a pretty reasonable feature request. We'll look into it for v2.1. We will try to keep it backward-compatible with the synchronous filters we have today.

@joeyparrish joeyparrish added the flag: good first issue This might be a relatively easy issue; good for new contributors label Dec 15, 2016
@joeyparrish joeyparrish reopened this Jan 6, 2017
@joeyparrish
Copy link
Member

Looks like we still need to update the externs for request and response filters and add something to the docs.

@joeyparrish
Copy link
Member

And we still need to make the response filters async as well.

shaka-bot pushed a commit that referenced this issue Jan 9, 2017
Also updated externs.

Issue #610

Change-Id: I4c9539442d6fb77781296ea1acf123b3653e3b40
@shaka-project shaka-project locked and limited conversation to collaborators Mar 22, 2018
@shaka-bot shaka-bot added the status: archived Archived and locked; will not be updated label Apr 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
flag: good first issue This might be a relatively easy issue; good for new contributors status: archived Archived and locked; will not be updated type: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants