Skip to content

Commit 173ed43

Browse files
committed
B Fixed incorrect RTCP callback, added proper event handlers for Raw data
1 parent 8e8bceb commit 173ed43

1 file changed

Lines changed: 23 additions & 8 deletions

File tree

src/SharpRTSPClient/RTSPClient.cs

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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 ReceivedRTCPDelegate RawRtcpMessageReceived;
48-
public delegate void ReceivedRTCPDelegate(byte[] rtcp, bool isVideo);
47+
public event EventHandler<RawDataEventArgs> ReceivedRawVideoRTCP;
48+
public event EventHandler<RawDataEventArgs> ReceivedRawAudioRTCP;
4949

5050
public bool ProcessRTP { get; set; } = true;
51-
public event ReceivedRTPDelegate RawRtpMessageReceived;
52-
public delegate void ReceivedRTPDelegate(byte[] rtp, bool isVideo);
51+
public event EventHandler<RawDataEventArgs> ReceivedRawVideoRTP;
52+
public event EventHandler<RawDataEventArgs> ReceivedRawAudioRTP;
5353

5454
public bool AutoPlay { get; set; } = true;
5555

@@ -419,7 +419,7 @@ private void VideoRtpDataReceived(object sender, RtspDataEventArgs e)
419419
return;
420420
}
421421

422-
RawRtpMessageReceived?.Invoke(data.Data.ToArray(), true);
422+
ReceivedRawVideoRTP?.Invoke(this, new RawDataEventArgs(data.Data));
423423

424424
if (!ProcessRTP)
425425
{
@@ -459,7 +459,7 @@ private void AudioRtpDataReceived(object sender, RtspDataEventArgs e)
459459
return;
460460
}
461461

462-
RawRtpMessageReceived?.Invoke(data.Data.ToArray(), false);
462+
ReceivedRawAudioRTP?.Invoke(this, new RawDataEventArgs(data.Data));
463463

464464
if (!ProcessRTP)
465465
{
@@ -491,7 +491,7 @@ private void VideoRtcpControlDataReceived(object sender, RtspDataEventArgs e)
491491

492492
using (var data = e.Data)
493493
{
494-
RawRtcpMessageReceived?.Invoke(data.Data.ToArray(), true);
494+
ReceivedRawVideoRTCP?.Invoke(this, new RawDataEventArgs(data.Data));
495495

496496
if (!ProcessRTCP)
497497
return;
@@ -513,7 +513,7 @@ private void AudioRtcpControlDataReceived(object sender, RtspDataEventArgs e)
513513

514514
using (var data = e.Data)
515515
{
516-
RawRtcpMessageReceived?.Invoke(data.Data.ToArray(), true);
516+
ReceivedRawAudioRTCP?.Invoke(this, new RawDataEventArgs(data.Data));
517517

518518
if (!ProcessRTCP)
519519
return;
@@ -1239,6 +1239,21 @@ public override string ToString()
12391239
}
12401240
}
12411241

1242+
public class RawDataEventArgs : EventArgs
1243+
{
1244+
public RawDataEventArgs(ReadOnlyMemory<byte> data)
1245+
{
1246+
Data = data;
1247+
}
1248+
1249+
public ReadOnlyMemory<byte> Data { get; }
1250+
1251+
public override string ToString()
1252+
{
1253+
return $"Data {Data.Length}";
1254+
}
1255+
}
1256+
12421257
public static class RTSPMessageAuthExtensions
12431258
{
12441259
public static void AddAuthorization(this RtspMessage message, Authentication authentication, Uri uri, uint commandCounter)

0 commit comments

Comments
 (0)