From 869b0f515c17d3417277a861a1ca0e7ed4126036 Mon Sep 17 00:00:00 2001 From: Kalev Lember Date: Mon, 30 Nov 2015 18:52:28 +0100 Subject: [PATCH] Include the gstreamer plugin in gstreamer1-plugin-openh264 subpackage Sadly, the current build infrastructure doesn't let us build any external packages against openh264, so we have to include the gstreamer plugin build in the same source rpm. https://fedorahosted.org/fesco/ticket/1496 includes some background info why it can't be a separate package. --- .gitignore | 1 + gst-p-bad-cleanup.sh | 203 +++++++++++++++++++++++++++++++++++++++++++ openh264.spec | 116 ++++++++++++++++++++++++- sources | 1 + 4 files changed, 319 insertions(+), 2 deletions(-) create mode 100755 gst-p-bad-cleanup.sh diff --git a/.gitignore b/.gitignore index 55f767f..155ae3e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /gmp-api-c5f1d0f.tar.gz +/gst-plugins-bad-openh264-1.6.1.tar.xz /openh264-21e44bd.tar.gz diff --git a/gst-p-bad-cleanup.sh b/gst-p-bad-cleanup.sh new file mode 100755 index 0000000..fcbcdbc --- /dev/null +++ b/gst-p-bad-cleanup.sh @@ -0,0 +1,203 @@ +#!/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 +audiofxbad +audiomixer +audioparsers +audiovisualizers +autoconvert +bayer +camerabin +camerabin2 +cdxaparse +coloreffects +colorspace +compositor +dataurisrc +dccp +debugutils +dtmf +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 +nsf +nuvdemux +onvif +openh264 +patchdetect +pcapparse +pnm +qtmux +rawparse +removesilence +rtp +rtpmux +rtpvp8 +scaletempo +sdi +sdp +segmentclip +selector +smooth +speed +stereo +subenc +tta +valve +videofilters +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" + if grep -q "AG_GST_CHECK_PLUGIN($MODULE)" configure.ac ; then + echo "Removing element check for $MODULE" + grep -v "AG_GST_CHECK_PLUGIN($MODULE)" configure.ac > configure.ac.new && mv configure.ac.new configure.ac + fi + echo "Removing Makefile generation for $MODULE" + grep -v "$dir/Makefile" configure.ac > configure.ac.new && mv configure.ac.new configure.ac + # Urgh + if test $MODULE = real ; then + grep -v "AG_GST_DISABLE_PLUGIN(real)" configure.ac > configure.ac.new && mv configure.ac.new configure.ac + fi + echo "Removing documentation for $MODULE" + if grep -q "$MODULE" docs/plugins/Makefile.am ; then + grep -v $dir docs/plugins/Makefile.am > docs/plugins/Makefile.am.new && mv docs/plugins/Makefile.am.new docs/plugins/Makefile.am + fi + 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 + +autoreconf + +popd > /dev/null + +tar cJf $NEW_SOURCE $DIRECTORY +echo "$NEW_SOURCE is ready to use" + diff --git a/openh264.spec b/openh264.spec index cc83eea..937d76d 100644 --- a/openh264.spec +++ b/openh264.spec @@ -7,16 +7,27 @@ %global commit1 c5f1d0f3213178818cbfb3e16f31d07328980560 %global shortcommit1 %(c=%{commit1}; echo ${c:0:7}) +%global gst_version 1.6.1 + Name: openh264 Version: 1.5.2 -Release: 0.2.git%{shortcommit0}%{?dist} +Release: 0.3.git%{shortcommit0}%{?dist} Summary: H.264 codec library License: BSD URL: http://www.openh264.org/ Source0: https://github.com/cisco/openh264/archive/%{commit0}/openh264-%{shortcommit0}.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 + +BuildRequires: autoconf +BuildRequires: chrpath +BuildRequires: gstreamer1-devel >= %{gst_version} +BuildRequires: gstreamer1-plugins-base-devel >= %{gst_version} BuildRequires: nasm %description @@ -33,6 +44,17 @@ The %{name}-devel package contains libraries and header files for developing applications that use %{name}. +%package -n gstreamer1-plugin-openh264 +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. + + %package -n mozilla-openh264 Summary: H.264 codec support for Mozilla browsers Requires: %{name}%{?_isa} = %{version}-%{release} @@ -50,6 +72,9 @@ browsers. tar -xf %{S:1} mv gmp-api-%{commit1} gmp-api +# Extract gst-plugins-bad-free archive +tar -xf %{S:2} + # Update the makefile with our build options sed -i -e 's|^CFLAGS_OPT=.*$|CFLAGS_OPT=%{optflags}|' Makefile sed -i -e 's|^PREFIX=.*$|PREFIX=%{_prefix}|' Makefile @@ -59,9 +84,26 @@ sed -i -e '/^CFLAGS_OPT=/i LDFLAGS=%{__global_ldflags}' Makefile %build +# First build the openh264 libraries 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} +ln -s ../codec/api/svc wels +export OPENH264_CFLAGS="-I." +export OPENH264_LIBS="-L`pwd`/.. -lopenh264" +%configure \ + --with-package-name="Fedora gstreamer1-plugin-openh264 package" \ + --with-package-origin="http://www.openh264.org/" \ + --disable-static \ + --enable-openh264 +make V=1 %{?_smp_mflags} +popd + %install %make_install @@ -85,6 +127,69 @@ EOF # Remove static libraries rm $RPM_BUILD_ROOT%{_libdir}/*.a +# Install the gstreamer plugin +pushd gst-plugins-bad-%{gst_version} +%make_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/ + +
+EOF + +# Remove libtool .la files +find $RPM_BUILD_ROOT -name '*.la' -exec rm -f {} ';' + +# Remove unwanted gst-plugins-bad files +rm -rf $RPM_BUILD_ROOT%{_includedir}/gstreamer-1.0/ +rm -rf $RPM_BUILD_ROOT%{_libdir}/girepository-1.0/Gst*.typelib +rm -rf $RPM_BUILD_ROOT%{_libdir}/pkgconfig/gstreamer-*.pc +rm -rf $RPM_BUILD_ROOT%{_libdir}/libgst*.so* +rm -rf $RPM_BUILD_ROOT%{_datadir}/gir-1.0/Gst*.gir +rm -rf $RPM_BUILD_ROOT%{_datadir}/gstreamer-1.0/ +rm -rf $RPM_BUILD_ROOT%{_datadir}/gtk-doc/html/gst-plugins-bad*/ +rm -rf $RPM_BUILD_ROOT%{_datadir}/locale/*/*/gst-plugins-bad-1.0.mo + +# Only keep libgstopenh264.so +find $RPM_BUILD_ROOT%{_libdir}/gstreamer-1.0/ -not -name 'libgstopenh264.so' -type f | xargs rm + +# Kill rpath +chrpath --delete $RPM_BUILD_ROOT%{_libdir}/gstreamer-1.0/libgstopenh264.so +popd + %post -p /sbin/ldconfig @@ -109,8 +214,15 @@ rm $RPM_BUILD_ROOT%{_libdir}/*.a %{_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 + %changelog +* Mon Nov 30 2015 Kalev Lember - 1.5.2-0.3.git21e44bd +- Include the gstreamer plugin in gstreamer1-plugin-openh264 subpackage + * Thu Nov 26 2015 Kalev Lember - 1.5.2-0.2.git21e44bd - Pass Fedora LDFLAGS to the build to get full relro (#1285338) diff --git a/sources b/sources index 1c53465..ffb49b6 100644 --- a/sources +++ b/sources @@ -1,2 +1,3 @@ 961eb0256e27a12dd0a19421b56f3309 gmp-api-c5f1d0f.tar.gz +74ec07ae3c1c5a678c761d3624f06060 gst-plugins-bad-openh264-1.6.1.tar.xz 0821a30af77607e17bdf956faf5c64f2 openh264-21e44bd.tar.gz