Repository navigation
obs-outputs: Run the new socket loop over RTMPS (#2220) - #2778
Conversation
8822cfd to
be5421d
Compare
|
Status from the worker that opened this: RED and GREEN are both in, the Linux Verified here
Still needed, and it needs a maintainer decision or hardware Acceptance item 3 in #2220: one real RTMPS stream on Windows with So this says
|
be5421d to
331e6f6
Compare
|
Windows evidence is in. Verify-only run 40684548610 (
So The macOS jobs in the same run failed, but not from this branch: both died on Still missing for |
The new socket loop (`write_data()` in `rtmp-windows.c.h`) treats anything but `-1`/WSAEWOULDBLOCK and `0` as "no error". That holds for a plain socket; an RTMPS stream sends through `mbedtls_ssl_write()`, which answers a full transport with `MBEDTLS_ERR_SSL_WANT_WRITE` and a pending handshake with `MBEDTLS_ERR_SSL_WANT_READ`, so the loop spins with `can_write` still set and a real TLS error is not fatal either. This pulls the decision out of the `#ifdef _WIN32` loop into `plugins/obs-outputs/rtmp-send-result.h` and pins it from Linux Tier 2, in the crate's existing `test_obs_outputs_rtmp_host` binary: the two Mbed TLS error codes, the classification, the loop action, and the retry length `mbedtls_ssl_write()` requires after WANT_WRITE. RED: the helper reproduces today's rule (plain socket only, no retry length memory), so the new cases fail: test_send_result_tls_would_block: -0x6880 classifies as FAILED, not WAIT_WRITE test_send_result_tls_wants_read: -0x6900 classifies as FAILED, not WAIT_READ test_send_retry_repeats_first_length: 4000, not 1000 after a WANT_WRITE Refs #2220.
`RTMPSockBuf_Send()` is `mbedtls_ssl_write()` when `sb_ssl` is set, but `write_data()` only understood a plain socket's `-1`/WSAEWOULDBLOCK and `0`. An RTMPS stream therefore spun on `MBEDTLS_ERR_SSL_WANT_WRITE` with `can_write` still true, queried `WSAGetLastError()` for a code that is not a Winsock error, and could drop queued bytes when it retried a write the TLS layer had not accepted with a length the buffer had grown past. - `write_data()` classifies through `rtmp_send_result_of()`: WANT_WRITE and WANT_READ clear `can_write` and return RET_BREAK (the loop waits for FD_WRITE/FD_READ), any other negative is fatal, and a fatal TLS send logs `mbedtls_strerror()` instead of `GetLastError()`. - The in-flight length lives in `struct rtmp_stream::send_retry` and is repeated on a WANT_WRITE retry, which is what `mbedtls_ssl_write()` requires (it reports the new call's length once it flushes `out_left`). - The `FD_READ` discard reads through `TLS_read()` when a session is set, so a handshake or renegotiation can complete; a raw `recv()` threw those records away. - The `rtmps://` check in `rtmp-stream.c.h` is deleted, so network optimizations and low-latency mode stay on for RTMPS. GREEN: `OBS_CTEST_JOBS=16 uv run ci/local_gate.py --lane tier2-linux` runs 11 cases in test_obs_outputs_rtmp_host, all passing; `./lint --fix` clean. docs/features.md has the ledger line. Refs #2220: the Windows RTMPS run with both settings on is still needed.
331e6f6 to
d3a9713
Compare
Makes "Enable network optimizations" (the new socket loop) and low-latency mode work over RTMPS on Windows instead of being turned off, and stops the loop from spinning or losing bytes when the TLS layer would block. Refs #2220.
RED
addd46be4addsplugins/obs-outputs/rtmp-send-result.h, the platform-neutralhalf of the loop's decision (
rtmp_send_result_of(),rtmp_send_action_of(),rtmp_send_retry_length()), and pins it from Linux Tier 2 in the crate'sexisting
test_obs_outputs_rtmp_hostbinary (no new test binary). The helperin that commit reproduces today's rule — plain socket only, no retry-length
memory — so three cases fail:
Local command:
OBS_CTEST_JOBS=16 uv run ci/local_gate.py --lane tier2-linux(test/cmocka/test_obs_outputs_rtmp_host.c:112, :123, :161).
Why these are the bug:
RTMPSockBuf_Send()ismbedtls_ssl_write()whensb_sslis set (plugins/obs-outputs/librtmp/rtmp.h:104), and the oldwrite_data()only understoodret == -1+WSAEWOULDBLOCKandret == 0.MBEDTLS_ERR_SSL_WANT_WRITE(-0x6880) therefore fell through both brancheswith
can_writestill true — the loop spins — andWSAGetLastError()wasqueried for a code that is not a Winsock error. The send length was also
recomputed from
write_buf_lenon every pass, whichmbedtls_ssl_write()forbids after WANT_WRITE (it keeps the unflushed record in
out_leftandreturns the new call's length once it flushes), so a retry with a grown
length made the
memmovedrop bytes the record never carried.GREEN
rtmp_send_result_of()classifies> 0as success,WANT_WRITEaswait-for-
FD_WRITE,WANT_READas wait-for-FD_READ, and everything else(a closed connection, a plain
-1that is notWSAEWOULDBLOCK, any otherMbed TLS error) as fatal.
rtmp_send_action_of()says what the loop doeswith each: clear
can_writeand wait, or shut the stream down.write_data()sends through the helper, remembers the in-flight length instruct rtmp_stream::send_retryand repeats it on a WANT_WRITE retry, andlogs a TLS failure with
mbedtls_strerror()instead ofGetLastError().FD_READdiscard reads throughTLS_read()whensb_sslis set, so ahandshake or renegotiation can make progress; it used a raw
recv(), whichthrows the TLS records away.
rtmps://check inrtmp-stream.c.his gone, sonew_socket_loopandlow_latency_modestay on for an RTMPS URL.rtmp_send_tls_error_text()(declared in the helper,which is why it includes
mbedtls/error.h:mbedtls/ssl.halone does notdeclare
mbedtls_strerror()), so the Windows loop does not have to reachfor a header its unity PCH does not carry.
GREEN:
test_obs_outputs_rtmp_hostnow runs 12 cases and all pass(
OBS_CTEST_JOBS=16 OBS_TIER2_MODES=ON uv run ci/local_gate.py --lane tier2-linux,[ PASSED ] 12 test(s); the case that pins the error textalso proves the Mbed TLS link the Windows lane uses).
./lintclean.What this does not do
Refs #2220, notFixes: acceptance item 3 is a real RTMPS run on Windowswith both settings on, compared with plain RTMP at the same settings, with
the log in the PR. No PR lane builds the Windows app (
ci/ci_scope.py, "full:never from a PR path"), and this checkout has no Windows host, so the Windows
Tier 2 lane can only show that the code compiles and the Linux-side rules
hold. The Windows app lane on
release-rust.yaml(-f verify_only=true) canbuild it once someone dispatches it.