diff --git a/crates/datis-core/src/lib.rs b/crates/datis-core/src/lib.rs index 320880d..2682413 100644 --- a/crates/datis-core/src/lib.rs +++ b/crates/datis-core/src/lib.rs @@ -30,7 +30,7 @@ use futures::future::FutureExt; use futures::select; use futures::sink::SinkExt; use futures::stream::{SplitSink, StreamExt}; -use srs::{Client, VoiceStream, message::Coalition}; +use srs::{message::Coalition, Client, VoiceStream}; use tokio::runtime::{self, Runtime}; use tokio::sync::{oneshot, RwLock}; use tokio::time::delay_for; diff --git a/crates/srs/src/client.rs b/crates/srs/src/client.rs index 538a6de..86b3317 100644 --- a/crates/srs/src/client.rs +++ b/crates/srs/src/client.rs @@ -1,7 +1,7 @@ use std::net::SocketAddr; use std::sync::Arc; -use crate::message::{create_sguid, GameMessage, LatLngPosition, Coalition}; +use crate::message::{create_sguid, Coalition, GameMessage, LatLngPosition}; use crate::voice_stream::{VoiceStream, VoiceStreamError}; use futures::channel::mpsc; @@ -21,7 +21,7 @@ pub struct Client { freq: u64, pos: Arc>, unit: Option, - pub coalition: Coalition + pub coalition: Coalition, } impl Client { @@ -32,7 +32,7 @@ impl Client { freq, pos: Arc::new(RwLock::new(LatLngPosition::default())), unit: None, - coalition + coalition, } } diff --git a/crates/srs/src/voice_codec.rs b/crates/srs/src/voice_codec.rs index 9311341..602ada4 100644 --- a/crates/srs/src/voice_codec.rs +++ b/crates/srs/src/voice_codec.rs @@ -165,25 +165,25 @@ impl Encoder for VoiceCodec { // Packet format as specified in // https://github.com/ciribob/DCS-SimpleRadioStandalone/blob/1.9.3.0/DCS-SR-Common/Network/UDPVoicePacket.cs#L9 /* - * UDP PACKET LAYOUT - * - * - HEADER SEGMENT - * UInt16 Packet Length - 2 bytes - * UInt16 AudioPart1 Length - 2 bytes - * UInt16 FrequencyPart Length - 2 bytes - * - AUDIO SEGMENT - * Bytes AudioPart1 - variable bytes - * - FREQUENCY SEGMENT (one or multiple) - * double Frequency - 8 bytes - * byte Modulation - 1 byte - * byte Encryption - 1 byte - * - FIXED SEGMENT - * UInt UnitId - 4 bytes - * UInt64 PacketId - 8 bytes - * byte Retransmit / node / hop count - 1 byte - * Bytes / ASCII String TRANSMISSION GUID - 22 bytes used for transmission relay - * Bytes / ASCII String CLIENT GUID - 22 bytes - */ + * UDP PACKET LAYOUT + * + * - HEADER SEGMENT + * UInt16 Packet Length - 2 bytes + * UInt16 AudioPart1 Length - 2 bytes + * UInt16 FrequencyPart Length - 2 bytes + * - AUDIO SEGMENT + * Bytes AudioPart1 - variable bytes + * - FREQUENCY SEGMENT (one or multiple) + * double Frequency - 8 bytes + * byte Modulation - 1 byte + * byte Encryption - 1 byte + * - FIXED SEGMENT + * UInt UnitId - 4 bytes + * UInt64 PacketId - 8 bytes + * byte Retransmit / node / hop count - 1 byte + * Bytes / ASCII String TRANSMISSION GUID - 22 bytes used for transmission relay + * Bytes / ASCII String CLIENT GUID - 22 bytes + */ // NOTE: the final packet will start with the total packet length, but this will be added // by the inner fixed codec @@ -192,10 +192,9 @@ impl Encoder for VoiceCodec { let audio_length = packet.audio_part.len(); let fixed_segment_length = 4 + 8 + 1 + 22 + 22; - let capacity = - header_length + - audio_length + - frequency_length * packet.frequencies.len() + let capacity = header_length + + audio_length + + frequency_length * packet.frequencies.len() + fixed_segment_length; let mut wd = Cursor::new(Vec::with_capacity(capacity)); diff --git a/crates/srs/src/voice_stream.rs b/crates/srs/src/voice_stream.rs index 325550a..69cdc7d 100644 --- a/crates/srs/src/voice_stream.rs +++ b/crates/srs/src/voice_stream.rs @@ -9,8 +9,7 @@ use std::time::Duration; use crate::client::Client; use crate::message::{ - Client as MsgClient, GameMessage, Message, MsgType, Radio, RadioInfo, - RadioSwitchControls, + Client as MsgClient, GameMessage, Message, MsgType, Radio, RadioInfo, RadioSwitchControls, }; use crate::messages_codec::{self, MessagesCodec}; use crate::voice_codec::*; @@ -26,7 +25,6 @@ use tokio::time; use tokio_util::codec::{FramedRead, FramedWrite}; use tokio_util::udp::UdpFramed; -use std::default::Default; const SRS_VERSION: &str = "1.9.0.0"; pub struct VoiceStream { @@ -300,6 +298,7 @@ impl Sink> for VoiceStream { impl Sink for VoiceStream { type Error = mpsc::SendError; + fn poll_ready(self: Pin<&mut Self>, cx: &mut Context) -> Poll> { let s = self.get_mut(); Pin::new(&mut s.voice_sink).poll_ready(cx)