Class RTPChannel
A communications channel for transmitting and receiving Real-time Protocol (RTP) and Real-time Control Protocol (RTCP) packets. This class performs the socket management functions.
Implements
Inherited Members
Namespace: SIPSorcery.Net
Assembly: SIPSorcery.dll
Syntax
public class RTPChannel : IDisposable
Constructors
| Improve this Doc View SourceRTPChannel(Boolean, IPAddress, Int32, PortRange)
Creates a new RTP channel. The RTP and optionally RTCP sockets will be bound in the constructor. They do not start receiving until the Start method is called.
Declaration
public RTPChannel(bool createControlSocket, IPAddress bindAddress, int bindPort = 0, PortRange rtpPortRange = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | createControlSocket | Set to true if a separate RTCP control socket should be created. If RTP and RTCP are being multiplexed (as they are for WebRTC) there's no need to a separate control socket. |
| System.Net.IPAddress | bindAddress | Optional. An IP address belonging to a local interface that will be used to bind the RTP and control sockets to. If left empty then the IPv6 any address will be used if IPv6 is supported and fallback to the IPv4 any address. |
| System.Int32 | bindPort | Optional. The specific port to attempt to bind the RTP port on. |
| PortRange | rtpPortRange |
Fields
| Improve this Doc View Sourcem_controlReceiver
Declaration
protected UdpReceiver m_controlReceiver
Field Value
| Type | Description |
|---|---|
| UdpReceiver |
m_rtpReceiver
Declaration
protected UdpReceiver m_rtpReceiver
Field Value
| Type | Description |
|---|---|
| UdpReceiver |
Properties
| Improve this Doc View SourceControlLocalEndPoint
The local end point the control socket is listening on.
Declaration
public IPEndPoint ControlLocalEndPoint { get; }
Property Value
| Type | Description |
|---|---|
| System.Net.IPEndPoint |
ControlPort
The local port we are listening for RTCP packets on.
Declaration
public int ControlPort { get; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
IsClosed
Declaration
public bool IsClosed { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
IsDualMode
Returns true if the RTP socket supports dual mode IPv4 and IPv6. If the control socket exists it will be the same.
Declaration
public bool IsDualMode { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
LastRtpDestination
The last remote end point an RTP packet was sent to or received from. Used for reporting purposes only.
Declaration
protected IPEndPoint LastRtpDestination { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Net.IPEndPoint |
RTPLocalEndPoint
The local end point the RTP socket is listening on.
Declaration
public IPEndPoint RTPLocalEndPoint { get; }
Property Value
| Type | Description |
|---|---|
| System.Net.IPEndPoint |
RTPPort
The local port we are listening for RTP (and whatever else is multiplexed) packets on.
Declaration
public int RTPPort { get; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
RtpSocket
Declaration
public Socket RtpSocket { get; }
Property Value
| Type | Description |
|---|---|
| System.Net.Sockets.Socket |
Methods
| Improve this Doc View SourceClose(String)
Closes the session's RTP and control ports.
Declaration
public void Close(string reason)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | reason |
Dispose()
Declaration
public void Dispose()
Dispose(Boolean)
Declaration
protected virtual void Dispose(bool disposing)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | disposing |
OnRTPPacketReceived(UdpReceiver, Int32, IPEndPoint, Byte[])
Event handler for packets received on the RTP UDP socket.
Declaration
protected virtual void OnRTPPacketReceived(UdpReceiver receiver, int localPort, IPEndPoint remoteEndPoint, byte[] packet)
Parameters
| Type | Name | Description |
|---|---|---|
| UdpReceiver | receiver | The UDP receiver the packet was received on. |
| System.Int32 | localPort | The local port it was received on. |
| System.Net.IPEndPoint | remoteEndPoint | The remote end point of the sender. |
| System.Byte[] | packet | The raw packet received (note this may not be RTP if other protocols are being multiplexed). |
Send(RTPChannelSocketsEnum, IPEndPoint, Byte[])
The send method for the RTP channel.
Declaration
public virtual SocketError Send(RTPChannelSocketsEnum sendOn, IPEndPoint dstEndPoint, byte[] buffer)
Parameters
| Type | Name | Description |
|---|---|---|
| RTPChannelSocketsEnum | sendOn | The socket to send on. Can be the RTP or Control socket. |
| System.Net.IPEndPoint | dstEndPoint | The destination end point to send to. |
| System.Byte[] | buffer | The data to send. |
Returns
| Type | Description |
|---|---|
| System.Net.Sockets.SocketError | The result of initiating the send. This result does not reflect anything about whether the remote party received the packet or not. |
Start()
Starts listening on the RTP and control ports.
Declaration
public void Start()
StartControlReceiver()
Starts the UDP receiver that listens for RTCP (control) packets.
Declaration
public void StartControlReceiver()
StartRtpReceiver()
Starts the UDP receiver that listens for RTP packets.
Declaration
public void StartRtpReceiver()
Events
| Improve this Doc View SourceOnClosed
Declaration
public event Action<string> OnClosed
Event Type
| Type | Description |
|---|---|
| System.Action<System.String> |
OnControlDataReceived
Declaration
public event Action<int, IPEndPoint, byte[]> OnControlDataReceived
Event Type
| Type | Description |
|---|---|
| System.Action<System.Int32, System.Net.IPEndPoint, System.Byte[]> |
OnRTPDataReceived
Declaration
public event Action<int, IPEndPoint, byte[]> OnRTPDataReceived
Event Type
| Type | Description |
|---|---|
| System.Action<System.Int32, System.Net.IPEndPoint, System.Byte[]> |