Skip to content

feat: add structured parsing sample data support#2

Merged
alfg merged 16 commits intomainfrom
feat/sample-tables-structured-data
Dec 9, 2025
Merged

feat: add structured parsing sample data support#2
alfg merged 16 commits intomainfrom
feat/sample-tables-structured-data

Conversation

@alfg
Copy link
Copy Markdown
Member

@alfg alfg commented Dec 8, 2025

This pull request introduces structured data decoding for MP4 sample table boxes, making it possible to programmatically access detailed information from boxes like stts, ctts, stsc, stsz, stss, stco, co64, and stsd. It also adds new binaries and examples, including a demonstration of how to analyze and parse sample tables using the new structured output. The changes improve both the API and internal decoders, enabling richer introspection and easier downstream processing of MP4 files.

Structured data support for sample table boxes

  • Added a new StructuredData enum and related structs (e.g., SttsData, CttsData, StscData, etc.) to represent parsed box contents in a typed format. Decoders for sample table boxes now return this structured data instead of plain text. (src/registry.rs)
  • Updated all relevant box decoders (StsdDecoder, SttsDecoder, CttsDecoder, StscDecoder, StszDecoder, StssDecoder, StcoDecoder, Co64Decoder) to parse their payloads into the corresponding structured types and return them via BoxValue::Structured. (src/registry.rs) [1] [2] [3] [4] [5] [6] [7] [8]
  • Modified the API to expose these new structured types and make them available for downstream use. (src/lib.rs, src/api.rs) [1] [2]

Example and binary additions

  • Added new binaries (mp4info, mp4samples) and examples (simple, boxes, typed_sample_tables) to Cargo.toml for demonstrating and testing the structured decoding features.
  • Implemented an example (examples/typed_sample_tables.rs) that shows how to analyze sample table boxes and access their structured contents, including a demonstration of direct parsing using the registry.

Minor improvements

  • Small code style and import tweaks for consistency. (src/api.rs)

Copilot AI review requested due to automatic review settings December 8, 2025 10:20
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds structured data parsing for MP4 sample table boxes, enabling programmatic access to detailed sample information. However, the implementation has several critical issues that prevent it from working as intended.

Key Changes:

  • Added StructuredData enum and related structs to represent parsed MP4 box contents in typed format
  • Updated 8 box decoders (stsd, stts, ctts, stsc, stsz, stss, stco, co64) to return structured data
  • Added new samples module with API for extracting track sample information
  • Added mp4samples binary and typed_sample_tables example to demonstrate the feature

Critical Issues Found:

  1. The samples.rs module parses debug strings instead of using the actual BoxValue::Structured data, making it fragile and defeating the purpose of structured parsing
  2. Multiple functions return hardcoded placeholder values (track IDs, timescales, file offsets) instead of parsing real data
  3. The StsdDecoder doesn't parse version/flags and only processes one entry instead of all entries
  4. Test coverage is incomplete - only 3 of 8 decoders are tested

Reviewed changes

Copilot reviewed 7 out of 9 changed files in this pull request and generated 13 comments.

Show a summary per file
File Description
src/registry.rs Adds StructuredData types and updates 8 decoders to return structured data; StsdDecoder has incomplete parsing
src/samples.rs New module for extracting track samples; critically flawed - parses debug strings instead of structured data and returns placeholder values
src/lib.rs Exports new structured data types and sample extraction API
src/api.rs Adds handling for BoxValue::Structured in decode_value function
src/bin/mp4dump.rs Adds structured data formatting support
src/bin/mp4samples.rs New binary for displaying sample info; uses placeholder values instead of real parsed data
examples/typed_sample_tables.rs Example demonstrating structured parsing; has unused import
tests/registry_tests.rs Tests for 3 decoders (stts, stsz, stsc); missing tests for ctts, stss, stco, co64, stsd
Cargo.toml Declares new binaries (mp4info, mp4samples) and examples

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 10 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 11 changed files in this pull request and generated 10 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 11 changed files in this pull request and generated 19 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@alfg alfg merged commit 85a86ed into main Dec 9, 2025
1 check passed
@alfg alfg deleted the feat/sample-tables-structured-data branch December 9, 2025 11:12
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.

2 participants