BASS.NET API for the Un4seen BASS Audio LibraryBroadCastStartEncoder Method BASS.NET API for the Un4seen BASS Audio Library
Starts the underlying encoder (see Encoder).

Namespace: Un4seen.Bass.Misc
Assembly: Bass.Net (in Bass.Net.dll) Version: 2.4.12.0
Syntax

public bool StartEncoder(
	ENCODEPROC proc,
	IntPtr user,
	bool paused
)

Parameters

proc
Type: Un4seen.Bass.AddOn.EncENCODEPROC
Optional callback function to receive the encoded data. To have the encoded data received by a callback function, the encoder needs to be told to output to STDOUT (instead of a file), so SupportsSTDOUT must return true.
user
Type: SystemIntPtr
User instance data to pass to the callback function.
paused
Type: SystemBoolean
Start the encoder paused? If , you might use Pause(Boolean) to unpause (and really start the encoder).

Return Value

Type: Boolean
Return , if the encoder was successfully started - else is returned (see LastError or LastErrorMessage for details).
Remarks

Do NOT call this method, if you are in AutomaticMode, since the encoder will be started automatically in this case.

If the encoder was already started, this method anyhow returns - however no Notification event will be raised in this case.

If you Connect manually, your ENCODEPROC must call SendData(IntPtr, Int32) manually as well, see the example below.

Examples

This example demonstrates a user defined ENCODEPROC:
VB
Private _broadCast As BroadCast
Private _myEncProc As ENCODEPROC
...
' create your encoder (using a recording handle)
Dim lame As New EncoderLAME(_recHandle)

' create an streaming server instance
Dim shoutcast As New SHOUTcast(lame)

' create the broadcast instance
_broadCast = New BroadCast(shoutcast)
_broadCast.AutoReconnect = True
AddHandler _broadCast.Notification, AddressOf OnBroadCast_Notification

' create your encoder callback
_myEncProc = New ENCODEPROC(AddressOf MyEncodingCallback)
' start the encoder (paused)
_broadCast.StartEncoder(_myEncProc, IntPtr.Zero, True)
' now connect to start your broadcast
_broadCast.Connect()
' and really start the encoder
_broadCast.Server.Encoder.Pause(False)
...

' your broadcast encoder callback implementation
Private Sub MyEncodingCallback(handle As Integer, channel As Integer, 
                               buffer As IntPtr, length As Integer, user As IntPtr)
  ' here we receive the encoded data back (manual mode)
  If _broadCast.IsConnected Then
    _broadCast.SendData(buffer, length)
  End If
End Sub

Private Sub OnBroadCast_Notification(sender As Object, e As BroadCastEventArgs)
  If e.EventType = BroadCastEventType.EncoderRestartRequired Then
    _broadCast.StartEncoder(_myEncProc, 0)
  End If 

  If Not _broadCast.IsConnected Then
    ' connection lost
  End If
End Sub
private BroadCast _broadCast;
private ENCODEPROC _myEncProc;
...
// create your encoder (using a recording handle)
EncoderLAME lame = new EncoderLAME(_recHandle);

// create an streaming server instance
SHOUTcast shoutcast = new SHOUTcast(lame);

// create the broadcast instance
_broadCast = new BroadCast(shoutcast);
_broadCast.AutoReconnect = true;
_broadCast.Notification += new BroadCastEventHandler(OnBroadCast_Notification);

// create your encoder callback
_myEncProc = new ENCODEPROC(MyEncodingCallback);
// start the encoder (paused)
_broadCast.StartEncoder(_myEncProc, IntPtr.Zero, true);
// now connect to start your broadcast
_broadCast.Connect();
// and really start the encoder
_broadCast.Server.Encoder.Pause(false);
...

// your broadcast encoder callback implementation
private void MyEncodingCallback(int handle, int channel, IntPtr buffer, int length, IntPtr user)
{
  // here we receive the encoded data back (manual mode)
  if ( _broadCast.IsConnected )
  {
    _broadCast.SendData(buffer, length);
  }
}

private void OnBroadCast_Notification(object sender, BroadCastEventArgs e)
{
  if (e.EventType == BroadCastEventType.EncoderRestartRequired)
    _broadCast.StartEncoder(_myEncProc, 0);

  if (!_broadCast.IsConnected)
  {
    // connection lost
  }
}
See Also

Reference