Skip to content

Commit

Permalink
fix ossrs#155, #135, support osx(darwin) for mac pro. 2.0.137.
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Mar 10, 2015
1 parent 20fb5f3 commit db7ddfd
Show file tree
Hide file tree
Showing 16 changed files with 1,072 additions and 49 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ flv/ts/mp3/aac streaming for user prefered.
1. Multiple feature: transcode, forward, ingest, http hooks, dvr, hls, rtsp, http streaming,
http api, refer, log, bandwith test and srs-librtmp.
1. Best maintainess: simple arch over state-threads(coroutine), single thread, single process
and only linux platform, common server x86-64/i386/arm/mips cpus, rich comments, strictly
and for linux/osx platform, common server x86-64/i386/arm/mips cpus, rich comments, strictly
follows RTMP/HLS/RTSP spec.
1. Easy to use: both English and Chinese wiki, typically config files in trunk/conf, traceable
and session based log, linux service script and install script.
Expand All @@ -37,7 +37,7 @@ Enjoy it!

SRS(SIMPLE RTMP Server) over state-threads created in 2013.10.

SRS delivers rtmp/hls/http live on x86/x64/arm/mips linux,
SRS delivers rtmp/hls/http live on x86/x64/arm/mips linux/osx,
supports origin/edge/vhost and transcode/ingest and dvr/forward
and http-api/http-callback/reload, introduces tracable
session-oriented log, exports client srs-librtmp,
Expand Down Expand Up @@ -550,6 +550,7 @@ Supported operating systems and hardware:

### SRS 2.0 history

