[v4,1/7] libpjsip: Add Alsa option

Message ID 20180312092953.24258-1-aduskett@gmail.com
State Changes Requested
Headers show
Series
  • [v4,1/7] libpjsip: Add Alsa option
Related show

Commit Message

Adam Duskett March 12, 2018, 9:29 a.m.
This is the first patch in a series that will enable audio support
for libpjsip. This patch does the following:

- Turn libpjsip into a menuconfig option
- Add a option for alsa support

Signed-off-by: Adam Duskett <aduskett@gmail.com>
---
Changes v1 -> v2:
  - Remove the option to enable or disable alsa support in favor of
    just depending on alsa-lib if it's selected by the user.

Changes v2 -> v3:
  - Make this patch the start of the series.
  - Re-add the option to enable or disable support (Thomas)

Changes v3 -> v4:
  - None

 package/libpjsip/Config.in   | 12 +++++++++++-
 package/libpjsip/libpjsip.mk |  8 +++++++-
 2 files changed, 18 insertions(+), 2 deletions(-)

Comments

Thomas Petazzoni March 26, 2018, 7:46 p.m. | #1
Hello,

On Mon, 12 Mar 2018 05:29:47 -0400, Adam Duskett wrote:
> This is the first patch in a series that will enable audio support
> for libpjsip. This patch does the following:
> 
> - Turn libpjsip into a menuconfig option
> - Add a option for alsa support
> 
> Signed-off-by: Adam Duskett <aduskett@gmail.com>

I've applied your patches, did a few tweaks, but I have some issues.
Could you restart from what I've done at:

  https://git.bootlin.com/users/thomas-petazzoni/buildroot/log/?h=pjsip-improvements

The improvements I've done are:

 - Tweak the commit titles

 - Use the --enable-<foo> options for the dependency-less codecs, since
   those options definitely exist.

 - Minor other formatting tweaks.

 - Select BR2_PACKAGE_ALSA_LIB_MIXER in the first patch, otherwise the
   build fails when this option is disabled.

Unfortunately, with all this, I see two problems. The first problem is
that the link command line contains flags like -Lyes/lib. This is due
to constructs such as:

                    LDFLAGS="$LDFLAGS -L$with_opencore_amr/lib"

So when you pass --with-opencore-amr, $with_opencore_amr has the value
"yes". You should change such options to
--with-opencore-amr=$(STAGING_DIR)/usr instead.

The second problem is that the following defconfig fails to build:

BR2_arm=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_CUSTOM=y
BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD=y
BR2_TOOLCHAIN_EXTERNAL_URL="http://autobuild.buildroot.org/toolchains/tarballs/br-arm-full-2017.11-rc1.tar.bz2"
BR2_TOOLCHAIN_EXTERNAL_GCC_4_9=y
BR2_TOOLCHAIN_EXTERNAL_HEADERS_3_10=y
BR2_TOOLCHAIN_EXTERNAL_LOCALE=y
# BR2_TOOLCHAIN_EXTERNAL_HAS_THREADS_DEBUG is not set
BR2_TOOLCHAIN_EXTERNAL_CXX=y
BR2_INIT_NONE=y
BR2_SYSTEM_BIN_SH_NONE=y
# BR2_PACKAGE_BUSYBOX is not set
# BR2_PACKAGE_ALSA_LIB_ALOAD is not set
# BR2_PACKAGE_ALSA_LIB_RAWMIDI is not set
# BR2_PACKAGE_ALSA_LIB_HWDEP is not set
# BR2_PACKAGE_ALSA_LIB_SEQ is not set
# BR2_PACKAGE_ALSA_LIB_ALISP is not set
# BR2_PACKAGE_ALSA_LIB_OLD_SYMBOLS is not set
BR2_PACKAGE_LIBPJSIP=y
BR2_PACKAGE_LIBPJSIP_ALSA=y
BR2_PACKAGE_LIBPJSIP_CODEC_G711=y
BR2_PACKAGE_LIBPJSIP_CODEC_G722=y
BR2_PACKAGE_LIBPJSIP_CODEC_G7221=y
BR2_PACKAGE_LIBPJSIP_CODEC_ILBC=y
BR2_PACKAGE_LIBPJSIP_CODEC_L16=y
BR2_PACKAGE_LIBPJSIP_CODEC_BCG729=y
BR2_PACKAGE_LIBPJSIP_CODEC_GSM=y
BR2_PACKAGE_LIBPJSIP_CODEC_OPENCORE_AMR=y
BR2_PACKAGE_LIBPJSIP_CODEC_OPUS=y
BR2_PACKAGE_LIBPJSIP_CODEC_SPEEX=y
# BR2_TARGET_ROOTFS_TAR is not set

