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
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<Version>11.0.3</Version>
<Version>11.0.4</Version>
<SkillName>bb-hikvision</SkillName>
</PropertyGroup>

Expand All @@ -12,7 +12,6 @@

<ItemGroup>
<PackageReference Include="BootstrapBlazor" Version="$(BBVersion)" />
<PackageReference Include="BootstrapBlazor.MediaMtx" Version="11.0.1" />
</ItemGroup>

<ItemGroup>
Expand All @@ -28,4 +27,9 @@
<EmbeddedResource Include="Locales\*.json" />
</ItemGroup>

<ItemGroup>
<None Remove="readme.md" />
<None Include="README.HikVision.md" Pack="true" PackagePath="" />
</ItemGroup>

</Project>

This file was deleted.

This file was deleted.

11 changes: 0 additions & 11 deletions src/components/BootstrapBlazor.HikVision/Locales/en.json

This file was deleted.

11 changes: 0 additions & 11 deletions src/components/BootstrapBlazor.HikVision/Locales/zh.json

This file was deleted.

47 changes: 1 addition & 46 deletions src/components/BootstrapBlazor.HikVision/README.HikVision.md
Original file line number Diff line number Diff line change
@@ -1,56 +1,11 @@
# BootstrapBlazor.HikVision

海康威视摄像机预览组件,包括通过 MediaMTX 播放页面预览的 `HikVisionWebRtc`,以及依赖海康 WebSDK 的 `HikVisionWebPlugin`。

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 · HikVision examples fail to compile

When users follow the MediaMTX example or upgrade an application using HikVisionWebRtc to 11.0.4, HikVisionWebRtc is no longer included, so the documented Razor element and existing calls fail compilation; shipping that removal in 11.0.4 also breaks callers without a major-version signal.

Keep HikVisionWebRtc available in this release, or defer its removal to a major release after updating the integration guidance.

Also at src/components/BootstrapBlazor.HikVision/skills/bb-hikvision/SKILL.md:8, src/components/BootstrapBlazor.HikVision/README.HikVision.md:25.

Prompt for AI agents
In `src/components/BootstrapBlazor.HikVision/README.HikVision.md` at line 3:

**HikVision examples fail to compile**

When users follow the MediaMTX example or upgrade an application using `HikVisionWebRtc` to 11.0.4, `HikVisionWebRtc` is no longer included, so the documented Razor element and existing calls fail compilation; shipping that removal in 11.0.4 also breaks callers without a major-version signal.

Keep `HikVisionWebRtc` available in this release, or defer its removal to a major release after updating the integration guidance.

Also at `src/components/BootstrapBlazor.HikVision/skills/bb-hikvision/SKILL.md:8`, `src/components/BootstrapBlazor.HikVision/README.HikVision.md:25`.

From AGENTS.md L23:

复用现有能力,保留用户的已有改动和公开 API 行为

From docs/agents/component-checklist.md L5:

保留已有调用方式和所支持框架的行为

海康威视摄像机预览组件,包括依赖海康 WebSDK 的 `HikVisionWebPlugin`。

```powershell
dotnet add package BootstrapBlazor.HikVision
```

## WebRTC 预览

`HikVisionWebRtc` 使用服务端 `BootstrapBlazor.MediaMtx` 管理网关和登记摄像头,再以 iframe 展示播放页面。网关由服务管理,组件不负责下载工具或管理进程;此方案需要支持运行进程的服务端宿主,不适用于独立 WebAssembly 宿主。

在服务端注册:

```csharp
builder.Services.AddBootstrapBlazor();
builder.Services.AddMediaMtxService();
```

在已授权的 Interactive Server 页面使用:

```razor
@using BootstrapBlazor.Components

<HikVisionWebRtc Options="@camera" Title="入口摄像头" />

@code {
private readonly MediaMtxCameraOptions camera = new()
{
Path = "entrance",
RtspUrl = "rtsp://192.0.2.1:554/Streaming/Channels/101"
};
}
```

