Skip to content

feat(p2p): implement TorrServer-based P2P streaming for desktop#122

Open
aelrased wants to merge 1 commit into
NuvioMedia:Devfrom
aelrased:p2p-streaming-only
Open

feat(p2p): implement TorrServer-based P2P streaming for desktop#122
aelrased wants to merge 1 commit into
NuvioMedia:Devfrom
aelrased:p2p-streaming-only

Conversation

@aelrased

Copy link
Copy Markdown

Port the Android TorrServer-based P2P engine to Desktop (Windows and Linux).

Changes

  • P2pStreamingEngine.desktop.kt: Full implementation replacing the stub
    • TorrServerBinary: manages process lifecycle (start, stop, health check)
    • TorrServerApi: HTTP REST client for TorrServer JSON API using Ktor CIO + kotlinx.serialization
    • Stream management with generation counter pattern, file index resolution, stats polling
    • Binary extraction from classpath resources at runtime (same pattern as NativePlayerBridge)
  • AppFeaturePolicy.desktop.kt: Enabled p2pEnabled = true
  • build.gradle.kts: Added downloadTorrserver Gradle task + JAR bundling for Linux

How it works

  1. Bundles TorrServer binary (torrserver for Linux, torrserver.exe for Windows) in JAR resources at /native/torrserver/
  2. Starts TorrServer as a local HTTP server on port 8091 via ProcessBuilder
  3. Player streams from http://127.0.0.1:8091/stream?link=...&index=...&play

Testing

  • Built with ./gradlew :composeApp:compileKotlinDesktop
  • P2P toggle appears in settings
  • TorrServer binary is extracted and started
  • Stream URL is returned and playback attempts to start

- Port Android P2pStreamingEngine to desktop using TorrServer
- TorrServerBinary: process lifecycle, binary extraction from resources
- TorrServerApi: HTTP REST client using Ktor CIO + kotlinx.serialization
- Enable p2pEnabled flag in AppFeaturePolicy for desktop
- Supports Windows (torrserver.exe) and Linux (torrserver) binaries
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant