KtorMediaIoResolver

class KtorMediaIoResolver(client: HttpClient? = null, headers: Map<String, String> = emptyMap(), policy: HttpReaderPolicy = HttpReaderPolicy()) : MediaIoResolver, AutoCloseable

Explicit HTTP/HTTPS resolver for a shared HttpClient, default request headers or an HttpReaderPolicy of its own; the automatic provider uses the default policy. Install it as io.github.yuroyami.kiteplayer.NetworkConfig.ioResolver; other URIs pass to the backend. Adding this module already supplies automatic transport for standard opens, whose private clients close with each reader. Use this resolver when the application owns a shared client or wants resolver-wide defaults. Per-item headers override these defaults.

The defaults also go to every related address a reader opens, such as an HLS segment on another server. Per-item headers go only to the scheme, host and port of the item's own address.

An address that answers with a DASH manifest plays as a DASH presentation, as the automatic provider plays it: the manifest is recognised by its content type, by a path that ends in .mpd, or by its root element when the type leaves room for one, and its segments open on this resolver's client.

The client this resolver creates is shared by every item it opens, so it keeps no cookies: one item's session must not reach another. A stream protected by a cookie plays through the automatic transport, whose client belongs to one item and keeps them, or through a client of your own with Ktor's HttpCookies installed.

The lazily created client lives for the resolver's lifetime, which is normally the process: exactly how OkHttp and NSURLSession want to be held. A resolver with a shorter life closes the client it created through close (it used to leak the engine's connection and thread pools); a caller-supplied client stays the caller's to close, as everywhere else.

Constructors

Link copied to clipboard
constructor(client: HttpClient? = null, headers: Map<String, String> = emptyMap(), policy: HttpReaderPolicy = HttpReaderPolicy())

Functions

Link copied to clipboard
open override fun close()

Closes the client this resolver created, if it ever created one. Idempotent.

Link copied to clipboard
open suspend override fun resolve(uri: String): MediaIo?

open suspend override fun resolve(uri: String, headers: Map<String, String>): MediaIo?

Per-item headers override this resolver's defaults, with case-insensitive HTTP names.