@@ -44,12 +44,12 @@ public class RTSPClient : IDisposable
4444 public event EventHandler < SimpleDataEventArgs > ReceivedAudioData ;
4545
4646 public bool ProcessRTCP { get ; set ; } = true ; // answer RTCP
47- public event EventHandler < RawDataEventArgs > ReceivedRawVideoRTCP ;
48- public event EventHandler < RawDataEventArgs > ReceivedRawAudioRTCP ;
47+ public event EventHandler < RawRtcpDataEventArgs > ReceivedRawVideoRTCP ;
48+ public event EventHandler < RawRtcpDataEventArgs > ReceivedRawAudioRTCP ;
4949
5050 public bool ProcessRTP { get ; set ; } = true ;
51- public event EventHandler < RawDataEventArgs > ReceivedRawVideoRTP ;
52- public event EventHandler < RawDataEventArgs > ReceivedRawAudioRTP ;
51+ public event EventHandler < RawRtpDataEventArgs > ReceivedRawVideoRTP ;
52+ public event EventHandler < RawRtpDataEventArgs > ReceivedRawAudioRTP ;
5353
5454 public bool AutoPlay { get ; set ; } = true ;
5555
@@ -419,7 +419,22 @@ private void VideoRtpDataReceived(object sender, RtspDataEventArgs e)
419419 return ;
420420 }
421421
422- ReceivedRawVideoRTP ? . Invoke ( this , new RawDataEventArgs ( data . Data ) ) ;
422+ ReceivedRawVideoRTP ? . Invoke ( this ,
423+ new RawRtpDataEventArgs (
424+ data . Data ,
425+ rtpPacket . CsrcCount ,
426+ rtpPacket . ExtensionHeaderId ,
427+ rtpPacket . HasPadding ,
428+ rtpPacket . IsMarker ,
429+ rtpPacket . IsWellFormed ,
430+ rtpPacket . PayloadSize ,
431+ rtpPacket . PayloadType ,
432+ rtpPacket . SequenceNumber ,
433+ rtpPacket . Ssrc ,
434+ rtpPacket . Timestamp ,
435+ rtpPacket . Version
436+ )
437+ ) ;
423438
424439 if ( ! ProcessRTP )
425440 {
@@ -436,7 +451,7 @@ private void VideoRtpDataReceived(object sender, RtspDataEventArgs e)
436451 {
437452 if ( nalUnits . Any ( ) )
438453 {
439- ReceivedVideoData ? . Invoke ( this , new SimpleDataEventArgs ( nalUnits . Data , nalUnits . ClockTimestamp ) ) ;
454+ ReceivedVideoData ? . Invoke ( this , new SimpleDataEventArgs ( nalUnits . Data , nalUnits . ClockTimestamp , nalUnits . RtpTimestamp ) ) ;
440455 }
441456 }
442457 }
@@ -459,7 +474,22 @@ private void AudioRtpDataReceived(object sender, RtspDataEventArgs e)
459474 return ;
460475 }
461476
462- ReceivedRawAudioRTP ? . Invoke ( this , new RawDataEventArgs ( data . Data ) ) ;
477+ ReceivedRawAudioRTP ? . Invoke ( this ,
478+ new RawRtpDataEventArgs (
479+ data . Data ,
480+ rtpPacket . CsrcCount ,
481+ rtpPacket . ExtensionHeaderId ,
482+ rtpPacket . HasPadding ,
483+ rtpPacket . IsMarker ,
484+ rtpPacket . IsWellFormed ,
485+ rtpPacket . PayloadSize ,
486+ rtpPacket . PayloadType ,
487+ rtpPacket . SequenceNumber ,
488+ rtpPacket . Ssrc ,
489+ rtpPacket . Timestamp ,
490+ rtpPacket . Version
491+ )
492+ ) ;
463493
464494 if ( ! ProcessRTP )
465495 {
@@ -476,7 +506,7 @@ private void AudioRtpDataReceived(object sender, RtspDataEventArgs e)
476506 {
477507 if ( audioFrames . Any ( ) )
478508 {
479- ReceivedAudioData ? . Invoke ( this , new SimpleDataEventArgs ( audioFrames . Data , audioFrames . ClockTimestamp ) ) ;
509+ ReceivedAudioData ? . Invoke ( this , new SimpleDataEventArgs ( audioFrames . Data , audioFrames . ClockTimestamp , audioFrames . RtpTimestamp ) ) ;
480510 }
481511 }
482512 }
@@ -491,7 +521,7 @@ private void VideoRtcpControlDataReceived(object sender, RtspDataEventArgs e)
491521
492522 using ( var data = e . Data )
493523 {
494- ReceivedRawVideoRTCP ? . Invoke ( this , new RawDataEventArgs ( data . Data ) ) ;
524+ ReceivedRawVideoRTCP ? . Invoke ( this , new RawRtcpDataEventArgs ( data . Data ) ) ;
495525
496526 if ( ! ProcessRTCP )
497527 return ;
@@ -513,7 +543,7 @@ private void AudioRtcpControlDataReceived(object sender, RtspDataEventArgs e)
513543
514544 using ( var data = e . Data )
515545 {
516- ReceivedRawAudioRTCP ? . Invoke ( this , new RawDataEventArgs ( data . Data ) ) ;
546+ ReceivedRawAudioRTCP ? . Invoke ( this , new RawRtcpDataEventArgs ( data . Data ) ) ;
517547
518548 if ( ! ProcessRTCP )
519549 return ;
@@ -1224,24 +1254,75 @@ public interface IStreamConfigurationData
12241254
12251255 public class SimpleDataEventArgs : EventArgs
12261256 {
1227- public SimpleDataEventArgs ( IEnumerable < ReadOnlyMemory < byte > > data , DateTime timeStamp )
1257+ public SimpleDataEventArgs ( IEnumerable < ReadOnlyMemory < byte > > data , DateTime timestamp , uint rtpTimestamp )
12281258 {
12291259 Data = data ;
1230- TimeStamp = timeStamp ;
1260+ Timestamp = timestamp ;
1261+ RtpTimestamp = rtpTimestamp ;
12311262 }
12321263
1233- public DateTime TimeStamp { get ; }
1264+ public DateTime Timestamp { get ; }
1265+ public uint RtpTimestamp { get ; }
12341266 public IEnumerable < ReadOnlyMemory < byte > > Data { get ; }
12351267
12361268 public override string ToString ( )
12371269 {
1238- return $ "{ TimeStamp } : Data { Data . Count ( ) } ";
1270+ return $ "{ Timestamp } : Data { Data . Count ( ) } ";
12391271 }
12401272 }
12411273
1242- public class RawDataEventArgs : EventArgs
1274+ public class RawRtpDataEventArgs : EventArgs
12431275 {
1244- public RawDataEventArgs ( ReadOnlyMemory < byte > data )
1276+ public ReadOnlyMemory < byte > Data { get ; }
1277+ public int CsrcCount { get ; }
1278+ public int ? ExtensionHeaderId { get ; }
1279+ public bool HasPadding { get ; }
1280+ public bool IsMarker { get ; }
1281+ public bool IsWellFormed { get ; }
1282+ public int PayloadSize { get ; }
1283+ public int PayloadType { get ; }
1284+ public int SequenceNumber { get ; }
1285+ public uint Ssrc { get ; }
1286+ public uint Timestamp { get ; }
1287+ public int Version { get ; }
1288+
1289+ public RawRtpDataEventArgs (
1290+ ReadOnlyMemory < byte > data ,
1291+ int csrcCount ,
1292+ int ? extensionHeaderId ,
1293+ bool hasPadding ,
1294+ bool isMarker ,
1295+ bool isWellFormed ,
1296+ int payloadSize ,
1297+ int payloadType ,
1298+ int sequenceNumber ,
1299+ uint ssrc ,
1300+ uint timestamp ,
1301+ int version )
1302+ {
1303+ Data = data ;
1304+ CsrcCount = csrcCount ;
1305+ ExtensionHeaderId = extensionHeaderId ;
1306+ HasPadding = hasPadding ;
1307+ IsMarker = isMarker ;
1308+ IsWellFormed = isWellFormed ;
1309+ PayloadSize = payloadSize ;
1310+ PayloadType = payloadType ;
1311+ SequenceNumber = sequenceNumber ;
1312+ Ssrc = ssrc ;
1313+ Timestamp = timestamp ;
1314+ Version = version ;
1315+ }
1316+
1317+ public override string ToString ( )
1318+ {
1319+ return $ "RTP { Timestamp } : Data { Data . Length } ";
1320+ }
1321+ }
1322+
1323+ public class RawRtcpDataEventArgs : EventArgs
1324+ {
1325+ public RawRtcpDataEventArgs ( ReadOnlyMemory < byte > data )
12451326 {
12461327 Data = data ;
12471328 }
0 commit comments