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.
10pub const PROTOCOL_VERSION: u16 = 0x28;
11
12/// UDP port used in broadcast mode.
13pub const BROADCAST_PORT: u16 = 8811;
14
15/// Multicast group address used for discovery.
16pub const MULTICAST_IP: std::net::Ipv4Addr = std::net::Ipv4Addr::new(224, 8, 8, 8);
17
18/// UDP port used in multicast mode.
19pub const MULTICAST_PORT: u16 = 8812;
20
21/// Default destination UDP port of a V2IP video stream.
22pub const V2IP_PORT_VIDEO: u16 = 50020;
23
24/// Default destination UDP port of a V2IP ancillary-data stream.
25pub const V2IP_PORT_ANC: u16 = 50021;
26
27/// Default destination UDP port of a V2IP audio stream.
28pub const V2IP_PORT_AUDIO: u16 = 50022;
29
30/// Sample rate a V2IP audio stream uses when none is given.
31pub const V2IP_AUDIO_DEFAULT_SAMPLE_RATE: u32 = 48000;
32
33/// Channel count a V2IP audio stream uses when none is given.
34pub const V2IP_AUDIO_DEFAULT_CHANNELS: u8 = 2;
35
36/// Lowest channel count a V2IP audio stream accepts.
37pub const V2IP_AUDIO_MIN_CHANNELS: u8 = 1;
38
39/// Highest channel count a V2IP audio stream accepts.
40pub const V2IP_AUDIO_MAX_CHANNELS: u8 = 8;
41
42/// Lowest valid encoder TX rate, in units of 10Mb/s.
43///
44/// A V2IP device-config sender with no rate to offer puts a value outside
45/// [`V2IP_SOURCE_RATE_MIN`]..=[`V2IP_SOURCE_RATE_MAX`] in `tx_rate`; the
46/// firmware drops that as invalid and keeps the rate it already had, which is
47/// what stops an address-only or scaling-only write from resetting a peer.
48pub const V2IP_SOURCE_RATE_MIN: u8 = 5;
49
50/// Highest valid encoder TX rate, in units of 10Mb/s. See [`V2IP_SOURCE_RATE_MIN`].
51pub const V2IP_SOURCE_RATE_MAX: u8 = 100;
52
53/// Marks a DSCP byte as carrying a value.
54///
55/// DSCP 0 (CS0) is a legal marking, so the byte needs a bit of its own to
56/// separate "no marking" from CS0; it is OR'd in alongside the value.
57pub const V2IP_DSCP_SET: u8 = 0x80;
58
59/// Highest DSCP value; the marking occupies the upper 6 bits of the IPv4 TOS byte.
60pub const V2IP_DSCP_MAX: u8 = 63;
61
62/// CS2, the marking the video processor applies at boot and the value firmware
63/// falls back to when a peer sends none.
64pub const V2IP_DSCP_DEFAULT: u8 = 16;