Skip to content

nativeRemoteHLS drops LoadOptions.httpHeaders (AVURLAsset created without AVURLAssetHTTPHeaderFieldsKey) #119

Closed

Description

@dlev02

Summary

On the nativeRemoteHLS bypass, LoadOptions.httpHeaders is silently ignored: loadRemoteHLS hands the URL to NativeAVPlayerHost.load, which builds the asset as AVURLAsset(url:) with no options dictionary (Sources/AetherEngine/Native/NativeAVPlayerHost.swift, ~line 147).

The path's doc comment says "Jellyfin HLS URL carries auth (ApiKey / PlaySessionId / LiveStreamId) as query params; no extra headers needed" — true for Jellyfin, but nativeRemoteHLS is also the only viable route for generic remote live HLS (IPTV / Stremio TV add-ons), and many of those origins enforce per-stream Referer / User-Agent / Authorization headers declared by the provider (Stremio behaviorHints.proxyHeaders.request). Those channels currently cannot play at all:

  • FFmpeg ingest path: a remote playlist through the custom AVIOReader has no base URL for relative segment URIs (avformat_open_input runs with url = nil), so remote HLS must use nativeRemoteHLS regardless.
  • nativeRemoteHLS path: headers are dropped, so header-enforcing origins answer 403/error bodies.

Repro

  1. Any HLS origin that 403s without a Referer (or use a local server that requires one).
  2. load(url:options:) with options.isLive = true, options.nativeRemoteHLS = true, options.httpHeaders = ["Referer": "..."].
  3. Observe the request goes out without the header (Charles/mitmproxy), playback fails; the same URL + headers plays via curl/ffplay -headers.

Suggested fix

When options.httpHeaders is non-empty on this path, create the asset as:

AVURLAsset(url: url, options: ["AVURLAssetHTTPHeaderFieldsKey": headers])

(the long-standing key AVFoundation honors for playlist+segment requests), and plumb a headers parameter through NativeAVPlayerHost.load. Worth a doc note either way that httpHeaders currently doesn't apply to nativeRemoteHLS.

Found while wiring IPTV live channels in a host app: streams resolved from a Stremio TV add-on declare User-Agent/Referer per channel; channels whose origins enforce them fail on this path today.

Activity

  1. superuser404notfound commented on Jul 10, 2026

    @superuser404notfound
    Owner

    Fixed on main in d8a1525. LoadOptions.httpHeaders now rides into the AVURLAsset on the nativeRemoteHLS path via AVURLAssetHTTPHeaderFieldsKey, plumbed through a new httpHeaders parameter on NativeAVPlayerHost.load (same pattern the audio-only host already used). Loopback callers pass nothing and keep their default asset, so Jellyfin behavior is untouched.

    One thing beyond the report: the remote-HLS audio tap (#95) fetches playlists, segments, and AES keys on its own URLSession, so it would have kept 403ing on the same origins. The tap fetcher now sends the same headers.

    The stale doc comments (LoadOptions.httpHeaders, the load-site note) are updated too. Please retest with your header-enforcing Stremio channels against main; #120 landed alongside this, so both fixes are in.

  2. added a commit that references this issue on Jul 10, 2026
  3. superuser404notfound commented on Jul 10, 2026

    @superuser404notfound
    Owner

    Tagged and released: both this fix and #120 shipped in 5.0.1, so you can pin the release tag instead of main for the retest.

  4. dlev02 commented on Jul 10, 2026

    @dlev02
    ContributorAuthor

    Retested on 5.0.1, fixed. I verified it at the wire: a local proxy that 403s unless the exact Referer + User-Agent arrive, fronting a real live HLS master. The player's playlist request came through with both headers and playback started (it couldn't have otherwise, the proxy rejects bare requests). Good catch on the audio-tap fetcher needing the same headers; I wouldn't have noticed that until AI subtitles went quiet on those channels. Thanks, closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions