refactor(types): split media_common.rs by media domain#50
Merged
BlindMaster24 merged 1 commit intomainfrom Apr 24, 2026
Merged
Conversation
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
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
types/entities/media_common.rswas a flat 458-line file bundlingaudio, 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.rskept itsso every downstream user of the flat glob export (
types::JitterConfig,types::VideoFormat,types::EncryptionContext, etc.) continues toresolve unchanged.
Structural only, no semantic change:
#[non_exhaustive]derives, and methodbodies are byte-for-byte identical to the pre-split file.
missing_docs = "deny"started flagging them in their new homes(no behavioral effect).
unsafe { ... }bindgen-union accessors invideo.rs::VideoCodec::{from, to_ffi}bit-for-bit identical.EncryptionContext::to_ffiraw pointercopy_nonoverlappinglogic bit-for-bit identical (no change tothe 511-byte clamps or the
utils::ToTTcall sites).Local verification:
cargo fmt --all --checkcleancargo clippy --workspace --all-targets --all-features -- -D warningscleancargo test --workspace --all-features-> 287 passed / 0 failedReview & Testing Checklist for Human
types::{JitterConfig, AudioFormat, AudioInputProgress, VideoFormat, VideoCodec, VideoFrame, EncryptionContext, ClientKeepAlive, AbusePrevention, DesktopInput, ErrorMessage}all continue to resolve. Theparent glob
pub use media_common::*;is unchanged.audio=jitter + audio format + input progress;
video= videoformat + codec + frame metadata;
transport= TLS + keep-alive + rate limiting;
desktop= input packet;error=SDK error payload.
JitterConfiglives underaudio/because it is primarily an audio jitter buffer knob.
unsafeblocks invideo.rs::VideoCodecstillmatch 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_ffiis 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 theirown tests; then a big test-fill PR driven by
scripts/audit_teamtalk_coverage.py.The pre-existing
semverCI gate is expected to remain red;release-plzhandles the eventual version bump.Link to Devin session: https://app.devin.ai/sessions/71fdd6196cb74723a2e277bb81993a9c
Requested by: @BlindMaster24