Package com.google.android.exoplayer2.audio

## Class SilenceSkippingAudioProcessor

- java.lang.Object
- - com.google.android.exoplayer2.audio.BaseAudioProcessor
  - - com.google.android.exoplayer2.audio.SilenceSkippingAudioProcessor

- All Implemented Interfaces:
    `AudioProcessor`

      public final class SilenceSkippingAudioProcessor
      extends BaseAudioProcessor

  An `AudioProcessor` that skips silence in the input stream. Input and output are 16-bit PCM.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface com.google.android.exoplayer2.audio.AudioProcessor

      `AudioProcessor.AudioFormat, AudioProcessor.UnhandledAudioFormatException`

  - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `static long` | `DEFAULT_MINIMUM_SILENCE_DURATION_US` | The default value for `minimumSilenceDurationUs`.
    `static long` | `DEFAULT_PADDING_SILENCE_US` | The default value for `paddingSilenceUs`.
    `static short` | `DEFAULT_SILENCE_THRESHOLD_LEVEL` | The default value for `silenceThresholdLevel`.

    - ### Fields inherited from class com.google.android.exoplayer2.audio.BaseAudioProcessor

      `inputAudioFormat, outputAudioFormat`

    - ### Fields inherited from interface com.google.android.exoplayer2.audio.AudioProcessor

      `EMPTY_BUFFER`

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `SilenceSkippingAudioProcessor()` | Creates a new silence skipping audio processor.
    `SilenceSkippingAudioProcessor​(long minimumSilenceDurationUs, long paddingSilenceUs, short silenceThresholdLevel)` | Creates a new silence skipping audio processor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `long` | `getSkippedFrames()` | Returns the total number of frames of input audio that were skipped due to being classified as silence since the last call to `BaseAudioProcessor.flush()`.
    `boolean` | `isActive()` | Returns whether the processor is configured and will process input buffers.
    `AudioProcessor.AudioFormat` | `onConfigure​(AudioProcessor.AudioFormat inputAudioFormat)` | Called when the processor is configured for a new input format.
    `protected void` | `onFlush()` | Called when the processor is flushed, directly or as part of resetting.
    `protected void` | `onQueueEndOfStream()` | Called when the end-of-stream is queued to the processor.
    `protected void` | `onReset()` | Called when the processor is reset.
    `void` | `queueInput​(ByteBuffer inputBuffer)` | Queues audio data between the position and limit of the input `buffer` for processing.
    `void` | `setEnabled​(boolean enabled)` | Sets whether to skip silence in the input.

    - ### Methods inherited from class com.google.android.exoplayer2.audio.BaseAudioProcessor

      `configure, flush, getOutput, hasPendingOutput, isEnded, queueEndOfStream, replaceOutputBuffer, reset`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### DEFAULT_MINIMUM_SILENCE_DURATION_US

          public static final long DEFAULT_MINIMUM_SILENCE_DURATION_US

      The default value for `minimumSilenceDurationUs`.
      See Also:
        Constant Field Values

    - #### DEFAULT_PADDING_SILENCE_US

          public static final long DEFAULT_PADDING_SILENCE_US

      The default value for `paddingSilenceUs`.
      See Also:
        Constant Field Values

    - #### DEFAULT_SILENCE_THRESHOLD_LEVEL

          public static final short DEFAULT_SILENCE_THRESHOLD_LEVEL

      The default value for `silenceThresholdLevel`.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### SilenceSkippingAudioProcessor

          public SilenceSkippingAudioProcessor()

      Creates a new silence skipping audio processor.

    - #### SilenceSkippingAudioProcessor

          public SilenceSkippingAudioProcessor​(long minimumSilenceDurationUs,
                                               long paddingSilenceUs,
                                               short silenceThresholdLevel)

      Creates a new silence skipping audio processor.
      Parameters:
        `minimumSilenceDurationUs` - The minimum duration of audio that must be below `silenceThresholdLevel` to classify that part of audio as silent, in microseconds.
        `paddingSilenceUs` - The duration of silence by which to extend non-silent sections, in microseconds. The value must not exceed `minimumSilenceDurationUs`.
        `silenceThresholdLevel` - The absolute level below which an individual PCM sample is classified as silent.

  - ### Method Detail

    - #### setEnabled

          public void setEnabled​(boolean enabled)

      Sets whether to skip silence in the input. This method may only be called after draining data through the processor. The value returned by `isActive()` may change, and the processor must be `flushed` before queueing more data.
      Parameters:
        `enabled` - Whether to skip silence in the input.

    - #### getSkippedFrames

          public long getSkippedFrames()

      Returns the total number of frames of input audio that were skipped due to being classified as silence since the last call to `BaseAudioProcessor.flush()`.

    - #### onConfigure

          public AudioProcessor.AudioFormat onConfigure​(AudioProcessor.AudioFormat inputAudioFormat)
                                                 throws AudioProcessor.UnhandledAudioFormatException

      Description copied from class: `BaseAudioProcessor`
      Called when the processor is configured for a new input format.
      Overrides:
        `onConfigure` in class `BaseAudioProcessor`
      Throws:
        `AudioProcessor.UnhandledAudioFormatException`

    - #### isActive

          public boolean isActive()

      Description copied from interface: `AudioProcessor`
      Returns whether the processor is configured and will process input buffers.
      Specified by:
        `isActive` in interface `AudioProcessor`
      Overrides:
        `isActive` in class `BaseAudioProcessor`

    - #### queueInput

          public void queueInput​(ByteBuffer inputBuffer)

      Description copied from interface: `AudioProcessor`
      Queues audio data between the position and limit of the input `buffer` for processing. `buffer` must be a direct byte buffer with native byte order. Its contents are treated as read-only. Its position will be advanced by the number of bytes consumed (which may be zero). The caller retains ownership of the provided buffer. Calling this method invalidates any previous buffer returned by `AudioProcessor.getOutput()`.
      Parameters:
        `inputBuffer` - The input buffer to process.

    - #### onQueueEndOfStream

          protected void onQueueEndOfStream()

      Description copied from class: `BaseAudioProcessor`
      Called when the end-of-stream is queued to the processor.
      Overrides:
        `onQueueEndOfStream` in class `BaseAudioProcessor`

    - #### onFlush

          protected void onFlush()

      Description copied from class: `BaseAudioProcessor`
      Called when the processor is flushed, directly or as part of resetting.
      Overrides:
        `onFlush` in class `BaseAudioProcessor`

    - #### onReset

          protected void onReset()

      Description copied from class: `BaseAudioProcessor`
      Called when the processor is reset.
      Overrides:
        `onReset` in class `BaseAudioProcessor`