Skip to content

Commit

Permalink
fix RtpPacket and RtcpPacket bitmask setter logic (#209)
Browse files Browse the repository at this point in the history
previous logic only worked on zeroed data, it could not update existing packets
  • Loading branch information
SteveAyre authored Aug 4, 2024
1 parent 3cded41 commit 7ca0301
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion PacketDotNet/RtcpPacket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public bool HasPadding
public int ReceptionReportCount
{
get => (Header.Bytes[Header.Offset] & RtcpFields.ReceptionReportCountMask);
set => Header.Bytes[Header.Offset] |= (byte) (value & RtcpFields.ReceptionReportCountMask);
set => Header.Bytes[Header.Offset] = (byte) ((Header.Bytes[Header.Offset] & ~RtcpFields.ReceptionReportCountMask) | (value & RtcpFields.ReceptionReportCountMask));
}

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions PacketDotNet/RtpPacket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public int CsrcCount
get => Header.Bytes[Header.Offset] & RtpFields.CsrcCountMask;
set
{
Header.Bytes[Header.Offset] |= (byte) (value & RtpFields.CsrcCountMask);
Header.Bytes[Header.Offset] = (byte) ((Header.Bytes[Header.Offset] & ~RtpFields.CsrcCountMask) | (value & RtpFields.CsrcCountMask));
Header.Length = RtpFields.HeaderLength + CsrcCount * RtpFields.CsrcIdLength;
if (HasExtension)
Header.Length += RtpFields.ProfileSpecificExtensionHeaderLength + RtpFields.ExtensionLengthLength +
Expand Down Expand Up @@ -174,7 +174,7 @@ public bool Marker
public int PayloadType
{
get => Header.Bytes[Header.Offset + 1] & RtpFields.PayloadTypeMask;
set => Header.Bytes[Header.Offset + 1] |= (byte) (value & RtpFields.PayloadTypeMask);
set => Header.Bytes[Header.Offset + 1] = (byte) ((Header.Bytes[Header.Offset + 1] & ~RtpFields.PayloadTypeMask) | (value & RtpFields.PayloadTypeMask));
}

/// <summary>
Expand Down

0 comments on commit 7ca0301

Please sign in to comment.