├── .gitignore ├── CHANGELOG.md ├── README.md ├── bcg729-build ├── build ├── config.conf ├── openh264-build-target-archs ├── openssl-build-target-archs ├── opus-build ├── patches ├── export_rtcp_fb │ ├── patch.sh │ └── rtcpfb.patch ├── fix_missing_contact_header_on_incall_ip_change │ ├── fix_missing_contact_header.patch │ └── patch.sh └── fixed_callid │ ├── README.md │ ├── callid.old.patch │ ├── callid.patch │ └── patch.sh └── prepare-build-system /.gitignore: -------------------------------------------------------------------------------- 1 | # libraries and tools downloaded 2 | tools/ 3 | 4 | # all the build artifacts 5 | output/ 6 | 7 | # ide stuff 8 | .vscode 9 | 10 | # OSX 11 | .DS_Store 12 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | ## Version 2.7.0 (2022-11-22) 4 | 5 | * Add patch to fix update_contact_header when need_outbound is false and only reg_contact_uri_params is not empty 6 | * **Issues fixed**: 7 | * #54 8 | 9 | ## Version 2.6.0 (2022-11-22) 10 | 11 | * Add patch to allow exporting of RtcpFb event data to pjsua2 12 | * Add switch and setting to change the default PJSIP_TRANSPORT_IDLE_TIME 13 | * **Issues fixed**: 14 | * #50 15 | * #51 16 | 17 | ## Version 2.5.0 (2022-11-03) 18 | 19 | * Add switch to compile with debug symbols 20 | * **Issues fixed**: 21 | * #49 22 | 23 | ## Version 2.4.1 (2022-07-29) 24 | 25 | * Add switches to compile PJSIP with only specific support libraries 26 | 27 | ## Version 2.4.0 (2022-07-28) 28 | 29 | * Bump default versions 30 | * NDK to `r21e` 31 | * PJSIP to `2.12.1` 32 | * Cmd Tools to `8512546` 33 | * **Issues fixed**: 34 | * #48 35 | 36 | ## Version 2.3.0 (2021-05-19) 37 | 38 | * Bump default versions 39 | * NDK to `r20b` 40 | * SWIG to `4.0.2` 41 | * PJSIP to `2.11` 42 | * OpenSSL to `1.1.1k` 43 | * OpenH264 to `2.1.0` 44 | * Opus to `1.3.1` 45 | * Use bcg729 to enable `g729` codec 46 | * **Issues fixed**: 47 | * #43 48 | * #44 49 | 50 | ## Version 2.2.0 (2020-03-30) 51 | 52 | * Add flag to support IPv6 53 | * **Issues fixed**: 54 | * #41 55 | 56 | ## Version 2.1.0 (2019-09-13) 57 | 58 | * **Issues fixed**: 59 | * #31 60 | * #36 61 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PJSIP Android Builder 2 | 3 | Easily build PJSIP with: OpenSSL, OpenH264, Opus and G.729 (without Intel IPP) for Android. 4 | 5 | ## Purpose 6 | 7 | I needed an easily replicable build system to build PJSIP native library with NDK for Android. So, I created an Ubuntu docker container (20.04.4 LTS) and wrote some scripts to download, install all the requirements needed to make it a complete build environment and some automated build scripts. 8 | If you want to contribute, your help is really appreciated :) 9 | 10 | ## Support - PJSIP 2.9+ 11 | 12 | Using Android API `21`. 13 | Default versions included: 14 | 15 | - Android Cmd Tools: `8512546` 16 | - Android NKD: `r21e` 17 | - OpenSSL: `1.1.1k` (Uses NDK Level 21) 18 | - OpenH264: `2.1.0` (Uses NDK Level 21) 19 | - Opus: `1.3.1` 20 | - bcg729: `1.1.1` 21 | - Swig: `4.0.2` 22 | 23 | ## Legacy support 24 | 25 | Checkout tag `2.2.0` to build older pjsip (or other libs) versions. 26 | 27 | ## Setup 28 | 29 | You can install everything on your local machine, or (the way I do) use an Ubuntu Docker container and mount an external volume with this repo. E.g.: 30 | 31 | ```bash 32 | docker run -it --name pjsip-builder -v /path/to/host/repo:/home ubuntu bash 33 | ``` 34 | 35 | ### Configuration 36 | 37 | 1. Clone this repo on your machine or in the mounted volume inside your container. 38 | 2. Properly configure the `config.conf` file. It's possible to configure libraries versions and build settings by editing it. The settings in the `Support` section above have been tested. Please read the comments in the file for more details. Now single libraries can be configured to be compiled with PJSIP without further editing, just enable the switches in the config file. 39 | 3. In the `config.conf` file there are some toggles to apply patches ([`fixed_callid`](patches/fixed_callid)). See the respective README for more info. 40 | 41 | ### Prepare Environment 42 | 43 | 1. Execute `./prepare-build-system` 44 | 2. If everything goes well you should see all the compiled libraries (opus, openh264, openssl, bcg729) in the **output** folder. 45 | 46 | ## Build PJSIP 47 | 48 | After you have successfully set up everything, to build PJSIP execute `./build` 49 | 50 | The script is going to create a new folder inside the output named **pjsip-output-build** organized as follows: 51 | 52 | ```none 53 | pjsip-output-build 54 | |-- logs/ contains the full build log for each target architecture 55 | |-- lib/ contains the compiled libraries for each target architecture 56 | |-- java/ contains PJSUA Java wrapper to work with the library 57 | ``` 58 | 59 | If something goes wrong during the compilation of a particular target architecture, the main script will be terminated and you can see the full log in `./pjsip-output-build/logs/.log`. So for example if there's an error for **x86**, you can see the full log in `./pjsip-output-build/logs/x86.log` 60 | 61 | #### x86 Relocation 62 | 63 | To fix the issue, popping up in recent NDK versions. I've used the fix proposed by @alexmelnikov [here](https://github.com/VoiSmart/pjsip-android-builder/pull/28/commits/b4b1868b741f7eae037ea8b7ab274c8f1ac2c3e8), but I have applied it only for `x86` arch. 64 | 65 | ## Build Libraries only 66 | 67 | This project has separate independent script to build only single libraries: 68 | 69 | - Bcg729 70 | - OpenSSL 71 | - OpenH264 72 | - Opus 73 | 74 | If you want to build a single library, or just change it's version, you can disable everything except the library you want to build from the `config.conf` file and specify the version you want (of course you would also need the NDK). Then execute the `prepare-build-system` script. If the environment is ready you can also just run the lib dedicated script. 75 | 76 | ## License 77 | 78 | ```text 79 | Copyright (C) 2015-2022 VoiSmart Srl 80 | 81 | Licensed under the Apache License, Version 2.0 (the "License"); 82 | you may not use this file except in compliance with the License. 83 | You may obtain a copy of the License at 84 | 85 | http://www.apache.org/licenses/LICENSE-2.0 86 | 87 | Unless required by applicable law or agreed to in writing, software 88 | distributed under the License is distributed on an "AS IS" BASIS, 89 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 90 | See the License for the specific language governing permissions and 91 | limitations under the License. 92 | ``` 93 | -------------------------------------------------------------------------------- /bcg729-build: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | . config.conf 4 | 5 | NDK_PATH="$DOWNLOAD_DIR/${NDK_DIR_NAME}" 6 | BCG729_PATH="$DOWNLOAD_DIR/${BCG729_DIR_NAME}" 7 | LIB_PATH="${BCG729_BUILD_OUT_PATH}/libs" 8 | LOG_PATH="${BCG729_BUILD_OUT_PATH}/logs" 9 | 10 | LIB_BUILD_PATH="$BCG729_PATH/obj/local" 11 | LIB_HEADERS_PATH="$BCG729_PATH/include" 12 | 13 | rm -rf "${BCG729_BUILD_OUT_PATH}" 14 | mkdir -p "${LIB_PATH}" 15 | mkdir -p "${LOG_PATH}" 16 | 17 | cd $BCG729_PATH 18 | 19 | # Patching Android.mk 20 | echo "Patching bcg729 Android.mk ..." 21 | echo "there" 22 | ADD_TO_LOCAL_SRC_FILES=$(cat <<-END 23 | src\/utils\.c \\ 24 | src\/cng\.c \\ 25 | src\/dtx\.c \\ 26 | src\/vad\.c 27 | END 28 | ) 29 | echo "here" 30 | sed -e "s/src\/utils\.c/${ADD_TO_LOCAL_SRC_FILES}/g" -i Android.mk 31 | 32 | # Build bcg729 33 | echo "Building bcg729 $BCG729_VERSION ..." 34 | 35 | for arch in "${TARGET_ARCHS[@]}" 36 | do 37 | echo "Building bcg729 for $arch ..." 38 | cd $BCG729_PATH 39 | $NDK_PATH/build/ndk-build APP_PLATFORM=android-${TARGET_ANDROID_API} APP_ABI=$arch NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=Android.mk >> "${LOG_PATH}/$arch.log" 2>&1 40 | 41 | echo "Copying bcg729 files for target arch $arch ..." 42 | cp -r $LIB_BUILD_PATH/$arch* $LIB_PATH 43 | cd $LIB_PATH/$arch 44 | mkdir -p lib 45 | mv `ls | grep -w -v lib` lib 46 | mkdir -p include 47 | cp -r $LIB_HEADERS_PATH/* include 48 | done 49 | 50 | echo "Finished building bcg729" 51 | -------------------------------------------------------------------------------- /build: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | # @author Aleksandar Gotev (alex.gotev@mobimesh.it) 3 | # @author Vincenzo Esposito (v.esposito@voismart.it) 4 | 5 | . config.conf 6 | 7 | BASE_FOLDER=$DOWNLOAD_DIR 8 | 9 | PJSIP_BASE_PATH="${BASE_FOLDER}/${PJSIP_DIR_NAME}" 10 | PJSIP_TMP_PATH="/tmp/pjsip" 11 | CONFIG_SITE_PATH="${PJSIP_BASE_PATH}/pjlib/include/pj/config_site.h" 12 | PJSUA_BASE_DIR="${PJSIP_TMP_PATH}/pjsip-apps/src/swig" 13 | PJSUA_GENERATED_SRC_DIR="${PJSUA_BASE_DIR}/java/android/$PJSIP_GENERATED_ROOT_DIR_NAME/src/main/java/" 14 | PJSUA_GENERATED_SO_PATH="${PJSUA_BASE_DIR}/java/android/$PJSIP_GENERATED_ROOT_DIR_NAME/src/main/jniLibs" 15 | FINAL_BUILD_DIR=$PJSIP_BUILD_OUT_PATH 16 | FINAL_BUILD_LIB="${FINAL_BUILD_DIR}/lib" 17 | FINAL_BUILD_LOGS="${FINAL_BUILD_DIR}/logs" 18 | 19 | export ANDROID_NDK_ROOT="${BASE_FOLDER}/${NDK_DIR_NAME}" 20 | export PATH="$ANDROID_NDK_ROOT:$PATH" 21 | 22 | if [ "${ADD_DEBUG_SYMBOLS}" == "1" ] 23 | then 24 | echo "Adding compile flags for debug symbols" 25 | export NDK_CFLAGS="-g -O2" 26 | else 27 | echo "Debug symbols will not be included" 28 | fi 29 | 30 | ############################################################################## 31 | ############################ FUNCTIONS ############################## 32 | ############################################################################## 33 | 34 | function clearBuildDirectory { 35 | echo "Clear final build folder ..." 36 | rm -rf "${FINAL_BUILD_DIR}" 37 | mkdir -p "${FINAL_BUILD_LIB}" 38 | mkdir -p "${FINAL_BUILD_LOGS}" 39 | } 40 | 41 | function setConfigSite { 42 | echo "Creating config site file for Android ..." 43 | echo "#define PJ_CONFIG_ANDROID 1" > "$CONFIG_SITE_PATH" 44 | echo "#define PJMEDIA_HAS_G7221_CODEC 1" >> "$CONFIG_SITE_PATH" 45 | echo "#define PJMEDIA_AUDIO_DEV_HAS_ANDROID_JNI 0" >> "$CONFIG_SITE_PATH" 46 | echo "#define PJMEDIA_AUDIO_DEV_HAS_OPENSL 1" >> "$CONFIG_SITE_PATH" 47 | echo "#define PJSIP_AUTH_AUTO_SEND_NEXT 0" >> "$CONFIG_SITE_PATH" 48 | echo "#define PJMEDIA_HAS_OPUS_CODEC 1" >> "$CONFIG_SITE_PATH" 49 | 50 | # Check the README in patches README.md for more info 51 | if [ "${USE_FIXED_CALLID}" == "1" ] 52 | then 53 | echo "Changing PJSIP_MAX_URL_SIZE to 512" 54 | echo "#define PJSIP_MAX_URL_SIZE 512" >> "$CONFIG_SITE_PATH" 55 | fi 56 | 57 | # If you are compiling pjsip with openssl you will likely use srtp 58 | # in such scenario it might happen that the sdp contains srtp info 59 | # thus the whole packet will likely exceed the default 4000 bytes. 60 | # We are here increasing that limit to 6000 bytes. 61 | if [ "${ENABLE_OPENSSL}" == "1" ] 62 | then 63 | echo "Changing PJSIP_MAX_PKT_LEN to 6000" 64 | echo "#define PJSIP_MAX_PKT_LEN 6000" >> "$CONFIG_SITE_PATH" 65 | else 66 | echo "You have not enabled OpenSSL in config_site" 67 | fi 68 | 69 | if [ "${ENABLE_IPV6}" == "1" ] 70 | then 71 | echo "Enabling IPV6 in config_site" 72 | echo "#define PJ_HAS_IPV6 1" >> "$CONFIG_SITE_PATH" 73 | else 74 | echo "You have not enabled IPV6 in config_site" 75 | fi 76 | 77 | if [ "${ENABLE_BCG729}" == "1" ] 78 | then 79 | echo "Enabling BCG729 in config_site" 80 | echo "#define PJMEDIA_HAS_BCG729 1" >> "$CONFIG_SITE_PATH" 81 | else 82 | echo "You have not enabled BCG729 in config_site" 83 | fi 84 | 85 | if [ "${ENABLE_OPENH264}" == "1" ] 86 | then 87 | echo "Enabling Video support in config_site" 88 | echo "#define PJMEDIA_HAS_VIDEO 1" >> "$CONFIG_SITE_PATH" 89 | # TODO: must be tested before enabling following settings 90 | # echo "#define PJMEDIA_VIDEO_DEV_HAS_OPENGL 1" >> "$CONFIG_SITE_PATH" 91 | # echo "#define PJMEDIA_VIDEO_DEV_HAS_OPENGL_ES 1" >> "${CONFIG_SITE_PATH}" 92 | # echo "#include " >> "${CONFIG_SITE_PATH}" 93 | else 94 | echo "You have not enabled Video support in config_site" 95 | fi 96 | 97 | if [ "${CHANGE_PJSIP_TRANSPORT_IDLE_TIME}" == "1" ] 98 | then 99 | echo "Changing PJSIP_TRANSPORT_IDLE_TIME to $PJSIP_TRANSPORT_IDLE_TIME" 100 | echo "#define PJSIP_TRANSPORT_IDLE_TIME $PJSIP_TRANSPORT_IDLE_TIME" >> "$CONFIG_SITE_PATH" 101 | fi 102 | 103 | echo "#include " >> "$CONFIG_SITE_PATH" 104 | } 105 | 106 | function buildPjSip { 107 | arch=$1 108 | echo "" 109 | echo "Compile PJSIP for arch $arch ..." 110 | rm -rf "${PJSIP_TMP_PATH}" 111 | mkdir -p "${PJSIP_TMP_PATH}" 112 | cd "${PJSIP_BASE_PATH}" 113 | cp -r * "${PJSIP_TMP_PATH}" 114 | cd "${PJSIP_TMP_PATH}" 115 | 116 | args=("--use-ndk-cflags") 117 | 118 | if [ "${ENABLE_OPENSSL}" == "1" ] 119 | then 120 | echo "with OpenSSL support" 121 | args+=("--with-ssl=${OPENSSL_BUILD_OUT_PATH}/libs/${arch}") 122 | else 123 | echo "without OpenSSL support" 124 | fi 125 | 126 | if [ "${ENABLE_OPENH264}" == "1" ] 127 | then 128 | echo "with OpenH264 support" 129 | args+=("--with-openh264=${OPENH264_BUILD_OUT_PATH}/libs/${arch}") 130 | else 131 | echo "without OpenH264 support" 132 | fi 133 | 134 | if [ "${ENABLE_OPUS}" == "1" ] 135 | then 136 | echo "with Opus support" 137 | args+=("--with-opus=${OPUS_BUILD_OUT_PATH}/libs/${arch}") 138 | else 139 | echo "without Opus support" 140 | fi 141 | 142 | if [ "${ENABLE_BCG729}" == "1" ] 143 | then 144 | echo "with BCG729 support" 145 | args+=("--with-bcg729=${BCG729_BUILD_OUT_PATH}/libs/${arch}") 146 | else 147 | echo "without BCG729 support" 148 | fi 149 | 150 | APP_PLATFORM=android-${TARGET_ANDROID_API} TARGET_ABI=$arch ./configure-android "${args[@]}" >> "${FINAL_BUILD_LOGS}/${arch}.log" 2>&1 151 | 152 | make dep >>"${FINAL_BUILD_LOGS}/${arch}.log" 2>&1 153 | make clean >>"${FINAL_BUILD_LOGS}/${arch}.log" 2>&1 154 | make >>"${FINAL_BUILD_LOGS}/${arch}.log" 2>&1 155 | 156 | echo "Compile PJSUA for arch $arch ..." 157 | cd "${PJSUA_BASE_DIR}" 158 | make >>"${FINAL_BUILD_LOGS}/${arch}.log" 2>&1 159 | 160 | echo "Copying PJSUA .so library to final build directory ..." 161 | mkdir -p "${FINAL_BUILD_LIB}/${arch}" 162 | # Different versions of PJSIP put .so libs in different directory name 163 | # using /*/* we assume there is only one directory (whatever its name is) 164 | # and retrieve all its content (.so libs) 165 | mv "${PJSUA_GENERATED_SO_PATH}"/*/* "${FINAL_BUILD_LIB}/${arch}" 166 | 167 | if [ -f ${OPENH264_BUILD_OUT_PATH}/libs/${arch}/lib/libopenh264.so ]; then 168 | echo "Copying OpenH264 .so library to final build directory ..." 169 | cp ${OPENH264_BUILD_OUT_PATH}/libs/${arch}/lib/libopenh264.so ${FINAL_BUILD_LIB}/${arch}/ 170 | fi 171 | } 172 | 173 | function copyPjSuaJava { 174 | echo "Copying PJSUA2 java bindings to final build directory ..." 175 | cp -r "${PJSUA_GENERATED_SRC_DIR}" "${FINAL_BUILD_DIR}" 176 | rm -r "${PJSIP_TMP_PATH}" 177 | } 178 | 179 | function clearToolsDirectory { 180 | if [ "$REMOVE_TOOLS" == "1" ] 181 | then 182 | echo "" 183 | echo "Cleaning up tools ..." 184 | cd $BASEDIR 185 | rm -r tools 186 | echo "Finished cleaning up tools" 187 | fi 188 | } 189 | 190 | function setPermissions { 191 | if [ "$SET_PERMISSIONS" == "1" ] && [ "$OWNER" != "" ] 192 | then 193 | echo "" 194 | echo "Setting permissions on $BUILD_DIR for user $OWNER" 195 | chown $OWNER -R $BUILD_DIR 196 | echo "Finished Setting permissions" 197 | elif [ "$SET_PERMISSIONS" == "1" ] || [ "$OWNER" != "" ] 198 | then 199 | echo "You must set both the toggle [SET_PERMISSIONS] to 1 and the name of the user [OWNER] that should own the files" 200 | fi 201 | } 202 | 203 | ############################################################################## 204 | ############################ MAIN ############################ 205 | ############################################################################## 206 | 207 | # Clearing the build output directory 208 | clearBuildDirectory 209 | 210 | # Create config_site file 211 | setConfigSite 212 | 213 | # Build PjSip for each ARCH specified in config.conf 214 | for arch in "${TARGET_ARCHS[@]}" 215 | do 216 | buildPjSip $arch 217 | done 218 | 219 | # Copy PjSua Java Bindings into final build output directory 220 | copyPjSuaJava 221 | 222 | # Delete the tools directory 223 | clearToolsDirectory 224 | 225 | # Setting Permission on build output directory 226 | setPermissions 227 | 228 | echo "Finished! Check the generated output in ${FINAL_BUILD_DIR}" 229 | -------------------------------------------------------------------------------- /config.conf: -------------------------------------------------------------------------------- 1 | # Set the path to the repo root folder 2 | # I set /home because I'm working within a Docker container 3 | BASEDIR=/home 4 | 5 | # TOOLS AND LIBRARIES DOWNLOAD DIRECTORY - add to gitignore too 6 | DOWNLOAD_DIR="$BASEDIR/tools" 7 | 8 | # BUILD DIRECTORY WHERE ALL THE BUILD ARTIFACTS WILL BE - add to gitignore too 9 | BUILD_DIR="$BASEDIR/output" 10 | 11 | 12 | ############################################################################### 13 | ############################### NDK ################################ 14 | ############################################################################### 15 | 16 | #NDK Version to download 17 | NDK_VERSION=r21e 18 | 19 | #The URL from which to download Android NDK 20 | NDK_DOWNLOAD_URL="https://dl.google.com/android/repository/android-ndk-$NDK_VERSION-linux-x86_64.zip" 21 | 22 | #The name of the folder created by executing the downloaded NDK bin 23 | #In general, the name corresponds to that of the bin file, except the platform info 24 | NDK_DIR_NAME="android-ndk-$NDK_VERSION" 25 | 26 | 27 | ############################################################################### 28 | ######################## Android CMD TOOLS ######################### 29 | ############################################################################### 30 | 31 | # Command Line Tools Version to download 32 | CMD_TOOLS_VERSION=8512546 33 | 34 | # The URL from which to download Android Command Line Tools 35 | CMD_TOOLS_DOWNLOAD_URL="https://dl.google.com/android/repository/commandlinetools-linux-${CMD_TOOLS_VERSION}_latest.zip" 36 | 37 | # The name of the folder created by unzipping the archive 38 | SDK_DIR_NAME="android-sdk-linux" 39 | 40 | # WARNING - Do not change. It is related to the $CMD_TOOLS_VERSION expected topmost dir name 41 | # In earlier version it was "tools" 42 | CMD_TOOLS="cmdline-tools" 43 | CMD_TOOLS_DIR_NAME="latest" 44 | 45 | 46 | ############################################################################### 47 | ############################## PJSIP ############################### 48 | ############################################################################### 49 | 50 | # PJSIP Version to download 51 | PJSIP_VERSION=2.12.1 52 | 53 | # The URL from which to download PJSIP sources tag 54 | PJSIP_DOWNLOAD_URL="https://github.com/pjsip/pjproject/archive/$PJSIP_VERSION.tar.gz" 55 | 56 | # The name of the folder generated when untarring PJSIP sources file 57 | # In general, the name corresponds to that of the tar, except the file extension 58 | PJSIP_DIR_NAME="pjproject-$PJSIP_VERSION" 59 | 60 | # The output directory where to store PJSIP compiled libraries 61 | PJSIP_BUILD_OUT_PATH="$BUILD_DIR/pjsip-build-output" 62 | 63 | # The generated java bindings and .so lib are placed under different location based on pjsip version 64 | # >= 2.11 -> "pjsua2" (default) 65 | # >= 2.4 -> "app" 66 | PJSIP_GENERATED_ROOT_DIR_NAME="pjsua2" 67 | 68 | 69 | ############################################################################### 70 | ############################### SWIG ############################### 71 | ############################################################################### 72 | 73 | # SWIG Tool Version to download 74 | SWIG_VERSION=4.0.2 75 | 76 | # The URL from which to download SWIG sources tar 77 | SWIG_DOWNLOAD_URL="http://prdownloads.sourceforge.net/swig/swig-$SWIG_VERSION.tar.gz" 78 | 79 | # The name of the folder generated when untarring SWIG sources file 80 | # In general, the name corresponds to that of the tar, except the file extension 81 | SWIG_DIR_NAME="swig-$SWIG_VERSION" 82 | 83 | # the output directory where logs will be 84 | SWIG_BUILD_OUT_PATH="$BUILD_DIR/swig-build-output" 85 | 86 | 87 | ############################################################################### 88 | ############################## OPENSSL ############################# 89 | ############################################################################### 90 | 91 | # OPENSSL Version to download 92 | OPENSSL_VERSION=1.1.1k 93 | 94 | # The URL from which to download OpenSSL sources tag 95 | OPENSSL_DOWNLOAD_URL="https://www.openssl.org/source/openssl-$OPENSSL_VERSION.tar.gz" 96 | 97 | # The name of the folder generated when untarring OpenSSL sources file 98 | # In general, the name corresponds to that of the tar, except the file extension 99 | OPENSSL_DIR_NAME="openssl-$OPENSSL_VERSION" 100 | 101 | # the output directory where to store OpenSSL compiled libraries 102 | OPENSSL_BUILD_OUT_PATH="$BUILD_DIR/openssl-build-output" 103 | 104 | # Configure the target NDK toolchain to use when compiling OpenSSL 105 | OPENSSL_TARGET_NDK_LEVEL=21 106 | 107 | 108 | ############################################################################### 109 | ############################# OPENH264 ############################# 110 | ############################################################################### 111 | 112 | # OpenH264 Version to download 113 | OPENH264_VERSION=openh264v2.1.0 114 | 115 | # The URL from which to download OpenH264 sources tag 116 | OPENH264_DOWNLOAD_URL="https://github.com/cisco/openh264/archive/$OPENH264_VERSION.tar.gz" 117 | 118 | # The name of the folder generated when untarring OpenH264 sources file 119 | # In general, the name corresponds to that of the tar, except the file extension 120 | OPENH264_DIR_NAME="openh264-$OPENH264_VERSION" 121 | 122 | # The output directory where to store OpenH264 compiled libraries 123 | OPENH264_BUILD_OUT_PATH="$BUILD_DIR/openh264-build-output" 124 | 125 | # Configure the target NDK toolchain to use when compiling OpenH264 126 | OPENH264_TARGET_NDK_LEVEL=21 127 | 128 | 129 | ############################################################################### 130 | ################################ OPUS ############################### 131 | ############################################################################### 132 | 133 | # OPUS Version to download 134 | OPUS_VERSION=1.3.1 135 | 136 | # The URL of the Opus repository 137 | OPUS_DOWNLOAD_URL="https://archive.mozilla.org/pub/opus/opus-$OPUS_VERSION.tar.gz" 138 | 139 | # The name of the folder generated when untarring OPUS sources file 140 | OPUS_DIR_NAME="opus-$OPUS_VERSION" 141 | 142 | # The output directory where to store OPUS compiled libraries 143 | OPUS_BUILD_OUT_PATH="$BUILD_DIR/opus-build-output" 144 | 145 | 146 | ############################################################################### 147 | ############################## BCG729 ############################## 148 | ############################################################################### 149 | 150 | # Belledonne Communication g729 Version to download. 151 | # If a version is not specified it will download the current master 152 | BCG729_VERSION=1.1.1 153 | 154 | # The URL of the bcg279 repository 155 | BCG729_DOWNLOAD_URL="https://gitlab.linphone.org/BC/public/bcg729.git" 156 | 157 | # The name of the folder generated when untarring bcg279 sources file 158 | BCG729_DIR_NAME="bcg729-$BCG729_VERSION" 159 | 160 | # The output directory where to store bcg729 compiled libraries 161 | BCG729_BUILD_OUT_PATH="$BUILD_DIR/bcg729-build-output" 162 | 163 | 164 | ############################################################################### 165 | ############################ TARGET ABI ############################ 166 | ############################################################################### 167 | 168 | # Target architectures that you want to build 169 | # Refer to the official NDK docs: https://developer.android.com/ndk/guides/abis.html#sa 170 | # Build only for "armeabi" "armeabi-v7a" "x86" as these are the only architectures 171 | # for which all the libraries are build without problems. You can comment this line and 172 | # uncomment the following one if you want to build for 64 bit archs. Bear in mind that 173 | # to build for 64 bit you have to use Android API 21+ and pjsip >= 2.6. 174 | # check the build compatibility matrix in the readme and in the issues for further reference. 175 | TARGET_ARCHS=("armeabi-v7a" "x86" "arm64-v8a" "x86_64") 176 | 177 | ############################################################################### 178 | ########################### ANDROID APIs ########################### 179 | ############################################################################### 180 | 181 | # Android APIs to setup 182 | SETUP_ANDROID_APIS=("21") 183 | ANDROID_BUILD_TOOLS="30.0.3" 184 | 185 | # Target Android API level 186 | TARGET_ANDROID_API=21 187 | 188 | ############################################################################### 189 | ########################## CONFIGURATION ########################### 190 | ############################################################################### 191 | 192 | # Toggles used only by prepare-build-system script 193 | # Set the value to 1 to enable the feature or to another value to disable it 194 | # Useful when you need to update or restore some sources or packages 195 | 196 | # Updates and installs all the required packages on the system 197 | SETUP_PACKAGES=1 198 | 199 | # Download a fresh copy of Android NDK. Any existing NDK will be replaced 200 | DOWNLOAD_NDK=1 201 | 202 | # Download a fresh copy of Android SDK. Any existing SDK will be replaced 203 | DOWNLOAD_SDK=1 204 | 205 | # Download Android APIs defined in SETUP_ANDROID_APIS 206 | DOWNLOAD_ANDROID_APIS=1 207 | 208 | # Download a fresh copy of PJSIP sources. Any existing files will be deleted 209 | DOWNLOAD_PJSIP=1 210 | 211 | # Downloads and compiles a fresh copy of SWIG 212 | DOWNLOAD_SWIG=1 213 | 214 | # Downloads a fresh copy of OpenSSL and builds it against the specified archs. Any existing files will be deleted 215 | DOWNLOAD_OPENSSL=1 216 | # Compiles PJSIP with OpenSSL support; download and build are required to enable it 217 | ENABLE_OPENSSL=1 218 | 219 | # Downloads a fresh copy of OpenH264 and builds it against the specified archs. Any existing files will be deleted 220 | DOWNLOAD_OPENH264=1 221 | # Compiles PJSIP with OpenH264 support; download and build are required to enable it 222 | ENABLE_OPENH264=1 223 | 224 | # On recent versions of OpenH264 building encdemo and decdemo build fails 225 | # [OpenH264 2.1.x && NDK >= r20b] 226 | SKIP_OPENH264_DEMO=1 227 | 228 | # Downloads a fresh copy of Opus and builds it against the specified archs. Any existing files will be deleted 229 | DOWNLOAD_OPUS=1 230 | # Compiles PJSIP with Opus support; download and build are required to enable it 231 | ENABLE_OPUS=1 232 | 233 | # Downloads a fresh copy of Bcg729 and builds it against the specified archs. Any existing files will be deleted 234 | DOWNLOAD_BCG729=1 235 | # Compiles PJSIP with BCG729 support; download and build are required to enable it 236 | ENABLE_BCG729=1 237 | 238 | # Add debug symbols 239 | ADD_DEBUG_SYMBOLS=1 240 | 241 | # Remove Tools directory after build 242 | REMOVE_TOOLS=0 243 | 244 | # Set permission on output directory -- FOR DOCKER USE 245 | # It should be set in combination with OWNER 246 | SET_PERMISSIONS=0 247 | 248 | # Set the name of the user on the host machine 249 | OWNER="" 250 | 251 | ############################################################################### 252 | ####################### PJSIP CONFIGURATION ######################## 253 | ############################################################################### 254 | 255 | # Enable IPv6 256 | # Thanks to @maccadoo and MR#40 257 | ENABLE_IPV6=0 258 | 259 | # Patch PJSIP to use a fixed Call-ID --- see README.md in patches/fixed_callid folder 260 | USE_FIXED_CALLID=1 261 | 262 | # Change the default PJSIP_TRANSPORT_IDLE_TIME 263 | # On anonymous calls servers might not send options to keep the transport alive 264 | # in such scenario sip messages will not be received after transport shutdown 265 | CHANGE_PJSIP_TRANSPORT_IDLE_TIME=1 266 | PJSIP_TRANSPORT_IDLE_TIME=600 267 | 268 | # Apply a different fixed Call-ID patch if PJSIP version is lower than 2.11 269 | IS_PJSIP_LOWER_THAN_2_11=0 270 | 271 | # Patch PJSIP to export some RTCP FB Event data in pjsua2 Call#onCallMediaEvent 272 | EXPORT_RTCP_FB_DATA=1 273 | 274 | # Patch PJSIP to fix teh Wrong Contact Header when Ip Changes during a call 275 | FIX_MISSING_CONTACT_HEADER=1 276 | -------------------------------------------------------------------------------- /openh264-build-target-archs: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | set -e 4 | 5 | # Source variables from config.conf file 6 | . config.conf 7 | 8 | 9 | ############################################################################## 10 | ############################ FUNCTIONS ############################## 11 | ############################################################################## 12 | 13 | function initialSetup { 14 | NDK_PATH="$DOWNLOAD_DIR/$NDK_DIR_NAME" 15 | SDK_TOOLS_PATH="$DOWNLOAD_DIR/${SDK_DIR_NAME}"/tools 16 | OPENH264_SRC_PATH="$DOWNLOAD_DIR/${OPENH264_DIR_NAME}" 17 | OPENH264_TMP_DIR="/tmp/openh264" 18 | } 19 | 20 | function setupPathsAndExports { 21 | LIB_PATH="${OPENH264_BUILD_OUT_PATH}/libs" 22 | LOG_PATH="${OPENH264_BUILD_OUT_PATH}/logs" 23 | 24 | export ANDROID_NDK_HOME=$NDK_PATH 25 | export ANDROID_HOME=$DOWNLOAD_DIR/${SDK_DIR_NAME} 26 | 27 | export PATH=${SDK_TOOLS_PATH}:$PATH 28 | } 29 | 30 | function clearBuildDirectory { 31 | rm -rf "${OPENH264_BUILD_OUT_PATH}" 32 | mkdir -p "${LIB_PATH}" 33 | mkdir -p "${LOG_PATH}" 34 | } 35 | 36 | function clearTmpAndInitDirectory { 37 | rm -rf "${OPENH264_TMP_DIR}" 38 | mkdir -p "${OPENH264_TMP_DIR}" 39 | cd ${OPENH264_SRC_PATH} 40 | cp -r * ${OPENH264_TMP_DIR} 41 | cd ${OPENH264_TMP_DIR} 42 | mkdir -p "$BUILD_DIR" 43 | mkdir -p "${LIB_PATH}/${arch}" 44 | mkdir -p "${LOG_PATH}" 45 | } 46 | 47 | function finalizeArgs { 48 | arch=$1 49 | if [ "$arch" == "armeabi" ] 50 | then 51 | ARGS="${ARGS}arm APP_ABI=armeabi" 52 | elif [ "$arch" == "armeabi-v7a" ] 53 | then 54 | ARGS="${ARGS}arm" 55 | elif [ "$arch" == "x86" ] 56 | then 57 | ARGS="${ARGS}x86 ENABLEPIC=Yes" 58 | elif [ "$arch" == "x86_64" ] 59 | then 60 | ARGS="${ARGS}x86_64" 61 | elif [ "$arch" == "arm64-v8a" ] 62 | then 63 | ARGS="${ARGS}arm64" 64 | else 65 | echo "Unsupported target ABI: $arch" 66 | exit 1 67 | fi 68 | } 69 | 70 | 71 | ############################################################################## 72 | ############################ INIT ############################ 73 | ############################################################################## 74 | 75 | # Initial variables setup 76 | initialSetup 77 | # Set final paths and exports 78 | setupPathsAndExports 79 | # Clear and recreate the build output directory 80 | clearBuildDirectory 81 | 82 | 83 | ############################################################################## 84 | ############################ MAIN ############################ 85 | ############################################################################## 86 | 87 | for arch in "${TARGET_ARCHS[@]}" 88 | do 89 | echo "Building OpenH264 for target arch $arch ..." 90 | # Clear the tmp source directory 91 | clearTmpAndInitDirectory 92 | 93 | #change default output DIR for make install 94 | sed -i "s*PREFIX=/usr/local*PREFIX=${LIB_PATH}/${arch}*g" Makefile 95 | 96 | ARGS="APP_PLATFORM=android-${TARGET_ANDROID_API} OS=android NDKROOT=${NDK_PATH} NDK_TOOLCHAIN_VERSION=clang NDKLEVEL=${OPENH264_TARGET_NDK_LEVEL} " 97 | ARGS="${ARGS}TARGET=android-${TARGET_ANDROID_API} ARCH=" 98 | # Add final architecture dependent info 99 | finalizeArgs $arch 100 | 101 | make ${ARGS} >> "${LOG_PATH}/${arch}.log" 2>&1 102 | mkdir -p ${LIB_PATH}/${arch} 103 | make ${ARGS} install >> "${LOG_PATH}/${arch}.log" 2>&1 104 | done 105 | 106 | echo "Finished building OpenH264! Check output folder: ${OPENH264_BUILD_OUT_PATH}" 107 | 108 | set +e 109 | -------------------------------------------------------------------------------- /openssl-build-target-archs: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | # @author Vincenzo Esposito (v.esposito@voismart.it) 3 | # Hints and code taken also from https://proandroiddev.com/tutorial-compile-openssl-to-1-1-1-for-android-application-87137968fee 4 | 5 | set -e 6 | 7 | # Source variables from config.conf file 8 | . config.conf 9 | 10 | 11 | ############################################################################## 12 | ############################ FUNCTIONS ############################## 13 | ############################################################################## 14 | 15 | function initialSetup { 16 | CUR_DIR="$(pwd)" 17 | OPENSSL_SRC_PATH="$DOWNLOAD_DIR/${OPENSSL_DIR_NAME}" 18 | OPENSSL_TMP_FOLDER="/tmp/openssl" 19 | } 20 | 21 | function setupPathsAndExports { 22 | NDK_PATH="$DOWNLOAD_DIR/${NDK_DIR_NAME}" 23 | LIB_PATH="${OPENSSL_BUILD_OUT_PATH}/libs" 24 | LOG_PATH="${OPENSSL_BUILD_OUT_PATH}/logs" 25 | 26 | # Export ANDROID_NDK_HOME env var 27 | export ANDROID_NDK_HOME=$NDK_PATH 28 | # Add toolchains bin directory to PATH 29 | TOOLCHAIN_PATH="$NDK_PATH/toolchains/llvm/prebuilt/linux-x86_64" 30 | # for some reason it does not need to be exported 31 | PATH=$TOOLCHAIN_PATH/bin:$PATH 32 | } 33 | 34 | function clearBuildDirectory { 35 | rm -rf "${OPENSSL_BUILD_OUT_PATH}" 36 | mkdir -p "${LIB_PATH}" 37 | mkdir -p "${LOG_PATH}" 38 | } 39 | 40 | function clearTmpDirectory { 41 | rm -rf "$OPENSSL_TMP_FOLDER" 42 | mkdir -p "$OPENSSL_TMP_FOLDER" 43 | cp -r ${OPENSSL_SRC_PATH}/* ${OPENSSL_TMP_FOLDER} 44 | } 45 | 46 | function getArchitecture { 47 | OPENSSL_TARGET_ABI=$1 48 | if [ "$OPENSSL_TARGET_ABI" == "armeabi-v7a" ] 49 | then 50 | ARCHITECTURE="android-arm" 51 | elif [ "$OPENSSL_TARGET_ABI" == "arm64-v8a" ] 52 | then 53 | ARCHITECTURE="android-arm64" 54 | elif [ "$OPENSSL_TARGET_ABI" == "x86" ] 55 | then 56 | # Use "no-asm" arg as specified in Merge Request #28 --- Use Only for x86 ARCH 57 | ARCHITECTURE="android-x86 no-asm" 58 | elif [ "$OPENSSL_TARGET_ABI" == "x86_64" ] 59 | then 60 | ARCHITECTURE="android-x86_64" 61 | else 62 | echo "Unsupported target ABI: $OPENSSL_TARGET_ABI" 63 | exit 1 64 | fi 65 | } 66 | 67 | 68 | ############################################################################## 69 | ############################ INIT ############################ 70 | ############################################################################## 71 | 72 | # Initial variables setup 73 | initialSetup 74 | # Set final paths and exports 75 | setupPathsAndExports 76 | # Clear and recreate the build output directory 77 | clearBuildDirectory 78 | # Set clang compiler, instead of gcc by default 79 | CC=clang 80 | 81 | 82 | ############################################################################## 83 | ############################ MAIN ############################ 84 | ############################################################################## 85 | 86 | # Build OpenSSL for each ARCH specified in config.conf 87 | for arch in "${TARGET_ARCHS[@]}" 88 | do 89 | echo "Configuring OpenSSL for target arch $arch ..." 90 | 91 | # Clear the tmp source directory 92 | clearTmpDirectory 93 | # Go to source files 94 | cd ${OPENSSL_TMP_FOLDER} 95 | 96 | OPENSSL_OUTPUT_PATH=$LIB_PATH/$arch 97 | 98 | # Set the target architecture 99 | # Can be android-arm, android-arm64, android-x86 etc 100 | ARCHITECTURE="android-arm" 101 | getArchitecture $arch 102 | 103 | # Create Makefile 104 | ./Configure $ARCHITECTURE -D__ANDROID_API__=${OPENSSL_TARGET_NDK_LEVEL} >> "${LOG_PATH}/${arch}.log" 2>&1 105 | 106 | # Build Openssl 107 | echo "Building OpenSSL Library for Android arch $arch" 108 | make >> "${LOG_PATH}/${arch}.log" 2>&1 109 | mkdir -p $OPENSSL_OUTPUT_PATH 110 | OUTPUT_LIB=$OPENSSL_OUTPUT_PATH/lib 111 | mkdir -p $OUTPUT_LIB 112 | OUTPUT_INCLUDE=${OPENSSL_OUTPUT_PATH}/include 113 | mkdir -p $OUTPUT_INCLUDE 114 | cp -RL include/openssl $OUTPUT_INCLUDE 115 | 116 | # Copy libs to final destination folder 117 | cp libssl.a $OUTPUT_LIB 118 | cp libcrypto.a $OUTPUT_LIB 119 | # Uncomment if you want .so libs (pjsip only needs the static libs) 120 | # cp libssl.so $OUTPUT_LIB 121 | # cp libcrypto.so $OUTPUT_LIB 122 | echo "Build completed! Check output libraries in ${OPENSSL_OUTPUT_PATH}" 123 | done 124 | 125 | # Remove tmp folder 126 | rm -rf ${OPENSSL_TMP_FOLDER} 127 | echo "Finished building OpenSSL! Check output folder: ${OPENSSL_BUILD_OUT_PATH}" 128 | 129 | set +e 130 | -------------------------------------------------------------------------------- /opus-build: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | . config.conf 4 | 5 | NDK_PATH="$DOWNLOAD_DIR/${NDK_DIR_NAME}" 6 | OPUS_PATH="$DOWNLOAD_DIR/${OPUS_DIR_NAME}" 7 | LIB_PATH="${OPUS_BUILD_OUT_PATH}/libs" 8 | LOG_PATH="${OPUS_BUILD_OUT_PATH}/logs" 9 | 10 | LIB_BUILD_PATH="$OPUS_PATH/obj/local" 11 | LIB_HEADERS_PATH="$OPUS_PATH/include" 12 | 13 | rm -rf "${OPUS_BUILD_OUT_PATH}" 14 | mkdir -p "${LIB_PATH}" 15 | mkdir -p "${LOG_PATH}" 16 | 17 | 18 | cd $OPUS_PATH 19 | 20 | # Download Android.mk 21 | echo "Downloading Android.mk file from PjSip website ..." 22 | mkdir -p jni 23 | (cd jni && curl -O https://trac.pjsip.org/repos/raw-attachment/ticket/1904/Android.mk) 24 | 25 | # Build Opus 26 | echo "Building Opus $OPUS_VERSION ..." 27 | $NDK_PATH/ndk-build APP_PLATFORM=android-${TARGET_ANDROID_API} >> "${LOG_PATH}/opus.log" 2>&1 28 | 29 | # Copy Files to Build Directory 30 | echo "Copying build file in Opus Build directory ..." 31 | cp -r $LIB_BUILD_PATH/* $LIB_PATH 32 | 33 | for arch in "${TARGET_ARCHS[@]}" 34 | do 35 | echo "Copying Opus file for target arch $arch ..." 36 | cd $LIB_PATH/$arch 37 | mkdir -p lib 38 | mv `ls | grep -w -v lib` lib 39 | mkdir -p include/opus 40 | cp $LIB_HEADERS_PATH/* include/opus 41 | done 42 | 43 | echo "Finished building Opus" -------------------------------------------------------------------------------- /patches/export_rtcp_fb/patch.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | . ../../config.conf 4 | 5 | PJPROJECT_BASE_FOLDER="$DOWNLOAD_DIR/$PJSIP_DIR_NAME" 6 | 7 | cp rtcpfb.patch $PJPROJECT_BASE_FOLDER 8 | 9 | pushd "$PJPROJECT_BASE_FOLDER" 10 | patch -p0 < rtcpfb.patch 11 | rm rtcpfb.patch 12 | popd -------------------------------------------------------------------------------- /patches/export_rtcp_fb/rtcpfb.patch: -------------------------------------------------------------------------------- 1 | diff --git pjsip/include/pjsua2/media.hpp pjsip/include/pjsua2/media.hpp 2 | index 5c4321082..85bf0c8f6 100644 3 | --- pjsip/include/pjsua2/media.hpp 4 | +++ pjsip/include/pjsua2/media.hpp 5 | @@ -2559,6 +2559,15 @@ struct AudDevErrorEvent 6 | pj_status_t status; /**< The status code. */ 7 | }; 8 | 9 | +/** 10 | + * This structure describes the rtcp fb event. 11 | + */ 12 | +struct RtcpFbEvent 13 | +{ 14 | + pjmedia_rtcp_fb_type fbType; 15 | + bool isParamLengthZero; 16 | +}; 17 | + 18 | /** 19 | * Media event data. 20 | */ 21 | @@ -2572,6 +2581,11 @@ typedef union MediaEventData { 22 | * Audio device error event data. 23 | */ 24 | AudDevErrorEvent audDevError; 25 | + 26 | + /** 27 | + * Rtcp FB event data. 28 | + */ 29 | + RtcpFbEvent rtcpFb; 30 | 31 | /** 32 | * Pointer to storage to user event data, if it's outside 33 | diff --git pjsip/src/pjsua2/media.cpp pjsip/src/pjsua2/media.cpp 34 | index de9819fda..158bdc945 100644 35 | --- pjsip/src/pjsua2/media.cpp 36 | +++ pjsip/src/pjsua2/media.cpp 37 | @@ -1931,6 +1931,9 @@ void MediaEvent::fromPj(const pjmedia_event &ev) 38 | data.audDevError.dir = ev.data.aud_dev_err.dir; 39 | data.audDevError.id = ev.data.aud_dev_err.id; 40 | data.audDevError.status = ev.data.aud_dev_err.status; 41 | + } else if (type == PJMEDIA_EVENT_RX_RTCP_FB) { 42 | + data.rtcpFb.fbType = ev.data.rx_rtcp_fb.cap.type; 43 | + data.rtcpFb.isParamLengthZero = ev.data.rx_rtcp_fb.cap.param.slen == 0; 44 | } 45 | pjMediaEvent = (void *)&ev; 46 | } 47 | -------------------------------------------------------------------------------- /patches/fix_missing_contact_header_on_incall_ip_change/fix_missing_contact_header.patch: -------------------------------------------------------------------------------- 1 | diff -Naur ./pjproject-2.12.1/pjsip/src/pjsua-lib/pjsua_acc.c ./pjproject-2.12.1-patched/pjsip/src/pjsua-lib/pjsua_acc.c 2 | --- ./pjsip/src/pjsua-lib/pjsua_acc.c 2023-11-24 15:02:28 3 | +++ ./pjsip/src/pjsua-lib/pjsua_acc.c 2023-11-27 14:41:25 4 | @@ -1580,7 +1580,7 @@ 5 | acc->cfg.reg_contact_params.slen + 6 | acc->cfg.reg_contact_uri_params.slen + 7 | (need_outbound? 8 | - (acc->rfc5626_instprm.slen + acc->rfc5626_regprm.slen): 0); 9 | + (acc->rfc5626_instprm.slen + acc->rfc5626_regprm.slen): 1); 10 | if (len > acc->contact.slen) { 11 | reg_contact.ptr = (char*) pj_pool_alloc(acc->pool, len); 12 | 13 | -------------------------------------------------------------------------------- /patches/fix_missing_contact_header_on_incall_ip_change/patch.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | . ../../config.conf 4 | 5 | PJPROJECT_BASE_FOLDER="$DOWNLOAD_DIR/$PJSIP_DIR_NAME" 6 | 7 | PATCH_NAME=fix_missing_contact_header.patch 8 | 9 | cp $PATCH_NAME $PJPROJECT_BASE_FOLDER 10 | 11 | pushd "$PJPROJECT_BASE_FOLDER" 12 | patch -p0 < $PATCH_NAME 13 | rm $PATCH_NAME 14 | popd -------------------------------------------------------------------------------- /patches/fixed_callid/README.md: -------------------------------------------------------------------------------- 1 | # Fixed Call-ID patch 2 | 3 | For our own purposes we are required to set the sip registration expiration to `2 weeks`. Moreover, our PBX identify different registrations based on the `Call-ID` header, which in PJSIP is randomly generated. 4 | 5 | Since the app gets closed/killed by the OS the new registration has a new Call-ID and so the registrations start to pile up. 6 | 7 | Using this patch we use the same Call-ID for every registration performed by the combination of same {fcm token, sipuser}. We have added another method to the pjsua2/swig binding to set the `Call-ID` from java code. If this value is not set, the library falls back to the regular way of generating the `Call-ID`. 8 | 9 | The script also increases the `PJSIP_MAX_URL_SIZE` to `512` defined in `sip_config.g` because the FCM token may cause the Contact Header to exceed the max default size which was set to `256`. 10 | -------------------------------------------------------------------------------- /patches/fixed_callid/callid.old.patch: -------------------------------------------------------------------------------- 1 | diff -ru pjsip/include/pjsip-ua/sip_regc.h pjsip/include/pjsip-ua/sip_regc.h 2 | --- pjsip/include/pjsip-ua/sip_regc.h 2019-02-27 14:20:20.317143606 +0100 3 | +++ pjsip/include/pjsip-ua/sip_regc.h 2019-02-27 18:23:41.431145200 +0100 4 | @@ -205,7 +205,8 @@ 5 | const pj_str_t *to_url, 6 | int ccnt, 7 | const pj_str_t contact[], 8 | - pj_uint32_t expires); 9 | + pj_uint32_t expires, 10 | + const pj_str_t *cid); 11 | 12 | /** 13 | * Set callback to be called when the registration received a final response. 14 | diff -ru pjsip/include/pjsua2/account.hpp pjsip/include/pjsua2/account.hpp 15 | --- pjsip/include/pjsua2/account.hpp 2019-02-27 14:20:20.318143608 +0100 16 | +++ pjsip/include/pjsua2/account.hpp 2019-02-27 18:23:41.431145200 +0100 17 | @@ -168,6 +168,14 @@ 18 | */ 19 | unsigned proxyUse; 20 | 21 | + /** 22 | + * This value will be used to set the registration Call-ID 23 | + * if not present the library will generate a random unique value 24 | + * 25 | + * The parameters should be a string of 32 alphanumeric chars 26 | + */ 27 | + string callID; 28 | + 29 | public: 30 | /** 31 | * Read this object from a container node. 32 | diff -ru pjsip/include/pjsua-lib/pjsua.h pjsip/include/pjsua-lib/pjsua.h 33 | --- pjsip/include/pjsua-lib/pjsua.h 2019-02-27 14:20:20.318143608 +0100 34 | +++ pjsip/include/pjsua-lib/pjsua.h 2019-02-27 18:23:41.432145201 +0100 35 | @@ -2939,6 +2939,14 @@ 36 | pj_str_t id; 37 | 38 | /** 39 | + * The Call ID used in REGISTER. If the value is empty, a random generated 40 | + * value will be used. 41 | + * 42 | + * This field is optional. 43 | + */ 44 | + pj_str_t call_id; 45 | + 46 | + /** 47 | * This is the URL to be put in the request URI for the registration, 48 | * and will look something like "sip:serviceprovider". 49 | * 50 | diff -ru pjsip/src/pjsip-ua/sip_reg.c pjsip/src/pjsip-ua/sip_reg.c 51 | --- pjsip/src/pjsip-ua/sip_reg.c 2019-02-27 14:20:20.321143612 +0100 52 | +++ pjsip/src/pjsip-ua/sip_reg.c 2019-02-27 18:23:41.433145202 +0100 53 | @@ -334,7 +334,8 @@ 54 | const pj_str_t *to_url, 55 | int contact_cnt, 56 | const pj_str_t contact[], 57 | - pj_uint32_t expires) 58 | + pj_uint32_t expires, 59 | + const pj_str_t *cid) 60 | { 61 | pj_str_t tmp; 62 | pj_status_t status; 63 | @@ -386,7 +387,12 @@ 64 | 65 | /* Set "Call-ID" header. */ 66 | regc->cid_hdr = pjsip_cid_hdr_create(regc->pool); 67 | - pj_create_unique_string(regc->pool, ®c->cid_hdr->id); 68 | + if (cid->slen > 0){ 69 | + pj_strdup_with_null(regc->pool, ®c->cid_hdr->id, cid); 70 | + PJ_LOG(4,(THIS_FILE, "regc: callID %.*s", regc->cid_hdr->id.slen, regc->cid_hdr->id.ptr)); 71 | + } else { 72 | + pj_create_unique_string(regc->pool, ®c->cid_hdr->id); 73 | + } 74 | 75 | /* Set "CSeq" header. */ 76 | regc->cseq_hdr = pjsip_cseq_hdr_create(regc->pool); 77 | diff -ru pjsip/src/pjsua2/account.cpp pjsip/src/pjsua2/account.cpp 78 | --- pjsip/src/pjsua2/account.cpp 2019-02-27 14:20:20.322143613 +0100 79 | +++ pjsip/src/pjsua2/account.cpp 2019-02-27 18:23:41.433145202 +0100 80 | @@ -44,6 +44,7 @@ 81 | NODE_READ_UNSIGNED (this_node, unregWaitMsec); 82 | NODE_READ_UNSIGNED (this_node, proxyUse); 83 | NODE_READ_STRING (this_node, contactParams); 84 | + NODE_READ_STRING (this_node, callID); 85 | 86 | readSipHeaders(this_node, "headers", headers); 87 | } 88 | @@ -63,6 +64,7 @@ 89 | NODE_WRITE_UNSIGNED (this_node, unregWaitMsec); 90 | NODE_WRITE_UNSIGNED (this_node, proxyUse); 91 | NODE_WRITE_STRING (this_node, contactParams); 92 | + NODE_WRITE_STRING (this_node, callID); 93 | 94 | writeSipHeaders(this_node, "headers", headers); 95 | } 96 | @@ -332,6 +334,7 @@ 97 | ret.unreg_timeout = regConfig.unregWaitMsec; 98 | ret.reg_use_proxy = regConfig.proxyUse; 99 | ret.reg_contact_params = str2Pj(regConfig.contactParams); 100 | + ret.call_id = str2Pj(regConfig.callID); 101 | for (i=0; icontact_uri_params, 117 | &src->contact_uri_params); 118 | pj_strdup_with_null(pool, &dst->pidf_tuple_id, &src->pidf_tuple_id); 119 | + pj_strdup_with_null(pool, &dst->call_id, &src->call_id); 120 | pj_strdup_with_null(pool, &dst->rfc5626_instance_id, 121 | &src->rfc5626_instance_id); 122 | pj_strdup_with_null(pool, &dst->rfc5626_reg_id, &src->rfc5626_reg_id); 123 | @@ -430,7 +431,7 @@ 124 | if (acc->pool) 125 | pj_pool_reset(acc->pool); 126 | else 127 | - acc->pool = pjsua_pool_create("acc%p", 512, 256); 128 | + acc->pool = pjsua_pool_create("acc%p", 1024, 256); 129 | 130 | /* Copy config */ 131 | pjsua_acc_config_dup(acc->pool, &pjsua_var.acc[id].cfg, cfg); 132 | @@ -2399,7 +2400,8 @@ 133 | &acc->cfg.id, 134 | &acc->cfg.id, 135 | 1, &acc->reg_contact, 136 | - acc->cfg.reg_timeout); 137 | + acc->cfg.reg_timeout, 138 | + &acc->cfg.call_id); 139 | if (status != PJ_SUCCESS) { 140 | pjsua_perror(THIS_FILE, 141 | "Client registration initialization error", 142 | diff -ru pjsip/src/pjsua-lib/pjsua_core.c pjsip/src/pjsua-lib/pjsua_core.c 143 | --- pjsip/src/pjsua-lib/pjsua_core.c 2019-02-27 14:20:20.321143612 +0100 144 | +++ pjsip/src/pjsua-lib/pjsua_core.c 2019-02-27 18:23:41.434145203 +0100 145 | @@ -259,6 +259,8 @@ 146 | 147 | pj_bzero(cfg, sizeof(*cfg)); 148 | 149 | + cfg->call_id = pj_str(""); 150 | + 151 | cfg->reg_timeout = PJSUA_REG_INTERVAL; 152 | cfg->reg_delay_before_refresh = PJSIP_REGISTER_CLIENT_DELAY_BEFORE_REFRESH; 153 | cfg->unreg_timeout = PJSUA_UNREG_TIMEOUT; 154 | diff -ru pjsip/src/test/regc_test.c pjsip/src/test/regc_test.c 155 | --- pjsip/src/test/regc_test.c 2019-02-27 14:20:20.323143614 +0100 156 | +++ pjsip/src/test/regc_test.c 2019-02-27 18:23:41.435145204 +0100 157 | @@ -293,7 +293,7 @@ 158 | return -100; 159 | 160 | status = pjsip_regc_init(regc, registrar_uri, &aor, &aor, contact_cnt, 161 | - contacts, expires ? expires : 60); 162 | + contacts, expires ? expires : 60, "highComplexityCall-Id123456"); 163 | if (status != PJ_SUCCESS) { 164 | pjsip_regc_destroy(regc); 165 | return -110; -------------------------------------------------------------------------------- /patches/fixed_callid/callid.patch: -------------------------------------------------------------------------------- 1 | diff --git pjsip/include/pjsip-ua/sip_regc.h pjsip/include/pjsip-ua/sip_regc.h 2 | index b094afeb7..67a69a73d 100644 3 | --- pjsip/include/pjsip-ua/sip_regc.h 4 | +++ pjsip/include/pjsip-ua/sip_regc.h 5 | @@ -225,7 +225,8 @@ PJ_DECL(pj_status_t) pjsip_regc_init(pjsip_regc *regc, 6 | const pj_str_t *to_url, 7 | int ccnt, 8 | const pj_str_t contact[], 9 | - pj_uint32_t expires); 10 | + pj_uint32_t expires, 11 | + const pj_str_t *cid); 12 | 13 | 14 | /** 15 | diff --git pjsip/include/pjsua-lib/pjsua.h pjsip/include/pjsua-lib/pjsua.h 16 | index e5d9b494b..f3df90031 100644 17 | --- pjsip/include/pjsua-lib/pjsua.h 18 | +++ pjsip/include/pjsua-lib/pjsua.h 19 | @@ -3672,6 +3672,14 @@ typedef struct pjsua_acc_config 20 | */ 21 | pj_str_t id; 22 | 23 | + /** 24 | + * The Call ID used in REGISTER. If the value is empty, a random generated 25 | + * value will be used. 26 | + * 27 | + * This field is optional. 28 | + */ 29 | + pj_str_t call_id; 30 | + 31 | /** 32 | * This is the URL to be put in the request URI for the registration, 33 | * and will look something like "sip:serviceprovider". 34 | diff --git pjsip/include/pjsua2/account.hpp pjsip/include/pjsua2/account.hpp 35 | index 76e7e179b..4454fce2c 100644 36 | --- pjsip/include/pjsua2/account.hpp 37 | +++ pjsip/include/pjsua2/account.hpp 38 | @@ -179,6 +179,14 @@ struct AccountRegConfig : public PersistentObject 39 | */ 40 | unsigned proxyUse; 41 | 42 | + /** 43 | + * This value will be used to set the registration Call-ID 44 | + * if not present the library will generate a random unique value 45 | + * 46 | + * The parameters should be a string of 32 alphanumeric chars 47 | + */ 48 | + string callID; 49 | + 50 | public: 51 | /** 52 | * Read this object from a container node. 53 | diff --git pjsip/src/pjsip-ua/sip_reg.c pjsip/src/pjsip-ua/sip_reg.c 54 | index a5132adf9..485a65728 100644 55 | --- pjsip/src/pjsip-ua/sip_reg.c 56 | +++ pjsip/src/pjsip-ua/sip_reg.c 57 | @@ -343,7 +343,8 @@ PJ_DEF(pj_status_t) pjsip_regc_init( pjsip_regc *regc, 58 | const pj_str_t *to_url, 59 | int contact_cnt, 60 | const pj_str_t contact[], 61 | - pj_uint32_t expires) 62 | + pj_uint32_t expires, 63 | + const pj_str_t *cid) 64 | { 65 | pj_str_t tmp; 66 | pj_status_t status; 67 | @@ -395,7 +396,12 @@ PJ_DEF(pj_status_t) pjsip_regc_init( pjsip_regc *regc, 68 | 69 | /* Set "Call-ID" header. */ 70 | regc->cid_hdr = pjsip_cid_hdr_create(regc->pool); 71 | - pj_create_unique_string(regc->pool, ®c->cid_hdr->id); 72 | + if (cid->slen > 0){ 73 | + pj_strdup_with_null(regc->pool, ®c->cid_hdr->id, cid); 74 | + PJ_LOG(4,(THIS_FILE, "regc: callID %.*s", regc->cid_hdr->id.slen, regc->cid_hdr->id.ptr)); 75 | + } else { 76 | + pj_create_unique_string(regc->pool, ®c->cid_hdr->id); 77 | + } 78 | 79 | /* Set "CSeq" header. */ 80 | regc->cseq_hdr = pjsip_cseq_hdr_create(regc->pool); 81 | diff --git pjsip/src/pjsua-lib/pjsua_acc.c pjsip/src/pjsua-lib/pjsua_acc.c 82 | index af1d79ddf..6ea77c1b6 100644 83 | --- pjsip/src/pjsua-lib/pjsua_acc.c 84 | +++ pjsip/src/pjsua-lib/pjsua_acc.c 85 | @@ -96,6 +96,7 @@ PJ_DEF(void) pjsua_acc_config_dup( pj_pool_t *pool, 86 | pj_strdup_with_null(pool, &dst->contact_uri_params, 87 | &src->contact_uri_params); 88 | pj_strdup_with_null(pool, &dst->pidf_tuple_id, &src->pidf_tuple_id); 89 | + pj_strdup_with_null(pool, &dst->call_id, &src->call_id); 90 | pj_strdup_with_null(pool, &dst->rfc5626_instance_id, 91 | &src->rfc5626_instance_id); 92 | pj_strdup_with_null(pool, &dst->rfc5626_reg_id, &src->rfc5626_reg_id); 93 | @@ -2655,7 +2656,8 @@ static pj_status_t pjsua_regc_init(int acc_id) 94 | &acc->cfg.id, 95 | &acc->cfg.id, 96 | 1, &acc->reg_contact, 97 | - acc->cfg.reg_timeout); 98 | + acc->cfg.reg_timeout, 99 | + &acc->cfg.call_id); 100 | if (status != PJ_SUCCESS) { 101 | pjsua_perror(THIS_FILE, 102 | "Client registration initialization error", 103 | diff --git pjsip/src/pjsua-lib/pjsua_core.c pjsip/src/pjsua-lib/pjsua_core.c 104 | index c437011b5..ac0e616be 100644 105 | --- pjsip/src/pjsua-lib/pjsua_core.c 106 | +++ pjsip/src/pjsua-lib/pjsua_core.c 107 | @@ -324,6 +324,8 @@ PJ_DEF(void) pjsua_acc_config_default(pjsua_acc_config *cfg) 108 | 109 | pj_bzero(cfg, sizeof(*cfg)); 110 | 111 | + cfg->call_id = pj_str(""); 112 | + 113 | cfg->reg_timeout = PJSUA_REG_INTERVAL; 114 | cfg->reg_delay_before_refresh = PJSIP_REGISTER_CLIENT_DELAY_BEFORE_REFRESH; 115 | cfg->unreg_timeout = PJSUA_UNREG_TIMEOUT; 116 | diff --git pjsip/src/pjsua2/account.cpp pjsip/src/pjsua2/account.cpp 117 | index e7a6d4eaa..15367d1a8 100644 118 | --- pjsip/src/pjsua2/account.cpp 119 | +++ pjsip/src/pjsua2/account.cpp 120 | @@ -237,6 +237,7 @@ void AccountRegConfig::readObject(const ContainerNode &node) 121 | NODE_READ_UNSIGNED (this_node, unregWaitMsec); 122 | NODE_READ_UNSIGNED (this_node, proxyUse); 123 | NODE_READ_STRING (this_node, contactParams); 124 | + NODE_READ_STRING (this_node, callID); 125 | 126 | readSipHeaders(this_node, "headers", headers); 127 | } 128 | @@ -257,6 +258,7 @@ void AccountRegConfig::writeObject(ContainerNode &node) const 129 | NODE_WRITE_UNSIGNED (this_node, unregWaitMsec); 130 | NODE_WRITE_UNSIGNED (this_node, proxyUse); 131 | NODE_WRITE_STRING (this_node, contactParams); 132 | + NODE_WRITE_STRING (this_node, callID); 133 | 134 | writeSipHeaders(this_node, "headers", headers); 135 | } 136 | @@ -578,6 +580,7 @@ void AccountConfig::toPj(pjsua_acc_config &ret) const 137 | ret.drop_calls_on_reg_fail = regConfig.dropCallsOnFail; 138 | ret.unreg_timeout = regConfig.unregWaitMsec; 139 | ret.reg_use_proxy = regConfig.proxyUse; 140 | + ret.call_id = str2Pj(regConfig.callID); 141 | ret.reg_contact_params = str2Pj(regConfig.contactParams); 142 | ret.reg_contact_uri_params = str2Pj(regConfig.contactUriParams); 143 | for (i=0; i&1 46 | rm -rf "$NDK_DIR_NAME" 47 | echo "" 48 | echo "Android NDK downloaded!" 49 | echo "" 50 | echo "Extracting Android NDK ..." 51 | echo "" 52 | unzip ndk.zip -d ndk 53 | mv ndk/$NDK_DIR_NAME . 54 | rm -rf ndk 55 | rm -rf ndk.zip 56 | fi 57 | 58 | if [ "$DOWNLOAD_SDK" == "1" ] 59 | then 60 | CMD_ZIP_FILE="$CMD_TOOLS.zip" 61 | 62 | echo "" 63 | echo "Downloading Android CMD Line Tools version ${CMD_TOOLS_VERSION} ..." 64 | cd $DOWNLOAD_DIR 65 | curl -L -# -o $CMD_ZIP_FILE $CMD_TOOLS_DOWNLOAD_URL 2>&1 66 | echo "" 67 | echo "Android CMD Tools downloaded!" 68 | echo "Extracting Android CMD Tools ..." 69 | rm -rf $SDK_DIR_NAME 70 | unzip -d $SDK_DIR_NAME $CMD_ZIP_FILE 71 | 72 | # Remove zip file 73 | rm -rf $CMD_ZIP_FILE 74 | 75 | # Create empty repositories.cfg file to avoid warning 76 | mkdir -p ~/.android 77 | touch ~/.android/repositories.cfg 78 | 79 | # Since new updates, there are some changes that are not mentioned in the documentation. 80 | # After unzipping the command line tools package, the top-most directory you'll get is $CMD_TOOLS. 81 | # Rename the unpacked directory from $CMD_TOOLS to $CMD_TOOLS_DIR_NAME, and place it under $ANDROID_HOME/$CMD_TOOLS 82 | # which will then look like $ANDROID_HOME/$CMD_TOOLS/$CMD_TOOLS_DIR_NAME 83 | cd $SDK_DIR_NAME/$CMD_TOOLS 84 | mkdir -p $CMD_TOOLS_DIR_NAME 85 | mv `ls | grep -w -v $CMD_TOOLS_DIR_NAME` $CMD_TOOLS_DIR_NAME 86 | fi 87 | 88 | if [ "$DOWNLOAD_ANDROID_APIS" == "1" ] 89 | then 90 | echo "Exporting ANDROID_HOME" 91 | export ANDROID_HOME=$DOWNLOAD_DIR/$SDK_DIR_NAME 92 | SDK_MANAGER=$ANDROID_HOME/$CMD_TOOLS/$CMD_TOOLS_DIR_NAME/bin/sdkmanager 93 | echo "Downloading Android Platforms" 94 | for api in ${SETUP_ANDROID_APIS[@]} 95 | do 96 | echo yes | $SDK_MANAGER "platforms;android-$api" 97 | done 98 | 99 | echo "Downloading Android Platform-Tools" 100 | echo yes | $SDK_MANAGER "platform-tools" 101 | echo "Exporting TOOLS & PLATFORM_TOOLS" 102 | export PATH=$ANDROID_HOME/platform-tools/:$ANDROID_HOME/tools:$PATH 103 | 104 | echo "Downloading Android Build-Tools" 105 | echo yes | $SDK_MANAGER "build-tools;$ANDROID_BUILD_TOOLS" 106 | fi 107 | 108 | if [ "$DOWNLOAD_PJSIP" == "1" ] 109 | then 110 | echo "" 111 | echo "Downloading PJSIP ${PJSIP_VERSION} ..." 112 | echo "" 113 | cd $DOWNLOAD_DIR 114 | pjsipFile="pjsip.tar.gz" 115 | curl -L -# -o $pjsipFile "$PJSIP_DOWNLOAD_URL" 2>&1 116 | rm -rf "$PJSIP_DIR_NAME" 117 | echo "PJSIP downloaded!" 118 | echo "Extracting PJSIP ..." 119 | tar xzf $pjsipFile && rm -rf $pjsipFile 120 | 121 | PATCH_DIR=$BASEDIR/patches 122 | 123 | # Fixed Call-ID PATCH 124 | if [ "${USE_FIXED_CALLID}" == "1" ] 125 | then 126 | echo "" 127 | echo "" 128 | echo "######################################################################" 129 | echo "Apply patch to use a fixed Call-ID in registration ..." 130 | echo "######################################################################" 131 | echo "" 132 | cd $PATCH_DIR/fixed_callid 133 | ./patch.sh 134 | cd $BASEDIR 135 | fi 136 | 137 | # Rtcp-FB-Event data to pjsua2 PATCH 138 | if [ "${EXPORT_RTCP_FB_DATA}" == "1" ] 139 | then 140 | echo "" 141 | echo "" 142 | echo "######################################################################" 143 | echo "Apply patch to export RTCP-FB Event data to pjsua2 ..." 144 | echo "######################################################################" 145 | echo "" 146 | cd $PATCH_DIR/export_rtcp_fb 147 | ./patch.sh 148 | cd $BASEDIR 149 | fi 150 | 151 | # Fix missing contact header PATCH 152 | if [ "${FIX_MISSING_CONTACT_HEADER}" == "1" ] 153 | then 154 | echo "" 155 | echo "" 156 | echo "######################################################################" 157 | echo "Apply patch to fix missing contact header ..." 158 | echo "######################################################################" 159 | echo "" 160 | cd $PATCH_DIR/fix_missing_contact_header_on_incall_ip_change 161 | ./patch.sh 162 | cd $BASEDIR 163 | fi 164 | fi 165 | 166 | if [ "$DOWNLOAD_SWIG" == "1" ] 167 | then 168 | echo "" 169 | echo "Downloading SWIG ${SWIG_VERSION} ..." 170 | echo "" 171 | cd $DOWNLOAD_DIR 172 | curl -L -# -o swig.tar.gz "$SWIG_DOWNLOAD_URL" 2>&1 173 | rm -rf "$SWIG_DIR_NAME" 174 | echo "SWIG downloaded!" 175 | echo "Extracting SWIG ..." 176 | tar xzf swig.tar.gz && rm -rf swig.tar.gz 177 | cd "$SWIG_DIR_NAME" 178 | mkdir -p $SWIG_BUILD_OUT_PATH 179 | echo "Configuring SWIG ..." 180 | ./configure >> "$SWIG_BUILD_OUT_PATH/swig.log" 2>&1 181 | echo "Compiling SWIG ..." 182 | make >> "$SWIG_BUILD_OUT_PATH/swig.log" 2>&1 183 | echo "Installing SWIG ..." 184 | make install >> "$SWIG_BUILD_OUT_PATH/swig.log" 2>&1 185 | cd .. 186 | rm -rf "$SWIG_DIR_NAME" 187 | fi 188 | 189 | if [ "$DOWNLOAD_OPENSSL" == "1" ] 190 | then 191 | echo "" 192 | echo "Downloading OpenSSL ${OPENSSL_VERSION} ..." 193 | echo "" 194 | 195 | cd $DOWNLOAD_DIR 196 | curl -L -# -o openssl.tar.gz "$OPENSSL_DOWNLOAD_URL" 2>&1 197 | rm -rf "$OPENSSL_DIR_NAME" 198 | echo "OpenSSL downloaded!" 199 | echo "Extracting OpenSSL ..." 200 | tar xzf openssl.tar.gz && rm -rf openssl.tar.gz 201 | cd "${BASEDIR}" 202 | ./openssl-build-target-archs 203 | fi 204 | 205 | if [ "$DOWNLOAD_OPENH264" == "1" ] 206 | then 207 | echo "" 208 | echo "Downloading OpenH264 ${OPENH264_VERSION} ..." 209 | echo "" 210 | cd $DOWNLOAD_DIR 211 | curl -L -# -o openh264.tar.gz "$OPENH264_DOWNLOAD_URL" 2>&1 212 | rm -rf "${OPENH264_DIR_NAME}" 213 | echo "OpenH264 downloaded!" 214 | echo "Extracting OpenH264 ..." 215 | tar xzf openh264.tar.gz && rm -rf openh264.tar.gz 216 | 217 | if [ "$SKIP_OPENH264_DEMO" == "1" ] 218 | then 219 | echo "Modifying platform-android.mk to skip Encdemo and Decdemo builds" 220 | sed -e "/binaries: decdemo encdemo/ s/^#*/#/" -i ${OPENH264_DIR_NAME}/build/platform-android.mk 221 | fi 222 | cd ${BASEDIR} 223 | ./openh264-build-target-archs || true 224 | fi 225 | 226 | if [ "$DOWNLOAD_OPUS" == "1" ] 227 | then 228 | echo "" 229 | echo "Downloading Opus ${OPUS_VERSION} ..." 230 | echo "" 231 | cd "$DOWNLOAD_DIR" 232 | curl -L -# -o opus.tar.gz "$OPUS_DOWNLOAD_URL" 2>&1 233 | rm -rf "${OPUS_DIR_NAME}" 234 | echo "Opus downloaded!" 235 | echo "Extracting Opus ..." 236 | tar xzf opus.tar.gz && rm -rf opus.tar.gz 237 | cd ${BASEDIR} 238 | ./opus-build || true 239 | fi 240 | 241 | if [ "${DOWNLOAD_BCG729}" == "1" ] 242 | then 243 | echo "" 244 | echo "Downloading bcg729 $BCG729_VERSION ..." 245 | echo "" 246 | cd "$DOWNLOAD_DIR" 247 | rm -rf "${BCG729_DIR_NAME}" 248 | mkdir $BCG729_DIR_NAME 249 | git clone -b $BCG729_VERSION $BCG729_DOWNLOAD_URL $BCG729_DIR_NAME 250 | echo "bcg729 downloaded!" 251 | cd ${BASEDIR} 252 | ./bcg729-build || true 253 | fi 254 | 255 | echo "" 256 | echo "The build system is ready! Execute: ./build to build PJSIP" 257 | --------------------------------------------------------------------------------