Skip to content

Parameter setUrlCleaner

Description

The setUrlCleaner method in TeleportConfiguration.Builder allows you to define a function for unifying URL addresses of manifests and video segments. Its main task is to remove any unique information from the URL (e.g., authorization tokens, session IDs, timestamps) that does not affect the uniqueness of the content itself, but may change for different users or sessions.

Why is this needed?

For the correct operation of the Teleport PDN (Peer-to-Peer Delivery Network), it is extremely important that the URL of the same video segment or manifest is identical for all peers in the network. This allows the SDK to correctly match content and efficiently exchange it.

Function Requirements

  • The function must accept a Uri and return a String (the unified URL).
  • Called on a background thread.

Consequences without setUrlCleaner

Without proper URL unification, the Teleport SDK may mistakenly consider the same segment as different content for different users, which prevents the formation of a peer-to-peer network and reduces the efficiency of P2P delivery.

Example Usage

kotlin
TeleportConfiguration.Builder("YOUR_API_KEY")
        .setUrlCleaner { uri: Uri ->
            // Example: leaves only the URL path, discarding query parameters
            uri.path.orEmpty()
        }
        .build()

In this example, setUrlCleaner uses Uri.path to get only the URL path, ignoring all query parameters. You can adapt this function to the specifics of your URLs.