Class MediaStreamTrack
Inheritance
Inherited Members
Namespace: SIPSorcery.Net
Assembly: SIPSorcery.dll
Syntax
public class MediaStreamTrack
Constructors
| Improve this Doc View SourceMediaStreamTrack(SDPMediaTypesEnum, Boolean, List<SDPAudioVideoMediaFormat>, MediaStreamStatusEnum, List<SDPSsrcAttribute>, Dictionary<Int32, RTPHeaderExtension>)
Creates a lightweight class to track a media stream track within an RTP session When supporting RFC3550 (the standard RTP specification) the relationship between an RTP stream and session is 1:1. For WebRTC and RFC8101 there can be multiple streams per session.
Declaration
public MediaStreamTrack(SDPMediaTypesEnum kind, bool isRemote, List<SDPAudioVideoMediaFormat> capabilities, MediaStreamStatusEnum streamStatus = MediaStreamStatusEnum.SendRecv, List<SDPSsrcAttribute> ssrcAttributes = null, Dictionary<int, RTPHeaderExtension> headerExtensions = null)
Parameters
Type | Name | Description |
---|---|---|
SDPMediaTypesEnum | kind | The type of media for this stream. There can only be one stream per media type. |
System.Boolean | isRemote | True if this track corresponds to a media announcement from the remote party. |
System.Collections.Generic.List<SDPAudioVideoMediaFormat> | capabilities | The capabilities for the track being added. Where the same media type is supported locally and remotely only the mutual capabilities can be used. This will occur if we receive an SDP offer (add track initiated by the remote party) and we need to remove capabilities we don't support. |
MediaStreamStatusEnum | streamStatus | The initial stream status for the media track. Defaults to send receive. |
System.Collections.Generic.List<SDPSsrcAttribute> | ssrcAttributes | Optional. If the track is being created from an SDP announcement this parameter contains a list of the SSRC attributes that should then match the RTP header SSRC value for this track. |
System.Collections.Generic.Dictionary<System.Int32, RTPHeaderExtension> | headerExtensions |
MediaStreamTrack(AudioFormat, MediaStreamStatusEnum)
Add a local audio track.
Declaration
public MediaStreamTrack(AudioFormat format, MediaStreamStatusEnum streamStatus = MediaStreamStatusEnum.SendRecv)
Parameters
Type | Name | Description |
---|---|---|
SIPSorceryMedia.Abstractions.AudioFormat | format | The audio format that the local application supports. |
MediaStreamStatusEnum | streamStatus | Optional. The stream status for the audio track, e.g. whether send and receive or only one of. |
MediaStreamTrack(SDPWellKnownMediaFormatsEnum[])
Adds a local audio track based on one or more well known audio formats. There is no equivalent for a local video track as there is no support in this library for any of the well known video formats.
Declaration
public MediaStreamTrack(params SDPWellKnownMediaFormatsEnum[] wellKnownAudioFormats)
Parameters
Type | Name | Description |
---|---|---|
SIPSorceryMedia.Abstractions.SDPWellKnownMediaFormatsEnum[] | wellKnownAudioFormats | One or more well known audio formats. |
MediaStreamTrack(VideoFormat, MediaStreamStatusEnum)
Add a local video track.
Declaration
public MediaStreamTrack(VideoFormat format, MediaStreamStatusEnum streamStatus = MediaStreamStatusEnum.SendRecv)
Parameters
Type | Name | Description |
---|---|---|
SIPSorceryMedia.Abstractions.VideoFormat | format | The video format that the local application supports. |
MediaStreamStatusEnum | streamStatus | Optional. The stream status for the video track, e.g. whether send and receive or only one of. |
MediaStreamTrack(List<AudioFormat>, MediaStreamStatusEnum)
Add a local audio track.
Declaration
public MediaStreamTrack(List<AudioFormat> formats, MediaStreamStatusEnum streamStatus = MediaStreamStatusEnum.SendRecv)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.List<SIPSorceryMedia.Abstractions.AudioFormat> | formats | The audio formats that the local application supports. |
MediaStreamStatusEnum | streamStatus | Optional. The stream status for the audio track, e.g. whether send and receive or only one of. |
MediaStreamTrack(List<VideoFormat>, MediaStreamStatusEnum)
Add a local video track.
Declaration
public MediaStreamTrack(List<VideoFormat> formats, MediaStreamStatusEnum streamStatus = MediaStreamStatusEnum.SendRecv)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.List<SIPSorceryMedia.Abstractions.VideoFormat> | formats | The video formats that the local application supports. |
MediaStreamStatusEnum | streamStatus | Optional. The stream status for the video track, e.g. whether send and receive or only one of. |
Properties
| Improve this Doc View SourceCapabilities
The media capabilities supported by this track.
Declaration
public List<SDPAudioVideoMediaFormat> Capabilities { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.List<SDPAudioVideoMediaFormat> |
DefaultStreamStatus
Represents the original and default stream status for the track. This is set when the track is created and does not change. It allows tracks to be set back to their original state after being put on hold etc. For example if a track is added as receive only video source then when after on and off hold it needs to be known that the track reverts receive only rather than sendrecv.
Declaration
public MediaStreamStatusEnum DefaultStreamStatus { get; }
Property Value
Type | Description |
---|---|
MediaStreamStatusEnum |
HeaderExtensions
a=extmap - Mapping for RTP header extensions
Declaration
public Dictionary<int, RTPHeaderExtension> HeaderExtensions { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.Dictionary<System.Int32, RTPHeaderExtension> |
IsRemote
Indicates whether this track was sourced by a remote connection.
Declaration
public bool IsRemote { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Kind
The type of media stream represented by this track. Must be audio or video.
Declaration
public SDPMediaTypesEnum Kind { get; }
Property Value
Type | Description |
---|---|
SDPMediaTypesEnum |
LastAbsoluteCaptureTimestamp
The last abs-capture-time received from the remote peer for this stream.
Declaration
public TimestampPair LastAbsoluteCaptureTimestamp { get; }
Property Value
Type | Description |
---|---|
TimestampPair |
LastRemoteSeqNum
The last seqnum received from the remote peer for this stream.
Declaration
public ushort LastRemoteSeqNum { get; }
Property Value
Type | Description |
---|---|
System.UInt16 |
MaximumBandwidth
If set to a non-zero value for local tracks then a Transport Independent Bandwidth (TIAS) attribute will be included in any SDP for the track's media announcement. For remote tracks thi a non-zero value indicates the a TIAS attribute was set in the remote SDP media announcement. The bandwith is specified in bits per seconds (bps).
Declaration
public uint MaximumBandwidth { get; set; }
Property Value
Type | Description |
---|---|
System.UInt32 |
Remarks
| Improve this Doc View SourceNoDtmfSupport
By default audio channels will support DTMF via telephone events. To opt out of DTMF support set this property to true.
Declaration
public bool NoDtmfSupport { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
SdpSsrc
If the SDP remote the remote party provides "a=ssrc" attributes, as specified in RFC5576, this property will hold the values. The list can be used when an RTP/RTCP packet is received and needs to be matched against a media type or RTCP report.
Declaration
public Dictionary<uint, SDPSsrcAttribute> SdpSsrc { get; set; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.Dictionary<System.UInt32, SDPSsrcAttribute> |
SeqNum
Declaration
public ushort SeqNum { get; }
Property Value
Type | Description |
---|---|
System.UInt16 |
Ssrc
The value used in the RTP Synchronisation Source header field for media packets sent using this media stream. Be careful that the RTP Synchronisation Source header field should not be changed unless specific implementations require it. By default this value is chosen randomly, with the intent that no two synchronization sources within the same RTP session will have the same SSRC.
Declaration
public uint Ssrc { get; set; }
Property Value
Type | Description |
---|---|
System.UInt32 |
StreamStatus
Holds the stream state of the track.
Declaration
public MediaStreamStatusEnum StreamStatus { get; }
Property Value
Type | Description |
---|---|
MediaStreamStatusEnum |
Timestamp
The value used in the RTP Timestamp header field for media packets sent using this media stream.
Declaration
public uint Timestamp { get; }
Property Value
Type | Description |
---|---|
System.UInt32 |
Methods
| Improve this Doc View SourceGetFormatForPayloadID(Int32)
Gets the matching audio or video format for a payload ID.
Declaration
public SDPAudioVideoMediaFormat? GetFormatForPayloadID(int payloadID)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | payloadID | The payload ID to get the format for. |
Returns
Type | Description |
---|---|
System.Nullable<SDPAudioVideoMediaFormat> | An audio or video format or null if no payload ID matched. |
GetNextSeqNum()
Returns the next SeqNum to be used in the RTP Sequence Number header field for media packets sent using this media stream.
Declaration
public ushort GetNextSeqNum()
Returns
Type | Description |
---|---|
System.UInt16 |
IsPayloadIDMatch(Int32)
Checks whether the payload ID in an RTP packet received from the remote call party is in this track's list.
Declaration
public bool IsPayloadIDMatch(int payloadID)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | payloadID | The payload ID to check against. |
Returns
Type | Description |
---|---|
System.Boolean | True if the payload ID matches one of the codecs for this stream. False if not. |
IsSsrcMatch(UInt32)
Checks whether a SSRC value from an RTP header or RTCP report matches a value expected for this track.
Declaration
public bool IsSsrcMatch(uint ssrc)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | ssrc | The SSRC value to check. |
Returns
Type | Description |
---|---|
System.Boolean | True if the SSRC value is expected for this track. False if not. |
RestrictCapabilities(SDPAudioVideoMediaFormat)
To restrict MediaStream Capabilties to one Audio/Video format. This Audio/Video format must already be present in the previous list or if the list is empty/null
Usefull once you have successfully created a connection with a Peer to use the same format even even others negocitions are performed
Declaration
public bool RestrictCapabilities(SDPAudioVideoMediaFormat sdpAudioVideoMediaFormat)
Parameters
Type | Name | Description |
---|---|---|
SDPAudioVideoMediaFormat | sdpAudioVideoMediaFormat | The Audio/Video Format to restrict |
Returns
Type | Description |
---|---|
System.Boolean | True if the operation has been performed |
RestrictCapabilities(AudioFormat)
To restrict MediaStream Capabilties to one Audio format. This Audio format must already be present in the previous list or if the list is empty/null
Usefull once you have successfully created a connection with a Peer to use the same format even even others negocitions are performed
Declaration
public bool RestrictCapabilities(AudioFormat audioFormat)
Parameters
Type | Name | Description |
---|---|---|
SIPSorceryMedia.Abstractions.AudioFormat | audioFormat | The Audio Format to restrict |
Returns
Type | Description |
---|---|
System.Boolean | True if the operation has been performed |
RestrictCapabilities(VideoFormat)
To restrict MediaStream Capabilties to one Video format. This Video format must already be present in the previous list or if the list is empty/null
Usefull once you have successfully created a connection with a Peer to use the same format even even others negocitions are performed
Declaration
public bool RestrictCapabilities(VideoFormat videoFormat)
Parameters
Type | Name | Description |
---|---|---|
SIPSorceryMedia.Abstractions.VideoFormat | videoFormat | The Video Format to restrict |
Returns
Type | Description |
---|---|
System.Boolean | True if the operation has been performed |