Fix/821 mtu aware packet length#836
Closed
Ayoub-glitsh wants to merge 3 commits into
Closed
Conversation
The --rate flag only sets the input device sample rate, but the packet encoding defaults to L16_Stereo at 44100 Hz. When input rate differs from packet encoding rate, the sender creates a resampler even if the user doesn't want one. Add --packet-encoding option that lets users register a custom RTP encoding and select it for outgoing packets. This allows sending at 48kHz (or any rate) without resampling: roc-send --rate=48000 --packet-encoding=96:s16/48000/stereo ... The option accepts the format '<id>:<format>/<rate>/<channels>', e.g.: 96:s16/48000/stereo 97:s16/48000/mono The encoding is registered in the context encoding map and the sender is configured to use it as the packet encoding.
Tests cover: - Initialization: valid/invalid configs, intact vs tuning profiles - Bounds checking: latency at target, above max, below min, stalling suppression, no-metrics-yet behavior, intact profile ignores bounds - Scaling: no scaling before first interval, near-1.0 at target, above-1.0 when latency high, below-1.0 when latency low, clamped to scaling_tolerance, intact profile never produces scaling - E2E backend: no update without e2e metrics, terminates on out-of-bounds
When neither packet_length nor packet_mtu is configured, the sender now derives packet_length from a default MTU of 1200 bytes (WebRTC default), then uses min(5ms, mtu_derived_length). This fixes multitrack scenarios where the default 5ms packet length exceeds the MTU for high channel counts. Rules: - neither set: use min(DefaultPacketLength, bytes_2_ns(DefaultMtu - RtpHeader)) - only packet_mtu set: derive packet_length from it - only packet_length set: use it as-is (existing behavior) - both set: log a warning and use whichever leads to smaller packet size Changes: - pipeline/config.h: add DefaultPacketMtu, RtpHeaderSize constants; add packet_mtu field to SenderSinkConfig; update deduce_defaults() signature to accept encoding SampleSpec - pipeline/config.cpp: implement MTU resolution logic in deduce_defaults() - pipeline/sender_sink.cpp: pass encoding spec to deduce_defaults() - public_api/include/roc/config.h: add packet_mtu to roc_sender_config - public_api/src/adapters.cpp: wire packet_mtu from public API - tools/roc_send/cmdline.ggo: add --packet-mtu option - tools/roc_send/main.cpp: parse and apply --packet-mtu
|
🤖 Pull request is not targeted to |
Member
|
Thanks for posting.
|
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.
Fixes #821
Implements the approach discussed with @baranovmv adds a packet_mtu parameter and auto-derives packet length from MTU when neither is set.
neither set → min(5ms, derived from 1200 bytes default MTU)
only packet_mtu set → derive length from it
only packet_length set → nothing changes
both set → warn and pick the smaller one
Existing stereo users are unaffected since 5ms fits fine within 1200 bytes.