Commit Graph

519 Commits

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

后面还会提交一个新的pr, 主要是配合这个pr实现"PlayerProxy 无感重连与 muxer 保留策略", 这样就能在遇到坏flow时,
自动重连, 但是播放器无感知, 也不会断开.
2026-08-02 13:09:12 +08:00
YuLi
006eece147 优化http文件上传相关代码 (#4796) 2026-08-02 13:04:57 +08:00
YuLi
245f7c3e45 HLS TS 切片下载失败后清除该切片遗留的解复用输入缓存 (#4786)
在 HLS TS 切片下载失败后清除该切片遗留的解复用输入缓存,防止其与下一切片拼接导致错误的包或者损坏的包出现.
2026-07-24 11:23:19 +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
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
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
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
4e170e9281 addStreamProxy新增force,支持强制重试拉流 2026-03-17 19:33:43 +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
3a35144243 新增cookie登录鉴权模式,避免secret硬编码鉴权安全缺陷 2026-02-19 23:09:37 +08:00
xia-chu
128d2a057c 新增支持HTTP PUT方法 2026-01-09 11:39:41 +08:00
xia-chu
52b55ded97 修复ws-flv/fmp4/ts播放异常的bug (#4553)
修复提交 "8b5f313284ee876f3627ab4a2eb6460072f12fd1" 引入的bug
2025-11-23 19:26:29 +08:00
xia-chu
8b5f313284 解决websocket-flv/fmp4/ts多路播放请求pending问题 (#4553)
解决等待流注册或播放鉴权hook回复时,zlm未及时回复http头(升级为websocket), 多个http请求并发导致pending的问题
2025-11-23 12:55:23 +08:00
baigao-X
3fb43c5fef feat: 增加webrtc代理拉流 (#4389)
- 增加客户端模式,支持主动拉流、推流:
   - addStreamProxy接口新增支持whep主动拉流,拉流地址目前只兼容zlm的whep url。
   - addStreamPusherProxy接口新增支持whip主动推流,推流地址目前只兼容zlm的whip url。
   - 以上推流url格式为webrtc[s]://server_host:server_port/app/stream_id?key=value, 内部会自动转换为http[s]://server_host:server_port/index/api/[whip/whep]?app=app&stream=stream_id&key=value。

- 增加WebRtc p2p 模式:
  - 增加 ICE FULL模式。
  - 增加STUN/TURN 服务器。
  - 增加websocket 信令。
  - 增加P2P代理拉流。

---------

Co-authored-by: xia-chu <771730766@qq.com>
Co-authored-by: mtdxc <mtdxc@126.com>
Co-authored-by: cqm <cqm@97kid.com>
2025-09-20 16:23:30 +08:00
xia-chu
a8f5cedd84 rtsp/http类型播放协议支持自定义header 2025-09-10 21:51:26 +08:00
xia-chu
57fede9508 修复编译警告 2025-08-09 15:42:28 +08:00
肖锋
fd34b5526b feature:添加http head请求的支持 (#4321)
添加http head请求的支持
2025-06-30 20:46:18 +08:00
PioLing
7b1f8fedac Add network traffic statistics (#4239)
Co-authored-by: xiongguangjie <xiong_panda@163.com>
Co-authored-by: xia-chu <771730766@qq.com>
2025-05-02 16:23:25 +08:00
Wayne Chen
dfca520857 修复http代理的两个问题,原http代理功能提交(#2988):d593267 (#4219)
1. CONNECT请求添加Host字段, 解决400 bad request问题;
    2. HLS拉取第2个ts分片时,重新设置http代理,解决第2个分片及后续分片未走代理的问题。
2025-04-10 15:09:46 +08:00
ibranch7
56fe66da7c 修复http文件下载指定目录时mmap导致崩溃的bug (#4213)
在`HttpBody.cpp`中,`getSharedMmap`函数直接尝试对所有路径进行mmap操作,没有进行文件类型检查
2025-04-09 21:35:28 +08:00
custompal
f0204ea3b3 播放器(reader)setGetInfoCB时统一使用Session对象 (#4195)
Co-authored-by: custompal <chenrengen@gosuncn.com>
2025-03-21 15:22:48 +08:00
xiongguangjie
2a85dffdf9 on_play/on_publish hook 新增protocol字段 (#4133 #4143)
对于webhook  涉及到media info的相关信息,增加protocol 的字段,表明是基于什么协议传输的
2025-02-13 15:18:47 +08:00
yanggs
69e4c127bc Fix compile error when config with -DENABLE_SRT=OFF (#4132) 2025-02-11 13:23:24 +08:00
xia-chu
87b42ab492 优化代码
除1024改成右移10位
2024-11-29 23:51:34 +08:00
alex
4152dcd409 AI automatically translates all comments in the code into English (#3917) 2024-09-19 14:53:50 +08:00
PioLing
3e7e1a317e Fix the bug in Win32 that fails to retrieve sizes larger than 4GB. (#3707 #3702) 2024-07-10 10:43:14 +08:00
xia-chu
e4de454d5d Charset default to UTF-8 on Windows 2024-04-20 22:25:21 +08:00
xiongziliang
3e13e69724 BufFix: avoid may change data in splitter 2024-03-24 22:01:56 +08:00
xia-chu
e972ec5a22 Remove deprecated code 2024-03-22 20:50:07 +08:00
sandro-qiang
ceae040a7a Fix http url path and component's coding (#3237 #3181) 2024-01-28 19:18:36 +08:00
xiongziliang
cfe9a31ca6 Fix http cross domain issues 2024-01-27 21:29:10 +08:00
PioLing
fdc5bfac26 Add win32 mmap (#3229) 2024-01-18 11:04:27 +08:00
xiongguangjie
9d68b668fc Add http pipelining request support (#3154)
Support recv multi http request before reponse it.

Co-authored-by: 夏楚 <771730766@qq.com>
2023-12-23 21:27:28 +08:00
夏楚
bbe8f4a018 release 8.0 2023-12-09 16:23:51 +08:00
xiongziliang
527d9b9e64 优化http目录索引相关代码
优先使用ZLToolKit提供的api
2023-12-02 21:53:25 +08:00
xiongziliang
fd52470fc9 修复http文件服务器未设置charset的bug 2023-12-02 21:53:25 +08:00
xiongziliang
a3a563ed41 修复http虚拟目录相关bug 2023-12-02 21:53:25 +08:00
xiongziliang
c12a6f0aed 适配ZLToolKit 2023-12-02 19:49:28 +08:00
xiongziliang
d555f6038a http文件索引改用英文
防止中文乱码
2023-12-02 16:43:06 +08:00
夏楚
76aebd74c6 整理MediaSource协议类型 2023-12-02 16:31:40 +08:00
夏楚
10c2197e76 新增downloadFile接口,支持下载限定目录下任意文件 (#3073) 2023-12-02 15:58:40 +08:00
xiongziliang
23b785b263 修复编译警告问题 2023-12-02 10:22:45 +08:00
alexliyu7352
4648c156c8 优化hls播放器,使用持久化连接 (#3070)
hls播放时,如果对方reset断开了tcp连接,应该自动发起重连
2023-12-01 17:56:08 +08:00
alexliyu7352
50281513d9 hls播放器优化 (#3064)
1. 连续切片下载失败后关闭播放器, 这种适用于源端服务器出现故障导致m3u8索引正常,但切片文件不正常时,尽快的能关闭播放器并通过web
hook上报业务系统,而不是仍旧不停的拉取ts切片.
2. 优化m3u8拉取失败时的快速重拉, 增加一个0.3秒的延时. 因为有时候httpClient已经_complete=true了,
但是alive()仍旧是true,所以稍微增加一个延时, 避免出现大量的m3u8重试, 实际上这里能否直接判断_complete=true?
3. 继续修改到哪里就把代码注释添加英文版本
2023-12-01 14:43:35 +08:00
alexliyu7352
86029d08af addStreamProxy支持透传参数并设置MediaPlayer (#3063)
通过addStreamProxy接口可以直接配置MediaPlayer相关设置参数,比如说http代理url等
2023-12-01 14:33:07 +08:00
alexliyu7352
d593267f61 增加http代理功能 (#2988)
支持通过http代理拉流, 避免内外网复杂网络环境时需要专门配置防火墙,现在只需要配置一台代理内网的服务器.

---------

Co-authored-by: xia-chu <771730766@qq.com>
2023-11-23 11:09:01 +08:00
xia-chu
aa5343effa 修复http客户端设置tcp连接超时时间单位错误的问题
须毫秒转换为秒
2023-11-07 23:15:16 +08:00