Class AudioSource

Direct Known Subclasses:
CustomAudioSource

public class AudioSource extends AudioDevice
Use AudioSource as a generic source to send app-generated audio to the SDK in LPCM format. See also Session.createAudioInputSource(int, BroadcastConfiguration.AudioSampleRate, Format)
  • Field Details

  • Method Details

    • setGain

      public void setGain(Float gain)
      Description copied from class: AudioDevice
      Set the input gain
      Specified by:
      setGain in class AudioDevice
      Parameters:
      gain - Generally between 0 and 1, but values up to 2 are accepted. Any value over 1 amplifies the signal and may cause clipping.
    • appendBuffer

      public int appendBuffer(ByteBuffer buffer, long count, long presentationTimeUs)
      Description copied from class: AudioDevice
      Append an audio buffer. This can only be used with Device.Descriptor.DeviceType.USER_AUDIO
      Specified by:
      appendBuffer in class AudioDevice
      Parameters:
      buffer - The buffer of audio data to append. This must be allocated as a Direct ByteBuffer
      count - The number of bytes to use
      presentationTimeUs - The presentation time, in microseconds
      Returns:
      The number of samples processed
    • getDescriptor

      public Device.Descriptor getDescriptor()
      From Device
      Specified by:
      getDescriptor in class Device
    • isValid

      public boolean isValid()
      Specified by:
      isValid in class Device
    • getTag

      public String getTag()
      Specified by:
      getTag in class Device
    • setStatsCallback

      public void setStatsCallback(AudioDevice.StatsCallback callback)
      Description copied from class: AudioDevice
      Set a callback to receive audio stats for this device. This will be called on the main thread.
      Specified by:
      setStatsCallback in class AudioDevice
      Parameters:
      callback - A callback lambda that takes two floats: peak and rms.
    • getHandle

      public long getHandle()
    • setGain

      protected void setGain(long handle, float gain)
    • setConfiguration

      protected void setConfiguration(long handle, int channels, int sampleRate, int format)
    • appendBuffer

      protected int appendBuffer(long handle, ByteBuffer buffer, long count, long presentationTimeUs)