CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-webrtc-adapter

A shim to insulate apps from WebRTC spec changes and browser prefix differences

Overall
score

98%

Overview
Eval results
Files

task.mdevals/scenario-5/

WebRTC Track Statistics Monitor

Build a statistics monitoring utility for WebRTC that retrieves quality metrics for individual audio and video tracks.

Requirements

Your implementation should provide functionality to retrieve statistics for individual RTP senders and receivers. The utility should:

  1. Sender Statistics: Retrieve metrics for a specific RTP sender (outbound streams)
  2. Receiver Statistics: Retrieve metrics for a specific RTP receiver (inbound streams)
  3. Empty State Handling: Return an empty stats report when a sender has no active track

The implementation should work across different browsers by utilizing webrtc-adapter's cross-browser compatibility features.

Implementation

@generates

API

/**
 * Retrieves statistics for a specific RTP sender.
 *
 * @param {RTCRtpSender} sender - The RTP sender to get stats for
 * @returns {Promise<RTCStatsReport>} Stats report containing sender-specific metrics
 */
async function getSenderStats(sender) {
  // IMPLEMENTATION HERE
}

/**
 * Retrieves statistics for a specific RTP receiver.
 *
 * @param {RTCRtpReceiver} receiver - The RTP receiver to get stats for
 * @returns {Promise<RTCStatsReport>} Stats report containing receiver-specific metrics
 */
async function getReceiverStats(receiver) {
  // IMPLEMENTATION HERE
}

module.exports = {
  getSenderStats,
  getReceiverStats
};

Test Cases

  • Given an RTP sender with an active track, getSenderStats returns a stats report with outbound-rtp metrics @test
  • Given an RTP receiver with an active track, getReceiverStats returns a stats report with inbound-rtp metrics @test
  • Given an RTP sender without an active track, getSenderStats returns an empty stats report @test

Dependencies { .dependencies }

webrtc-adapter { .dependency }

Provides cross-browser WebRTC compatibility and normalizes API differences between browsers.

Install with Tessl CLI

npx tessl i tessl/npm-webrtc-adapter

tile.json