files/twinkle: fixes

- add G.729 patch
- remove ilbc flag
- move qt5 as hard dependency

Signed-off-by: Victor Kustov <ktrace@yandex.ru>
pull/13/head
Victor Kustov 1 year ago
parent 9a53cd4fe6
commit d560e8a4ca
Signed by: ktrace
GPG Key ID: 9494B70312B4CADE

@ -0,0 +1,140 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 59a8b08..cc7388c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -97,6 +97,10 @@ if (WITH_G729)
if (G729_FOUND)
message(STATUS "bcg729 OK")
set(HAVE_BCG729 TRUE)
+
+ if (G729_ANNEX_B)
+ set(HAVE_BCG729_ANNEX_B TRUE)
+ endif (G729_ANNEX_B)
include_directories(${G729_INCLUDE_DIR})
else (G729_FOUND)
diff --git a/cmake/FindG729.cmake b/cmake/FindG729.cmake
index 4a30ba0..1fbfeeb 100644
--- a/cmake/FindG729.cmake
+++ b/cmake/FindG729.cmake
@@ -1,14 +1,50 @@
+INCLUDE(CMakePushCheckState)
+INCLUDE(CheckCSourceCompiles)
+
FIND_PATH(G729_INCLUDE_DIR bcg729/decoder.h)
FIND_LIBRARY(G729_LIBRARY NAMES bcg729)
IF(G729_INCLUDE_DIR AND G729_LIBRARY)
SET(G729_FOUND TRUE)
+
+ # The bcg729 API was changed in 1.0.2 to add support for G.729 Annex B.
+ # This checks whether we are dealing with the old or new API.
+ CMAKE_PUSH_CHECK_STATE()
+ SET(CMAKE_REQUIRED_INCLUDES "${INCLUDE_DIRECTORIES}" "${G729_INCLUDE_DIR}")
+ SET(CMAKE_REQUIRED_LIBRARIES "${G729_LIBRARY}")
+ SET(CMAKE_REQUIRED_QUIET TRUE)
+ # Try to compile something using the old (pre-1.0.2) API.
+ #
+ # We cannot do it the other way around, as initBcg729EncoderChannel()
+ # did not have a prototype before 1.0.2, thus compilation would not fail
+ # when passing it an extra argument.
+ CHECK_C_SOURCE_COMPILES("
+ #include <bcg729/encoder.h>
+
+ int main() {
+ /* This function requires an argument since 1.0.2 */
+ initBcg729EncoderChannel();
+ return 0;
+ }
+ " G729_OLD_API)
+ CMAKE_POP_CHECK_STATE()
+
+ IF (G729_OLD_API)
+ SET(G729_ANNEX_B FALSE)
+ ELSE (G729_OLD_API)
+ SET(G729_ANNEX_B TRUE)
+ ENDIF (G729_OLD_API)
ENDIF(G729_INCLUDE_DIR AND G729_LIBRARY)
IF(G729_FOUND)
IF (NOT G729_FIND_QUIETLY)
MESSAGE(STATUS "Found bcg729 includes: ${G729_INCLUDE_DIR}/bcg729/decoder.h")
MESSAGE(STATUS "Found bcg729 library: ${G729_LIBRARY}")
+ IF (G729_ANNEX_B)
+ MESSAGE(STATUS "bcg729 supports Annex B; using the new (1.0.2) API")
+ ELSE (G729_ANNEX_B)
+ MESSAGE(STATUS "bcg729 does not support Annex B; using the old (pre-1.0.2) API")
+ ENDIF (G729_ANNEX_B)
ENDIF (NOT G729_FIND_QUIETLY)
ELSE(G729_FOUND)
IF (G729_FIND_REQUIRED)
diff --git a/src/audio/audio_decoder.cpp b/src/audio/audio_decoder.cpp
index 65935dd..c661910 100644
--- a/src/audio/audio_decoder.cpp
+++ b/src/audio/audio_decoder.cpp
@@ -547,7 +547,11 @@ uint16 t_g729a_audio_decoder::decode(uint8 *payload, uint16 payload_size,
for (uint16 done = 0; done < payload_size; done += 10)
{
+#ifdef HAVE_BCG729_ANNEX_B
+ bcg729Decoder(_context, &payload[done], 0, false, false, false, &pcm_buf[done * 8]);
+#else
bcg729Decoder(_context, &payload[done], false, &pcm_buf[done * 8]);
+#endif
}
return payload_size * 8;
@@ -562,7 +566,11 @@ uint16 t_g729a_audio_decoder::conceal(int16 *pcm_buf, uint16 pcm_buf_size)
{
assert(pcm_buf_size >= 80);
+#ifdef HAVE_BCG729_ANNEX_B
+ bcg729Decoder(_context, nullptr, 0, true, false, false, pcm_buf);
+#else
bcg729Decoder(_context, nullptr, true, pcm_buf);
+#endif
return 80;
}
diff --git a/src/audio/audio_encoder.cpp b/src/audio/audio_encoder.cpp
index d6ff356..952b1ee 100644
--- a/src/audio/audio_encoder.cpp
+++ b/src/audio/audio_encoder.cpp
@@ -433,7 +433,11 @@ uint16 t_g726_audio_encoder::encode(int16 *sample_buf, uint16 nsamples,
t_g729a_audio_encoder::t_g729a_audio_encoder(uint16 payload_id, uint16 ptime, t_user *user_config)
: t_audio_encoder(payload_id, ptime, user_config)
{
+#ifdef HAVE_BCG729_ANNEX_B
+ _context = initBcg729EncoderChannel(false);
+#else
_context = initBcg729EncoderChannel();
+#endif
}
t_g729a_audio_encoder::~t_g729a_audio_encoder()
@@ -451,7 +455,13 @@ uint16 t_g729a_audio_encoder::encode(int16 *sample_buf, uint16 nsamples,
for (uint16 done = 0; done < nsamples; done += 80)
{
+#ifdef HAVE_BCG729_ANNEX_B
+ uint8 frame_size = 10;
+ bcg729Encoder(_context, &sample_buf[done], &payload[done / 8], &frame_size);
+ assert(frame_size == 10);
+#else
bcg729Encoder(_context, &sample_buf[done], &payload[done / 8]);
+#endif
}
return nsamples / 8;
diff --git a/twinkle_config.h.in b/twinkle_config.h.in
index 3928565..6990142 100644
--- a/twinkle_config.h.in
+++ b/twinkle_config.h.in
@@ -3,6 +3,7 @@
#cmakedefine HAVE_ILBC
#cmakedefine HAVE_ZRTP
#cmakedefine HAVE_BCG729
+#cmakedefine HAVE_BCG729_ANNEX_B
#cmakedefine HAVE_GSM
#cmakedefine HAVE_UNISTD_H

@ -13,9 +13,7 @@
Twinkle is a SIP-based VoIP client, ported to Qt5.
</longdescription>
<use>
<flag name="diamondcard">Diamondcard.us VOIP Service</flag>
<flag name="g729">G.729 codec</flag>
<flag name="ilbc">iLBC codec</flag>
<flag name="zrtp">RTP compression</flag>
</use>
<upstream>

@ -3,7 +3,7 @@
EAPI=8
inherit cmake
inherit cmake xdg
DESCRIPTION="Softphone for VoIP communcations using SIP protocol"
HOMEPAGE="http://twinkle.dolezel.info/"
@ -12,32 +12,43 @@ SRC_URI="https://github.com/LubosD/twinkle/archive/v${PV}.tar.gz -> ${P}.tar.gz"
LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE="alsa diamondcard g729 ilbc speex +qt5 +zrtp"
IUSE="alsa g729 gsm speex zrtp"
DEPEND="dev-libs/boost
DEPEND="dev-libs/libxml2:2
dev-libs/ucommon
dev-libs/libxml2
dev-qt/qtcore:5
dev-qt/qtgui:5
dev-qt/qtquickcontrols2:5
dev-qt/qtwidgets:5
media-libs/fontconfig
media-libs/libsndfile
media-libs/libsndfile
net-libs/ccrtp
sys-libs/readline:=
sys-apps/file:=
alsa? ( media-libs/alsa-lib )
g729? ( media-libs/bcg729 )
ilbc? ( media-libs/libilbc )
speex? ( media-libs/speex )
gsm? ( media-sound/gsm )
speex? ( media-libs/speex media-libs/speexdsp )
zrtp? ( net-libs/zrtpcpp )"
RDEPEND="${DEPEND}"
BDEPEND=""
BDEPEND="dev-qt/linguist-tools:5
sys-devel/bison
sys-devel/flex"
PATCHES=( "${FILESDIR}/${P}"-g729.patch )
src_configure() {
local mycmakeargs=(
-DWITH_ALSA=$(usex alsa)
-DWITH_DIAMONDCARD=$(usex diamondcard)
-DWITH_G729=$(usex g729)
-DWITH_ILBC=$(usex ilbc)
-DWITH_QT5=$(usex qt5)
-DWITH_GSM=$(usex gsm)
-DWITH_ILBC=no
-DWITH_QT5=yes
-DWITH_SPEEX=$(usex speex)
-DWITH_ZRTP=$(usex zrtp)
)
cmake_src_configure
}
Loading…
Cancel
Save