Could you have a look, fix those problems, and send an updated version ?

Thanks!

Thomas
Thomas Petazzoni March 26, 2018, 7:48 p.m. | #2
Hello,

On Mon, 26 Mar 2018 21:46:02 +0200, Thomas Petazzoni wrote:

> The second problem is that the following defconfig fails to build:
> 
> BR2_arm=y
> BR2_TOOLCHAIN_EXTERNAL=y
> BR2_TOOLCHAIN_EXTERNAL_CUSTOM=y
> BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD=y
> BR2_TOOLCHAIN_EXTERNAL_URL="http://autobuild.buildroot.org/toolchains/tarballs/br-arm-full-2017.11-rc1.tar.bz2"
> BR2_TOOLCHAIN_EXTERNAL_GCC_4_9=y
> BR2_TOOLCHAIN_EXTERNAL_HEADERS_3_10=y
> BR2_TOOLCHAIN_EXTERNAL_LOCALE=y
> # BR2_TOOLCHAIN_EXTERNAL_HAS_THREADS_DEBUG is not set
> BR2_TOOLCHAIN_EXTERNAL_CXX=y
> BR2_INIT_NONE=y
> BR2_SYSTEM_BIN_SH_NONE=y
> # BR2_PACKAGE_BUSYBOX is not set
> # BR2_PACKAGE_ALSA_LIB_ALOAD is not set
> # BR2_PACKAGE_ALSA_LIB_RAWMIDI is not set
> # BR2_PACKAGE_ALSA_LIB_HWDEP is not set
> # BR2_PACKAGE_ALSA_LIB_SEQ is not set
> # BR2_PACKAGE_ALSA_LIB_ALISP is not set
> # BR2_PACKAGE_ALSA_LIB_OLD_SYMBOLS is not set
> BR2_PACKAGE_LIBPJSIP=y
> BR2_PACKAGE_LIBPJSIP_ALSA=y
> BR2_PACKAGE_LIBPJSIP_CODEC_G711=y
> BR2_PACKAGE_LIBPJSIP_CODEC_G722=y
> BR2_PACKAGE_LIBPJSIP_CODEC_G7221=y
> BR2_PACKAGE_LIBPJSIP_CODEC_ILBC=y
> BR2_PACKAGE_LIBPJSIP_CODEC_L16=y
> BR2_PACKAGE_LIBPJSIP_CODEC_BCG729=y
> BR2_PACKAGE_LIBPJSIP_CODEC_GSM=y
> BR2_PACKAGE_LIBPJSIP_CODEC_OPENCORE_AMR=y
> BR2_PACKAGE_LIBPJSIP_CODEC_OPUS=y
> BR2_PACKAGE_LIBPJSIP_CODEC_SPEEX=y
> # BR2_TARGET_ROOTFS_TAR is not set

It fails like this:

if test ! -d ../bin; then mkdir -p ../bin; fi
/home/thomas/projets/buildroot/output/host/bin/arm-linux-gcc -o ../bin/pjmedia-test-arm-buildroot-linux-uclibcgnueabi \
     output/pjmedia-test-arm-buildroot-linux-uclibcgnueabi/codec_vectors.o  output/pjmedia-test-arm-buildroot-linux-uclibcgnueabi/jbuf_test.o  output/pjmedia-test-arm-buildroot-linux-uclibcgnueabi/main.o  output/pjmedia-test-arm-buildroot-linux-uclibcgnueabi/mips_test.o  output/pjmedia-test-arm-buildroot-linux-uclibcgnueabi/vid_codec_test.o  output/pjmedia-test-arm-buildroot-linux-uclibcgnueabi/vid_dev_test.o  output/pjmedia-test-arm-buildroot-linux-uclibcgnueabi/vid_port_test.o  output/pjmedia-test-arm-buildroot-linux-uclibcgnueabi/rtp_test.o  output/pjmedia-test-arm-buildroot-linux-uclibcgnueabi/test.o  output/pjmedia-test-arm-buildroot-linux-uclibcgnueabi/sdp_neg_test.o -lpjmedia-codec -lpjmedia-videodev -lpjmedia-audiodev -lpjmedia -lpjnath -lpjlib-util -lpj  -lilbccodec -lg7221codec  -lsrtp -lgsm -lspeex -lspeexdsp
