Class: shaka.net.NetworkingEngine

Constructor

new NetworkingEngine(onProgressUpdatedopt, onHeadersReceivedopt, onDownloadCompletedopt, onDownloadFailedopt, onRequestopt, onRetryopt, onResponseopt)

Parameters:
Name Type Attributes Description
onProgressUpdated shaka.net.NetworkingEngine.onProgressUpdated <optional>
Called when a progress event is triggered. Passed the duration, in milliseconds, that the request took, the number of bytes transferred, and the boolean of whether the switching is allowed.
onHeadersReceived shaka.net.NetworkingEngine.OnHeadersReceived <optional>
Called when the headers are received for a download.
onDownloadCompleted shaka.net.NetworkingEngine.OnDownloadCompleted <optional>
Called when a download completed successfully.
onDownloadFailed shaka.net.NetworkingEngine.OnDownloadFailed <optional>
Called when a download fails, for any reason.
onRequest shaka.net.NetworkingEngine.OnRequest <optional>
Called when a request is made
onRetry shaka.net.NetworkingEngine.OnRetry <optional>
Called when a request retry is made
onResponse shaka.net.NetworkingEngine.OnResponse <optional>
Called when receive the response
Implements:
Source:

Classes

NumBytesRemainingClass
PendingRequest

Members

AdvancedRequestType :number

A more advanced form of the RequestType structure, meant to describe sub-types of basic request types. For example, an INIT_SEGMENT is a sub-type of SEGMENT. This is meant to allow for more specificity to be added to the request type data, without breaking backwards compatibility.
Type:
  • number
Properties:
Name Value Type Description
INIT_SEGMENT 0 number
MEDIA_SEGMENT 1 number
MEDIA_PLAYLIST 2 number
MASTER_PLAYLIST 3 number
MPD 4 number
MSS 5 number
MPD_PATCH 6 number
MEDIATAILOR_SESSION_INFO 7 number
MEDIATAILOR_TRACKING_INFO 8 number
MEDIATAILOR_STATIC_RESOURCE 9 number
MEDIATAILOR_TRACKING_EVENT 10 number
INTERSTITIAL_ASSET_LIST 11 number
INTERSTITIAL_AD_URL 12 number
Source:

CommonAccessTokenHeaderName_ :string

Type:
  • string
Source:

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:

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
TIMING 4 number
SERVER_CERTIFICATE 5 number
KEY 6 number
ADS 7 number
CONTENT_STEERING 8 number
Source:

schemes_ :Object.<string, shaka.net.NetworkingEngine.SchemeObject>

Contains the scheme plugins.
Type:
Source:

destroyed_ :boolean

Type:
  • boolean
Source:

forceHTTP_ :boolean

Type:
  • boolean
Source:

forceHTTPS_ :boolean

Type:
  • boolean
Source:

hostCommonAccessTokenMap_ :Map.<string, string>

Type:
  • Map.<string, string>
Source:

minBytesForProgressEvents_ :number

Type:
  • number
Source:

Methods

defaultRetryParameters() → {shaka.extern.RetryParameters}

Gets a copy of the default retry parameters.
Source:
Returns:
NOTE: The implementation moved to shaka.net.Backoff to avoid a circular dependency between the two classes.
Type
shaka.extern.RetryParameters

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

makeRequest(urisnon-null, retryParams, streamDataCallbacknullable) → {shaka.extern.Request}

Makes a simple network request for the given URIs.
Parameters:
Name Type Attributes Default Description
uris Array.<string>
retryParams shaka.extern.RetryParameters
streamDataCallback ?function(BufferSource):!Promise= <nullable>
null
Source:
Returns:
Type
shaka.extern.Request

registerScheme(scheme, plugin, priorityopt, progressSupportopt)

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 Default Description
scheme string
plugin shaka.extern.SchemePlugin
priority number <optional>
progressSupport boolean <optional>
false
Source:

unregisterScheme(scheme)

Removes a scheme plugin.
Parameters:
Name Type Description
scheme string
Source:

allowSwitch_(context) → {boolean}

Parameters:
Name Type Description
context shaka.extern.RequestContext | undefined
Source:
Returns:
Type
boolean

clearAllRequestFilters()

Clears all request filters.
Source:

clearAllResponseFilters()

