Skip to main content

mx_remote/wire/
constants.rs

1// Author: Lars Op den Kamp (lars@opdenkamp-it.nl)
2// Copyright (c) 2026 Op den Kamp IT Solutions
3
4//! Library, protocol and network constants.
5
6/// Version of this library.
7pub const VERSION: &str = env!("CARGO_PKG_VERSION");
8
9/// Highest MX Remote protocol version understood.
10///
11/// This is what a hello announces about this client, and it is not what any
12/// frame is stamped with - `stamp_for` decides that per opcode. A peer holds
13/// it as this client's ceiling, so understating it costs whatever the peer
14/// then withholds.
15pub const PROTOCOL_VERSION: u16 = 0x29;
16
17/// UDP port used in broadcast mode.
18pub const BROADCAST_PORT: u16 = 8811;
19
20/// Multicast group address used for discovery.
21pub const MULTICAST_IP: std::net::Ipv4Addr = std::net::Ipv4Addr::new(224, 8, 8, 8);
22
23/// UDP port used in multicast mode.
24pub const MULTICAST_PORT: u16 = 8812;
25
26/// Default destination UDP port of a V2IP video stream.
27pub const V2IP_PORT_VIDEO: u16 = 50020;
28
29/// Default destination UDP port of a V2IP ancillary-data stream.
30pub const V2IP_PORT_ANC: u16 = 50021;
31
32/// Default destination UDP port of a V2IP audio stream.
33pub const V2IP_PORT_AUDIO: u16 = 50022;
34
35/// Sample rate a V2IP audio stream uses when none is given.
36pub const V2IP_AUDIO_DEFAULT_SAMPLE_RATE: u32 = 48000;
37
38/// Channel count a V2IP audio stream uses when none is given.
39pub const V2IP_AUDIO_DEFAULT_CHANNELS: u8 = 2;
40
41/// Lowest channel count a V2IP audio stream accepts.
42pub const V2IP_AUDIO_MIN_CHANNELS: u8 = 1;
43
44/// Highest channel count a V2IP audio stream accepts.
45pub const V2IP_AUDIO_MAX_CHANNELS: u8 = 8;
46
47/// Lowest valid encoder TX rate, in units of 10Mb/s.
48///
49/// A V2IP device-config sender with no rate to offer puts a value outside
50/// [`V2IP_SOURCE_RATE_MIN`]..=[`V2IP_SOURCE_RATE_MAX`] in `tx_rate`; the
51/// firmware drops that as invalid and keeps the rate it already had, which is
52/// what stops an address-only or scaling-only write from resetting a peer.
53pub const V2IP_SOURCE_RATE_MIN: u8 = 5;
54
55/// Highest valid encoder TX rate, in units of 10Mb/s. See [`V2IP_SOURCE_RATE_MIN`].
56pub const V2IP_SOURCE_RATE_MAX: u8 = 100;
57
58/// Marks a DSCP byte as carrying a value.
59///
60/// DSCP 0 (CS0) is a legal marking, so the byte needs a bit of its own to
61/// separate "no marking" from CS0; it is OR'd in alongside the value.
62pub const V2IP_DSCP_SET: u8 = 0x80;
63
64/// Highest DSCP value; the marking occupies the upper 6 bits of the IPv4 TOS byte.
65pub const V2IP_DSCP_MAX: u8 = 63;
66
67/// CS2, the marking the video processor applies at boot and the value firmware
68/// falls back to when a peer sends none.
69pub const V2IP_DSCP_DEFAULT: u8 = 16;