-
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.
- Loading branch information
schlaubi
authored and
schlaubi
committed
Jan 25, 2024
1 parent
55dd87c
commit 83e991d
Showing
63 changed files
with
321 additions
and
104 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 |
---|---|---|
@@ -1,9 +1,16 @@ | ||
plugins { | ||
`kord-module` | ||
`kord-native-module` | ||
`kord-multiplatform-module` | ||
`kord-publishing` | ||
} | ||
|
||
dependencies { | ||
api(projects.core) | ||
api(projects.voice) | ||
kotlin { | ||
sourceSets { | ||
commonMain { | ||
dependencies { | ||
api(projects.core) | ||
api(projects.voice) | ||
} | ||
} | ||
} | ||
} |
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
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 |
---|---|---|
@@ -1,22 +1,54 @@ | ||
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi | ||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget | ||
|
||
plugins { | ||
`kord-internal-multiplatform-module` | ||
`kord-native-module` | ||
} | ||
|
||
@OptIn(ExperimentalKotlinGradlePluginApi::class) | ||
kotlin { | ||
applyDefaultHierarchyTemplate { | ||
common { | ||
group("voice") { | ||
withLinux() | ||
withMacos() | ||
withJvm() | ||
} | ||
} | ||
} | ||
js { | ||
binaries.executable() | ||
} | ||
|
||
targets.withType<KotlinNativeTarget> { | ||
binaries.executable { | ||
entryPoint = "dev.kord.voice.test.main" | ||
} | ||
} | ||
|
||
sourceSets { | ||
commonMain { | ||
dependencies { | ||
implementation(projects.core) | ||
implementation(libs.kotlin.logging) | ||
} | ||
} | ||
jvmMain { | ||
dependencies { | ||
runtimeOnly(libs.slf4j.simple) | ||
} | ||
} | ||
linuxMain { | ||
dependencies { | ||
implementation(libs.ktor.client.curl) | ||
} | ||
} | ||
|
||
named("voiceMain") { | ||
dependencies { | ||
implementation(projects.coreVoice) | ||
} | ||
} | ||
} | ||
} |
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 @@ | ||
org.slf4j.simpleLogger.defaultLogLevel=trace |
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,52 @@ | ||
@file:OptIn(KordVoice::class) | ||
|
||
package dev.kord.voice.test | ||
|
||
import dev.kord.common.annotation.KordVoice | ||
import dev.kord.core.Kord | ||
import dev.kord.core.behavior.channel.BaseVoiceChannelBehavior | ||
import dev.kord.core.behavior.channel.connect | ||
import dev.kord.core.behavior.interaction.respondPublic | ||
import dev.kord.core.event.interaction.GuildChatInputCommandInteractionCreateEvent | ||
import dev.kord.core.on | ||
import dev.kord.voice.AudioFrame | ||
import kotlinx.coroutines.launch | ||
import kotlinx.coroutines.runBlocking | ||
|
||
fun main(args: Array<String>) = runBlocking { | ||
val kord = Kord(args.firstOrNull() ?: error("Missing token")) | ||
|
||
kord.createGlobalApplicationCommands { | ||
input("join", "Test command") { | ||
dmPermission = false | ||
} | ||
} | ||
|
||
kord.on<GuildChatInputCommandInteractionCreateEvent> { | ||
val channel = interaction.user.asMember(interaction.guildId).getVoiceState().getChannelOrNull() | ||
if (channel == null) { | ||
interaction.respondPublic { content = "not in channel" } | ||
return@on | ||
} | ||
interaction.respondPublic { content = "success" } | ||
channel.connectEcho() | ||
} | ||
|
||
kord.login() | ||
} | ||
|
||
private suspend fun BaseVoiceChannelBehavior.connectEcho() { | ||
val buffer = ArrayList(listOf(AudioFrame.SILENCE, AudioFrame.SILENCE, AudioFrame.SILENCE, AudioFrame.SILENCE)) | ||
val connection = connect { | ||
receiveVoice = true | ||
audioProvider { | ||
buffer.removeLastOrNull() ?: AudioFrame.SILENCE | ||
} | ||
} | ||
connection.scope.launch { | ||
connection.streams.incomingAudioFrames.collect { (userId, frame) -> | ||
println("Received frame from:${userId}") | ||
buffer.add(frame) | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,21 +1,31 @@ | ||
plugins { | ||
java // for TweetNaclFast | ||
`kord-module` | ||
`kord-sampled-module` | ||
`kord-native-module` | ||
`kord-multiplatform-module` | ||
`kord-publishing` | ||
} | ||
|
||
dependencies { | ||
api(projects.common) | ||
api(projects.gateway) | ||
kotlin { | ||
jvm { | ||
withJava() | ||
} | ||
|
||
implementation(libs.kotlin.logging) | ||
implementation(libs.slf4j.api) | ||
sourceSets { | ||
commonMain { | ||
dependencies { | ||
api(projects.common) | ||
api(projects.gateway) | ||
|
||
// TODO remove when voiceGatewayOnLogger is removed | ||
implementation(libs.kotlin.logging.old) | ||
api(libs.ktor.network) | ||
implementation(libs.kotlin.logging) | ||
|
||
compileOnly(projects.kspAnnotations) | ||
compileOnly(projects.kspAnnotations) | ||
} | ||
} | ||
|
||
api(libs.ktor.network) | ||
nonJvmMain { | ||
dependencies { | ||
implementation(libs.libsodium) | ||
} | ||
} | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions
1
voice/src/main/kotlin/AudioFrame.kt → voice/src/commonMain/kotlin/AudioFrame.kt
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.