NetworkConfig

@objcMembers
@objc(BMPNetworkConfig)
public class NetworkConfig : NSObject

The network config gives the ability to influence network requests. At the moment only changing DRM and HLS Playlist requests are supported. Processing responses or influencing the retry behaviour is not supported.

  • Type definition for the handler that needs to be called if a retry should happen.

    Declaration

    Swift

    public typealias RetryHandler = (_ retryDelay: TimeInterval, _ request: HttpRequest) -> Void

    Parameters

    retryDelay

    The delay in seconds before the retry should happen.

    request

    The request that should be done to retry the failed request. It can be the same as the failed request or a modified version of it.

  • Type definition for the handler that needs to be called if no retry should happen.

    Declaration

    Swift

    public typealias AbortHandler = () -> Void
  • Type definition for the handler that allows implementing a custom retry behaviour for failed HTTP requests.

    Declaration

    Swift

    public typealias RetryHttpRequestHandler = (
        _ type: HttpRequestType,
        _ retry: Int,
        _ response: HttpResponse,
        _ retryHandler: @escaping RetryHandler,
        _ abortHandler: @escaping AbortHandler
    ) -> Void

    Parameters

    type

    The type of the failed request.

    retry

    The number of the current retry attempt.

    response

    The response of the failed request. It contains a reference to the failed request.

    retryHandler

    Handler that needs to be called if a retry should happen.

    abortHandler

    Handler that needs to be called if no retry should happen.

  • Called before a HTTP request is made.

    Only changing DRM and HLS Playlist requests are currently supported.

    Declaration

    Swift

    public weak var preprocessHttpRequestDelegate: PreprocessHttpRequestDelegate?
  • Called when an HLS playlist request has failed. Will override the default retry behaviour.

    If a custom retryHttpRequest handler is set, no internal retry handling is done at all. The custom handler needs to take care of all retries. Some things to consider when implementing an own handler are:

    • Make sure to have a maximum number of allowed retries to not retry unreasonable amount of times.
    • There is an underlying AVFoundation limit of about 20 seconds for doing retries. If a failed request is not retried successfully within that time, there will be an error. Within that time frame, the amount of retries that can be done is unlimited.

    Declaration

    Swift

    public var retryHttpRequest: RetryHttpRequestHandler?