[SEN] 修复实时监看按需拉流循环等待 (#54) #55

Open
ila wants to merge 34 commits from agent/codex/54-sense-liveview-on-demand into agent/codex/51-sense-auto-liveview
Owner

结果

修复 MediaMTX 按需拉流的前端/状态循环等待:

  • waiting 且有播放地址时立即加载播放器,建立第一个读取连接;
  • 会话轮询只读刷新 MediaMTX 实际状态,不重复配置路径;
  • 保持 sourceOnDemand,无人观看时不持续占用摄像机连接。

验证

  • go test ./...:通过。
  • corepack pnpm lint:0 error(806 个既有 warning)。
  • corepack pnpm build:通过(3 个既有体积 warning)。
  • Go 1.26.5 Windows 打包:通过。
  • 真实链路:MediaMTX sourceReady=true、readers=1、收到媒体字节并识别 H.264 1920×1080 + AAC;Sense 会话 waiting → ready。
  • 最终浏览器可视画面留待用户验收。

关联工单:#54。基线分支:#51。

## 结果 修复 MediaMTX 按需拉流的前端/状态循环等待: - waiting 且有播放地址时立即加载播放器,建立第一个读取连接; - 会话轮询只读刷新 MediaMTX 实际状态,不重复配置路径; - 保持 sourceOnDemand,无人观看时不持续占用摄像机连接。 ## 验证 - `go test ./...`:通过。 - `corepack pnpm lint`:0 error(806 个既有 warning)。 - `corepack pnpm build`:通过(3 个既有体积 warning)。 - Go 1.26.5 Windows 打包:通过。 - 真实链路:MediaMTX sourceReady=true、readers=1、收到媒体字节并识别 H.264 1920×1080 + AAC;Sense 会话 waiting → ready。 - 最终浏览器可视画面留待用户验收。 关联工单:#54。基线分支:#51。
ila added 11 commits 2026-08-13 15:08:47 +08:00
ila added 1 commit 2026-08-13 15:26:07 +08:00
ila added 1 commit 2026-08-13 15:26:10 +08:00
ila added 1 commit 2026-08-13 15:26:13 +08:00
ila added 1 commit 2026-08-13 15:26:13 +08:00
Author
Owner

验收反馈修复完成

已按确认方案修复浏览器“127.0.0.1 拒绝了我们的连接请求”:

  • 根因:全局 X-Frame-Options: DENY 阻止实时监看同源 iframe 加载播放器包装页。
  • 修复:仅播放器包装接口返回 SAMEORIGIN,同时 CSP 增加 frame-ancestors 'self';首页及其他接口仍为 DENY。
  • 回归测试:新增播放器嵌入边界测试,go test ./... 全部通过。
  • Windows 包:使用 Go 1.26.5 重新打包并恢复 MediaMTX,Sense 与媒体端口均已重新启动。
  • 运行验证:播放器接口 200、SAMEORIGIN、CSP 同源限制和 MediaMTX iframe 地址均正确;首页仍返回 DENY。

新增提交:3696442、703148d。PR #55 已更新。
未验证部分:最终浏览器画面由用户刷新页面后验收。工单恢复为 open / 待验收。

## 验收反馈修复完成 已按确认方案修复浏览器“127.0.0.1 拒绝了我们的连接请求”: - 根因:全局 `X-Frame-Options: DENY` 阻止实时监看同源 iframe 加载播放器包装页。 - 修复:仅播放器包装接口返回 `SAMEORIGIN`,同时 CSP 增加 `frame-ancestors 'self'`;首页及其他接口仍为 `DENY`。 - 回归测试:新增播放器嵌入边界测试,`go test ./...` 全部通过。 - Windows 包:使用 Go 1.26.5 重新打包并恢复 MediaMTX,Sense 与媒体端口均已重新启动。 - 运行验证:播放器接口 200、`SAMEORIGIN`、CSP 同源限制和 MediaMTX iframe 地址均正确;首页仍返回 `DENY`。 新增提交:`3696442`、`703148d`。PR #55 已更新。 未验证部分:最终浏览器画面由用户刷新页面后验收。工单恢复为 open / 待验收。
ila added 1 commit 2026-08-13 21:32:50 +08:00
ila added 1 commit 2026-08-13 21:32:51 +08:00
ila added 1 commit 2026-08-13 21:32:54 +08:00
ila added 1 commit 2026-08-13 21:32:56 +08:00
ila added 1 commit 2026-08-13 21:32:59 +08:00
ila added 1 commit 2026-08-13 21:33:02 +08:00
ila added 1 commit 2026-08-13 21:33:04 +08:00
Author
Owner

第二次验收反馈修复完成

本次修复了 iframe 导航认证误拒绝:

  • 播放器导航不再要求浏览器无法附加的 X-Product 请求头;
  • 仍必须同时满足有效 Sense 会话 Cookie、媒体读取权限、同源、导航模式和 iframe 目标;
  • 跨站播放器请求返回 401;
  • 普通 API 缺少 X-Product 仍返回 401;
  • 播放会话继续按用户绑定且最长两分钟。

验证:

  • go test ./... 全部通过;
  • Go 1.26.5 Windows 重新打包通过;
  • 新运行包中,不带 X-Product 的浏览器式同源 iframe 请求返回 200、SAMEORIGIN 和 frame-ancestors 'self';
  • 跨站 iframe 返回 401,普通 API 缺少产品头返回 401;
  • Sense 18080、MediaMTX 8554/8889/9997 当前均监听。

新增提交:8bf9a6d、6c6a245;PR #55 已更新。
请先退出再登录,或强制刷新后重新选择摄像机,生成新的播放会话。工单保持 open / 待验收。

## 第二次验收反馈修复完成 本次修复了 iframe 导航认证误拒绝: - 播放器导航不再要求浏览器无法附加的 `X-Product` 请求头; - 仍必须同时满足有效 Sense 会话 Cookie、媒体读取权限、同源、导航模式和 iframe 目标; - 跨站播放器请求返回 401; - 普通 API 缺少 `X-Product` 仍返回 401; - 播放会话继续按用户绑定且最长两分钟。 验证: - `go test ./...` 全部通过; - Go 1.26.5 Windows 重新打包通过; - 新运行包中,不带 `X-Product` 的浏览器式同源 iframe 请求返回 200、`SAMEORIGIN` 和 `frame-ancestors 'self'`; - 跨站 iframe 返回 401,普通 API 缺少产品头返回 401; - Sense 18080、MediaMTX 8554/8889/9997 当前均监听。 新增提交:`8bf9a6d`、`6c6a245`;PR #55 已更新。 请先退出再登录,或强制刷新后重新选择摄像机,生成新的播放会话。工单保持 open / 待验收。
ila added 1 commit 2026-08-13 22:05:28 +08:00
ila added 1 commit 2026-08-13 22:05:28 +08:00
ila added 1 commit 2026-08-13 22:05:29 +08:00
ila added 1 commit 2026-08-13 22:05:31 +08:00
ila added 1 commit 2026-08-13 22:05:32 +08:00
ila added 1 commit 2026-08-13 22:05:34 +08:00
ila added 1 commit 2026-08-13 22:05:35 +08:00
ila added 1 commit 2026-08-13 22:05:39 +08:00
ila added 1 commit 2026-08-13 22:05:40 +08:00
ila added 1 commit 2026-08-13 22:05:43 +08:00
ila added 1 commit 2026-08-13 22:05:43 +08:00
Author
Owner

第三次验收反馈修复完成

已修复播放器 stream not found:

  • MediaMTX 路径首次配置使用 add,已存在路径使用 replace;
  • MediaMTX 刚启动时,控制器在限定时间等待 localhost Control API 就绪;
  • Sense 完成数据库迁移后自动恢复所有 desired=running 路径;
  • 路径不存在现在标记为配置失败,不再误报“等待拉流”。

冷启动实测:

  • 不做人工对账,MediaMTX 配置列表自动恢复 2 条 Sense sourceOnDemand 路径;
  • 主码流实际读取成功:H.264 1920×1080 + AAC;
  • 子码流实际读取成功:H.264;
  • 两条路径均收到媒体字节;
  • Sense 18080、MediaMTX 8554/8889/9997 当前均监听。

验证:

  • go test ./... 全部通过;
  • 前端生产构建通过(3 个既有体积 warning);
  • Go 1.26.5 Windows 包重新生成;
  • 单元测试覆盖首次 add、已有 replace、控制 API 启动等待、启动恢复和缺失路径状态。

新增提交:d7cd3a5、14c9776;PR #55 已更新。
请强制刷新并重新选择摄像机。工单保持 open / 待验收。

## 第三次验收反馈修复完成 已修复播放器 `stream not found`: - MediaMTX 路径首次配置使用 add,已存在路径使用 replace; - MediaMTX 刚启动时,控制器在限定时间等待 localhost Control API 就绪; - Sense 完成数据库迁移后自动恢复所有 `desired=running` 路径; - 路径不存在现在标记为配置失败,不再误报“等待拉流”。 冷启动实测: - 不做人工对账,MediaMTX 配置列表自动恢复 2 条 Sense `sourceOnDemand` 路径; - 主码流实际读取成功:H.264 1920×1080 + AAC; - 子码流实际读取成功:H.264; - 两条路径均收到媒体字节; - Sense 18080、MediaMTX 8554/8889/9997 当前均监听。 验证: - `go test ./...` 全部通过; - 前端生产构建通过(3 个既有体积 warning); - Go 1.26.5 Windows 包重新生成; - 单元测试覆盖首次 add、已有 replace、控制 API 启动等待、启动恢复和缺失路径状态。 新增提交:`d7cd3a5`、`14c9776`;PR #55 已更新。 请强制刷新并重新选择摄像机。工单保持 open / 待验收。
You are not authorized to merge this pull request.
This pull request can be merged automatically.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin agent/codex/54-sense-liveview-on-demand:agent/codex/54-sense-liveview-on-demand
git checkout agent/codex/54-sense-liveview-on-demand
Sign in to join this conversation.