/// <summary> /// Starts listening on the RTP and control ports. /// </summary> public void Start() { if (!m_started) { m_started = true; logger.LogDebug($"RTPChannel for {RtpSocket.LocalEndPoint} started."); m_rtpReceiver = new UdpReceiver(RtpSocket); m_rtpReceiver.OnPacketReceived += OnRTPPacketReceived; m_rtpReceiver.OnClosed += Close; m_rtpReceiver.BeginReceiveFrom(); if (m_controlSocket != null) { m_controlReceiver = new UdpReceiver(m_controlSocket); m_controlReceiver.OnPacketReceived += OnControlPacketReceived; m_controlReceiver.OnClosed += Close; m_controlReceiver.BeginReceiveFrom(); } } }
/// <summary> /// Event handler for packets received on the control UDP socket. /// </summary> /// <param name="receiver">The UDP receiver the packet was received on.</param> /// <param name="localPort">The local port it was received on.</param> /// <param name="remoteEndPoint">The remote end point of the sender.</param> /// <param name="packet">The raw packet received which should always be an RTCP packet.</param> private void OnControlPacketReceived(UdpReceiver receiver, int localPort, IPEndPoint remoteEndPoint, byte[] packet) { LastControlDestination = remoteEndPoint; OnControlDataReceived?.Invoke(localPort, remoteEndPoint, packet); }