unified-headless-video-core

Crates.iounified-headless-video-core
lib.rsunified-headless-video-core
version0.3.0
created_at2026-01-25 15:14:31.979546+00
updated_at2026-01-25 15:14:31.979546+00
descriptionCross-platform headless video playback logic engine - Same code, same behavior, all platforms
homepagehttps://github.com/4iShmmri/unified-headless-video-core
repositoryhttps://github.com/4iShmmri/unified-headless-video-core
max_upload_size
id2068931
size525,462
(4iShmmri)

documentation

https://docs.rs/unified-headless-video-core

README

๐ŸŽฌ Unified Headless Video Playback Core

Rust License Version

Cross-platform video playback logic engine - Same code, same behavior, all platforms.


๐ŸŽฏ What is This?

A Rust library that manages video playback logic (state management, quality decisions, events) without performing video decoding or rendering. It works seamlessly with native video players on each platform (ExoPlayer on Android, AVPlayer on iOS, video_player on Flutter, react-native-video on React Native, HTML5 Video on Web).

Core Principle: Core makes decisions โ†’ Platform adapters execute them.

Why Use This?

Traditional video playback solutions require maintaining separate codebases for each platform, leading to:

  • โŒ Inconsistent behavior across platforms
  • โŒ Different bugs on different platforms
  • โŒ High maintenance costs
  • โŒ Duplicated logic

Unified Headless Video Playback Core solves this by providing:

  • โœ… One Core for all platforms
  • โœ… Consistent behavior everywhere
  • โœ… Single source of truth for playback logic
  • โœ… Reduced maintenance - fix bugs once, benefit everywhere

โœจ Key Features

Format Support (9 Formats)

  • Container Formats: MP4, WebM, MKV, FLV
  • Adaptive Streaming: HLS, DASH, Smooth Streaming
  • Streaming Protocols: RTMP, RTSP

Platform Support (5 Platforms)

  • Web - WASM bindings for HTML5 Video
  • Android - Kotlin/JNI bindings for ExoPlayer
  • iOS - Swift bindings for AVPlayer
  • Flutter - Dart/FFI bindings for video_player
  • React Native - TypeScript bindings for react-native-video

Core Capabilities

  • โœ… State Machine - Deterministic playback state management
  • โœ… Adaptive Bitrate (ABR) - Built-in ABR engine with 3 strategies
  • โœ… Playback Speed - Control speed from 0.25x to 4.0x
  • โœ… Chapters - Full chapter management & navigation
  • โœ… Subtitle Detection - Automatic format detection (SRT, VTT, TTML)
  • โœ… Dynamic Quality - Request quality targets with downscaling support
  • โœ… Live Streaming - Full support for live & VOD streams
  • โœ… Plugin System - Extensible for analytics, ads, and more
  • โœ… DRM Policy - DRM policy handling and decisions
  • โœ… Enhanced Metadata Extraction - Advanced parsing for all formats

๐Ÿš€ Quick Start

โšก Fast Install? See QUICK_INSTALL.md for one-command installation on any platform.

Installation

Option 1: From Git (Development/Unpublished Versions)

For development or unpublished versions, install from Git:

[dependencies]
unified-headless-video-core = { git = "https://github.com/4iShmmri/unified-headless-video-core", tag = "v0.3.0" }

Or use the latest commit:

[dependencies]
unified-headless-video-core = { git = "https://github.com/4iShmmri/unified-headless-video-core" }

Option 2: From crates.io (Recommended)

Install directly from crates.io:

[dependencies]
unified-headless-video-core = "0.3.0"

Or use the latest version:

[dependencies]
unified-headless-video-core = "0.3"

Option 3: Build from Source

Clone the repository and add as a local dependency:

git clone https://github.com/4iShmmri/unified-headless-video-core.git
cd unified-headless-video-core

Then in your Cargo.toml:

[dependencies]
unified-headless-video-core = { path = "../unified-headless-video-core" }

Platform-Specific Installation

For platform-specific integrations (Android, iOS, Flutter, React Native, Web), see:

Basic Usage (Rust)

use core::core::*;

fn main() -> Result<()> {
    // Create player
    let mut player = CorePlayer::new(Config::default())?;
    
    // Load video
    player.load("https://example.com/video.mp4")?;
    
    // Play
    player.play()?;
    
    // Control playback
    player.set_speed(1.5)?;  // 1.5x speed
    player.seek(30.0)?;      // Seek to 30 seconds
    
    // Handle events
    player.on_event(Box::new(|event| {
        match event {
            Event::Play => println!("Playing"),
            Event::QualityChanged(q) => println!("Quality: {}", q),
            Event::Error(msg) => eprintln!("Error: {}", msg),
            _ => {}
        }
    }));
    
    Ok(())
}

