[domistream] HTTP API: serverinfo, applist, launch/resume/cancel requests and capped XML parsers
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
//! `GET /launch` and `GET /resume` (`docs/PROTOCOL.md` 1.4).
|
||||
|
||||
use super::HttpRequest;
|
||||
use crate::SessionKeys;
|
||||
|
||||
/// Maximum size of a launch or resume answer, in bytes.
|
||||
pub const MAX_LAUNCH_RESPONSE_BYTES: usize = 16 * 1024;
|
||||
/// Maximum length of `sessionUrl0`, in bytes.
|
||||
pub const MAX_SESSION_URL_BYTES: usize = 256;
|
||||
|
||||
/// Audio channel layouts the client can ask for.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||
pub enum AudioLayout {
|
||||
/// 2.0.
|
||||
Stereo,
|
||||
/// 5.1.
|
||||
Surround51,
|
||||
/// 7.1.
|
||||
Surround71,
|
||||
}
|
||||
|
||||
/// What to launch and how.
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct LaunchParams {
|
||||
/// App `ID` from [`super::parse_app_list`].
|
||||
pub app_id: u32,
|
||||
/// Stream width in pixels.
|
||||
pub width: u32,
|
||||
/// Stream height in pixels.
|
||||
pub height: u32,
|
||||
/// Frames per second.
|
||||
pub fps: u32,
|
||||
/// Fresh keys for this session (never reuse; see [`SessionKeys`]).
|
||||
pub keys: SessionKeys,
|
||||
/// Ask for HDR (`hdrMode=1`).
|
||||
pub hdr: bool,
|
||||
/// Audio layout (`surroundAudioInfo`).
|
||||
pub audio: AudioLayout,
|
||||
}
|
||||
|
||||
/// What the host answers to launch or resume.
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct LaunchResponse {
|
||||
/// `gamesession == 1`.
|
||||
pub game_session: bool,
|
||||
/// `sessionUrl0`, e.g. `rtsp://192.0.2.10:48010`; `None` when missing (UNKNOWN U4).
|
||||
pub session_url: Option<String>,
|
||||
}
|
||||
|
||||
/// Builds `GET /launch` (HTTPS).
|
||||
///
|
||||
/// # Errors
|
||||
/// [`crate::Error::Malformed`] for a zero size or frame rate, or a bad `unique_id`. Phase A: always
|
||||
/// [`crate::Error::Unimplemented`].
|
||||
pub fn launch_request(params: &LaunchParams, unique_id: &str) -> crate::Result<HttpRequest> {
|
||||
let _ = (params, unique_id);
|
||||
Err(crate::Error::Unimplemented)
|
||||
}
|
||||
|
||||
/// Builds `GET /resume` (HTTPS) with fresh keys.
|
||||
///
|
||||
/// # Errors
|
||||
/// As [`launch_request`].
|
||||
pub fn resume_request(keys: &SessionKeys, unique_id: &str) -> crate::Result<HttpRequest> {
|
||||
let _ = (keys, unique_id);
|
||||
Err(crate::Error::Unimplemented)
|
||||
}
|
||||
|
||||
/// Parses a launch or resume answer.
|
||||
///
|
||||
/// # Errors
|
||||
/// [`crate::Error::TooLarge`] over [`MAX_LAUNCH_RESPONSE_BYTES`] or [`MAX_SESSION_URL_BYTES`],
|
||||
/// [`crate::Error::HostStatus`] for a non-200 answer, [`crate::Error::Malformed`] for a `sessionUrl0` that is not an
|
||||
/// `rtsp://host:port` URL. Phase A: always [`crate::Error::Unimplemented`].
|
||||
pub fn parse_launch_response(body: &[u8]) -> crate::Result<LaunchResponse> {
|
||||
let _ = body;
|
||||
Err(crate::Error::Unimplemented)
|
||||
}
|
||||
Reference in New Issue
Block a user