Skip to content

Commit

Permalink
Update RtspMultiplexer style
Browse files Browse the repository at this point in the history
  • Loading branch information
ngraziano committed Apr 4, 2024
1 parent 88e4edd commit 93cbfe6
Show file tree
Hide file tree
Showing 12 changed files with 275 additions and 418 deletions.
35 changes: 8 additions & 27 deletions RtspMultiplexer/Fowarder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public abstract class Forwarder
/// <summary>
/// Logger object
/// </summary>
private static NLog.Logger _logger = NLog.LogManager.GetCurrentClassLogger();
private static readonly NLog.Logger _logger = NLog.LogManager.GetCurrentClassLogger();

/// <summary>
/// First port number to use
Expand Down Expand Up @@ -43,13 +43,11 @@ protected static int GetNextPort()
/// <summary>
/// Forward UDP port (send data from this port)
/// </summary>
protected UdpClient ForwardVUdpPort
{ get; private set; }
protected UdpClient ForwardVUdpPort { get; private set; }
/// <summary>
/// Listen UDP port (receive data on this port)
/// </summary>
protected UdpClient ListenCUdpPort
{ get; private set; }
protected UdpClient ListenCUdpPort { get; private set; }

/// <summary>
/// Initializes a new instance of the <see cref="Forwarder"/> class.
Expand All @@ -72,11 +70,8 @@ protected Forwarder()
{
_logger.Debug("Fail to allocate port, try again");

if (ForwardVUdpPort != null)
ForwardVUdpPort.Close();

if (ListenCUdpPort != null)
ListenCUdpPort.Close();
ForwardVUdpPort?.Close();
ListenCUdpPort?.Close();
}
}
// Not sure it is usefull
Expand Down Expand Up @@ -111,25 +106,13 @@ protected Forwarder()
/// Gets video port from which the system forward .
/// </summary>
/// <value>Video port.</value>
public int FromForwardVideoPort
{
get
{
return ((IPEndPoint)ForwardVUdpPort.Client.LocalEndPoint).Port;
}
}
public int FromForwardVideoPort => ((IPEndPoint)ForwardVUdpPort.Client.LocalEndPoint).Port;

/// <summary>
/// Gets the listen command port.
/// </summary>
/// <value>The listen command port.</value>
public int ListenCommandPort
{
get
{
return ((IPEndPoint)ListenCUdpPort.Client.LocalEndPoint).Port;
}
}
public int ListenCommandPort => ((IPEndPoint)ListenCUdpPort.Client.LocalEndPoint).Port;

/// <summary>
/// Starts this instance.
Expand Down Expand Up @@ -232,9 +215,7 @@ private enum RTCPType : byte
/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
protected void OnCommandReceive(EventArgs e)
{
EventHandler handler = CommandReceive;
if (handler != null)
handler(this, e);
CommandReceive?.Invoke(this, e);
}

/// <summary>
Expand Down
4 changes: 0 additions & 4 deletions RtspMultiplexer/OriginContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ namespace RtspMulticaster
/// </summary>
internal class OriginContext
{
public OriginContext()
{
}

public int OriginCSeq { get; internal set; }
public RtspListener OriginSourcePort { get; internal set; }
}
Expand Down
35 changes: 13 additions & 22 deletions RtspMultiplexer/Program.cs
Original file line number Diff line number Diff line change
@@ -1,27 +1,18 @@
namespace RtspMulticaster
{
using System;

class Program
{
private static NLog.Logger _logger = NLog.LogManager.GetCurrentClassLogger();

static void Main(string[] args)
{
_logger.Info("Starting");
RtspServer monServeur = new RtspServer(8554);

using RtspMulticaster;
using System;

monServeur.StartListen();
RTSPDispatcher.Instance.StartQueue();
NLog.Logger _logger = NLog.LogManager.GetCurrentClassLogger();

while (Console.ReadLine() != "q")
{
}
_logger.Info("Starting");
RtspServer monServeur = new(8554);

monServeur.StopListen();
RTSPDispatcher.Instance.StopQueue();
monServeur.StartListen();
RTSPDispatcher.Instance.StartQueue();


}
}
while (Console.ReadLine() != "q")
{
}

monServeur.StopListen();
RTSPDispatcher.Instance.StopQueue();
35 changes: 0 additions & 35 deletions RtspMultiplexer/Properties/AssemblyInfo.cs

This file was deleted.

Loading

0 comments on commit 93cbfe6

Please sign in to comment.