Skip to content

Commit

Permalink
Merge pull request nesterenkodm#40 from cbanta/master
Browse files Browse the repository at this point in the history
Add OPUS Support
  • Loading branch information
chebur authored Oct 6, 2016
2 parents 27dc7a9 + 01db373 commit 3a3e380
Show file tree
Hide file tree
Showing 27 changed files with 255 additions and 23 deletions.
19 changes: 18 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ function openssl() {
pushd . > /dev/null
cd ${OPENSSL_DIR}
/bin/sh ${OPENSSL_SH}
mv include include2
mkdir -p include
mv include2 include/openssl
popd > /dev/null
else
echo "Using OpenSSL..."
Expand All @@ -49,11 +52,25 @@ function openh264() {
OPENH264_ENABLED=1
}

# opus
OPUS_DIR="${BUILD_DIR}/opus"
OPUS_ENABLED=
function opus() {
if [ ! -f "${OPUS_DIR}/dependencies/lib/libopus.a" ] || [ ! -d "${OPUS_DIR}/dependencies/include/opus/" ]; then
"${__DIR__}/opus.sh" "${OPUS_DIR}"
else
echo "Using OPUS..."
fi

OPUS_ENABLED=1
}

PJSIP_DIR="${BUILD_DIR}/pjproject"
function pjsip() {
"${__DIR__}/pjsip.sh" "${PJSIP_DIR}" --with-openssl "${OPENSSL_DIR}" --with-openh264 "${OPENH264_DIR}"
"${__DIR__}/pjsip.sh" "${PJSIP_DIR}" --with-openssl "${OPENSSL_DIR}" --with-openh264 "${OPENH264_DIR}" --with-opus "${OPUS_DIR}/dependencies"
}

openssl
openh264
opus
pjsip
Binary file modified build/openh264/lib/libopenh264.a
Binary file not shown.
Binary file added build/opus/dependencies/lib/libopus.a
Binary file not shown.
Binary file not shown.
Binary file modified build/pjproject/src/pjlib/lib/libpj-apple-darwin_ios.a
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@

/* OPUS codec */
#ifndef PJMEDIA_HAS_OPUS_CODEC
#define PJMEDIA_HAS_OPUS_CODEC 0
#define PJMEDIA_HAS_OPUS_CODEC 1
#endif

#endif /* __PJMEDIA_CODEC_CONFIG_AUTO_H_ */
Expand Down
Binary file modified build/pjproject/src/pjmedia/lib/libpjmedia-apple-darwin_ios.a
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified build/pjproject/src/pjmedia/lib/libpjsdp-apple-darwin_ios.a
Binary file not shown.
Binary file modified build/pjproject/src/pjnath/lib/libpjnath-apple-darwin_ios.a
Binary file not shown.
Binary file modified build/pjproject/src/pjsip/lib/libpjsip-apple-darwin_ios.a
Binary file not shown.
Binary file modified build/pjproject/src/pjsip/lib/libpjsip-simple-apple-darwin_ios.a
Binary file not shown.
Binary file modified build/pjproject/src/pjsip/lib/libpjsip-ua-apple-darwin_ios.a
Binary file not shown.
Binary file modified build/pjproject/src/pjsip/lib/libpjsua-apple-darwin_ios.a
Binary file not shown.
Binary file modified build/pjproject/src/pjsip/lib/libpjsua2-apple-darwin_ios.a
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified build/pjproject/src/third_party/lib/libilbccodec-apple-darwin_ios.a
Binary file not shown.
Binary file not shown.
Binary file modified build/pjproject/src/third_party/lib/libspeex-apple-darwin_ios.a
Binary file not shown.
Binary file modified build/pjproject/src/third_party/lib/libsrtp-apple-darwin_ios.a
Binary file not shown.
Binary file modified build/pjproject/src/third_party/lib/libyuv-apple-darwin_ios.a
Binary file not shown.
187 changes: 187 additions & 0 deletions opus.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
#!/bin/bash
# Builds libopus for all three current iPhone targets: iPhoneSimulator-i386,
# iPhoneOS-armv6, iPhoneOS-armv7.
#
# Copyright 2012 Mike Tigas <[email protected]>
#
# Based on work by Felix Schulze on 16.12.10.
# Copyright 2010 Felix Schulze. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
###########################################################################
# Choose your libopus version and your currently-installed iOS SDK version:
#
VERSION="1.1.3"
SDKVERSION="10.0"
MINIOSVERSION="8.0"

###########################################################################
#
# Don't change anything under this line!
#
###########################################################################

# by default, we won't build for debugging purposes
if [ "${DEBUG}" == "true" ]; then
echo "Compiling for debugging ..."
OPT_CFLAGS="-O0 -fno-inline -g"
OPT_LDFLAGS=""
OPT_CONFIG_ARGS="--enable-assertions --disable-asm"
else
OPT_CFLAGS="-Ofast -flto -g"
OPT_LDFLAGS="-flto"
OPT_CONFIG_ARGS=""
fi


# No need to change this since xcode build will only compile in the
# necessary bits from the libraries we create
ARCHS="armv7 armv7s arm64 i386 x86_64"

DEVELOPER=`xcode-select -print-path`
#DEVELOPER="/Applications/Xcode.app/Contents/Developer"

# cd "`dirname \"$0\"`"
# REPOROOT=$(pwd)
REPOROOT=$(python -c "import os,sys; print os.path.realpath(sys.argv[1])" "$1")

# Where we'll end up storing things in the end
OUTPUTDIR="${REPOROOT}/dependencies"
mkdir -p "${OUTPUTDIR}/include"
mkdir -p "${OUTPUTDIR}/lib"


BUILDDIR="${REPOROOT}/build"

# where we will keep our sources and build from.
SRCDIR="${BUILDDIR}/src"
mkdir -p $SRCDIR
# where we will store intermediary builds
INTERDIR="${BUILDDIR}/built"
mkdir -p $INTERDIR

########################################

cd $SRCDIR

# Exit the script if an error happens
set -e

if [ ! -e "${SRCDIR}/opus-${VERSION}.tar.gz" ]; then
echo "Downloading opus-${VERSION}.tar.gz"
curl -LO http://downloads.xiph.org/releases/opus/opus-${VERSION}.tar.gz
fi
echo "Using opus-${VERSION}.tar.gz"

tar zxf opus-${VERSION}.tar.gz
cd "${SRCDIR}/opus-${VERSION}"

set +e # don't bail out of bash script if ccache doesn't exist
CCACHE=`which ccache`
if [ $? == "0" ]; then
echo "Building with ccache: $CCACHE"
CCACHE="${CCACHE} "
else
echo "Building without ccache"
CCACHE=""
fi
set -e # back to regular "bail out on error" mode

export ORIGINALPATH=$PATH

for ARCH in ${ARCHS}
do
echo "** Compiling ${ARCH}"
if [ "${ARCH}" == "i386" ] || [ "${ARCH}" == "x86_64" ]; then
PLATFORM="iPhoneSimulator"
EXTRA_FLAGS="--with-pic"
EXTRA_CFLAGS="-arch ${ARCH}"
EXTRA_CONFIG="--host=${ARCH}-apple-darwin"
else
PLATFORM="iPhoneOS"
EXTRA_CFLAGS="-arch ${ARCH}"
EXTRA_CONFIG="--host=arm-apple-darwin"
fi

mkdir -p "${INTERDIR}/${PLATFORM}${SDKVERSION}-${ARCH}.sdk"

./configure \
--enable-float-approx --disable-shared --enable-static \
--with-pic --disable-extra-programs --disable-doc ${EXTRA_CONFIG} \
--prefix="${INTERDIR}/${PLATFORM}${SDKVERSION}-${ARCH}.sdk" \
$EXTRA_CONFIG \
LDFLAGS="$LDFLAGS ${OPT_LDFLAGS} -fPIE -miphoneos-version-min=${MINIOSVERSION} -L${OUTPUTDIR}/lib" \
CFLAGS="$CFLAGS ${EXTRA_CFLAGS} ${OPT_CFLAGS} -fPIE -miphoneos-version-min=${MINIOSVERSION} -I${OUTPUTDIR}/include -isysroot ${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer/SDKs/${PLATFORM}${SDKVERSION}.sdk" \

# Build the application and install it to the fake SDK intermediary dir
# we have set up. Make sure to clean up afterward because we will re-use
# this source tree to cross-compile other targets.
make -j4
make install
make clean
done

########################################

echo "Build library..."

# These are the libs that comprise libopus.
OUTPUT_LIBS="libopus.a"
for OUTPUT_LIB in ${OUTPUT_LIBS}; do
INPUT_LIBS=""
for ARCH in ${ARCHS}; do
if [ "${ARCH}" == "i386" ] || [ "${ARCH}" == "x86_64" ];
then
PLATFORM="iPhoneSimulator"
else
PLATFORM="iPhoneOS"
fi
INPUT_ARCH_LIB="${INTERDIR}/${PLATFORM}${SDKVERSION}-${ARCH}.sdk/lib/${OUTPUT_LIB}"
if [ -e $INPUT_ARCH_LIB ]; then
INPUT_LIBS="${INPUT_LIBS} ${INPUT_ARCH_LIB}"
fi
done
# Combine the three architectures into a universal library.
if [ -n "$INPUT_LIBS" ]; then
echo "** lipo libs"
lipo -create $INPUT_LIBS \
-output "${OUTPUTDIR}/lib/${OUTPUT_LIB}"
else
echo "$OUTPUT_LIB does not exist, skipping (are the dependencies installed?)"
fi
done

for ARCH in ${ARCHS}; do
if [ "${ARCH}" == "i386" ] || [ "${ARCH}" == "x86_64" ];
then
PLATFORM="iPhoneSimulator"
else
PLATFORM="iPhoneOS"
fi
cp -R ${INTERDIR}/${PLATFORM}${SDKVERSION}-${ARCH}.sdk/include/* ${OUTPUTDIR}/include/
if [ $? == "0" ]; then
# We only need to copy the headers over once. (So break out of forloop
# once we get first success.)
break
fi
done


####################

echo "Building done."
echo "Cleaning up..."
rm -fr ${INTERDIR}
rm -fr "${SRCDIR}/opus-${VERSION}"
echo "Done."
50 changes: 32 additions & 18 deletions pjsip.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "pjsip"
s.version = "2.5.5.2"
s.version = "2.5.5.3"
s.summary = "Open Source SIP, Media and NAT Traversal Library."
s.homepage = "http://www.pjsip.org"
s.author = 'www.pjsip.org'
Expand All @@ -25,38 +25,52 @@ LICENSE
}

s.source_files =
s.public_header_files = 'build/pjproject/src/pjlib/include/**',
'build/pjproject/src/pjlib-util/include/**',
'build/pjproject/src/pjmedia/include/**',
'build/pjproject/src/pjnath/include/**',
'build/pjproject/src/pjsip/include/**'
s.public_header_files =['build/pjproject/src/pjlib/include/*.h',
'build/pjproject/src/pjlib/include/**/*.h',
'build/pjproject/src/pjlib-util/include/**/*.h',
'build/pjproject/src/pjlib-util/include/*.h',
'build/pjproject/src/pjmedia/include/**/*.h',
'build/pjproject/src/pjmedia/include/*.h',
'build/pjproject/src/pjnath/include/**/*.h',
'build/pjproject/src/pjnath/include/*.h',
'build/pjproject/src/pjsip/include/**/*.h',
'build/pjproject/src/pjsip/include/*.h']

