Skip to content

Parameter setQualityGetter

Description

The setQualityGetter method in TeleportConfiguration.Builder allows you to provide the Teleport SDK with a function to determine the quality (track) of a video segment. This information is extremely important for the Teleport PDN, as it allows peers to exchange segments of the same quality, which increases the efficiency and stability of the peer-to-peer network.

Importance of Quality Determination

Accurate determination of the current video stream quality helps the Teleport SDK more effectively select peers for segment exchange, ensuring content delivery in the best available quality and reducing CDN load.

Function Requirements

  • The function must accept a Uri and return one of the values listed in the SegmentQuality class.

Example Usage

kotlin
TeleportConfiguration.Builder("YOUR_API_KEY")
        .setQualityGetter { url: Uri ->
            when {
                uri.path.contains("track-q0") -> SegmentQuality.Q360P
                uri.path.contains("track-q1") -> SegmentQuality.Q480P
                uri.path.contains("track-q2") -> SegmentQuality.Q720P
                uri.path.contains("track-q3") -> SegmentQuality.Q1080P
                uri.path.contains("track-q4") -> SegmentQuality.Q4K
                else -> SegmentQuality.UNKNOWN
            }
        }
        .build()

In this example, the setQualityGetter function analyzes the URI path to determine the segment quality based on track naming.

SegmentQuality Class

For more details on the SegmentQuality class and its possible values, refer to the Teleport Android SDK API Methods documentation or the SDK source code.