-L/home/thomas/projets/buildroot/output/host/arm-buildroot-linux-uclibcgnueabi/sysroot/usr/lib  -Lyes/lib -lbcg729 -lopus -lm -lrt -lpthread  -lasound -lopencore-amrnb -lopencore-amrwb   -L/home/thomas/projets/buildroot/output/build/libpjsip-2.7.2/pjlib/lib -L/home/thomas/projets/buildroot/output/build/libpjsip-2.7.2/pjlib-util/lib -L/home/thomas/projets/buildroot/output/build/libpjsip-2.7.2/pjnath/lib -L/home/thomas/projets/buildroot/output/build/libpjsip-2.7.2/pjmedia/lib -L/home/thomas/projets/buildroot/output/build/libpjsip-2.7.2/pjsip/lib -L/home/thomas/projets/buildroot/output/build/libpjsip-2.7.2/third_party/lib         -L/home/thomas/projets/buildroot/output/host/arm-buildroot-linux-uclibcgnueabi/sysroot/usr/lib  -Lyes/lib     
output/pjmedia-test-arm-buildroot-linux-uclibcgnueabi/mips_test.o: In function `amr_encode_decode':
mips_test.c:(.text+0x1ba8): undefined reference to `pjmedia_codec_opencore_amrnb_init'
mips_test.c:(.text+0x1bac): undefined reference to `pjmedia_codec_opencore_amrnb_deinit'
output/pjmedia-test-arm-buildroot-linux-uclibcgnueabi/mips_test.o: In function `speex16_encode_decode':
mips_test.c:(.text+0x1bfc): undefined reference to `pjmedia_codec_speex_init_default'
mips_test.c:(.text+0x1c00): undefined reference to `pjmedia_codec_speex_deinit'
output/pjmedia-test-arm-buildroot-linux-uclibcgnueabi/mips_test.o: In function `speex8_encode_decode':
mips_test.c:(.text+0x1c50): undefined reference to `pjmedia_codec_speex_init_default'
mips_test.c:(.text+0x1c54): undefined reference to `pjmedia_codec_speex_deinit'
output/pjmedia-test-arm-buildroot-linux-uclibcgnueabi/mips_test.o: In function `gsm_encode_decode':
mips_test.c:(.text+0x1d10): undefined reference to `pjmedia_codec_gsm_init'
mips_test.c:(.text+0x1d14): undefined reference to `pjmedia_codec_gsm_deinit'
output/pjmedia-test-arm-buildroot-linux-uclibcgnueabi/mips_test.o: In function `create_stream_amr':
mips_test.c:(.text+0x21b0): undefined reference to `pjmedia_codec_opencore_amrnb_init'
mips_test.c:(.text+0x21b4): undefined reference to `pjmedia_codec_opencore_amrnb_deinit'
output/pjmedia-test-arm-buildroot-linux-uclibcgnueabi/mips_test.o: In function `create_stream_gsm_srtp80_with_auth':
mips_test.c:(.text+0x2228): undefined reference to `pjmedia_codec_gsm_init'
mips_test.c:(.text+0x222c): undefined reference to `pjmedia_codec_gsm_deinit'
output/pjmedia-test-arm-buildroot-linux-uclibcgnueabi/mips_test.o: In function `create_stream_gsm_srtp80_no_auth':
mips_test.c:(.text+0x22a4): undefined reference to `pjmedia_codec_gsm_init'
mips_test.c:(.text+0x22a8): undefined reference to `pjmedia_codec_gsm_deinit'
output/pjmedia-test-arm-buildroot-linux-uclibcgnueabi/mips_test.o: In function `create_stream_gsm_srtp32_with_auth':
mips_test.c:(.text+0x231c): undefined reference to `pjmedia_codec_gsm_init'
mips_test.c:(.text+0x2320): undefined reference to `pjmedia_codec_gsm_deinit'
output/pjmedia-test-arm-buildroot-linux-uclibcgnueabi/mips_test.o: In function `create_stream_gsm_srtp32_no_auth':
mips_test.c:(.text+0x2398): undefined reference to `pjmedia_codec_gsm_init'
mips_test.c:(.text+0x239c): undefined reference to `pjmedia_codec_gsm_deinit'
output/pjmedia-test-arm-buildroot-linux-uclibcgnueabi/mips_test.o: In function `create_stream_gsm':
mips_test.c:(.text+0x2410): undefined reference to `pjmedia_codec_gsm_init'
mips_test.c:(.text+0x2414): undefined reference to `pjmedia_codec_gsm_deinit'
collect2: error: ld returned 1 exit status
make[4]: *** [/home/thomas/projets/buildroot/output/build/libpjsip-2.7.2/build/rules.mak:125: ../bin/pjmedia-test-arm-buildroot-linux-uclibcgnueabi] Error 1
make[3]: *** [Makefile:243: pjmedia-test-arm-buildroot-linux-uclibcgnueabi] Error 2
make[2]: *** [Makefile:14: all] Error 1
make[1]: *** [package/pkg-generic.mk:224: /home/thomas/projets/buildroot/output/build/libpjsip-2.7.2/.stamp_built] Error 2
make: *** [Makefile:79: _all] Error 2

