Repository navigation
feat(MediaMtx): refactor runtime camera management #1387
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the Apache 2.0 License | ||
| // See the LICENSE file in the project root for more information. | ||
| // Maintainer: Argo Zhang([email protected]) Website: https://www.blazor.zone | ||
|
|
||
| namespace BootstrapBlazor.Components; | ||
|
|
||
| /// <summary> | ||
| /// <para lang="zh">服务端动态摄像头管理。调用方负责身份认证、权限检查和 RTSP 目标地址的访问策略。</para> | ||
| /// <para lang="en">Server-side dynamic camera management. Callers must enforce authentication, authorization and RTSP destination access policies.</para> | ||
| /// <para lang="zh">默认实现处理有效的摄像头登记和删除请求时,若网关未运行则抛出 <see cref="InvalidOperationException"/>。</para> | ||
| /// <para lang="en">The default implementation throws <see cref="InvalidOperationException"/> for valid camera registration and deletion requests when the gateway is not running.</para> | ||
| /// <para><version>11.0.0</version></para> | ||
| /// </summary> | ||
| public interface IMediaMtxService | ||
| { | ||
| /// <summary> | ||
| /// <para lang="zh">确保网关已启动并就绪,失败时抛出异常。默认实现复用本宿主的运行中进程;工具缺失时需手动部署。</para> | ||
| /// <para lang="en">Ensures the gateway is running and ready, throwing an exception on failure. The default service reuses its running process; missing tools must be deployed manually.</para> | ||
| /// <para><version>11.0.0</version></para> | ||
| /// </summary> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ⚪ Low · Startup API shows the wrong release version The new Mark Prompt for AI agentsIn `src/components/BootstrapBlazor.MediaMtx/IMediaMtxService.cs` at line 21:
**Startup API shows the wrong release version**
The new `EnsureStartedAsync` API is marked as introduced in 11.0.0 even though the package project version is 11.0.1. Generated API documentation therefore reports it as available in the wrong release.
Mark `EnsureStartedAsync` with version 11.0.1.From - XML 注释遵循 [BB 组件规范](https://github.com/dotnetcore/BootstrapBlazor/blob/main/docs/agents/component-checklist.md#参数与-api)。新增 API 时标记其所属扩展包计划发布的正式版本;修改已有 API 时保留其引入版本。 |
||
| /// <param name="cancellationToken"><para lang="zh">取消令牌。</para><para lang="en">The cancellation token.</para></param> | ||
| /// <returns><para lang="zh">网关就绪时完成的任务。</para><para lang="en">A task that completes when the gateway is ready.</para></returns> | ||
| /// <exception cref="MediaMtxToolNotFoundException"><para lang="zh">默认实现找不到网关工具。</para><para lang="en">The default implementation cannot find the gateway tool.</para></exception> | ||
| Task EnsureStartedAsync(CancellationToken cancellationToken = default); | ||
|
|
||
| /// <summary> | ||
| /// <para lang="zh">由宿主设置已就绪网关的 Control API 密码;传入 null 表示网关已停止。</para> | ||
| /// <para lang="en">Sets the Control API password for the ready gateway; null indicates that the gateway has stopped. Intended for use by the host.</para> | ||
| /// <para><version>11.0.0</version></para> | ||
| /// </summary> | ||
| /// <param name="apiPassword"><para lang="zh">网关密码,或表示停止的 null。</para><para lang="en">The gateway password, or null when stopped.</para></param> | ||
| /// <returns><para lang="zh">状态更新成功时为 true;默认实现更新状态并清除已登记路径记录。</para><para lang="en">True when the state is updated; the default implementation updates the state and clears its registered path records.</para></returns> | ||
| Task<bool> SetGatewayStateAsync(string? apiPassword); | ||
|
|
||
| /// <summary> | ||
| /// <para lang="zh">登记新路径或更新已有路径的摄像头源配置,返回播放 URL。摄像头 PlayUrl 为 null 时使用 WebRtcPublicUrl 或同机回环地址与 Path 生成地址;空字符串不是有效的播放地址。更新可能中断现有播放;成功不代表源已连通。</para> | ||
| /// <para lang="en">Registers a new path or updates the camera source configuration and returns its playback URL. When the camera's PlayUrl is null, builds the URL from WebRtcPublicUrl or the loopback address and Path; an empty string is not a valid playback URL. Updates may interrupt existing playback; success does not verify source connectivity.</para> | ||
| /// <para><version>11.0.0</version></para> | ||
| /// </summary> | ||
| /// <param name="camera"><para lang="zh">由管理 UI 提交的摄像头配置。</para><para lang="en">Camera configuration submitted by the management UI.</para></param> | ||
| /// <param name="cancellationToken"><para lang="zh">取消令牌。</para><para lang="en">The cancellation token.</para></param> | ||
| /// <returns><para lang="zh">播放 URL;自定义实现可返回 null 表示登记失败。默认实现失败时抛出异常。</para><para lang="en">The playback URL; custom implementations may return null on failure. The default implementation throws on failure.</para></returns> | ||
| Task<string?> AddOrUpdateAsync(MediaMtxCameraOptions camera, CancellationToken cancellationToken = default); | ||
|
|
||
| /// <summary> | ||
| /// <para lang="zh">显式删除摄像头路径,影响所有观看者;默认实现删除不存在的路径时抛出异常。</para> | ||
| /// <para lang="en">Explicitly deletes a camera path for all viewers. The default implementation throws when the path does not exist.</para> | ||
| /// <para><version>11.0.0</version></para> | ||
| /// </summary> | ||
| /// <param name="path"><para lang="zh">要删除的摄像头路径。</para><para lang="en">The camera path to delete.</para></param> | ||
| /// <param name="cancellationToken"><para lang="zh">取消令牌。</para><para lang="en">The cancellation token.</para></param> | ||
| /// <returns><para lang="zh">删除成功时为 true;自定义实现可返回 false 表示失败,默认实现失败时抛出异常。</para><para lang="en">True when deleted; custom implementations may return false on failure, while the default implementation throws.</para></returns> | ||
| Task<bool> RemoveAsync(string path, CancellationToken cancellationToken = default); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the Apache 2.0 License | ||
| // See the LICENSE file in the project root for more information. | ||
| // Maintainer: Argo Zhang([email protected]) Website: https://www.blazor.zone | ||
|
|
||
| namespace BootstrapBlazor.Components; | ||
|
|
||
| /// <summary> | ||
| /// <para lang="zh">由服务端配置或 UI 提供的摄像头配置,不应持久化到浏览器或写入日志。</para> | ||
| /// <para lang="en">Camera configuration supplied by server-side configuration or UI. Do not persist it in the browser or write it to logs.</para> | ||
| /// <para><version>11.0.0</version></para> | ||
| /// </summary> | ||
| public sealed class MediaMtxCameraOptions | ||
| { | ||
| /// <summary> | ||
| /// <para lang="zh">获得/设置唯一的播放路径。建议调用方限制为小写字母开头,后接小写字母、数字或连字符,最长 63 个字符,排除名称 all;默认服务仅检查非空。例如:camera01</para> | ||
| /// <para lang="en">Gets or sets the unique playback path. Callers should restrict it to a lowercase letter followed by lowercase letters, digits or hyphens, up to 63 characters, excluding all; the default service only checks that it is nonempty. For example: camera01</para> | ||
| /// <para><version>11.0.0</version></para> | ||
| /// </summary> | ||
| public string? Path { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// <para lang="zh">获得/设置浏览器访问的完整 HTTP 或 HTTPS 播放页面地址,不应包含凭据。为 null 时使用网关 WebRtcPublicUrl 或本机地址与 Path 生成播放地址;空字符串无效。此选项不改变网关监听和 ICE 配置。</para> | ||
| /// <para lang="en">Gets or sets the complete browser-facing HTTP or HTTPS player URL without credentials. When null, the URL is built from WebRtcPublicUrl or the loopback address and Path; an empty string is invalid. This option does not change listener or ICE configuration.</para> | ||
| /// <para><version>11.0.1</version></para> | ||
| /// </summary> | ||
| public string? PlayUrl { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// <para lang="zh">获得/设置不含用户信息的绝对 RTSP 或 RTSPS 地址,必须包含主机名。建议显式指定端口和流路径,不要在查询字符串中放置凭据。例如:rtsp://192.168.1.100:554/Streaming/Channels/101</para> | ||
| /// <para lang="en">Gets or sets the absolute RTSP or RTSPS URL with a host and without user information. Specify the port and stream path explicitly, and do not put credentials in the query string. For example: rtsp://192.168.1.100:554/Streaming/Channels/101</para> | ||
| /// <para><version>11.0.0</version></para> | ||
| /// </summary> | ||
| public string? RtspUrl { get; set; } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟠 High · Existing camera integrations break When an upgraded host retains Restore a compatibility path for Also at Prompt for AI agentsIn `src/components/BootstrapBlazor.MediaMtx/MediaMtxCameraOptions.cs` at line 34:
**Existing camera integrations break**
When an upgraded host retains `Url` in static camera configuration, an existing caller uses the former service contract, or a user follows the bundled HikVision skill, `MediaMtxCameraOptions` exposes `RtspUrl` instead of `Url`, so the skill no longer compiles and retained configuration leaves `RtspUrl` null; `BuildRtspSourceUrl` rejects that source, preventing registration. The changed `IMediaMtxService` return types also break existing callers and implementations at compile time and break already-built callers at runtime.
Restore a compatibility path for `Url` and the former service signatures, exposing the new behavior through additive APIs.
Also at `src/components/BootstrapBlazor.MediaMtx/IMediaMtxService.cs:34`, `src/components/BootstrapBlazor.MediaMtx/IMediaMtxService.cs:44`, `src/components/BootstrapBlazor.MediaMtx/IMediaMtxService.cs:54`.From 保留已有公开签名和接口约定。 |
||
|
|
||
| /// <summary> | ||
| /// <para lang="zh">获得/设置未进行 URL 编码的摄像头用户名。</para> | ||
| /// <para lang="en">Gets or sets the camera user name without URL encoding.</para> | ||
| /// <para><version>11.0.0</version></para> | ||
| /// </summary> | ||
| public string? UserName { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// <para lang="zh">获得/设置未进行 URL 编码的摄像头密码。未提供用户名时默认服务忽略密码。</para> | ||
| /// <para lang="en">Gets or sets the camera password without URL encoding. The default service ignores the password when no user name is supplied.</para> | ||
| /// <para><version>11.0.0</version></para> | ||
| /// </summary> | ||
| public string? Password { get; set; } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 Medium · Requested service interface
The issue asks for an
IRtspServiceexposing camera-path operations. The change provides those operations onIMediaMtxServiceinstead, so consumers looking for the requested interface cannot use that API as specified.Prompt for AI agents
From #1366: