Skip to content

HLS format_detection classifies codecs by substring sniffing #648

Description

@crippledgeek

Follow-up to #642 (closed via #647). Same silent-drift class as #576.

hls/format_detection.rs:69-71 classifies an HLS format id into a codec by substring sniffing:

} else if id.contains("aac") || id.contains("mp4a") {
    Some("aac".to_string())
} else if id.contains("opus") {

#642 typed the values these produce but left the classification untouched.

Why it's a defect, not just style

Substring matching is the same hazard #576 documented for hand-repeated alias lists: nothing enforces the mapping is complete or mutually exclusive, and an id that merely contains a token gets classified. It is also the last production site still deciding codec identity from raw string fragments now that container_matches resolves aliases through the registry.

Suggested shape

Resolve through the registry's alias mechanism (CodecRow::aliases(), extended to video rows in #647) rather than substring tests, so identity lives in one place. Keep the set open — unknown id must remain unclassified, not forced into a default.

Acceptance

  • Classification no longer uses .contains() on a codec id.
  • Mapping resolves through one shared alias source.
  • Mutation test: removing an alias from the registry row turns a test RED.
  • An unrecognised id still classifies as unknown (no silent default).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions