Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

feat(calls): promote screen share in room-composite recordings (#6266)

Will Hutchinson9347130b88e5
diff --git a/crates/call/src/domain/ports.rs b/crates/call/src/domain/ports.rs
index 7762ffa6a6..e903d9a4f4 100644
--- a/crates/call/src/domain/ports.rs
+++ b/crates/call/src/domain/ports.rs
@@ -500,7 +500,13 @@ pub trait CallRtcClient: Send + Sync + 'static {
participant_identity: MacroUserIdStr<'a>,
) -> impl Future<Output = anyhow::Result<()>> + Send;
- /// Start a room composite egress (recording). Returns the egress ID.
+ /// Start recording a room into the configured destination. Returns the
+ /// provider's egress ID.
+ ///
+ /// While nobody shares a screen, cameras fill the frame as equal tiles.
+ /// While someone shares, the shared screen fills the stage and cameras
+ /// move to a strip. The recording follows share start and stop for its
+ /// whole duration without further calls from the domain.
fn start_room_composite_egress(
&self,
room_name: &str,
@@ -508,6 +514,9 @@ pub trait CallRtcClient: Send + Sync + 'static {
) -> impl Future<Output = anyhow::Result<String>> + Send;
/// Stop an active egress by ID.
+ ///
+ /// Stopping does not change layout. The composition is chosen when
+ /// recording starts.
fn stop_egress(&self, egress_id: &str) -> impl Future<Output = anyhow::Result<()>> + Send;
/// Validate a webhook signature and parse the event from the raw body.
diff --git a/crates/call/src/outbound/livekit_rtc_client.rs b/crates/call/src/outbound/livekit_rtc_client.rs
index 8c544c7a3b..6c7bb380db 100644
--- a/crates/call/src/outbound/livekit_rtc_client.rs
+++ b/crates/call/src/outbound/livekit_rtc_client.rs
@@ -27,6 +27,9 @@ use crate::domain::ports::CallRtcClient;
const VOIP_TOKEN_MINT_CONCURRENCY: usize = 16;
+/// Empty layout is not default grid. The stock template only promotes layouts that start with `grid`.
+const STOCK_TEMPLATE_LAYOUT: &str = "grid";
+
/// LiveKit implementation of [`CallRtcClient`].
pub struct LivekitRtcClient {
room_client: RoomClient,
@@ -105,6 +108,7 @@ fn build_room_composite_egress_request(
});
let options = RoomCompositeOptions {
+ layout: STOCK_TEMPLATE_LAYOUT.to_owned(),
encoding: encoding::EncodingOptions {
audio_codec: AudioCodec::Aac,
video_codec: VideoCodec::H264Main,
diff --git a/crates/call/src/outbound/livekit_rtc_client/test.rs b/crates/call/src/outbound/livekit_rtc_client/test.rs
index 7ddc6f4080..aec3948cd0 100644
--- a/crates/call/src/outbound/livekit_rtc_client/test.rs
+++ b/crates/call/src/outbound/livekit_rtc_client/test.rs
@@ -1,8 +1,19 @@
+use livekit_protocol::VideoCodec;
use macro_user_id::user_id::MacroUserIdStr;
use super::*;
+use crate::domain::models::EgressS3Config;
use crate::domain::ports::CallRtcClient as _;
+fn s3_config() -> EgressS3Config {
+ EgressS3Config {
+ bucket: "recordings-bucket".to_string(),
+ region: "us-east-1".to_string(),
+ access_key: "test-access-key".to_string(),
+ secret: "test-secret".to_string(),
+ }
+}
+
fn client() -> LivekitRtcClient {
LivekitRtcClient::new(
"wss://lk.example",
@@ -48,3 +59,46 @@ async fn verify_access_token_rejects_token_signed_with_a_different_secret() {
fn verify_access_token_rejects_garbage() {
assert!(client().verify_access_token("not-a-jwt").is_err());
}
+
+#[test]
+fn room_composite_request_asks_the_stock_template_to_stage_a_shared_screen() {
+ let request = build_room_composite_egress_request("room-1", &s3_config());
+ assert_eq!(request.options.layout, "grid");
+ assert!(request.options.custom_base_url.is_empty());
+}
+
+#[test]
+fn room_composite_request_writes_one_mp4_under_the_room_prefix() {
+ let request = build_room_composite_egress_request("room-1", &s3_config());
+ assert_eq!(request.outputs.len(), 1);
+ let EgressOutput::File(file) = &request.outputs[0] else {
+ panic!("expected one file output");
+ };
+ assert_eq!(file.filepath, "calls/room-1/{time}");
+ assert_eq!(file.file_type, EncodedFileType::Mp4 as i32);
+}
+
+#[test]
+fn room_composite_request_uploads_to_the_configured_bucket() {
+ let request = build_room_composite_egress_request("room-1", &s3_config());
+ let EgressOutput::File(file) = &request.outputs[0] else {
+ panic!("expected one file output");
+ };
+ let Some(encoded_file_output::Output::S3(s3)) = &file.output else {
+ panic!("expected S3 upload");
+ };
+ assert_eq!(s3.bucket, "recordings-bucket");
+ assert_eq!(s3.region, "us-east-1");
+}
+
+#[test]
+fn room_composite_request_encodes_for_browser_playback() {
+ let request = build_room_composite_egress_request("room-1", &s3_config());
+ let encoding = &request.options.encoding;
+ assert_eq!(encoding.width, 1920);
+ assert_eq!(encoding.height, 1080);
+ assert_eq!(encoding.framerate, 30);
+ assert_eq!(encoding.video_bitrate, 4500);
+ assert_eq!(encoding.video_codec, VideoCodec::H264Main);
+ assert_eq!(encoding.audio_codec, AudioCodec::Aac);
+}
diff --git a/docs/AGENT_GUIDE/surfaces.md b/docs/AGENT_GUIDE/surfaces.md
index e122cdf7fa..3f5a8e1c4a 100644
--- a/docs/AGENT_GUIDE/surfaces.md
+++ b/docs/AGENT_GUIDE/surfaces.md
@@ -95,6 +95,8 @@ Google's out-of-office event type.
Tabs `All` / `Missed` / `Unattended`; `Call` button to start one. Recordings, transcriptions
and summaries appear here; empty state notes "Calls are available to agents."
+New recordings stage a shared screen with cameras in a side strip. Older
+recordings stay an equal-tile grid.
## Customers (CRM) — `/app/component/companies`