asterisk: add support for open-source opus codec

This commit is contained in:
Lorenz Brun 2022-04-06 20:28:12 +02:00
parent 2674e1469e
commit b71ff4c656

View File

@ -1,8 +1,10 @@
{ stdenv, lib, fetchurl, fetchsvn, { stdenv, lib, fetchurl, fetchsvn, fetchFromGitHub,
jansson, libedit, libxml2, libxslt, ncurses, openssl, sqlite, jansson, libedit, libxml2, libxslt, ncurses, openssl, sqlite,
util-linux, dmidecode, libuuid, newt, util-linux, dmidecode, libuuid, newt,
lua, speex, lua, speex, libopus, opusfile, libogg,
srtp, wget, curl, iksemel, pkg-config srtp, wget, curl, iksemel, pkg-config,
autoconf, libtool, automake,
withOpus ? true,
}: }:
let let
@ -13,8 +15,9 @@ let
buildInputs = [ jansson libedit libxml2 libxslt ncurses openssl sqlite buildInputs = [ jansson libedit libxml2 libxslt ncurses openssl sqlite
dmidecode libuuid newt dmidecode libuuid newt
lua speex lua speex
srtp wget curl iksemel ]; srtp wget curl iksemel ]
nativeBuildInputs = [ util-linux pkg-config ]; ++ lib.optionals withOpus [ libopus opusfile libogg ];
nativeBuildInputs = [ util-linux pkg-config autoconf libtool automake ];
patches = [ patches = [
# We want the Makefile to install the default /var skeleton # We want the Makefile to install the default /var skeleton
@ -22,7 +25,7 @@ let
# This patch changes the runtime behavior to look for state # This patch changes the runtime behavior to look for state
# directories in /var rather than ${out}/var. # directories in /var rather than ${out}/var.
./runtime-vardirs.patch ./runtime-vardirs.patch
]; ] ++ lib.optional withOpus "${asterisk-opus}/asterisk.patch";
postPatch = '' postPatch = ''
echo "PJPROJECT_CONFIG_OPTS += --prefix=$out" >> third-party/pjproject/Makefile.rules echo "PJPROJECT_CONFIG_OPTS += --prefix=$out" >> third-party/pjproject/Makefile.rules
@ -49,6 +52,12 @@ let
${lib.optionalString (externals ? "addons/mp3") "bash contrib/scripts/get_mp3_source.sh || true"} ${lib.optionalString (externals ? "addons/mp3") "bash contrib/scripts/get_mp3_source.sh || true"}
chmod -w externals_cache chmod -w externals_cache
${lib.optionalString withOpus ''
cp ${asterisk-opus}/include/asterisk/* ./include/asterisk
cp ${asterisk-opus}/codecs/* ./codecs
cp ${asterisk-opus}/formats/* ./formats
''}
./bootstrap.sh
''; '';
configureFlags = [ configureFlags = [
@ -63,6 +72,10 @@ let
${lib.optionalString (externals ? "addons/mp3") '' ${lib.optionalString (externals ? "addons/mp3") ''
substituteInPlace menuselect.makeopts --replace 'format_mp3 ' "" substituteInPlace menuselect.makeopts --replace 'format_mp3 ' ""
''} ''}
${lib.optionalString withOpus ''
substituteInPlace menuselect.makeopts --replace 'codec_opus_open_source ' ""
substituteInPlace menuselect.makeopts --replace 'format_ogg_opus_open_source ' ""
''}
''; '';
postInstall = '' postInstall = ''
@ -90,6 +103,14 @@ let
sha256 = "1s9idx2miwk178sa731ig9r4fzx4gy1q8xazfqyd7q4lfd70s1cy"; sha256 = "1s9idx2miwk178sa731ig9r4fzx4gy1q8xazfqyd7q4lfd70s1cy";
}; };
asterisk-opus = fetchFromGitHub {
owner = "traud";
repo = "asterisk-opus";
# No releases, points to master as of 2022-04-06
rev = "a959f072d3f364be983dd27e6e250b038aaef747";
sha256 = "sha256-CASlTvTahOg9D5jccF/IN10LP/U8rRy9BFCSaHGQfCw=";
};
# auto-generated by update.py # auto-generated by update.py
versions = lib.mapAttrs (_: {version, sha256}: common { versions = lib.mapAttrs (_: {version, sha256}: common {
inherit version sha256; inherit version sha256;