feat: implement rendering
This commit is contained in:
61
src/main.rs
61
src/main.rs
@@ -1,18 +1,13 @@
|
||||
use clap::Parser;
|
||||
use fomo_reducer::{
|
||||
BotManager, CommandRouter, GuildVoiceChannelToTextChannel, RecordingManager, RenderManager,
|
||||
State, Storage, UserManager, VCsSender, all_commands, command, heat_seek, initialize_vcs,
|
||||
update_vcs,
|
||||
AudioChannels, AudioSampleRate, BotManager, CommandRouter, GuildVoiceChannelToTextChannel,
|
||||
RecordingManager, RenderManager, State, Storage, UserManager, VCsSender, all_commands, command,
|
||||
heat_seek, initialize_vcs, update_vcs,
|
||||
};
|
||||
use secrecy::{ExposeSecret, SecretString};
|
||||
use snafu::{OptionExt, ResultExt, Snafu};
|
||||
use songbird::{
|
||||
Config, Songbird,
|
||||
driver::{Channels, DecodeConfig, SampleRate},
|
||||
shards::TwilightMap,
|
||||
};
|
||||
use songbird::{Config, Songbird, driver::DecodeConfig, shards::TwilightMap};
|
||||
use std::{collections::BTreeMap, fmt::Debug, str::FromStr, sync::Arc, time::Duration};
|
||||
use strum::EnumString;
|
||||
use tokio::{select, signal::ctrl_c, task::JoinSet};
|
||||
use tokio_util::{sync::CancellationToken, time::FutureExt as _};
|
||||
use tracing::Level;
|
||||
@@ -33,47 +28,6 @@ use twilight_model::{
|
||||
},
|
||||
};
|
||||
|
||||
#[derive(Clone, Copy, Debug, strum::Display, EnumString)]
|
||||
enum AudioChannels {
|
||||
Mono,
|
||||
Stereo,
|
||||
}
|
||||
|
||||
impl From<AudioChannels> for Channels {
|
||||
fn from(value: AudioChannels) -> Self {
|
||||
match value {
|
||||
AudioChannels::Mono => Channels::Mono,
|
||||
AudioChannels::Stereo => Channels::Stereo,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, strum::Display, EnumString)]
|
||||
enum AudioSampleRate {
|
||||
#[strum(serialize = "8000Hz")]
|
||||
Hz8000,
|
||||
#[strum(serialize = "12000Hz")]
|
||||
Hz12000,
|
||||
#[strum(serialize = "16000Hz")]
|
||||
Hz16000,
|
||||
#[strum(serialize = "24000Hz")]
|
||||
Hz24000,
|
||||
#[strum(serialize = "48000Hz")]
|
||||
Hz48000,
|
||||
}
|
||||
|
||||
impl From<AudioSampleRate> for SampleRate {
|
||||
fn from(value: AudioSampleRate) -> Self {
|
||||
match value {
|
||||
AudioSampleRate::Hz8000 => SampleRate::Hz8000,
|
||||
AudioSampleRate::Hz12000 => SampleRate::Hz12000,
|
||||
AudioSampleRate::Hz16000 => SampleRate::Hz16000,
|
||||
AudioSampleRate::Hz24000 => SampleRate::Hz24000,
|
||||
AudioSampleRate::Hz48000 => SampleRate::Hz48000,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Snafu)]
|
||||
enum ParseGuildVCToTextChannelError {
|
||||
/// the guild ID needs to be included with : before the voice channel to text channel mapping
|
||||
@@ -279,15 +233,12 @@ async fn main() -> Result<(), MainError> {
|
||||
.collect(),
|
||||
);
|
||||
|
||||
let audio_channels = audio_channels.into();
|
||||
let audio_sample_rate = audio_sample_rate.into();
|
||||
|
||||
let senders = Arc::new(senders);
|
||||
let songbird = Songbird::twilight(senders, discord_user_id);
|
||||
songbird.set_config(
|
||||
Config::default().decode_mode(songbird::driver::DecodeMode::Decode(DecodeConfig::new(
|
||||
audio_channels,
|
||||
audio_sample_rate,
|
||||
audio_channels.into(),
|
||||
audio_sample_rate.into(),
|
||||
))),
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user