v4.2.0
We are pleased to announce our final and largest release of 2025. This release includes contributions from 69 contributors.
This release also marks a new era for Pion. Going forward, we will publish releases on a regular schedule.
Major new features
RACK
- We are happy to announce that SCTP now includes a RACK implementation, enabled by default. This work is included in https://github.com/pion/sctp/pull/390 and https://github.com/pion/sctp/pull/438, with a reported 71% improvement in maximum throughput and 27% better latency.
ICE Renomination
- Pion now supports ICE renomination It was added in https://github.com/pion/ice/pull/822 and https://github.com/pion/ice/pull/799, and integrated into WebRTC in https://github.com/pion/webrtc/pull/3306. It can be enabled via the SettingEngine.
// For advanced use with a custom generator and interval.
se := webrtc.SettingEngine{}
interval := 2 * time.Second
customGen := func() uint32 { return uint32(time.Now().UnixNano()) } // example
if err := se.SetICERenomination(
webrtc.WithRenominationGenerator(customGen),
webrtc.WithRenominationInterval(interval),
); err != nil {
log.Println(err)
}
Cryptex
- Pion now supports Cryptex, enabling full encryption of RTP headers and header extensions. This work is included in https://github.com/pion/srtp/pull/324 and https://github.com/pion/sdp/pull/213.
FlexFEC
- FlexFEC has been added, is stable, and is ready for production use. See https://github.com/pion/interceptor/pull/333, https://github.com/pion/webrtc/pull/3075, https://github.com/pion/interceptor/pull/330, https://github.com/pion/interceptor/pull/344, and https://github.com/pion/interceptor/pull/383.
ICEAddressRewriteRule
- Pion’s NAT 1:1 API is now deprecated. After years of use, it no longer fits modern deployment models. This change is implemented in https://github.com/pion/ice/pull/834 and https://github.com/pion/webrtc/pull/3309.
The new API, SetICEAddressRewriteRules(rules ...ICEAddressRewriteRule) error, rewrites the IP addresses embedded in gathered ICE candidates.
Rule fields (high level):
- External []string: the address or addresses you want to expose
- Matchers: Local, CIDR, or Iface
- Mode: Replace (default) or Append (keep the original and add the rewritten candidate)
- Optional: AsCandidateType (for example, rewrite as srflx)
se := webrtc.SettingEngine{}
_ = se.SetICEAddressRewriteRules(
webrtc.ICEAddressRewriteRule{
Local: "10.0.0.12",
External: []string{"203.0.113.10"},
// Mode omitted, defaults to Replace.
},
)
api := webrtc.NewAPI(webrtc.WithSettingEngine(se))
// pc, _ := api.NewPeerConnection(...)
// For more advanced use.
se := webrtc.SettingEngine{}
se.SetICEAddressRewriteRules(
// Allow eth0 (map RFC1918 to public 203.0.113.10)
webrtc.ICEAddressRewriteRule{
Iface: "eth0",
CIDR: "10.0.0.0/8",
External: []string{"203.0.113.10"},
Mode: webrtc.ICEAddressRewriteReplace,
},
// Allow eth1 (map 192.168/16 to public 198.51.100.20)
webrtc.ICEAddressRewriteRule{
Iface: "eth1",
CIDR: "192.168.0.0/16",
External: []string{"198.51.100.20"},
Mode: webrtc.ICEAddressRewriteReplace,
},
// Catch-all: drop any other IPv4 host candidates
webrtc.ICEAddressRewriteRule{
CIDR: "0.0.0.0/0",
Mode: webrtc.ICEAddressRewriteReplace,
External: nil, // drop
},
// Catch-all: drop any other IPv6 host candidates
webrtc.ICEAddressRewriteRule{
CIDR: "::/0",
Mode: webrtc.ICEAddressRewriteReplace,
External: nil, // drop
},
)
SVT-AV1
- Adds a new AV1 video encoder to pion/mediadevices backed by SVT-AV1: https://github.com/pion/mediadevices/pull/660.
HEVC reader and writer
-
https://github.com/pion/webrtc/pull/3171
pkg/media/h265readerparses an H.265/HEVC Annex-B byte stream (start-code delimited) into NAL units you can work with.pkg/media/h265writertakes H.265 RTP payloads (RFC 7798) and writes them back out as an Annex-B bytestream, which is useful for recording and archiving.
New OGG Reader API
-
A series of improvements to oggreader:
- #3301 adds OpusTags support via
ParseOpusTags, enabling access to artist, title, and vendor comments. - #3299 expands
ParseOpusHeadto parse Opus channel mappings for multichannel layouts. - #3300 updates oggreader to handle multi-track Ogg by routing pages by serial and introducing
NewWithOptionsalong with richer page and header APIs. - #3302 validates the full flow by streaming single-track and multi-track Ogg with a playlist and metadata over DataChannel control, while audio remains on the RTP track.
- #3301 adds OpusTags support via
More great features
- Do not discard SEI NALs for H264/H265 — https://github.com/pion/webrtc/pull/3313
- Use ping-pong buffer for batch conn — https://github.com/pion/transport/pull/363
- Add CanTrickleICECandidates — https://github.com/pion/webrtc/pull/3283
- Add nohost gather policy — https://github.com/pion/webrtc/pull/3305
- Make Allocation/Permission lifetime configurable — https://github.com/pion/turn/pull/495
- RFC: Add a configurable sized nonce generator — https://github.com/pion/turn/pull/460
- Add AudioPlayoutStatsProvider interface for getting media-playout stats — https://github.com/pion/webrtc/pull/3234
- Expose stats ID for use in interceptor factories — https://github.com/pion/webrtc/pull/3249
- Allow IVFWriter Width/Height to be modified — https://github.com/pion/webrtc/pull/3219
- Allow IVFWriter Framerate to be modified — https://github.com/pion/webrtc/pull/3220
New Examples
- Add ice-proxy example (2) — https://github.com/pion/webrtc/pull/3165
- Add Play from disk ogg playlist example — https://github.com/pion/webrtc/pull/3302
- Add examples/encrypt-decrypt — https://github.com/pion/srtp/pull/353
- Add simple datachannel example with demo.html — https://github.com/pion/webrtc/pull/3252
- Add real-time encoder integration example — https://github.com/pion/bwe-test/pull/99
- Add gocv-to-webrtc — https://github.com/pion/example-webrtc-applications/pull/370
- Create examples/data-channels-detach-create — https://github.com/pion/webrtc/pull/3225
Major bug fixes
- Fix a deadlock in TaskLoop — https://github.com/pion/ice/pull/840
- Fix a deadlock with Abort — https://github.com/pion/sctp/pull/441
- Fix nack deadlocks from writers — https://github.com/pion/interceptor/pull/387
- Fix race condition in setSelectedPair — https://github.com/pion/ice/pull/826
- Fix memory leak with nackCountLogs — https://github.com/pion/interceptor/pull/386
- Fix a leak with pop in pending_queue — https://github.com/pion/sctp/pull/401
- Fix PacketsReceived underflow — https://github.com/pion/interceptor/pull/389
- Fix RTP timestamp drift in WriteSample — https://github.com/pion/webrtc/pull/3312
- Prevent negative intervals — https://github.com/pion/dtls/pull/760
- Do not block on SCTP accept if the transport is aborted — https://github.com/pion/webrtc/pull/3308
- Fix infinite loop when current time equals deadline — https://github.com/pion/transport/pull/359
- Fix zero-delta case in overuse detector — https://github.com/pion/interceptor/pull/369
- Fix off-by-one in TwoByteHeaderExtension.Set — https://github.com/pion/rtp/pull/335
- Fix off-by-one in OneByteHeaderExtension.Set — https://github.com/pion/rtp/pull/334
- Fix unmarshalling extension-only packet — https://github.com/pion/rtp/pull/325
- Fix padding overflow with PacketFactory — https://github.com/pion/interceptor/pull/338
- Fix RTPSender.SetReadDeadline crash — https://github.com/pion/webrtc/pull/3224
- fix track.unbind panic — https://github.com/pion/mediadevices/pull/634
- Do not invoke OnBufferedAmountLow after close — https://github.com/pion/webrtc/pull/3291
- Emit a disconnected state before failing — https://github.com/pion/ice/pull/846
- Fix error reporting in SendIndication handler — https://github.com/pion/turn/pull/466
- Fix sender/receiver reports in whip-whep example — https://github.com/pion/webrtc/pull/3167
- Permissively parse SDPs unless completely invalid — https://github.com/pion/webrtc/pull/3297
- Warn on non-zero reliability parameter for reliable channels — https://github.com/pion/datachannel/pull/263
- Assert DONT-FRAGMENT behavior in Server (1) — https://github.com/pion/turn/pull/494
- Assert DONT-FRAGMENT behavior in Server (2) — https://github.com/pion/turn/pull/493
- Add Unknown Attribute Handler — https://github.com/pion/turn/pull/486
Performance improvement
- Optimize slice allocation in UDPMuxDefault — https://github.com/pion/ice/pull/788
- Add MarshalTo for zero-allocation extension marshalling — https://github.com/pion/rtp/pull/344
- Preallocate slice capacity in Registry.Build() — https://github.com/pion/interceptor/pull/353
- use atomic instead of lock in sequencer — https://github.com/pion/rtp/pull/343
- Use atomic.Uint64 for thread-safe byte counters — https://github.com/pion/ice/pull/785
- Change activeTCPConn.close to atomic.Bool — https://github.com/pion/ice/pull/782
- Prefer makezero with a cap — https://github.com/pion/webrtc/pull/3230
- Fixes to use the same buffer as input and output (srtp) — https://github.com/pion/srtp/pull/320
- We never allocate more than 32 bytes AES/CTR — https://github.com/pion/srtp/pull/327
@3drx @5ur3 @aalekseevx @aankur @adeithe @alexhu-oai @amanakin @andjcoll @anshulmalik @arindamnayak @arjunshajitech @asayyah @astroza @at-wat @atoppi @bajam-genetec @berkant @boks1971 @britblue @cgojin @chaturvedishilpa @chenosaurus @cmorillas @cnderrauber @copilot @cppcoffee @debugmenot @drshrey @enobufs @frantabot @ghost @hackerman-ru @hanguyen-nuro @hexbabe @jackielii @jasmoran @jiajieli-dev @joeturki @juliapixel @kevmo314 @kmansoft @lars-sto @lidian-runner @lkang-nuro @mengelbart @mikeyg42 @miya-masa @mrpomidoro @nils-ohlmeier @olexandr88 @penhauer @philipch07 @pionbot @rg0now @ryanpotat @sean-der @setheck @sirzooro @sundenis @sunofcoder @sxmzou @theodorsm @thesyncim @tmatth @trs00 @valorzard @wrangelvid @xinze-zheng @yannismate @yzhao-nuro