OggFileAudioBufferSink
@UnstableApi
class OggFileAudioBufferSink : ForwardingAudioSink
| kotlin.Any | ||
| ↳ | androidx.media3.exoplayer.audio.ForwardingAudioSink | |
| ↳ | androidx.media3.test.utils.OggFileAudioBufferSink |
A sink for audio buffers that writes output audio as .ogg files with a given path prefix. When new audio data is handled after flushing the audio packetizer, a counter is incremented and its value is appended to the output file name.
Note: if writing to external storage it's necessary to grant the
WRITE_EXTERNAL_STORAGE permission.
Summary
Constants |
|
|---|---|
const Int |
SAMPLE_RATE = 48000Opus streams are always 48000 Hz. |
Public constructors |
|---|
OggFileAudioBufferSink(Creates an instance. |
Public functions |
|
|---|---|
Unit |
flush()Flushes the sink, after which it is ready to receive buffers from a new playback position. |
Boolean |
handleBuffer(Attempts to process data from a |
Unit |
reset()Resets the sink, releasing any resources that it currently holds. |
Inherited Constants |
||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Inherited functions |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Constants
Public constructors
OggFileAudioBufferSink
OggFileAudioBufferSink(
audioSink: AudioSink!,
outputFileNamePrefix: String!
)
Creates an instance.
Public functions
flush
fun flush(): Unit
Flushes the sink, after which it is ready to receive buffers from a new playback position.
The audio session may remain active until reset is called.
handleBuffer
fun handleBuffer(
buffer: ByteBuffer!,
presentationTimeUs: Long,
encodedAccessUnitCount: Int
): Boolean
Attempts to process data from a ByteBuffer, starting from its current position and ending at its limit (exclusive). The position of the ByteBuffer is advanced by the number of bytes that were handled. onPositionDiscontinuity will be called if presentationTimeUs is discontinuous with the last buffer handled since the last reset.
Returns whether the data was handled in full. If the data was not handled in full then the same ByteBuffer must be provided to subsequent calls until it has been fully consumed, except in the case of an intervening call to flush (or to configure that causes the sink to be flushed).
| Parameters | |
|---|---|
buffer: ByteBuffer! |
The buffer containing audio data. |
presentationTimeUs: Long |
The presentation timestamp of the buffer in microseconds. |
encodedAccessUnitCount: Int |
The number of encoded access units in the buffer, or 1 if the buffer contains PCM audio. This allows batching multiple encoded access units in one buffer. |
| Returns | |
|---|---|
Boolean |
Whether the buffer was handled fully. |
| Throws | |
|---|---|
androidx.media3.exoplayer.audio.AudioSink.InitializationException |
If an error occurs initializing the sink. |
androidx.media3.exoplayer.audio.AudioSink.WriteException |
If an error occurs writing the audio data. |