Class AudioProcessingPipeline
- java.lang.Object
-
- com.google.android.exoplayer2.audio.AudioProcessingPipeline
-
@Deprecated public final class AudioProcessingPipeline extends Object
Deprecated.com.google.android.exoplayer2 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.Handles passing buffers through multipleAudioProcessor
instances.Two instances of
AudioProcessingPipeline
are considered equal if they have the same underlyingAudioProcessor
references, in the same order.To make use of this class, the caller must:
- Initialize an instance, passing in all audio processors that may be used for processing.
- Call
configure(AudioFormat)
with theAudioProcessor.AudioFormat
of the input data. This method will give back theAudioProcessor.AudioFormat
that will be output from the pipeline when this configuration is in use. - Call
flush()
to apply the pending configuration. - Check if the pipeline
isOperational()
. If not, then the pipeline can not be used to process buffers in the current configuration. This is because none of the underlyingAudioProcessor
instances are active. - If the pipeline
isOperational()
,queueInput(ByteBuffer)
thengetOutput()
to process buffers. queueEndOfStream()
to inform the pipeline the current input stream is at an end.- Repeatedly call
getOutput()
and handle those buffers untilisEnded()
returns true. - When finished with the pipeline, call
reset()
to release underlying resources.
If underlying
AudioProcessor
instances have pending configuration changes, or theAudioProcessor.AudioFormat
of the input is changing:- Call
configure(AudioFormat)
to configure the pipeline for the new input stream. You can stillqueueInput(ByteBuffer)
andgetOutput()
in the old setup at this time. queueEndOfStream()
to inform the pipeline the current input stream is at an end.- Repeatedly call
getOutput()
untilisEnded()
returns true. - Call
flush()
to apply the new configuration and flush the pipeline. - Begin queuing input and handling the output in the new configuration.
-
-
Constructor Summary
Constructors Constructor Description AudioProcessingPipeline(ImmutableList<AudioProcessor> audioProcessors)
Deprecated.Creates an instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description AudioProcessor.AudioFormat
configure(AudioProcessor.AudioFormat inputAudioFormat)
Deprecated.Configures the pipeline to process input audio with the specified format.boolean
equals(Object o)
Deprecated.Indicates whether some other object is "equal to" this one.void
flush()
Deprecated.Clears any buffered data and pending output.ByteBuffer
getOutput()
Deprecated.Returns aByteBuffer
containing processed output data between its position and limit.AudioProcessor.AudioFormat
getOutputAudioFormat()
Deprecated.Returns theAudioProcessor.AudioFormat
currently being output.int
hashCode()
Deprecated.boolean
isEnded()
Deprecated.Returns whether the pipeline has ended.boolean
isOperational()
Deprecated.Whether the pipeline can be used for processing buffers.void
queueEndOfStream()
Deprecated.Queues an end of stream signal.void
queueInput(ByteBuffer inputBuffer)
Deprecated.Queues audio data between the position and limit of theinputBuffer
for processing.void
reset()
Deprecated.Resets the pipeline and its underlyingAudioProcessor
instances to their unconfigured state, releasing any resources.
-
-
-
Constructor Detail
-
AudioProcessingPipeline
public AudioProcessingPipeline(ImmutableList<AudioProcessor> audioProcessors)
Deprecated.Creates an instance.- Parameters:
audioProcessors
- TheAudioProcessor
instances to be used for processing buffers.
-
-
Method Detail
-
configure
@CanIgnoreReturnValue public AudioProcessor.AudioFormat configure(AudioProcessor.AudioFormat inputAudioFormat) throws AudioProcessor.UnhandledAudioFormatException
Deprecated.Configures the pipeline to process input audio with the specified format. Returns the configured output audio format.To apply the new configuration for use, the pipeline must be flushed. Before applying the new configuration, it is safe to queue input and get output in the old input/output formats/configuration. Call
queueEndOfStream()
when no more input will be supplied for processing in the old configuration.- Parameters:
inputAudioFormat
- The format of audio that will be queued after the next call toflush()
.- Returns:
- The configured output audio format.
- Throws:
AudioProcessor.UnhandledAudioFormatException
- If the specified format is not supported by the pipeline.
-
flush
public void flush()
Deprecated.Clears any buffered data and pending output. If any underlying audio processors are active, this also prepares them to receive a new stream of input in the last configured (pending) format.configure(AudioFormat)
must have been called at least once since the last call toreset()
before calling this.
-
getOutputAudioFormat
public AudioProcessor.AudioFormat getOutputAudioFormat()
Deprecated.Returns theAudioProcessor.AudioFormat
currently being output.
-
isOperational
public boolean isOperational()
Deprecated.Whether the pipeline can be used for processing buffers.For this to happen the pipeline must be configured, flushed and have active underlying audio processors that are ready to process buffers with the current configuration.
-
queueInput
public void queueInput(ByteBuffer inputBuffer)
Deprecated.Queues audio data between the position and limit of theinputBuffer
for processing. After calling this method, processed output may be available viagetOutput()
.- Parameters:
inputBuffer
- The input buffer to process. It must be a directByteBuffer
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.
-
getOutput
public ByteBuffer getOutput()
Deprecated.Returns aByteBuffer
containing processed output data between its position and limit. The buffer will be empty if no output is available.Buffers returned from this method are retained by pipeline, and it is necessary to consume the data (or copy it into another buffer) to allow the pipeline to progress.
- Returns:
- A buffer containing processed output data between its position and limit.
-
queueEndOfStream
public void queueEndOfStream()
Deprecated.Queues an end of stream signal. After this method has been called,queueInput(ByteBuffer)
should not be called until after the next call toflush()
. CallinggetOutput()
will return any remaining output data. Multiple calls may be required to read all of the remaining output data.isEnded()
will returntrue
once all remaining output data has been read.
-
isEnded
public boolean isEnded()
Deprecated.Returns whether the pipeline has ended.The pipeline is considered ended when:
- End of stream has been queued.
- Every input buffer has been processed.
- Every output buffer has been fully consumed.
-
reset
public void reset()
Deprecated.Resets the pipeline and its underlyingAudioProcessor
instances to their unconfigured state, releasing any resources.
-
equals
public boolean equals(@Nullable Object o)
Deprecated.Indicates whether some other object is "equal to" this one.Two instances of
AudioProcessingPipeline
are considered equal if they have the same underlyingAudioProcessor
references in the same order.
-
-