Skip to content

Conversation

@mickael-menu
Copy link
Member

Added

LCP

  • Support for streaming an LCP-protected publication from its License Document (LCPL).

Streaming an LCP protected package

If the server hosting the LCP protected package supports the HTTP HEAD method and HTTP Range requests, it is possible to stream directly an LCP protected publication from a License Document (.lcpl) file, without downloading the whole publication first.

Simply open the License Document directly using the PublicationOpener. Make sure you provide an HTTPClient (or an HTTPResourceFactory for additional customization) to the AssetRetriever.

// Instantiate the required components.
let httpClient = DefaultHTTPClient()
let assetRetriever = AssetRetriever(httpClient: httpClient)
let publicationOpener = PublicationOpener(
    parser: DefaultPublicationParser(
        httpClient: httpClient,
        assetRetriever: assetRetriever
    ),
    contentProtections: [
        lcpService.contentProtection(with: LCPDialogAuthentication()),
    ]
)

// Retrieve an `Asset` to access the LCPL content.
let url = FileURL(path: "/path/to/license.lcpl", isDirectory: false)
let asset = try await assetRetriever.retrieve(url: url).get()

// Open a `Publication` from the LCPL `Asset`.
let publication = try await publicationOpener.open(
    asset: asset,
    allowUserInteraction: true,
    sender: hostViewController
).get()

print("Opened \(publication.metadata.title)")

Possible improvements: servers not supporting HEAD requests and progressive streaming using the same HTTP request. This requires some breaking changes in the HTTPClient protocol, so postponing for 4.0.

@mickael-menu mickael-menu changed the title Lcp streaming Add support for streaming LCP publications Mar 7, 2025
@mickael-menu mickael-menu merged commit 497bc6b into develop Mar 7, 2025
5 checks passed
@mickael-menu mickael-menu deleted the lcp-streaming branch March 7, 2025 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants