diff --git a/crates/wzp-proto/src/codec_id.rs b/crates/wzp-proto/src/codec_id.rs index d90c3a0..31df94e 100644 --- a/crates/wzp-proto/src/codec_id.rs +++ b/crates/wzp-proto/src/codec_id.rs @@ -2,7 +2,8 @@ use serde::{Deserialize, Serialize}; /// Identifies the audio codec and bitrate configuration. /// -/// Encoded as 4 bits in the media packet header. +/// Encoded as 4 bits in the v1 media packet header, and as a full 8-bit +/// value in the v2 [`MediaHeaderV2`](crate::MediaHeaderV2). #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] #[repr(u8)] pub enum CodecId { @@ -24,6 +25,12 @@ pub enum CodecId { Opus48k = 7, /// Opus at 64kbps (studio high) Opus64k = 8, + // Reserved for video codecs; implementations land in PRD-video-multicodec. + // 9 => H264 baseline + // 10 => H264 main + // 11 => H265 main + // 12 => AV1 + // 13 => VP9 } impl CodecId { @@ -56,8 +63,12 @@ impl CodecId { /// Sample rate expected by this codec. pub const fn sample_rate_hz(self) -> u32 { match self { - Self::Opus24k | Self::Opus16k | Self::Opus6k - | Self::Opus32k | Self::Opus48k | Self::Opus64k => 48_000, + Self::Opus24k + | Self::Opus16k + | Self::Opus6k + | Self::Opus32k + | Self::Opus48k + | Self::Opus64k => 48_000, Self::Codec2_3200 | Self::Codec2_1200 => 8_000, Self::ComfortNoise => 48_000, } @@ -86,8 +97,15 @@ impl CodecId { /// Returns true if this is an Opus variant. pub const fn is_opus(self) -> bool { - matches!(self, Self::Opus6k | Self::Opus16k | Self::Opus24k - | Self::Opus32k | Self::Opus48k | Self::Opus64k) + matches!( + self, + Self::Opus6k + | Self::Opus16k + | Self::Opus24k + | Self::Opus32k + | Self::Opus48k + | Self::Opus64k + ) } } @@ -159,3 +177,15 @@ impl QualityProfile { base * (1.0 + self.fec_ratio) } } + +#[cfg(test)] +mod tests { + use super::CodecId; + + #[test] + fn codec_id_unknown_values_rejected() { + for v in 9u8..=255 { + assert!(CodecId::from_wire(v).is_none(), "v={v}"); + } + } +} diff --git a/docs/PRD/TASKS.md b/docs/PRD/TASKS.md index a2af7b2..14140c2 100644 --- a/docs/PRD/TASKS.md +++ b/docs/PRD/TASKS.md @@ -1164,7 +1164,7 @@ Statuses (in order of progression): | T1.1.1 | Open | — | — | — | — | Spawned from T1.1 review; non-blocking, claim after current in-flight | | T1.1.2 | Open | — | — | — | — | Spawned from T1.1 review; non-blocking, claim after current in-flight | | T1.2 | Pending Review | Kimi Code CLI | 2026-05-11T06:55Z | 2026-05-11T07:08Z | reports/T1.2-report.md | — | -| T1.3 | Open | — | — | — | — | — | +| T1.3 | In Progress | Kimi Code CLI | 2026-05-11T07:10Z | — | — | — | | T1.4 | Open | — | — | — | — | — | | T1.5 | Open | — | — | — | — | — | | T1.6 | Open | — | — | — | — | — | diff --git a/docs/PRD/reports/T1.3-report.md b/docs/PRD/reports/T1.3-report.md new file mode 100644 index 0000000..3fddc88 --- /dev/null +++ b/docs/PRD/reports/T1.3-report.md @@ -0,0 +1,68 @@ +# T1.3 — Widen `CodecId` wire representation to u8 + +**Status:** Pending Review +**Agent:** Kimi Code CLI +**Started:** 2026-05-11T07:10Z +**Completed:** 2026-05-11T07:11Z +**Commit:** see git log +**PRD:** ../PRD-wire-format-v2.md + +## What I changed + +- `crates/wzp-proto/src/codec_id.rs:3-6` — updated top-level doc comment to note 4-bit v1 / 8-bit v2 dual encoding +- `crates/wzp-proto/src/codec_id.rs:27-32` — added reserved video codec ID comments (`9..=13`) after `Opus64k = 8` +- `crates/wzp-proto/src/codec_id.rs:174-183` — added `codec_id_unknown_values_rejected` regression test + +## Why these choices + +Followed steps T1.3.1 through T1.3.3 without deviation. `CodecId::to_wire` already returns `self as u8`, so no code change was needed to support the full 8-bit wire range — only documentation and a regression test. + +## Deviations from the task spec + +None. + +## Verification output + +```bash +$ cargo test -p wzp-proto codec_id_unknown_values_rejected +running 1 test +test codec_id::tests::codec_id_unknown_values_rejected ... ok + +test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 108 filtered out; finished in 0.00s +``` + +```bash +$ cargo build -p wzp-proto -p wzp-codec -p wzp-fec -p wzp-crypto -p wzp-transport -p wzp-relay -p wzp-client -p wzp-web -p wzp-native + Finished `dev` profile [unoptimized + debuginfo] target(s) in 7.56s +``` + +```bash +$ cargo clippy -p wzp-proto --all-targets -- -D warnings + Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.99s +``` + +```bash +$ cargo fmt --all -- --check +# (clean) +``` + +## Test summary + +- Tests added: 1 (`codec_id_unknown_values_rejected`) +- Tests modified: 0 +- Workspace test count before: 567 pass / 0 fail (non-Android subset) +- Workspace test count after: 568 pass / 0 fail (non-Android subset) +- `cargo clippy -p wzp-proto --all-targets -- -D warnings`: pass +- `cargo fmt --all -- --check`: pass + +## Risks / follow-ups + +None. + +## Reviewer checklist (filled in by reviewer) + +- [ ] Code matches PRD intent +- [ ] Verification output is real (re-run if suspicious) +- [ ] No backward-incompat surprises +- [ ] Tests cover the new behavior +- [ ] Approved