Skip to content

Commit

Permalink
[GStreamer] Update the registry only if the private video encoder was…
Browse files Browse the repository at this point in the history
… successfully registered

https://bugs.webkit.org/show_bug.cgi?id=258885

Reviewed by Xabier Rodriguez-Calvar.

This is a small clean-up that prevents un-needed updates of the registry scanner.

* Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.cpp:
(WebCore::registerInternalVideoEncoder):
(WebCore::registerWebKitGStreamerVideoEncoder):

Canonical link: https://commits.webkit.org/265796@main
  • Loading branch information
philn committed Jul 6, 2023
1 parent 50f3b47 commit 053f200
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,11 +309,14 @@ bool ensureGStreamerInitialized()
return isGStreamerInitialized;
}

static void registerInternalVideoEncoder()
static bool registerInternalVideoEncoder()
{
#if ENABLE(VIDEO)
gst_element_register(nullptr, "webkitvideoencoder", GST_RANK_PRIMARY + 100, WEBKIT_TYPE_VIDEO_ENCODER);
if (auto factory = adoptGRef(gst_element_factory_find("webkitvideoencoder")))
return false;
return gst_element_register(nullptr, "webkitvideoencoder", GST_RANK_PRIMARY + 100, WEBKIT_TYPE_VIDEO_ENCODER);
#endif
return false;
}

void registerWebKitGStreamerElements()
Expand Down Expand Up @@ -426,8 +429,7 @@ void registerWebKitGStreamerVideoEncoder()
static std::once_flag onceFlag;
bool registryWasUpdated = false;
std::call_once(onceFlag, [&registryWasUpdated] {
registerInternalVideoEncoder();
registryWasUpdated = true;
registryWasUpdated = registerInternalVideoEncoder();
});

// The video encoder might be registered after the scanner was initialized, so in this situation
Expand Down

0 comments on commit 053f200

Please sign in to comment.