Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 48ba671f2f85b586706f412bfb2d2479e5575b32
https://github.com/WebKit/WebKit/commit/48ba671f2f85b586706f412bfb2d2479e5575b32
Author: Enrique Ocaña González <[email protected]>
Date: 2026-06-25 (Thu, 25 Jun 2026)
Changed paths:
M Source/WebCore/platform/VideoFrame.h
M Source/WebCore/platform/graphics/gstreamer/VideoFrameGStreamer.cpp
M Source/WebCore/platform/graphics/gstreamer/VideoFrameGStreamer.h
M Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp
M Source/WebCore/platform/mediastream/RealtimeMediaSource.h
Log Message:
-----------
[libWebRTC][GStreamer] Missing video in WebRTC playback when decoding on
playback pipeline
https://bugs.webkit.org/show_bug.cgi?id=317111
Reviewed by Xabier Rodriguez-Calvar.
LibWebRTC has a dedicated Decoder component that is supposed to decode video
frames and supply them like that to its observers. Under those assumptions,
missing some of those decoded frames (eg: because no observer is listening yet)
isn't very problematic in this expected case.
However, in order to facilitate hardware decoding, the libWebRTC Decoder
implementation provided by the GStreamer port emits encoded frames (that is,
doesn't decode at all) unders some circumstances, with the hope that those
encoded frames end up reaching the playback pipeline and being decoded there.
In such a case, missing video frames because no observer has been registered
(a circumstance that has been reported by at least one downstream setup but
that can't be reproduced reliably) can be problematic. Missing the first
"frames" (buffers) of an encoded video means that the video headers (eg:
SPS/PPS for H.264) are missed that's a condition the actual video decoder
can't recover from.
This patch provides a mechanism to keep undelivered buffers when they come
in an encoded format and there's no registered observer to deliver them to,
and redeliver them when the first observer is registered. This solves the
problem detected in the mentioned downstream setup.
If a format change is detected or if RealtimeMediaSource is stopping, the
list of pending frames is emtied, since there's no point anymore on
delivering them.
Co-authored by: Ganesh prasad Sahu <[email protected]>
* Source/WebCore/platform/VideoFrame.h:
(WebCore::VideoFrame::isEncoded const): Added generic implementation to know if
a VideoFrame has an encoded format or not. Defaults to false.
(WebCore::VideoFrame::hasSameEncodedFormat const): Compares if format of one
sample is the same as the one from another. Defaults to false.
* Source/WebCore/platform/graphics/gstreamer/VideoFrameGStreamer.cpp:
(WebCore::VideoFrameGStreamer::VideoFrameGStreamer): Added assertion to ensure
m_sample is not null.
(WebCore::VideoFrameGStreamer::isEncoded const): Specific implementation, only
true when the caps are other than video/x-raw.
(WebCore::VideoFrameGStreamer::hasSameEncodedFormat const): Format comparison
is implemented by comparing caps.
* Source/WebCore/platform/graphics/gstreamer/VideoFrameGStreamer.h: Added
isEncoded() declaration.
* Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp:
(WebCore::RealtimeMediaSource::videoFrameAvailable): Added code to hoard
decoded frames when there's no observer, and redeliver then later. The frame
delivery code is reused from the regular case, so it has been factored into a
lambda. If a format change is detected, the pending frames are emptied, because
there's no point on redelivering them (only the ones with the new format are
relevant).
(WebCore::RealtimeMediaSource::stop): Empty the pending frames, since there's
no point in delivering them when we're stopping the whole RealtimeMediaSource.
* Source/WebCore/platform/mediastream/RealtimeMediaSource.h: Added
PendingVideoFrame struct to hold the pending frames and metadata, a Vector of
pending frames, and the constant that defines the maximum number of frames that
can be kept waiting redelivery.
Canonical link: https://commits.webkit.org/315815@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications