-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Add APIs to read stats of segment HTTP requests #4152
Comments
Hi @Sergears and all, I think you can achieve all you need using current available API, by using the However, I think this is the opportunity to define like a common "standardized" API to enable any applications to:
We could define an API as following, for requests event:
and for responses event:
The properties lists are not exhaustive and can be completed, and the objective would be to design an API that could fit to every player type. But starting with dash.js is a good option to prove the concept. This same API could also be used for license requests. Also, to go further, beyond CDN load balancer topic, we can consider any other potential uses case for which one would like to execute the requests instead of the player itself.
This would avoid to implement force solutions redefining some parts of each player.
|
@bbert thanks for the response, I would definitely support the idea of a standard API that could fit every player, and especially the most powerful version of it where the application could execute the requests instead of the player itself. |
Thank you for starting the discussion. I summarized below what we have in place and what we might want to add based on your feedback. What we haveModifying segment/manifest requestsThe Modifying segment/manifest responsesThe Modifying license requestsA license request filter can be defined as shown here: https://reference.dashif.org/dash.js/nightly/samples/drm/license-wrapping.html Modifying license responsesA license response filter can be defined as shown here: https://reference.dashif.org/dash.js/nightly/samples/drm/license-wrapping.html Metadata Events for the applicationdash.js dispatches multiple events related to downloading segments and manifests, see http://cdn.dashjs.org/latest/jsdoc/MediaPlayerEvents.html for a complete list. As an example, the
Potential improvementsFrom my point of view the described functionality to modify requests and responses can be unified to make it easier for applications to modify request and response data. What I would suggest is the following (probably similar to what you mean in your description above): We allow the app to define (What we could consider is keeping the In general, the input for the filters would look like @bbert explained above. Application based request executionLet's discuss this in a different issue. |
Thank you @dsilhavy for the proposal. For the load balancer integration, the solution with Regarding the removal of some of the existing APIs, possible retro-compatibility issues need to be looked at. The last SVTA meeting there was a discussion about us submitting the PR for this. If we go this way, we first need the specs for the new APIs to be agreed upon by the dash.js team. |
@Sergears The Otherwise, I am obviously happy to review your PR if you want to implement this. Although these are breaking changes, we could do it as part of 4.8.0, no need to wait for 5.0.0. We need to adjust the samples in the sample section accordingly and announce these changes in the release notes. |
@dsilhavy I appreciate your feedback, and nice to see that we have converged on the functionality to implement. The discussed ambitious timing to implement this for MHV conference is probably not feasible as we would not be able to start working on this until May, either. We can discuss the timing later, depending on next sprint priorities. |
Thinking about this from the multi-player perspective, it would be great to add something like "Common Media Request" and "Common Media Response" interfaces/types to the Common Media Library. I'm wondering if it would be possible to reuse existing, standardized, APIs for this, or at least borrow the terminology. For example, import { CMCD } from '@svta.org/common-media-library';
interface CommonMediaRequest {
url: string;
method?: string;
headers?: Record<string, string>;
credentials?: RequestCredentials;
cmcd?: CMCD;
}
// ≈ Partial<PerformanceResourceTiming>
interface ResourceTiming {
// Returns the timestamp for the time a resource fetch started.
startTime: number;
// Returns a timestamp that is the difference between the responseEnd and the startTime properties.
duration: number;
// A number representing the size (in octets) of the fetched resource. The size includes the response header fields plus the response payload body.
transferSize: number;
// A timestamp immediately after the browser receives the first byte of the response from the server.
responseStart?: number;
// A timestamp immediately after the browser receives the last byte of the resource or immediately before the transport connection is closed, whichever comes first.
responseEnd?: number;
}
interface CommonMediaResponse {
url: string;
redirected: boolean;
status: number;
data: any;
request: CommonRequest;
resourceTiming: ResourceTiming;
} As for timeouts, or other errors for that matter, could those just be another set of properties on the response? interface CommonResponse {
...
ok: boolean;
error?: string; // could be 'timeout' or something similar
} |
Good point @littlespex , I do agree with your proposal.
If all agree, for point 1 how can we proceed @littlespex ? Pull request ? |
We are finalizing the contribution guidelines/workflow in the next few days, but for now make a branch and PR. We can also publish a dev/pre-release package. |
Hi @littlespex, please let me know when workflow is ready for Common Media Library (for the moment we still can't fork the repo). |
@bbert I've added you as a maintainer. You should be able to check out the repo directly and branch from there. |
@littlespex @bbert I like the idea, I was also looking to implement the Resource Timing API as part of the ABR/Throughput estimation refactoring. How are we dealing with player-specific attributes? There might be some attributes that are player-specific and should be part of either the request or the response object. Do you consider this to be a separate object or should there be some kind of generic object like |
Hi @dsilhavy It can of course be renamed and I guess we can consider adding this kind of property in the Maybe we should continue this discussion on svta repo (streaming-video-technology-alliance/common-media-library#18). |
Context
For the integration with the open source client-side CDN load balancer, we need to observe and modify HTTP requsts. The key role of the load balancer is to rewrite the URLs of the segment and manifest requests, for which the existing
RequestModifier
should work fine. However, we also need the additional capabilities described below.What is needed
- the timestamp when the HTTP request was made
- the timestamp when the HTTP response was received
- the byte size of the received payload
- (optional) the time to first byte to measure latency
The currently existing
SegmentResponseModifier
does not have access to this info as it only receives an internally fabricatedchunk
object. For example, in shaka player, this info is accessible withResponseFilter
that gives access the the wholeresponse
object.- we need to know which URL resulted in the timeout / error
This could be possible if there is some kind of event listener for
onError
andonTimeout
that gives access to the event object containing the URL. Or, alternatively, anonRetry
listener triggered when the player retries the segment request.Alternative solution
All of these can be probably be implemented by heavily intervening and extending the low level
XHRloader
andFetchLoader
functions, and wrapping the methodshttpRequest.onload
,httpRequest.onerror
,httpRequest.ontimeout
of the passedhttpRequest
. However this is a brute force solution. Instead, we would want to have the official methods to achieve the needed functionality. They would then be potentially useful for other needs beyond the CDN load balancer.P.S. We would eventually also want to integrate with the content steering functionality of dash.js, for which additional APIs may be needed, but this topic deserves a separate issue.
The text was updated successfully, but these errors were encountered: