Page 1 of 1

[Help] with Overbyte with RVMedia and streaming microphone data to all connected clients.

Posted: Sun Jan 13, 2019 1:56 am
by WpgnGaming
OK am trying to work out away to use overbyte to stream the audio data from RVMicrophone and then replace it back using RVAudioPlayer on the other clients.

but am finding it a little tricky and there no demo on how to stream via internet but I done some thing like this as a example of my idea

Send data to server

Code: Select all

procedure TForm1.RVMicrophone1GetAudio(Sender: TObject; AStream: TMemoryStream;
  var ADataSize: Integer; const AAudioIndex: Word; var AStartTime,
  ADuration: Cardinal; var ASamplesPerSec: TRVSamplesPerSec;
  var ABitsPerSample: TRVBitsPerSample; var AChannels: Integer);
begin
  AStream.Position := 0;
  WSocket1.Send(AStream, AStream.Size); // send to overbyte socket server
end;
Server gets data and then send it back to client

Code: Select all

procedure TForm1.WSocketServer1DataAvailable(Sender: TObject; ErrCode: Word);
var
   AStream: TMemoryStream;
begin
    AStream := TMemoryStream.Create();
    WSocketServer1.Receive(AStream, AStream.Size);
    AStream.Position := 0;
    WSocketServer1.Client[0].Send(AStream, AStream.Size); // sent to overbyte client scoket
end;
Client plays back the audio

Code: Select all

procedure TForm1.WSocket1DataAvailable(Sender: TObject; ErrCode: Word);
var
    AStream: TMemoryStream;
begin
    AStream := TMemoryStream.Create();
    WSocket1.Receive(AStream, AStream.Size);
    AStream.Position := 0;
    RVAudioPlayer1.PlayAudio(AStream,AStream.Size); // add to player so clients can hear incoming audio
end;
now all that code is just a mock up and more then likely will not work but it gives you a general understanding what am after. and sorry for any bad spelling :D

Re: [Help] with Overbyte with RVMedia and streaming microphone data to all connected clients.

Posted: Mon Jan 14, 2019 9:50 am
by Sergey Tkachenko
TRVAudioPlayer really has PlayAudio method, but it has more parameters:

Code: Select all

procedure PlayAudio(AStream : TMemoryStream;
      var ADataSize : Integer; AGUID : TGUID; const AAudioIndex : Word;
      var AStartTime, ADuration : Longword;
      var ASamplesPerSec : TRVSamplesPerSec;
      var ABitsPerSample : TRVBitsPerSample;
      var AChannels : Integer); override;
Values of almost all parameters must be taken from TRVMicrophone.OnGetAudio event. It's not enough to send an audio stream from AStream, you need to send other parameters as well, receive them, and pass to TRVAudioPlayer.PlayAudio.
The only additional parameter is AGUID, fill it yourself, it must identify the audio source (the same value of GUID must be for all audio data from the same source, different sources must have different AGUID)

Re: [Help] with Overbyte with RVMedia and streaming microphone data to all connected clients.

Posted: Mon Jan 14, 2019 2:58 pm
by WpgnGaming
thanks, yea I slowly working this out but on a other note because your

Code: Select all

procedure PlayAudio(AStream : TMemoryStream;
      var ADataSize : Integer; AGUID : TGUID; const AAudioIndex : Word;
      var AStartTime, ADuration : Longword;
      var ASamplesPerSec : TRVSamplesPerSec;
      var ABitsPerSample : TRVBitsPerSample;
      var AChannels : Integer); override;
uses var in the procedure itself, am unable to access it outside of the vcl it self, as it calls following error
[DCC Error] Test_unit.pas(139): E2033 Types of actual and formal var parameters must be identical

Re: [Help] with Overbyte with RVMedia and streaming microphone data to all connected clients.

Posted: Mon Jan 14, 2019 6:48 pm
by Sergey Tkachenko
This error occurs because you use wrong types for some parameters. The types of var-parameters must be exactly the same as declared.