Fix VideoTile bug and improve screen sharing
This commit is contained in:
parent
f93f2efd28
commit
bb3fc6c891
7 changed files with 187 additions and 19 deletions
80
shared/src/lib.rs
Normal file
80
shared/src/lib.rs
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
pub type UserId = u32; // Unique identifier for a user within a room
|
||||
pub type StreamId = u16; // Typically mapped to User + Media Source
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
#[repr(u8)]
|
||||
pub enum MediaType {
|
||||
Audio = 0,
|
||||
Video = 1,
|
||||
Screen = 2,
|
||||
Command = 3, // For handshake/keepalive
|
||||
Unknown = 255,
|
||||
}
|
||||
|
||||
/// UDP Packet Header (fixed size binary struct)
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct PacketHeader {
|
||||
pub version: u8, // Protocol version (v1)
|
||||
pub media_type: MediaType,
|
||||
pub user_id: UserId, // Identifies the source user (was stream_id)
|
||||
pub sequence: u32, // User-defined sequence number (for reordering/loss)
|
||||
pub timestamp: u32, // RTP-like timestamp
|
||||
pub fragment_index: u16, // If packet is fragmented (0 if not)
|
||||
pub fragment_count: u16, // Total fragments (1 if not)
|
||||
pub flags: u8, // Bitmask: 0x01 = Keyframe, etc.
|
||||
}
|
||||
|
||||
pub const FLAG_KEYFRAME: u8 = 0x01;
|
||||
|
||||
/// Signaling Messages (WebSocket - JSON)
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[serde(tag = "type", content = "data")]
|
||||
pub enum ControlMsg {
|
||||
/// Client -> Server: Request to join a room
|
||||
Join {
|
||||
room_code: String,
|
||||
display_name: String,
|
||||
},
|
||||
/// Server -> Client: Join success
|
||||
Joined {
|
||||
self_id: UserId,
|
||||
room_code: String,
|
||||
peers: Vec<PeerInfo>,
|
||||
},
|
||||
/// Server -> Client: New peer joined
|
||||
PeerJoined {
|
||||
user_id: UserId,
|
||||
display_name: String,
|
||||
},
|
||||
/// Server -> Client: Peer left
|
||||
PeerLeft {
|
||||
user_id: UserId,
|
||||
},
|
||||
/// Client -> Server: Update stream status (e.g. camera on/off)
|
||||
UpdateStream {
|
||||
user_id: UserId,
|
||||
stream_id: StreamId,
|
||||
active: bool,
|
||||
media_type: MediaType,
|
||||
},
|
||||
/// Client <-> Server: Chat message
|
||||
ChatMessage {
|
||||
user_id: UserId,
|
||||
display_name: String,
|
||||
message: String,
|
||||
timestamp: u64,
|
||||
},
|
||||
/// General Error
|
||||
Error {
|
||||
message: String,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct PeerInfo {
|
||||
pub user_id: UserId,
|
||||
pub display_name: String,
|
||||
// Could include active streams etc.
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue