diff --git a/src/types/events/webrtc/identify.rs b/src/types/events/webrtc/identify.rs index 45f1037..a4e887c 100644 --- a/src/types/events/webrtc/identify.rs +++ b/src/types/events/webrtc/identify.rs @@ -3,8 +3,10 @@ use serde::{Deserialize, Serialize}; #[derive(Debug, Deserialize, Serialize, Default, Clone, PartialEq, Eq)] /// The identify payload for the webrtc stream; +/// /// Contains info to begin a webrtc connection; -/// See https://discord.com/developers/docs/topics/voice-connections#establishing-a-voice-websocket-connection-example-voice-identify-payload; +/// +/// See pub struct VoiceIdentify { server_id: Snowflake, user_id: Snowflake, diff --git a/src/types/events/webrtc/mod.rs b/src/types/events/webrtc/mod.rs index ecfe3da..9c4e13c 100644 --- a/src/types/events/webrtc/mod.rs +++ b/src/types/events/webrtc/mod.rs @@ -1,5 +1,6 @@ use super::WebSocketEvent; use serde::{Deserialize, Serialize}; +use serde_json::{value::RawValue, Value}; pub use identify::*; pub use ready::*; @@ -14,40 +15,38 @@ mod session_description; mod speaking; #[derive(Debug, Default, Serialize, Clone)] -/// The payload used for sending events to the webrtc gateway -/// Not tha this is very similar to the regular gateway, except we no longer have a sequence number +/// The payload used for sending events to the webrtc gateway. /// -/// Similar to [WebrtcReceivePayload], except we send a [Value] for d whilst we receive a [serde_json::value::RawValue] -/// Also, we never need to send the event name +/// Similar to [VoiceGatewayReceivePayload], except we send a [Value] for d whilst we receive a [serde_json::value::RawValue] pub struct VoiceGatewaySendPayload { #[serde(rename = "op")] pub op_code: u8, #[serde(rename = "d")] - pub data: serde_json::Value, + pub data: Value, } impl WebSocketEvent for VoiceGatewaySendPayload {} #[derive(Debug, Deserialize, Clone)] -/// The payload used for receiving events from the webrtc gateway -/// Note that this is very similar to the regular gateway, except we no longer have s or t +/// The payload used for receiving events from the webrtc gateway. /// -/// Similar to [WebrtcSendPayload], except we send a [Value] for d whilst we receive a [serde_json::value::RawValue] -/// Also, we never need to sent the event name +/// Note that this is similar to the regular gateway, except we no longer have s or t +/// +/// Similar to [VoiceGatewaySendPayload], except we send a [Value] for d whilst we receive a [serde_json::value::RawValue] pub struct VoiceGatewayReceivePayload<'a> { #[serde(rename = "op")] pub op_code: u8, #[serde(borrow)] #[serde(rename = "d")] - pub data: &'a serde_json::value::RawValue, + pub data: &'a RawValue, } impl<'a> WebSocketEvent for VoiceGatewayReceivePayload<'a> {} /// The modes of encryption available in webrtc connections; -/// See https://discord.com/developers/docs/topics/voice-connections#establishing-a-voice-udp-connection-encryption-modes; +/// See #[derive(Debug, Default, Serialize, Deserialize, Clone, Copy, PartialEq, Eq)] #[serde(rename_all = "snake_case")] pub enum WebrtcEncryptionMode { @@ -68,9 +67,9 @@ pub const VOICE_HEARTBEAT_ACK: u8 = 6; pub const VOICE_RESUME: u8 = 7; pub const VOICE_HELLO: u8 = 8; pub const VOICE_RESUMED: u8 = 9; -/// See https://discord-userdoccers.vercel.app/topics/opcodes-and-status-codes#voice-opcodes +/// See pub const VOICE_VIDEO: u8 = 12; pub const VOICE_CLIENT_DISCONENCT: u8 = 13; -/// See https://discord-userdoccers.vercel.app/topics/opcodes-and-status-codes#voice-opcodes; +/// See /// Sent with empty data from the client, the server responds with the voice backend version; pub const VOICE_BACKEND_VERSION: u8 = 16; diff --git a/src/types/events/webrtc/ready.rs b/src/types/events/webrtc/ready.rs index 5e7286d..8a879b9 100644 --- a/src/types/events/webrtc/ready.rs +++ b/src/types/events/webrtc/ready.rs @@ -7,10 +7,12 @@ use super::WebrtcEncryptionMode; #[derive(Debug, Deserialize, Serialize, Clone, PartialEq, Eq)] /// The ready event for the webrtc stream; +/// /// Used to give info after the identify event; -/// See https://discord.com/developers/docs/topics/voice-connections#establishing-a-voice-websocket-connection-example-voice-ready-payload; +/// +/// See pub struct VoiceReady { - /// See https://developer.mozilla.org/en-US/docs/Web/API/RTCRtpStreamStats/ssrc + /// See ssrc: i32, ip: Ipv4Addr, port: u32, diff --git a/src/types/events/webrtc/select_protocol.rs b/src/types/events/webrtc/select_protocol.rs index 0966cd8..731c0d8 100644 --- a/src/types/events/webrtc/select_protocol.rs +++ b/src/types/events/webrtc/select_protocol.rs @@ -6,15 +6,18 @@ use super::WebrtcEncryptionMode; #[derive(Debug, Deserialize, Serialize, Clone)] /// An event sent by the client to the webrtc server, detailing what protocol, address and encryption to use; -/// See https://discord.com/developers/docs/topics/voice-connections#establishing-a-voice-udp-connection-example-select-protocol-payload +/// +/// See pub struct SelectProtocol { /// The protocol to use. The only option detailed in discord docs is "udp" pub protocol: String, + pub data: SelectProtocolData, } #[derive(Debug, Deserialize, Serialize, Clone)] /// The data field of the SelectProtocol Event -/// See https://discord.com/developers/docs/topics/voice-connections#establishing-a-voice-udp-connection-example-select-protocol-payload; +/// +/// See pub struct SelectProtocolData { /// Our external ip pub address: Ipv4Addr, diff --git a/src/types/events/webrtc/speaking.rs b/src/types/events/webrtc/speaking.rs index 3778266..dab9aba 100644 --- a/src/types/events/webrtc/speaking.rs +++ b/src/types/events/webrtc/speaking.rs @@ -2,8 +2,10 @@ use bitflags::bitflags; use serde::{Deserialize, Serialize}; /// Event that tells the server we are speaking; -/// Essentially, what allows us to send udp data and lights up the green circle around your avatar; -/// See https://discord.com/developers/docs/topics/voice-connections#speaking-example-speaking-payload +/// +/// Essentially, what allows us to send udp data and lights up the green circle around your avatar. +/// +/// See #[derive(Debug, Deserialize, Serialize, Clone, Default)] pub struct Speaking { /// Data about the audio we're transmitting, its type @@ -15,7 +17,8 @@ pub struct Speaking { bitflags! { /// Bitflags of speaking types; - /// See https://discord.com/developers/docs/topics/voice-connections#speaking; + /// + /// See #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Serialize, Deserialize)] pub struct SpeakingBitflags: u8 { /// Whether we'll be transmitting normal voice audio