Parameter qualityGetter
Description
The qualityGetter parameter allows the Teleport SDK to identify the active video stream quality at the current moment. This is extremely important for optimizing the operation of the Teleport PDN (Peer-to-Peer Delivery Network), 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.
When is it necessary?
It is always recommended to specify the qualityGetter function if your player provides information about the active video stream quality. This is especially relevant for adaptive streaming protocols where quality can change dynamically.
Example Usage
let player = new shaka.Player(video); // Example of Shaka Player initialization
let videoIdToQuality = {}; // Map to associate video ID with Teleport quality
// Example of populating the map (depends on your player's logic and manifest)
videoIdToQuality["1"] = teleport.Quality.Q1080P;
videoIdToQuality["2"] = teleport.Quality.Q720P;
videoIdToQuality["3"] = teleport.Quality.Q480P;
let tlprt = await teleport.initialize({
apiKey: "YOUR_API_KEY", // Your API key
loader: {
type: "PLUGIN_ID", // Identifier of the player plugin used
params: {
// Function to determine the current video stream quality
qualityGetter: () => {
// Example of getting the active track from Shaka Player
let activeTrack = player.getVariantTracks().find(x => x && x.active);
// Return the corresponding Teleport quality or Unknown if not defined
return activeTrack && activeTrack.videoId && videoIdToQuality[activeTrack.videoId] || teleport.Quality.Unknown;
}
}
}
});teleport.Quality Enum
Available values for video stream quality are defined in the teleport.Quality enumeration. See the JavaScript API: Enums section for details.