Skip to content

Commit

Permalink
Cherry-pick 275166@main (764cbc5). https://bugs.webkit.org/show_bug.c…
Browse files Browse the repository at this point in the history
…gi?id=269838

    [LibWebRTC][GStreamer] Incoming H.264 stream parsing fails
    https://bugs.webkit.org/show_bug.cgi?id=269838

    Reviewed by Xabier Rodriguez-Calvar.

    Workaround cases where the GStreamer LibWebRTC decoder is expected to process frames with invalid
    render time.

    * Source/WebCore/platform/mediastream/libwebrtc/gstreamer/GStreamerVideoDecoderFactory.cpp:
    (WebCore::GStreamerVideoDecoder::GstDecoderFactory):

    Canonical link: https://commits.webkit.org/275166@main

Canonical link: https://commits.webkit.org/274313.178@webkitglib/2.44
  • Loading branch information
philn authored and aperezdc committed Apr 28, 2024
1 parent 1a7ce9a commit 00bd6ae
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,14 @@ class GStreamerWebRTCVideoDecoder : public webrtc::VideoDecoder {
return WEBRTC_VIDEO_CODEC_UNINITIALIZED;
}

// No renderTime provided, probably some issue with the WebRTC clock. Use a monotonically
// incrementing counter instead.
static int64_t s_forgedRenderTime { 0 };
if (!renderTimeMs) {
renderTimeMs = s_forgedRenderTime;
s_forgedRenderTime += 30 * GST_MSECOND;
}

if (!GST_CLOCK_TIME_IS_VALID(m_firstBufferPts)) {
GRefPtr<GstPad> srcpad = adoptGRef(gst_element_get_static_pad(m_src, "src"));
m_firstBufferPts = (static_cast<guint64>(renderTimeMs)) * GST_MSECOND;
Expand Down Expand Up @@ -277,7 +285,7 @@ class GStreamerWebRTCVideoDecoder : public webrtc::VideoDecoder {
return { webrtc::SdpVideoFormat(Name()) };
}

static GRefPtr<GstElementFactory> GstDecoderFactory(const char *capsStr)
static GRefPtr<GstElementFactory> GstDecoderFactory(const char* capsStr)
{
auto allDecoders = gst_element_factory_list_get_elements(GST_ELEMENT_FACTORY_TYPE_DECODER,
GST_RANK_MARGINAL);
Expand Down

0 comments on commit 00bd6ae

Please sign in to comment.