ados_sdk/context/media.rs
1//! `ctx.video` and `ctx.sensors`: the relays the host carries for a plugin
2//! whose sandbox cannot reach the media server or the control plane.
3
4use std::sync::Arc;
5
6use crate::client::{ClientError, PluginIpcClient, WhepAnswer};
7
8/// `ctx.video` — WebRTC playback (WHEP) sessions on the agent's published
9/// camera legs, for viewers the plugin serves. Needs `video.whep.relay`.
10#[derive(Clone)]
11pub struct VideoClient {
12 pub(super) ipc: Arc<PluginIpcClient>,
13}
14
15impl VideoClient {
16 /// Open a playback session on the configured camera `camera_id` for
17 /// `offer_sdp`. See [`PluginIpcClient::whep_offer`].
18 pub async fn whep_offer(
19 &self,
20 camera_id: &str,
21 offer_sdp: &str,
22 ) -> Result<WhepAnswer, ClientError> {
23 self.ipc.whep_offer(camera_id, offer_sdp).await
24 }
25
26 /// Close a session this plugin opened, by its location. See
27 /// [`PluginIpcClient::whep_close`].
28 pub async fn whep_close(&self, location: &str) -> Result<(), ClientError> {
29 self.ipc.whep_close(location).await
30 }
31}
32
33/// `ctx.sensors` — the sensor rig document. Needs `sensors.rig.write`.
34#[derive(Clone)]
35pub struct SensorsClient {
36 pub(super) ipc: Arc<PluginIpcClient>,
37}
38
39impl SensorsClient {
40 /// Relays to core `PUT /api/v1/sensors/rig`; returns the core HTTP status
41 /// and JSON body (`{"ok":true,"rig_id","calib_version"}` or
42 /// `{"error":"E_RIG_INVALID","detail"}`). See [`PluginIpcClient::put_rig`].
43 pub async fn put_rig(
44 &self,
45 rig: &serde_json::Value,
46 ) -> Result<(u16, serde_json::Value), ClientError> {
47 self.ipc.put_rig(rig).await
48 }
49}