├── .gitignore ├── LICENSE ├── Makefile └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Object files 2 | *.o 3 | *.ko 4 | 5 | # Libraries 6 | *.lib 7 | *.a 8 | 9 | # Shared objects (inc. Windows DLLs) 10 | *.dll 11 | *.so 12 | *.so.* 13 | *.dylib 14 | 15 | # Executables 16 | *.exe 17 | *.out 18 | *.app 19 | 20 | openssl* 21 | re 22 | rem 23 | retest 24 | baresip 25 | opus* 26 | speex* 27 | libzrtp* 28 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013, Alfred E. Heggestad 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, this 11 | list of conditions and the following disclaimer in the documentation and/or 12 | other materials provided with the distribution. 13 | 14 | * Neither the name of the {organization} nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 22 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 25 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile 3 | # 4 | # Copyright (C) 2014 Creytiv.com 5 | # 6 | 7 | # Paths to your Android SDK/NDK 8 | NDK_PATH := $(HOME)/android/android-ndk-r16b 9 | SDK_PATH := $(HOME)/android/android-sdk 10 | 11 | # 12 | # Android API-levels: 13 | # 14 | # API-Level: Version: 15 | # --------- ------- 16 | # 19 4.4 - 4.4.4 17 | # 21 5.0 18 | # 22 5.1.1 19 | # 23 6.0 20 | # 21 | API_LEVEL := 21 22 | PLATFORM := android-$(API_LEVEL) 23 | 24 | 25 | TRIPLE := arm-linux-androideabi 26 | 27 | 28 | # Path to install binaries on your Android-device 29 | TARGET_PATH=/data/local/tmp 30 | 31 | # Config path where .baresip directory is located 32 | CONFIG_PATH=/data/local/tmp 33 | 34 | 35 | OS := $(shell uname -s | tr "[A-Z]" "[a-z]") 36 | 37 | ifeq ($(OS),linux) 38 | HOST_OS := linux-x86_64 39 | endif 40 | ifeq ($(OS),darwin) 41 | HOST_OS := darwin-x86_64 42 | endif 43 | 44 | 45 | # Tools 46 | SYSROOT := $(NDK_PATH)/platforms/$(PLATFORM)/arch-arm 47 | SYSROOT_INC := $(NDK_PATH)/sysroot 48 | 49 | PREBUILT := $(NDK_PATH)/toolchains/arm-linux-androideabi-4.9/prebuilt 50 | BIN := $(PREBUILT)/$(HOST_OS)/bin 51 | CC := $(BIN)/arm-linux-androideabi-gcc 52 | CXX := $(BIN)/arm-linux-androideabi-g++ 53 | RANLIB := $(BIN)/arm-linux-androideabi-ranlib 54 | AR := $(BIN)/arm-linux-androideabi-ar 55 | ADB := $(SDK_PATH)/platform-tools/adb 56 | PWD := $(shell pwd) 57 | 58 | # Compiler and Linker Flags 59 | # 60 | # NOTE: use -isystem to avoid warnings in system header files 61 | CFLAGS := \ 62 | -D__ANDROID_API__=$(API_LEVEL) \ 63 | -isystem $(SYSROOT_INC)/usr/include/ \ 64 | -isystem $(SYSROOT_INC)/usr/include/$(TRIPLE) \ 65 | -I$(PWD)/openssl/include \ 66 | -I$(PWD)/opus/include_opus \ 67 | -I$(PWD)/libzrtp/include \ 68 | -I$(PWD)/libzrtp/third_party/bnlib \ 69 | -I$(PWD)/libzrtp/third_party/bgaes \ 70 | -march=armv7-a \ 71 | -fPIE -fPIC \ 72 | -DCONFIG_PATH='\"$(CONFIG_PATH)\"' 73 | LFLAGS := -L$(SYSROOT)/usr/lib/ \ 74 | -L$(PWD)/openssl \ 75 | -L$(PWD)/opus/.libs \ 76 | -L$(PWD)/libzrtp \ 77 | -L$(PWD)/libzrtp/third_party/bnlib \ 78 | -fPIE -pie 79 | LFLAGS += --sysroot=$(NDK_PATH)/platforms/$(PLATFORM)/arch-arm 80 | 81 | 82 | COMMON_FLAGS := CC=$(CC) \ 83 | CXX=$(CXX) \ 84 | RANLIB=$(RANLIB) \ 85 | AR=$(AR) \ 86 | EXTRA_CFLAGS="$(CFLAGS) -DANDROID $(EXTRA_CFLAGS)" \ 87 | EXTRA_CXXFLAGS="$(CFLAGS) -DANDROID" \ 88 | EXTRA_LFLAGS="$(LFLAGS)" \ 89 | SYSROOT=$(SYSROOT_INC)/usr \ 90 | SYSROOT_ALT=$(SYSROOT)/usr \ 91 | SHARE_PATH="$(TARGET_PATH)/share" \ 92 | HAVE_LIBRESOLV= \ 93 | HAVE_RESOLV= \ 94 | HAVE_PTHREAD=1 \ 95 | HAVE_PTHREAD_RWLOCK=1 \ 96 | HAVE_LIBPTHREAD= \ 97 | HAVE_INET_PTON=1 \ 98 | HAVE_INET6=1 \ 99 | HAVE_GETIFADDRS= \ 100 | PEDANTIC= \ 101 | OS=linux ARCH=arm \ 102 | USE_OPENSSL=yes \ 103 | USE_OPENSSL_DTLS=yes \ 104 | USE_OPENSSL_SRTP=yes \ 105 | ANDROID=yes 106 | 107 | EXTRA_MODULES := g711 stdio opensles dtls_srtp echo aubridge 108 | 109 | ifneq ("$(wildcard $(PWD)/opus)","") 110 | EXTRA_MODULES := $(EXTRA_MODULES) opus 111 | endif 112 | 113 | ifneq ("$(wildcard $(PWD)/libzrtp)","") 114 | EXTRA_MODULES := $(EXTRA_MODULES) zrtp 115 | endif 116 | 117 | default: baresip 118 | 119 | libre.a: Makefile 120 | @rm -f re/libre.* 121 | @make $@ -C re $(COMMON_FLAGS) 122 | 123 | librem.a: Makefile libre.a 124 | @rm -f rem/librem.* 125 | @make $@ -C rem $(COMMON_FLAGS) 126 | 127 | libbaresip.a: Makefile librem.a libre.a 128 | @rm -f baresip/baresip baresip/src/static.c 129 | PKG_CONFIG_LIBDIR="$(SYSROOT)/usr/lib/pkgconfig" \ 130 | make $@ -C baresip $(COMMON_FLAGS) STATIC=1 \ 131 | LIBRE_SO=$(PWD)/re LIBREM_PATH=$(PWD)/rem \ 132 | MOD_AUTODETECT= \ 133 | EXTRA_MODULES="$(EXTRA_MODULES)" 134 | 135 | .PHONY: baresip 136 | baresip: Makefile librem.a libre.a 137 | @rm -f baresip/baresip baresip/src/static.c 138 | PKG_CONFIG_LIBDIR="$(SYSROOT)/usr/lib/pkgconfig" \ 139 | make $@ -C baresip $(COMMON_FLAGS) STATIC=1 \ 140 | LIBRE_SO=$(PWD)/re LIBREM_PATH=$(PWD)/rem \ 141 | MOD_AUTODETECT= \ 142 | EXTRA_MODULES="$(EXTRA_MODULES)" 143 | 144 | .PHONY: selftest 145 | selftest: Makefile librem.a libre.a 146 | @rm -f baresip/selftest baresip/src/static.c 147 | PKG_CONFIG_LIBDIR="$(SYSROOT)/usr/lib/pkgconfig" \ 148 | make selftest -C baresip $(COMMON_FLAGS) STATIC=1 \ 149 | LIBRE_SO=$(PWD)/re LIBREM_PATH=$(PWD)/rem \ 150 | MOD_AUTODETECT= 151 | $(ADB) push baresip/selftest $(TARGET_PATH)/selftest 152 | $(ADB) shell "cd $(TARGET_PATH) && ./selftest " 153 | 154 | 155 | install: baresip 156 | $(ADB) push baresip/baresip $(TARGET_PATH)/baresip 157 | 158 | config: 159 | $(ADB) push .baresip $(TARGET_PATH)/ 160 | $(ADB) push baresip/share $(TARGET_PATH)/share 161 | 162 | clean: 163 | make distclean -C baresip 164 | make distclean -C retest 165 | make distclean -C rem 166 | make distclean -C re 167 | 168 | 169 | OPENSSL_FLAGS := \ 170 | threads \ 171 | -D__ANDROID_API__=$(API_LEVEL) \ 172 | -isystem$(SYSROOT_INC)/usr/include \ 173 | -isystem$(SYSROOT_INC)/usr/include/$(TRIPLE) \ 174 | -fPIE -fPIC -pie \ 175 | \ 176 | no-async \ 177 | no-bf \ 178 | no-blake2 \ 179 | no-camellia \ 180 | no-capieng \ 181 | no-cast \ 182 | no-comp \ 183 | no-dso \ 184 | no-engine \ 185 | no-gost \ 186 | no-heartbeats \ 187 | no-idea \ 188 | no-md2 \ 189 | no-md4 \ 190 | no-mdc2 \ 191 | no-psk \ 192 | no-rc2 \ 193 | no-rc4 \ 194 | no-rc5 \ 195 | no-sctp \ 196 | no-seed \ 197 | no-shared \ 198 | no-srp \ 199 | no-ssl3 200 | 201 | 202 | .PHONY: openssl 203 | openssl: 204 | cd openssl && \ 205 | CC=$(CC) RANLIB=$(RANLIB) AR=$(AR) \ 206 | ./Configure android $(OPENSSL_FLAGS) && \ 207 | ANDROID_DEV=$(SYSROOT)/usr \ 208 | CROSS_SYSROOT="$(SYSROOT)" \ 209 | make build_libs 210 | 211 | .PHONY: opus 212 | opus: 213 | cd opus && \ 214 | rm -rf include_opus && \ 215 | CC="$(CC) --sysroot $(SYSROOT)" \ 216 | RANLIB="$(RANLIB)" AR="$(AR)" PATH="$(BIN):$(PATH)" \ 217 | ./configure --host=arm-linux-androideabi --disable-shared \ 218 | --disable-doc \ 219 | --disable-extra-programs \ 220 | CFLAGS="$(CFLAGS)" && \ 221 | CC="$(CC) --sysroot $(SYSROOT)" \ 222 | RANLIB="$(RANLIB)" AR="$(AR)" PATH="$(BIN):$(PATH)" \ 223 | make && \ 224 | mkdir include_opus && \ 225 | mkdir include_opus/opus && \ 226 | cp include/* include_opus/opus 227 | 228 | .PHONY: zrtp 229 | zrtp: 230 | cd libzrtp && \ 231 | ./bootstrap.sh && \ 232 | CC="$(CC) --sysroot $(SYSROOT)" \ 233 | RANLIB="$(RANLIB)" AR="$(AR)" PATH="$(BIN):$(PATH)" \ 234 | ./configure --host=arm-linux-androideabi CFLAGS="$(CFLAGS)" && \ 235 | cd third_party/bnlib/ && \ 236 | CC="$(CC) --sysroot $(SYSROOT)" \ 237 | RANLIB="$(RANLIB)" AR="$(AR)" PATH="$(BIN):$(PATH)" \ 238 | ./configure --host=arm-linux-androideabi CFLAGS="$(CFLAGS)" && \ 239 | cd ../.. && \ 240 | CC="$(CC) --sysroot $(SYSROOT)" \ 241 | RANLIB="$(RANLIB)" AR="$(AR)" PATH="$(BIN):$(PATH)" \ 242 | make 243 | 244 | emulator: 245 | @$(SDK_PATH)/tools/emulator -avd test 246 | 247 | shell: 248 | @$(ADB) shell 249 | 250 | info: 251 | make $@ -C re $(COMMON_FLAGS) 252 | 253 | dump: 254 | @echo "NDK_PATH = $(NDK_PATH)" 255 | @echo "SDK_PATH = $(SDK_PATH)" 256 | @echo "HOST_OS = $(HOST_OS)" 257 | 258 | # 259 | # additional targets for `retest' 260 | # 261 | 262 | test: retest 263 | .PHONY: retest 264 | retest: Makefile librem.a libre.a 265 | @rm -f retest/retest 266 | @make $@ -C retest $(COMMON_FLAGS) LIBRE_SO=$(PWD)/re \ 267 | LIBREM_PATH=$(PWD)/rem 268 | $(ADB) push retest/retest $(TARGET_PATH)/retest 269 | $(ADB) push retest/data/. $(TARGET_PATH)/data 270 | $(ADB) shell "cd $(TARGET_PATH) && ./retest -r -v" 271 | 272 | 273 | .PHONY: toolchain 274 | toolchain: 275 | $(NDK_PATH)/build/tools/make_standalone_toolchain.py \ 276 | --arch arm \ 277 | --api $(API_LEVEL) \ 278 | --install-dir $(PWD)/toolchain 279 | 280 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | baresip-android 2 | =============== 3 | 4 | Baresip for Android 5 | 6 | 7 | This project shows how to build baresip for Android NDK. 8 | Baresip is a modular SIP-client with audio/video support 9 | that supports many target platforms. Baresip can be used 10 | as a standalone console application, or as a powerful 11 | toolkit (libbaresip) for 3rd-party applications. 12 | 13 | 14 | ## Supported NDKs 15 | 16 | | NDK: | Supported: | 17 | |------|------------| 18 | | r18 | No | 19 | | r17 | Yes | 20 | | r16 | Yes | 21 | | r15 | Yes | 22 | | r14 | Yes | 23 | | r13 | No | 24 | 25 | 26 | 27 | ## Step 1 - download source code 28 | 29 | Download baresip/librem/libre source from creytiv.com [1] 30 | 31 | ``` 32 | $ wget http://www.creytiv.com/pub/baresip-0.5.9.tar.gz 33 | $ wget http://www.creytiv.com/pub/rem-0.5.3.tar.gz 34 | $ wget http://www.creytiv.com/pub/re-0.5.8.tar.gz 35 | $ wget http://www.creytiv.com/pub/retest-0.5.2.tar.gz 36 | 37 | $ # .. and download OpenSSL source from openssl.org [2] 38 | $ wget https://www.openssl.org/source/openssl-1.1.0h.tar.gz 39 | 40 | $ # .. and download Opus source from opus.org [5] (optional) 41 | $ wget http://downloads.xiph.org/releases/opus/opus-1.1.3.tar.gz 42 | 43 | $ # .. and download ZRTP source from github.com [7] (optional) 44 | $ wget https://github.com/juha-h/libzrtp/archive/master.zip 45 | 46 | $ # .. download Android NDK from [3] 47 | ``` 48 | 49 | 50 | 51 | ## Step 2 - unpack source code 52 | 53 | unpack the source code in the current directory, or create 54 | symlinks to the source code so that you have a layout like this: 55 | 56 | baresip/ 57 | openssl/ 58 | opus/ (optional) 59 | libzrtp/ (optional) 60 | re/ 61 | rem/ 62 | 63 | 64 | 65 | ## Step 3 - build openssl 66 | 67 | libre depends on openssl for crypto and TLS. 68 | 69 | ``` 70 | $ make openssl 71 | ``` 72 | 73 | 74 | 75 | ## Step 4 - build opus, zrtp (optional) 76 | 77 | ``` 78 | $ make opus 79 | $ make zrtp 80 | ``` 81 | 82 | 83 | 84 | ## Step 5 - build baresip + libs 85 | 86 | baresip depends on librem and libre. 87 | 88 | ``` 89 | $ make baresip 90 | ``` 91 | 92 | this will create a statically linked binary in baresip/baresip 93 | 94 | 95 | 96 | 97 | ## Step 6 - install baresip in Emulator or target 98 | 99 | ``` 100 | $ make install 101 | ``` 102 | 103 | this will use adb to install baresip in your configured Android emulator. 104 | you can also copy the binary to an Android device using ssh. 105 | 106 | 107 | ## Run test program on Android target 108 | 109 | ``` 110 | $ make test 111 | ``` 112 | 113 | this will compile retest and install it on your configured 114 | Android device, and then run the whole test program. 115 | 116 | 117 | 118 | ## Support 119 | 120 | if you have questions or issues you are welcome to join our 121 | mailing-list [4] and contribute patches here :) 122 | 123 | 124 | 125 | 126 | ## References: 127 | 128 | - [1] www.creytiv.com 129 | - [2] www.openssl.org 130 | - [3] http://developer.android.com/tools/sdk/ndk/index.html 131 | - [4] http://lists.creytiv.com/mailman/listinfo/re-devel 132 | - [5] http://opus-codec.org 133 | - [7] https://github.com/juha-h/libzrtp 134 | --------------------------------------------------------------------------------