Skip to content

Commit

Permalink
Attempt to reduce packet loss
Browse files Browse the repository at this point in the history
  • Loading branch information
Craig Moksnes committed Mar 14, 2020
1 parent b2db777 commit 485adeb
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion SocketUtils.pas
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ TRTPVideoSink = class(TInterfacedObject, IRTPVideoSink)
private
fStats: IVideoStats;
fServer: TIdUDPServer;
fLargestPacket: Int64;
fClosed: Boolean;
fWriteEvent: TEvent;

Expand Down Expand Up @@ -410,7 +411,7 @@ constructor TRTPVideoSink.Create(const aPacketSize, aPacketCount: Integer; const
fServer.DefaultPort := 0;
fServer.ThreadedEvent := True;
fServer.OnUDPRead := UDPRead;
fServer.Binding.SetSockOpt(Id_SOL_SOCKET, Id_SO_RCVBUF, 1024*1024);
fServer.Binding.SetSockOpt(Id_SOL_SOCKET, Id_SO_RCVBUF, 2*1024*1024);

SetLength(fPackets, aPacketCount);
for i := 0 to High(fPackets) do
Expand Down Expand Up @@ -504,6 +505,15 @@ procedure TRTPVideoSink.UDPRead(AThread: TIdUDPListenerThread;
if Length(AData) < 12 then
Exit;

if AThread.Priority <> tpHigher then
AThread.Priority := tpHigher;

if Length(AData) > fLargestPacket then
begin
fLargestPacket := Length(AData);
TLogger.LogFmt(cLogDefault, 'Largest packet: %d', [fLargestPacket]);
end;

lHeader := @AData[0];

Lock;
Expand Down

0 comments on commit 485adeb

Please sign in to comment.