Package moe.kyokobot.koe.media
Interface AudioFrameProvider
public interface AudioFrameProvider
Base interface for audio frame providers.
For audio-only usage with the default Opus codec, implementations may omit codec checks. This is provided for completeness and for future or experimental codec support.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanvoiddispose()Called when thisAudioFrameProvidershould clean up it's event handlers and etc.voidonCodecChanged(CodecInstance codec) Notifies this provider of the current codec for the connection.booleanprovideFrame(io.netty.buffer.ByteBuf buf) Retrieves a media frame and writes it to the providedByteBuf.
-
Method Details
-
onCodecChanged
Notifies this provider of the current codec for the connection.Guarantees:
- This method is called before the first
canProvide()invocation for a provider instance attached to a connection (e.g. when set viasetAudioSender). - It is called again whenever the codec is changed via
setAudioCodecwhile this provider is attached.
falsefromcanProvide()until the codec changes to a supported one.- Parameters:
codec- the current codec instance for this connection
- This method is called before the first
-
dispose
void dispose()Called when thisAudioFrameProvidershould clean up it's event handlers and etc. -
canProvide
boolean canProvide()- Returns:
- If true, this provider has media data available and can provide frames. This is used by the
frame poller to determine if it should attempt to retrieve frames from this provider.
Must return false if the provider cannot supply data for the current codec (see
onCodecChanged(moe.kyokobot.koe.codec.CodecInstance)).
-
provideFrame
boolean provideFrame(io.netty.buffer.ByteBuf buf) Retrieves a media frame and writes it to the providedByteBuf. The buffer is guaranteed to be empty and have enough capacity for the frame. The provider should write the frame data to the buffer and return true if a frame was provided, or return false if no frame is available (e.g. end of stream).- Parameters:
buf- The buffer to write the frame data to.- Returns:
- true if a frame was provided and written to the buffer, false if no frame is available.
-