Class BufferStreamer

java.lang.Object
com.vivoka.vsdk.audio.ProducerModule
com.vivoka.vsdk.audio.producers.BufferStreamer

public class BufferStreamer extends ProducerModule
BufferStreamer is a producer module that allows the user to dispatch audio buffers to a pipeline consumers. It operates in a threaded mode, processing buffers asynchronously. The module can handle acceleration rates, allowing for faster processing of audio data. It is designed to work with a specified buffer size. The BufferStreamer can be used only in an asynchronous pipeline (pipeline.start()) and it supports pausing and resuming operations.
  • Constructor Details

    • BufferStreamer

      public BufferStreamer()
      Constructs a BufferStreamer with the default acceleration rate of 1.0. This means that the audio processing will not be accelerated.
    • BufferStreamer

      public BufferStreamer(double accelerationRate) throws Exception
      Constructs a BufferStreamer with the specified acceleration rate. The acceleration rate must be greater than or equal to 1.0.
      Parameters:
      accelerationRate - The rate at which the audio processing is accelerated.
      Throws:
      Exception - If the acceleration rate is less than 1.0.
  • Method Details

    • setAccelerationRate

      public void setAccelerationRate(double rate) throws Exception
      Sets the acceleration rate for the BufferStreamer. The acceleration rate must be greater than or equal to 1.0.
      Parameters:
      rate - The acceleration rate to set.
      Throws:
      Exception - If the acceleration rate is less than 1.0.
    • getAccelerationRate

      public double getAccelerationRate()
      Gets the current acceleration rate of the BufferStreamer. This rate determines how fast the audio processing is accelerated.
      Returns:
      The current acceleration rate.
    • stream

      public void stream(Buffer buffer, boolean last, int bufferSize) throws Exception
      Streams the audio buffer to the pipeline consumers.
      Parameters:
      buffer - The audio buffer to be streamed.
      last - Indicates whether this is the last buffer to be streamed.
      bufferSize - The size of the buffer to be processed.
      Throws:
      Exception - Occurs if the buffer is null, or if the channel count or sample rate of the buffer does not match the values of the first buffer received after start.
    • startImpl

      public void startImpl() throws Exception
      Description copied from class: ProducerModule
      Starts the producer module in a non-blocking manner. The producer state must be OPENED. When calling start pipeline, this method will be called after the open method. startImpl() should initiate the producer and return immediately without waiting for processing to complete and update the state to STARTED when it is done.
      Overrides:
      startImpl in class ProducerModule
      Throws:
      Exception - If an error occurs during starting.
    • stopImpl

      public void stopImpl() throws Exception
      Description copied from class: ProducerModule
      Stops the producer module. The producer state must be STARTED. When calling stop pipeline, this method will be called. It should initiate the stopping process and return immediately without waiting for it to complete. It should make sure that the state is updated to OPENED when it is done.
      Overrides:
      stopImpl in class ProducerModule
      Throws:
      Exception - If an error occurs during stopping.
    • pauseImpl

      public void pauseImpl() throws Exception
      Description copied from class: ProducerModule
      Pauses the producer module. The producer state must be STARTED. When calling pause pipeline, this method will be called. It should initiate the pausing process and return immediately without waiting for it to complete. It should make sure that the state is updated to PAUSED when it is done.
      Overrides:
      pauseImpl in class ProducerModule
      Throws:
      Exception - If an error occurs during pausing.
    • resumeImpl

      public void resumeImpl() throws Exception
      Description copied from class: ProducerModule
      Resumes the producer module. The producer state must be PAUSED. When the producer is resumed, the child class needs to update the state to STARTED. When calling resume pipeline, this method will be called. It should initiate the resuming process and return immediately without waiting for it to complete. It should make sure that the state is updated to OPENED when it is done.
      Overrides:
      resumeImpl in class ProducerModule
      Throws:
      Exception - If an error occurs during resuming.