Repository navigation
Expose active Java socket for RTMP diagnostics - #2215
Merged
pedroSG94 merged 2 commits intoOct 17, 2026
Merged
Conversation
AubreyHaskett
commented
Oct 14, 2026
|
|
||
| abstract class TcpStreamSocketJavaBase: TcpStreamSocket() { | ||
|
|
||
| @Volatile |
Contributor
Author
There was a problem hiding this comment.
Needed here and for the RtmpSocket so that every thread is told to read the latest value of the socket instead of potentially using a cached value. This is important for how I will be using the info from the socket, but should overall strengthen thread visibility without changing how the code behaves.
This will not do anything undesirable like change how the socket connects, sends data, reconnects, or closes.
AubreyHaskett
commented
Oct 14, 2026
| @@ -0,0 +1,59 @@ | |||
| /* | |||
| * Copyright (C) 2024 pedroSG94. | |||
Contributor
Author
There was a problem hiding this comment.
added because most (but not all) of the tests have this. hope that's okay.
AubreyHaskett
marked this pull request as ready for review
October 14, 2026 19:53
Owner
|
Thank you for the PR. Merged |
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
👋 RootEncoder exposes RTMP ping/pong RTT, but not the RTT tracked by the kernel for the underlying TCP connection, which I'd love to have. This PR will:
java.net.Socketfor direct RTMP connections that use the Java socket implementationRtmpClient,RtmpStreamClient, andGenericStreamClientnullwhen the connection is inactive, tunneled, uses another protocol, or uses a non-Java socketContext
This is a follow-up to #2211. That proposal added native
TCP_INFOsupport inside RootEncoder, which we do not want to do, as it required heavy non-Java/Kotlin additions to the repo.This revision follows your recommendation -- RootEncoder only exposes its Java socket, while consumers can do what they like with that on their end (in my case, that will be obtaining a descriptor and implementing JNA/JNI diagnostics). This keeps code native, and keeps CMake/NDK config + ABI maintenance out of RootEncoder.
Users of RootEncoder will be able to use this socket access point for things other than kernel RTT as well (IP addresses/ports, correlating the connection w/app telemetry, additional info during SSLSocket use, additional TCP info, etc.).
Validation
./gradlew :common:testDebugUnitTest./gradlew :rtmp:testDebugUnitTest./gradlew :library:compileReleaseKotlinParcelFileDescriptor.fromSocket()andgetsockopt(TCP_INFO)during a live RTMPS stream: 111 consecutive RTT samples, 0 unavailable readings, 37.7–60.3 ms range, 48.0 ms averagePedro - thanks for your time reviewing, chatting, and for the great library!