7 releases (1 stable)
1.0.0 | Jan 27, 2021 |
---|---|
0.4.1 | Jan 19, 2021 |
0.3.1 | Jan 7, 2021 |
0.2.0 | Jan 7, 2021 |
0.1.0 | Jan 6, 2021 |
#889 in Audio
13KB
229 lines
AudioSocket
AudioSocket is a simple TCP-based protocol for sending and receiving real-time audio streams.
Usage
use std::{convert::TryFrom, str::FromStr};
use audiosocket::{Message, RawMessage, Type};
use uuid::Uuid;
// You may replace this with bytes from TCP socket, test file, etc.
let recv = [
// Message contains a stream identifier.
1u8,
// Payload length is 16 bytes.
0,
16,
// Payload with UUID.
4,
54,
67,
12,
43,
2,
98,
76,
32,
50,
87,
5,
1,
33,
43,
87
];
let raw_message = RawMessage::try_from(&recv[..]).unwrap();
assert_eq!(*raw_message.message_type(), Type::Identifier);
let message = Message::try_from(raw_message).unwrap();
assert_eq!(message, Message::Identifier(Uuid::from_str("0436430c-2b02-624c-2032-570501212b57").unwrap()))
lib.rs
:
AudioSocket is a simple TCP-based protocol for sending and receiving real-time audio streams.
This crate is a port of a Go library.
use std::{convert::TryFrom, str::FromStr};
use audiosocket::{Message, RawMessage, Type};
use uuid::Uuid;
let recv = [
// Message contains a stream identifier.
1u8,
// Payload length is 16 bytes.
0,
16,
// Payload with UUID.
4,
54,
67,
12,
43,
2,
98,
76,
32,
50,
87,
5,
1,
33,
43,
87
];
let raw_message = RawMessage::try_from(&recv[..]).unwrap();
assert_eq!(*raw_message.message_type(), Type::Identifier);
let message = Message::try_from(raw_message).unwrap();
assert_eq!(message, Message::Identifier(Uuid::from_str("0436430c-2b02-624c-2032-570501212b57").unwrap()))
Dependencies
~1.5MB
~39K SLoC