Commit Graph

4646 Commits

Author SHA1 Message Date
ceoicac
da9b2017fb fix(rtsp): 保留 Content-Base 末尾斜杠,适配严格匹配的 RTSP 服务器 (#4820)
---

## 标题

```
fix(rtsp): 保留 Content-Base 末尾斜杠,适配严格匹配的 RTSP 服务器
```

## 描述

```markdown
## 问题描述

使用 `addStreamProxy` 拉流地址形如 `rtsp://<ip>/live` 时(注意 URL 末尾无斜杠),
部分 RTSP 服务器(例如 Alltech streaming server)会在 DESCRIBE 响应中返回
**带末尾斜杠**的 `Content-Base`:

```
Content-Base: rtsp://192.168.16.108:8554/live/
```

这类服务器对后续 PLAY 请求的 URL 做**精确字符串匹配**。

ZLMediaKit 原实现会去掉 `_content_base` 末尾的 `/`,随后发送无斜杠的 PLAY 请求:

```
PLAY rtsp://192.168.16.108:8554/live RTSP/1.0
```

服务器匹配失败,返回 `404 Stream Not Found`。

## 现象佐证

- 用 VLC 直接播放同一个 `rtsp://<ip>/live` 源**可以正常播放**,说明源本身正常;
- 用 VLC 播放经 ZLM 转出的流同样失败,说明问题出在 ZLM 拉流环节的 URL 处理;
- 日志中明确出现 `404 Stream Not Found`。

## 根因

`RtspPlayer::handleResDESCRIBE` 中以下代码去掉了 `_content_base` 的末尾斜杠:

```cpp
if (_content_base.back() == '/') {
    _content_base.pop_back();
}
```

导致 PLAY 请求使用与 `Content-Base` 不一致、去掉斜杠后的 URL。

## 修复内容

1. `src/Rtsp/RtspPlayer.cpp`
   - 移除去掉 `_content_base` 末尾斜杠的 `pop_back` 逻辑,保留 `Content-Base` 原始内容(含末尾斜杠),
     使 PLAY 请求发送与服务器 `Content-Base` 完全一致的 URL。

2. `src/Rtsp/Rtsp.cpp`
   - `SdpTrack::getControlUrl` 在拼接前先去除 `base_url` 末尾斜杠,
     避免 `_content_base` 带斜杠时 SETUP 的 track URL 被错误拼接为 `rtsp://<ip>/live//<track>` 这样的双斜杠。

## 影响范围

- 对返回不带末尾斜杠 `Content-Base` 的标准服务器:行为完全不变(原 `pop_back` 仅在末尾有 `/` 时生效)。
- 对返回带末尾斜杠 `Content-Base` 的服务器:由"去斜杠"改为"保留原始斜杠",修复 404 问题。

## 测试

- 环境:拉流 `rtsp://192.168.16.108:8554/live`(Content-Base 带末尾斜杠)。
- 修复前:PLAY 请求报 `404 Stream Not Found`,无法拉流。
- 修复后:拉流成功,RTSP 可正常播放。

---

## 提交说明(可选,供参考)

- [x] 已本地编译通过
- [x] 已在目标服务器验证可正常拉流
```

---
2026-09-08 15:05:50 +08:00
Xiaofeng Wang
5793bb56fe fix: discard invalid RTP packets (#4823)
## 问题

部分海康 RTSP 流的首个 RTP 包使用 version 1。当前 `inputRtp` 对 version 非法的 RTP 包抛出异常。

## 修改

- 对 version 非法的 RTP 包记录警告日志并返回 `nullptr` 丢弃。
- RTP 头长度不足和 payload 长度非法时仍抛出 `BadRtpException`,保留 RTP-over-TCP 的重同步机制。
- 保持后续合法 RTP 包的处理逻辑不变。
2026-09-08 15:05:02 +08:00
xiongziliang
296dcebe8f 优化配置项读取 2026-09-03 21:20:19 +08:00
xiongziliang
9f90548a67 修复编译问题 2026-08-27 23:18:00 +08:00
xiongziliang
2fa5398073 修复webrtc播放时插入sps pps rtp相关字段不正确的bug 2026-08-27 23:10:50 +08:00
xiongziliang
2049df6d1a webrtc whip拉流支持直接代理模式 2026-08-27 23:10:43 +08:00
xiongziliang
d554ba1c0c 修复webrtc sdp中不传递aac fmtp的bug 2026-08-27 23:10:37 +08:00
xiongziliang
43be587b74 修复webrtc offer sdp aac payload type冲突的bug 2026-08-27 23:10:02 +08:00
xiongziliang
2bc239fca7 更新ZLToolKit 2026-08-27 23:09:39 +08:00
xiongziliang
70bd146aa6 fix(rtsp): 修复RTSP传输模式字符串格式问题(#4797) 2026-08-26 17:59:44 +08:00
xiongziliang
034eae91ad 更新ZLToolKit 2026-08-26 17:53:58 +08:00
xiongziliang
39eac339d5 修复ice建连成功前关闭WebRtcTransport对象失败的bug 2026-08-26 17:52:35 +08:00
xiongziliang
fdaec2604d 修复访问空指针的bug 2026-08-21 13:22:38 +08:00
xiongziliang
ee42f6b2c2 修复rtsp点播seek与直播时间戳相关的bug (#4802) 2026-08-20 21:43:56 +08:00
mtdxc
d072f0f4d4 修复vp9无法秒开bug (#4815) 2026-08-20 16:47:01 +08:00
xiongziliang
9fbe034a8a 优化webrtc批量发送性能 2026-08-16 14:31:59 +08:00
Caner Ateş
992e34ab90 Fix publish failure from non-standard RTMP publishers (#4800)
## 问题 / Problem

部分摄像机(实测:宇视/Uniview)推流时,在 `@setDataFrame` 之前插入了 **2 个多余的 AMF0 number(共
18 字节)**。抓包结果:

Some publishers (verified with a Uniview camera) insert **two redundant
AMF0 numbers (18 bytes)** before `@setDataFrame`. Captured bytes:

```
44 00 00 28 00 00 a9 12   <- chunk header, type 0x12 (AMF0_DATA), body_size 169
00 0000000000000000        <- AMF0 number 0.0   (多余 / redundant)
00 0000000000000000        <- AMF0 number 0.0   (多余 / redundant)
02 00 0d "@setDataFrame"   <- 按标准应从这里开始 / message should start here
02 00 0a "onMetaData" ...
```

`RtmpSession::onRtmpChunk()` 在 `MSG_DATA` 分支中无条件把首个 AMF 元素当作字符串读取,遇到
`0x00`(number)标记时 `amf.cpp` 抛出 `Expected a string`,异常未被捕获,推流连接被断开。

`RtmpSession::onRtmpChunk()` reads the first AMF element as a string
unconditionally in the `MSG_DATA` branch. With a `0x00` (number) marker,
`amf.cpp` throws `Expected a string`; the exception is not caught and
the publisher is dropped.

nginx-rtmp 可以正常接收同一路流,ZLMediaKit 无法接收。

nginx-rtmp accepts the very same stream; ZLMediaKit does not.

### 修复前日志 / Log before the fix

```
RtmpSession.cpp:130 | publish 回复时间:2ms
TcpServer.cpp:210   | on err: 6(Expected a string)
RtmpSession.cpp:28  | RTMP推流器(__defaultVhost__/live/stream)断开:Expected a string,耗时(s):0
```

## 修改内容 / Changes

新增 `amfLoadLeadingString()`,跳过前置的非字符串 AMF 值后再取首个字符串。该写法参考了 `FlvSplitter`
中已有的防御式解析(先 `load<AMFValue>()`
再判断类型),并把它统一成一个公共函数。`AMFDecoder::remain()` 用于限定循环边界,避免缓冲区读完后再次抛异常。

Add `amfLoadLeadingString()`, which skips leading non-string AMF values
before returning the first string. This generalizes the defensive
parsing already present in `FlvSplitter` (`load<AMFValue>()` followed by
a type check) into one shared helper. `AMFDecoder::remain()` bounds the
loop so it does not throw once the buffer is exhausted.

- `amf.h` / `amf.cpp` — 新增 `remain()` 与 `amfLoadLeadingString()` / add
`remain()` and `amfLoadLeadingString()`
- `RtmpSession.cpp` — 推流侧,本 issue 的根因 / publish side, the root cause
here
- `RtmpPlayer.cpp` — 拉流侧存在同样的崩溃风险 / pull side has the identical failure
mode
- `FlvSplitter.cpp` — 原本不会断开,但会静默丢弃 metadata;现在能正确解析 / did not
disconnect before, but silently dropped the metadata; now parses it

## 验证 / Verification

用真实摄像机推流抓取了 17.8 MB 原始 RTMP 字节流,分别回放到修改前后的 MediaServer:

A 17.8 MB raw RTMP capture from the live camera was replayed against
MediaServer before and after the change:

| 场景 / Scenario | 修改前 / Before | 修改后 / After |
|---|---|---|
| 原始流(含多余 AMF 值)/ raw stream with redundant AMF values | `Expected a
string`,推流被断开 / dropped | 全部回放完成,无断开 / replayed fully, no disconnect |
| 去掉那 18 字节的标准流 / same stream with the 18 bytes removed | 正常 / OK | 正常 /
OK(回归测试 / regression) |

对照实验:**仅**从原始抓包中删除那 18 字节,其余字节完全不变,修改前的版本即可正常收流 —— 说明问题确实由这段多余的 AMF 值引起。

Control experiment: removing **only** those 18 bytes from the capture,
leaving every other byte untouched, makes the unpatched build work —
confirming those bytes are the cause.

修复后的日志 / Log after the fix:

```
MultiMediaSourceMuxer.cpp | stream: rtmp://__defaultVhost__/live/stream , codec info: H264[1920/1080/25]
MediaSource.cpp | 媒体注册:rtmp://__defaultVhost__/live/stream
MediaSource.cpp | 媒体注册:rtsp/hls/ts/fmp4://__defaultVhost__/live/stream
```

摄像机实时推流也已验证:拉取 HTTP-FLV 后用 ffmpeg 解码无报错(H264 1920x1080 25fps)。

Also verified end to end with the live camera: pulling HTTP-FLV and
decoding it with ffmpeg produces no errors (H264 1920x1080 25fps).

## 行为变化说明 / Note on behavior change

`RtmpPlayer` 中被修改的分支同时处理
`MSG_CMD`。命令消息的首个元素本来就是字符串,正常情况下行为不变;但如果收到首元素非字符串的畸形命令消息,以前会断开连接,现在会打印
`can not support cmd:` 警告并继续。符合标准的流行为完全不变(已通过上面的回归测试验证)。

The modified branch in `RtmpPlayer` also handles `MSG_CMD`. The first
element of a command message is already a string, so normal behavior is
unchanged; for a malformed command message whose first element is not a
string, the connection used to be dropped and now a `can not support
cmd:` warning is logged instead. Standard-compliant streams are
unaffected, as shown by the regression test above.
2026-08-14 13:29:23 +08:00
xiongziliang
0e9e59bf43 fix(webrtc): 修复webrtc连接迁移后close失败的bug 2026-08-06 21:42:31 +08:00
YuLi
49b99f106f 优化 PlayerProxy 重连时的 muxer 保留策略 (#4794)
当 `general.resetWhenRePlay=0` 时,上游临时断开不再立即重置
muxer。重连成功后会比较新旧轨道的编码、初始化配置、视频尺寸及音频参数:

  - 轨道兼容时只替换输入 delegate,保留原 MediaSource、HLS 状态和下游播放连接。
  - 轨道不兼容时正常重置并重新初始化封装状态。
  - 重试耗尽或主动关闭时释放 muxer,并取消等待中的重连任务。

这样做的目的是上游自动重连不会导致客户端播放器断开, 对客户端播放器来说上游重连是无感的
2026-08-02 13:13:19 +08:00
YuLi
7768aee571 修复HTTP-TS 媒体帧超时 (#4793)
这个修复是因为有时的可能由于上游网络flow损坏,会导致http-ts拉流时连接不会断开, 只有几kb的速度.
这样实际上流媒体是无法正常播放的, 但是又因为能读取到非常少的数据, 不会触发超时. 等于链接假死在那里了.常见与跨域/跨洲传输时.
所以这个pr就是用于判断如果媒体帧长时间接收不全, 就也应该认为是超时断开.

后面还会提交一个新的pr, 主要是配合这个pr实现"PlayerProxy 无感重连与 muxer 保留策略", 这样就能在遇到坏flow时,
自动重连, 但是播放器无感知, 也不会断开.
2026-08-02 13:09:12 +08:00
YuLi
b0427c3901 VP9 RTP parser: add robust bounds checks, fix pictureID and references, add unit tests (#4790)
### Motivation

- Harden VP9 RTP payload parsing against malformed/truncated packets to
avoid OOB reads and crashes.
- Fix incorrect assembly of extended `pictureID` and incorrect
consumption of reference indices in flexible mode.
- Add focused unit tests to cover descriptor variants and edge cases so
regressions are caught automatically.

### Description

- Change parser signature to `int parse(const unsigned char *data, int
dataLength)` and replace raw pointer arithmetic with
`readByte`/`skipBytes` helpers that track remaining bytes and enforce
bounds.
- Fix `largePictureID` assembly by concatenating bytes correctly instead
of using `ntohs` arithmetic, and ensure `additionalReferenceIdx` is set
from the parsed byte; also limit flexible-mode reference chain to at
most three references.
- Parse scalability-structure fields (`spatialLayers`, `hasResolution`,
`hasGof`) with bounds checks and correctly read resolution entries and
GOF reference indices; return `-1` on truncation.
- Add an extra safety check in `VP9RtpDecoder::decodeRtp` to verify the
parsed header offset is within payload bounds, and add
`tests/test_vp9_rtp.cpp` with many descriptor/edge-case cases exercising
parsing logic.

### Testing

- Added unit test `tests/test_vp9_rtp.cpp` covering L/F/P combinations,
picture ID variants, reference chains, resolution and GOF parsing, and
truncation cases, and executed it as an automated test.
- The new test binary completed all test cases successfully (all
expected pass/fail outcomes matched).

------
[Codex
Task](https://chatgpt.com/codex/cloud/tasks/task_e_6a63e97a4c2c8320aa66d51a746c2e4d)
2026-08-02 13:06:34 +08:00
YuLi
006eece147 优化http文件上传相关代码 (#4796) 2026-08-02 13:04:57 +08:00
YuLi
79d795a767 修复 ffmpeg.snap 模板注入导致的命令执行 (#4789)
### Motivation
- 发现 `ffmpeg.snap` 可被 `setServerConfig` 修改并被直接作为 `snprintf`
格式串使用,攻击者可借此选择任意可执行文件从而触发远程命令执行(RCE),因此需要在代码层阻断可远程篡改入口并增加模板校验。
- 本次变更目标是快速切断远程覆盖向量并加入纵深校验,作为短期补丁同时为后续移除格式化命令模板并改用参数数组的长期修复铺路。 

### Description
- 在 `server/FFmpegSource.cpp` 的 `FFmpegSnap::makeSnap` 中增加模板校验逻辑,要求模板以
`%s` 开头、恰好包含 3 个 `%s` 占位符且不包含其它格式说明符,否则通过回调返回错误并且不启动子进程。
- 在 `server/WebApi.cpp` 的 `setServerConfig` 中将 `ffmpeg.snap` 加入不可通过 API
动态修改的黑名单(与已有的 `ffmpeg.bin` 限制保持一致),以切断远程通过 API 覆盖可执行程序的入口。
- 对非法模板的处理改为:不构造/执行命令并通过 `onSnap` 回调返回明确错误信息,降低误用导致的未定义行为风险。 

### Testing
- 运行 `git diff --check` 检查代码风格和差异冲突,结果通过。 
- 进行了构建验证:`cmake -S . -B build -DENABLE_WEBRTC=OFF -DENABLE_TESTS=OFF
-DCMAKE_BUILD_TYPE=Release` 且 `cmake --build build -j2` 完成并成功生成
`MediaServer` 可执行文件。
- 提交已生成并验证工作区干净(`git status --short --branch`),构建过程无新增错误或未解决警告导致失败。

------
[Codex
Task](https://chatgpt.com/codex/cloud/tasks/task_e_6a63e3fc74a08320865dbe10b93a14a2)
2026-07-27 22:57:19 +08:00
YuLi
6b16281ab0 fix: limit AMF decoder nesting depth (#4787)
### Motivation
- Prevent unbounded recursive-descent parsing in the AMF decoder that
allowed deeply nested AMF objects/arrays to exhaust the process stack
and cause a pre-auth remote DoS.

### Description
- Add an RAII depth guard `AMFDecoder::DepthGuard` and a per-decoder
`depth` counter with `kMaxDepth = 64` to `AMFDecoder` in
`src/Rtmp/amf.h`/`src/Rtmp/amf.cpp`.
- Instrument `load_object()`, `load_ecma()`, and `load_arr()` to create
a `DepthGuard` at entry so nesting is incremented and reliably
decremented on return or exception, and throw
`std::runtime_error("Maximum AMF nesting depth exceeded")` when the
limit is exceeded.
- Add `tests/test_amf.cpp` to assert that a 64-level nested AMF
container is accepted and a 65-level nested container is rejected with
the expected error.
- Keep non-nested parsing behavior unchanged; the guard only enforces a
maximum container nesting depth.

### Testing
- Configured the project with tests enabled using `cmake -S . -B build
-DENABLE_TESTS=ON`, which generated the `test_amf` target successfully.
- Built the test target with `cmake --build build --target test_amf` and
performed smoke compiles of modified sources, with `src/Rtmp/amf.cpp`
compiling to object (`/tmp/amf.o`) successfully.
- Compiled the new test source with `c++ -std=gnu++11 -c
tests/test_amf.cpp` successfully and verified `git diff --cached
--check` passed.

------
[Codex
Task](https://chatgpt.com/codex/cloud/tasks/task_e_6a63c9326b9883209c857c0f4fa5d0cc)
2026-07-27 22:56:18 +08:00
YuLi
867fc9ce83 fix: harden AAC RTP decoder payload bounds checks (#4788)
### Motivation
- 修复 `ext-codec/AACRtp.cpp` 中的越界读取问题,避免在处理异常短的 AAC RTP payload 时读取
`ptr[1]` 导致堆越界(CWE-125)。
- 在解码器层对输入数据做前置且严格的长度校验以防止网络可达的、未认证或畸形的 RTP 包触发服务可用性影响。 

### Description
- 在 `AACRtpDecoder::inputRtp` 中对 `payload_size` 强制要求至少为 2 字节以保障对
AU-Header-Length 的安全读取。
- 添加对 AU-header 表的完整性检查:计算 `au_headers_size = au_header_count * 2` 并在访问
AU-header 或做指针偏移前验证可用字节,否则拒绝该包。
- 在 `flushData()` 中将帧长度判断移到前面,先检查 `_frame->size() > ADTS_HEADER_LEN` 再访问
`ptr[0]`/`ptr[1]`,避免短帧情况下的顺序求值导致的越界读取。

### Testing
- 运行 `git diff --check`,无格式/冲突检查错误并通过。 
- 运行配置命令 `cmake -S . -B build -DENABLE_TESTS=OFF -DENABLE_WEBRTC=OFF
-DENABLE_SRT=OFF -DENABLE_FFMPEG=OFF -DCMAKE_BUILD_TYPE=Debug`,CMake
配置成功。
- 运行构建 `cmake --build build --target zlmediakit -j2`,目标构建完成且
`zlmediakit` 目标成功编译。

------
[Codex
Task](https://chatgpt.com/codex/cloud/tasks/task_e_6a63e2a088ac8320ac3864716f13c995)
2026-07-27 22:50:23 +08:00
Yohann
ac64e3314b ci: add Linux ARM64 build workflow (#4784)
Add GitHub Actions workflow to build ZLMediaKit for linux/arm64
(aarch64) using the native ubuntu-24.04-arm runner.

- Build container: debian:11 (glibc 2.31) for broad compatibility
- Compile steps extracted into package/build_linux_arm64.sh for
debugging
- OpenSSL: no-asm/no-dso/-fPIC to fix aarch64 PIC relocation issues
- Artifacts: Linux_ARM64_<branch>_<date>

Successfully tested on my fork; artifact includes MediaServer and
related binaries.

Co-authored-by: yangheng <492238647@qq.com>
2026-07-24 11:51:08 +08:00
YuLi
245f7c3e45 HLS TS 切片下载失败后清除该切片遗留的解复用输入缓存 (#4786)
在 HLS TS 切片下载失败后清除该切片遗留的解复用输入缓存,防止其与下一切片拼接导致错误的包或者损坏的包出现.
2026-07-24 11:23:19 +08:00
YuLi
1681864d79 修复mp4异常视频尺寸可能导致的未定义行为 (#4785)
libmov 的 `mov_add_video()` 接收 `int` 类型的视频宽高,并直接执行:

  ```c
  track->tkhd.width = width << 16;
  track->tkhd.height = height << 16;
```
这是为了生成 MP4 Track Header 使用的 16.16 定点数。

当输入轨道包含异常视频尺寸,例如负数或在 32 位 int 平台上大于 32767 的值时,左移操作会产生有符号整数溢出,构成未定义行为,可能导致程序异常终止或生成错误的 MP4 轨道信息。
2026-07-24 11:21:33 +08:00
YuLi
59ffb2c9fd Fix/ts splitter resync (#4783) 2026-07-23 13:58:31 +08:00
YuLi
4a24057e73 feat(http): decouple upload size limit from maxReqSize and harden file upload (#4780)
- Add maxUploadSize config (default 1GB) for custom HttpBody streaming uploads;
  maxReqSize now only controls in-memory buffering threshold
- Reject uploads exceeding maxUploadSize with 413 before writing any data
- Delete incomplete files on HttpFileStorage destruction
- Open HttpFileStorage in "wb" mode instead of "ab" to avoid stale data
- Pass content_size to writeData() for integrity validation
- Use uint64_t for content_len to support large file uploads
- Wrap HttpBody _on_completed callback in try-catch to prevent unhandled exceptions
- Make GET_CONFIG global variables read-only
- Update ZLToolKit submodule

---------

Co-authored-by: xiongziliang <771730766@qq.com>
2026-07-23 13:55:35 +08:00
YuLi
daaa74a72e fix(ext-codec): harden H264/H265 SPS/VPS parsing against malformed input (#4781)
- Add 1MiB cap on parameter set size to prevent memory exhaustion
- Validate SPS/VPS field ranges per H.264/H.265 spec (sps_id, bit_depth, poc_type, ref_frames, etc.)
- Fix Exp-Golomb reader EOF/overflow handling (throw instead of silent zero)
- Use wide integers for crop/delta_scale arithmetic to prevent overflow
- Commit output params only after full parse success (no partial metadata)
- Harden getExtraData with size checks, from_nalu API, AssertFailedException guard
- Avoid redundant update() in inputFrame_l (retry only on SPS change or first-ready)
2026-07-23 11:43:21 +08:00
YuLi
7563db36bb fix: restore SRT transport cleanup on session error (#4777)
### Motivation
- Restore the transport cleanup path on SRT session errors so
`SrtTransport::onShutdown` runs its unregister logic and prevents
unbounded growth of weak_ptr entries in the transport manager that could
lead to a memory-exhaustion DoS.

### Description
- Re-enabled shutdown cleanup in `srt/SrtSession.cpp` by capturing `err`
in the delayed callback and calling `transport->onShutdown(err)` from
the `getPoller()->async` lambda.

### Testing
- Ran `cmake -S . -B build` to sanity-check configuration; configuration
failed in this environment due to a missing `3rdpart/ZLToolKit`
submodule and unrelated CMake errors, not due to the patch.

------
[Codex
Task](https://chatgpt.com/codex/cloud/tasks/task_e_69b32b68f8ac8320b6a9b0fad53594c6)

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
2026-07-13 11:03:00 +08:00
GW.J
fcdd7bd990 bugfix: MediaSource 经 listener->getMuxer() 的空指针竞态崩溃 (#4775) 2026-07-13 11:02:39 +08:00
YuLi
1b4f3ef9a1 Bound paced sender cache by frame count (#4776)
### Motivation
- Prevent unbounded memory growth in `FramePacedSender` when many frames
share identical or tightly clustered DTS values by restoring an
insertion-time frame-count guard independent of DTS-span-based pressure.

### Description
- Add a `kMaxCacheSize` constant and force a cache `flushCache(...)`
when `_cache.size()` exceeds `kMaxCacheSize`, keeping paced-sender
buffering bounded even if `buf_ms` remains small; the guard is applied
immediately after `_cache.emplace(...)` in
`FramePacedSender::inputFrame`.

### Testing
- Performed static discovery of call sites and symbols with `rg`/`sed`
to verify the paced sender is created when `_option.paced_sender_ms` is
nonzero and that frames are routed to `_paced_sender->inputFrame(...)`;
this succeeded.
- Attempted to configure and build with `cmake -S . -B build
-DCMAKE_BUILD_TYPE=Release && cmake --build build -j2` and `cmake
--build build -j2`, both failed during configuration or build due to
missing third-party artifacts (`3rdpart/ZLToolKit/CMakeLists.txt`) or no
existing `build` directory in the checkout, so no binary tests were
executed.

------
[Codex
Task](https://chatgpt.com/codex/cloud/tasks/task_e_6a512c4481a883209d56b8e7109a91ba)
2026-07-11 08:19:43 +08:00
xiongziliang
a485d89063 修复程序退出时访问NoticeCenter单例可能崩溃的bug 2026-07-08 11:12:22 +08:00
xiongziliang
6c0bc2e5c0 重构平滑发送逻辑,自适应发送速度降低延时 2026-07-08 11:12:22 +08:00
xiongziliang
6d2d586fb2 优化getSnap截图接口性能 2026-07-08 11:12:22 +08:00
xiongziliang
92681fe6e1 新增支持http文件上传功能 2026-07-08 11:12:22 +08:00
xiongziliang
b44e5b0731 替换SPS解析器实现以改进H264和H265视频参数提取 2026-07-08 11:12:22 +08:00
erquren
fa347d7dbe Fix dockerfile warnning (#4767)
LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format (line 89)
2026-07-06 21:06:01 +08:00
PioLing
d133d6e668 Add async init SDL audio device for player to prevent blocking main poller(#4773) 2026-07-06 21:05:02 +08:00
YuLi
5f11d3b3bf Limit RTP/JPEG reassembly to prevent unbounded memory growth (#4764) 2026-06-14 12:01:47 +08:00
luna
14fd9187b8 Add Web management site integration to README (#4762)
增加一个Web管理网站集成
2026-06-11 11:21:55 +08:00
Caner Ateş
64ae6e43c5 支持配置 fmp4 HLS 切片文件扩展名 (.mp4/.m4s) (#4746)
## 背景 / 问题
fmp4 模式下,HLS 切片文件名被硬编码为 `.mp4`(见 `HlsMakerImp::onOpenSegment`),无法改用 fmp4
媒体段更规范、更常见的 `.m4s` 扩展名(`init` 段用 `init.mp4`、媒体段用 `.m4s` 是 CMAF/DASH
的通行约定)。

## 改动
- 新增配置项 `hls.fmp4SegExt`,默认 `.mp4`,**完全向后兼容**;用户可设为 `.m4s`。
- `init` 段仍固定为 `init.mp4`,mpegts 切片仍为 `.ts`,相关行为不变。
- 切片文件名同时用作 m3u8 中的分片 URI,因此扩展名变更后 playlist 自动保持一致,无需额外同步。
- 在 HTTP MIME 表中注册 `.m4s` -> `video/mp4`;否则会以 `text/plain` 返回,导致 Safari
等播放器无法播放 HLS-fmp4。
- 配置值不带前导点(如 `m4s`)时自动规范化为 `.m4s`。

## 涉及文件
`src/Common/config.h`、`src/Common/config.cpp`、`src/Record/HlsRecorder.h`、`src/Record/HlsMakerImp.h`、`src/Record/HlsMakerImp.cpp`、`src/Http/HttpConst.cpp`、`conf/config.ini`

## 测试
- **默认(未配置)**:切片仍为 `*.mp4`,`init` 为 `init.mp4`,行为与改动前一致(回归正常)。
- **`hls.fmp4SegExt=.m4s`**:切片文件为 `*_N.m4s`,m3u8 中 `#EXTINF` 的 URI 指向
`.m4s`,`#EXT-X-MAP` 仍为 `init.mp4`;HTTP 拉取切片返回 `Content-Type:
video/mp4`;hls.js 与 Safari 播放正常。
- **`hls.fmp4SegExt=m4s`(无前导点)**:自动规范化,仍生成 `*.m4s`。

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-08 21:25:25 +08:00
ickeep
eeb2693f22 Fix RTMP proxy audio forwarding (#4745)
## Summary

This fixes RTMP playback audio corruption and VLC playback compatibility
when proxying some upstream RTMP streams through `addStreamProxy`. In
the reproduced case, HTTP-FLV playback was normal, while RTMP playback
had missing audio or occasional sharp noise in VLC.

## Root cause

- RTMP aggregate message parsing copied the 4-byte `PreviousTagSize`
field into the sub-message payload. This shifts the payload boundary and
can corrupt subsequent audio packets.
- `RtmpSession::onSendMedia` forwarded proxied audio/video packets with
the packet's original chunk stream id. This can make audio packets use
an unsuitable chunk id for RTMP playback.
- The RTMP play response emitted non-essential `MSG_DATA` notifications
(`|RtmpSampleAccess` and `NetStream.Data.Start`). FFmpeg tolerates
these, but VLC may expose them as an extra `Data: none` stream and
handle RTMP playback poorly.

## Changes

- Exclude `PreviousTagSize` from aggregate sub-message payloads while
still skipping it when advancing the parser cursor.
- Send audio packets on `CHUNK_AUDIO` and video packets on `CHUNK_VIDEO`
from `STREAM_MEDIA`; keep the original values for other packet types.
- Avoid sending the non-essential RTMP play data notifications before
metadata/config/media packets.

## Validation

- Built `MediaServer` locally in Debug mode.
- Proxied four live RTMP test streams via `addStreamProxy`.
- Verified local RTMP and HTTP-FLV playback expose AAC audio tracks.
- Decoded RTMP audio with `ffmpeg -xerror`; all tested streams completed
without AAC decode errors.
- Verified the VLC compatibility change removes the extra `Data: none`
stream from RTMP output while preserving Video + Audio streams.
- Built and deployed a Docker image locally with docker compose and
re-tested RTMP/FLV audio playback.
2026-06-04 16:03:06 +08:00
mtdxc
4a2c4d0e98 处理seek offset为负数情况 (#4742)
详见media-server的buffer实现, seek的语义和回调不一致,这边进行统一
static int mov_file_read(void* fp, void* data, uint64_t bytes)
{
    if (bytes == fread(data, 1, bytes, (FILE*)fp))
        return 0;
	return 0 != ferror((FILE*)fp) ? ferror((FILE*)fp) : -1 /*EOF*/;
}

static int mov_file_write(void* fp, const void* data, uint64_t bytes)
{
return bytes == fwrite(data, 1, bytes, (FILE*)fp) ? 0 :
ferror((FILE*)fp);
}

static int mov_file_seek(void* fp, int64_t offset)
{
	return fseek64((FILE*)fp, offset, offset >= 0 ? SEEK_SET : SEEK_END);
}

static int64_t mov_file_tell(void* fp)
{
	return ftell64((FILE*)fp);
}
2026-05-28 10:49:33 +08:00
夏楚
e90da4ca68 Add link to ruoyi-qs-nvr in README 2026-05-28 10:39:35 +08:00
xia-chu
86a7204bab 解决mp4_as_player设置为1时相关bug (#4725) 2026-05-21 16:39:20 +08:00
xia-chu
37ea51a2ec 彻底解决mp4_as_player设置为1时,on_stream_none_reader回调无效流信息的问题 (#4725) 2026-05-08 18:16:16 +08:00
xia-chu
ca0f122938 修复编译警告 2026-05-08 18:15:50 +08:00