[domistream] Implementation: HTTP, pairing, RTSP/SDP, ENet, control, input, RTP, FEC, video and audio receivers
Per PROTOCOL.md and the Wolf docs; interop with a real host is unverified. Strict, capped parsers throughout, shared helpers in util.rs. Where PROTOCOL.md says UNKNOWN the Wolf-documented behaviour is used. The audio receiver waits for the jitter budget before rebuilding a missing packet, so a late packet beats a rebuilt one.
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
//! `GET /applist` (`docs/PROTOCOL.md` 1.3).
|
||||
|
||||
use crate::Result;
|
||||
use crate::util::{cap, malformed, parse_u32};
|
||||
|
||||
/// Maximum size of an applist body, in bytes.
|
||||
pub const MAX_APPLIST_BYTES: usize = 1024 * 1024;
|
||||
/// Maximum number of apps accepted in one list.
|
||||
@@ -18,13 +21,28 @@ pub struct App {
|
||||
pub hdr_supported: bool,
|
||||
}
|
||||
|
||||
/// Parses an applist body. Apps keep the host's order; duplicate ids are refused.
|
||||
/// Parses an applist body. Apps keep the host's order; duplicate ids are refused; other elements are ignored.
|
||||
///
|
||||
/// # Errors
|
||||
/// [`crate::Error::TooLarge`] over [`MAX_APPLIST_BYTES`], [`MAX_APPS`] or [`MAX_APP_TITLE_BYTES`],
|
||||
/// [`crate::Error::HostStatus`] for a non-200 answer, [`crate::Error::Malformed`] for an `App` without `ID` or
|
||||
/// `AppTitle`. Phase A: always [`crate::Error::Unimplemented`].
|
||||
pub fn parse_app_list(body: &[u8]) -> crate::Result<Vec<App>> {
|
||||
let _ = body;
|
||||
Err(crate::Error::Unimplemented)
|
||||
/// `AppTitle`, a bad `ID`, or a duplicate `ID`.
|
||||
pub fn parse_app_list(body: &[u8]) -> Result<Vec<App>> {
|
||||
let doc = super::document(body, MAX_APPLIST_BYTES, "applist")?;
|
||||
let count = doc.root.children.iter().filter(|c| c.name == "App").count();
|
||||
cap("applist apps", MAX_APPS, count)?;
|
||||
let mut apps: Vec<App> = Vec::with_capacity(count);
|
||||
let mut ids = std::collections::BTreeSet::new();
|
||||
for e in doc.root.children.iter().filter(|c| c.name == "App") {
|
||||
let title = e.child("AppTitle").ok_or(malformed("applist: App without AppTitle"))?;
|
||||
cap("applist AppTitle", MAX_APP_TITLE_BYTES, title.text.len())?;
|
||||
let id = e.child("ID").ok_or(malformed("applist: App without ID"))?;
|
||||
let id = parse_u32("applist ID", &id.text)?;
|
||||
if !ids.insert(id) {
|
||||
return Err(malformed("applist: duplicate ID"));
|
||||
}
|
||||
let hdr_supported = e.child("IsHdrSupported").is_some_and(|h| h.text == "1");
|
||||
apps.push(App { id, title: title.text.clone(), hdr_supported });
|
||||
}
|
||||
Ok(apps)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user