Class MediaDescription
Class for processing the Media Description "m=" type for the SDP contents. See Section 5.14 of RFC 8866.
Inherited Members
Namespace: SipLib.Sdp
Assembly: SipLib.dll
Syntax
public class MediaDescription
Constructors
| Edit this page View SourceMediaDescription()
Constructs an empty MediaDescription object. Use this constructor to create a new Media Description for a new SDP message block to send.
Declaration
public MediaDescription()
MediaDescription(string, int, List<int>)
Constructs a new MediaDescription object from parameters provided by the caller.
Declaration
public MediaDescription(string strMediaType, int iPort, List<int> payloadTypes)
Parameters
Type | Name | Description |
---|---|---|
string | strMediaType | Media type. Ex: "audio" or "video" |
int | iPort | Port number that the session will occur on. |
List<int> | payloadTypes | Media payload types. |
Properties
| Edit this page View SourceAttributes
Contains the attributes for this type of media except the rtpmap attributes, which are stored in the RtpMapAttributes field.
Declaration
public List<SdpAttribute> Attributes { get; set; }
Property Value
Type | Description |
---|---|
List<SdpAttribute> |
Bandwidth
Specifies the bandwidth limit for the media in kilo-bits per second. This is comes from or generates a b=AS:Bandwidth line in the media description. An empty or null value indicates that there is no b= line in the media description.
Declaration
public string Bandwidth { get; set; }
Property Value
Type | Description |
---|---|
string |
ConnectionData
Contains the connection data (c=) for this media. If null, then use the ConnectionData of the SDP session.
Declaration
public ConnectionData? ConnectionData { get; set; }
Property Value
Type | Description |
---|---|
ConnectionData |
Label
Gets or sets the label attribute of a media description block. RFC 4574 specifies the characteristics of the label attribute.
The getter returns an empty string if the media description does not have a label attribute. The setter removes any existing label attributes and then adds one with the value to ensure that each MediaDescription has a single label attribute.
Declaration
public string? Label { get; set; }
Property Value
Type | Description |
---|---|
string |
MediaDirection
Gets or Sets the media direction attribute for this media description. If there is no media direction attribute, then the getter returns sendrecv.
Declaration
public MediaDirectionEnum MediaDirection { get; set; }
Property Value
Type | Description |
---|---|
MediaDirectionEnum |
MediaType
Specifies the media type. Example: "audio", "video", "text" or "message".
Declaration
public string MediaType { get; set; }
Property Value
Type | Description |
---|---|
string |
PayloadTypes
Contains a list of payload types for the m= line.
Declaration
public List<int> PayloadTypes { get; set; }
Property Value
Type | Description |
---|---|
List<int> |
Port
Specifies the TCP/UDP port number;
Declaration
public int Port { get; set; }
Property Value
Type | Description |
---|---|
int |
RtpMapAttributes
Contains a list of RtpMap objects. Each object corresponds to a a=rtpmap .... line in the media description.
Declaration
public List<RtpMapAttribute> RtpMapAttributes { get; set; }
Property Value
Type | Description |
---|---|
List<RtpMapAttribute> |
Transport
Specifies the transport mechanism: "TCP", "UDP", "RTP/AVP", etc.
Declaration
public string Transport { get; set; }
Property Value
Type | Description |
---|---|
string |
UsingEncryption
Returns true if this MediaDescription object call for DTLS-SRTP or SDES-SRTP encryption of false if it does not.
Declaration
public bool UsingEncryption { get; }
Property Value
Type | Description |
---|---|
bool |
Methods
| Edit this page View SourceAddSetupAttribute(SetupType)
Adds a a=setup:xxx attribute.
Declaration
public void AddSetupAttribute(SetupType SetType)
Parameters
Type | Name | Description |
---|---|---|
SetupType | SetType | Specifies the role (active, passive, etc.) |
BuildH264AnswerSmd(int)
Builds an MediaDescription that contains only the offerred H264 codec attributes.
Declaration
public MediaDescription? BuildH264AnswerSmd(int Port)
Parameters
Type | Name | Description |
---|---|---|
int | Port | RTP port number to use. |
Returns
Type | Description |
---|---|
MediaDescription | Returns a new MediaDescription object or null if the video media block does not contain an offer of H264 media. |
CreateCopy()
Creates a deep copy of this object.
Declaration
public MediaDescription CreateCopy()
Returns
Type | Description |
---|---|
MediaDescription | Returns a new object with a copy of each member variable in this object. |
GetAttributeValue(string)
Gets the attribute value for the specified attribute name.
Declaration
public string? GetAttributeValue(string strAttributeName)
Parameters
Type | Name | Description |
---|---|---|
string | strAttributeName | Name of the attribute to search for. |
Returns
Type | Description |
---|---|
string | A string containing the attribute value. Returns an empty string if the attribute name was not found or if the attribute was found but does not have a value (not all attributes have values). |
GetCryptoAttributes()
Gets a list of the CryptoAttributes in this MediaDescription.
Declaration
public List<CryptoAttribute> GetCryptoAttributes()
Returns
Type | Description |
---|---|
List<CryptoAttribute> | Returns a list of the crypto attributes for SDES-SRTP in this MediaDescription. The return value will not be null but it may be empty. |
GetFmtpForFormatNumber(string)
Finds the fmtp attribute for the specified media format number.
Declaration
public SdpAttribute? GetFmtpForFormatNumber(string strFormatNumber)
Parameters
Type | Name | Description |
---|---|---|
string | strFormatNumber | String representation of the media format number to look for. |
Returns
Type | Description |
---|---|
SdpAttribute | Returns the SdpAttribute object or null if its not found. |
GetNamedAttribute(string)
Returns the SdpAttribute object for a named attribute.
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. |
GetNamedAttributes(string)
Gets a list of SdpAttributes for an attribute name.
Declaration
public List<SdpAttribute> GetNamedAttributes(string strAttr)
Parameters
Type | Name | Description |
---|---|---|
string | strAttr | Attribute name. |
Returns
Type | Description |
---|---|
List<SdpAttribute> | Returns a list of SdpAttribute object. The return value will never be null but will be empty if there are no attributes with a name that matches the strAttr parameter. |
GetRtpMapForCodecType(string)
Finds the RtpMapAttribute object for the specified codec name (encoding name)
Declaration
public RtpMapAttribute? GetRtpMapForCodecType(string strCodecName)
Parameters
Type | Name | Description |
---|---|---|
string | strCodecName | Codec or encoding name |
Returns
Type | Description |
---|---|
RtpMapAttribute | Returns the RtpMapAttribute object if found or null if not found |
GetRtpMapForPayloadType(int)
Gets the RtpMapAttribute object for the specified payload type
Declaration
public RtpMapAttribute? GetRtpMapForPayloadType(int payloadType)
Parameters
Type | Name | Description |
---|---|---|
int | payloadType | Specifies the payload type to look for |
Returns
Type | Description |
---|---|
RtpMapAttribute | Returns the RtpMapAttribute object if successful or null if it is not present |
GetSetupTypeAttributeValue()
Gets the value of the setup attribute.
Declaration
public SetupType GetSetupTypeAttributeValue()
Returns
Type | Description |
---|---|
SetupType |
GetTelephoneEventPayloadType(out int)
Retrieves the payload type for DTMF telephone events.
Declaration
public bool GetTelephoneEventPayloadType(out int PayloadType)
Parameters
Type | Name | Description |
---|---|---|
int | PayloadType | Output is set to the value for the first rtpmap attribute for a telephone-event if the return value is true. This output parameter will be set to 0 if the return value of this function is false. |
Returns
Type | Description |
---|---|
bool | True if the rtpmap attribute for a telephone-event is found. A return value of false indicates that the telephone-event rtpmap attrubute could not be found. |
HasMediaStateAttribute()
Determines if the media description has an attribute that specifies the media state. The media state attributes are inactive, sendrecv, recvonly and sendonly.
Declaration
public bool HasMediaStateAttribute()
Returns
Type | Description |
---|---|
bool | Returns true if there is a media state attribute, else returns false. |
ParseMediaDescriptionLine(string)
Parses a string containing the parameter fields of a SDP m= line
Declaration
public static MediaDescription ParseMediaDescriptionLine(string strMd)
Parameters
Type | Name | Description |
---|---|---|
string | strMd | Contains the parameter fields of a m= line. The m= field must not be included. |
Returns
Type | Description |
---|---|
MediaDescription | Returns a new MediaDescription object. |
ParseMediaDescriptionString(string)
Parses a string containing a full media description block into a MediaDescription object.
Declaration
public static MediaDescription? ParseMediaDescriptionString(string strMd)
Parameters
Type | Name | Description |
---|---|---|
string | strMd | Input string containing the lines of an SDP media description block. The first line must contain an m= line |
Returns
Type | Description |
---|---|
MediaDescription | Returns a new MediaDescription object of successful or null if an error is detected. |
RemoveNamedAttributes(string)
Removes all instances of a named SDP attribute.
Declaration
public void RemoveNamedAttributes(string Attr)
Parameters
Type | Name | Description |
---|---|---|
string | Attr | Name of the SDP attribute to remove. |
ToString()
Converts the MediaDescription object to a string.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string | The string format is: "m=MediaType Port Transport MediaFormat(s)" |
Overrides
| Edit this page View SourceUsingDtlsSrtp(out SetupType)
Determines if its necessary to use DTLS-SRTP to negotiate encryption keys and algorithms.
Declaration
public bool UsingDtlsSrtp(out SetupType SetType)
Parameters
Type | Name | Description |
---|---|---|
SetupType | SetType | SetupType to use in the answer to the offered SetupType. |
Returns
Type | Description |
---|---|
bool | Returns true if DTLS-SRTP is required. |
UsingSdesSrtp()
Returns true if this MediaDescription object is for SDES-SRTP media encryption.
Declaration
public bool UsingSdesSrtp()
Returns
Type | Description |
---|---|
bool |