DiscordVoiceFileDataSource
open class DiscordVoiceFileDataSource : DiscordBufferedVoiceDataSource
A subclass of DiscordBufferedVoiceDataSource that buffers a raw audio file.
Usage:
func client(_ client: DiscordClient, needsDataSourceForEngine engine: DiscordVoiceEngine) throws -> DiscordVoiceDataSource {
return try DiscordVoiceFileDataSource(opusEncoder: try DiscordOpusEncoder(bitrate: 128_000),
file: URL(string: "file://output.raw")!)
}
-
A FileHandle for reading the wrapped file.
Declaration
Swift
public let wrappedFile: FileHandle
-
Sets up a buffered source around a voice file.
Declaration
Swift
public init(opusEncoder: DiscordOpusEncoder, file: URL, bufferSize: Int = 15_000, drainThreshold: Int = 13_500) throwsParameters
opusEncoderThe Opus encoder to use.
fileA file to buffer around.
bufferSizeThe max number of voice packets to buffer.
drainThresholdThe number of packets that must be in the buffer before we start reading more into the buffer.
-
Called when it is time to setup a
DispatchIOfor reading.Override to attach a custom file descriptor. By default it uses
wrappedFile.Declaration
Swift
open override func createDispatchIO()
DiscordVoiceFileDataSource Class Reference