Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
can i add text to rawtobytedata ?
#2
(09-19-2019, 09:13 AM)Madammar Wrote: i want to add a text identification to each audio sent and then remove that text when its received 

like following as example 

Code:
if (Buffer <> nil) and (BufferSize > 0) And (udpreciver.Active) then
begin
udpsender.SendBuffer(ip, port, RawToBytes('Audio1'+Buffer^, Buffersize));
end;

how to do this in correct way

There are many different ways you can handle this.

Code:
// Delphi XE7 or later only ...
var Bytes: TIdBytes;
Bytes := ToBytes('Audio1') + RawToBytes(Buffer^, Buffersize);
// or: Bytes := Concat(ToBytes('Audio1'), RawToBytes(Buffer^, Buffersize));
udpsender.SendBuffer(ip, port, Bytes);

Code:
var Bytes: TidBytes;
Bytes := ToBytes('Audio1');
AppendBytes(Bytes, RawToBytes(Buffer^, Buffersize));
udpsender.SendBuffer(ip, port, Bytes);

Code:
var Bytes: TidBytes;
SetLength(Bytes, 6 + Buffersize);
CopyTIdString('Audio1', Bytes, 0);
CopyTIdBytes(RawToBytes(Buffer^, Buffersize), 0, Bytes, 6, Buffersize);
udpsender.SendBuffer(ip, port, Bytes);

Code:
var Bytes: TIdBytes;
SetLength(Bytes, 6 + Buffersize);
Move(PAnsiChar('Audio1')^, Bytes[0], 6);
Move(Buffer^, Bytes[6], Buffersize);
udpsender.SendBuffer(ip, port, Bytes);

Reply


Messages In This Thread
can i add text to rawtobytedata ? - by Madammar - 09-19-2019, 09:13 AM
RE: can i add text to rawtobytedata ? - by rlebeau - 09-19-2019, 08:30 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)