Class RtpChannel
Class for sending and receiving Real Time Protocol (RTP) media such as audio, video and text (RTT). Each instance of an RtpChannel class handles a single media type.
Inherited Members
Namespace: SipLib.Rtp
Assembly: SipLib.dll
Syntax
public class RtpChannel
Remarks
Follow these steps to create and use an RtpChannel object.
- Call the CreateFromSdp() method with the offered SDP and offered media description and the answered SDP and the answered media description after the media description negotiation has been completed.
- Hook the events of the RtpChannel class. At least the RtpPacketReceived event should be handled.
- Call the StartListening() method to start the RtpChannel.
- Call the Send() method to send a new RTP packet containing new media.
When the media session ends, unhook the events and call the Shutdown() method to release all resources held by the RtpChannel object.
Properties
| Edit this page View SourceCertificateFingerprint
Gets the fingerprint of the self-signed X.509 certificate that will be used for DTLS-SRTP. The certificate is a required SDP attribute for calls that offer or answer DTLS-SRTP media encryption.
The RtpChannel class automatically creates a self-signed X.509 certificate that will be used for all instances of the RtpChannel class for an application session.
Declaration
public static string? CertificateFingerprint { get; }
Property Value
Type | Description |
---|---|
string | Returns null if there was an error during creation of the self-signed X.509 certificate. |
IsDtlsSrtp
Returns true if this channel is using DTLS-SRTP encryption
Declaration
public bool IsDtlsSrtp { get; }
Property Value
Type | Description |
---|---|
bool |
IsSdesSrtp
Returns true if this channel is using SDES-SRTP encryption
Declaration
public bool IsSdesSrtp { get; }
Property Value
Type | Description |
---|---|
bool |
LocalPort
Gets the port number of the local IPEndPoint.
Declaration
public int LocalPort { get; }
Property Value
Type | Description |
---|---|
int |
MediaType
Gets the media type for this RtpChannel
Declaration
public string MediaType { get; }
Property Value
Type | Description |
---|---|
string | Will be one of "audio", "video" or "text" (for RTT) |
RemoteRtcpEndPoint
Gets or sets the RTCP IPEndPoint of the remote
Declaration
public IPEndPoint RemoteRtcpEndPoint { get; set; }
Property Value
Type | Description |
---|---|
IPEndPoint |
RemoteRtpEndPoint
Gets or sets the RTP IPEndPoint of the remote.
Declaration
public IPEndPoint RemoteRtpEndPoint { get; set; }
Property Value
Type | Description |
---|---|
IPEndPoint |
SSRC
Gets or sets the RTP SSRC for this RtpChannel. By default, the SSRC is set to a random unsigned 32-bit number so there is usually no need to change it by calling the setter.
Declaration
public uint SSRC { get; set; }
Property Value
Type | Description |
---|---|
uint |
Methods
| Edit this page View SourceCreateFromSdp(bool, Sdp, MediaDescription, Sdp, MediaDescription, bool, string?)
Creates an RtpChannel using the offered and answered Session Description Protocol (SDP) parameters.
Declaration
public static (RtpChannel?, string?) CreateFromSdp(bool Incoming, Sdp OfferedSdp, MediaDescription OfferedMd, Sdp AnsweredSdp, MediaDescription AnsweredMd, bool enableRtcp, string? CNAME)
Parameters
Type | Name | Description |
---|---|---|
bool | Incoming | Set to true if the call is incoming. |
Sdp | OfferedSdp | The SDP that was offered. If Incoming is true, then this parameter must be the Sdp object that was received in an INVITE request. Else, this parameter must be the Sdp object that the client sent in an INVITE request. |
MediaDescription | OfferedMd | The offered media description parameter block from the offered SDP for the media type that the RtpChannel will handle. |
Sdp | AnsweredSdp | The SDP that was answered. If Incoming is true, then this parameter must be the Sdp object that the server sent in response to an INVITE request that it received. Else, this parameter must the the Sdp object that the client received in response to the INVITE that it sent. |
MediaDescription | AnsweredMd | The answered media description parameter block from the answered SDP for the media type that the RtpChannel will handle. |
bool | enableRtcp | If true, then RTCP packets will be sent periodically. |
string | CNAME | Cononical name to use for sending SDES RTCP packets that identify the media source. If null, then a default CNAME will be automatically generated. |
Returns
Type | Description |
---|---|
(RtpChannel, string) | Returns a (RtpChannel, string) tuple. If the RtpChannel return value is null then an error was detected and the string return value will contain an explanation of the error. If the RtpChannel return value is not null then the string return value will be null. |
Send(RtpPacket)
Sends an RTP packet to the remote endpoint
Declaration
public void Send(RtpPacket rtpPacket)
Parameters
Type | Name | Description |
---|---|---|
RtpPacket | rtpPacket |
Shutdown()
Shuts down this RtpChannel and releases all resources. The RtpChannel object cannot be used after this method is called.
Declaration
public void Shutdown()
StartListening()
Starts the listener threads for RTP and RTCP.
Declaration
public void StartListening()
Events
| Edit this page View SourceDtlsHandshakeFailed
Event that is fired if the DTLS-SRTP handshake failed
Declaration
public event DtlsHandshakeFailedDelegate? DtlsHandshakeFailed
Event Type
Type | Description |
---|---|
DtlsHandshakeFailedDelegate |
ReceiveStatisticsReady
Event that is fired when new receive side statistics are ready. This event if fired only if RTCP is enabled for the RtpChannel and the media type is audio. This event will be fired every 5 seconds.
Declaration
public event ReceiveStatisticsReadyDelegate? ReceiveStatisticsReady
Event Type
Type | Description |
---|---|
ReceiveStatisticsReadyDelegate |
RtcpPacketReceived
Event that is fired when a RTCP packet is received.
Declaration
public event RtcpPacketReceivedDelegate? RtcpPacketReceived
Event Type
Type | Description |
---|---|
RtcpPacketReceivedDelegate |
RtcpPacketSent
Event that is fired when this class sends an RTCP packet.
Declaration
public event RtcpPacketSentDelegate? RtcpPacketSent
Event Type
Type | Description |
---|---|
RtcpPacketSentDelegate |
RtpPacketReceived
Event that is fired when a RTP media packet has been received by this RtpChannel
Declaration
public event RtpPacketReceivedDelegate? RtpPacketReceived
Event Type
Type | Description |
---|---|
RtpPacketReceivedDelegate |
RtpPacketSent
Event that is fired when a RTP packet has been sent by this RtpChannel. This event is used for logging media when using an active SIP media recorder (SIPREC).
Declaration
public event RtpPacketSentDelegate? RtpPacketSent
Event Type
Type | Description |
---|---|
RtpPacketSentDelegate |