diff --git a/.gitignore b/.gitignore index eff902581..399419fa4 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,6 @@ /trunk/research/api-server/static-dir/forward /trunk/research/api-server/static-dir/live /trunk/research/api-server/static-dir/players + +# Apple-specific garbage files. +.AppleDouble diff --git a/AUTHORS.txt b/AUTHORS.txt index 93cf0f7c8..3a65799a2 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -23,4 +23,5 @@ CONTRIBUTORS ordered by first contribution. * tufang14 "Bug fixed" * allspace "The srs-librtmp windows support" * niesongsong "Configure support relative path" +* rudeb0t "Bug fixed" diff --git a/trunk/3rdparty/patches/1.st.arm.patch b/trunk/3rdparty/patches/1.st.arm.patch index 1e1825940..0e949631e 100644 --- a/trunk/3rdparty/patches/1.st.arm.patch +++ b/trunk/3rdparty/patches/1.st.arm.patch @@ -1,7 +1,5 @@ -Only in .: 1.st.arm.patch -diff -r -c ./md.h ../st-1.9-patch-arm/md.h -*** ./md.h 2009-10-02 02:46:43.000000000 +0800 ---- ../st-1.9-patch-arm/md.h 2014-03-16 20:49:03.845344804 +0800 +*** md.h Fri Oct 2 02:46:43 2009 +--- ../st-1.9-patch/md.h Mon Mar 16 15:11:49 2015 *************** *** 422,428 **** #define MD_STACK_GROWS_DOWN diff --git a/trunk/3rdparty/patches/2.http.parser.patch b/trunk/3rdparty/patches/2.http.parser.patch index 596d5972b..108880944 100644 --- a/trunk/3rdparty/patches/2.http.parser.patch +++ b/trunk/3rdparty/patches/2.http.parser.patch @@ -1,17 +1,16 @@ -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 +*** Makefile Wed Mar 27 06:35:20 2013 +--- ../http-parser-2.1-patch/Makefile Mon Mar 16 15:25:59 2015 *************** -*** 12,22 **** +*** 12,17 **** +--- 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 -- ++ # 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 ---- diff --git a/trunk/3rdparty/patches/3.st.osx.kqueue.patch b/trunk/3rdparty/patches/3.st.osx.kqueue.patch new file mode 100644 index 000000000..d3e016b10 --- /dev/null +++ b/trunk/3rdparty/patches/3.st.osx.kqueue.patch @@ -0,0 +1,19 @@ +*** io.c Fri Oct 2 06:49:07 2009 +--- ../st-1.9-patch/io.c Mon Mar 16 15:06:28 2015 +*************** +*** 89,94 **** +--- 89,102 ---- + if (fdlim > 0 && rlim.rlim_max > (rlim_t) fdlim) { + rlim.rlim_max = fdlim; + } ++ ++ /* when rlimit max is negative, for example, osx, use cur directly. */ ++ /* @see https://github.com/winlinvip/simple-rtmp-server/issues/336 */ ++ if ((int)rlim.rlim_max < 0) { ++ _st_osfd_limit = (int)(fdlim > 0? fdlim : rlim.rlim_cur); ++ return 0; ++ } ++ + rlim.rlim_cur = rlim.rlim_max; + if (setrlimit(RLIMIT_NOFILE, &rlim) < 0) + return -1; diff --git a/trunk/3rdparty/patches/4.st.disable.examples.patch b/trunk/3rdparty/patches/4.st.disable.examples.patch new file mode 100644 index 000000000..c775f30df --- /dev/null +++ b/trunk/3rdparty/patches/4.st.disable.examples.patch @@ -0,0 +1,15 @@ +*** Makefile Fri Oct 2 06:55:03 2009 +--- ../st-1.9-patch/Makefile Mon Mar 16 15:30:35 2015 +*************** +*** 310,315 **** +--- 310,319 ---- + EXAMPLES = + endif + ++ # disable examples for ubuntu crossbuild failed. ++ # @see https://github.com/winlinvip/simple-rtmp-server/issues/308 ++ EXAMPLES = ++ + ifeq ($(OS), DARWIN) + LINKNAME = libst.$(DSO_SUFFIX) + SONAME = libst.$(MAJOR).$(DSO_SUFFIX) diff --git a/trunk/auto/depends.sh b/trunk/auto/depends.sh index e5b9fca50..46e11ed16 100755 --- a/trunk/auto/depends.sh +++ b/trunk/auto/depends.sh @@ -376,7 +376,7 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then _ST_MAKE=linux-debug && _ST_EXTRA_CFLAGS="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="" + _ST_MAKE=darwin-debug && _ST_EXTRA_CFLAGS="EXTRA_CFLAGS=-DMD_HAVE_KQUEUE" fi # memory leak for linux-optimized # @see: https://github.com/winlinvip/simple-rtmp-server/issues/197 @@ -390,10 +390,11 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then echo "build st-1.9t for arm"; ( rm -rf ${SRS_OBJS}/st-1.9 && cd ${SRS_OBJS} && - unzip -q ../3rdparty/st-1.9.zip && cd st-1.9 && - patch -p0 -R < ../../3rdparty/patches/1.st.arm.patch && - make ${_ST_MAKE} CC=${SrsArmCC} AR=${SrsArmAR} LD=${SrsArmLD} RANDLIB=${SrsArmRANDLIB} \ - EXTRA_CFLAGS=${_ST_EXTRA_CFLAGS} && + unzip -q ../3rdparty/st-1.9.zip && cd st-1.9 && chmod +w * && + patch -p0 < ../../3rdparty/patches/1.st.arm.patch && + patch -p0 < ../../3rdparty/patches/3.st.osx.kqueue.patch && + patch -p0 < ../../3rdparty/patches/4.st.disable.examples.patch && + make ${_ST_MAKE} CC=${SrsArmCC} AR=${SrsArmAR} LD=${SrsArmLD} RANDLIB=${SrsArmRANDLIB} ${_ST_EXTRA_CFLAGS} && cd .. && rm -rf st && ln -sf st-1.9/obj st && cd .. && touch ${SRS_OBJS}/_flag.st.arm.tmp ) @@ -405,7 +406,9 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then echo "build st-1.9t"; ( rm -rf ${SRS_OBJS}/st-1.9 && cd ${SRS_OBJS} && - unzip -q ../3rdparty/st-1.9.zip && cd st-1.9 && + unzip -q ../3rdparty/st-1.9.zip && cd st-1.9 && chmod +w * && + patch -p0 < ../../3rdparty/patches/3.st.osx.kqueue.patch && + patch -p0 < ../../3rdparty/patches/4.st.disable.examples.patch && 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 @@ -431,7 +434,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 && + patch -p0 < ../../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 && @@ -448,7 +451,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 && + patch -p0 < ../../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 diff --git a/trunk/ide/srs_xcode/srs_xcode.xcodeproj/project.pbxproj b/trunk/ide/srs_xcode/srs_xcode.xcodeproj/project.pbxproj index cef6a41c8..ab911d35f 100644 --- a/trunk/ide/srs_xcode/srs_xcode.xcodeproj/project.pbxproj +++ b/trunk/ide/srs_xcode/srs_xcode.xcodeproj/project.pbxproj @@ -87,6 +87,13 @@ 3C663F181AB0155100286D8B /* srs_play.c in Sources */ = {isa = PBXBuildFile; fileRef = 3C663F0B1AB0155100286D8B /* srs_play.c */; }; 3C663F191AB0155100286D8B /* srs_publish.c in Sources */ = {isa = PBXBuildFile; fileRef = 3C663F0C1AB0155100286D8B /* srs_publish.c */; }; 3C663F1A1AB0155100286D8B /* srs_rtmp_dump.c in Sources */ = {isa = PBXBuildFile; fileRef = 3C663F0D1AB0155100286D8B /* srs_rtmp_dump.c */; }; + 3C689F961AB6AAAC00C9CEEE /* event.c in Sources */ = {isa = PBXBuildFile; fileRef = 3C689F921AB6AAAC00C9CEEE /* event.c */; }; + 3C689F971AB6AAAC00C9CEEE /* io.c in Sources */ = {isa = PBXBuildFile; fileRef = 3C689F931AB6AAAC00C9CEEE /* io.c */; }; + 3C689F981AB6AAAC00C9CEEE /* key.c in Sources */ = {isa = PBXBuildFile; fileRef = 3C689F941AB6AAAC00C9CEEE /* key.c */; }; + 3C689F9E1AB6AAC800C9CEEE /* md.S in Sources */ = {isa = PBXBuildFile; fileRef = 3C689F991AB6AAC800C9CEEE /* md.S */; }; + 3C689F9F1AB6AAC800C9CEEE /* sched.c in Sources */ = {isa = PBXBuildFile; fileRef = 3C689F9B1AB6AAC800C9CEEE /* sched.c */; }; + 3C689FA01AB6AAC800C9CEEE /* stk.c in Sources */ = {isa = PBXBuildFile; fileRef = 3C689F9C1AB6AAC800C9CEEE /* stk.c */; }; + 3C689FA11AB6AAC800C9CEEE /* sync.c in Sources */ = {isa = PBXBuildFile; fileRef = 3C689F9D1AB6AAC800C9CEEE /* sync.c */; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -311,6 +318,16 @@ 3C663F0B1AB0155100286D8B /* srs_play.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = srs_play.c; path = ../../../research/librtmp/srs_play.c; sourceTree = ""; }; 3C663F0C1AB0155100286D8B /* srs_publish.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = srs_publish.c; path = ../../../research/librtmp/srs_publish.c; sourceTree = ""; }; 3C663F0D1AB0155100286D8B /* srs_rtmp_dump.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = srs_rtmp_dump.c; path = ../../../research/librtmp/srs_rtmp_dump.c; sourceTree = ""; }; + 3C689F911AB6AAAC00C9CEEE /* common.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = common.h; path = "../../objs/st-1.9/common.h"; sourceTree = ""; }; + 3C689F921AB6AAAC00C9CEEE /* event.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = event.c; path = "../../objs/st-1.9/event.c"; sourceTree = ""; }; + 3C689F931AB6AAAC00C9CEEE /* io.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = io.c; path = "../../objs/st-1.9/io.c"; sourceTree = ""; }; + 3C689F941AB6AAAC00C9CEEE /* key.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = key.c; path = "../../objs/st-1.9/key.c"; sourceTree = ""; }; + 3C689F951AB6AAAC00C9CEEE /* md.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = md.h; path = "../../objs/st-1.9/md.h"; sourceTree = ""; }; + 3C689F991AB6AAC800C9CEEE /* md.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; name = md.S; path = "../../objs/st-1.9/md.S"; sourceTree = ""; }; + 3C689F9A1AB6AAC800C9CEEE /* public.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = public.h; path = "../../objs/st-1.9/public.h"; sourceTree = ""; }; + 3C689F9B1AB6AAC800C9CEEE /* sched.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = sched.c; path = "../../objs/st-1.9/sched.c"; sourceTree = ""; }; + 3C689F9C1AB6AAC800C9CEEE /* stk.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = stk.c; path = "../../objs/st-1.9/stk.c"; sourceTree = ""; }; + 3C689F9D1AB6AAC800C9CEEE /* sync.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = sync.c; path = "../../objs/st-1.9/sync.c"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -331,6 +348,7 @@ 3C1231DC1AAE64A400CE8F6C = { isa = PBXGroup; children = ( + 3C689F901AB6AA9100C9CEEE /* st-1.9 */, 3C1EE6D21AB1366500576EE9 /* doc */, 3C1231E61AAE64A400CE8F6C /* Products */, 3C1232EE1AAEA71C00CE8F6C /* links */, @@ -672,6 +690,23 @@ path = srs_xcode; sourceTree = ""; }; + 3C689F901AB6AA9100C9CEEE /* st-1.9 */ = { + isa = PBXGroup; + children = ( + 3C689F991AB6AAC800C9CEEE /* md.S */, + 3C689F9A1AB6AAC800C9CEEE /* public.h */, + 3C689F9B1AB6AAC800C9CEEE /* sched.c */, + 3C689F9C1AB6AAC800C9CEEE /* stk.c */, + 3C689F9D1AB6AAC800C9CEEE /* sync.c */, + 3C689F911AB6AAAC00C9CEEE /* common.h */, + 3C689F921AB6AAAC00C9CEEE /* event.c */, + 3C689F931AB6AAAC00C9CEEE /* io.c */, + 3C689F941AB6AAAC00C9CEEE /* key.c */, + 3C689F951AB6AAAC00C9CEEE /* md.h */, + ); + name = "st-1.9"; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -730,6 +765,7 @@ files = ( 3C1232951AAE81D900CE8F6C /* srs_app_config.cpp in Sources */, 3C663F0F1AB0155100286D8B /* srs_aac_raw_publish.c in Sources */, + 3C689FA01AB6AAC800C9CEEE /* stk.c in Sources */, 3C1232961AAE81D900CE8F6C /* srs_app_conn.cpp in Sources */, 3C12322A1AAE814D00CE8F6C /* srs_kernel_ts.cpp in Sources */, 3C12329E1AAE81D900CE8F6C /* srs_app_hls.cpp in Sources */, @@ -737,6 +773,7 @@ 3C663F131AB0155100286D8B /* srs_flv_injecter.c in Sources */, 3C1232971AAE81D900CE8F6C /* srs_app_dvr.cpp in Sources */, 3C1232271AAE814D00CE8F6C /* srs_kernel_log.cpp in Sources */, + 3C689F961AB6AAAC00C9CEEE /* event.c in Sources */, 3C1232A81AAE81D900CE8F6C /* srs_app_log.cpp in Sources */, 3C1232A41AAE81D900CE8F6C /* srs_app_ingest.cpp in Sources */, 3C1232B41AAE81D900CE8F6C /* srs_app_st.cpp in Sources */, @@ -764,6 +801,7 @@ 3C1232491AAE81A400CE8F6C /* srs_rtmp_utility.cpp in Sources */, 3C663F191AB0155100286D8B /* srs_publish.c in Sources */, 3C1232A01AAE81D900CE8F6C /* srs_app_http_client.cpp in Sources */, + 3C689F981AB6AAAC00C9CEEE /* key.c in Sources */, 3C12329B1AAE81D900CE8F6C /* srs_app_ffmpeg.cpp in Sources */, 3C1232421AAE81A400CE8F6C /* srs_rtmp_amf0.cpp in Sources */, 3C1232AA1AAE81D900CE8F6C /* srs_app_pithy_print.cpp in Sources */, @@ -774,12 +812,14 @@ 3C1232A21AAE81D900CE8F6C /* srs_app_http_hooks.cpp in Sources */, 3C663F121AB0155100286D8B /* srs_detect_rtmp.c in Sources */, 3C1232B11AAE81D900CE8F6C /* srs_app_server.cpp in Sources */, + 3C689F9F1AB6AAC800C9CEEE /* sched.c in Sources */, 3C1232B31AAE81D900CE8F6C /* srs_app_st_socket.cpp in Sources */, 3C1232061AAE812C00CE8F6C /* srs_main_server.cpp in Sources */, 3C1232281AAE814D00CE8F6C /* srs_kernel_mp3.cpp in Sources */, 3C1232B21AAE81D900CE8F6C /* srs_app_source.cpp in Sources */, 3C1231F71AAE652D00CE8F6C /* srs_core_performance.cpp in Sources */, 3C1232981AAE81D900CE8F6C /* srs_app_edge.cpp in Sources */, + 3C689F9E1AB6AAC800C9CEEE /* md.S in Sources */, 3C1232461AAE81A400CE8F6C /* srs_rtmp_msg_array.cpp in Sources */, 3C1232A71AAE81D900CE8F6C /* srs_app_listener.cpp in Sources */, 3C1232261AAE814D00CE8F6C /* srs_kernel_flv.cpp in Sources */, @@ -788,6 +828,7 @@ 3C1232441AAE81A400CE8F6C /* srs_rtmp_handshake.cpp in Sources */, 3C1232291AAE814D00CE8F6C /* srs_kernel_stream.cpp in Sources */, 3C663F181AB0155100286D8B /* srs_play.c in Sources */, + 3C689F971AB6AAAC00C9CEEE /* io.c in Sources */, 3C1232B61AAE81D900CE8F6C /* srs_app_thread.cpp in Sources */, 3C1232A91AAE81D900CE8F6C /* srs_app_mpegts_udp.cpp in Sources */, 3C1232AE1AAE81D900CE8F6C /* srs_app_rtmp_conn.cpp in Sources */, @@ -802,6 +843,7 @@ 3C12329D1AAE81D900CE8F6C /* srs_app_heartbeat.cpp in Sources */, 3C1232231AAE814D00CE8F6C /* srs_kernel_consts.cpp in Sources */, 3C1232AF1AAE81D900CE8F6C /* srs_app_rtsp.cpp in Sources */, + 3C689FA11AB6AAC800C9CEEE /* sync.c in Sources */, 3C1232A31AAE81D900CE8F6C /* srs_app_http.cpp in Sources */, 3C12329A1AAE81D900CE8F6C /* srs_app_encoder.cpp in Sources */, ); diff --git a/trunk/src/app/srs_app_http_hooks.cpp b/trunk/src/app/srs_app_http_hooks.cpp index 6d1de2155..37e21eab9 100644 --- a/trunk/src/app/srs_app_http_hooks.cpp +++ b/trunk/src/app/srs_app_http_hooks.cpp @@ -82,7 +82,7 @@ int SrsHttpHooks::on_connect(string url, int client_id, string ip, SrsRequest* r return ret; } -void SrsHttpHooks::on_close(string url, int client_id, string ip, SrsRequest* req) +void SrsHttpHooks::on_close(string url, int client_id, string ip, SrsRequest* req, int64_t send_bytes, int64_t recv_bytes) { int ret = ERROR_SUCCESS; @@ -92,6 +92,8 @@ void SrsHttpHooks::on_close(string url, int client_id, string ip, SrsRequest* re << __SRS_JFIELD_ORG("client_id", client_id) << __SRS_JFIELD_CONT << __SRS_JFIELD_STR("ip", ip) << __SRS_JFIELD_CONT << __SRS_JFIELD_STR("vhost", req->vhost) << __SRS_JFIELD_CONT + << __SRS_JFIELD_ORG("send_bytes", send_bytes) << __SRS_JFIELD_CONT + << __SRS_JFIELD_ORG("recv_bytes", recv_bytes) << __SRS_JFIELD_CONT << __SRS_JFIELD_STR("app", req->app) << __SRS_JOBJECT_END; diff --git a/trunk/src/app/srs_app_http_hooks.hpp b/trunk/src/app/srs_app_http_hooks.hpp index 49c387fb9..1d34dc3fb 100644 --- a/trunk/src/app/srs_app_http_hooks.hpp +++ b/trunk/src/app/srs_app_http_hooks.hpp @@ -66,7 +66,7 @@ public: * @param url the api server url, to process the event. * ignore if empty. */ - static void on_close(std::string url, int client_id, std::string ip, SrsRequest* req); + static void on_close(std::string url, int client_id, std::string ip, SrsRequest* req, int64_t send_bytes, int64_t recv_bytes); /** * on_publish hook, when client(encoder) start to publish stream * @param client_id the id of client on server. diff --git a/trunk/src/app/srs_app_rtmp_conn.cpp b/trunk/src/app/srs_app_rtmp_conn.cpp index f887bfceb..7d4949b36 100644 --- a/trunk/src/app/srs_app_rtmp_conn.cpp +++ b/trunk/src/app/srs_app_rtmp_conn.cpp @@ -1294,7 +1294,7 @@ void SrsRtmpConn::http_hooks_on_close() int connection_id = _srs_context->get_id(); for (int i = 0; i < (int)on_close->args.size(); i++) { std::string url = on_close->args.at(i); - SrsHttpHooks::on_close(url, connection_id, ip, req); + SrsHttpHooks::on_close(url, connection_id, ip, req, kbps->get_send_bytes(), kbps->get_recv_bytes()); } } #endif diff --git a/trunk/src/app/srs_app_st.cpp b/trunk/src/app/srs_app_st.cpp index 4160f9464..b54c73eec 100644 --- a/trunk/src/app/srs_app_st.cpp +++ b/trunk/src/app/srs_app_st.cpp @@ -26,8 +26,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include #include -#ifndef SRS_OSX +#ifdef __linux__ #include + bool srs_st_epoll_is_supported(void) { struct epoll_event ev; @@ -45,30 +46,31 @@ int srs_init_st() { int ret = ERROR_SUCCESS; -#ifndef SRS_OSX +#ifdef __linux__ // check epoll, some old linux donot support epoll. // @see https://github.com/winlinvip/simple-rtmp-server/issues/162 if (!srs_st_epoll_is_supported()) { ret = ERROR_ST_SET_EPOLL; - srs_error("epoll required. ret=%d", ret); + srs_error("epoll required on Linux. ret=%d", ret); return ret; } - - // use linux epoll. - if (st_set_eventsys(ST_EVENTSYS_ALT) == -1) { - ret = ERROR_ST_SET_EPOLL; - srs_error("st_set_eventsys use linux epoll failed. ret=%d", ret); - return ret; - } - srs_verbose("st_set_eventsys use linux epoll success"); #endif + // Select the best event system available on the OS. In Linux this is + // epoll(). On BSD it will be kqueue. + if (st_set_eventsys(ST_EVENTSYS_ALT) == -1) { + ret = ERROR_ST_SET_EPOLL; + srs_error("st_set_eventsys use %s failed. ret=%d", st_get_eventsys_name(), ret); + return ret; + } + srs_trace("st_set_eventsys to %s", st_get_eventsys_name()); + if(st_init() != 0){ ret = ERROR_ST_INITIALIZE; srs_error("st_init failed. ret=%d", ret); return ret; } - srs_verbose("st_init success"); + srs_trace("st_init success, use %s", st_get_eventsys_name()); return ret; }