Class Sdp
Class for processing the Session Description Protocol message contents of a SIP message. See RFC 8866.
Inherited Members
Namespace: SipLib.Sdp
Assembly: SipLib.dll
Syntax
public class Sdp
Constructors
| Edit this page View SourceSdp(IPAddress, string)
Constructs a new Sdp and initializes the Origin (o=), ConnectionData (c=), session name (s=) and an empty media list.
Declaration
public Sdp(IPAddress LocalIp, string UaName)
Parameters
| Type | Name | Description |
|---|---|---|
| IPAddress | LocalIp | Local IP address |
| string | UaName | User agent or server name |
Properties
| Edit this page View SourceAttributes
Contains the attributes for this media session.
Declaration
public List<SdpAttribute> Attributes { get; set; }
Property Value
| Type | Description |
|---|---|
| List<SdpAttribute> |
Bandwidth
Bandwidth parameter (b) for the entire session. See Section 5.8 of RFC 8866. This parameter is optional. Treating it as a simple string.
Declaration
public string Bandwidth { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
ConnectionData
Contains the connecton data for the call.
Declaration
public ConnectionData? ConnectionData { get; set; }
Property Value
| Type | Description |
|---|---|
| ConnectionData |
Contains the e-mail parameter (e) for the session. See Section 5.6 of RFC 8866. This parameter is optional.
Declaration
public string Email { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
Media
Contains a list of all of the different types of media for a call.
Declaration
public List<MediaDescription> Media { get; set; }
Property Value
| Type | Description |
|---|---|
| List<MediaDescription> |
MediaDirection
Gets or sets the media direction attribute for the session level.
Declaration
public MediaDirectionEnum MediaDirection { get; set; }
Property Value
| Type | Description |
|---|---|
| MediaDirectionEnum |
Origin
Contains the origin information for the "o" parameter. See Section 5.2 of RFC 8866.
Declaration
public Origin? Origin { get; set; }
Property Value
| Type | Description |
|---|---|
| Origin |
PhoneNumber
Contains the phone number (p) parameter for the session. See Section 5.6 of RFC 8866. This parameter is optional.
Declaration
public string PhoneNumber { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
SessionInformation
Contains the session information "i" parameter. See Section 5.4 of RFC 8866. This parameter is optional.
Declaration
public string SessionInformation { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
SessionName
Contains the Session Name for the "s" type. parameter Section 5.3 of RFC 8866.
Declaration
public string SessionName { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
Timing
Timing (t) parameter. See Section 5.9 of RFC 8866.
Declaration
public string Timing { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
Uri
Contains a URI to more information about the session. This is the "u" parameter. See Section 5.5 of RFC 8866. This parameter is optional.
Declaration
public string Uri { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
Version
Contains the version number (v) of the SDP protocol. This is expected to be always 0. See Section 5.1 of RFC 8866.
Declaration
public int Version { get; }
Property Value
| Type | Description |
|---|---|
| int |
Methods
| Edit this page View SourceBuildAnswerSdp(Sdp, IPAddress, SdpAnswerSettings)
Builds an Sdp object to send as the answered Sdp in responsed to the offered Sdp
Declaration
public static Sdp BuildAnswerSdp(Sdp OfferedSdp, IPAddress address, SdpAnswerSettings AnswerSettings)
Parameters
| Type | Name | Description |
|---|---|---|
| Sdp | OfferedSdp | SDP that was offered |
| IPAddress | address | IP address to be used for transport of all media. This address is used in the "c=" line of the SDP. |
| SdpAnswerSettings | AnswerSettings | Settings that determine how to build the answered SDP |
Returns
| Type | Description |
|---|---|
| Sdp | Returns the SDP to send to the client that offered the SDP |
BuildAudioAnswerMediaDescription(MediaDescription, SdpAnswerSettings, int)
Builds a MediaDescription object for audio for sending as an answer to an offered media description
Declaration
public static MediaDescription BuildAudioAnswerMediaDescription(MediaDescription OfferedMd, SdpAnswerSettings Settings, int LocalPortToUse)
Parameters
| Type | Name | Description |
|---|---|---|
| MediaDescription | OfferedMd | Media description that was offered for audio |
| SdpAnswerSettings | Settings | Settings that determine how to build the answer media description |
| int | LocalPortToUse | Local port number used by the current RtpChannel for audio. Set to zero if there currently is no audio RtpChannel. If set to 0 then a port will be assigned by the port manager. |
Returns
| Type | Description |
|---|---|
| MediaDescription | Returns a new MediaDescription to send in the SDP of an OK response. |
BuildMsrpAnswerMediaDescription(MediaDescription, IPAddress, SdpAnswerSettings, MsrpUri?)
Builds a MediaDescription object for MSRP for sending as an answer to an offered media description
Declaration
public static MediaDescription BuildMsrpAnswerMediaDescription(MediaDescription OfferedMd, IPAddress Address, SdpAnswerSettings Settings, MsrpUri? LocalMsrpUriToUse)
Parameters
| Type | Name | Description |
|---|---|---|
| MediaDescription | OfferedMd | Media description that was offered for MSRP |
| IPAddress | Address | Local IP address to use for the transport of MSRP |
| SdpAnswerSettings | Settings | Settings that determine how to build the answer media description |
| MsrpUri | LocalMsrpUriToUse | Set to the MsrpUri if there is a MsrpConnection for MSRP. Set to null if there is currently no MSRP for the call. If null then a new local port will be assigned by the port manager and a new local MsrpUri object will be created. |
Returns
| Type | Description |
|---|---|
| MediaDescription | Returns a new MediaDescription to send in the SDP of an OK response. |
BuildOfferSdp(IPAddress, SdpOfferSettings, X509Certificate2?)
Builds an Sdp object to send with the INVITE request for a new call.
Declaration
public static Sdp BuildOfferSdp(IPAddress address, SdpOfferSettings offerSettings, X509Certificate2? msrpCert)
Parameters
| Type | Name | Description |
|---|---|---|
| IPAddress | address | IP address to be used for transport of all media. This address is used in the "c=" line of the SDP. |
| SdpOfferSettings | offerSettings | Configuration settings that specify what media types to offer and the types of codecs to offer for each media type. |
| X509Certificate2 | msrpCert | X.509 certificate to use for MSRP. This may be null if not offering MSRP. It must be non-null if offering MSRP and the offerSettings.MsrpSetupType is not active. |
Returns
| Type | Description |
|---|---|
| Sdp | Returns a new Sdp object to send with an INVITE request. |
BuildReInviteAnswerSdp(Sdp, IPAddress, SdpAnswerSettings, int, int, int, MsrpUri?)
Builds an Sdp object to send as the answered Sdp in response to the offered Sdp in a re-INVITE request
Declaration
public static Sdp BuildReInviteAnswerSdp(Sdp OfferedSdp, IPAddress address, SdpAnswerSettings AnswerSettings, int LocalAudioPort, int LocalVideoPort, int LocalRttPort, MsrpUri? localMsrpUri)
Parameters
| Type | Name | Description |
|---|---|---|
| Sdp | OfferedSdp | SDP that was offered in the re-INVITE |
| IPAddress | address | Local IP address to be used for transport of all media. This address is used in the "c=" line of the SDP. |
| SdpAnswerSettings | AnswerSettings | Settings that determine how to build the answered SDP |
| int | LocalAudioPort | Local port number used by the current RtpChannel for audio. Set to zero if there currently is no audio RtpChannel. If set to 0 then a port will be assigned by the port manager. |
| int | LocalVideoPort | Local port number used by the current RtpChannel for video. Set to zero if there curently is no video RtpChannel. If set to 0 then a port will be assigned by the port manager. |
| int | LocalRttPort | Local port number used by the current RtpChannel for RTT. Set to zero if there is currently no RTT RtpChannel. If set to 0 then a port will be assigned by the port manager. |
| MsrpUri | localMsrpUri | Set to the MsrpUri if there is a MsrpConnection for MSRP. Set to null if there is currently no MSRP for the call. If null then a new local port will be assigned by the port manager and a new local MsrpUri object will be created. |
Returns
| Type | Description |
|---|---|
| Sdp | Returns the SDP to send to the client that offered the SDP |
BuildRttAnswerMediaDescription(MediaDescription, SdpAnswerSettings, int)
Builds a MediaDescription object for RTT for sending as an answer to an offered media description
Declaration
public static MediaDescription BuildRttAnswerMediaDescription(MediaDescription OfferedMd, SdpAnswerSettings Settings, int LocalPortToUse)
Parameters
| Type | Name | Description |
|---|---|---|
| MediaDescription | OfferedMd | Media description that was offered for RTT |
| SdpAnswerSettings | Settings | Settings that determine how to build the answer media description |
| int | LocalPortToUse | Local port number used by the current RtpChannel for RTT. Set to zero if there currently is no RTT RtpChannel. If set to 0 then a port will be assigned by the port manager. |
Returns
| Type | Description |
|---|---|
| MediaDescription | Returns a new MediaDescription to send in the SDP of an OK response. |
BuildVideoAnswerMediaDescription(MediaDescription, SdpAnswerSettings, int)
Builds a MediaDescription object for video for sending as an answer to an offered media description
Declaration
public static MediaDescription BuildVideoAnswerMediaDescription(MediaDescription OfferedMd, SdpAnswerSettings Settings, int LocalPortToUse)
Parameters
| Type | Name | Description |
|---|---|---|
| MediaDescription | OfferedMd | Media description that was offered for video |
| SdpAnswerSettings | Settings | Settings that determine how to build the answer media description |
| int | LocalPortToUse | Local port number used by the current RtpChannel for video. Set to zero if there currently is no video RtpChannel. If set to 0 then a port will be assigned by the port manager. |
Returns
| Type | Description |
|---|---|
| MediaDescription | Returns a new MediaDescription to send in the SDP of an OK response. |
CreateCopy()
Creates a deep copy (i.e. by-value) of this object.
Declaration
public Sdp CreateCopy()
Returns
| Type | Description |
|---|---|
| Sdp | Returns a new Sdp object. |
GetAudioConnectionData(ref string?, ref int)
Retrieves the IP address and the port number for the audio media in this SDP.
Declaration
public bool GetAudioConnectionData(ref string? strIpAddr, ref int Port)
Parameters
| Type | Name | Description |
|---|---|---|
| string | strIpAddr | IP address to send the audio to. This output will contain the IP address if this method returns true or it will be set to null if this method returns false. |
| int | Port | Port number to send the audio to. This output will contain the port number to if this method returns true or it will be set to 0 if this function returns false. |
Returns
| Type | Description |
|---|---|
| bool | Returns true if the audio media type is present and valid. Else returns null. |
GetMediaByTypeAndLabel(string, string)
Gets the MediaDescription object for the specified media type and media label attribute.
Declaration
public MediaDescription? GetMediaByTypeAndLabel(string strType, string LabelAttribute)
Parameters
| Type | Name | Description |
|---|---|---|
| string | strType | The media type to search for (audio, video, message or text) |
| string | LabelAttribute | Value of the label attribute to seach for. |
Returns
| Type | Description |
|---|---|
| MediaDescription | Returns a MediaDescription object if the specified media type and label exist or null if not found. |
GetMediaDirection(Sdp, MediaDescription)
Gets the media direction attribute for a media type. The media direction may be specified at the session level or at the media level. The media level has priority.
Declaration
public static MediaDirectionEnum GetMediaDirection(Sdp sdp, MediaDescription md)
Parameters
| Type | Name | Description |
|---|---|---|
| Sdp | sdp | Session data |
| MediaDescription | md | Media description. Must be one of the MediaDescription objects in the SDP. |
Returns
| Type | Description |
|---|---|
| MediaDirectionEnum | Returns the media direction if specified at the media level or the session level. Returns MediaDirectionEnum.sendrecv if the direction is not specified at either level. |
GetMediaEndPoint(Sdp, MediaDescription)
Gets the IPEndPoint for media given the offered SDP and the offered SDP Media Description for that media. The destination IP address may be specified at the session level or the media level.
Declaration
public static IPEndPoint? GetMediaEndPoint(Sdp Sdp, MediaDescription Md)
Parameters
| Type | Name | Description |
|---|---|---|
| Sdp | Sdp | The entire SDP block that was offered. |
| MediaDescription | Md | The SDP Media Description block for the media to get the IP address for. |
Returns
| Type | Description |
|---|---|
| IPEndPoint | Returns an IPAddress. Returns null if there was no address specified in the session or media levels. |
GetMediaIPAddr(Sdp, MediaDescription)
Gets the destination IP address for media given the offered SDP and the offered SDP Media Description for that media. The destination IP address may be specified at the session level or the media level.
Declaration
public static IPAddress? GetMediaIPAddr(Sdp Sdp, MediaDescription Smd)
Parameters
| Type | Name | Description |
|---|---|---|
| Sdp | Sdp | The entire SDP block that was offered. |
| MediaDescription | Smd | The SDP Media Description block for the media to get the IP address for. |
Returns
| Type | Description |
|---|---|
| IPAddress | Returns an IPAddress. Returns null if there was no address specified in the session or media levels. |
GetMediaType(string)
Gets the MediaDescription object for the specified type of media.
Declaration
public MediaDescription? GetMediaType(string strType)
Parameters
| Type | Name | Description |
|---|---|---|
| string | strType | Type of media such as audio, video, text, etc.. |
Returns
| Type | Description |
|---|---|
| MediaDescription | Returns the SepMediaDescription object if the specified type of media is present or null if it is not. |
GetMediaTypeIndex(string)
Gets the index of a specified media type in the Media list.
Declaration
public int GetMediaTypeIndex(string strType)
Parameters
| Type | Name | Description |
|---|---|---|
| string | strType | Type of media to look for. Must be "audio", "video", "text" or "message" |
Returns
| Type | Description |
|---|---|
| int | Returns the index of the media type in the Media list. Returns -1 if the media type is not present. |
GetMediaTypeList(string)
Gets a list of MediaDescription objects in the SDP that have the same type of media.
Declaration
public List<MediaDescription> GetMediaTypeList(string strType)
Parameters
| Type | Name | Description |
|---|---|---|
| string | strType | Media type. Must be one of "audio", "video", "text" or "message" |
Returns
| Type | Description |
|---|---|
| List<MediaDescription> | Returns a list of MediaDescription objects of the same media type. The return value will not be null. |
GetNamedAttribute(string)
Returns the SdpAttribute object for a named attribute for the entire SDP at the session level.
Declaration
public SdpAttribute? GetNamedAttribute(string strAttr)
Parameters
| Type | Name | Description |
|---|---|---|
| string | strAttr | Name of the attribute to search for. |
Returns
| Type | Description |
|---|---|
| SdpAttribute | Returns a SdpAttribute for the named attribute if it is found or null if the named attribute is not present. |
HasMultiMedia()
Checks to see if the offered SDP has media other that "audio" that is a known media type.
Declaration
public bool HasMultiMedia()
Returns
| Type | Description |
|---|---|
| bool | Returns true if the SDP contains media other than "audio" or false does not. |
MediaTypeToDisplayString(string)
Returns a display name for the associated media type name.
Declaration
public static string MediaTypeToDisplayString(string mediaTypeName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | mediaTypeName | Media type name. Should be one of "audio", "video", "message" or "text". |
Returns
| Type | Description |
|---|---|
| string | Return a name for displaying. |
ParseSDP(string)
Parses the SDP contained in a string
Declaration
public static Sdp ParseSDP(string strSdp)
Parameters
| Type | Name | Description |
|---|---|---|
| string | strSdp | Contains a SDP SIP body part. |
Returns
| Type | Description |
|---|---|
| Sdp | Returns a new Sdp object. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown if an invalid argument is detected |
| Exception | Thrown if an unexpected error occurs |
RemoveNamedAttribute(string)
Removes all instances of a named SDP attribute.
Declaration
public void RemoveNamedAttribute(string strAttr)
Parameters
| Type | Name | Description |
|---|---|---|
| string | strAttr | Name of the SDP attribute to remove. |
ToString()
Converts the Sdp object to a string.
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| string | The string is formatted so that it can be appended to a SIP message as the SDP contents. |