From f994f18a3ba228ab0cf403c837cc184b2f094389 Mon Sep 17 00:00:00 2001 From: Derrors <33656531+Derrors@users.noreply.github.com> Date: Wed, 25 Nov 2026 15:05:16 +0800 Subject: [PATCH] fix: follow-ups from the review of #187-#193 - /mcp chunked bodies: the raw body is bounded too (the decoded 1 MB plus 64 KB of framing; endless trailer lines or long chunk extensions got 413 instead of growing for a minute), read in 64 KB pieces (about 16 decoding passes for 1 MB instead of 256), and a broken chunk gets 400 instead of a closed connection - /mcp answers: 1xx, 204 and 304 are never sent chunked (they have no body, RFC 9112 6.3) - MjpegStream errors are in the page's language (the stream ran outside the request's language scope) - the scoped-task foreground check matches `Route` like the other dispatch sites - a page's native video connection that closes while it waits for the next media stream (an unlock holds the device for seconds) no longer opens the stream again for nobody - the viewer lets its port go before stopping the agents - media.rs's comment and the changelog no longer say unwatched frames aren't assembled: they are depacketized and scanned, only not copied or queued - CONTRIBUTING's per-package fmt list includes ictl-ax, as CI does - the Unreleased changelog: PR numbers on every line, the iOS 17-18 disk image fix (#186), sections and wording per CONTRIBUTING Not changed: a TTL in front of the token file's stat (microseconds per request; a revoked token would keep working for the TTL). Co-authored-by: Claude Opus 5.5 --- CHANGELOG.md | 42 +++++++++++++-------------- CHANGELOG.zh-CN.md | 42 +++++++++++++-------------- CONTRIBUTING.md | 2 +- apps/iphone-control/src/viewer.rs | 40 +++++++++++++++++++------ apps/iphone-control/src/viewer/mcp.rs | 17 ++++++++++- crates/ictl-daemon/src/core.rs | 13 +++++---- crates/ictl-daemon/src/lib.rs | 4 +-- crates/ictl-daemon/src/screen.rs | 18 ++++++++++-- crates/ictl-device/src/media.rs | 2 +- 9 files changed, 116 insertions(+), 64 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dc88e0e..594609b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,30 +6,30 @@ What changed in each release, one line per change. Versions follow [Semantic Ver ## [Unreleased] -### Fixes +### Improvements -- Times in `status`, `doctor` and the event log are shown in local time with the time zone; they were UTC without saying so. -- Errors from `iphone-control update`, `service` and the update panel on the control page follow the chosen language; they were always in English. -- Phones driven natively (iOS 27+) no longer trigger WebDriverAgent re-signing or the daily Apple ID session check (and its "session expired" warning) when another device once used WebDriverAgent. -- After re-signing, the new WebDriverAgent starts right away instead of at the next check up to 10 seconds later. -- A dragged finger held down (`iphone_swipe` with `hold`) is lifted if the drag fails or times out halfway. -- Responses from WebDriverAgent, accessibility messages and screen video frames have size limits, so a broken stream can't make the program use unbounded memory. -- Screenshots of a phone driven natively say "via CoreDevice" instead of "via HID". -- With nobody watching the control page, the phone's screen video is no longer assembled into frames, which saves CPU while an agent works. -- Several control pages on one phone running WebDriverAgent share one picture stream from the phone instead of opening one each, which could push WebDriverAgent over the CPU limit at which iOS stops it. -- Pages watching the phone's own video share one rotation check a second instead of one per page. -- At most 4 control pages at once get the phone's own video transcoded to H.264 (browsers without HEVC, one ffmpeg each); more retry until one closes, instead of starting another ffmpeg each. -- The control page polls less: the task list comes with the device-info poll instead of a poll of its own, the device panel asks two requests a round instead of three, and a page in a background tab stops polling until it is shown again. -- A daemon that ended with the screen media stream open (stuck and restarted by its watchdog, crashed or killed) no longer leaves the phone showing "viewed remotely" and never auto-locking: the next daemon clears it once the phone is ready. -- MCP over HTTP (`/mcp`) accepts request bodies sent chunked, which some clients and reverse proxies do; they got 411 Length Required. Streamed answers are sent chunked, so a proxy can tell their end from a dropped connection. -- The control page's server allows 64 connections instead of 32, and answers 503 (and logs it) when they are all taken instead of dropping the connection silently. -- Stopping the viewer (`systemctl stop`, an update, Ctrl-C) also stops the agents of AI tasks started from the page; they kept running on their own. -- An idle `iphone-control mcp` (kept running by Claude Desktop, Cursor, Claude Code…) no longer keeps updates from installing: it holds the maintenance lock only during a tool call, and its next call reaches the new daemon. -- The phone's own video on the control page pauses while the phone unlocks itself or the bitrate changes, instead of dropping and reconnecting. +- Several control pages on one phone running WebDriverAgent share one picture stream from the phone instead of opening one each, which could push WebDriverAgent over the CPU limit at which iOS stops it (#188). +- On iOS 17–26 the control page's picture comes through the daemon; apart from `wda-bridge`, only the daemon talks to the phone now (#192). +- The phone's own video on the control page pauses while the phone unlocks itself or the bitrate changes, instead of dropping and reconnecting (#190). +- While nobody watches the control page, the phone's screen video costs less CPU (#187). +- The control page polls less, and not at all from a background tab (#193). -### Improvements +### Fixes -- On iOS 17–26 the control page's picture comes through the daemon instead of the viewer opening WebDriverAgent's picture port on the phone itself; apart from `wda-bridge`, only the daemon talks to the phone now. +- iOS 17–18: the developer disk image is mounted the way these versions need, so WebDriverAgent starts on them again (#186). +- Times in `status`, `doctor` and the event log are shown in local time with the time zone; they were UTC without saying so (#184). +- Errors from `iphone-control update`, `service` and the update panel on the control page follow the chosen language; they were always in English (#184). +- An idle `iphone-control mcp` (kept running by Claude Desktop, Cursor, Claude Code…) no longer keeps updates from installing; its next call reaches the new daemon (#190). +- Phones driven natively (iOS 27+) no longer trigger WebDriverAgent re-signing or the daily Apple ID session check (and its "session expired" warning) when another device once used WebDriverAgent (#187). +- After re-signing, the new WebDriverAgent starts right away (#187). +- A dragged finger held down (`iphone_swipe` with `hold`) is lifted if the drag fails or times out halfway (#187). +- A broken stream from the phone can no longer make the program use unbounded memory (#187). +- Screenshots of a phone driven natively say "via CoreDevice" instead of "via HID" (#187). +- A daemon that ended with the screen media stream open (stuck and restarted, crashed or killed) no longer leaves the phone showing "viewed remotely" and never auto-locking (#193). +- MCP over HTTP (`/mcp`) accepts request bodies sent chunked, as some clients and reverse proxies send them, and ends streamed answers so a proxy can tell their end from a dropped connection (#189). +- The control page's server takes more connections and answers 503 when they are all taken instead of dropping new ones silently (#189). +- At most 4 control pages at once get the phone's own video transcoded to H.264 (browsers without HEVC); more retry until one closes (#193). +- Stopping the viewer (`systemctl stop`, an update, Ctrl-C) also stops the agents of AI tasks started from the page; they kept running on their own (#189). ## [0.2.14] - 2026-11-24 diff --git a/CHANGELOG.zh-CN.md b/CHANGELOG.zh-CN.md index e2b23c9..62ab15a 100644 --- a/CHANGELOG.zh-CN.md +++ b/CHANGELOG.zh-CN.md @@ -6,30 +6,30 @@ ## [Unreleased] -### 修复 +### 改进 -- `status`、`doctor` 和事件日志里的时间改为本地时间并标明时区,之前显示的是 UTC 却没有说明。 -- `iphone-control update`、`service` 和控制台更新面板里的报错跟随界面语言,之前总是英文。 -- 原生控制的手机(iOS 27 起)不再因为别的设备用过 WebDriverAgent 而触发 WebDriverAgent 重签和每天一次的 Apple ID 会话检查(以及「会话失效」提醒)。 -- 重签完成后马上启动新的 WebDriverAgent,不用再等最多 10 秒的下一轮巡检。 -- 按住再拖(`iphone_swipe` 带 `hold`)中途失败或超时时会抬起手指,不再留着按下的状态。 -- WebDriverAgent 的响应、无障碍消息和屏幕视频帧都有了大小上限,数据流出错时不会无限占用内存。 -- 原生控制时截图说明写「经 CoreDevice」,不再写「经 HID」。 -- 控制台没人观看时不再把手机的屏幕视频拼成帧,Agent 操作期间更省 CPU。 -- 用 WebDriverAgent 的手机开着多个控制台页面时,共用手机上的一路画面,不再每个页面各开一路(多开时可能让 WebDriverAgent 超出 CPU 上限被 iOS 结束)。 -- 观看手机原生视频的多个页面共用每秒一次的屏幕方向检查,不再每个页面各查一次。 -- 浏览器解不了 HEVC、要把手机原生视频转成 H.264 的控制台页面(每页一个 ffmpeg)同时最多 4 个,再多的等有页面关掉后重试,不再每多一页就多开一个 ffmpeg。 -- 控制台页面的轮询更少:任务列表随设备信息的轮询一起取,不再单独轮询;设备面板每轮两个请求而不是三个;页面在后台标签页时停止轮询,切回来再接着。 -- 守护进程开着屏幕媒体流就退出(卡死被看门狗重启、崩溃或被结束)后,手机不再一直显示「正在被查看」、一直不自动锁屏:新的守护进程在手机就绪后清掉它。 -- HTTP 上的 MCP(`/mcp`)接受分块(chunked)发送的请求体,之前会回 411 Length Required(有的客户端和反向代理这样发)。流式的回答改为分块发送,代理能分清正常结束和连接中断。 -- 控制台服务的连接上限从 32 个提高到 64 个,满了时回 503 并记日志,不再悄悄断开。 -- 停止控制台(`systemctl stop`、升级、Ctrl-C)时一并结束从页面启动的 AI 任务的 agent,之前它们会自己继续运行。 -- 空闲的 `iphone-control mcp`(Claude Desktop、Cursor、Claude Code 等一直开着)不再挡住更新安装:它只在工具调用期间占用维护锁,升级后下一次调用自动连上新的守护进程。 -- 手机自动解锁或码率切换时,控制台里的手机原生画面只是暂停,不再断开重连。 +- 用 WebDriverAgent 的手机开着多个控制台页面时,共用手机上的一路画面,不再每个页面各开一路(多开时可能让 WebDriverAgent 超出 CPU 上限被 iOS 结束)(#188)。 +- iOS 17–26 上控制台的画面改经守护进程取;除了 `wda-bridge`,现在只有守护进程和手机打交道(#192)。 +- 手机自动解锁或码率切换时,控制台里的手机原生画面只是暂停,不再断开重连(#190)。 +- 控制台没人观看时,手机的屏幕视频占用的 CPU 更少(#187)。 +- 控制台页面的轮询更少,在后台标签页时不再轮询(#193)。 -### 改进 +### 修复 -- iOS 17–26 上控制台的画面改经守护进程取,viewer 不再自己连手机上 WebDriverAgent 的画面端口;除了 `wda-bridge`,现在只有守护进程和手机打交道。 +- iOS 17–18:开发者镜像按这些版本需要的方式挂载,WebDriverAgent 又能在上面启动了(#186)。 +- `status`、`doctor` 和事件日志里的时间改为本地时间并标明时区,之前显示的是 UTC 却没有说明(#184)。 +- `iphone-control update`、`service` 和控制台更新面板里的报错跟随界面语言,之前总是英文(#184)。 +- 空闲的 `iphone-control mcp`(Claude Desktop、Cursor、Claude Code 等一直开着)不再挡住更新安装,升级后下一次调用自动连上新的守护进程(#190)。 +- 原生控制的手机(iOS 27 起)不再因为别的设备用过 WebDriverAgent 而触发 WebDriverAgent 重签和每天一次的 Apple ID 会话检查(以及「会话失效」提醒)(#187)。 +- 重签完成后马上启动新的 WebDriverAgent(#187)。 +- 按住再拖(`iphone_swipe` 带 `hold`)中途失败或超时时会抬起手指,不再留着按下的状态(#187)。 +- 手机那边的数据流出错时,程序不会再无限占用内存(#187)。 +- 原生控制时截图说明写「经 CoreDevice」,不再写「经 HID」(#187)。 +- 守护进程开着屏幕媒体流就退出(卡死被重启、崩溃或被结束)后,手机不再一直显示「正在被查看」、一直不自动锁屏(#193)。 +- HTTP 上的 MCP(`/mcp`)接受分块(chunked)发送的请求体(有的客户端和反向代理这样发),流式的回答也明确结束,代理能分清正常结束和连接中断(#189)。 +- 控制台服务能接更多连接,满了时回 503,不再悄悄断开新连接(#189)。 +- 浏览器解不了 HEVC、要把手机原生视频转成 H.264 的控制台页面同时最多 4 个,再多的等有页面关掉后重试(#193)。 +- 停止控制台(`systemctl stop`、升级、Ctrl-C)时一并结束从页面启动的 AI 任务的 agent,之前它们会自己继续运行(#189)。 ## [0.2.14] - 2026-11-24 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8848505..c4a2f2c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -24,7 +24,7 @@ cargo clippy --workspace --all-targets --all-features --locked -- -D warnings # the control page's tests (Node 22, no packages): the page is apps/iphone-control/web/, put together by build.rs node --test tests/viewer/*.test.mjs # vendor/ is upstream code and isn't formatted; check only this repository's packages: -for p in ictl-l10n ictl-webinspector ictl-device ictl-wda ictl-sign ictl-unlock ictl-daemon ictl-mcp ictl-protocol iphone-control; do cargo fmt -p $p -- --check; done +for p in ictl-ax ictl-l10n ictl-webinspector ictl-device ictl-wda ictl-sign ictl-unlock ictl-daemon ictl-mcp ictl-protocol iphone-control; do cargo fmt -p $p -- --check; done ``` Or, without Rust installed: diff --git a/apps/iphone-control/src/viewer.rs b/apps/iphone-control/src/viewer.rs index 7639f52..22af89b 100644 --- a/apps/iphone-control/src/viewer.rs +++ b/apps/iphone-control/src/viewer.rs @@ -367,6 +367,8 @@ pub async fn run( // here are stopped (they run in process groups of their own, which nothing else would end); open pictures and // event streams end with the process, and the pages reconnect to the next viewer tracing::info!("viewer: stopping"); + // the port is let go first: nothing waits in the backlog while the agents are stopped + drop(listener); ctx.agents.stop_all().await; Ok(()) } @@ -709,8 +711,9 @@ async fn route( } let body = if req.chunked { match read_chunked(client, body, mcp::MAX_BODY).await? { - Some(b) => b, - None => return reply(client, 413, "text/plain", b"too large").await, + Ok(b) => b, + Err(mcp::Chunked::TooLarge) => return reply(client, 413, "text/plain", b"too large").await, + Err(_) => return reply(client, 400, "text/plain", b"bad chunked body").await, } } else { let len = req.content_length.unwrap_or(0); @@ -1111,18 +1114,28 @@ async fn read_body(client: &mut Conn, body: &mut Vec, len: usize) -> anyhow: const BODY_TIMEOUT: Duration = Duration::from_secs(60); -/// A chunked body (`/mcp` only): read until its last chunk, decoded. `None` when it is bigger than `max`. What -/// follows it is left unread: the connection closes after the answer -async fn read_chunked(client: &mut Conn, mut raw: Vec, max: usize) -> anyhow::Result>> { +/// Framing a chunked body may add to what it carries (sizes, extensions, trailers): past this much more than the +/// decoded limit, on the wire, it is refused as too large +const CHUNKED_OVERHEAD: usize = 64 * 1024; + +/// A chunked body (`/mcp` only): read until its last chunk, decoded. `Err` with [`mcp::Chunked::TooLarge`] when it, +/// or its framing ([`CHUNKED_OVERHEAD`]), is bigger than allowed, [`mcp::Chunked::Invalid`] when it isn't chunked +/// properly; the caller answers 413 or 400. What follows it is left unread: the connection closes after the answer. +/// It is decoded again from the start as more comes, so it is read in large pieces: a 1 MB body takes about 16 passes +async fn read_chunked( + client: &mut Conn, + mut raw: Vec, + max: usize, +) -> anyhow::Result, mcp::Chunked>> { let read = async { + let mut buf = vec![0u8; 64 * 1024]; loop { match mcp::dechunk(&raw, max) { - mcp::Chunked::Done(body, _) => return anyhow::Ok(Some(body)), - mcp::Chunked::TooLarge => return Ok(None), - mcp::Chunked::Invalid => bail!("bad chunked body"), + mcp::Chunked::Done(body, _) => return anyhow::Ok(Ok(body)), + mcp::Chunked::Partial if raw.len() > max + CHUNKED_OVERHEAD => return Ok(Err(mcp::Chunked::TooLarge)), mcp::Chunked::Partial => {} + other => return Ok(Err(other)), } - let mut buf = [0u8; 4096]; let n = tokio::time::timeout(crate::READ_TIMEOUT, client.read(&mut buf)).await??; if n == 0 { bail!("body cut off"); @@ -1673,6 +1686,15 @@ mod tests { assert!(exchange(&ctx, both).await.starts_with("HTTP/1.1 400")); let gzip = format!("{}0\r\n\r\n", head("Transfer-Encoding: gzip, chunked\r\n")); assert!(exchange(&ctx, gzip).await.starts_with("HTTP/1.1 400")); + // a broken chunk is told so, not just cut off + let broken = format!("{}zz\r\n{{}}\r\n0\r\n\r\n", head("Transfer-Encoding: chunked\r\n")); + let r = exchange(&ctx, broken).await; + assert!(r.starts_with("HTTP/1.1 400"), "{r}"); + // framing that never ends (trailer lines, each short) stops at the limit instead of growing without bound + let trailers = "X-A: 1\r\n".repeat((mcp::MAX_BODY + CHUNKED_OVERHEAD) / 8 + 1); + let endless = format!("{}0\r\n{trailers}", head("Transfer-Encoding: chunked\r\n")); + let r = exchange(&ctx, endless).await; + assert!(r.starts_with("HTTP/1.1 413"), "{r}"); } /// Before the login nothing is kept open: without a token a machine on the network can't hold the places diff --git a/apps/iphone-control/src/viewer/mcp.rs b/apps/iphone-control/src/viewer/mcp.rs index 1624fa9..fdb535a 100644 --- a/apps/iphone-control/src/viewer/mcp.rs +++ b/apps/iphone-control/src/viewer/mcp.rs @@ -31,7 +31,7 @@ pub async fn serve(svc: &ictl_mcp::HttpService, client: &mut Conn, head: &[u8], return Ok(()); }; let (parts, mut body) = svc.handle(req).await.into_parts(); - let chunked = !parts.headers.contains_key(http::header::CONTENT_LENGTH); + let chunked = sent_chunked(&parts); client.write_all(response_head(&parts, chunked).as_bytes()).await?; client.flush().await?; while let Some(frame) = body.frame().await { @@ -136,6 +136,12 @@ fn request(head: &[u8], body: Vec) -> Option>> { b.body(Full::new(Bytes::from(body))).ok() } +/// An answer goes out chunked when it has a body of unknown length (a stream). 1xx, 204 and 304 have no body at all +/// (RFC 9112 6.3): nothing to frame +fn sent_chunked(parts: &http::response::Parts) -> bool { + !matches!(parts.status.as_u16(), 100..=199 | 204 | 304) && !parts.headers.contains_key(http::header::CONTENT_LENGTH) +} + /// Status line and headers: `chunked` when the answer has no length (a stream). The connection closes after it fn response_head(parts: &http::response::Parts, chunked: bool) -> String { let mut out = @@ -256,6 +262,15 @@ mod tests { let (json, _) = http::Response::builder().header("content-length", "2").body(()).unwrap().into_parts(); let head = response_head(&json, false); assert!(head.contains("content-length: 2\r\n") && !head.contains("Transfer-Encoding")); + assert!(sent_chunked(&stream) && !sent_chunked(&json)); + for status in [202, 204, 304] { + let (p, _) = http::Response::builder().status(status).body(()).unwrap().into_parts(); + assert_eq!( + sent_chunked(&p), + status == 202, + "{status}: a body without a length only where there may be one" + ); + } // the request's own framing isn't passed to rmcp let r = request(b"POST /mcp HTTP/1.1\r\nHost: x\r\nTransfer-Encoding: chunked", b"{}".to_vec()).unwrap(); assert!(!r.headers().contains_key(http::header::TRANSFER_ENCODING)); diff --git a/crates/ictl-daemon/src/core.rs b/crates/ictl-daemon/src/core.rs index c6adca9..7a43bad 100644 --- a/crates/ictl-daemon/src/core.rs +++ b/crates/ictl-daemon/src/core.rs @@ -1085,13 +1085,14 @@ impl Daemon { )) }; // the lock is let go before the user is asked (below) - let app = if self.wda(&mut g).is_none() && self.native(&g) { - Box::pin(self.native_foreground(&mut g)).await.map_err(|e| unknown(e.to_string()))? - } else { - let Some(w) = self.wda(&mut g) else { + let app = match self.route(&mut g) { + Route::Wda(w) => w.active_app().await.map_err(|e| unknown(e.to_string()))?, + Route::Native => { + Box::pin(self.native_foreground(&mut g)).await.map_err(|e| unknown(e.to_string()))? + } + Route::Hid | Route::Unavailable => { return Err(unknown(ictl_l10n::tr!("WDA 不可用", "WDA unavailable").into())); - }; - w.active_app().await.map_err(|e| unknown(e.to_string()))? + } }; Target::Foreground(app) } diff --git a/crates/ictl-daemon/src/lib.rs b/crates/ictl-daemon/src/lib.rs index ec01c0d..2393fa6 100644 --- a/crates/ictl-daemon/src/lib.rs +++ b/crates/ictl-daemon/src/lib.rs @@ -175,9 +175,9 @@ async fn serve_conn(daemon: Arc, stream: tokio::net::UnixStream) { return; } // the same for WDA's MJPEG picture (iOS 17-26) - (Ok((protocol::Request::MjpegStream, _, ctx, _lang)), Ok(lease)) => { + (Ok((protocol::Request::MjpegStream, _, ctx, lang)), Ok(lease)) => { drop(lease); - mjpeg::stream(&daemon, reader, w, ctx.expect_udid).await; + ictl_l10n::scope(lang, mjpeg::stream(&daemon, reader, w, ctx.expect_udid)).await; return; } // also streams; an opened task's connection is its lease, so it isn't held against updates either diff --git a/crates/ictl-daemon/src/screen.rs b/crates/ictl-daemon/src/screen.rs index 269d78c..acdc89b 100644 --- a/crates/ictl-daemon/src/screen.rs +++ b/crates/ictl-daemon/src/screen.rs @@ -64,7 +64,8 @@ impl Drop for Viewer { g.screen_viewers = g.screen_viewers.saturating_sub(1); if low { g.low_bandwidth_viewers = g.low_bandwidth_viewers.saturating_sub(1); - // the last page in low-bandwidth mode is gone: the others get the full rate (they reconnect) + // the last page in low-bandwidth mode is gone: the others get the full rate (their connections wait + // for the new stream, see the module docs) let full = video_bitrate(&g); if g.low_bandwidth_viewers == 0 && g.screen_viewers > 0 @@ -86,6 +87,13 @@ impl Drop for Viewer { } } +/// Returns once the page's side of the connection closes. What it sends meanwhile (keyframe requests) is dropped: a +/// reopened stream asks for a keyframe anyway +async fn page_gone(reader: &mut tokio::io::BufReader) { + let mut b = [0u8; 64]; + while matches!(reader.read(&mut b).await, Ok(n) if n > 0) {} +} + impl Daemon { /// Serves one [`protocol::Request::ScreenStream`] connection until either side closes it pub(crate) async fn screen_stream( @@ -163,7 +171,13 @@ impl Daemon { if reopened > REOPEN_TRIES { return; } - let Some((f, sub)) = self.reopen_feed(expect_udid.as_deref(), low_bandwidth).await else { return }; + // the page may close meanwhile (an unlock holds the device for seconds): then don't open the + // stream again only to leave the phone "viewed" for nobody until the HID session idles out + let reopened_feed = tokio::select! { + r = self.reopen_feed(expect_udid.as_deref(), low_bandwidth) => r, + () = page_gone(&mut reader) => return, + }; + let Some((f, sub)) = reopened_feed else { return }; (feed, frames) = (f, sub); need_key = true; feed.request_keyframe(); diff --git a/crates/ictl-device/src/media.rs b/crates/ictl-device/src/media.rs index 657a349..5caceb8 100644 --- a/crates/ictl-device/src/media.rs +++ b/crates/ictl-device/src/media.rs @@ -125,7 +125,7 @@ fn receive( media_ssrc = p.ssrc; first_seq.get_or_insert(p.sequence_number); last_seq = p.sequence_number; - // 没人订阅时只记参数集,不拼帧(新订阅者会要关键帧,参数集补在它前面) + // 没人订阅时照样解包、扫一遍 NAL(要记参数集、数帧回确认),但不复制成帧、不进广播队列(新订阅者会要关键帧,参数集补在它前面) let watched = frames.receiver_count() > 0; // 新的时间戳开始了新的一帧:上一帧要是还没随 marker 结束,先把它发出去 if let Some(Some(f)) = asm.new_timestamp(p.timestamp, watched) {