Skip to content

Commit

Permalink
Correct some type for rtp value
Browse files Browse the repository at this point in the history
  • Loading branch information
ngraziano committed Apr 11, 2024
1 parent ae9833d commit 70d9197
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion RTSP/RTSP.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<Authors>ngraziano</Authors>
<Product>SharpRTSP</Product>
<Description>Handle receive and send of Rtsp Messages</Description>
<VersionPrefix>1.4.0</VersionPrefix>
<VersionPrefix>1.4.1</VersionPrefix>
<PackageProjectUrl>https://github.com/ngraziano/SharpRTSP</PackageProjectUrl>
<RepositoryUrl>https://github.com/ngraziano/SharpRTSP</RepositoryUrl>
<EnableNETAnalyzers>True</EnableNETAnalyzers>
Expand Down
4 changes: 2 additions & 2 deletions RTSP/Rtp/AACPayload.cs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public RawMediaFrame ProcessPacket(RtpPacket packet)
{
RtpTimestamp = packet.Timestamp,
ClockTimestamp = RtpPacketOnvifUtils.ProcessRTPTimestampExtension(packet.Extension, headerPosition: out _),
};
};
}
}
}
}
2 changes: 1 addition & 1 deletion RTSP/Rtp/RawMediaFrame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public IEnumerable<ReadOnlyMemory<byte>> Data
}

public required DateTime ClockTimestamp { get; init; }
public required ulong RtpTimestamp { get; init; }
public required uint RtpTimestamp { get; init; }


public RawMediaFrame(IEnumerable<ReadOnlyMemory<byte>> data, IEnumerable<IMemoryOwner<byte>> owners)
Expand Down
9 changes: 6 additions & 3 deletions RTSP/Rtp/RtpPacket.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Buffers.Binary;

namespace Rtsp.Rtp
{
Expand All @@ -11,15 +12,17 @@ public RtpPacket(ReadOnlySpan<byte> rawData)
this.rawData = rawData;
}

public bool IsWellFormed => rawData.Length >= 12 && Version == 2 && PayloadSize >= 0;

public int Version => (rawData[0] >> 6) & 0x03;
public bool HasPadding => (rawData[0] & 0x20) > 0;
public bool HasExtension => (rawData[0] & 0x10) > 0;
public int CsrcCount => rawData[0] & 0x0F;
public bool IsMarker => (rawData[1] & 0x80) > 0;
public int PayloadType => rawData[1] & 0x7F;
public int SequenceNumber => (rawData[2] << 8) + rawData[3];
public ulong Timestamp => (ulong)(rawData[4] << 24) + (ulong)(rawData[5] << 16) + (ulong)(rawData[6] << 8) + (ulong)rawData[7];
public ulong Ssrc => (ulong)(rawData[8] << 24) + (ulong)(rawData[9] << 16) + (ulong)(rawData[10] << 8) + (ulong)rawData[11];
public int SequenceNumber => BinaryPrimitives.ReadUInt16BigEndian(rawData[2..]);
public uint Timestamp => BinaryPrimitives.ReadUInt32BigEndian(rawData[4..]);
public uint Ssrc => BinaryPrimitives.ReadUInt32BigEndian(rawData[8..]);

public int? ExtensionHeaderId => HasExtension ? (rawData[HeaderSize] << 8) + rawData[HeaderSize + 1] : null;

Expand Down

0 comments on commit 70d9197

Please sign in to comment.