Class: shaka.net.NetworkingEngine

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, number)= <optional>
Called when a segment is downloaded. Passed the wall-clock time, in milliseconds, when the request began (before any outbound request filters); the wall-clock time, in milliseconds, when the response ended (after all retries and inbound response filters); and the total number of bytes transferred.
Implements:
Source:

Members

(static) RequestType :number

Request types. Allows a filter to decide which requests to read/alter.
Type:
  • number
Properties:
Name Type Description
MANIFEST number
SEGMENT number
LICENSE number
Source:

(private, static, non-null) schemes_ :Object.<string, ?shaka.net.NetworkingEngine.SchemePlugin>

Contains the scheme plugins.
Type:
Source:

(private) destroyed_ :boolean

Type:
  • boolean
Source:

(private, nullable) onSegmentDownloaded_ :?function(number, number, number)

Type:
  • ?function(number, number, number)
Source:

(private, non-null) requestFilters_ :Array.<shaka.net.NetworkingEngine.RequestFilter>

Type:
Source:

(private, non-null) requests_ :Array.<!Promise>

Type:
  • Array.<!Promise>
Source:

(private, non-null) responseFilters_ :Array.<shaka.net.NetworkingEngine.ResponseFilter>

Type:
Source:

Methods

(static) defaultRetryParameters() → {shakaExtern.RetryParameters}

Gets a copy of the default retry parameters.
Source:
Returns:
Type
shakaExtern.RetryParameters

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

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.
Parameters:
Name Type Description
scheme string
plugin shaka.net.NetworkingEngine.SchemePlugin
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 shaka.net.NetworkingEngine.RequestFilter
Source:

registerResponseFilter(filter)

Registers a new response filter. All filters are applied in the order they are registered.
Parameters:
Name Type Description
filter shaka.net.NetworkingEngine.ResponseFilter
Source:

request(type, request) → (non-null) {Promise.<shakaExtern.Response>}

Makes a network request and returns the resulting data.
Parameters:
Name Type Description
type shaka.net.NetworkingEngine.RequestType
request shakaExtern.Request
Source:
Returns:
Type
Promise.<shakaExtern.Response>

(private) resend_(type, request, delayMs, index) → (non-null) {Promise.<shakaExtern.Response>}

Resends the request after applying a delay. This does not handle retry.
Parameters:
Name Type Description
type shaka.net.NetworkingEngine.RequestType
request shakaExtern.Request
delayMs number The current base delay.
index number
Source:
Returns:
Type
Promise.<shakaExtern.Response>

(private) send_(type, request, index) → (non-null) {Promise.<shakaExtern.Response>}

Sends the given request to the correct plugin. This does not handle retry.
Parameters:
Name Type Description
type shaka.net.NetworkingEngine.RequestType
request shakaExtern.Request
index number
Source:
Returns:
Type
Promise.<shakaExtern.Response>

unregisterRequestFilter(filter)

Removes a request filter.
Parameters:
Name Type Description
filter shaka.net.NetworkingEngine.RequestFilter
Source:

unregisterResponseFilter(filter)

Removes a response filter.
Parameters:
Name Type Description
filter shaka.net.NetworkingEngine.ResponseFilter
Source:

Type Definitions

RequestFilter

Defines a filter for requests. This filter takes the request and modifies it before it is sent to the scheme plugin.
Type:
Source:

ResponseFilter

Defines a filter for responses. This filter takes the response and modifies it before it is returned.
Type:
Source:

SchemePlugin

Defines a plugin that handles a specific scheme.
Type:
Source: