Commit Graph

21 Commits

Author SHA1 Message Date
Dmytro Bogovych 03c58c4572 - G.722: decode as 16 kHz audio, keep the 8 kHz RTP clock separate
G722Codec::info() reported an 8 kHz sample rate for its 16 kHz output (640
bytes of PCM per 20 ms frame, read as 40 ms at 8 kHz). AudioReceiver therefore
fetched packets at half the rate they arrived, and the high-water trim
discarded about 44% of every G.722 stream: 109 of 250 packets per 5 s, with the
buffer at 360 ms instead of 100 ms.

The 8 kHz figure is right for one thing: RFC 3551 keeps G.722's RTP clock at
8000. Codec::Info already had mTimestampUnit for that. G.722 now reports
mSamplerate 16000 and mTimestampUnit 1/8000, and Codec::rtpClockRate() gives
the clock rate. The uses of samplerate() that mean RTP time now use it:
- the jitter statistics in AudioReceiver::add;
- the timestamp-gap-to-milliseconds conversion in AudioReceiver;
- AudioStream's transmit timestamp unit and increment (numerically unchanged
  for every codec, including G.722).
PCM uses stay on samplerate(), so AudioStream now also feeds the G.722
encoder 16 kHz audio instead of 8 kHz. The factory still advertises G722/8000
in SDP, as it must; only its backwards comment is fixed.

AudioReceiver::infoFor() also applied a "G729A silence" rule to payload type
9, which is G.722; G.729 is 18. It now applies to PT 18. Other fixed-frame
payloads are timed proportionally, as AudioReceiver::add already does, so a
10 ms G.722 packet (half a 160-byte frame) counts as 10 ms, not 20.

Measured in vq-core with 16 replayed calls (NISQA speech; G.722 from ffmpeg
and pjmedia, G.711 controls of the same speech; 3 runs each, all identical):
- G.722 packet drops: 44% -> 0; buffer 100 ms like G.711; no underruns;
- Sevana MOS of every G.722 call now equals its G.711 control, normal and loud
  (with the previous code three calls read 4.45 against 4.25);
- DeadAir-01 0.68-0.89 -> 0.01-0.27 (G.711: 0.00-0.14); SilentCall within 0.01
  of G.711 for the ffmpeg-encoded calls (was 0.15-0.17 higher);
- AmpClipping on loud calls 0.004/0.001, as G.711; the 0.02-0.03 seen after
  the codec swap alone came from the dropped packets;
- G.711 results, packet counts, loss, jitter and audio durations unchanged.
The transmit path (AudioStream) builds but was not exercised; vq-core only
receives.

Needs the vq_net change that computes jitter with rtpClockRate().

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-21 18:03:58 +02:00
dmytro.bogovych e166bae1ea - clang format + naming improved 2026-09-03 10:03:42 +03:00
dmytro.bogovych 249e614def - find total number of received RTP (not RTCP) bytes 2026-08-14 11:32:35 +03:00
dmytro.bogovych 40f3b34b16 - fixes after review 2026-06-16 18:05:51 +03:00
dmytro.bogovych 97c4c3aef0 - statistics improved + allow to use virtual microphone AND/OR speaker + minor cleanups 2026-05-18 10:46:21 +03:00
dmytro.bogovych fd4f664164 - patches for RTT / jitter / Network MOS calculation 2026-05-17 05:42:35 +03:00
dmytro.bogovych 06e8bf0b5d - fix logging - too much different subsystem names were used 2026-03-09 15:27:55 +03:00
dmytro.bogovych 783359c616 - fix clang build (build_linux.py) + fix problems reported by Kimi LLM 2026-02-23 20:40:59 +03:00
dmytro.bogovych 260413fad1 - fixes 2026-01-30 08:25:17 +03:00
dmytro.bogovych eec5aabc42 - cleanups 2025-09-26 12:55:19 +03:00
dmytro.bogovych e6cb2a22f7 - improve SRTP decoder API 2025-08-24 14:01:43 +03:00
dmytro.bogovych 0607bd1c47 - ongoing work to ease jitter & RTT calculation 2023-04-11 13:43:38 +03:00
dmytro.bogovych 74b5aa69cb - ongoing work to fix issue with unstable audio 2021-08-06 18:31:42 +03:00
dmytro.bogovych fbad7e07d0 - make better AQuA parameters' set + fix odd logging line 2021-06-09 14:41:17 +03:00
dmytro.bogovych 9479a0f36f - fix opus codec usage 2021-06-09 13:06:26 +03:00
dmytro.bogovych 2a977af330 - more cleanups 2020-10-29 10:28:53 +02:00
dmytro.bogovych 11db9b7450 - put references to RtpDump to #ifdef USE_RTPDUMP where possible 2019-03-14 10:30:38 +02:00
dmytro.bogovych 8e4f2152d2 - fixed problem with loss packet counter (it was higher than real value) 2019-03-08 13:01:24 +02:00
dmytro.bogovych c303b6f09d - changes to library 2019-02-04 23:35:55 +03:00
dmytro.bogovych 59e512175a - logging improved 2018-07-19 09:52:51 +03:00
dmytro.bogovych e1a4931375 - initial import 2018-06-05 11:05:37 +03:00