DASH segment download resiliency
Network issues may affect the timely retrieval of DASH stream segments. The CONNECT Player SDK for Browsers/ConnectedTV allows for adjustments in the resiliency of downloading of segments. A configurable timeout on segment download enables you to apply a multiplication factor to the rendered length of the segment. Segment downloads that fail to complete within this time will be retried.
Example code
It may be desirable to use different settings on a stream-by-stream basis as the segment length is likely to vary between Live and VOD streams. The configuration can optionally be set on a per-stream basis by setting the flag(s) simultaneously as passing the URL, MIME-type and token in the loaded callback. The default configuration will set timeouts of 500% of segment length for VOD streams and 150% for Live. Both of the defaults will be restricted to the interval 6000-15000 (6-15 seconds).
Through playback source
The example below ensures that two-second long segments will be allowed 200% of their segment length (4 seconds) to complete their download.
const playerInstance = otvplayer(
"videoPlayer",
{
plugins: {
otvtoolkit: {}
}
},
() => {
playerInstance.src({
src: "https://....",
type: "application/dash+xml",
token: "eyJra...",
vodSegmentTimeout: 2,
liveSegmentTimeout: 2
});
}
);
When the liveSegmentTimeout
and vodSegmentTimeout
values are omitted, the app will use the defaults listed above. If either liveSegmentTimeout
or vodSegmentTimeout
is specified, the resulting timeouts will not be limited to the default interval.
Through otvtoolkit configure API
The SDK has a set of default optimised values to configure the Shaka engine. A configure()
API is provided to enable the application to optimise the configuration in the application end to end ecosystem. If the configure()
API is called before a player has been initialised ('ready' event received), it will return false and the configuration change will not be applied.
The SDK optimises the segment timeout and maxAttempts
by default, with the value passed via source API or SDK recommended default value. The application will have to wait until the canPlay
event has been received to override these settings. You can set the timeout using the streaming.retryParameters.timeout
field with OtvToolkit.configure()
:
playerInstance
.otvtoolkit()
.configure("streaming.retryParameters.timeout", 10000);
This sets the timeout on the current stream to 10000ms. See the API documentation for more details on OtvToolkit.configure()
. The timeout can also be disabled by setting the timeout to 0, effectively marking it as unlimited. Once a new stream is selected, the segment timeout will return to being calculated using the segment timeout multiplier.