Commit Graph

4 Commits

Author SHA1 Message Date
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
Xiaofeng Wang
435dcbcbbf VP9RtpDecoder: validate payload bounds (#4703) 2026-03-30 10:14:29 +08:00
xia-chu
a59809047c 修复编译警告 2026-01-08 21:18:00 +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