54 Commits

Author SHA1 Message Date
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
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
xiongziliang
b44e5b0731 替换SPS解析器实现以改进H264和H265视频参数提取 2026-07-08 11:12:22 +08:00
YuLi
5f11d3b3bf Limit RTP/JPEG reassembly to prevent unbounded memory growth (#4764) 2026-06-14 12:01:47 +08:00
xia-chu
3aa9b8977c Revert "fix: 解决h265多Tile编码时,只有左侧画面,右侧画面灰色图的问题 (#4699)"
This reverts commit d75d35dc7a.
2026-05-03 19:50:09 +08:00
yzhw
d75d35dc7a fix: 解决h265多Tile编码时,只有左侧画面,右侧画面灰色图的问题 (#4699)
推流H265 RTMP,播放 webrtc,左半边画面正常,右半边画面是灰度图。

原因:
FUA打包的M错误导致组帧有问题,播放侧只解码了左边的Tile,右边灰度图背景。

进一步分析推的H265视频
为双Tile左右布局,Webrtc分为两个NALU传输的,H265RtpEncoder::packRtpFu里将两个NALU的RTP包的M标记都标记为1------
这个是错误的,这个M标记是帧结束的标记,而不是NALU结束的标记。也就是说只需要将帧的最后一个NALU的最后一个RTP包的M置1。
2026-04-01 17:40:36 +08:00
Xiaofeng Wang
435dcbcbbf VP9RtpDecoder: validate payload bounds (#4703) 2026-03-30 10:14:29 +08:00
xia-chu
bb903fddcd 新增对mp2音视频编码格式的支持 2026-03-11 22:17:48 +08:00
xia-chu
da9deb352c 兼容某些rtsp流sdp中aac config不规范的bug (#4642) 2026-01-24 23:57:36 +08:00
xia-chu
a59809047c 修复编译警告 2026-01-08 21:18:00 +08:00
mtdxc
f35771a83e 完善ertmp相关代码 (#4505)
增加多种Codec支持,并修复一些bug:
- opus 非标准实现,不输出config frame,与旧的实现保持一致
- 添加RTMP_CODEC_MAP宏,精简代码
2025-10-19 11:56:35 +08:00
xia-chu
8b6aa37b87 优化ertmp对opus的支持 2025-10-16 20:15:34 +08:00
mtdxc
b003eb3eec 各协议全面支持vp8/vp9/av1编码,ertmp新增支持opus编码 (#4498)
实现功能:
- rtp 增加vp8,vp9和av1编码支持
- 实现MP4录像所需的extra_data接口
- 扩展rtmp增加对opus、vp8、vp9和av1的支持

已知问题:
- 开启enhance rtmp后,ffmpeg暂时不支持播放vp8编码格式,其他格式的支持
- vp9和av1开始播放时容易遇到卡顿情况,过几秒后好了,原因暂时未知

---------

Co-authored-by: xia-chu <771730766@qq.com>
2025-10-16 19:26:46 +08:00
韦伟
1bf00cc2a4 新增支持AV1编码 (#4479)
rtsp/webrtc协议新增支持AV1编码
2025-09-26 21:28:12 +08:00
xia-chu
1bb3b43313 兼容某些不规范的rtsp流 (#4463)
兼容某些rtsp流sdp中的vps/sps/pps信息没有去除start code的问题
2025-09-26 15:27:28 +08:00
weishao
8bf64e0407 update 2025-08-22 20:38:17 +08:00
weishao
ceb78bd54c feat: add H.265 profile parameters support for WebRTC SDP negotiation 2025-08-22 20:38:17 +08:00
weishao
6f71dd39ca fix: correct H.265 RTP mark bit handling 2025-08-22 20:38:17 +08:00
PioLing
a972fa85ec 修复某些流带aud帧不兼容的问题 (#4379) 2025-08-06 12:02:43 +08:00
xia-chu
32ab752263 Revert "优化SEI/AUD帧处理逻辑" (#4361)
This reverts commit a35444f27e.
2025-08-02 21:00:30 +08:00
xia-chu
a35444f27e 优化SEI/AUD帧处理逻辑 2025-06-29 18:00:47 +08:00
xiongguangjie
a050f38cc9 提升浏览器webrtc g711音频播放效果 (#4280 #4282)
For chrome (136.0.7103.93)
2025-05-11 11:18:34 +08:00
xiongguangjie
cd7f7fb5ea h265 track fix get extera data size error 2025-02-23 21:21:59 +08:00
PioLing
9863f9c160 Add logo and version information to exe on windows (#4093) 2025-01-03 11:33:35 +08:00
xiongguangjie
cb4db80502 Fix g711 rtp encoder timestamp calculate bug (#4085) 2024-12-28 10:41:52 +08:00
xiongguangjie
5e32199661 improve g711 rtp packetizer code 2024-12-21 19:38:54 +08:00
xiongguangjie
824be6cbd5 修复某些H264视频流缺少sps pps帧的问题 (#4050 #4047 ) 2024-12-04 10:46:37 +08:00
Dw9
2bf85eb8ff Add mp3_plugin, support rtsp with mp3 (#4048)
增加mp3_plugin, 解决rtmp推流转rtsp无法播放问题
ref: https://datatracker.ietf.org/doc/html/rfc2250#section-3.5
2024-12-03 10:40:24 +08:00
xia-chu
aa56576b0e 修复默认音频参数相关bug 2024-11-30 10:54:45 +08:00
xia-chu
892108d6ba 新增若干音视频编码类型的默认实现
部分支持VP8/VP9/AV1/JPEG/MP3/H266/ADPCM/SVAC/G722/G723/G729
2024-11-30 08:23:10 +08:00
xia-chu
87b42ab492 优化代码
除1024改成右移10位
2024-11-29 23:51:34 +08:00
xia-chu
64285b6b09 优化G711 rtp打包分片逻辑相关代码 2024-11-29 20:19:30 +08:00
alex
4152dcd409 AI automatically translates all comments in the code into English (#3917) 2024-09-19 14:53:50 +08:00
夏楚
2cc69d1be6 Fix H.265 multi-PPS frame compatibility issue (#3902) 2024-09-17 09:43:37 +08:00
alex
7c5ba5a099 Add pps structure and parsing function (#3875) 2024-09-10 10:59:44 +08:00
yujitai
6889afbc76 修复弱网丢包场景下rtp解码器可能不会输出配置帧的问题 (#3818)
在弱网丢包场景下,rtp解码器很可能进入gop dropped状态,需要等到idr到来才能继续输出帧,
这会导致idr前面的sps/pps无法被输出, 进而可能导致播放器渲染失败
2024-08-14 20:11:24 +08:00
xia-chu
9463d1291d 修复编译警告 2024-07-21 19:47:36 +08:00
xiongziliang
2ead272187 修复webrtc播放时生成config rtp线程安全的bug
rtsp直接代理时会从config frame生成rtp,在获取VideoTrack配置帧列表时存在线程安全风险;
同时简化getConfigFrames函数代码,去除缓存逻辑。
2024-06-22 13:04:06 +08:00
xiongguangjie
9106dde23e g711 rtp encoder rtp mark set false compitable for freeswitch (#3647) 2024-06-19 18:42:06 +08:00
Xiaofeng Wang
efc683228c 修复H264/H265创建config帧异常问题(#3643)
https://github.com/ZLMediaKit/ZLMediaKit/pull/3611#issuecomment-2177535917
2024-06-19 14:05:23 +08:00
Xiaofeng Wang
84dbe4b076 Send config frames once before sending DirectProxy RTP packets (#3611) 2024-06-16 09:37:33 +08:00
xiongziliang
3de2ee7a2b 优化aac rtp解码器内存安全限定 2024-06-16 09:34:39 +08:00
xiongziliang
720d6304d2 修复aac rtp解码兼容性相关bug 2024-06-15 15:11:36 +08:00
chdahuzi
15bc4c8767 解决帧率解析错误问题 (#3607)
有时解析H265的sps,帧率会出错,例如QgEBAWAAAAMAAAMAAAMAAAMAlqABQCAFof4qtO6JLuaAgAg9YADN/mAE
帧率会解析成3971
2024-06-09 10:43:32 +08:00
xiongguangjie
4aa330ab82 rtp g711 encoder rtp not key pos avoid gop cache useless (#3476)
g711 rtp encoder input packet not key pos , avoid gop cache useless, fix
the bug
2024-04-16 22:34:54 +08:00
xia-chu
f5ca61d235 Enhance compatibility with non-compliant RTMP AAC streams 2024-03-22 20:50:07 +08:00
xia-chu
49ddde28c0 Refactor code 2024-03-22 20:50:07 +08:00
johzzy
2f50344e7b Add ServiceController to manage PlayerProxy/PusherProxy/FFmpegSource/RtpServer services (#3337) 2024-03-10 16:31:20 +08:00
xiongguangjie
06abbd0eb7 rtp send rtp g711 audio can config duration (#3325)
optimization for this
[issue](https://github.com/ZLMediaKit/ZLMediaKit/issues/3316)
2024-03-02 16:40:13 +08:00
imp_rayjay
87cb488b04 Added support for DRI frames in MJPEG RTP packetization (#3305) 2024-02-19 11:54:13 +08:00