Skip to content

Commit 1e12ff7

Browse files
committed
F Added payload start to fix raw RTP forwarding
1 parent 1349937 commit 1e12ff7

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

src/SharpRTSPClient/RTSPClient.cs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,8 @@ private void VideoRtpDataReceived(object sender, RtspDataEventArgs e)
442442
rtpPacket.SequenceNumber,
443443
rtpPacket.Ssrc,
444444
rtpPacket.Timestamp,
445-
rtpPacket.Version
445+
rtpPacket.Version,
446+
CalculatePayloadStart(rtpPacket)
446447
)
447448
);
448449

@@ -467,6 +468,13 @@ private void VideoRtpDataReceived(object sender, RtspDataEventArgs e)
467468
}
468469
}
469470

471+
private static int CalculatePayloadStart(RtpPacket rtpPacket)
472+
{
473+
// Note: e.PayloadSize includes also extensions and is incorrect for RTP forwarding,
474+
// we have to calculate the correct size using 12 + e.CsrcCount * 4
475+
return 12 + rtpPacket.CsrcCount * 4;
476+
}
477+
470478
private void AudioRtpDataReceived(object sender, RtspDataEventArgs e)
471479
{
472480
if (e.Data.Data.IsEmpty)
@@ -497,7 +505,8 @@ private void AudioRtpDataReceived(object sender, RtspDataEventArgs e)
497505
rtpPacket.SequenceNumber,
498506
rtpPacket.Ssrc,
499507
rtpPacket.Timestamp,
500-
rtpPacket.Version
508+
rtpPacket.Version,
509+
CalculatePayloadStart(rtpPacket)
501510
)
502511
);
503512

@@ -1297,6 +1306,7 @@ public class RawRtpDataEventArgs : EventArgs
12971306
public uint Ssrc { get; }
12981307
public uint Timestamp { get; }
12991308
public int Version { get; }
1309+
public int PayloadStart { get; }
13001310

13011311
public RawRtpDataEventArgs(
13021312
ReadOnlyMemory<byte> data,
@@ -1310,7 +1320,8 @@ public RawRtpDataEventArgs(
13101320
int sequenceNumber,
13111321
uint ssrc,
13121322
uint timestamp,
1313-
int version)
1323+
int version,
1324+
int payloadStart)
13141325
{
13151326
Data = data;
13161327
CsrcCount = csrcCount;
@@ -1324,6 +1335,7 @@ public RawRtpDataEventArgs(
13241335
Ssrc = ssrc;
13251336
Timestamp = timestamp;
13261337
Version = version;
1338+
PayloadStart = payloadStart;
13271339
}
13281340

13291341
public override string ToString()

0 commit comments

Comments
 (0)