i use Tidtudpserver to send audio to clients i have something i do not understand from long time ago
when one client Send Audiodata to udpserver and udpserver send it back to clients every thing works fine and audio arrived good and clear
if 2 or 3 clients send audio at the same time the audio arrived un understandable and have too many cutting i wanted to make it a live conversation with duplex audio but i dont understand where is the problem is is it from idudpserver or from receiver side ?
here is the receiver side code
and here is the server side i have set multithreaded event to True
sorry for my bad grammar i am trying to describe what i am trying to do as best as i can
when one client Send Audiodata to udpserver and udpserver send it back to clients every thing works fine and audio arrived good and clear
if 2 or 3 clients send audio at the same time the audio arrived un understandable and have too many cutting i wanted to make it a live conversation with duplex audio but i dont understand where is the problem is is it from idudpserver or from receiver side ?
here is the receiver side code
Code:
procedure TForm2.udpreciverUDPRead(AThread: TIdUDPListenerThread;
const AData: TIdBytes; ABinding: TIdSocketHandle);
var
AudioDataSize: Integer;
AudioData : Pointer;
begin
TThread.Synchronize(nil,
procedure
begin
AudioDataSize := Length(AData);
if (AudioDataSize > 10) then
begin
try
if not Player.Active then
begin
Player.Active := True;
Player.WaitForStart;
end;
except
end;
if BlockAlign > 1 then
begin
Dec(AudioDataSize, AudioDataSize mod BlockAlign);
end;
AudioData := AudioBuffer.BeginUpdate(AudioDataSize);
try
BytesToRaw(AData, AudioData^, AudioDataSize);
finally
AudioBuffer.EndUpdate;
end;
end else
begin
Player.Active := False;
Player.WaitForStop;
end;
end);
end;
and here is the server side i have set multithreaded event to True
Code:
procedure TForm1.broadcatsaudio(ABinding: TIdSocketHandle; ipada : string; porta, serverprta : integer; const AData: TIdBytes);
var
AUDIOLIST : TAUDIOLIST;
c : integer;
List : Tlist;
begin
list := AllAUDIO.LockList;
try
for c := 0 to list.Count - 1 do
begin
AUDIOLIST := list.Items[c];
if (AUDIOLIST.userserverPort = serverprta)
And (AUDIOLIST.userport <> porta) then
begin
Abinding.SendTo(AUDIOLIST.userip, AUDIOLIST.userport, Adata);
end;
end;
finally
AllAUDIO.UnlockList;
end;
end;
sorry for my bad grammar i am trying to describe what i am trying to do as best as i can