From 74387c514701e9fc47ee32f5d9b68fd2d7913071 Mon Sep 17 00:00:00 2001 From: Philippe Normand Date: Thu, 23 Feb 2023 00:53:02 -0800 Subject: [PATCH] [GStreamer][WebRTC] Renegotiation signalling improvement https://bugs.webkit.org/show_bug.cgi?id=252756 Reviewed by Xabier Rodriguez-Calvar. When webrtcbin emits its on-negotiation-needed it has already made sure the negotiation is really needed according to the spec, but our implementation wasn't resetting the corresponding flag afterwards. We now match the event serial number, similarly to the libwebrtc implementation. * Source/WebCore/Modules/mediastream/gstreamer/GStreamerMediaEndpoint.cpp: (WebCore::GStreamerMediaEndpoint::onNegotiationNeeded): * Source/WebCore/Modules/mediastream/gstreamer/GStreamerMediaEndpoint.h: (WebCore::GStreamerMediaEndpoint::isNegotiationNeeded const): * Source/WebCore/Modules/mediastream/gstreamer/GStreamerPeerConnectionBackend.cpp: (WebCore::GStreamerPeerConnectionBackend::isNegotiationNeeded const): Canonical link: https://commits.webkit.org/260731@main --- .../mediastream/gstreamer/GStreamerMediaEndpoint.cpp | 7 ++----- .../Modules/mediastream/gstreamer/GStreamerMediaEndpoint.h | 4 ++-- .../gstreamer/GStreamerPeerConnectionBackend.cpp | 4 ++-- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/Source/WebCore/Modules/mediastream/gstreamer/GStreamerMediaEndpoint.cpp b/Source/WebCore/Modules/mediastream/gstreamer/GStreamerMediaEndpoint.cpp index 313ebbd3f5b4..74ec2473b7a8 100644 --- a/Source/WebCore/Modules/mediastream/gstreamer/GStreamerMediaEndpoint.cpp +++ b/Source/WebCore/Modules/mediastream/gstreamer/GStreamerMediaEndpoint.cpp @@ -1140,13 +1140,10 @@ void GStreamerMediaEndpoint::resume() void GStreamerMediaEndpoint::onNegotiationNeeded() { - m_isNegotiationNeeded = true; - + ++m_negotiationNeededEventId; callOnMainThread([protectedThis = Ref(*this), this] { - if (isStopped()) - return; GST_DEBUG_OBJECT(m_pipeline.get(), "Negotiation needed!"); - m_peerConnectionBackend.markAsNeedingNegotiation(0); + m_peerConnectionBackend.markAsNeedingNegotiation(m_negotiationNeededEventId); }); } diff --git a/Source/WebCore/Modules/mediastream/gstreamer/GStreamerMediaEndpoint.h b/Source/WebCore/Modules/mediastream/gstreamer/GStreamerMediaEndpoint.h index b1e9ba285f2b..6e1063afc24f 100644 --- a/Source/WebCore/Modules/mediastream/gstreamer/GStreamerMediaEndpoint.h +++ b/Source/WebCore/Modules/mediastream/gstreamer/GStreamerMediaEndpoint.h @@ -76,7 +76,7 @@ class GStreamerMediaEndpoint : public ThreadSafeRefCounted&&); - bool isNegotiationNeeded() const { return m_isNegotiationNeeded; } + bool isNegotiationNeeded(uint32_t eventId) const { return eventId == m_negotiationNeededEventId; } void configureAndLinkSource(RealtimeOutgoingMediaSourceGStreamer&); @@ -176,7 +176,7 @@ class GStreamerMediaEndpoint : public ThreadSafeRefCountedgatherDecoderImplementationName(WTFMove(callback)); } -bool GStreamerPeerConnectionBackend::isNegotiationNeeded(uint32_t) const +bool GStreamerPeerConnectionBackend::isNegotiationNeeded(uint32_t eventId) const { - return m_endpoint->isNegotiationNeeded(); + return m_endpoint->isNegotiationNeeded(eventId); } } // namespace WebCore