Author Topic: How to connect to shoutcast  (Read 286 times)

luquep

  • Posts: 3
How to connect to shoutcast
« on: 30 Oct '22 - 15:42 »
I need to connect to a shoutcast server and stream live audio with Delphi FMX compiled for Android.

I'm able  to connect to the server with the function BASS_Encode_CastInit, but have not idea how to start the broadcast process. In general my code is.

Code: [Select]
  if Not BASS_RecordInit(0) then
   ShowMessage('Error on Init bass')
 
 vChan:=BASS_RecordStart(44100, 2, BASS_RECORD_PAUSE, @RecordingCallback, 0);

  if vChan = 0 then
  begin
    ShowMessage('Couldn''t start recording!');
    exit;
  end;

  if not BASS_Encode_CastInit(Encoder,'https://myserver',
                                      mypassword,
                                      BASS_ENCODE_TYPE_OGG,
                                      PAnsiChar(AnsiString('')),
                                      PAnsiChar(AnsiString('')),
                                      PAnsiChar(AnsiString('')),
                                      PAnsiChar(AnsiString('')),
                                      '',
                                      128,
                                      false) then
  begin
    ShowMessage('Couldn''t setup connection with server');
    BASS_ChannelStop(vChan);
    rchan := 0;
    exit;
  end;

;

but now I don't know how to continue to start the data transmission process to the server.
Could someone tell me in Delphi or another language or pseudocode how to continue? keep in mind that i need it for android, lame.exe is not available

Ian @ un4seen

  • Administrator
  • Posts: 25446
Re: How to connect to shoutcast
« Reply #1 on: 31 Oct '22 - 12:40 »
For MP3 encoding, you will need the BASSenc_MP3 add-on and a BASS_Encode_MP3_Start call placed between the BASS_RecordStart and BASS_Encode_CastInit calls. And then a BASS_ChannelStart/Play call to resume the recording. So something like this:

Code: [Select]
record = BASS_RecordStart(44100, 2, BASS_RECORD_PAUSE, RecordProc, NULL); // start recording (paused)
encoder = BASS_Encode_MP3_Start(record, "-b 128", 0, NULL, NULL); // set MP3 encoder on it
BASS_Encode_CastInit(encoder, ...); // connect encoder to Shoutcast server
BASS_ChannelStart(record); // resume recording

Please see the documentation for details on the mentioned functions.

luquep

  • Posts: 3
Re: How to connect to shoutcast
« Reply #2 on: 2 Nov '22 - 21:56 »
Thank you for you help, I will test.. :)