Clears all response filters.
Source:

clearCommonAccessTokenMap()

Clears Common Access Token map.
Source:

copyFiltersInto(othernon-null)

Copies all of the filters from this networking engine into another.
Parameters:
Name Type Description
other shaka.net.NetworkingEngine
Source:

destroy() → {Promise}

Request that this object be destroyed, 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

filterRequest_(type, request, contextopt) → {shaka.util.AbortableOperation.<undefined>}

Parameters:
Name Type Attributes Description
type shaka.net.NetworkingEngine.RequestType
request shaka.extern.Request
context shaka.extern.RequestContext <optional>
Source:
Returns:
Type
shaka.util.AbortableOperation.<undefined>

registerRequestFilter(filter)

Registers a new request filter. All filters are applied in the order they are registered.
Parameters:
Name Type Description
filter shaka.extern.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.extern.ResponseFilter
Source:

request(type, request, contextopt) → {shaka.net.NetworkingEngine.PendingRequest}

Makes a network request and returns the resulting data.
Parameters:
Name Type Attributes Description
type shaka.net.NetworkingEngine.RequestType
request shaka.extern.Request
context shaka.extern.RequestContext <optional>
Source:
Returns:
Type
shaka.net.NetworkingEngine.PendingRequest

send_(type, request, context, backoffnon-null, index, lastErrornullable, numBytesRemainingObj) → {shaka.extern.IAbortableOperation.<shaka.net.NetworkingEngine.ResponseAndGotProgress>}

Sends the given request to the correct plugin and retry using Backoff.
Parameters:
Name Type Attributes Description
type shaka.net.NetworkingEngine.RequestType
request shaka.extern.Request
context shaka.extern.RequestContext | undefined
backoff shaka.net.Backoff
index number
lastError shaka.util.Error <nullable>
numBytesRemainingObj shaka.net.NetworkingEngine.NumBytesRemainingClass
Source:
Returns:
Type
shaka.extern.IAbortableOperation.<shaka.net.NetworkingEngine.ResponseAndGotProgress>

setForceHTTP(forceHTTP)

Parameters:
Name Type Description
forceHTTP boolean
Source:

setForceHTTPS(forceHTTPS)

Parameters:
Name Type Description
forceHTTPS boolean
Source:

setMinBytesForProgressEvents(minBytes)

Parameters:
Name Type Description
minBytes number
Source:

unregisterRequestFilter(filter)

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

unregisterResponseFilter(filter)

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

Type Definitions

OnDownloadCompleted

A callback function that notifies the player when a download completed successfully.
Type:
  • function( !shaka.extern.Request, !shaka.extern.Response)
Source:

OnDownloadFailed

A callback function that notifies the player when a download fails, for any reason (e.g. even if the download was aborted).
Type:
  • function( !shaka.extern.Request, ?shaka.util.Error, number, boolean)
Source:

OnHeadersReceived

A callback function that passes the shaka.extern.HeadersReceived along to the player, plus some extra data.
Type:
  • function( !Object.<string, string>, !shaka.extern.Request, !shaka.net.NetworkingEngine.RequestType)
Source:

onProgressUpdated

A callback that is passed the duration, in milliseconds, that the request took, the number of bytes transferred, a boolean representing whether the switching is allowed and a ref to the original request.
Type:
  • function( number, number, boolean, shaka.extern.Request=)
Source:

OnRequest

A callback function called on every request
Type:
Source:

OnResponse

A callback function called on every request
Type:
Source:

OnRetry

A callback function called on every request retry. The first string is the new URI and the second string is the old URI.
Type:
Source:

ResponseAndGotProgress

Defines a response wrapper object, including the response object and whether progress event is fired by the scheme plugin.
Type:
Properties:
Name Type Description
response shaka.extern.Response
gotProgress boolean
Source:

SchemeObject

Type:
Properties:
Name Type Description
plugin shaka.extern.SchemePlugin The associated plugin.
priority number The plugin's priority.
progressSupport boolean The plugin's supports progress events
Source:

Events

RetryEvent

Fired when the networking engine receives a recoverable error and retries.
Properties:
Name Type Attributes Description
type string 'retry'
error shaka.util.Error <nullable>
The error that caused the retry. If it was a non-Shaka error, this is set to null.
Source: