[PR #236] [CLOSED] Implement adaptive bitrate for WHIP streaming #238

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

📋 Pull Request Information

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

Base: mainHead: copilot/implement-adaptive-bitrate-streaming


📝 Commits (3)

  • 540473e Initial plan
  • 602aef4 Implement adaptive bitrate for WHIP streaming
  • 2dc06c3 Rename misleading variable per code review feedback

📊 Changes

7 files changed (+122 additions, -9 deletions)

View changed files

📝 Moblin/Media/HaishinKit/Whip/WhipStream.swift (+15 -4)
📝 Moblin/Various/Media.swift (+53 -3)
📝 Moblin/Various/Model/Model.swift (+6 -0)
📝 Moblin/Various/Model/ModelStream.swift (+5 -1)
📝 Moblin/Various/Settings/SettingsStream.swift (+17 -0)
📝 Moblin/View/Settings/Streams/Stream/StreamSettingsView.swift (+5 -1)
Moblin/View/Settings/Streams/Stream/Whip/StreamWhipSettingsView.swift (+21 -0)

📄 Description

Adds adaptive bitrate support for WHIP streams, adjusting encoder target bitrate based on network capacity. Follows the existing patterns used by RTMP and RIST protocols.

Congestion detection

Since libdatachannel doesn't expose RTT or packet loss stats, congestion is inferred from failed rtcSendMessage calls. The failed-send percentage is fed into the existing AdaptiveBitrateSrtFight algorithm as the packetsInFlight signal, and transport bitrate is tracked via an EMA of bytes successfully sent.

Changes

  • WhipStream — Track sent/failed video packet counts; expose via getVideoPacketStats()
  • MediawhipStartStream now accepts targetBitrate and adaptiveBitrateEnabled; added updateAdaptiveBitrateWhip to compute stats and drive the algorithm; whipStopStream cleans up; streamTransportBitrate reports WHIP throughput
  • SettingsStream — New SettingsStreamWhip class with adaptiveBitrateEnabled; added whip property with Codable/clone support; bitrateString() shows < prefix when enabled
  • Model/ModelStreamstartNetStreamWhip passes bitrate config; added updateAdaptiveBitrateWhipIfEnabled
  • UI — New StreamWhipSettingsView with adaptive bitrate toggle; StreamSettingsView links to it instead of EmptyView()

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


🔄 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/236 **Author:** [@Copilot](https://github.com/apps/copilot-swe-agent) **Created:** 2/13/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `copilot/implement-adaptive-bitrate-streaming` --- ### 📝 Commits (3) - [`540473e`](https://github.com/eerimoq/moblin/commit/540473e089a67e0d7e2d859cc0ec9f8cbf72c6a0) Initial plan - [`602aef4`](https://github.com/eerimoq/moblin/commit/602aef45fd1403e826a1663ab473ff89af53af22) Implement adaptive bitrate for WHIP streaming - [`2dc06c3`](https://github.com/eerimoq/moblin/commit/2dc06c3fcee1b48d882cb7bc0193759bf9de8411) Rename misleading variable per code review feedback ### 📊 Changes **7 files changed** (+122 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `Moblin/Media/HaishinKit/Whip/WhipStream.swift` (+15 -4) 📝 `Moblin/Various/Media.swift` (+53 -3) 📝 `Moblin/Various/Model/Model.swift` (+6 -0) 📝 `Moblin/Various/Model/ModelStream.swift` (+5 -1) 📝 `Moblin/Various/Settings/SettingsStream.swift` (+17 -0) 📝 `Moblin/View/Settings/Streams/Stream/StreamSettingsView.swift` (+5 -1) ➕ `Moblin/View/Settings/Streams/Stream/Whip/StreamWhipSettingsView.swift` (+21 -0) </details> ### 📄 Description Adds adaptive bitrate support for WHIP streams, adjusting encoder target bitrate based on network capacity. Follows the existing patterns used by RTMP and RIST protocols. ### Congestion detection Since `libdatachannel` doesn't expose RTT or packet loss stats, congestion is inferred from failed `rtcSendMessage` calls. The failed-send percentage is fed into the existing `AdaptiveBitrateSrtFight` algorithm as the `packetsInFlight` signal, and transport bitrate is tracked via an EMA of bytes successfully sent. ### Changes - **`WhipStream`** — Track sent/failed video packet counts; expose via `getVideoPacketStats()` - **`Media`** — `whipStartStream` now accepts `targetBitrate` and `adaptiveBitrateEnabled`; added `updateAdaptiveBitrateWhip` to compute stats and drive the algorithm; `whipStopStream` cleans up; `streamTransportBitrate` reports WHIP throughput - **`SettingsStream`** — New `SettingsStreamWhip` class with `adaptiveBitrateEnabled`; added `whip` property with Codable/clone support; `bitrateString()` shows `<` prefix when enabled - **`Model`/`ModelStream`** — `startNetStreamWhip` passes bitrate config; added `updateAdaptiveBitrateWhipIfEnabled` - **UI** — New `StreamWhipSettingsView` with adaptive bitrate toggle; `StreamSettingsView` links to it instead of `EmptyView()` <!-- START COPILOT CODING AGENT TIPS --> --- ✨ Let Copilot coding agent [set things up for you](https://github.com/eerimoq/moblin/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot) — coding agent works faster and does higher quality work when set up for your repo. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-02 04:00:52 +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#238
No description provided.