Platform Adapters

See platform-specific documentation:


๐Ÿ’ก Why Choose This Over Other Solutions?

Comparison with Platform-Specific Players

โŒ Without Core (Traditional Approach)

Android (ExoPlayer):

// Different code for each platform
val exoPlayer = ExoPlayer.Builder(context).build()
exoPlayer.setMediaItem(MediaItem.fromUri(url))
exoPlayer.prepare()
exoPlayer.play()

// Different ABR logic
// Different state management
// Different event handling

iOS (AVPlayer):

// Completely different code
let player = AVPlayer(url: URL(string: url)!)
player.play()

// Different ABR logic
// Different state management  
// Different event handling

Problems:

  • ๐Ÿ”ด Different behavior on each platform
  • ๐Ÿ”ด Bugs appear on one platform but not others
  • ๐Ÿ”ด Need to maintain 5+ codebases
  • ๐Ÿ”ด Inconsistent user experience

โœ… With Core (Unified Approach)

All Platforms:

// Same code everywhere!
let mut player = CorePlayer::new(Config::default())?;
player.load(url)?;
player.play()?;

// Same ABR logic everywhere
// Same state management everywhere
// Same event handling everywhere

Benefits:

  • โœ… Consistent behavior across all platforms
  • โœ… Single codebase for playback logic
  • โœ… Fix bugs once, benefit everywhere
  • โœ… Unified user experience

Comparison Table

Feature Without Core With Core
Code Consistency โŒ Different code per platform โœ… Same code everywhere
Behavior โŒ Inconsistent โœ… Identical
Bug Fixes โŒ Fix 5+ times โœ… Fix once
ABR Logic โŒ Platform-specific โœ… Unified
State Management โŒ Platform-specific โœ… Unified
Maintenance โŒ High (5x effort) โœ… Low (1x effort)
Testing โŒ Test 5+ platforms โœ… Test Core once

๐Ÿ“š Documentation


๐ŸŽฎ Examples

See the examples directory for complete examples:

  • basic_usage.rs - Basic playback
  • webm_example.rs - WebM format with enhanced metadata
  • mkv_example.rs - MKV format with subtitle support
  • flv_example.rs - FLV format with metadata extraction
  • rtmp_example.rs - RTMP streaming
  • rtsp_example.rs - RTSP streaming
  • smooth_streaming_example.rs - Smooth Streaming with fragment URLs
  • advanced_usage.rs - Advanced features

๐Ÿงช Testing

The project includes comprehensive testing:

  • 52+ Unit Tests - Core functionality
  • Integration Tests - Format support and enhanced features
  • Stress Tests - Performance under load
  • Performance Benchmarks - Parser and operation benchmarks

Run tests:

cargo test
cargo test -- --ignored  # Run stress tests
cargo bench              # Run benchmarks

๐Ÿ—๏ธ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    Application Layer                        โ”‚
โ”‚  (Your App: Android/iOS/Flutter/React Native/Web)           โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                        โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚              Platform Adapter Layer                         โ”‚
โ”‚  (Thin Wrappers: Kotlin/Swift/Dart/TypeScript/WASM)        โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                        โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                  FFI Bridge Layer                           โ”‚
โ”‚  (C API / WASM API)                                          โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                        โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                  Rust Core Layer                            โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”      โ”‚
โ”‚  โ”‚ State Machineโ”‚  โ”‚  ABR Engine  โ”‚  โ”‚   Parsers    โ”‚      โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜      โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”      โ”‚
โ”‚  โ”‚ Event System โ”‚  โ”‚ Plugin Systemโ”‚  โ”‚ DRM Handler  โ”‚      โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜      โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                        โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚              Native Player Layer                             โ”‚
โ”‚  (ExoPlayer / AVPlayer / video_player / HTML5 Video)        โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ”ง Building

Prerequisites

  • Rust 1.70+
  • Cargo

Build Commands

cargo build            # Debug build
cargo build --release  # Release build
cargo test            # Run tests
cargo fmt             # Format code
cargo clippy          # Lint code

Platform-Specific Builds

See platform-specific READMEs for build instructions:


๐Ÿ“Š Project Status

Status: โœ… Production Ready
Version: 0.2.0
Test Coverage: 52+ tests


๐Ÿ“„ License

Licensed under either of:

at your option.


๐Ÿค Contributing

Contributions are welcome! Please see our contributing guidelines.


๐Ÿ”— Links


Built with โค๏ธ using Rust

Commit count: 0

cargo fmt