* v2.0, 2015-03-10, fix [#155](https://github.com/winlinvip/simple-rtmp-server/issues/155), support osx(darwin) for mac pro. 2.0.137.
* v2.0, 2015-03-08, fix [#316](https://github.com/winlinvip/simple-rtmp-server/issues/316), http api provides stream/vhost/srs/server bytes, codec and count. 2.0.136.
* v2.0, 2015-03-08, fix [#310](https://github.com/winlinvip/simple-rtmp-server/issues/310), refine aac LC, support aac HE/HEv2. 2.0.134.
* v2.0, 2015-03-06, for [#322](https://github.com/winlinvip/simple-rtmp-server/issues/322), fix http-flv stream bug, support multiple streams. 2.0.133.
Expand Down
17 changes: 17 additions & 0 deletions trunk/3rdparty/patches/2.http.parser.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
diff -r -c ./Makefile ../http-parser-2.1/Makefile
*** ./Makefile Tue Mar 10 10:44:19 2015
--- ../http-parser-2.1/Makefile Wed Mar 27 06:35:20 2013
***************
*** 12,22 ****
CFLAGS_FAST = $(CFLAGS) -O3 $(CFLAGS_FAST_EXTRA)
CFLAGS_LIB = $(CFLAGS_FAST) -fPIC

- # patch by winlin
- CPPFLAGS_FAST = $(CPPFLAGS_DEBUG)
- CFLAGS_FAST = $(CFLAGS_DEBUG)
- CFLAGS_LIB = $(CFLAGS_FAST) -fPIC
-
test: test_g test_fast
./test_g
./test_fast
--- 12,17 ----
22 changes: 21 additions & 1 deletion trunk/auto/auto_headers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,28 @@ echo "#define SRS_AUTO_BUILD_DATE \"`date \"+%Y-%m-%d %H:%M:%S\"`\"" >> $SRS_AUT
echo "#define SRS_AUTO_UNAME \"`uname -a`\"" >> $SRS_AUTO_HEADERS_H
echo "#define SRS_AUTO_USER_CONFIGURE \"${SRS_AUTO_USER_CONFIGURE}\"" >> $SRS_AUTO_HEADERS_H
echo "#define SRS_AUTO_CONFIGURE \"${SRS_AUTO_CONFIGURE}\"" >> $SRS_AUTO_HEADERS_H
echo "" >> $SRS_AUTO_HEADERS_H

# export the preset.
if [ $SRS_OSX = YES ]; then
echo "#define SRS_OSX" >> $SRS_AUTO_HEADERS_H
fi
if [ $SRS_X86_X64 = YES ]; then
echo "#define SRS_X86_X64" >> $SRS_AUTO_HEADERS_H
fi
if [ $SRS_ARM_UBUNTU12 = YES ]; then
echo "#define SRS_ARM_UBUNTU12" >> $SRS_AUTO_HEADERS_H
fi
if [ $SRS_MIPS_UBUNTU12 = YES ]; then
echo "#define SRS_MIPS_UBUNTU12" >> $SRS_AUTO_HEADERS_H
fi
if [ $SRS_PI = YES ]; then
echo "#define SRS_PI" >> $SRS_AUTO_HEADERS_H
fi
if [ $SRS_CUBIE = YES ]; then
echo "#define SRS_CUBIE" >> $SRS_AUTO_HEADERS_H
fi

# new empty line to auto headers file.
echo "" >> $SRS_AUTO_HEADERS_H

#####################################################################################
Expand Down
195 changes: 163 additions & 32 deletions trunk/auto/depends.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,24 @@ function Ubuntu_prepare()
return 0;
fi
fi

# for arm, install the cross build tool chain.
if [ $SRS_ARM_UBUNTU12 = YES ]; then
$SrsArmCC --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
echo "install gcc-arm-linux-gnueabi g++-arm-linux-gnueabi"
require_sudoer "sudo apt-get install -y --force-yes gcc-arm-linux-gnueabi g++-arm-linux-gnueabi"
sudo apt-get install -y --force-yes gcc-arm-linux-gnueabi g++-arm-linux-gnueabi; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "install gcc-arm-linux-gnueabi g++-arm-linux-gnueabi success"
fi
fi

# for mips, user must installed the tool chain.
if [ $SRS_MIPS_UBUNTU12 = YES ]; then
$SrsArmCC --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
echo "user must install the tool chain: $SrsArmCC"
return 2
fi
fi

OS_IS_UBUNTU=YES
echo "Ubuntu detected, install tools if needed"
Expand Down Expand Up @@ -110,24 +128,6 @@ function Ubuntu_prepare()
fi
fi

# for arm, install the cross build tool chain.
if [ $SRS_ARM_UBUNTU12 = YES ]; then
$SrsArmCC --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
echo "install gcc-arm-linux-gnueabi g++-arm-linux-gnueabi"
require_sudoer "sudo apt-get install -y --force-yes gcc-arm-linux-gnueabi g++-arm-linux-gnueabi"
sudo apt-get install -y --force-yes gcc-arm-linux-gnueabi g++-arm-linux-gnueabi; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "install gcc-arm-linux-gnueabi g++-arm-linux-gnueabi success"
fi
fi

# for mips, user must installed the tool chain.
if [ $SRS_MIPS_UBUNTU12 = YES ]; then
$SrsArmCC --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
echo "user must install the tool chain: $SrsArmCC"
return 2
fi
fi

echo "Ubuntu install tools success"
return 0
}
Expand All @@ -144,6 +144,12 @@ function Centos_prepare()
if [[ ! -f /etc/redhat-release ]]; then
return 0;
fi

# for arm, install the cross build tool chain.
if [ $SRS_EMBEDED_CPU = YES ]; then
echo "embeded(arm/mips) is invalid for CentOS"
return 1
fi

OS_IS_CENTOS=YES
echo "Centos detected, install tools if needed"
Expand Down Expand Up @@ -220,26 +226,149 @@ function Centos_prepare()
fi
fi

echo "Centos install tools success"
return 0
}
# donot prepare tools, for srs-librtmp depends only gcc and g++.
if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
Centos_prepare; ret=$?; if [[ 0 -ne $ret ]]; then echo "CentOS prepare failed, ret=$ret"; exit $ret; fi
fi
#####################################################################################
# for Centos, auto install tools by yum
#####################################################################################
OS_IS_OSX=NO
function OSX_prepare()
{
uname -s|grep Darwin >/dev/null 2>&1
ret=$?; if [[ 0 -ne $ret ]]; then
if [ $SRS_OSX = YES ]; then
echo "OSX check failed, actual is `uname -s`"
exit 1;
fi
return 0;
fi

# for arm, install the cross build tool chain.
if [ $SRS_EMBEDED_CPU = YES ]; then
echo "embeded(arm/mips) is invalid for CentOS"
echo "embeded(arm/mips) is invalid for OSX"
return 1
fi

OS_IS_OSX=YES
echo "OSX detected, install tools if needed"

echo "Centos install tools success"
brew --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
echo "install brew"
echo "ruby -e \"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)\""
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "install brew success"
fi

gcc --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
echo "install gcc"
echo "brew install gcc"
brew install gcc; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "install gcc success"
fi

g++ --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
echo "install gcc-c++"
echo "brew install gcc-c++"
brew install gcc-c++; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "install gcc-c++ success"
fi

make --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
echo "install make"
echo "brew install make"
brew install make; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "install make success"
fi

patch --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
echo "install patch"
echo "brew install patch"
brew install patch; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "install patch success"
fi

unzip --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
echo "install unzip"
echo "brew install unzip"
brew install unzip; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "install unzip success"
fi

if [ $SRS_FFMPEG_TOOL = YES ]; then
automake --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
echo "install automake"
echo "brew install automake"
brew install automake; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "install automake success"
fi

autoconf --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
echo "install autoconf"
echo "brew install autoconf"
brew install autoconf; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "install autoconf success"
fi

libtool --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
echo "install libtool"
echo "brew install libtool"
brew install libtool; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "install libtool success"
fi

if [[ ! -f /usr/include/pcre.h ]]; then
echo "install pcre-devel"
echo "brew install pcre-devel"
brew install pcre-devel; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "install pcre-devel success"
fi

if [[ ! -f /usr/include/zlib.h ]]; then
echo "install zlib-devel"
echo "brew install zlib-devel"
brew install zlib-devel; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "install zlib-devel success"
fi
fi

echo "OSX install tools success"
return 0
}
# donot prepare tools, for srs-librtmp depends only gcc and g++.
if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
Centos_prepare; ret=$?; if [[ 0 -ne $ret ]]; then echo "CentOS prepare failed, ret=$ret"; exit $ret; fi
OSX_prepare; ret=$?; if [[ 0 -ne $ret ]]; then echo "OSX prepare failed, ret=$ret"; exit $ret; fi
fi
# requires the osx when os
if [ $OS_IS_OSX = YES ]; then
if [ $SRS_OSX = NO ]; then
echo "OSX detected, must specifies the --osx"
exit 1
fi
if [ $SRS_HTTP_API = YES ]; then
echo "OSX does not support http-api, use --without-http-api"
exit 1
fi
if [ $SRS_STAT = YES ]; then
echo "OSX does not support stat, use --without-stat"
exit 1
fi
fi

#####################################################################################
# st-1.9
#####################################################################################
if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
# check the arm flag file, if flag changed, need to rebuild the st.
_ST_MAKE=linux-debug
_ST_MAKE=linux-debug && _ST_EXTRA_CFLAGS="-DMD_HAVE_EPOLL"
# for osx, use darwin for st, donot use epoll.
if [ $OS_IS_OSX = YES ]; then
_ST_MAKE=darwin-debug && _ST_EXTRA_CFLAGS=""
fi
# memory leak for linux-optimized
# @see: https://github.com/winlinvip/simple-rtmp-server/issues/197
if [ $SRS_EMBEDED_CPU = YES ]; then
Expand All @@ -253,9 +382,9 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
(
rm -rf ${SRS_OBJS}/st-1.9 && cd ${SRS_OBJS} &&
unzip -q ../3rdparty/st-1.9.zip && cd st-1.9 &&
patch -p0 < ../../3rdparty/patches/1.st.arm.patch &&
patch -p0 -R < ../../3rdparty/patches/1.st.arm.patch &&
make CC=${SrsArmCC} AR=${SrsArmAR} LD=${SrsArmLD} RANDLIB=${SrsArmRANDLIB} \
EXTRA_CFLAGS="-DMD_HAVE_EPOLL" ${_ST_MAKE} &&
EXTRA_CFLAGS=${_ST_EXTRA_CFLAGS} ${_ST_MAKE} &&
cd .. && rm -rf st && ln -sf st-1.9/obj st &&
cd .. && touch ${SRS_OBJS}/_flag.st.arm.tmp
)
Expand All @@ -268,7 +397,7 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
(
rm -rf ${SRS_OBJS}/st-1.9 && cd ${SRS_OBJS} &&
unzip -q ../3rdparty/st-1.9.zip && cd st-1.9 &&
make ${_ST_MAKE} EXTRA_CFLAGS="-DMD_HAVE_EPOLL" &&
make ${_ST_MAKE} ${_ST_EXTRA_CFLAGS} &&
cd .. && rm -rf st && ln -sf st-1.9/obj st &&
cd .. && rm -f ${SRS_OBJS}/_flag.st.arm.tmp
)
Expand All @@ -293,6 +422,7 @@ if [ $SRS_HTTP_PARSER = YES ]; then
(
rm -rf ${SRS_OBJS}/http-parser-2.1 && cd ${SRS_OBJS} && unzip -q ../3rdparty/http-parser-2.1.zip &&
cd http-parser-2.1 &&
patch -p0 -R < ../../3rdparty/patches/2.http.parser.patch &&
sed -i "s/CPPFLAGS_FAST +=.*$/CPPFLAGS_FAST = \$\(CPPFLAGS_DEBUG\)/g" Makefile &&
sed -i "s/CFLAGS_FAST =.*$/CFLAGS_FAST = \$\(CFLAGS_DEBUG\)/g" Makefile &&
make CC=${SrsArmCC} AR=${SrsArmAR} package &&
Expand All @@ -309,8 +439,7 @@ if [ $SRS_HTTP_PARSER = YES ]; then
(
rm -rf ${SRS_OBJS}/http-parser-2.1 && cd ${SRS_OBJS} && unzip -q ../3rdparty/http-parser-2.1.zip &&
cd http-parser-2.1 &&
sed -i "s/CPPFLAGS_FAST +=.*$/CPPFLAGS_FAST = \$\(CPPFLAGS_DEBUG\)/g" Makefile &&
sed -i "s/CFLAGS_FAST =.*$/CFLAGS_FAST = \$\(CFLAGS_DEBUG\)/g" Makefile &&
patch -p0 -R < ../../3rdparty/patches/2.http.parser.patch &&
make package &&
cd .. && rm -rf hp && ln -sf http-parser-2.1 hp &&
cd .. && rm -f ${SRS_OBJS}/_flag.st.hp.tmp
Expand Down Expand Up @@ -402,7 +531,7 @@ if [ $SRS_HTTP_CALLBACK = YES ]; then
if [[ -f ${SRS_OBJS}/CherryPy-3.2.4/setup.py ]]; then
echo "CherryPy-3.2.4 is ok.";
else
require_sudoer "configure --with-http-callback"
require_sudoer "install CherryPy-3.2.4"
echo "install CherryPy-3.2.4";
(
sudo rm -rf ${SRS_OBJS}/CherryPy-3.2.4 && cd ${SRS_OBJS} &&
Expand Down Expand Up @@ -454,9 +583,11 @@ fi
#####################################################################################
# extra configure options
CONFIGURE_TOOL="./config"
EXTRA_CONFIGURE=""
if [ $SRS_EMBEDED_CPU = YES ]; then
CONFIGURE_TOOL="./Configure"
CONFIGURE_TOOL="./Configure linux-armv4"
fi
if [ $SRS_OSX = YES ]; then
CONFIGURE_TOOL="./Configure darwin64-`uname -m`-cc"
fi
# @see http://www.openssl.org/news/secadv_20140407.txt
# Affected users should upgrade to OpenSSL 1.0.1g. Users unable to immediately
Expand All @@ -475,7 +606,7 @@ if [ $SRS_SSL = YES ]; then
(
rm -rf ${SRS_OBJS}/openssl-1.0.1f && cd ${SRS_OBJS} &&
unzip -q ../3rdparty/openssl-1.0.1f.zip && cd openssl-1.0.1f &&
$CONFIGURE_TOOL --prefix=`pwd`/_release -no-shared no-asm linux-armv4 -DOPENSSL_NO_HEARTBEATS ${EXTRA_CONFIGURE} &&
$CONFIGURE_TOOL --prefix=`pwd`/_release -no-shared no-asm &&
make CC=${SrsArmCC} GCC=${SrsArmGCC} AR="${SrsArmAR} r" \
LD=${SrsArmLD} LINK=${SrsArmGCC} RANDLIB=${SrsArmRANDLIB} &&
make install_sw &&
Expand All @@ -492,7 +623,7 @@ if [ $SRS_SSL = YES ]; then
(
rm -rf ${SRS_OBJS}/openssl-1.0.1f && cd ${SRS_OBJS} &&
unzip -q ../3rdparty/openssl-1.0.1f.zip && cd openssl-1.0.1f &&
$CONFIGURE_TOOL --prefix=`pwd`/_release -no-shared -DOPENSSL_NO_HEARTBEATS ${EXTRA_CONFIGURE} &&
$CONFIGURE_TOOL --prefix=`pwd`/_release -no-shared &&
make && make install_sw &&
cd .. && rm -rf openssl && ln -sf openssl-1.0.1f/_release openssl &&
cd .. && rm -f ${SRS_OBJS}/_flag.ssl.arm.tmp
Expand Down
Loading

0 comments on commit db7ddfd

Please sign in to comment.