diff --git a/FnePeer.cs b/FnePeer.cs
index 22c9559..36c6c02 100644
--- a/FnePeer.cs
+++ b/FnePeer.cs
@@ -39,6 +39,18 @@ namespace fnecore
/// Stream ID
/// True, if the frame was handled, otherwise false.
public delegate bool RawNetworkFrame(UdpFrame frame, uint peerId, uint streamId);
+ ///
+ /// Callback used to process a raw network frame.
+ ///
+ ///
+ /// Peer ID
+ /// Stream ID
+ /// RTP Header
+ /// RTP FNE Header
+ /// Raw packet message
+ /// True, if the frame was handled, otherwise false.
+ public delegate bool UserPacketHandler(UdpFrame frame, uint peerId, uint streamId,
+ RtpHeader rtpHeader, RtpFNEHeader fneHeader, byte[] message);
///
/// Implements an FNE "peer".
@@ -114,6 +126,16 @@ namespace fnecore
private set;
}
+ ///
+ /// Gets/sets flag indicating whether or not the user packet handler is also handling
+ /// protocol packets.
+ ///
+ public bool UserProtocolHandler
+ {
+ get;
+ set;
+ }
+
/*
** Events/Callbacks
*/
@@ -122,6 +144,10 @@ namespace fnecore
/// Event action that handles a raw network frame directly.
///
public RawNetworkFrame NetworkFrameHandler = null;
+ ///
+ /// Event action that handles a RTP network packet.
+ ///
+ public UserPacketHandler UserPacketHandler = null;
/*
** Methods
@@ -157,6 +183,8 @@ namespace fnecore
info.PeerID = peerId;
info.State = ConnectionState.WAITING_LOGIN;
+ UserProtocolHandler = false;
+
PingsAcked = 0;
}
@@ -497,6 +525,13 @@ namespace fnecore
{
case Constants.NET_FUNC_PROTOCOL:
{
+ // are we handling protocol packets with the user packet handler?
+ if (UserPacketHandler != null && UserProtocolHandler)
+ {
+ UserPacketHandler(frame, peerId, streamId, rtpHeader, fneHeader, message);
+ break;
+ }
+
if (fneHeader.SubFunction == Constants.NET_PROTOCOL_SUBFUNC_DMR) // Encapsulated DMR data frame
{
if (peerId != this.peerId)
@@ -1016,6 +1051,13 @@ namespace fnecore
break;
default:
+ // are we handling anything else with a user handler?
+ if (UserPacketHandler != null)
+ {
+ UserPacketHandler(frame, peerId, streamId, rtpHeader, fneHeader, message);
+ break;
+ }
+
Log(LogLevel.ERROR, $"({systemName}) Unknown opcode {FneUtils.BytesToString(message, 0, 4)} -- {FneUtils.HexDump(message, 0)}");
break;
}