From c922075e19beb680cdad0032eb34d6418eb30949 Mon Sep 17 00:00:00 2001 From: madomado Date: Tue, 20 Feb 2024 05:42:51 +0800 Subject: [PATCH] fix: openh264 (#941) --- anda/lib/openh264/gst-p-bad-cleanup.sh | 201 ------------------ anda/lib/openh264/hardcode-openh264-dep.patch | 14 -- anda/lib/openh264/openh264.spec | 147 +++---------- anda/lib/openh264/pre.rhai | 14 -- 4 files changed, 35 insertions(+), 341 deletions(-) delete mode 100644 anda/lib/openh264/gst-p-bad-cleanup.sh delete mode 100644 anda/lib/openh264/hardcode-openh264-dep.patch delete mode 100644 anda/lib/openh264/pre.rhai diff --git a/anda/lib/openh264/gst-p-bad-cleanup.sh b/anda/lib/openh264/gst-p-bad-cleanup.sh deleted file mode 100644 index 92211717e0..0000000000 --- a/anda/lib/openh264/gst-p-bad-cleanup.sh +++ /dev/null @@ -1,201 +0,0 @@ -#!/bin/sh - -# Process a gst-plugins-bad tarball to remove -# unwanted GStreamer plugins. -# -# This script here is taken from Fedora gstreamer1-plugins-bad-free repo, with -# only change being openh264 addition. -# -# See https://bugzilla.redhat.com/show_bug.cgi?id=532470 -# for details -# -# Bastien Nocera - 2010 -# - -SOURCE="$1" -NEW_SOURCE=`echo $SOURCE | sed 's/bad-/bad-openh264-/'` -DIRECTORY=`echo $SOURCE | sed 's/\.tar\.xz//'` - -ALLOWED=" -aacparse -accurip -adpcmdec -adpcmenc -aiff -aiffparse -amrparse -asfmux -audiobuffersplit -audiofxbad -audiolatency -audiomixer -audiomixmatrix -audioparsers -audiovisualizers -autoconvert -bayer -camerabin -camerabin2 -cdxaparse -codecalpha -codectimestamper -coloreffects -colorspace -compositor -dataurisrc -dccp -debugutils -dtmf -dvbsubenc -faceoverlay -festival -fieldanalysis -freeverb -freeze -frei0r -gaudieffects -gdp -geometrictransform -h264parse -hdvparse -hls -id3tag -inter -interlace -invtelecine -ivfparse -ivtc -jpegformat -jp2kdecimator -legacyresample -librfb -liveadder -midi -mve -mpegdemux -mpeg4videoparse -mpegpsmux -mpegtsdemux -mpegtsmux -mpegvideoparse -mxf -netsim -nsf -nuvdemux -onvif -openh264 -patchdetect -pcapparse -pnm -proxy -qtmux -rawparse -removesilence -rist -rtmp2 -rtp -rtpmux -rtpvp8 -scaletempo -sdi -sdp -segmentclip -selector -smooth -speed -stereo -subenc -switchbin -timecode -transcode -tta -valve -videofilters -videoframe_audiolevel -videomaxrate -videomeasure -videoparsers -videosignal -vmnc -yadif -y4m -" - -NOT_ALLOWED=" -dvbsuboverlay -dvdspu -real -siren -" - -error() -{ - MESSAGE=$1 - echo $MESSAGE - exit 1 -} - -check_allowed() -{ - MODULE=$1 - for i in $ALLOWED ; do - if test x$MODULE = x$i ; then - return 0; - fi - done - # Ignore errors coming from ext/ directory - # they require external libraries so are ineffective anyway - return 1; -} - -check_not_allowed() -{ - MODULE=$1 - for i in $NOT_ALLOWED ; do - if test x$MODULE = x$i ; then - return 0; - fi - done - return 1; -} - -rm -rf $DIRECTORY -tar xJf $SOURCE || error "Cannot unpack $SOURCE" -pushd $DIRECTORY > /dev/null || error "Cannot open directory \"$DIRECTORY\"" - -unknown="" -for subdir in gst ext sys; do - for dir in $subdir/* ; do - # Don't touch non-directories - if ! [ -d $dir ] ; then - continue; - fi - MODULE=`basename $dir` - if ( check_not_allowed $MODULE ) ; then - echo "**** Removing $MODULE ****" - echo "Removing directory $dir" - rm -r $dir || error "Cannot remove $dir" - echo - elif test $subdir = ext || test $subdir = sys; then - # Ignore library or system non-blacklisted plugins - continue; - elif ! ( check_allowed $MODULE ) ; then - echo "Unknown module in $dir" - unknown="$unknown $dir" - fi - done -done - -echo - -if test "x$unknown" != "x"; then - echo -n "Aborting due to unkown modules: " - echo "$unknown" | sed "s/ /\n /g" - exit 1 -fi - -popd > /dev/null - -tar cJf $NEW_SOURCE $DIRECTORY -echo "$NEW_SOURCE is ready to use" - diff --git a/anda/lib/openh264/hardcode-openh264-dep.patch b/anda/lib/openh264/hardcode-openh264-dep.patch deleted file mode 100644 index fbedcd96e1..0000000000 --- a/anda/lib/openh264/hardcode-openh264-dep.patch +++ /dev/null @@ -1,14 +0,0 @@ -diff -up gst-plugins-bad-1.18.2/ext/openh264/meson.build.orig gst-plugins-bad-1.18.2/ext/openh264/meson.build ---- gst-plugins-bad-1.18.2/ext/openh264/meson.build.orig 2020-12-06 14:24:13.000000000 +0100 -+++ gst-plugins-bad-1.18.2/ext/openh264/meson.build 2021-02-11 11:48:58.660450319 +0100 -@@ -4,9 +4,7 @@ openh264_sources = [ - 'gstopenh264plugin.c', - ] - --openh264_dep = dependency('openh264', version : '>= 1.3.0', -- required : get_option('openh264'), -- fallback: ['openh264', 'openh264_dep']) -+openh264_dep = cc.find_library('openh264') - - if openh264_dep.found() - gstopenh264 = library('gstopenh264', diff --git a/anda/lib/openh264/openh264.spec b/anda/lib/openh264/openh264.spec index 6bf4c32de4..4af10ecab9 100644 --- a/anda/lib/openh264/openh264.spec +++ b/anda/lib/openh264/openh264.spec @@ -1,36 +1,29 @@ -# ref: https://src.fedoraproject.org/rpms/openh264 +# ref: https://src.fedoraproject.org/rpms/openh264/blob/rawhide/f/openh264.spec +# To get the gmp-api commit to use, run: +# rm -rf gmp-api;make gmp-bootstrap;cd gmp-api;git rev-parse HEAD %global commit1 e7d30b921df736a1121a0c8e0cf3ab1ce5b8a4b7 %global shortcommit1 %(c=%{commit1}; echo ${c:0:7}) -%global openh264_version 2.4.0 -%global gst_version 1.23.2 +# Filter out soname provides for the mozilla plugin +%global __provides_exclude_from ^%{_libdir}/mozilla/plugins/ Name: openh264 -Version: %{openh264_version} -# Also bump the Release tag for gstreamer1-plugin-openh264 down below -Release: 1%{?dist} +Version: 2.4.1 +Release: 2%{?dist} Summary: H.264 codec library -License: BSD +License: BSD-2-Clause URL: https://www.openh264.org/ -Source0: https://github.com/cisco/openh264/archive/v%{openh264_version}/openh264-%{openh264_version}.tar.gz +Source0: https://github.com/cisco/openh264/archive/v%{version}/openh264-%{version}.tar.gz Source1: https://github.com/mozilla/gmp-api/archive/%{commit1}/gmp-api-%{shortcommit1}.tar.gz -# The source is: -# http://gstreamer.freedesktop.org/src/gst-plugins-bad/gst-plugins-bad-%%{gst_version}.tar.xz -# modified with gst-p-bad-cleanup.sh from SOURCE3 -Source2: gst-plugins-bad-openh264-%{gst_version}.tar.xz -Source3: gst-p-bad-cleanup.sh - -# Don't use pkg-config for finding openh264 as we are building against an in-tree copy -Patch2: hardcode-openh264-dep.patch BuildRequires: gcc-c++ -BuildRequires: gstreamer1-devel >= %{gst_version} -BuildRequires: gstreamer1-plugins-base-devel >= %{gst_version} BuildRequires: make -BuildRequires: meson BuildRequires: nasm +# Replace the stub package +Obsoletes: noopenh264 < 1:0 + %description OpenH264 is a codec library which supports H.264 encoding and decoding. It is suitable for use in real time applications such as WebRTC. @@ -38,7 +31,9 @@ suitable for use in real time applications such as WebRTC. %package devel Summary: Development files for %{name} -Requires: %{name}%{?_isa} = %{openh264_version}-%{release} +Requires: %{name}%{?_isa} = %{version}-%{release} +# Replace the stub package +Obsoletes: noopenh264-devel < 1:0 %description devel The %{name}-devel package contains libraries and header files for @@ -47,7 +42,7 @@ developing applications that use %{name}. %package -n mozilla-openh264 Summary: H.264 codec support for Mozilla browsers -Requires: %{name}%{?_isa} = %{openh264_version}-%{release} +Requires: %{name}%{?_isa} = %{version}-%{release} Requires: mozilla-filesystem%{?_isa} %description -n mozilla-openh264 @@ -55,18 +50,6 @@ The mozilla-openh264 package contains a H.264 codec plugin for Mozilla browsers. -%package -n gstreamer1-plugin-openh264 -Version: %{gst_version} -Release: 2%{?dist} -Summary: GStreamer H.264 plugin - -%description -n gstreamer1-plugin-openh264 -GStreamer is a streaming media framework, based on graphs of elements which -operate on media data. - -This package contains the H.264 plugin. - - %prep %setup -q @@ -74,12 +57,6 @@ This package contains the H.264 plugin. tar -xf %{S:1} mv gmp-api-%{commit1} gmp-api -# Extract gst-plugins-bad-free archive -tar -xf %{S:2} -pushd gst-plugins-bad-%{gst_version} -%patch2 -p1 -popd - %build # Update the makefile with our build options @@ -96,20 +73,6 @@ make %{?_smp_mflags} # ... then build the mozilla plugin make plugin %{?_smp_mflags} -# ... and finally build the gstreamer plugin against the previously built -# openh264 libraries -pushd gst-plugins-bad-%{gst_version} -CFLAGS="%{build_cflags} -I`pwd`/../codec/api" \ -CXXFLAGS="%{build_cflags} -I`pwd`/../codec/api" \ -LDFLAGS="%{build_ldflags} -L`pwd`/.." \ -%meson \ - --auto-features=disabled \ - -D package-name="Fedora gstreamer1-plugin-openh264 package" \ - -D package-origin="http://www.openh264.org/" \ - -D openh264=enabled -%meson_build -popd - %install %make_install @@ -125,71 +88,32 @@ pref("media.gmp-gmpopenh264.version", "system-installed"); EOF mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/profile.d -cat > $RPM_BUILD_ROOT%{_sysconfdir}/profile.d/gmpopenh264.sh << EOF -MOZ_GMP_PATH="${MOZ_GMP_PATH}${MOZ_GMP_PATH:+:}%{_libdir}/mozilla/plugins/gmp-gmpopenh264/system-installed" -export MOZ_GMP_PATH +cat > $RPM_BUILD_ROOT%{_sysconfdir}/profile.d/gmpopenh264.sh << 'EOF' +if [[ ":$MOZ_GMP_PATH:" != *":%{_libdir}/mozilla/plugins/gmp-gmpopenh264/system-installed:"* ]]; then + MOZ_GMP_PATH="${MOZ_GMP_PATH}${MOZ_GMP_PATH:+:}%{_libdir}/mozilla/plugins/gmp-gmpopenh264/system-installed" + export MOZ_GMP_PATH +fi EOF -# Remove static libraries -rm $RPM_BUILD_ROOT%{_libdir}/*.a - -# Install the gstreamer plugin -pushd gst-plugins-bad-%{gst_version} -%meson_install - -# Register as an AppStream component to be visible in the software center -# -# NOTE: It would be *awesome* if this file was maintained by the upstream -# project, translated and installed into the right place during `make install`. -# -# See http://www.freedesktop.org/software/appstream/docs/ for more details. -# -mkdir -p $RPM_BUILD_ROOT%{_datadir}/appdata -cat > $RPM_BUILD_ROOT%{_datadir}/appdata/gstreamer-openh264.appdata.xml < - - - gstreamer-openh264 - CC0-1.0 - GStreamer Multimedia Codecs - H.264 - Multimedia playback for H.264 - -

- This addon includes a codec for H.264 playback and encoding. -

-

- These codecs can be used to encode and decode media files where the - format is not patent encumbered. -

-

- A codec decodes audio and video for playback or editing and is also - used for transmission or storage. - Different codecs are used in video-conferencing, streaming media and - video editing applications. -

-
- http://gstreamer.freedesktop.org/ - https://bugzilla.gnome.org/enter_bug.cgi?product=GStreamer - http://gstreamer.freedesktop.org/documentation/ - http://www.gnome.org/friends/ - -
+mkdir -p $RPM_BUILD_ROOT%{_datadir}/fish/vendor_conf.d +cat > $RPM_BUILD_ROOT%{_datadir}/fish/vendor_conf.d/gmpopenh264.fish << 'EOF' +set -x --path MOZ_GMP_PATH $MOZ_GMP_PATH +set dir %{_libdir}/mozilla/plugins/gmp-gmpopenh264/system-installed +if not contains $dir $MOZ_GMP_PATH + set -p MOZ_GMP_PATH $dir +end +set -e dir EOF -# Remove unwanted gst-plugins-bad files -rm -rf $RPM_BUILD_ROOT%{_bindir}/gst-transcoder-1.0 -rm -rf $RPM_BUILD_ROOT%{_includedir}/gstreamer-1.0/ -rm -rf $RPM_BUILD_ROOT%{_libdir}/pkgconfig/gstreamer-*.pc -rm -rf $RPM_BUILD_ROOT%{_libdir}/libgst*.so* -rm -rf $RPM_BUILD_ROOT%{_datadir}/gstreamer-1.0/ -popd +# Remove static libraries +rm $RPM_BUILD_ROOT%{_libdir}/*.a %files %license LICENSE %doc README.md %{_libdir}/libopenh264.so.7 -%{_libdir}/libopenh264.so.%{openh264_version} +%{_libdir}/libopenh264.so.%{version} %files devel %{_includedir}/wels/ @@ -203,10 +127,9 @@ popd %dir %{_libdir}/firefox/defaults/pref %{_libdir}/firefox/defaults/pref/gmpopenh264.js %{_libdir}/mozilla/plugins/gmp-gmpopenh264/ - -%files -n gstreamer1-plugin-openh264 -%{_datadir}/appdata/*.appdata.xml -%{_libdir}/gstreamer-1.0/libgstopenh264.so +%dir %{_datadir}/fish +%dir %{_datadir}/fish/vendor_conf.d +%{_datadir}/fish/vendor_conf.d/gmpopenh264.fish %changelog diff --git a/anda/lib/openh264/pre.rhai b/anda/lib/openh264/pre.rhai deleted file mode 100644 index 6cfc5a8b63..0000000000 --- a/anda/lib/openh264/pre.rhai +++ /dev/null @@ -1,14 +0,0 @@ -let cwd = "anda/lib/openh264"; -let spec = open_file("anda/lib/openh264/openh264.spec").read_string(); -let gst = find("%global gst_version ([\\d.]+)", spec, 1); -print(`:: found gst version ${gst}`); -let out = sh(`wget https://gstreamer.freedesktop.org/src/gst-plugins-bad/gst-plugins-bad-${gst}.tar.xz`, cwd); -//print(":: wget stdout below"); -//print(out.sh_stdout()); -//print(":: wget stderr below"); -//print(out.sh_stderr()); -out = sh(`sh gst-p-bad-cleanup.sh gst-plugins-bad-${gst}.tar.xz`, cwd); -//print(":: script stdout below"); -//print(out.sh_stdout()); -//print(":: script stderr below"); -//print(out.sh_stderr());