Class SilenceSkippingAudioProcessor

  • All Implemented Interfaces:

    public final class SilenceSkippingAudioProcessor
    extends BaseAudioProcessor
    Deprecated. is deprecated. Please migrate to androidx.media3 (which contains the same ExoPlayer code). See the migration guide for more details, including a script to help with the migration.
    An AudioProcessor that skips silence in the input stream. Input and output are 16-bit PCM.
    • 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.
        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.
        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().
      • queueInput

        public void queueInput​(ByteBuffer inputBuffer)
        Description copied from interface: AudioProcessor
        Queues audio data between the position and limit of the inputBuffer for processing. After calling this method, processed output may be available via AudioProcessor.getOutput(). Calling queueInput(ByteBuffer) again invalidates any pending output.
        inputBuffer - The input buffer to process. It 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.
      • onFlush

        protected void onFlush()
        Description copied from class: BaseAudioProcessor
        Called when the processor is flushed, directly or as part of resetting.
        onFlush in class BaseAudioProcessor