Movatterモバイル変換


[0]ホーム

URL:


MDN Web Docs

RTCCodecStats

BaselineWidely available *

TheRTCCodecStats dictionary of theWebRTC API provides statistics about a codec used byRTP streams that are being sent or received by the associatedRTCPeerConnection object.

These statistics can be obtained by iterating theRTCStatsReport object returned byRTCPeerConnection.getStats() until you find an entry with thetype ofcodec.

The codec statistics can be correlated with the inbound or outbound stream statistics (both local and remote) by matching theircodecId property to the codec'sid.For example, ifRTCInboundRtpStreamStats.codecId matches anRTCCodecStats.id in the same report, then we know that the codec is being used on this peer connection's inbound stream.If no streamcodecId references a codec statistic, then that codec statistic object is deleted — if the codec is used again, the statistics object will be recreated with the sameid.

Codec objects may be referenced by multiple RTP streams in media sections using the same transport.In fact, user agents are expected to consolidate information into a single "codec" entry per payload type per transport (unlesssdpFmtpLine is different when sending or receiving, in which case, different codecs will be needed for encoding and decoding).Note that other transports will use their own distinctRTCCodecStats objects.

Instance properties

channelsOptional

A positive number indicating the number of channels supported by the codec.

clockRateOptional

A positive number containing the media sampling rate.

mimeType

A string containing the media MIME type/subtype, such as video/VP8.

payloadType

A positive integer value in the range of 0 to 127 indicating the payload type used in RTP encoding or decoding.

sdpFmtpLineOptional

A string containing the format-specific parameters of the"a=fmtp" line in the codec'sSDP (if present).

transportId

A string containing the unique identifier of the transport on which this codec is being used.This can be used to match to the correspondingRTCTransportStats object.

Common instance properties

The following properties are common to all WebRTC statistics objects (seeRTCStatsReport for more information):

id

A string that uniquely identifies the object that is being monitored to produce this set of statistics.

timestamp

ADOMHighResTimeStamp object indicating the time at which the sample was taken for this statistics object.

type

A string with the value"codec", indicating the type of statistics the object contains.

Examples

Given a variablemyPeerConnection, which is an instance ofRTCPeerConnection, the code below usesawait to wait for the statistics report, and then iterates it usingRTCStatsReport.forEach().It then filters the dictionaries for just those reports that have the type ofcodec and logs the result.

js
const stats = await myPeerConnection.getStats();stats.forEach((report) => {  if (report.type === "codec") {    // Log the codec information    console.log(report);  }});

Specifications

Specification
Identifiers for WebRTC's Statistics API
# dom-rtcstatstype-codec

Browser compatibility

See also

Help improve MDN

Learn how to contribute.

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp