diff options
-rw-r--r-- | .travis.yml | 9 | ||||
-rw-r--r-- | CMakeLists.txt | 4 | ||||
-rw-r--r-- | cmake/FindG729.cmake | 36 | ||||
-rw-r--r-- | src/audio/audio_decoder.cpp | 8 | ||||
-rw-r--r-- | src/audio/audio_encoder.cpp | 10 | ||||
-rw-r--r-- | src/gui/getprofilenameform.cpp | 30 | ||||
-rw-r--r-- | src/gui/getprofilenameform.ui | 24 | ||||
-rw-r--r-- | src/gui/syssettingsform.ui | 2 | ||||
-rw-r--r-- | src/session.cpp | 5 | ||||
-rw-r--r-- | twinkle_config.h.in | 1 |
10 files changed, 123 insertions, 6 deletions
diff --git a/.travis.yml b/.travis.yml index 671a119..a406bcb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,7 @@ env: - FLAGS="-DWITH_QT5=ON -DWITH_ALSA=ON -DWITH_GSM=ON -DWITH_SPEEX=ON -DWITH_ZRTP=OFF" # (qttools5-dev-tools is explicitly included because of Debian bug #835295) - PACKAGES="libasound2-dev libgsm1-dev libspeex-dev libspeexdsp-dev qtdeclarative5-dev qttools5-dev qttools5-dev-tools" + matrix: # Test various compiler versions - PACKAGES_ADD="g++-5" MATRIX_EVAL="CC=gcc-5 && CXX=g++-5" @@ -20,9 +21,15 @@ env: - PACKAGES_ADD="clang-6.0" MATRIX_EVAL="CC=clang-6.0 && CXX=clang++-6.0" - PACKAGES_ADD="clang-7" MATRIX_EVAL="CC=clang-7 && CXX=clang++-7" - PACKAGES_ADD="clang-8" MATRIX_EVAL="CC=clang-8 && CXX=clang++-8" + # Test with all options disabled - FLAGS="-DWITH_QT5=OFF -DWITH_ALSA=OFF -DWITH_GSM=OFF -DWITH_SPEEX=OFF -DWITH_ZRTP=OFF" PACKAGES="" + # Test building with bcg729 + - BUILD_BCG729="master" FLAGS="-DWITH_QT5=OFF -DWITH_ALSA=OFF -DWITH_G729=ON" PACKAGES="git ca-certificates" + # Also test the old pre-1.0.2 API (see issue #104) + - BUILD_BCG729="1.0.1" BUILD_BCG729_AUTOTOOLS="Y" FLAGS="-DWITH_QT5=OFF -DWITH_ALSA=OFF -DWITH_G729=ON" PACKAGES="git ca-certificates pkg-config libtool automake autoconf" + # See https://docs.travis-ci.com/user/languages/cpp/#C11-C%2B%2B11-%28and-Beyond%29-and-Toolchain-Versioning before_install: - eval "${MATRIX_EVAL}" @@ -33,6 +40,8 @@ install: - sudo apt-get -y install bison cmake flex libccrtp-dev libmagic-dev libreadline-dev libsndfile1-dev libucommon-dev libxml2-dev linux-libc-dev $PACKAGES $PACKAGES_ADD script: + # Download and build bcg729 if necessary + - if [ "$BUILD_BCG729" ]; then git clone git://git.linphone.org/bcg729.git --branch "$BUILD_BCG729" && (cd bcg729 && if [ "$BUILD_BCG729_AUTOTOOLS" ]; then ./autogen.sh && ./configure; else cmake .; fi && make && sudo make install); fi - mkdir _build - cd _build - cmake -DCMAKE_INSTALL_PREFIX=../_install $FLAGS .. diff --git a/CMakeLists.txt b/CMakeLists.txt index 1dafe55..7e3fde0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -116,6 +116,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/src/gui/getprofilenameform.cpp b/src/gui/getprofilenameform.cpp index 89c715e..854b9c2 100644 --- a/src/gui/getprofilenameform.cpp +++ b/src/gui/getprofilenameform.cpp @@ -16,6 +16,7 @@ GetProfileNameForm::GetProfileNameForm(QWidget* parent) : QDialog(parent) { setupUi(this); + init(); } /* @@ -28,17 +29,38 @@ GetProfileNameForm::~GetProfileNameForm() void GetProfileNameForm::init() { - // Letters, digits, underscore, minus - QRegExp rxFilenameChars("[\\w\\-][\\w\\-@\\.]*"); + // Letters, digits, underscore, minus, "@" and period + QRegExp rxFilenameChars("[\\w\\-@\\.]*"); // Set validators // USER profileLineEdit->setValidator(new QRegExpValidator(rxFilenameChars, this)); + + // Focus seems to default to OK button, despite tab order + profileLineEdit->setFocus(); } void GetProfileNameForm::validate() { - if (profileLineEdit->text().isEmpty()) return; + QString profileName = profileLineEdit->text(); + + if (profileName.isEmpty()) return; + + // Check for anything that was let through by the validator + QRegExp rxFilename("^[\\w\\-][\\w\\-@\\.]*$"); + if (!rxFilename.exactMatch(profileName)) { + QMessageBox::critical(this, PRODUCT_NAME, + tr("Invalid profile name: %1").arg(profileName) + // While this would be better suited as informativeText, + // Qt wouldn't take it into account when sizing the box + // (see http://apocalyptech.com/linux/qt/qmessagebox/) + + QString("\n\n") + tr( + "Allowed characters are: letters, digits, '-', '_', '.' and '@'.\n" + "Furthermore, the initial character cannot be '.' or '@'." + )); + + return; + } // Find the .twinkle directory in HOME QDir d = QDir::home(); @@ -48,7 +70,7 @@ void GetProfileNameForm::validate() reject(); } - QString filename = profileLineEdit->text(); + QString filename = profileName; filename.append(USER_FILE_EXT); QString fullname = d.filePath(filename); if (QFile::exists(fullname)) { diff --git a/src/gui/getprofilenameform.ui b/src/gui/getprofilenameform.ui index 9e1ba47..417e952 100644 --- a/src/gui/getprofilenameform.ui +++ b/src/gui/getprofilenameform.ui @@ -109,6 +109,30 @@ To remember your profiles easily you could use your SIP user name as a profile n </property> </widget> </item> + <item> + <widget class="QLabel" name="profileNoteLabel"> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>(Allowed characters: letters, digits, '-', '_', '.', '@')</string> + </property> + <property name="scaledContents"> + <bool>false</bool> + </property> + <property name="alignment"> + <set>Qt::AlignVCenter</set> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> </layout> </item> </layout> diff --git a/src/gui/syssettingsform.ui b/src/gui/syssettingsform.ui index 9cb084d..a0ae501 100644 --- a/src/gui/syssettingsform.ui +++ b/src/gui/syssettingsform.ui @@ -955,7 +955,7 @@ If before answering a call, the microphone or speaker appears to be invalid, a w </item> </layout> </item> - <item row="8" column="0"> + <item row="9" column="0"> <layout class="QHBoxLayout"> <item> <widget class="QLabel" name="browserTextLabel"> diff --git a/src/session.cpp b/src/session.cpp index ae816fa..2007791 100644 --- a/src/session.cpp +++ b/src/session.cpp @@ -44,7 +44,10 @@ void t_session::set_recvd_codecs(t_sdp *sdp) { t_audio_codec ac = sdp->get_codec(SDP_AUDIO, *i); if (ac > CODEC_UNSUPPORTED) { recvd_codecs.push_back(ac); - send_ac2payload[ac] = *i; + // Don't overwrite any previous mapping for this codec + if (!send_ac2payload.count(ac)) { + send_ac2payload[ac] = *i; + } send_payload2ac[*i] = ac; } } diff --git a/twinkle_config.h.in b/twinkle_config.h.in index a1aa3b4..53a0426 100644 --- a/twinkle_config.h.in +++ b/twinkle_config.h.in @@ -4,6 +4,7 @@ #cmakedefine HAVE_ILBC_CPP #cmakedefine HAVE_ZRTP #cmakedefine HAVE_BCG729 +#cmakedefine HAVE_BCG729_ANNEX_B #cmakedefine HAVE_GSM #cmakedefine HAVE_UNISTD_H |