Skip to content

Commit

Permalink
Formating
Browse files Browse the repository at this point in the history
  • Loading branch information
ngraziano committed Mar 24, 2024
1 parent 18a7397 commit d8fe7c8
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 28 deletions.
1 change: 0 additions & 1 deletion RTSP/Rtp/AACPayload.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ section 4.1.
*/


public class AACPayload : IPayloadProcessor
{
private readonly MemoryPool<byte> _memoryPool;
Expand Down
1 change: 0 additions & 1 deletion RTSP/Rtp/RawMediaFrame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ public RawMediaFrame(IEnumerable<ReadOnlyMemory<byte>> data, IEnumerable<IMemory

public bool Any() => Data.Any();


protected virtual void Dispose(bool disposing)
{
if (!disposedValue)
Expand Down
2 changes: 1 addition & 1 deletion RtspCameraExample/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public Demo(ILoggerFactory loggerFactory)
// It will feed YUV Images into the event handler, which will compress the video into NALs and pass them into the RTSP Server
// It will feed PCM Audio into the event handler, which will compress the audio into G711 uLAW packets and pass them into the RTSP Server
/////////////////////////////////////////
TestCard av_source = new TestCard((int)width, (int)height, (int)fps);
TestCard av_source = new(width, height, (int)fps);
av_source.ReceivedYUVFrame += Video_source_ReceivedYUVFrame; // the event handler is where all the magic happens
av_source.ReceivedAudioFrame += Audio_source_ReceivedAudioFrame; // the event handler is where all the magic happens

Expand Down
1 change: 0 additions & 1 deletion RtspCameraExample/RTCPUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public static void WriteRTCPHeader(Span<byte> rtcp_sender_report, int version, b

public static void WriteSenderReport(Span<byte> rtcpSenderReport, DateTime now, uint rtp_timestamp, uint rtpPacketCount, uint octetCount)
{

// Bytes 8, 9, 10, 11 and 12,13,14,15 are the Wall Clock
// Bytes 16,17,18,19 are the RTP payload timestamp

Expand Down
4 changes: 2 additions & 2 deletions RtspCameraExample/RtspServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -734,9 +734,9 @@ private static (List<Memory<byte>>, List<IMemoryOwner<byte>>) PrepareVideoRtpPac
RTPPacketUtil.WriteTS(rtp_packet.Span, rtp_timestamp);

// Now append the Fragmentation Header (with Start and End marker) and part of the raw_nal
byte f_bit = 0;
const byte f_bit = 0;
byte nri = (byte)(first_byte >> 5 & 0x03); // Part of the 1st byte of the Raw NAL (NAL Reference ID)
byte type = 28; // FU-A Fragmentation
const byte type = 28; // FU-A Fragmentation

rtp_packet.Span[12] = (byte)((f_bit << 7) + (nri << 5) + type);
rtp_packet.Span[13] = (byte)((start_bit << 7) + (end_bit << 6) + (0 << 5) + (first_byte & 0x1F));
Expand Down
14 changes: 2 additions & 12 deletions RtspClientExample/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace RtspClientExample
{
public static class Program
{
static void Main(string[] args)
static void Main()
{
var loggerFactory = LoggerFactory.Create(builder =>
{
Expand Down Expand Up @@ -68,11 +68,9 @@ static void Main(string[] args)

// H265 Tests


// Create a RTSP Client
RTSPClient client = new(loggerFactory);


client.NewVideoStream += (_, args) =>
{
switch (args.StreamType)
Expand Down Expand Up @@ -115,12 +113,8 @@ static void Main(string[] args)
Console.WriteLine("Unknow Audio format" + arg.StreamType);
break;
}
};

/*
*/
client.SetupMessageCompleted += (_, _) =>
{
if (usePlayback)
Expand Down Expand Up @@ -170,7 +164,6 @@ static void Main(string[] args)

private static void NewAACAudioStream(NewStreamEventArgs arg, RTSPClient client)
{

string now = DateTime.Now.ToString("yyyyMMdd_HHmmss");
string filename = "rtsp_capture_" + now + ".aac";
var fs_a = new FileStream(filename, FileMode.Create);
Expand All @@ -187,7 +180,7 @@ private static void NewAACAudioStream(NewStreamEventArgs arg, RTSPClient client)
// int sample_freq = 4; // 4 = 44100 Hz
// int channel_config = 2; // 2 = Stereo
Rtsp.BitStream bs = new Rtsp.BitStream();
Rtsp.BitStream bs = new();
bs.AddValue(0xFFF, 12); // (a) Start of data
bs.AddValue(0, 1); // (b) Version ID, 0 = MPEG4
bs.AddValue(0, 2); // (c) Layer always 2 bits set to 0
Expand All @@ -214,7 +207,6 @@ private static void NewAACAudioStream(NewStreamEventArgs arg, RTSPClient client)
fs_a.Write(data.Span);
}
};

}

private static void NewAMRAudioStream(RTSPClient client)
Expand Down Expand Up @@ -317,7 +309,6 @@ private static void NewH265Stream(NewStreamEventArgs args, RTSPClient client)
Console.WriteLine("NAL Type = " + nal_unit_type + " " + description);
}
fs_v.Write(nalUnit);
}
}
};
Expand Down Expand Up @@ -356,7 +347,6 @@ private static void NewH264Stream(NewStreamEventArgs args, RTSPClient client)
Console.WriteLine("NAL Ref = " + nal_ref_idc + " NAL Type = " + nal_unit_type + " " + description);
}
fs_v.Write(nalUnit);
}
};
}
Expand Down
5 changes: 1 addition & 4 deletions RtspClientExample/RTSPClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,6 @@ public void Play(DateTime seekTimeFrom, DateTime seekTimeTo, double speed = 1.0)