s.preserve_paths = 'build/pjproject/src/pjlib/include/**/*',
s.preserve_paths =['build/pjproject/src/pjlib/include/**/*',
'build/pjproject/src/pjlib/include/*',
'build/pjproject/src/pjlib-util/include/**/*',
'build/pjproject/src/pjlib-util/include/*',
'build/pjproject/src/pjmedia/include/**/*',
'build/pjproject/src/pjmedia/include/*',
'build/pjproject/src/pjnath/include/**/*',
'build/pjproject/src/pjsip/include/**/*'
'build/pjproject/src/pjnath/include/*',
'build/pjproject/src/pjsip/include/**/*',
'build/pjproject/src/pjsip/include/*']

s.vendored_libraries = 'build/openh264/lib/*.a',
s.vendored_libraries =['build/openh264/lib/*.a',
'build/opus/dependencies/lib/*.a',
'build/pjproject/src/pjlib/lib/*.a',
'build/pjproject/src/pjlib-util/lib/*.a',
'build/pjproject/src/pjmedia/lib/*.a',
'build/pjproject/src/pjnath/lib/*.a',
'build/pjproject/src/pjsip/lib/*.a',
'build/pjproject/src/third_party/lib/*.a'
'build/pjproject/src/third_party/lib/*.a']

header_search_paths = '"$(PODS_ROOT)/pjsip/build/pjproject/src/pjlib/include"',
'"$(PODS_ROOT)/pjsip/build/pjproject/src/pjlib-util/include"',
'"$(PODS_ROOT)/pjsip/build/pjproject/src/pjmedia/include"',
'"$(PODS_ROOT)/pjsip/build/pjproject/src/pjnath/include"',
'"$(PODS_ROOT)/pjsip/build/pjproject/src/pjsip/include"'
header_search_paths =['"$(PODS_ROOT)/pjsip/pjlib/include"',
'"$(PODS_ROOT)/pjsip/pjlib-util/include"',
'"$(PODS_ROOT)/pjsip/pjmedia/include"',
'"$(PODS_ROOT)/pjsip/pjnath/include"',
'"$(PODS_ROOT)/pjsip/pjsip/include"']

