Parameter setSegmentTypeGetter
Description
The setSegmentTypeGetter method in TeleportConfiguration.Builder allows you to provide the Teleport SDK with a function to identify the type of the loaded video segment (e.g., video, audio, subtitles). This information is used for finer control over the peer-to-peer network and optimizing data exchange, as different segment types may have different priorities or processing rules.
Importance of Segment Type Determination
Determining the segment type helps the Teleport SDK more effectively manage data streams, for example, by prioritizing video segments or applying specific rules for audio or subtitles. This improves the quality of Teleport PDN operation.
Function Requirements
- The function must accept a
Uriand return the segment type, defined by theSegmentTypeclass. - By default, the segment type is always determined as
SegmentType.UNKNOWN. - Called on a background thread.
Example Usage
TeleportConfiguration.Builder("YOUR_API_KEY")
.setSegmentTypeGetter { uri: Uri ->
val path = uri.path
when {
path == null -> SegmentType.UNKNOWN
path.contains("video") -> SegmentType.VIDEO
path.contains("audio") -> SegmentType.AUDIO
path.contains("subs") -> SegmentType.CAPTION
else -> SegmentType.OTHER
}
}
.build()In this example, the setSegmentTypeGetter function analyzes the URI path to determine the segment type.
SegmentType Class
For more details on the SegmentType class and its possible values, refer to the Teleport Android SDK API Methods documentation or the SDK source code.