Skip to content

Implement WHIP server ingest#235

Draft
Copilot wants to merge 4 commits intomainfrom
copilot/implement-whip-server-ingest
Draft

Implement WHIP server ingest#235
Copilot wants to merge 4 commits intomainfrom
copilot/implement-whip-server-ingest

Conversation

Copy link
Contributor

Copilot AI commented Feb 13, 2026

Adds a WHIP server for receiving WebRTC streams (H.264 video + Opus audio) into the app, reusing the existing HttpServer infrastructure.

HTTP server enhancements (HttpServer.swift)

  • Request body parsing via Content-Length
  • Custom response Content-Type and headers
  • 201 Created / 204 No Content status codes
  • Prefix-based route matching for DELETE /whip/{id}

WebRTC receive path (WhipServerClient.swift)

  • Accepts SDP offer via libdatachannel, returns SDP answer after ICE gathering
  • rtcSetTrackCallback + rtcSetMessageCallback to receive RTP on incoming tracks
  • H.264 RTP depacketization (single NAL + FU-A), SPS/PPS extraction → CMVideoFormatDescription → hardware decode via VideoDecoder
  • Opus RTP → AVAudioConverter decode to PCM Int16 → CMSampleBuffer

WHIP protocol (WhipServer.swift)

  • POST /whip — SDP offer/answer exchange, returns 201 with Location header
  • DELETE /whip/{id} — client teardown
  • Manages concurrent WhipServerClient instances keyed by UUID

Settings & model integration

  • SettingsWhipServer / SettingsWhipServerStream in SettingsIngests.swift
  • Database.whipServer with encode/decode
  • ModelWhipServer.swift implements WhipServerDelegate, routes decoded video/audio into the buffered media pipeline via appendBufferedVideoSampleBuffer / appendBufferedAudioSampleBuffer
  • whipCamera() / isWhipCameraOrMic() helpers in CommonUtils.swift

WHIP endpoint usage

A WHIP client (e.g. OBS, ffmpeg, GStreamer) sends an SDP offer:

POST /whip HTTP/1.1
Content-Type: application/sdp

v=0
...

Server responds with the SDP answer and a session URL for teardown:

HTTP/1.1 201 Created
Content-Type: application/sdp
Location: /whip/<session-uuid>

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits February 13, 2026 18:36
…264/Opus depacketization, HTTP server body parsing, and model integration

Co-authored-by: eerimoq <176810+eerimoq@users.noreply.github.com>
… parameters

Co-authored-by: eerimoq <176810+eerimoq@users.noreply.github.com>
… creation

Co-authored-by: eerimoq <176810+eerimoq@users.noreply.github.com>
Copilot AI changed the title [WIP] Add WHIP server ingest for video and audio tracks Implement WHIP server ingest Feb 13, 2026
Copilot AI requested a review from eerimoq February 13, 2026 18:43
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.

2 participants