DiscordVoiceEngineSpec
public protocol DiscordVoiceEngineSpec : DiscordWebSocketable, DiscordGatewayable
Declares that a type will be a voice engine.
-
The encoder for this engine. The encoder is responsible for turning raw audio data into OPUS encoded data.
Declaration
Swift
var source: DiscordVoiceDataSource?
-
The secret key used for encryption.
Declaration
Swift
var secret: [UInt8]!
-
Stops encoding and requests a new encoder. A
voiceEngine.ready
event will be fired when the encoder is ready.Declaration
Swift
func requestNewDataSource()
-
Takes a process that outputs random audio data, and sends it to a hidden FFmpeg process that turns the data into raw PCM.
Example setting up youtube-dl to play music.
youtube = EncoderProcess() youtube.launchPath = "usrlocalbinyoutube-dl" youtube.arguments = ["-f", "bestaudio", "-q", "-o", "-", link] voiceEngine.setupMiddleware(youtube) { print("youtube died") }
Declaration
Swift
func setupMiddleware(_ middleware: Process, terminationHandler: (() -> ())?)
Parameters
middleware
The process that will output audio data.
terminationHandler
Called when the middleware is done. Does not mean that all encoding is done.