[PR #231] [CLOSED] Add WHIP WebRTC streaming support via libdatachannel #232

Closed
opened 2026-03-02 04:00:50 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/eerimoq/moblin/pull/231
Author: @Copilot
Created: 2/9/2026
Status: Closed

Base: mainHead: copilot/add-webrtc-support-whip-servers-again


📝 Commits (4)

  • d9d1598 Initial plan
  • 83a4d7d Add WHIP WebRTC streaming support with libdatachannel
  • 14bf477 Fix sign extension bug in NAL length parsing
  • 0a158c7 Cleanup.

📊 Changes

9 files changed (+550 additions, -1 deletions)

View changed files

📝 Common/Localizable.xcstrings (+3 -0)
📝 Common/Various/Validate.swift (+2 -0)
📝 Moblin.xcodeproj/project.pbxproj (+15 -0)
📝 Moblin.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved (+10 -1)
Moblin/Media/HaishinKit/Whip/WhipStream.swift (+448 -0)
📝 Moblin/Various/Media.swift (+37 -0)
📝 Moblin/Various/Model/ModelStream.swift (+27 -0)
📝 Moblin/Various/Settings/SettingsStream.swift (+6 -0)
📝 Moblin/View/Settings/Streams/Stream/StreamSettingsView.swift (+2 -0)

📄 Description

Adds support for streaming to standard WHIP servers over WebRTC, using eerimoq/Webrtc (libdatachannel SPM wrapper). One video track (H.264/H.265) and one audio track (Opus), sent as RTP. No data channels.

Protocol & settings

  • Added whip to SettingsStreamProtocol / SettingsStreamDetailedProtocol
  • whip:// maps to HTTP, whips:// maps to HTTPS for WHIP signaling
  • URL validation accepts whip/whips schemes

WhipStream (new)

Core WebRTC transport in Moblin/Media/HaishinKit/Whip/WhipStream.swift:

  • Creates peer connection via libdatachannel C API, adds sendonly video + audio tracks with RTP packetizers
  • Implements VideoEncoderDelegate / AudioEncoderDelegate directly — receives encoded frames from Processor, converts AVCC NAL units to Annex B start codes, feeds to libdatachannel's H.264/H.265/Opus RTP packetizers
  • WHIP signaling: waits for ICE gathering complete → POST SDP offer → set remote SDP answer
  • Sends DELETE to the resource URL on teardown
whip://my-server.example.com/whip/live
whips://my-server.example.com/whip/live

Integration

  • Media.swift: whipStream instance, whipStartStream()/whipStopStream(), WhipStreamDelegate conformance
  • ModelStream.swift: WHIP case in startNetStream()/stopNetStream(), connected/disconnected handlers
  • MediaDelegate: added mediaOnWhipConnected/mediaOnWhipDisconnected
  • StreamSettingsView: shows WHIP label for whip-scheme streams

Dependency

  • Added eerimoq/Webrtc SPM package (pinned to main, consistent with other eerimoq dependencies like Rist, SwiftCube)

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/eerimoq/moblin/pull/231 **Author:** [@Copilot](https://github.com/apps/copilot-swe-agent) **Created:** 2/9/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `copilot/add-webrtc-support-whip-servers-again` --- ### 📝 Commits (4) - [`d9d1598`](https://github.com/eerimoq/moblin/commit/d9d1598ab426d0f387ec2743e0ad571a2a80cb14) Initial plan - [`83a4d7d`](https://github.com/eerimoq/moblin/commit/83a4d7dacc0aa5708934866248874cebee23e3d1) Add WHIP WebRTC streaming support with libdatachannel - [`14bf477`](https://github.com/eerimoq/moblin/commit/14bf47745bcb5d5c4d297f428ae618228e6093bb) Fix sign extension bug in NAL length parsing - [`0a158c7`](https://github.com/eerimoq/moblin/commit/0a158c733646a4dd609b7af23262c9ef0b17c569) Cleanup. ### 📊 Changes **9 files changed** (+550 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `Common/Localizable.xcstrings` (+3 -0) 📝 `Common/Various/Validate.swift` (+2 -0) 📝 `Moblin.xcodeproj/project.pbxproj` (+15 -0) 📝 `Moblin.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved` (+10 -1) ➕ `Moblin/Media/HaishinKit/Whip/WhipStream.swift` (+448 -0) 📝 `Moblin/Various/Media.swift` (+37 -0) 📝 `Moblin/Various/Model/ModelStream.swift` (+27 -0) 📝 `Moblin/Various/Settings/SettingsStream.swift` (+6 -0) 📝 `Moblin/View/Settings/Streams/Stream/StreamSettingsView.swift` (+2 -0) </details> ### 📄 Description Adds support for streaming to standard WHIP servers over WebRTC, using [eerimoq/Webrtc](https://github.com/eerimoq/Webrtc) (libdatachannel SPM wrapper). One video track (H.264/H.265) and one audio track (Opus), sent as RTP. No data channels. ### Protocol & settings - Added `whip` to `SettingsStreamProtocol` / `SettingsStreamDetailedProtocol` - `whip://` maps to HTTP, `whips://` maps to HTTPS for WHIP signaling - URL validation accepts `whip`/`whips` schemes ### WhipStream (new) Core WebRTC transport in `Moblin/Media/HaishinKit/Whip/WhipStream.swift`: - Creates peer connection via libdatachannel C API, adds sendonly video + audio tracks with RTP packetizers - Implements `VideoEncoderDelegate` / `AudioEncoderDelegate` directly — receives encoded frames from `Processor`, converts AVCC NAL units to Annex B start codes, feeds to libdatachannel's H.264/H.265/Opus RTP packetizers - WHIP signaling: waits for ICE gathering complete → POST SDP offer → set remote SDP answer - Sends DELETE to the resource URL on teardown ``` whip://my-server.example.com/whip/live whips://my-server.example.com/whip/live ``` ### Integration - `Media.swift`: `whipStream` instance, `whipStartStream()`/`whipStopStream()`, `WhipStreamDelegate` conformance - `ModelStream.swift`: WHIP case in `startNetStream()`/`stopNetStream()`, connected/disconnected handlers - `MediaDelegate`: added `mediaOnWhipConnected`/`mediaOnWhipDisconnected` - `StreamSettingsView`: shows WHIP label for whip-scheme streams ### Dependency - Added `eerimoq/Webrtc` SPM package (pinned to `main`, consistent with other eerimoq dependencies like Rist, SwiftCube) <!-- START COPILOT CODING AGENT TIPS --> --- 💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more [Copilot coding agent tips](https://gh.io/copilot-coding-agent-tips) in the docs. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem closed this issue 2026-03-02 04:00:51 +03:00
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/moblin#232
No description provided.