Constructor
new NetworkingEngine(opt_onSegmentDownloadedopt)
NetworkingEngine wraps all networking operations. This accepts plugins that
handle the actual request. A plugin is registered using registerScheme.
Each scheme has at most one plugin to handle the request.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
opt_onSegmentDownloaded |
function(number, number)= |
<optional> |
Called when a segment is downloaded. Passed the duration, in milliseconds, that the request took; and the total number of bytes transferred. |
- Implements:
- Source:
Members
-
(static) defaultRetryParameters
-
Gets a copy of the default retry parameters.
- Source:
-
(static) PluginPriority :number
-
Priority level for network scheme plugins. If multiple plugins are provided for the same scheme, only the highest-priority one is used.
Type:
- number
Properties:
Name Value Type Description FALLBACK
1 number PREFERRED
2 number APPLICATION
3 number - Source:
-
(static) RequestType :number
-
Request types. Allows a filter to decide which requests to read/alter.
Type:
- number
Properties:
Name Value Type Description MANIFEST
0 number SEGMENT
1 number LICENSE
2 number APP
3 number - Source:
-
(private, static, non-null) schemes_ :Object.<string, shaka.net.NetworkingEngine.SchemeObject>
-
Contains the scheme plugins.
Type:
- Object.<string, shaka.net.NetworkingEngine.SchemeObject>
- Source:
-
(private) destroyed_ :boolean
-
Type:
- boolean
- Source:
-
(private, nullable) onSegmentDownloaded_ :?function(number, number)
-
Type:
- ?function(number, number)
- Source:
-
(private, non-null) requestFilters_ :Array.<shakaExtern.RequestFilter>
-
Type:
- Array.<shakaExtern.RequestFilter>
- Source:
-
(private, non-null) requests_ :Array.<!Promise>
-
Type:
- Array.<!Promise>
- Source:
-
(private, non-null) responseFilters_ :Array.<shakaExtern.ResponseFilter>
-
Type:
- Array.<shakaExtern.ResponseFilter>
- Source:
Methods
-
(private, static) getLocationProtocol_() → {string}
-
This is here only for testability. We can't mock location in our tests on all browsers, so instead we mock this.
- Source:
Returns:
The value of location.protocol.- Type
- string
-
(static) makeRequest(urisnon-null, retryParams) → {shakaExtern.Request}
-
Makes a simple network request for the given URIs.
Parameters:
Name Type Description uris
Array.<string> retryParams
shakaExtern.RetryParameters - Source:
Returns:
- Type
- shakaExtern.Request
-
(static) registerScheme(scheme, plugin, opt_priorityopt)
-
Registers a scheme plugin. This plugin will handle all requests with the given scheme. If a plugin with the same scheme already exists, it is replaced, unless the existing plugin is of higher priority. If no priority is provided, this defaults to the highest priority of APPLICATION.
Parameters:
Name Type Attributes Description scheme
string plugin
shakaExtern.SchemePlugin opt_priority
number <optional>
- Source:
-
(static) unregisterScheme(scheme)
-
Removes a scheme plugin.
Parameters:
Name Type Description scheme
string - Source:
-
clearAllRequestFilters()
-
Clear all request filters.
- Source:
-
clearAllResponseFilters()
-
Clear all response filters.
- Source:
-
destroy() → (non-null) {Promise}
-
Destroys the object, releasing all resources and shutting down all operations. Returns a Promise which is resolved when destruction is complete. This Promise should never be rejected.
- Implements:
- Source:
Returns:
- Type
- Promise
-
registerRequestFilter(filter)
-
Registers a new request filter. All filters are applied in the order they are registered.
Parameters:
Name Type Description filter
shakaExtern.RequestFilter - Source:
-
registerResponseFilter(filter)
-
Registers a new response filter. All filters are applied in the order they are registered.
Parameters:
Name Type Description filter
shakaExtern.ResponseFilter - Source:
-
request(type, request, opt_isCanceledopt, nullable) → (non-null) {Promise.<shakaExtern.Response>}
-
Makes a network request and returns the resulting data.
Parameters:
Name Type Attributes Description type
shaka.net.NetworkingEngine.RequestType request
shakaExtern.Request opt_isCanceled
?function()= <optional>
<nullable>
- Source:
Returns:
- Type
- Promise.<shakaExtern.Response>
-
(private) send_(type, request, backoffnon-null, index, requestFilterTime, isCanceled) → (non-null) {Promise.<shakaExtern.Response>}
-
Sends the given request to the correct plugin and retry using Backoff.
Parameters:
Name Type Description type
shaka.net.NetworkingEngine.RequestType request
shakaExtern.Request backoff
shaka.net.Backoff index
number requestFilterTime
number isCanceled
function() - Source:
Returns:
- Type
- Promise.<shakaExtern.Response>
-
unregisterRequestFilter(filter)
-
Removes a request filter.
Parameters:
Name Type Description filter
shakaExtern.RequestFilter - Source:
-
unregisterResponseFilter(filter)
-
Removes a response filter.
Parameters:
Name Type Description filter
shakaExtern.ResponseFilter - Source:
Type Definitions
-
SchemeObject
-
Type:
- {plugin: shakaExtern.SchemePlugin, priority: number}
Properties:
Name Type Description plugin
shakaExtern.SchemePlugin The associated plugin. priority
number The plugin's priority. - Source: