public void ForceDisconnectPool(List <Guid> connectionIds) { foreach (Guid connectionId in connectionIds.ToList()) { RTSPConnection connection = null; lock (_rtspList) { connection = _rtspList.FirstOrDefault(c => c.Id == connectionId); } if (connection != null) { connection.CloseConnection("forced"); } } }
public void SendRtpDataToConnection(Guid connectionId, byte[] data, Media.MediaTypes mediaType) { RTSPConnection targetConnection = null; lock (_rtspList) { foreach (RTSPConnection connection in _rtspList.ToArray()) { // Convert to Array to allow us to delete from rtsp_list if (connectionId == connection.Id) { targetConnection = connection; break; } } } if (targetConnection != null) { targetConnection.SendRtpData(data, mediaType); } }
void AcceptConnection() { Guid newConnectionId = Guid.Empty; try { while (!_stopping.WaitOne(0)) { // Wait for an incoming TCP Connection TcpClient oneClient = _RTSPServerListener.AcceptTcpClient(); newConnectionId = Guid.NewGuid(); // Hand the incoming TCP connection over to the RTSP classes var rtspSocket = new RtspTcpTransport(oneClient); RTSPConnection newRTSPConnection = null; // Add the RtspListener to the RTSPConnections List lock (_rtspList) { newRTSPConnection = new RTSPConnection(newConnectionId, rtspSocket, _ipAddress, _requestUrlVideoSourceResolverStrategy); newRTSPConnection.OnConnectionAdded += ProcessConnectionAdded; newRTSPConnection.OnConnectionRemoved += ProcessConnectionRemoved; newRTSPConnection.OnProvideSdpData += ProcessRtspProvideSdpData; _rtspList.Add(newRTSPConnection); } newRTSPConnection.Start(); } } catch (SocketException error) { _logger.Debug($"{newConnectionId} Got an error listening, I have to handle the stopping which also throw an error: " + error); } catch (Exception error) { _logger.Debug($"{newConnectionId} Got an error listening:" + error); } }