Skip to content

feat: build WebRTC with H.265 - #346

Merged
devopvoid merged 1 commit into
mainfrom
feat/webrtc-h265
Oct 11, 2026
Merged

devopvoid merged 1 commit into
mainfrom
feat/webrtc-h265

Conversation

@devopvoid

Copy link
Copy Markdown
Owner

Summary

WebRTC was built without H.265 (rtc_use_h265 follows proprietary_codecs, which is off), so a call could not carry H.265 even with an encoder and decoder for it: there was no H.265 RTP packetization, no depacketizer (WebRTC creates none and drops the stream) and no H.265 negotiation. This builds WebRTC with it. It is the groundwork for hardware H.265 in calls on Windows, macOS and Linux, which the hardware codec factories add next.

  • rtc_use_h265=true in the GN args, and RTC_ENABLE_H265 for the JNI code, so that it is compiled against the same declarations. None of the headers the JNI code includes changes a struct layout with it.
  • WebRTC has no H.265 encoder or decoder of its own, and none is added: H.265 is offered only by a factory that brings one (a Java one now, the hardware factories later). HEVC stays hardware only, as in the media player.
  • A compiled WebRTC is used only if it was built with the current GN args. The args are recorded next to the library, in the build tree and in the install directory, and a build without the record, or with other args, is built again; the stale installed library is removed first so that nothing links it meanwhile. Before, any existing webrtc.lib/libwebrtc.a was taken as it was, so a change to the args never reached a machine that had built WebRTC once. The record is written only when gn and ninja succeed. CI's WebRTC cache key already hashes this CMakeLists.txt, so CI rebuilds on its own.
  • VideoEncoderWrapper (Java encoders) parses the QP of H.265 frames and uses the H.264 quality-scaling thresholds for H.265, as WebRTC's own Android wrapper does (bugs.webrtc.org/13485).
  • The codec guide and the Javadoc describe H.265.

Testing

  • Windows x64: with the GN args changed, the configure step found no record, removed the installed library, synced and rebuilt WebRTC (only what rtc_use_h265 touches is recompiled; about 5 minutes here). The new library has the H.265 packetizer, depacketizer and bitstream parser, and the next configure reuses it.
  • VideoCodecFactoryTests.h265CallRoundTrips is new: a call between two local peer connections negotiates H.265 through a Java encoder and decoder, which wrap the test payload in H.265 NAL units (VPS, SPS, PPS and an IDR slice). Every frame received is one that was sent. Without H.265 in WebRTC the receiver has no depacketizer for the stream and nothing arrives.
  • The full test suites of webrtc and webrtc-java-media pass against the rebuilt library.

Not verified

The rebuild ran on Windows x64 only; CI rebuilds WebRTC for the other six platforms. No real H.265 encoder or decoder is involved yet: the test checks negotiation, packetization and depacketization with a synthetic bitstream.

WebRTC was built without H.265 (rtc_use_h265 follows proprietary_codecs,
which is off), so a call could not carry it even with an encoder and a
decoder for it: no H.265 packetization, no depacketizer (WebRTC creates
none and drops the stream) and no H.265 negotiation. It is now built with
rtc_use_h265=true, and the JNI code with RTC_ENABLE_H265 to match.
WebRTC has no H.265 codec of its own and none is added, so H.265 is
offered only by a factory that brings one.

A compiled WebRTC is used only if it was built with the current GN args,
which are recorded next to the library in the build tree and the install
directory. A build without the record or with other args is built again,
and the stale installed library is removed so nothing links it meanwhile.
Before, any existing library was taken as it was, so a change to the args
never reached a machine that had built WebRTC once. The record is written
only when gn and ninja succeed.

Java encoders get the QP of H.265 frames parsed, and the H.264 quality
scaling thresholds for H.265, as WebRTC's Android wrapper has them.
A new test sends a call through a Java H.265 encoder and decoder, whose
frames are wrapped in H.265 NAL units.
@devopvoid
devopvoid added this pull request to stack #349 October 11, 2026 13:02
@devopvoid
devopvoid merged commit 82204ea into main Oct 11, 2026
24 checks passed
@devopvoid
devopvoid deleted the feat/webrtc-h265 branch October 11, 2026 18:25
@devopvoid
devopvoid restored the feat/webrtc-h265 branch October 11, 2026 18:39
@devopvoid
devopvoid deleted the feat/webrtc-h265 branch October 11, 2026 20:10
SendableMetatype added a commit to EduGeyser/webrtc-java that referenced this pull request Oct 15, 2026
Brings in the work upstream added from October 11 to 15: hardware video
codecs on every platform, through Media Foundation, VideoToolbox, VA-API
and NVDEC, with WebRTC built with H.265 (devopvoid#346 to devopvoid#348, devopvoid#352, devopvoid#353, devopvoid#356,
devopvoid#359, devopvoid#371 to devopvoid#377); HEVC and AV1 decoding in the media player, with
dav1d and Vulkan Video (devopvoid#331, devopvoid#345); encoded frame injectors (devopvoid#365);
receiver source changes and audio packet infos (devopvoid#366); audio codec
factories (devopvoid#340); network thread observers called on a callback thread
(devopvoid#364); screen capture with ScreenCaptureKit (devopvoid#354); Windows audio
devices that mix more than two channels (devopvoid#358); autoninja (devopvoid#357); and
the release channels of the docs site (devopvoid#361).

Fork-side adaptations:
- The factory keeps the CreatePeerConnectionFactory overload without a
  worker thread, and still switches device capture on the network
  thread. devopvoid#355 copies WebRTC's factory setup and has the audio module
  learn a worker thread, which only matters for a worker thread distinct
  from the network thread, and WebRTC is removing those. The audio codec
  factories and hardware codec switches of devopvoid#340 and devopvoid#359 go to that
  overload.
- WebRTC stays on a commit on main, so the move to branch 8059 (devopvoid#360)
  and its fixed clang package are left out.
- The data channels variant builds WebRTC without H.265 and without the
  extra targets, leaves out the audio codec factory bindings and
  addTransceiverOfType, and skips the new tests that need audio or
  video.
- dav1d is built against the sysroot on native Linux builds as well, as
  FFmpeg is. CI installs Meson for the full variant only, checks out the
  dav1d submodule, and adds its commit to the FFmpeg cache key. The
  fork's Windows SDK step stays, without upstream's second one.
- The release workflow records the docs' version in the tagged commit,
  as upstream's now does. The docs site still builds from main, since
  this fork publishes none.
- The Maven files stay deleted: Jetty is bumped in the version catalog,
  and the docs lockfile takes upstream's bumps on top of the fork's
  newer VitePress.
- The media module's README builds with Gradle.
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.

1 participant