Skip to content

Commit 562c730

Browse files
committed
bump openh264 to 2.1.0 compiled with clang (ndk r20b) - #44
to be able to compile v2.1.0 with ndk r20b we need to use the openh264v2.1.0 branch which supports newer ndk versions
1 parent 5b57984 commit 562c730

File tree

3 files changed

+86
-39
lines changed

3 files changed

+86
-39
lines changed

config.conf

+7-3
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,10 @@ OPENSSL_TARGET_NDK_LEVEL=21
110110
###############################################################################
111111

112112
# OPENH264 Version to download
113-
OPENH264_VERSION=1.7.0
113+
OPENH264_VERSION=openh264v2.1.0
114114

115115
# The URL from which to download OpenH264 sources tag
116-
OPENH264_DOWNLOAD_URL="https://github.com/cisco/openh264/archive/v$OPENH264_VERSION.tar.gz"
116+
OPENH264_DOWNLOAD_URL="https://github.com/cisco/openh264/archive/$OPENH264_VERSION.tar.gz"
117117

118118
# The name of the folder generated when untarring OpenH264 sources file
119119
# In general, the name corresponds to that of the tar, except the file extension
@@ -123,7 +123,7 @@ OPENH264_DIR_NAME="openh264-$OPENH264_VERSION"
123123
OPENH264_BUILD_OUT_PATH="$BUILD_DIR/openh264-build-output"
124124

125125
# Configure the target NDK toolchain to use when compiling OpenH264
126-
OPENH264_TARGET_NDK_LEVEL=23
126+
OPENH264_TARGET_NDK_LEVEL=21
127127

128128

129129
###############################################################################
@@ -226,6 +226,10 @@ DOWNLOAD_OPENSSL=1
226226
# Downloads a fresh copy of OpenH264. Any existing files will be deleted
227227
DOWNLOAD_OPENH264=1
228228

229+
# On recent versions of OpenH264 building encdemo and decdemo build fails
230+
# [OpenH264 2.1.x && NDK >= r20b]
231+
SKIP_OPENH264_DEMO=1
232+
229233
# Downloads a fresh copy of Opus. Any existing files will be deleted
230234
DOWNLOAD_OPUS=1
231235

openh264-build-target-archs

+73-36
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,108 @@
11
#!/bin/bash -e
22

3+
set -e
4+
5+
# Source variables from config.conf file
36
. config.conf
47

5-
NDK_PATH="$DOWNLOAD_DIR/${NDK_DIR_NAME}"
6-
SDK_TOOLS_PATH="$DOWNLOAD_DIR/${SDK_DIR_NAME}"/tools
7-
OPENH264_PATH="$DOWNLOAD_DIR/${OPENH264_DIR_NAME}"
8-
LIB_PATH="${OPENH264_BUILD_OUT_PATH}/libs"
9-
LOG_PATH="${OPENH264_BUILD_OUT_PATH}/logs"
10-
TMP_DIR="/tmp/openh264"
118

12-
export PATH=${SDK_TOOLS_PATH}:$PATH
9+
##############################################################################
10+
############################ FUNCTIONS ##############################
11+
##############################################################################
1312

14-
rm -rf "${OPENH264_BUILD_OUT_PATH}"
15-
mkdir -p "${LIB_PATH}"
16-
mkdir -p "${LOG_PATH}"
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+
}
1719

18-
for arch in "${TARGET_ARCHS[@]}"
19-
do
20-
echo "Building OpenH264 for target arch $arch ..."
21-
rm -rf "${TMP_DIR}"
22-
mkdir -p "${TMP_DIR}"
23-
cd ${OPENH264_PATH}
24-
cp -r * ${TMP_DIR}
25-
cd ${TMP_DIR}
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}
2642
mkdir -p "$BUILD_DIR"
2743
mkdir -p "${LIB_PATH}/${arch}"
2844
mkdir -p "${LOG_PATH}"
29-
30-
#change default output DIR for make install
31-
sed -i "s*PREFIX=/usr/local*PREFIX=${LIB_PATH}/${arch}*g" Makefile
32-
33-
ARGS="OS=android NDKROOT=${NDK_PATH} NDKLEVEL=${OPENH264_TARGET_NDK_LEVEL} "
34-
ARGS="${ARGS}TARGET=android-${TARGET_ANDROID_API} ARCH="
35-
45+
}
46+
47+
function finalizeArgs {
48+
arch=$1
3649
if [ "$arch" == "armeabi" ]
3750
then
3851
ARGS="${ARGS}arm APP_ABI=armeabi"
39-
4052
elif [ "$arch" == "armeabi-v7a" ]
4153
then
4254
ARGS="${ARGS}arm"
43-
4455
elif [ "$arch" == "x86" ]
4556
then
4657
ARGS="${ARGS}x86 ENABLEPIC=Yes"
47-
4858
elif [ "$arch" == "x86_64" ]
4959
then
5060
ARGS="${ARGS}x86_64"
51-
5261
elif [ "$arch" == "arm64-v8a" ]
5362
then
5463
ARGS="${ARGS}arm64"
64+
else
65+
echo "Unsupported target ABI: $arch"
66+
exit 1
67+
fi
68+
}
5569

56-
elif [ "$arch" == "mips" ]
57-
then
58-
ARGS="${ARGS}mips"
5970

60-
elif [ "$arch" == "mips64" ]
61-
then
62-
ARGS="${ARGS}mips64"
63-
fi
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
6495

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+
65101
make ${ARGS} >> "${LOG_PATH}/${arch}.log" 2>&1
66102
mkdir -p ${LIB_PATH}/${arch}
67103
make ${ARGS} install >> "${LOG_PATH}/${arch}.log" 2>&1
68104
done
69105

70106
echo "Finished building OpenH264! Check output folder: ${OPENH264_BUILD_OUT_PATH}"
71107

108+
set +e

prepare-build-system

+6
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,12 @@ then
199199
echo "OpenH264 downloaded!"
200200
echo "Extracting OpenH264 ..."
201201
tar xzf openh264.tar.gz && rm -rf openh264.tar.gz
202+
203+
if [ "$SKIP_OPENH264_DEMO" == "1" ]
204+
then
205+
echo "Modifying platform-android.mk to skip Encdemo and Decdemo builds"
206+
sed -e "/binaries: decdemo encdemo/ s/^#*/#/" -i ${OPENH264_DIR_NAME}/build/platform-android.mk
207+
fi
202208
cd ${BASEDIR}
203209
./openh264-build-target-archs || true
204210
fi

0 commit comments

Comments
 (0)