Skip to content

Feature: Add Lightweight ONVIF Support for RTSP Server Discovery#354

Open
SB2318 wants to merge 2 commits into
dkrivoruchko:masterfrom
SB2318:onvif-support-for-rtsp
Open

Feature: Add Lightweight ONVIF Support for RTSP Server Discovery#354
SB2318 wants to merge 2 commits into
dkrivoruchko:masterfrom
SB2318:onvif-support-for-rtsp

Conversation

@SB2318
Copy link
Copy Markdown
Contributor

@SB2318 SB2318 commented May 12, 2026

Description

This PR introduces a lightweight, non-conformant ONVIF server for RTSP streaming mode. It enables ScreenStream to be automatically discovered by Network Video Recorders (NVRs) and Video Management Software (VMS) on the local network.

Fixes #346

Key Features

  • WS-Discovery Support
    Implemented UDP multicast discovery:

    • IPv4: 239.255.255.250
    • IPv6: FF02::C
    • Port: 3702

    This allows automatic device discovery on the local network.

  • SOAP HTTP Server
    Added a lightweight SOAP server running on RTSP_PORT + 1000 (default: 9554) to handle core ONVIF Profile T/S requests.

  • Multicast Management
    Added proper permission handling and MulticastLock management to improve multicast reliability across Android versions and device manufacturers.

  • UI Integration
    Added a real-time counter in the RTSP Server UI to provide visual feedback whenever an ONVIF probe or request is received.


Technical Details

  • Modules Modified: rtsp, app
  • Core Logic: OnvifServer.kt handles low-level XML/SOAP routing without external heavy libraries, keeping the app lightweight.
  • Lifecycle Management: The ONVIF server is tightly coupled with the RtspServer lifecycle and starts/stops automatically when streaming begins or ends.
  • Permissions: Added android.permission.CHANGE_WIFI_MULTICAST_STATE to allow multicast packet reception.

Proposed Changes

rtsp

  • [NEW] OnvifServer.kt — Core implementation for WS-Discovery and SOAP handlers
  • [MODIFIED] RtspServer.kt — Integrated ONVIF server startup/shutdown
  • [MODIFIED] RtspStreamingService.kt — Added event handling for ONVIF request tracking
  • [MODIFIED] models.kt — Added onvifServerMessagesCount to RtspState
  • [MODIFIED] RtspMainScreenUI.kt — Updated UI cards to display ONVIF request counter

app

  • [MODIFIED] AndroidManifest.xml — Added required multicast permission

Verification Report

Environment

  • Device: Physical Android device (verified via ADB)
  • Network: Local Wi-Fi (IPv4 + IPv6 enabled)
  • Tools: Custom Python testing suite (WS-Discovery + SOAP 1.2)

Test Results

Test Case Method Result Notes
WS-Discovery Probe UDP 3702 Multicast ✅ PASS Responds with valid ProbeMatch
GetDeviceInformation SOAP HTTP ✅ PASS Returns "ScreenStream ONVIF Server"
GetProfiles SOAP HTTP ✅ PASS Returns "Profile_1" (Main Stream)
GetStreamUri SOAP HTTP ✅ PASS Returns valid rtsp://<ip>:<port>/<path>
UI Feedback Integration ✅ PASS Counter increments in real time on probe/request reception
WhatsApp Image 2026-05-12 at 9 03 22 AM (1)

Status: Ready for Review

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.

Add ONVIF support for RTSP server mode

1 participant