diff --git a/src/types/events/webrtc/media_sink_wants.rs b/src/types/events/webrtc/media_sink_wants.rs new file mode 100644 index 0000000..8731d85 --- /dev/null +++ b/src/types/events/webrtc/media_sink_wants.rs @@ -0,0 +1,14 @@ +use crate::types::WebSocketEvent; +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Default, Deserialize, Serialize, Clone, PartialEq, Copy)] +/// What does this do? +/// +/// {"op":15,"d":{"any":100}} +/// +/// Opcode from +pub struct VoiceMediaSinkWants { + pub any: u16, +} + +impl WebSocketEvent for VoiceMediaSinkWants {} diff --git a/src/types/events/webrtc/mod.rs b/src/types/events/webrtc/mod.rs index 3c87aa0..3cd13eb 100644 --- a/src/types/events/webrtc/mod.rs +++ b/src/types/events/webrtc/mod.rs @@ -6,6 +6,7 @@ pub use client_connect::*; pub use client_disconnect::*; pub use hello::*; pub use identify::*; +pub use media_sink_wants::*; pub use ready::*; pub use select_protocol::*; pub use session_description::*; @@ -16,6 +17,7 @@ mod client_connect; mod client_disconnect; mod hello; mod identify; +mod media_sink_wants; mod ready; mod select_protocol; mod session_description; @@ -104,6 +106,13 @@ pub const VOICE_RESUMED: u8 = 9; pub const VOICE_VIDEO: u8 = 12; pub const VOICE_CLIENT_DISCONNECT: u8 = 13; pub const VOICE_SESSION_UPDATE: u8 = 14; + +/// What is this? +/// +/// {"op":15,"d":{"any":100}} +/// +/// Opcode from +pub const VOICE_MEDIA_SINK_WANTS: u8 = 15; /// 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/voice/gateway.rs b/src/voice/gateway.rs index ec6019d..8e66033 100644 --- a/src/voice/gateway.rs +++ b/src/voice/gateway.rs @@ -20,8 +20,8 @@ use crate::types::{ self, SelectProtocol, Speaking, VoiceGatewayReceivePayload, VoiceGatewaySendPayload, VoiceIdentify, WebSocketEvent, VOICE_BACKEND_VERSION, VOICE_CLIENT_CONNECT_FLAGS, VOICE_CLIENT_CONNECT_PLATFORM, VOICE_CLIENT_DISCONNECT, VOICE_HEARTBEAT, VOICE_HEARTBEAT_ACK, - VOICE_HELLO, VOICE_IDENTIFY, VOICE_READY, VOICE_RESUME, VOICE_SELECT_PROTOCOL, - VOICE_SESSION_DESCRIPTION, VOICE_SESSION_UPDATE, VOICE_SPEAKING, + VOICE_HELLO, VOICE_IDENTIFY, VOICE_MEDIA_SINK_WANTS, VOICE_READY, VOICE_RESUME, + VOICE_SELECT_PROTOCOL, VOICE_SESSION_DESCRIPTION, VOICE_SESSION_UPDATE, VOICE_SPEAKING, }; use self::voice_events::VoiceEvents; @@ -454,7 +454,19 @@ impl VoiceGateway { return; } } + VOICE_MEDIA_SINK_WANTS => { + trace!("VGW: Received Media Sink Wants"); + let event = &mut self.events.lock().await.media_sink_wants; + let result = VoiceGateway::handle_event(gateway_payload.data.get(), event).await; + if result.is_err() { + warn!( + "Failed to parse VOICE_MEDIA_SINK_WANTS ({})", + result.err().unwrap() + ); + return; + } + } // We received a heartbeat from the server // "Discord may send the app a Heartbeat (opcode 1) event, in which case the app should send a Heartbeat event immediately." VOICE_HEARTBEAT => { @@ -650,7 +662,7 @@ struct VoiceHeartbeatThreadCommunication { pub mod voice_events { use crate::types::{ SessionDescription, SessionUpdate, VoiceBackendVersion, VoiceClientConnectFlags, - VoiceClientConnectPlatform, VoiceClientDisconnection, VoiceReady, + VoiceClientConnectPlatform, VoiceClientDisconnection, VoiceMediaSinkWants, VoiceReady, }; use super::*; @@ -665,6 +677,7 @@ pub mod voice_events { pub client_disconnect: GatewayEvent, pub client_connect_flags: GatewayEvent, pub client_connect_platform: GatewayEvent, + pub media_sink_wants: GatewayEvent, pub error: GatewayEvent, } }