Skip to content

Capture: encoded h26x - #1352

Open
ladvoc wants to merge 2 commits into
mainfrom
ladvoc/capture-encoded-h26x
Open

ladvoc wants to merge 2 commits into
mainfrom
ladvoc/capture-encoded-h26x

Conversation

@ladvoc

@ladvoc ladvoc commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Add H.264 and H.265 access unit parsing to support GStreamer source (and potentially others later).

Closes BOT-550

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

This report is out of date. Scroll down for Devin Review's latest report on this PR.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 1 additional finding.

Open in Devin Review

@alan-george-lk alan-george-lk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was more of a rubber stamp since I don't know much about h26x.rs, but I like the modularity!


//! H.264/H.265 parsing helpers: NAL-unit splitting, access-unit assembly,
//! and keyframe detection.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is pretty large (1K+). Consider splitting up if it makes sense to

})
}

fn split_start_code_index(bytes: &[u8], nal_start: usize) -> Result<usize, H26xParseError> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

q: i see utility functions in rust getting unit tested much less than we do in cpp. Is this due the nature of anything rust specific? or maybe should we beef up testing on this?

@ladvoc
ladvoc force-pushed the ladvoc/capture-encoded-h26x branch from af01f4b to f2ea3fb Compare August 25, 2026 21:35
@github-actions

Copy link
Copy Markdown
Contributor

Changeset incomplete

This PR's changeset is missing version bumps for packages that are affected by the change. The following packages still require a bump:

  • livekit-ffi

Already covered:

  • livekit-capture (minor)

A package must be bumped when its own files change, and whenever a package it depends on is bumped (so downstream consumers get a matching release).

Click here to create a changeset for the missing packages

The link pre-populates a changeset file with patch bumps for the missing packages. You can also add them to your existing changeset. Edit the bump types as needed before committing.

If this change doesn't require a version bump, add the internal label to this PR.

@ladvoc
ladvoc force-pushed the ladvoc/capture-encoded-h26x branch from f2ea3fb to 387d4a2 Compare August 25, 2026 23:13
@ladvoc
ladvoc force-pushed the ladvoc/capture-encoded-h26x branch from 387d4a2 to 6359891 Compare August 28, 2026 23:01
@ladvoc
ladvoc force-pushed the ladvoc/capture-encoded-h26x branch from 6359891 to dea4286 Compare August 31, 2026 18:43

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 new potential issue.

1 flag not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)

Devin Review

Comment on lines +580 to +584
// A VCL NAL opens a new picture when first_mb_in_slice == 0:
// ue(v) == 0 is a lone 1 bit, so the first RBSP bit after the
// header is set. The header byte is nonzero, so the next byte
// cannot be an emulation-prevention byte.
1..=5 => nal.len() >= 2 && nal[1] & 0x80 != 0,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Partitioned H.264 pictures split apart

starts_new_access_unit reads partition B/C payload bits as first_mb_in_slice. A set first bit splits one partitioned picture into invalid frames.

Prompt for agents
Fix H.264 access-unit boundary detection for data-partitioned streams in livekit-capture/src/encoded/h26x.rs. starts_new_access_unit currently interprets byte 1 as first_mb_in_slice for NAL types 1 through 5, but types 3 and 4 carry data partitions B and C and begin with slice_id instead. Parse boundaries only from NAL types that contain a slice header, and keep the associated B/C partitions with partition A. Add a test containing type 2 followed by type 3 and type 4 NAL units whose slice_id starts with a set bit, followed by the next picture.
Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

@ladvoc
ladvoc force-pushed the ladvoc/capture-encoded-h26x branch 2 times, most recently from c169311 to fb4530d Compare September 9, 2026 23:55
@ladvoc
ladvoc force-pushed the ladvoc/capture-encoded-h26x branch from fb4530d to 79c6537 Compare September 10, 2026 18:49
@ladvoc
ladvoc force-pushed the ladvoc/capture-encoded-h26x branch from 79c6537 to 7e80a34 Compare September 17, 2026 18:07
@ladvoc
ladvoc force-pushed the ladvoc/capture-encoded-h26x branch from 7e80a34 to deb0ea0 Compare September 17, 2026 19:45
@ladvoc
ladvoc force-pushed the ladvoc/capture-encoded-h26x branch from deb0ea0 to f7ea43c Compare September 17, 2026 20:37
Base automatically changed from ladvoc/capture-source-clock to main September 17, 2026 21:59
@ladvoc
ladvoc force-pushed the ladvoc/capture-encoded-h26x branch from f7ea43c to ebee3a9 Compare September 17, 2026 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants