Add more webrtc typings
This commit is contained in:
parent
cfe4e2c7bb
commit
b4a4e1f5d5
|
@ -1,5 +1,31 @@
|
||||||
pub use identify::*;
|
pub use identify::*;
|
||||||
pub use ready::*;
|
pub use ready::*;
|
||||||
|
pub use select_protocol::*;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
mod identify;
|
mod identify;
|
||||||
mod ready;
|
mod ready;
|
||||||
|
mod select_protocol;
|
||||||
|
|
||||||
|
/// The modes of encryption available in webrtc connections;
|
||||||
|
/// See https://discord.com/developers/docs/topics/voice-connections#establishing-a-voice-udp-connection-encryption-modes;
|
||||||
|
#[derive(Debug, Serialize, Deserialize, Clone, Copy)]
|
||||||
|
#[serde(rename_all = "snake_case")]
|
||||||
|
pub enum WebrtcEncryptionMode {
|
||||||
|
XSalsa20Poly1305,
|
||||||
|
XSalsa20Poly1305Suffix,
|
||||||
|
XSalsa20Poly1305Lite,
|
||||||
|
}
|
||||||
|
|
||||||
|
// The various voice opcodes
|
||||||
|
pub const VOICE_IDENTIFY: u8 = 0;
|
||||||
|
pub const VOICE_SELECT_PROTOCOL: u8 = 1;
|
||||||
|
pub const VOICE_READY: u8 = 2;
|
||||||
|
pub const VOICE_HEARTBEAT: u8 = 3;
|
||||||
|
pub const VOICE_SESSION_DESCRIPTION: u8 = 4;
|
||||||
|
pub const VOICE_SPEAKING: u8 = 5;
|
||||||
|
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;
|
||||||
|
pub const VOICE_CLIENT_DISCONENCT: u8 = 13;
|
||||||
|
|
|
@ -3,15 +3,19 @@ use std::net::Ipv4Addr;
|
||||||
use crate::types::WebSocketEvent;
|
use crate::types::WebSocketEvent;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
use super::WebrtcEncryptionMode;
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize, Clone)]
|
#[derive(Debug, Deserialize, Serialize, Clone)]
|
||||||
/// The ready event for the webrtc stream;
|
/// The ready event for the webrtc stream;
|
||||||
/// Used to give info after the identify event;
|
/// 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 https://discord.com/developers/docs/topics/voice-connections#establishing-a-voice-websocket-connection-example-voice-ready-payload;
|
||||||
pub struct VoiceReady {
|
pub struct VoiceReady {
|
||||||
ssrc: u8,
|
/// See https://developer.mozilla.org/en-US/docs/Web/API/RTCRtpStreamStats/ssrc
|
||||||
|
ssrc: i32,
|
||||||
ip: Ipv4Addr,
|
ip: Ipv4Addr,
|
||||||
port: u8,
|
port: u32,
|
||||||
modes: Vec<String>,
|
/// The available encryption modes for the webrtc connection
|
||||||
|
modes: Vec<WebrtcEncryptionMode>,
|
||||||
// Heartbeat interval is also sent, but is "an erroneous field and should be ignored. The correct heartbeat_interval value comes from the Hello payload."
|
// Heartbeat interval is also sent, but is "an erroneous field and should be ignored. The correct heartbeat_interval value comes from the Hello payload."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
use std::net::Ipv4Addr;
|
||||||
|
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
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
|
||||||
|
pub struct SelectProtocol {
|
||||||
|
/// The protocol to use. The only option detailed in discord docs is "udp"
|
||||||
|
pub protocol: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[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;
|
||||||
|
pub struct SelectProtocolData {
|
||||||
|
/// Our external ip
|
||||||
|
pub address: Ipv4Addr,
|
||||||
|
/// Our external udp port
|
||||||
|
pub port: u32,
|
||||||
|
/// The mode of encryption to use
|
||||||
|
pub mode: WebrtcEncryptionMode,
|
||||||
|
}
|
Loading…
Reference in New Issue