Skip to main content

Stream Concurrency

The Stream Concurrency library is a personalization library that facilitates stream concurrency check during playback and aborts playback if the check fails. The library performs concurrent stream checks for content at different stages of playback and aborts playback if the number of concurrent streams exceeds the allowed limit.

The StreamConcurrencyService is the interface for stream check contract which has all the APIs to perform different stream operations (Put and Delete). The StreamConcurrencyManager is composed on stream concurrency service to validate stream checks with Player and ComposablePlayer.

Usage

Use the following methods to create and manage stream concurrency checks.

Create StreamConcurrencyService

let service = FLStreamConcurrencyFactory.streamConcurrencyService(
endPoint: endPoint,
httpClient: httpClient,
authorizer: authorizer)

Create StreamConcurrencyManager

let config = FLStreamConcurrencyFactory.streamConcurrencyConfiguration(
endPoint: endPoint,
streamConcurrencySyncInterval: 30000)

let streamManager = FLStreamConcurrencyFactory.streamConcurrencyManager(
configuration: config,
deviceId: deviceId,
streamConcurrencyService: service,
authorizer: authorizer)

Check streams for content

The StreamConcurrencyManager has methods to check streams at different stages of playback. You can invoke these methods during playback on your own or use them with ComposablePlayer to automate the process. To use them with ComposablePlayer, add the functions with stream concurrency manager as inputs to addStateChangeBlock(:) and addHeartBeatBlock(:) to validate stream check during playback state change and playback progress respectively.

// Using BookmarkManager with ComposablePlayer
composablePlayer.addStateChangeBlock(streamManager.processPlaybackStateChange)
composablePlayer.addHeartBeatBlock(streamManager.processPlaybackProgress)