组件仅在首次交互渲染时启动网关并登记摄像头,预渲染不会启动。`Options` 未设置时显示配置缺失提示;异步加载配置时,应等配置就绪后再创建组件。首次渲染后的配置更改不会重新登记,重试或更换摄像头源时需要重新创建组件实例。

默认服务要求 `Path` 非空,`RtspUrl` 为不含用户信息的绝对 RTSP/RTSPS 地址。凭据使用 `UserName`、`Password` 由服务端安全配置提供,不要写入地址、日志或浏览器存储。登记成功只表示网关接受配置,不代表摄像机在线或已有首帧。相同路径的更新或删除会影响所有观看者。

`PlayUrl` 为 `null` 时由服务生成播放地址,空字符串无效;自定义地址必须是不含凭据的绝对 HTTP/HTTPS 地址。`IsMuted` 默认保留原地址及其 `muted` 参数;设为 `false` 时写入 `muted=false`,有声自动播放仍受浏览器策略限制。`Title` 默认为 `WebRTC`,用作 iframe 无障碍标题。

首次使用前需单独部署 MediaMTX 原生工具,例如使用独立的 `BootstrapBlazor.MediaMtx.Cli`:

```powershell
dotnet tool install -g BootstrapBlazor.MediaMtx.Cli --prerelease
bb-mediamtx --download
bb-mediamtx --copy --output .\publish
```

`--download` 未指定 `--rid` 时准备本机平台的缓存,指定具体 RID 时只准备该平台,指定 `--rid all` 时准备全部支持平台。`--copy` 从缓存复制到指定目录的 `mediamtx-tools\<RID>`,未指定 RID 时复制本机平台;跨平台复制需指定目标 `--rid`。组合 `--download --copy --rid all` 时会准备全部平台缓存,但只复制本机平台;`--copy --rid all` 无效。CLI 失败时输出警告,但仍以成功状态退出,应检查提示和目标文件。服务不会自动下载工具;工具缺失、网关启动失败和摄像头登记失败分别显示对应提示。

默认网关的 HTTP、Control API 和 ICE 仅监听回环地址。远程播放需要可达的信令和媒体路径、HTTPS 与鉴权;仅设置 `WebRtcPublicUrl` 或 `PlayUrl` 不会改变 ICE 地址。工具部署、配置及安全限制详见 `BootstrapBlazor.MediaMtx` 包文档。

## WebSDK 插件

`HikVisionWebPlugin` 使用浏览器端海康 WebSDK,需先等待 `OnInitedAsync` 返回初始化状态,再调用 `Login`。登录成功后通过 `OnGetChannelsAsync` 接收通道信息;登录失败可检查 `LoginErrorCode` 和 `LoginErrorMessage`。
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,58 +5,7 @@ description: 随 BootstrapBlazor.HikVision NuGet 包提供的 API 参考。需

# HikVision 使用参考

先读 [references/llms.txt](references/llms.txt),再查 [HikVisionWebPlugin](references/components/HikVisionWebPlugin.txt) 或 [HikVisionWebRtc](references/components/HikVisionWebRtc.txt)。以实际引用版本和源码为准,不编造参数。

## WebRTC 预览

HikVision 引用 `BootstrapBlazor.MediaMtx`。在服务端注册:

```csharp
builder.Services.AddBootstrapBlazor();
builder.Services.AddMediaMtxService();
```

在已授权的 Interactive Server 页面直接渲染:

```razor
<HikVisionWebRtc Options="@camera" Title="入口摄像头" />

@code {
private readonly MediaMtxCameraOptions camera = new()
{
Path = "entrance",
RtspUrl = "rtsp://192.0.2.1:554/Streaming/Channels/101"
};
}
```

示例源未配置认证;需要认证时从服务器安全配置提供 `UserName`、`Password`。WebRTC 网关需要可运行进程的服务端宿主,不支持独立 WebAssembly。

### 初始化与展示

