TURN transport readiness backport — 20 November 2026

The pinned mediastreamer2 sender dequeues and discards pending requests while
its TCP/TLS handshake is unfinished. ICE retries the initial ALLOCATE at a
200 ms interval, so request dispatch waits unnecessarily after transport ready.
The patch retains that queue until ready, signals the existing condition from
successful connect, and guards its predicate under the sending mutex. Readiness
is atomic because the read and send workers both access it. The 3000 ms stale
packet flow-control limit, gathering deadline, authentication, certificate/CN
verification, TURN/TLS-only transport, CallKit and media privacy remain unchanged.
No sleeps, fake ringing, preanswer microphone or gathering bypass is introduced.

Base SDK: tag 5.5.39, 4d00285c92511acbeba7b2c7c9c621599192584f, with previously
accepted NetExperts copy-policy backports. source-manifest.json pins exact
preimage and candidate of the only two modified upstream source files. Patch
only a NEW preserved SDK source tree; never mutate the established base package.
The patched source already exists in the candidate package's sibling source tree.

Candidate package:
/opt/data/NetExpertsPhone/sdk-backport-5.5.39-turn-ready-20261120/private-package
Original package/rollback:
/opt/data/NetExpertsPhone/sdk-backport-5.5.39/private-package

Both iOS-arm64 and simulator-arm64 native slices were rebuilt using their exact
original compile and link commands and all original unchanged link inputs.
Recompiling original turn_tcp.cpp produced a byte-identical object on BOTH
architectures. Simulator baseline linked file-backed Mach-O sections matched
original exactly; code signature/output identity differ. Both candidate dSYMs
were regenerated and their UUIDs verified against their binaries. Other sixteen
frameworks and Swift wrappers are unchanged. This is an isolated incremental
native rebuild, not a claim of an independent full clean toolchain rebuild.
No new privacy-reason API is introduced by this C++ queue/mutex/atomic change.

Validation:
- Exact-method native harness: original fails both initial queue tests;
  candidate passes all seven: readiness dispatch, FIFO, cancellation before
  ready, 1000-packet steady-state order, stale purge, error purge, later enqueue.
- Preserved r114 hosted unit/regression artifact: 442 passed, 14 explicit
  opt-in/device skips, 0 failures (456 cases). Newer current-source tests need
  the final application integration build; this artifact predates those cases.
- Three baseline and three candidate real Linphone two-core calls on Sundari
  Bangkok Wi-Fi using Melbourne production TURN/TLS443 with ephemeral test-only
  credentials and unregistered numeric-loopback SIP. No SIPCity, customer or
  carrier signalling. Both directions select forced relay and decode opposite
  synthetic tones over SRTP; strict TLS/CN validation, preanswer silence and
  no Connected before acceptance are retained in every sample. Credentials never
  enter command arguments or retained logs; private FIFO removed after each run.
- Median caller ICE gathering: 818 -> 565 ms. Actual loopback wire INVITE from
  first TURN TCP SYN: median 846.799 -> 588.683 ms. See paired-wire-results.json.
  The TLS1.3 ciphertext record gaps shrink from 24.869–205.152 ms to
  0.025–0.062 ms. Encrypted record contents were NOT decrypted: wire timing is
  not represented as a decoded TURN transaction trace.

Reproduce native queue tests (requires the two preserved source directories):
python3 SDKPrivacy/TURNReadiness/test_transport_queue.py --baseline /opt/data/NetExpertsPhone/sdk-backport-5.5.39/source/mediastreamer2/src/voip --candidate /opt/data/NetExpertsPhone/sdk-backport-5.5.39-turn-ready-20261120/source/mediastreamer2/src/voip --output /private/tmp/phone-turn-queue-review

Private complete commands, manifests, six packet captures and XCResults:
/source/netexperts-phone/20261120/v12-origination/evidence
/source/netexperts-phone/20261120/v12-origination/sdk-candidate

Limits: three samples per arm, not a production SLO or physical CallKit/audio-route
acceptance. The real v12 phone's 1263 ms Init-to-Progress and later 1661 ms to
Ringing cannot be fully decomposed historically: retained gateway journal has
61 rows, no INVITE/status transaction records. Socket-buffer warnings are not
SIP wire timings. The measured avoidable startup wait is fixed; remaining
Melbourne RTT, TLS/auth/allocation costs and downstream carrier signalling remain.
The existing edge coturn configuration was read and hash-verified unchanged;
there is no server setting to repair a client discarding its initial requests.
UDP fallback, certificate bypass and disabling ICE were deliberately excluded.

No TestFlight publication or protected device operation is part of this patch.
Reverting the package path and lock commit restores the prior package; old
source, package, test artifacts and all evidence remain preserved.