public void Stop()
{

// Send TEARDOWN
RtspRequest teardown_message = new RtspRequestTeardown
{
Expand Down Expand Up @@ -774,7 +773,6 @@ private void HandleDescribeResponse(RtspResponse message)
33 => "MP2T",
_ => string.Empty,
};

}
}

Expand All @@ -794,7 +792,6 @@ private void HandleDescribeResponse(RtspResponse message)
}
else if (videoPayloadProcessor is H265Payload && fmtp?.FormatParameter is not null)
{

// If the rtpmap contains H265 then split the fmtp to get the sprop-vps, sprop-sps and sprop-pps
// The RFC makes the VPS, SPS and PPS OPTIONAL so they may not be present. In which we pass back NULL values
var param = H265Parameters.Parse(fmtp.FormatParameter);
Expand Down Expand Up @@ -896,7 +893,7 @@ private void HandleDescribeResponse(RtspResponse message)
RtspUri = audio_uri,
};
setup_message.AddTransport(transport);
setup_message.AddAuthorization(_authentication!, _uri!, rtspSocket!.NextCommandIndex());
setup_message.AddAuthorization(_authentication, _uri!, rtspSocket!.NextCommandIndex());
if (_playbackSession)
{
setup_message.AddRequireOnvifRequest();
Expand Down
7 changes: 1 addition & 6 deletions RtspClientExample/RTSPEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,12 @@ public NewStreamEventArgs(string streamType, IStreamConfigurationData? streamCon
public IStreamConfigurationData? StreamConfigurationData { get; }
}

public interface IStreamConfigurationData
{
}
public interface IStreamConfigurationData;

public record H264StreamConfigurationData : IStreamConfigurationData
{
public required byte[] SPS { get; init; }
public required byte[] PPS { get; init; }

}

public record H265StreamConfigurationData: IStreamConfigurationData
Expand Down Expand Up @@ -52,6 +49,4 @@ public SimpleDataEventArgs(IEnumerable<ReadOnlyMemory<byte>> data, DateTime time
public DateTime TimeStamp { get; }
public IEnumerable<ReadOnlyMemory<byte>> Data { get; }
}


}

0 comments on commit d8fe7c8

Please sign in to comment.