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 check fails. The library facilitates check for concurrent streams of any content at different stages of playback and abort playback if the number of concurrent streams exceeds allowed limit.

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

Usage

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)

Stream Check for Content

The StreamConcurrencyManager has methods to check streams at different stages of playback. One could invoke these method during playback on their own or use it along with ComposablePlayer to automate the same. For using it 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)