Skip to content

Migrate Linux player from GStreamer Java/JNA to native C via JNI#185

Merged
kdroidFilter merged 1 commit into
masterfrom
feature/linux-jni-native-gstreamer
Apr 10, 2026
Merged

Migrate Linux player from GStreamer Java/JNA to native C via JNI#185
kdroidFilter merged 1 commit into
masterfrom
feature/linux-jni-native-gstreamer

Conversation

@kdroidFilter

@kdroidFilter kdroidFilter commented Apr 10, 2026

Copy link
Copy Markdown
Owner

Summary

  • Replace GStreamer Java/JNA with a native C library (NativeVideoPlayer.c) using GStreamer C API directly (playbin + appsink + scaletempo + level), matching the macOS/Windows JNI architecture
  • Remove JNA dependency entirely from the project — platform detection now uses System.getProperty("os.name") via CurrentPlatform utility
  • Remove gst1-java-core dependency — GStreamer is now used exclusively through the native C layer
  • Rewrite LinuxVideoPlayerState with coroutine-driven polling, AtomicLong native pointer, double-buffered Skia bitmaps, and output scaling — identical pattern to MacVideoPlayerState
  • Add dedicated bus polling thread using gst_bus_timed_pop (no GLib main loop needed)
  • Add queue element between decoder and appsink for thread decoupling
  • Native build via CMake + build.sh, producing libNativeVideoPlayer.so embedded in JAR resources

Test plan

  • Play local video files (MP4, WebM) on Linux
  • Play HTTP/HLS streams on Linux
  • Verify audio playback and volume control
  • Verify seek works correctly
  • Verify playback speed changes (0.5x - 2.0x)
  • Verify loop mode
  • Verify audio level meters (left/right)
  • Verify metadata extraction (title, bitrate, dimensions, frame rate)
  • Verify output scaling (resize window, check memory usage with 4K video)
  • Verify fullscreen toggle
  • Verify subtitle overlay
  • Verify no regression on macOS build
  • Verify no regression on Windows build

Replace the entire Linux video player backend with a native C library
using GStreamer C API directly, matching the macOS/Windows JNI architecture.

- Add native C GStreamer player (playbin + appsink + scaletempo + level)
- Add JNI bridge with 27 native methods
- Add CMake build system and build.sh for Linux
- Add Kotlin SharedVideoPlayer JNI binding
- Rewrite LinuxVideoPlayerState with coroutine-driven polling (like Mac)
- Add output scaling support via appsink caps
- Add queue element for thread decoupling between decoder and frame extraction
- Add dedicated bus polling thread (no GLib main loop needed)
- Remove GStreamer Java (gst1-java-core) dependency
- Remove JNA dependency entirely, replace with CurrentPlatform utility
- Update all tests to use CurrentPlatform instead of JNA Platform
@kdroidFilter kdroidFilter merged commit 736135b into master Apr 10, 2026
1 of 2 checks passed
@kdroidFilter kdroidFilter deleted the feature/linux-jni-native-gstreamer branch April 11, 2026 21:17
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