Table of Contents

Class RTCCodecStats

Namespace
CSharpToJavaScript.APIs.JS
Assembly
CSharpToJavaScript.dll

The RTCCodecStats dictionary of the WebRTC API provides statistics about a codec used by {{Glossary("RTP")}} streams that are being sent or received by the associated RTCPeerConnection object.

[ToObject]
public class RTCCodecStats : RTCStats
Inheritance
RTCCodecStats
Inherited Members

Remarks

These statistics can be obtained by iterating the RTCStatsReport object returned by GetStats(MediaStreamTrack?) until you find an entry with the type of codec.

The codec statistics can be correlated with the inbound or outbound stream statistics (both local and remote) by matching their codecId property to the codec's id.
For example, if RTCInboundRtpStreamStats.codecId matches an RTCCodecStats.id in the same report, then we know that the codec is being used on this peer connection's inbound stream.
If no stream codecId 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 same id.

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 (unless sdpFmtpLine 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 distinct RTCCodecStats objects.

-RTCStatsReport
-codecs option in parameter passed to SetCodecPreferences(List<RTCRtpCodec>) and SetParameters(RTCRtpSendParameters, RTCSetParameterOptions).
-codecs property in object returned by GetParameters() and GetParameters().

See also on MDN

Constructors

RTCCodecStats()

public RTCCodecStats()

Fields

Channels

The channels property of the RTCCodecStats dictionary is a positive number containing the number of channels supported by the codec.

[Value("channels")]
public ulong Channels

Field Value

ulong

A positive number indicating the number of channels.

Remarks

For audio codecs, a value of 1 specifies monaural sound while 2 indicates stereo.

-codecs.channels option in parameter passed to RTCRtpTransceiver.setCodecPreferences() and RTCRtpSender.setParameters().
-codecs.channels in object returned by RTCRtpSender.getParameters() and RTCRtpReceiver.getParameters().

See also on MDN

ClockRate

The clockRate property of the RTCCodecStats dictionary is a positive number containing the media sampling rate in hertz (Hz).

[Value("clockRate")]
public ulong ClockRate

Field Value

ulong

A positive number indicating the media sampling rate.

Remarks

-codecs.clockRate option in parameter passed to RTCRtpTransceiver.setCodecPreferences() and RTCRtpSender.setParameters().
-codecs.clockRate in object returned by RTCRtpSender.getParameters() and RTCRtpReceiver.getParameters().

See also on MDN

MimeType

The mimeType property of the RTCCodecStats dictionary is a string containing the codec's {{glossary("MIME type")}} and subtype.

[Value("mimeType")]
public required string MimeType

Field Value

string

A string indicating the code MIME type/subtype.

Remarks

This is of the form &quot;type/subtype&quot;, such as &quot;video/VP8&quot; or &quot;audio/opus&quot;, as defined in the IANA registry of valid MIME types.

-codecs.mimeType option in parameter passed to RTCRtpTransceiver.setCodecPreferences() and RTCRtpSender.setParameters().
-codecs.mimeType in object returned by RTCRtpSender.getParameters() and RTCRtpReceiver.getParameters().

See also on MDN

PayloadType

The payloadType property of the RTCCodecStats dictionary is a positive integer in the range from 0 to 127 that describes the format of the {{glossary("RTP")}} payload used in RTP encoding or decoding.

[Value("payloadType")]
public required ulong PayloadType

Field Value

ulong

A positive integer between 0 and 127.The mappings of values to formats is defined in RFC3550, and more specifically in Section 6: Payload Type Definitions of RFC3551.

Remarks

-payloadType returned by RTCEncodedAudioFrame.getMetadata()
-payloadType returned by RTCEncodedVideoFrame.getMetadata()
-codecs.payloadType option in parameter passed to RTCRtpSender.setParameters().
-codecs.payloadType in object returned by RTCRtpSender.getParameters() and RTCRtpReceiver.getParameters().

See also on MDN

SdpFmtpLine

The sdpFmtpLine property of the RTCCodecStats dictionary is a string containing the format-specific parameters of the codec.

[Value("sdpFmtpLine")]
public string SdpFmtpLine

Field Value

string

A string containing the format-specific parameters of the codec.

Remarks

These are the values in the &quot;a=fmtp&quot; line in the codec's SDP (if present) after the payload type number (see section 5.8 of the IETF specification for JSEP).

-codecs.sdpFmtpLine option in parameter passed to RTCRtpTransceiver.setCodecPreferences() and RTCRtpSender.setParameters().
-codecs.sdpFmtpLine in object returned by RTCRtpSender.getParameters() and RTCRtpReceiver.getParameters().

See also on MDN

TransportId

The transportId property of the RTCCodecStats dictionary is a string that contains the unique identifier of the corresponding transport on which this codec is being used.

[Value("transportId")]
public required string TransportId

Field Value

string

A string that uniquely identifies a matching RTCTransportStats object using its id.

Remarks

You can correlate the codec and associated transport statistics by matching the RTCCodecStats.transportId with an RTCTransportStats.Id value.

See also on MDN