Blob Blame History Raw
From 1dadccd48c97a4b7c96ae0307c2263107e7f1876 Mon Sep 17 00:00:00 2001
From: Kalev Lember <klember@redhat.com>
Date: Wed, 6 Dec 2023 14:58:38 +0100
Subject: [PATCH] openh264: Drop runtime version checks

With the way the runtime checks are currently set up, every single
openh264 release, no matter how minor, is considered an ABI break and
requires gst-plugins-bad recompilation. This is unnecessarily strict
because it doesn't allow downstream distributions to ship any openh264
bug fix version updates without breaking gstreamer's openh264 support.

Years ago, at the time when gstreamer's openh264 support was merged,
openh264 releases were done without a versioned soname (the library was
just libopenh264.so, unversioned). Since then, starting with version
1.3.0, openh264 has started using versioned sonames and the intent has
been to bump the soname every time there's a new release with an ABI
change.

This patch drops the strict version check. meson.build already has a
minimum requirement on openh264 version 1.3.0 where soname versioning
was added, which should be good enough to ensure that the library is
using soname versioning.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5780>
---
 .../ext/openh264/gstopenh264dec.cpp           |  7 +--
 .../ext/openh264/gstopenh264element.c         | 48 -------------------
 .../ext/openh264/gstopenh264elements.h        |  2 -
 .../ext/openh264/gstopenh264enc.cpp           |  7 +--
 .../gst-plugins-bad/ext/openh264/meson.build  |  1 -
 5 files changed, 4 insertions(+), 61 deletions(-)
 delete mode 100644 subprojects/gst-plugins-bad/ext/openh264/gstopenh264element.c

diff --git a/subprojects/gst-plugins-bad/ext/openh264/gstopenh264dec.cpp b/subprojects/gst-plugins-bad/ext/openh264/gstopenh264dec.cpp
index 77f2b8fe348..f3302567c7b 100644
--- a/subprojects/gst-plugins-bad/ext/openh264/gstopenh264dec.cpp
+++ b/subprojects/gst-plugins-bad/ext/openh264/gstopenh264dec.cpp
@@ -459,10 +459,7 @@ openh264dec_element_init (GstPlugin * plugin)
 {
   GST_DEBUG_CATEGORY_INIT (gst_openh264dec_debug_category, "openh264dec", 0,
       "debug category for openh264dec element");
-  if (openh264_element_init (plugin))
-    return gst_element_register (plugin, "openh264dec", GST_RANK_MARGINAL,
-        GST_TYPE_OPENH264DEC);
 
-  GST_ERROR ("Incorrect library version loaded, expecting %s", g_strCodecVer);
-  return FALSE;
+  return gst_element_register (plugin, "openh264dec", GST_RANK_MARGINAL,
+      GST_TYPE_OPENH264DEC);
 }
diff --git a/subprojects/gst-plugins-bad/ext/openh264/gstopenh264element.c b/subprojects/gst-plugins-bad/ext/openh264/gstopenh264element.c
deleted file mode 100644
index 3c5c378c81e..00000000000
--- a/subprojects/gst-plugins-bad/ext/openh264/gstopenh264element.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2014, Ericsson AB. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this
- * list of conditions and the following disclaimer in the documentation and/or other
- * materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
- * OF SUCH DAMAGE.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <gst/gst.h>
-#include <wels/codec_api.h>
-#include <wels/codec_ver.h>
-#include <string.h>
-#include "gstopenh264elements.h"
-
-
-gboolean
-openh264_element_init (GstPlugin * plugin)
-{
-  OpenH264Version libver;
-  /* g_stCodecVersion is the version detected at build time as defined in the
-   * headers and WelsGetCodecVersion() is the version detected at runtime.
-   * This is a safeguard to avoid crashes since OpenH264  has been changing
-   * ABI without changing the SONAME.
-   */
-  libver = WelsGetCodecVersion ();
-  return (memcmp (&libver, &g_stCodecVersion, sizeof (libver)) == 0);
-}
diff --git a/subprojects/gst-plugins-bad/ext/openh264/gstopenh264elements.h b/subprojects/gst-plugins-bad/ext/openh264/gstopenh264elements.h
index 572f6a8e078..5c9582941ee 100644
--- a/subprojects/gst-plugins-bad/ext/openh264/gstopenh264elements.h
+++ b/subprojects/gst-plugins-bad/ext/openh264/gstopenh264elements.h
@@ -27,8 +27,6 @@
 
 G_BEGIN_DECLS
 
-gboolean openh264_element_init (GstPlugin * plugin);
-
 GST_ELEMENT_REGISTER_DECLARE (openh264dec);
 GST_ELEMENT_REGISTER_DECLARE (openh264enc);
 
diff --git a/subprojects/gst-plugins-bad/ext/openh264/gstopenh264enc.cpp b/subprojects/gst-plugins-bad/ext/openh264/gstopenh264enc.cpp
index 6b54b1584f8..05c126cfc64 100644
--- a/subprojects/gst-plugins-bad/ext/openh264/gstopenh264enc.cpp
+++ b/subprojects/gst-plugins-bad/ext/openh264/gstopenh264enc.cpp
@@ -1066,10 +1066,7 @@ openh264enc_element_init (GstPlugin * plugin)
 {
   GST_DEBUG_CATEGORY_INIT (gst_openh264enc_debug_category, "openh264enc", 0,
       "debug category for openh264enc element");
-  if (openh264_element_init (plugin))
-    return gst_element_register (plugin, "openh264enc", GST_RANK_MARGINAL,
-        GST_TYPE_OPENH264ENC);
 
-  GST_ERROR ("Incorrect library version loaded, expecting %s", g_strCodecVer);
-  return FALSE;
+  return gst_element_register (plugin, "openh264enc", GST_RANK_MARGINAL,
+      GST_TYPE_OPENH264ENC);
 }
diff --git a/subprojects/gst-plugins-bad/ext/openh264/meson.build b/subprojects/gst-plugins-bad/ext/openh264/meson.build
index 1f0a198b05e..c6f247e1cdd 100644
--- a/subprojects/gst-plugins-bad/ext/openh264/meson.build
+++ b/subprojects/gst-plugins-bad/ext/openh264/meson.build
@@ -1,7 +1,6 @@
 openh264_sources = [
   'gstopenh264dec.cpp',
   'gstopenh264enc.cpp',
-  'gstopenh264element.c',
   'gstopenh264plugin.c',
 ]
 
-- 
GitLab