s.xcconfig = {'HEADER_SEARCH_PATHS' => header_search_paths.join(' '),
'GCC_PREPROCESSOR_DEFINITIONS' => 'PJ_AUTOCONF=1'}
s.xcconfig = {
'HEADER_SEARCH_PATHS' => header_search_paths.join(' '),
'GCC_PREPROCESSOR_DEFINITIONS' => 'PJ_AUTOCONF=1'
}

s.dependency 'OpenSSL-Universal', '1.0.1.19'
s.frameworks = 'CFNetwork', 'AudioToolbox', 'AVFoundation', 'CoreMedia'
s.libraries = 'stdc++'
s.header_mappings_dir = 'build/pjproject'
s.header_mappings_dir = 'build/pjproject/src'
s.requires_arc = false
end

20 changes: 17 additions & 3 deletions pjsip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ LIB_PATHS=("pjlib/lib" \

OPENSSL_PREFIX=
OPENH264_PREFIX=
OPUS_PREFIX=
while [ "$#" -gt 0 ]; do
case $1 in
--with-openssl)
if [ "$#" -gt 1 ]; then
OPENSSL_PREFIX=$2
OPENSSL_PREFIX=$(python -c "import os,sys; print os.path.realpath(sys.argv[1])" "$2")
shift 2
continue
else
Expand All @@ -36,14 +37,24 @@ while [ "$#" -gt 0 ]; do
;;
--with-openh264)
if [ "$#" -gt 1 ]; then
OPENH264_PREFIX=$2
OPENH264_PREFIX=$(python -c "import os,sys; print os.path.realpath(sys.argv[1])" "$2")
shift 2
continue
else
echo 'ERROR: Must specify a non-empty "--with-openh264 PREFIX" argument.' >&2
exit 1
fi
;;
--with-opus)
if [ "$#" -gt 1 ]; then
OPUS_PREFIX=$(python -c "import os,sys; print os.path.realpath(sys.argv[1])" "$2")
shift 2
continue
else
echo 'ERROR: Must specify a non-empty "--with-opus PREFIX" argument.' >&2
exit 1
fi
;;
esac

shift
Expand Down Expand Up @@ -120,6 +131,9 @@ function _build() {
if [[ ${OPENH264_PREFIX} ]]; then
CONFIGURE="${CONFIGURE} --with-openh264=${OPENH264_PREFIX}"
fi
if [[ ${OPUS_PREFIX} ]]; then
CONFIGURE="${CONFIGURE} --with-opus=${OPUS_PREFIX}"
fi

# flags
if [[ ! ${CFLAGS} ]]; then
Expand All @@ -146,7 +160,7 @@ function _build() {
ARCH="-arch ${ARCH}" ${CONFIGURE} >> ${LOG} 2>&1
make dep >> ${LOG} 2>&1
make clean >> ${LOG}
make >> ${LOG} 2>&1
make lib >> ${LOG} 2>&1

copy_libs ${ARCH}
}
Expand Down

0 comments on commit 3a3e380

Please sign in to comment.