Best regards,

Thomas

Patch

diff --git a/package/libpjsip/Config.in b/package/libpjsip/Config.in
index 727d2ec3d0..0e03ebf7a3 100644
--- a/package/libpjsip/Config.in
+++ b/package/libpjsip/Config.in
@@ -1,4 +1,4 @@ 
-config BR2_PACKAGE_LIBPJSIP
+menuconfig BR2_PACKAGE_LIBPJSIP
 	bool "libpjsip"
 	depends on BR2_INSTALL_LIBSTDCPP
 	depends on BR2_TOOLCHAIN_HAS_THREADS
@@ -10,5 +10,15 @@  config BR2_PACKAGE_LIBPJSIP
 
 	  http://www.pjsip.org
 
+if BR2_PACKAGE_LIBPJSIP
+
+comment "sound"
+
+config BR2_PACKAGE_LIBPJSIP_ALSA
+	bool "alsa support"
+	select BR2_PACKAGE_ALSA_LIB
+
+endif #BR2_PACKAGE_LIBPJSIP
+
 comment "libpjsip needs a toolchain w/ C++, threads"
 	depends on !BR2_INSTALL_LIBSTDCPP || !BR2_TOOLCHAIN_HAS_THREADS
diff --git a/package/libpjsip/libpjsip.mk b/package/libpjsip/libpjsip.mk
index 53b654d072..a584e8c73a 100644
--- a/package/libpjsip/libpjsip.mk
+++ b/package/libpjsip/libpjsip.mk
@@ -25,7 +25,6 @@  LIBPJSIP_CONF_ENV = \
 	CFLAGS="$(LIBPJSIP_CFLAGS)"
 
 LIBPJSIP_CONF_OPTS = \
-	--disable-sound \
 	--disable-gsm-codec \
 	--disable-speex-codec \
 	--disable-speex-aec \
@@ -67,4 +66,11 @@  ifeq ($(BR2_PACKAGE_UTIL_LINUX_LIBUUID),y)
 LIBPJSIP_DEPENDENCIES += util-linux
 endif
 
+ifeq ($(BR2_PACKAGE_LIBPJSIP_ALSA),y)
+LIBPJSIP_DEPENDENCIES += alsa-lib
+LIBPJSIP_CONF_OPTS += --enable-sound
+else
+LIBPJSIP_CONF_OPTS += --disable-sound
+endif
+
 $(eval $(autotools-package))