- `Options` 类型为 `MediaMtxCameraOptions`。组件首次交互渲染时依次调用 `EnsureStartedAsync()`、`AddOrUpdateAsync(Options)`,成功后显示 iframe;预渲染不启动网关。
- 初始化中显示黑底 16:9 占位;未配置、工具缺失、网关启动失败和摄像头登记失败显示本地化提示,异常记录到服务端日志。登记成功不代表已有视频首帧。
- 首次交互渲染后修改 `Options` 不会重新登记;异步配置应就绪后再创建组件。重试或更改摄像头配置时重新创建实例,可使用 `@key`。
- 即使指定 `Options.PlayUrl`,也必须完成网关启动与摄像头登记。组件不下载工具、不直接管理进程或调用 Control API。
- 销毁组件会取消未完成的初始化,不删除已登记路径、不停止就绪网关;取消不保证撤销已提交的登记。

| 参数 | 行为 |
| --- | --- |
| `Options` | 摄像头路径、RTSP 源和凭据;`PlayUrl` 可覆盖生成的播放地址。 |
| `Title` | 默认 `WebRTC`,作为 iframe 无障碍标题。 |
| `IsMuted` | 默认 `true`,保留原 URL 及已有 `muted` 参数;设为 `false` 写入 `muted=false`,有声自动播放仍受浏览器限制。 |

容器支持附加 `class`、`style`。iframe 允许自动播放、全屏并设置 `referrerpolicy="no-referrer"`;HTTPS 页面应使用 HTTPS 播放地址,代理须允许 BB 页面嵌入。

### 网关与播放配置

- 提前用 `bb-mediamtx --download --copy --output <应用目录>` 部署原生工具,跨平台加 `--rid`。工具默认在应用目录 `mediamtx-tools\<RID>`,缺失时组件提示错误,不自动安装。
- 自管模式必须通过安全配置源提供 `MediaMtxOptions:ApiPassword`;API 密码不是摄像头密码或播放密码。详细部署和服务规则见 MediaMtx 包的 `bb-mediamtx` skill 与 README。
- `RtspUrl` 必须是无用户信息的绝对 RTSP/RTSPS 地址。`Path` 标识共享摄像头路径,不同源使用不同路径;更新同一路径会影响其他观看者。
- `PlayUrl` 留为 `null` 时,使用 `WebRtcPublicUrl` 或默认 `http://127.0.0.1:<WebRtcPort>/` 加 `Path/`。空字符串无效;单路 URL 覆盖不更改监听、来源或 ICE。
- 自管网关公网部署需设置 `WebRtcPublicUrl`、`WebRtcConfigPath`,自行部署 YAML 片段并配置复制。HTTPS/nginx 负责播放页和信令,媒体另需可达的 UDP ICE 地址与端口;仅替换播放 URL 不够。
- 同一用户的宿主可复用网关;指纹变化且目标进程路径相同时会自动重启,打断所有共享观看者。宿主退出后网关继续运行,动态路径在网关重启后需重新登记。
- 网关不自动转码,视频、音频编码须兼容浏览器。音频可使用 G.711 μ-law(PCMU)或 A-law(PCMA);默认静音,需要时取消静音。
先读 [references/llms.txt](references/llms.txt),再查 [HikVisionWebPlugin](references/components/HikVisionWebPlugin.txt)。以实际引用版本和源码为准,不编造参数。

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 · Stale skill description

The issue asks to keep the package documentation focused on HikVision-specific WebSDK components. The skill description still says it covers WebRTC preview APIs, although the updated reference directs users only to HikVisionWebPlugin.

Prompt for AI agents
In `src/components/BootstrapBlazor.HikVision/skills/bb-hikvision/SKILL.md` at line 8:

**Stale skill description**

The issue asks to keep the package documentation focused on HikVision-specific WebSDK components. The skill description still says it covers WebRTC preview APIs, although the updated reference directs users only to HikVisionWebPlugin.

From #1405:

Keep the package focused on HikVision-specific WebSDK components and documentation.


## WebSDK 插件

Expand Down
Loading