Skip to content

refactor(types): split media_common.rs by media domain#50

Merged
BlindMaster24 merged 1 commit intomainfrom
devin/1776940287-split-media-common
Apr 24, 2026
Merged

refactor(types): split media_common.rs by media domain#50
BlindMaster24 merged 1 commit intomainfrom
devin/1776940287-split-media-common

Conversation

@devin-ai-integration
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot commented Apr 23, 2026

Summary

types/entities/media_common.rs was a flat 458-line file bundling
audio, video, transport, desktop, and error payload types in one
place. Split into a directory-first module per the AGENTS.md
guideline ("split when a module grows beyond ~400-600 lines or
mixes multiple responsibilities"):

  • media_common/mod.rs - module wiring + re-exports.
  • media_common/audio.rs - JitterConfig, AudioFormat,
    AudioInputProgress.
  • media_common/video.rs - VideoFormat, VideoCodec,
    VideoFrame.
  • media_common/transport.rs - EncryptionContext,
    ClientKeepAlive, AbusePrevention.
  • media_common/desktop.rs - DesktopInput.
  • media_common/error.rs - ErrorMessage.

The parent types/entities/mod.rs kept its

mod media_common;
pub use media_common::*;

so every downstream user of the flat glob export (types::JitterConfig,
types::VideoFormat, types::EncryptionContext, etc.) continues to
resolve unchanged.

Structural only, no semantic change:

  • Struct field visibility, #[non_exhaustive] derives, and method
    bodies are byte-for-byte identical to the pre-split file.
  • Added minimal doc comments on public fields where
    missing_docs = "deny" started flagging them in their new homes
    (no behavioral effect).
  • Kept the unsafe { ... } bindgen-union accessors in
    video.rs::VideoCodec::{from, to_ffi} bit-for-bit identical.
  • Kept EncryptionContext::to_ffi raw pointer
    copy_nonoverlapping logic bit-for-bit identical (no change to
    the 511-byte clamps or the utils::ToTT call sites).

Local verification:

  • cargo fmt --all --check clean
  • cargo clippy --workspace --all-targets --all-features -- -D warnings clean
  • cargo test --workspace --all-features -> 287 passed / 0 failed

Review & Testing Checklist for Human

  • Spot-check re-exports: types::{JitterConfig, AudioFormat, AudioInputProgress, VideoFormat, VideoCodec, VideoFrame, EncryptionContext, ClientKeepAlive, AbusePrevention, DesktopInput, ErrorMessage} all continue to resolve. The
    parent glob pub use media_common::*; is unchanged.
  • Confirm the domain groupings are reasonable: audio =
    jitter + audio format + input progress; video = video
    format + codec + frame metadata; transport = TLS + keep-
    alive + rate limiting; desktop = input packet; error =
    SDK error payload. JitterConfig lives under audio/
    because it is primarily an audio jitter buffer knob.
  • Verify the unsafe blocks in video.rs::VideoCodec still
    match the original FFI union layout exactly (they do -
    byte-for-byte copy from the pre-split file) and that the
    511-byte clamp logic in transport.rs::EncryptionContext::to_ffi
    is unchanged.

Notes

Next PR in the P0 structural refactor queue after #44-#49.
Independent of the other refactor PRs so can be merged in any
order.

Upcoming: split client/backend.rs (1334 lines) +
client/backend_mock.rs (1101 lines) pair; then P1 API tweaks
(full-jitter ExponentialBackoff, StreamTypes, SdkErrorCode,
TimeoutKind, SecretString, indexed dispatch) each with their
own tests; then a big test-fill PR driven by
scripts/audit_teamtalk_coverage.py.

The pre-existing semver CI gate is expected to remain red;
release-plz handles the eventual version bump.

Link to Devin session: https://app.devin.ai/sessions/71fdd6196cb74723a2e277bb81993a9c
Requested by: @BlindMaster24


Open in Devin Review

types/entities/media_common.rs was a flat 458-line file bundling
audio, video, transport, desktop, and error payload types. Split
into a directory-first module per the AGENTS.md guideline
(400-600+ lines or mixed responsibilities):

* media_common/mod.rs - module wiring + re-exports.
* media_common/audio.rs - JitterConfig, AudioFormat,
  AudioInputProgress.
* media_common/video.rs - VideoFormat, VideoCodec, VideoFrame.
* media_common/transport.rs - EncryptionContext, ClientKeepAlive,
  AbusePrevention.
* media_common/desktop.rs - DesktopInput.
* media_common/error.rs - ErrorMessage.

The parent types/entities/mod.rs kept its
  mod media_common;
  pub use media_common::*;
so every downstream user of the flat glob export (
types::JitterConfig, types::VideoFormat, types::EncryptionContext,
etc.) continues to resolve unchanged.

Structural only, no semantic change:
* Struct field visibility, #[non_exhaustive] derives, and method
  bodies are byte-for-byte identical to the pre-split file.
* Added minimal doc comments on public fields where missing_docs
  = "deny" started flagging them in their new homes (no
  behavioral effect).
* Kept the unsafe { ... } bindgen-union accessors in
  video.rs::VideoCodec::{from, to_ffi} bit-for-bit identical.
* Kept EncryptionContext::to_ffi raw pointer copy_nonoverlapping
  logic bit-for-bit identical (no change to the 511-byte clamps
  or the utils::ToTT call sites).

Local verification:
* cargo fmt --all --check clean
* cargo clippy --workspace --all-targets --all-features -- -D warnings clean
* cargo test --workspace --all-features -> 287 passed / 0 failed
@devin-ai-integration
Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Copy link
Copy Markdown
Contributor Author

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

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

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

View in Devin Review to see 2 additional findings.

Open in Devin Review

@BlindMaster24 BlindMaster24 merged commit aa83786 into main Apr 24, 2026
11 of 12 checks passed
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.

1 participant