Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion BootstrapBlazor.Extensions.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
<Project Path="src/components/BootstrapBlazor.Live2DDisplay/BootstrapBlazor.Live2DDisplay.csproj" />
<Project Path="src/components/BootstrapBlazor.Markdown/BootstrapBlazor.Markdown.csproj" />
<Project Path="src/components/BootstrapBlazor.MaterialDesign/BootstrapBlazor.MaterialDesign.csproj" />
<Project Path="src/components/BootstrapBlazor.MediaMtx/BootstrapBlazor.MediaMtx.csproj" />
<Project Path="src/components/BootstrapBlazor.MeiliSearch/BootstrapBlazor.MeiliSearch.csproj" />
<Project Path="src/components/BootstrapBlazor.Mermaid/BootstrapBlazor.Mermaid.csproj" />
<Project Path="src/components/BootstrapBlazor.MindMap/BootstrapBlazor.MindMap.csproj" />
Expand Down Expand Up @@ -78,7 +79,6 @@
<Project Path="src/extensions/BootstrapBlazor.DataAccess.FreeSql/BootstrapBlazor.DataAccess.FreeSql.csproj" />
<Project Path="src/extensions/BootstrapBlazor.DataAccess.PetaPoco/BootstrapBlazor.DataAccess.PetaPoco.csproj" />
<Project Path="src/extensions/BootstrapBlazor.DataAccess.SqlSugar/BootstrapBlazor.DataAccess.SqlSugar.csproj" />
<Project Path="src/extensions/BootstrapBlazor.MediaMtx/BootstrapBlazor.MediaMtx.csproj" />
<Project Path="src/extensions/BootstrapBlazor.OpcDa/BootstrapBlazor.OpcDa.csproj" />
<Project Path="src/extensions/BootstrapBlazor.OpcUa/BootstrapBlazor.OpcUa.csproj" />
<Project Path="src/extensions/BootstrapBlazor.SignalR.Client/BootstrapBlazor.SignalR.Client.csproj" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Version>11.0.0</Version>
<Version>11.0.1</Version>
<SkillName>bb-mediamtx</SkillName>
</PropertyGroup>

Expand All @@ -12,11 +12,11 @@
</PropertyGroup>

<ItemGroup>
<SupportedPlatform Remove="browser" />
<PackageReference Include="BootstrapBlazor" Version="$(BBVersion)" />
</ItemGroup>

<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<SupportedPlatform Remove="browser" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public interface IMediaMtxProcessLauncher
bool IsSupported { get; }

/// <summary>
/// <para lang="zh">使用宿主提供的配置启动 MediaMTX 进程。</para>
/// <para lang="en">Starts the MediaMTX process using the host-provided configuration.</para>
/// <para lang="zh">使用服务提供的配置启动 MediaMTX 进程。默认服务负责就绪探测和清理返回的进程。</para>
/// <para lang="en">Starts the MediaMTX process using the service-provided configuration. The default service probes readiness and cleans up the returned process.</para>
/// <para><version>11.0.0</version></para>
/// </summary>
/// <param name="startInfo"><para lang="zh">进程启动配置。</para><para lang="en">The process start configuration.</para></param>
Expand Down
55 changes: 55 additions & 0 deletions src/components/BootstrapBlazor.MediaMtx/IMediaMtxService.cs
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

Copy link
Copy Markdown

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 IRtspService exposing camera-path operations. The change provides those operations on IMediaMtxService instead, so consumers looking for the requested interface cannot use that API as specified.

Prompt for AI agents
In `src/components/BootstrapBlazor.MediaMtx/IMediaMtxService.cs` at line 15:

**Requested service interface**

The issue asks for an `IRtspService` exposing camera-path operations. The change provides those operations on `IMediaMtxService` instead, so consumers looking for the requested interface cannot use that API as specified.

From #1366:

Expose a server-side IRtspService for adding, updating, and removing camera paths.

{
/// <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>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚪ Low · 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.

Prompt for AI agents
In `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 docs/agents/component-checklist.md L6:

- 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);
}
49 changes: 49 additions & 0 deletions src/components/BootstrapBlazor.MediaMtx/MediaMtxCameraOptions.cs
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; }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 High · 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.

Prompt for AI agents
In `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 AGENTS.md L18:

保留已有公开签名和接口约定。


/// <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; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
namespace BootstrapBlazor.Components;

/// <summary>
/// <para lang="zh">从服务器配置的 MediaMtx 节读取的 MediaMTX 网关选项。</para>
/// <para lang="en">MediaMTX gateway options bound from the server's MediaMtx configuration section.</para>
/// <para lang="zh">从服务器配置的 MediaMtxOptions 节读取的 MediaMTX 网关选项。</para>
/// <para lang="en">MediaMTX gateway options bound from the server's MediaMtxOptions configuration section.</para>
/// <para><version>11.0.0</version></para>
/// </summary>
public sealed class MediaMtxOptions
Expand All @@ -22,15 +22,15 @@ public sealed class MediaMtxOptions
public int ApiPort { get; set; } = 9997;

/// <summary>
/// <para lang="zh">获得/设置网关启动时自动登记的摄像头,键为播放路径,值中的 Path 被忽略。密码应通过 User Secrets 或环境变量等安全配置源提供。</para>
/// <para lang="en">Gets or sets the cameras registered automatically when the gateway starts. Keys are playback paths, and the Path value of each entry is ignored. Supply passwords through a secure configuration source such as User Secrets or environment variables.</para>
/// <para lang="zh">获得/设置网关启动时配置的摄像头,键为播放路径,值中的 Path 和 PlayUrl 被忽略。密码应通过安全配置源提供;环境变量可能被子进程继承。</para>
/// <para lang="en">Gets or sets the cameras configured when the gateway starts. Keys are playback paths; Path and PlayUrl in each value are ignored. Supply passwords through a secure configuration source; environment variables may be inherited by child processes.</para>
/// <para><version>11.0.0</version></para>
/// </summary>
public Dictionary<string, MediaMtxCameraOptions> Cameras { get; set; } = new();

/// <summary>
/// <para lang="zh">获得/设置 MediaMTX 可执行文件路径,默认按当前系统和架构选择应用目录 mediamtx-tools 子目录下的工具。相对路径以应用目录为基准,文件不存在时不启动网关。</para>
/// <para lang="en">Gets or sets the MediaMTX executable path. By default, the tool is selected under the application directory's mediamtx-tools subdirectory according to the current OS and architecture. Relative paths are resolved against the application directory; the gateway is not started when the file does not exist.</para>
/// <para lang="zh">获得/设置 MediaMTX 可执行文件路径,默认按当前系统和架构选择应用目录 mediamtx-tools 子目录下的工具。相对路径以应用目录为基准;工具需预先手动部署。</para>
/// <para lang="en">Gets or sets the MediaMTX executable path. Defaults to the current platform's tool under the application's mediamtx-tools directory. Relative paths use the application directory; the tool must be deployed manually in advance.</para>
/// <para><version>11.0.0</version></para>
/// </summary>
public string MediaMtxPath { get; set; } = Path.Combine("mediamtx-tools",
Expand Down
Loading
Loading