Commit Graph

2406 Commits

Author SHA1 Message Date
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
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
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
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
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
xia-chu
ee05ae159a 修复mp4_as_player设置为1时,on_stream_none_reader回调无效流信息的问题 (#4725) 2026-05-03 19:50:09 +08:00
xia-chu
9bff057860 Revert "修复mp4_as_player设置为1时,on_stream_none_reader回调无效流信息的问题 (#4725)"
This reverts commit 6f9531c5fa.
2026-05-03 19:33:43 +08:00
xia-chu
c440c45ce4 新增流健康度探针功能 2026-05-03 15:02:03 +08:00
xia-chu
6f9531c5fa 修复mp4_as_player设置为1时,on_stream_none_reader回调无效流信息的问题 (#4725) 2026-05-03 12:04:09 +08:00
greenjim301-ux
a85db32223 fix: add DELETE and PUT to OPTIONS allowed methods for WHIP/WHEP CORS preflight (#4727)
## 问题

`onHttpRequest_OPTIONS()` 返回的三个 HTTP 响应头均未包含 `DELETE`(及 `PUT`)方法,而
`onRecvHeader()` 中已明确注册了这两个方法(注释说明用于 WHIP/WHEP)。

这导致浏览器发起跨域 `DELETE` 请求(WHIP session teardown)前的 CORS 预检失败,无法完成 WHIP
session 的正常关闭。

关联 issue: #4726

## 修改内容

在 `src/Http/HttpSession.cpp` 的 `onHttpRequest_OPTIONS()` 中:

| 响应头 | 修改前 | 修改后 |
|---|---|---|
| `Allow` | `GET, POST, HEAD, OPTIONS` | `GET, POST, PUT, HEAD, OPTIONS,
DELETE` |
| `Access-Control-Allow-Methods` | `GET, POST, HEAD, OPTIONS` | `GET,
POST, PUT, HEAD, OPTIONS, DELETE` |
| `Access-Control-Request-Methods` | `GET, POST, OPTIONS` | `GET, POST,
PUT, OPTIONS, DELETE` |

## 测试

使用支持 WHIP 协议的浏览器客户端,在 `allow_cross_domains=1` 配置下,跨域 `DELETE` 请求可通过 CORS
预检,WHIP session 正常 teardown。
2026-04-30 15:08:37 +08:00
xia-chu
068844b0da 优化rtp级联时接收限流逻辑,新增支持mp4点播限流 2026-04-18 18:58:09 +08:00
XiaoYan Lin
c3c0fb4448 支持rtsp回放控制 (#4691)
目前对接过很多第三方系统(海康ISC、大华ICC、华为IVS、中维等)都支持rtsp回放,觉得有必要支持该功能
2026-04-01 20:42:32 +08:00
YuLi
4daa30e229 avoid reusing non-persistent connections during 302 redirects (#4690)
When performing a 302 redirect, if the server explicitly indicates that the connection is not a persistent connection, the current
connection should not be reused; this prevents potential failures caused
by certain servers actively closing the connection.

---------

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-03-23 10:40:55 +08:00
xia-chu
899d9653a4 新增更新流代理的功能,支持修改已有拉流代理的URL和参数 2026-03-20 21:59:55 +08:00
xia-chu
3b54168b44 listStreamProxy接口支持返回track、status_str信息 2026-03-17 19:43:50 +08:00
xia-chu
4e170e9281 addStreamProxy新增force,支持强制重试拉流 2026-03-17 19:33:43 +08:00
xia-chu
bb49e4dcdc 播放器新增schema参数支持指定拉流协议 2026-03-11 22:24:21 +08:00
xia-chu
bb903fddcd 新增对mp2音视频编码格式的支持 2026-03-11 22:17:48 +08:00
xia-chu
5d4a266873 修复默认sdp时钟频率的bug 2026-03-11 22:11:30 +08:00
xia-chu
ca47a1f8b2 http access事件新增文件绝对路径参数 2026-03-09 18:01:48 +08:00
xia-chu
eef858ffd3 hls直播支持文件根目录设置在http根目录之外
解决hls保存根目录必须和http根目录一致才能播放的问题
2026-03-09 17:07:23 +08:00
xia-chu
b8301bd085 修复python on_create_muxer事件隐式拷贝对象的bug 2026-03-07 13:06:18 +08:00
xia-chu
3a35144243 新增cookie登录鉴权模式,避免secret硬编码鉴权安全缺陷 2026-02-19 23:09:37 +08:00
liangjianhua
8ca4b4d92a Add optional subnet_prefix parameter to searchOnvifDevice interface 2026-02-13 23:11:37 +08:00
夏楚
6d520ea6a3 新增支持Python混合编程模式 (#4579) 2026-02-10 13:28:42 +08:00
ShineSea
6e485ad31a fix(RtpSender): 修复 SSRC 解析溢出问题 (#4646) 2026-01-22 16:31:05 +08:00
xia-chu
a54a0b35c7 优化代码 2026-01-09 11:41:07 +08:00
xia-chu
c53730f36c 修复推流代理失败无限重试的问题
解决媒体注销但还保持无限重试推流的bug
2026-01-09 11:40:42 +08:00
xia-chu
128d2a057c 新增支持HTTP PUT方法 2026-01-09 11:39:41 +08:00
xia-chu
cd8a14d1ca 事件视频录制前溯和后溯时间支持负数 2026-01-09 11:34:18 +08:00
xia-chu
a59809047c 修复编译警告 2026-01-08 21:18:00 +08:00
haorui wang
48c37d4f46 [what][bugfix][rtsp] 修复handleResPAUSE 回调未被正常触发 (#4631)
[what][bugfix][rtsp][https://github.com/ZLMediaKit/ZLMediaKit/issues/4625]
修复handleResPAUSE 回调未被正常触发
2026-01-08 20:28:30 +08:00
jeyawn
2cbe4b714b 修复rtmp复杂模式下拉流 C2 不正确导致服务器异常断开的bug (#4598)
fix https://github.com/ZLMediaKit/ZLMediaKit/issues/4591
原因分析:
C2不正确导致拉流校验不通过
---------

Co-authored-by: xiongguangjie <xiong_panda@163.com>
2025-12-14 11:19:23 +08:00
Robo
5f0edeed6a 修正libavfilter相关的编译问题和transcode内的错误 (#4587)
1. 最近提交的libavfilter相关的代码,没有充分测试cmake编译问题,提交了修正。
2. transcode内存在一个c++11的兼容性问题和运算符优先级问题,提交了修正。
2025-12-09 15:34:15 +08:00
PioLing
1da300cf3e Add snapshot filter mark (#4571) 2025-12-03 16:38:28 +08:00
xiongguangjie
8c94395710 优化rtsp客户端对点播的支持 (#4575 #4569 #4576)
Co-authored-by: xia-chu <771730766@qq.com>
2025-12-01 20:35:54 +08:00
xia-chu
1892185b23 更新默认配置文件,支持配置注释和排序 2025-12-01 20:08:23 +08:00
mtdxc
8a4788504e remove duplicate code (#4570)
getRecvSpeed和getRecvTotalBytes这两函数已在RtspPlayer中实现了,就没必要在RtspPlayerImp中再实现一遍了吧.
2025-11-26 18:51:07 +08:00
JanffuChan
5efe843595 修复rtp无实际负载时判定为丢包的bug (#4563)
RTP无负载时,也记录序号
2025-11-25 19:00:38 +08:00
xia-chu
52b55ded97 修复ws-flv/fmp4/ts播放异常的bug (#4553)
修复提交 "8b5f313284ee876f3627ab4a2eb6460072f12fd1" 引入的bug
2025-11-23 19:26:29 +08:00