-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
allow for different implementations of streams, nop by default
- Loading branch information
1 parent
093caba
commit 025e481
Showing
6 changed files
with
102 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package dev.kord.voice.streams | ||
|
||
import dev.kord.common.annotation.KordVoice | ||
import dev.kord.common.entity.Snowflake | ||
import dev.kord.voice.AudioFrame | ||
import dev.kord.voice.udp.AudioPacket | ||
import kotlinx.coroutines.flow.Flow | ||
|
||
@KordVoice | ||
object NOPStreams : Streams() { | ||
override var key: ByteArray? = null | ||
|
||
override val incomingAudioPackets: Flow<AudioPacket.DecryptedPacket> | ||
get() = nopStreamsException() | ||
override val incomingAudioFrames: Flow<Pair<UInt, AudioFrame>> | ||
get() = nopStreamsException() | ||
override val incomingUserStreams: Flow<Pair<Snowflake, AudioFrame>> | ||
get() = nopStreamsException() | ||
override val ssrcToUser: Map<UInt, Snowflake> | ||
get() = nopStreamsException() | ||
|
||
@Suppress("NOTHING_TO_INLINE") | ||
private inline fun nopStreamsException(): Nothing = | ||
throw NotImplementedError("NOP implementation being used, try to enable voice receiving.") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package dev.kord.voice.streams | ||
|
||
import dev.kord.common.annotation.KordVoice | ||
import dev.kord.common.entity.Snowflake | ||
import dev.kord.voice.AudioFrame | ||
import dev.kord.voice.udp.AudioPacket | ||
import kotlinx.coroutines.flow.Flow | ||
|
||
|
||
/** | ||
* A representation of receiving voice through Discord and different stages of processing. | ||
*/ | ||
@KordVoice | ||
abstract class Streams { | ||
/** | ||
* An encryption key used for decryption of Discord packets. | ||
*/ | ||
internal abstract var key: ByteArray? | ||
|
||
/** | ||
* A flow of all incoming [dev.kord.voice.udp.AudioPacket.DecryptedPacket]s through the UDP connection. | ||
*/ | ||
abstract val incomingAudioPackets: Flow<AudioPacket.DecryptedPacket> | ||
|
||
/** | ||
* A flow of all incoming [AudioFrame]s mapped to their [ssrc][UInt]. | ||
*/ | ||
abstract val incomingAudioFrames: Flow<Pair<UInt, AudioFrame>> | ||
|
||
/** | ||
* A flow of all incoming [AudioFrame]s mapped to their [userId][Snowflake]. | ||
* Streams for every user should be built over time and will not be immediately available. | ||
*/ | ||
abstract val incomingUserStreams: Flow<Pair<Snowflake, AudioFrame>> | ||
|
||
/** | ||
* A map of [ssrc][UInt]s to their corresponding [userId][Snowflake]. | ||
*/ | ||
abstract val ssrcToUser: Map<UInt, Snowflake> | ||
} |