mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Merge branch 'develop' into feature/rtc
This commit is contained in:
commit
04c3370458
35 changed files with 489 additions and 111 deletions
|
@ -5,13 +5,13 @@ jobs:
|
|||
- image: ossrs/srs:dev
|
||||
steps:
|
||||
- checkout
|
||||
- run: cd trunk && ./configure --without-rtc && make && ./configure && make
|
||||
- run: cd trunk && ./configure --without-rtc && make && ./configure --with-utest && make
|
||||
test:
|
||||
docker:
|
||||
- image: ossrs/srs:dev
|
||||
steps:
|
||||
- checkout
|
||||
- run: cd trunk && ./configure --gcov && make && ./objs/srs_utest && bash auto/coverage.sh
|
||||
- run: cd trunk && ./configure --with-utest --gcov && make && ./objs/srs_utest && bash auto/coverage.sh
|
||||
workflows:
|
||||
version: 2
|
||||
build_and_test:
|
||||
|
|
|
@ -60,4 +60,3 @@ CONTRIBUTORS ordered by first contribution.
|
|||
* HuyaJohn<xiaozhihong@huya.com>
|
||||
* yanghuiwen<cainiaodj@qq.com>
|
||||
* Bepartofyou<pengqiang.wpq@alibaba-inc.com>
|
||||
|
||||
|
|
27
README.md
27
README.md
|
@ -13,22 +13,22 @@ SRS is a RTMP/HLS/WebRTC/SRT/GB28181 streaming cluster, high efficiency, stable
|
|||
<a name="product"></a>
|
||||
## Usage
|
||||
|
||||
**Step 1:** Get SRS.
|
||||
**>>> Step 1:** Get SRS.
|
||||
|
||||
```
|
||||
git clone https://gitee.com/winlinvip/srs.oschina.git srs &&
|
||||
cd srs/trunk && git remote set-url origin https://github.com/ossrs/srs.git && git pull
|
||||
```
|
||||
|
||||
> Note: Repository too large? Please clone from these [mirrors](#mirrors) instead.
|
||||
> Note: We use [mirrors(gitee)](#mirrors) here, but it's also ok to directly clone by `git clone https://github.com/ossrs/srs.git && cd srs/trunk`
|
||||
|
||||
**Step 2:** Build SRS.
|
||||
**>>> Step 2:** Build SRS.
|
||||
|
||||
```
|
||||
./configure && make
|
||||
```
|
||||
|
||||
> Remark: Recommend Centos6 64bits, please read wiki([CN][v3_CN_Build],[EN][v3_EN_Build]).
|
||||
> Remark: Recommend to use Centos7 64bits, please read wiki([CN][v3_CN_Build],[EN][v3_EN_Build]).
|
||||
|
||||
> Note: You can also build SRS in docker, please read [docker][docker-dev].
|
||||
|
||||
|
@ -38,13 +38,16 @@ cd srs/trunk && git remote set-url origin https://github.com/ossrs/srs.git && gi
|
|||
./objs/srs -c conf/srs.conf
|
||||
```
|
||||
|
||||
**Whatever**, you can also directly run SRS in [docker][docker-srs3]:
|
||||
**>>> Whatever**, you can also directly run SRS in [docker][docker-srs3]:
|
||||
|
||||
```
|
||||
docker run -p 1935:1935 -p 1985:1985 -p 8080:8080 ossrs/srs:3
|
||||
docker run -p 1935:1935 -p 1985:1985 -p 8080:8080 \
|
||||
registry.cn-hangzhou.aliyuncs.com/ossrs/srs:3
|
||||
```
|
||||
|
||||
**From here,** strongly recommend to read bellow wikis:
|
||||
> Note: Again, we use [ACR](https://cr.console.aliyun.com/) here, you can directly run in docker hub by `docker run -p 1935:1935 -p 1985:1985 -p 8080:8080 ossrs/srs:3`
|
||||
|
||||
**>>> From here,** strongly recommend to read bellow wikis:
|
||||
|
||||
* Usage: How to delivery RTMP?([CN][v1_CN_SampleRTMP], [EN][v1_EN_SampleRTMP])
|
||||
* Usage: How to delivery RTMP-Edge Cluster?([CN][v3_CN_SampleRTMPCluster], [EN][v3_EN_SampleRTMPCluster])
|
||||
|
@ -154,6 +157,7 @@ For previous versions, please read:
|
|||
|
||||
## V4 changes
|
||||
|
||||
* v4.0, 2020-03-22, Welcome maintainers [Runner365](https://github.com/runner365), [John](https://github.com/xiaozhihong) and [B.P.Y(Bepartofyou)](https://github.com/Bepartofyou). 4.0.15
|
||||
* v4.0, 2020-03-22, For [#307][bug #307], support play with WebRTC. 4.0.14
|
||||
* v4.0, 2020-03-13, For [#1636][bug #1636], fix bug for mux AAC to ADTS, never overwrite by RTMP sampling rate. 4.0.13
|
||||
* v4.0, 2020-03-07, For [#1612][bug #1612], fix crash bug for RTSP. 4.0.12
|
||||
|
@ -171,6 +175,10 @@ For previous versions, please read:
|
|||
|
||||
## V3 changes
|
||||
|
||||
* v3.0, 2020-03-28, For [#1250][bug #1250], support macOS, OSX, MacbookPro, Apple Darwin. 3.0.138
|
||||
* v3.0, 2020-03-21, For [#1629][bug #1629], fix kickoff FLV client bug. 3.0.137
|
||||
* v3.0, 2020-03-21, For [#1619][bug #1619], configure without utest by default. 3.0.136
|
||||
* v3.0, 2020-03-21, For [#1651][bug #1651], fix return pnwrite of srs_write_large_iovs. 3.0.135
|
||||
* <strong>v3.0, 2020-03-18, [3.0 beta3(3.0.134)][r3.0b3] released. 122509 lines.</strong>
|
||||
* v3.0, 2020-03-12, For [#1635][bug #1635], inotify watch ConfigMap for reload. 3.0.134
|
||||
* v3.0, 2020-03-12, For [#1635][bug #1635], support auto reaload config by inotify. 3.0.129
|
||||
|
@ -1138,6 +1146,8 @@ Maintainers of SRS project:
|
|||
* [Winlin](https://github.com/winlinvip): All areas of streaming server and documents.
|
||||
* [Wenjie](https://github.com/wenjiegit): The focus of his work is on the [HDS](https://github.com/simple-rtmp-server/srs/wiki/v2_CN_DeliveryHDS) module.
|
||||
* [Runner365](https://github.com/runner365): The focus of his work is on the [SRT](https://github.com/simple-rtmp-server/srs/wiki/v4_CN_SRTWiki) module.
|
||||
* [John](https://github.com/xiaozhihong): Focus on [WebRTC](https://github.com/simple-rtmp-server/srs/wiki/v4_CN_RTCWiki) module.
|
||||
* [B.P.Y(Bepartofyou)](https://github.com/Bepartofyou): Focus on [WebRTC](https://github.com/simple-rtmp-server/srs/wiki/v4_CN_RTCWiki) module.
|
||||
|
||||
A big THANK YOU goes to:
|
||||
|
||||
|
@ -1712,6 +1722,9 @@ Winlin
|
|||
[bug #1594]: https://github.com/ossrs/srs/issues/1594
|
||||
[bug #1630]: https://github.com/ossrs/srs/issues/1630
|
||||
[bug #1635]: https://github.com/ossrs/srs/issues/1635
|
||||
[bug #1651]: https://github.com/ossrs/srs/issues/1651
|
||||
[bug #1619]: https://github.com/ossrs/srs/issues/1619
|
||||
[bug #1629]: https://github.com/ossrs/srs/issues/1629
|
||||
[bug #yyyyyyyyyyyyy]: https://github.com/ossrs/srs/issues/yyyyyyyyyyyyy
|
||||
|
||||
[bug #1631]: https://github.com/ossrs/srs/issues/1631
|
||||
|
|
12
trunk/3rdparty/st-srs/Makefile
vendored
12
trunk/3rdparty/st-srs/Makefile
vendored
|
@ -128,6 +128,7 @@ OTHER_FLAGS = -Wall
|
|||
endif
|
||||
|
||||
ifeq ($(OS), DARWIN)
|
||||
EXTRA_OBJS = $(TARGETDIR)/md_darwin.o
|
||||
LD = cc
|
||||
SFLAGS = -fPIC -fno-common
|
||||
DSO_SUFFIX = dylib
|
||||
|
@ -139,8 +140,8 @@ CFLAGS += -arch ppc
|
|||
LDFLAGS += -arch ppc
|
||||
endif
|
||||
ifeq ($(INTEL), yes)
|
||||
CFLAGS += -arch i386 -arch x86_64
|
||||
LDFLAGS += -arch i386 -arch x86_64
|
||||
CFLAGS += -arch x86_64
|
||||
LDFLAGS += -arch x86_64
|
||||
endif
|
||||
LDFLAGS += -dynamiclib -install_name /sw/lib/libst.$(MAJOR).$(DSO_SUFFIX) -compatibility_version $(MAJOR) -current_version $(VERSION)
|
||||
OTHER_FLAGS = -Wall
|
||||
|
@ -313,7 +314,9 @@ endif
|
|||
# for SRS
|
||||
# disable examples for ubuntu crossbuild failed.
|
||||
# @see https://github.com/winlinvip/simple-rtmp-server/issues/308
|
||||
ifeq ($(OS), LINUX)
|
||||
EXAMPLES =
|
||||
endif
|
||||
|
||||
ifeq ($(OS), DARWIN)
|
||||
LINKNAME = libst.$(DSO_SUFFIX)
|
||||
|
@ -369,10 +372,13 @@ $(HEADER): public.h
|
|||
$(TARGETDIR)/md.o: md.S
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
$(TARGETDIR)/md_darwin.o: md_darwin.S
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
$(TARGETDIR)/%.o: %.c common.h md.h
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
examples::
|
||||
examples: $(SLIBRARY)
|
||||
@echo Making $@
|
||||
@cd $@; $(MAKE) CC="$(CC)" CFLAGS="$(CFLAGS)" OS="$(OS)" TARGETDIR="$(TARGETDIR)"
|
||||
|
||||
|
|
32
trunk/3rdparty/st-srs/md.h
vendored
32
trunk/3rdparty/st-srs/md.h
vendored
|
@ -120,26 +120,30 @@
|
|||
#define MD_ALWAYS_UNSERIALIZED_ACCEPT
|
||||
#define MD_HAVE_SOCKLEN_T
|
||||
|
||||
#define MD_SETJMP(env) _setjmp(env)
|
||||
#define MD_LONGJMP(env, val) _longjmp(env, val)
|
||||
#define MD_USE_BUILTIN_SETJMP
|
||||
|
||||
#if defined(__ppc__)
|
||||
#define MD_JB_SP 0
|
||||
#elif defined(__i386__)
|
||||
#define MD_JB_SP 9
|
||||
#elif defined(__x86_64__)
|
||||
#define MD_JB_SP 4
|
||||
#if defined(__amd64__) || defined(__x86_64__)
|
||||
#define JB_SP 12
|
||||
#define MD_GET_SP(_t) *((long *)&((_t)->context[JB_SP]))
|
||||
#else
|
||||
#error Unknown CPU architecture
|
||||
#endif
|
||||
|
||||
#define MD_INIT_CONTEXT(_thread, _sp, _main) \
|
||||
ST_BEGIN_MACRO \
|
||||
if (MD_SETJMP((_thread)->context)) \
|
||||
_main(); \
|
||||
*((long *)&((_thread)->context[MD_JB_SP])) = (long) (_sp); \
|
||||
|
||||
#define MD_INIT_CONTEXT(_thread, _sp, _main) \
|
||||
ST_BEGIN_MACRO \
|
||||
if (MD_SETJMP((_thread)->context)) \
|
||||
_main(); \
|
||||
MD_GET_SP(_thread) = (long) (_sp); \
|
||||
ST_END_MACRO
|
||||
|
||||
#if defined(MD_USE_BUILTIN_SETJMP)
|
||||
#define MD_SETJMP(env) _st_md_cxt_save(env)
|
||||
#define MD_LONGJMP(env, val) _st_md_cxt_restore(env, val)
|
||||
|
||||
extern int _st_md_cxt_save(jmp_buf env);
|
||||
extern void _st_md_cxt_restore(jmp_buf env, int val);
|
||||
#endif
|
||||
|
||||
#define MD_GET_UTIME() \
|
||||
struct timeval tv; \
|
||||
(void) gettimeofday(&tv, NULL); \
|
||||
|
|
76
trunk/3rdparty/st-srs/md_darwin.S
vendored
Normal file
76
trunk/3rdparty/st-srs/md_darwin.S
vendored
Normal file
|
@ -0,0 +1,76 @@
|
|||
|
||||
/* If user disable the ASM, such as avoiding bugs in ASM, donot compile it. */
|
||||
#if !defined(MD_ST_NO_ASM)
|
||||
|
||||
#if defined(__amd64__) || defined(__x86_64__)
|
||||
|
||||
/****************************************************************/
|
||||
|
||||
/*
|
||||
* Internal __jmp_buf layout
|
||||
*/
|
||||
#define JB_RBX 0
|
||||
#define JB_RBP 1
|
||||
#define JB_R12 2 /* Backup IP, https://www.cnblogs.com/Five100Miles/p/8458561.html */
|
||||
#define JB_R13 3 /* Backup SP, https://www.cnblogs.com/Five100Miles/p/8458561.html */
|
||||
#define JB_R14 4 /* Backup LR, https://www.cnblogs.com/Five100Miles/p/8458561.html */
|
||||
#define JB_R15 5 /* Backup PC, https://www.cnblogs.com/Five100Miles/p/8458561.html */
|
||||
#define JB_RSP 6
|
||||
#define JB_PC 7
|
||||
|
||||
.file "md_darwin.S"
|
||||
.text
|
||||
|
||||
/* _st_md_cxt_save(__jmp_buf env) */ /* The env is rdi, http://blog.chinaunix.net/uid-20157960-id-1974354.html */
|
||||
.globl __st_md_cxt_save
|
||||
.align 16
|
||||
__st_md_cxt_save:
|
||||
/*
|
||||
* Save registers.
|
||||
*/
|
||||
movq %rbx, (JB_RBX*8)(%rdi) /* Save rbx to env[0], *(int64_t*)(rdi+0)=rbx */
|
||||
movq %rbp, (JB_RBP*8)(%rdi) /* Save rbp to env[1], *(int64_t*)(rdi+1)=rbp */
|
||||
movq %r12, (JB_R12*8)(%rdi) /* Save r12 to env[2], *(int64_t*)(rdi+2)=r12 */
|
||||
movq %r13, (JB_R13*8)(%rdi) /* Save r13 to env[3], *(int64_t*)(rdi+3)=r13 */
|
||||
movq %r14, (JB_R14*8)(%rdi) /* Save r14 to env[4], *(int64_t*)(rdi+4)=r14 */
|
||||
movq %r15, (JB_R15*8)(%rdi) /* Save r15 to env[5], *(int64_t*)(rdi+5)=r15 */
|
||||
/* Save SP */
|
||||
leaq 8(%rsp), %rdx /* Save *(int64_t*)(rsp+8) to rdx, https://my.oschina.net/guonaihong/blog/508907 */
|
||||
movq %rdx, (JB_RSP*8)(%rdi) /* Save rdx(rsp) to env[6], *(int64_t*)(rdi+6)=rdx */
|
||||
/* Save PC we are returning to */
|
||||
movq (%rsp), %rax /* Save PC(parent function address) %(rsp) to rax */
|
||||
movq %rax, (JB_PC*8)(%rdi) /* Save rax(PC) to env[7], *(int64_t*)(rdi+7)=rax */
|
||||
xorq %rax, %rax /* Reset rax to 0 */
|
||||
ret
|
||||
|
||||
|
||||
/****************************************************************/
|
||||
|
||||
/* _st_md_cxt_restore(__jmp_buf env, int val) */ /* The env is rdi, val is esi/rsi, http://blog.chinaunix.net/uid-20157960-id-1974354.html */
|
||||
.globl __st_md_cxt_restore
|
||||
.align 16
|
||||
__st_md_cxt_restore:
|
||||
/*
|
||||
* Restore registers.
|
||||
*/
|
||||
movq (JB_RBX*8)(%rdi), %rbx /* Load rbx from env[0] */
|
||||
movq (JB_RBP*8)(%rdi), %rbp /* Load rbp from env[1] */
|
||||
movq (JB_R12*8)(%rdi), %r12 /* Load r12 from env[2] */
|
||||
movq (JB_R13*8)(%rdi), %r13 /* Load r13 from env[3] */
|
||||
movq (JB_R14*8)(%rdi), %r14 /* Load r14 from env[4] */
|
||||
movq (JB_R15*8)(%rdi), %r15 /* Load r15 from env[5] */
|
||||
/* Set return value */ /* The esi is param1 val, the eax is return value */
|
||||
test %esi, %esi /* if (!val) { */
|
||||
mov $01, %eax /* val=1; */
|
||||
cmove %eax, %esi /* } */
|
||||
mov %esi, %eax /* return val; */
|
||||
movq (JB_PC*8)(%rdi), %rdx /* Load rdx(PC) from env[7] */
|
||||
movq (JB_RSP*8)(%rdi), %rsp /* Load rsp from env[6] */
|
||||
/* Jump to saved PC */
|
||||
jmpq *%rdx /* Jump to rdx(PC) */
|
||||
|
||||
/****************************************************************/
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -149,6 +149,11 @@ if [ $SRS_CROSS_BUILD = YES ]; then
|
|||
else
|
||||
srs_undefine_macro "SRS_AUTO_CROSSBUILD" $SRS_AUTO_HEADERS_H
|
||||
fi
|
||||
if [ $SRS_OSX = YES ]; then
|
||||
srs_define_macro "SRS_AUTO_OSX" $SRS_AUTO_HEADERS_H
|
||||
else
|
||||
srs_undefine_macro "SRS_AUTO_OSX" $SRS_AUTO_HEADERS_H
|
||||
fi
|
||||
|
||||
# prefix
|
||||
echo "" >> $SRS_AUTO_HEADERS_H
|
||||
|
|
|
@ -118,6 +118,7 @@ function Ubuntu_prepare()
|
|||
if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
|
||||
Ubuntu_prepare; ret=$?; if [[ 0 -ne $ret ]]; then echo "Install tools for ubuntu failed, ret=$ret"; exit $ret; fi
|
||||
fi
|
||||
|
||||
#####################################################################################
|
||||
# for Centos, auto install tools by yum
|
||||
#####################################################################################
|
||||
|
@ -198,14 +199,105 @@ function Centos_prepare()
|
|||
if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
|
||||
Centos_prepare; ret=$?; if [[ 0 -ne $ret ]]; then echo "Install tools for CentOS failed, ret=$ret"; exit $ret; fi
|
||||
fi
|
||||
|
||||
#####################################################################################
|
||||
# For OSX, auto install tools by brew
|
||||
#####################################################################################
|
||||
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
|
||||
|
||||
# cross build for arm, install the cross build tool chain.
|
||||
if [ $SRS_CROSS_BUILD = YES ]; then
|
||||
echo "embeded(arm/mips) is invalid for OSX"
|
||||
return 1
|
||||
fi
|
||||
|
||||
OS_IS_OSX=YES
|
||||
echo "OSX detected, install tools if needed"
|
||||
# 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
|
||||
fi
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
OSX_prepare; ret=$?; if [[ 0 -ne $ret ]]; then echo "OSX prepare failed, ret=$ret"; exit $ret; fi
|
||||
fi
|
||||
|
||||
#####################################################################################
|
||||
# for Centos, auto install tools by yum
|
||||
#####################################################################################
|
||||
# We must use a bash function instead of variable.
|
||||
function sed_utility() {
|
||||
sed -i "$@"
|
||||
if [ $OS_IS_OSX = YES ]; then
|
||||
sed -i '' "$@"
|
||||
else
|
||||
sed -i "$@"
|
||||
fi
|
||||
|
||||
ret=$?; if [[ $ret -ne 0 ]]; then
|
||||
echo "sed -i \"$@\""
|
||||
if [ $OS_IS_OSX = YES ]; then
|
||||
echo "sed -i '' \"$@\""
|
||||
else
|
||||
echo "sed -i \"$@\""
|
||||
fi
|
||||
return $ret
|
||||
fi
|
||||
}
|
||||
|
@ -220,7 +312,7 @@ SED="sed_utility" && echo "SED is $SED"
|
|||
# directly build on arm/mips, for example, pi or cubie,
|
||||
# export srs-librtmp
|
||||
# others is invalid.
|
||||
if [[ $OS_IS_UBUNTU = NO && $OS_IS_CENTOS = NO && $SRS_EXPORT_LIBRTMP_PROJECT = NO ]]; then
|
||||
if [[ $OS_IS_UBUNTU = NO && $OS_IS_CENTOS = NO && $OS_IS_OSX = NO && $SRS_EXPORT_LIBRTMP_PROJECT = NO ]]; then
|
||||
if [[ $SRS_PI = NO && $SRS_CUBIE = NO && $SRS_CROSS_BUILD = NO ]]; then
|
||||
echo "Your OS `uname -s` is not supported."
|
||||
exit 1
|
||||
|
@ -232,10 +324,14 @@ fi
|
|||
#####################################################################################
|
||||
if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
|
||||
# check the cross build flag file, if flag changed, need to rebuild the st.
|
||||
_ST_MAKE=linux-debug && _ST_EXTRA_CFLAGS="-DMD_HAVE_EPOLL"
|
||||
_ST_MAKE=linux-debug && _ST_EXTRA_CFLAGS="-DMD_HAVE_EPOLL" && _ST_LD=${SRS_TOOL_LD}
|
||||
if [[ $SRS_VALGRIND == YES ]]; then
|
||||
_ST_EXTRA_CFLAGS="$_ST_EXTRA_CFLAGS -DMD_VALGRIND"
|
||||
fi
|
||||
# for osx, use darwin for st, donot use epoll.
|
||||
if [[ $SRS_OSX == YES ]]; then
|
||||
_ST_MAKE=darwin-debug && _ST_EXTRA_CFLAGS="-DMD_HAVE_KQUEUE" && _ST_LD=${SRS_TOOL_CC}
|
||||
fi
|
||||
# Pass the global extra flags.
|
||||
if [[ $SRS_EXTRA_FLAGS != '' ]]; then
|
||||
_ST_EXTRA_CFLAGS="$_ST_EXTRA_CFLAGS $SRS_EXTRA_FLAGS"
|
||||
|
@ -249,7 +345,7 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
|
|||
rm -rf ${SRS_OBJS}/st-srs && cd ${SRS_OBJS} &&
|
||||
ln -sf ../3rdparty/st-srs && cd st-srs &&
|
||||
make clean && make ${_ST_MAKE} EXTRA_CFLAGS="${_ST_EXTRA_CFLAGS}" \
|
||||
CC=${SRS_TOOL_CC} AR=${SRS_TOOL_AR} LD=${SRS_TOOL_LD} RANDLIB=${SRS_TOOL_RANDLIB} &&
|
||||
CC=${SRS_TOOL_CC} AR=${SRS_TOOL_AR} LD=${_ST_LD} RANDLIB=${SRS_TOOL_RANDLIB} &&
|
||||
cd .. && rm -f st && ln -sf st-srs/obj st
|
||||
)
|
||||
fi
|
||||
|
|
|
@ -23,7 +23,7 @@ SRS_NGINX=NO
|
|||
SRS_FFMPEG_TOOL=NO
|
||||
SRS_LIBRTMP=NO
|
||||
SRS_RESEARCH=NO
|
||||
SRS_UTEST=YES
|
||||
SRS_UTEST=NO
|
||||
SRS_GPERF=NO # Performance test: tcmalloc
|
||||
SRS_GPERF_MC=NO # Performance test: gperf memory check
|
||||
SRS_GPERF_MD=NO # Performance test: gperf memory defence
|
||||
|
@ -210,10 +210,6 @@ Remark:
|
|||
END
|
||||
}
|
||||
|
||||
function ignore_option() {
|
||||
echo "ignore option \"$option\""
|
||||
}
|
||||
|
||||
function parse_user_option() {
|
||||
case "$option" in
|
||||
-h) help=yes ;;
|
||||
|
@ -307,16 +303,16 @@ function parse_user_option() {
|
|||
--with-hls) SRS_HLS=YES ;;
|
||||
--with-dvr) SRS_DVR=YES ;;
|
||||
|
||||
--without-stream-caster) ignore_option ;;
|
||||
--without-ingest) ignore_option ;;
|
||||
--without-ssl) ignore_option ;;
|
||||
--without-stat) ignore_option ;;
|
||||
--without-transcode) ignore_option ;;
|
||||
--without-http-callback) ignore_option ;;
|
||||
--without-http-server) ignore_option ;;
|
||||
--without-http-api) ignore_option ;;
|
||||
--without-hls) ignore_option ;;
|
||||
--without-dvr) ignore_option ;;
|
||||
--without-stream-caster) echo "ignore option \"$option\"" ;;
|
||||
--without-ingest) echo "ignore option \"$option\"" ;;
|
||||
--without-ssl) echo "ignore option \"$option\"" ;;
|
||||
--without-stat) echo "ignore option \"$option\"" ;;
|
||||
--without-transcode) echo "ignore option \"$option\"" ;;
|
||||
--without-http-callback) echo "ignore option \"$option\"" ;;
|
||||
--without-http-server) echo "ignore option \"$option\"" ;;
|
||||
--without-http-api) echo "ignore option \"$option\"" ;;
|
||||
--without-hls) echo "ignore option \"$option\"" ;;
|
||||
--without-dvr) echo "ignore option \"$option\"" ;;
|
||||
|
||||
*)
|
||||
echo "$0: error: invalid option \"$option\""
|
||||
|
@ -407,7 +403,7 @@ function apply_user_presets() {
|
|||
SRS_HDS=YES
|
||||
SRS_LIBRTMP=YES
|
||||
SRS_RESEARCH=NO
|
||||
SRS_UTEST=YES
|
||||
SRS_UTEST=NO
|
||||
SRS_STATIC=NO
|
||||
fi
|
||||
|
||||
|
@ -434,7 +430,7 @@ function apply_user_presets() {
|
|||
SRS_HDS=YES
|
||||
SRS_LIBRTMP=YES
|
||||
SRS_RESEARCH=NO
|
||||
SRS_UTEST=YES
|
||||
SRS_UTEST=NO
|
||||
SRS_STATIC=NO
|
||||
fi
|
||||
|
||||
|
@ -587,16 +583,16 @@ function check_option_conflicts() {
|
|||
echo "For crossbuild, must not use default toolchain, cc: $SRS_TOOL_CC, cxx: $SRS_TOOL_CXX, ar: $SRS_TOOL_AR"; exit -1
|
||||
fi
|
||||
|
||||
if [ $SRS_OSX = YES ]; then
|
||||
echo "We don't support OSX, please use docker https://github.com/ossrs/srs-docker"; exit -1
|
||||
fi
|
||||
|
||||
if [[ $SRS_NGINX == YES ]]; then
|
||||
echo "Don't support building NGINX, please use docker https://github.com/ossrs/srs-docker"; exit -1
|
||||
echo "Don't support building NGINX, please use docker https://github.com/ossrs/srs-docker"; exit -1;
|
||||
fi
|
||||
|
||||
if [[ $SRS_FFMPEG_TOOL == YES ]]; then
|
||||
echo "Don't support building FFMPEG, please use docker https://github.com/ossrs/srs-docker"; exit -1
|
||||
echo "Don't support building FFMPEG, please use docker https://github.com/ossrs/srs-docker"; exit -1;
|
||||
fi
|
||||
|
||||
if [[ $SRS_OSX == YES && $SRS_UTEST == YES ]]; then
|
||||
echo "Mac does not support utest."; exit -1;
|
||||
fi
|
||||
|
||||
# TODO: FIXME: check more os.
|
||||
|
|
|
@ -58,7 +58,7 @@ function user_extra_params(query, params) {
|
|||
|| key === 'filename' || key === 'host' || key === 'hostname'
|
||||
|| key === 'http_port' || key === 'pathname' || key === 'port'
|
||||
|| key === 'server' || key === 'stream' || key === 'buffer'
|
||||
|| key === 'schema' || key === 'vhost'
|
||||
|| key === 'schema' || key === 'vhost' || key === 'api'
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
@ -211,6 +211,7 @@ function build_default_rtc_url(query) {
|
|||
var vhost = (!query.vhost)? window.location.hostname:query.vhost;
|
||||
var app = (!query.app)? "live":query.app;
|
||||
var stream = (!query.stream)? "livestream":query.stream;
|
||||
var api = query.api? ':'+query.api : '';
|
||||
|
||||
// Note that ossrs.net provides only web service,
|
||||
// that is migrating to r.ossrs.net
|
||||
|
@ -227,7 +228,7 @@ function build_default_rtc_url(query) {
|
|||
}
|
||||
queries = user_extra_params(query, queries);
|
||||
|
||||
var uri = "webrtc://" + server + "/" + app + "/" + stream + "?" + queries.join('&');
|
||||
var uri = "webrtc://" + server + api + "/" + app + "/" + stream + "?" + queries.join('&');
|
||||
while (uri.lastIndexOf("?") == uri.length - 1) {
|
||||
uri = uri.substr(0, uri.length - 1);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* depends: jquery1.10
|
||||
* https://gitee.com/winlinvip/codes/rpn0c2ewbomj81augzk4y59
|
||||
* @see: http://blog.csdn.net/win_lin/article/details/17994347
|
||||
* v 1.0.19
|
||||
* v 1.0.20
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -293,7 +293,9 @@ function __fill_query(query_string, obj) {
|
|||
function parse_rtmp_url(rtmp_url) {
|
||||
// @see: http://stackoverflow.com/questions/10469575/how-to-use-location-object-to-parse-url-without-redirecting-the-page-in-javascri
|
||||
var a = document.createElement("a");
|
||||
a.href = rtmp_url.replace("rtmp://", "http://").replace("webrtc://", "http://");
|
||||
a.href = rtmp_url.replace("rtmp://", "http://")
|
||||
.replace("webrtc://", "http://")
|
||||
.replace("rtc://", "http://");
|
||||
|
||||
var vhost = a.hostname;
|
||||
var app = a.pathname.substr(1, a.pathname.lastIndexOf("/") - 1);
|
||||
|
@ -327,7 +329,19 @@ function parse_rtmp_url(rtmp_url) {
|
|||
if (rtmp_url.indexOf("://") > 0) {
|
||||
schema = rtmp_url.substr(0, rtmp_url.indexOf("://"));
|
||||
}
|
||||
var port = (a.port == "")? (schema=="http"?"80":"1935"):a.port;
|
||||
|
||||
var port = a.port;
|
||||
if (!port) {
|
||||
if (schema === 'http') {
|
||||
port = 80;
|
||||
} else if (schema === 'https') {
|
||||
port = 443;
|
||||
} else if (schema === 'rtmp') {
|
||||
port = 1935;
|
||||
} else if (schema === 'webrtc' || schema === 'rtc') {
|
||||
port = 1985;
|
||||
}
|
||||
}
|
||||
|
||||
var ret = {
|
||||
url: rtmp_url,
|
||||
|
|
|
@ -94,7 +94,7 @@
|
|||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<img src='https://ossrs.net:8443/gif/v1/sls.gif?site=ossrs.net&path=/player/jwplayer'/>
|
||||
<img src='https://ossrs.net/gif/v1/sls.gif?site=ossrs.net&path=/player/jwplayer'/>
|
||||
<div class="navbar navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container">
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<img src='https://ossrs.net:8443/gif/v1/sls.gif?site=ossrs.net&path=/player/osmf'/>
|
||||
<img src='https://ossrs.net/gif/v1/sls.gif?site=ossrs.net&path=/player/osmf'/>
|
||||
<div class="navbar navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container">
|
||||
|
|
|
@ -15,9 +15,7 @@
|
|||
<script type="text/javascript" src="js/srs.page.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<!--
|
||||
<img src='https://ossrs.net:8443/gif/v1/sls.gif?site=ossrs.net&path=/player/srsplayer'/>
|
||||
-->
|
||||
<img src='https://ossrs.net/gif/v1/sls.gif?site=ossrs.net&path=/player/rtc'/>
|
||||
<div class="navbar navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container">
|
||||
|
@ -58,7 +56,7 @@
|
|||
var startPlay = function() {
|
||||
$('#rtc_media_player').show();
|
||||
var urlObject = parse_rtmp_url($("#txt_url").val());
|
||||
var schame = window.location.protocol;
|
||||
var schema = window.location.protocol;
|
||||
|
||||
// Close PC when user replay.
|
||||
if (pc) {
|
||||
|
@ -84,7 +82,7 @@
|
|||
return pc.setLocalDescription(offer).then(function(){ return offer; });
|
||||
}).then(function(offer) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
var port = urlObject.user_query.api || 1985;
|
||||
var port = urlObject.port || 1985;
|
||||
|
||||
// @see https://github.com/rtcdn/rtcdn-draft
|
||||
var api = urlObject.user_query.play || '/rtc/v1/play/';
|
||||
|
@ -92,7 +90,7 @@
|
|||
api += '/';
|
||||
}
|
||||
|
||||
var url = schame + '//' + urlObject.server + ':' + port + api;
|
||||
var url = schema + '//' + urlObject.server + ':' + port + api;
|
||||
for (var key in urlObject.user_query) {
|
||||
if (key != 'api' && key != 'play') {
|
||||
url += '&' + key + '=' + urlObject.user_query[key];
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<img src='https://ossrs.net:8443/gif/v1/sls.gif?site=ossrs.net&path=/player/bwt'/>
|
||||
<img src='https://ossrs.net/gif/v1/sls.gif?site=ossrs.net&path=/player/bwt'/>
|
||||
<div class="navbar navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container">
|
||||
|
@ -23,6 +23,7 @@
|
|||
<div class="nav-collapse collapse">
|
||||
<ul class="nav">
|
||||
<li><a id="nav_srs_player" href="srs_player.html">SRS播放器</a></li>
|
||||
<li><a id="nav_rtc_player" href="rtc_player.html">RTC播放器</a></li>
|
||||
<li><a id="nav_srs_publisher" href="srs_publisher.html">SRS编码器</a></li>
|
||||
<li><a id="nav_srs_chat" href="srs_chat.html">SRS会议</a></li>
|
||||
<li class="active"><a id="nav_srs_bwt" href="srs_bwt.html">SRS测网速</a></li>
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<img src='https://ossrs.net:8443/gif/v1/sls.gif?site=ossrs.net&path=/player/chat'/>
|
||||
<img src='https://ossrs.net/gif/v1/sls.gif?site=ossrs.net&path=/player/chat'/>
|
||||
<div class="navbar navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container">
|
||||
|
@ -22,6 +22,7 @@
|
|||
<div class="nav-collapse collapse">
|
||||
<ul class="nav">
|
||||
<li><a id="nav_srs_player" href="srs_player.html">SRS播放器</a></li>
|
||||
<li><a id="nav_rtc_player" href="rtc_player.html">RTC播放器</a></li>
|
||||
<li><a id="nav_srs_publisher" href="srs_publisher.html">SRS编码器</a></li>
|
||||
<li class="active"><a id="nav_srs_chat" href="srs_chat.html">SRS会议</a></li>
|
||||
<li><a id="nav_srs_bwt" href="srs_bwt.html">SRS测网速</a></li>
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<img src='https://ossrs.net:8443/gif/v1/sls.gif?site=ossrs.net&path=/player/srsplayer'/>
|
||||
<img src='https://ossrs.net/gif/v1/sls.gif?site=ossrs.net&path=/player/srsplayer'/>
|
||||
<div class="navbar navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container">
|
||||
|
@ -33,6 +33,7 @@
|
|||
<div class="nav-collapse collapse">
|
||||
<ul class="nav">
|
||||
<li class="active"><a id="nav_srs_player" href="srs_player.html">SRS播放器</a></li>
|
||||
<li><a id="nav_rtc_player" href="rtc_player.html">RTC播放器</a></li>
|
||||
<li><a id="nav_srs_publisher" href="srs_publisher.html">SRS编码器</a></li>
|
||||
<li><a id="nav_srs_chat" href="srs_chat.html">SRS会议</a></li>
|
||||
<li><a id="nav_srs_bwt" href="srs_bwt.html">SRS测网速</a></li>
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<img src='https://ossrs.net:8443/gif/v1/sls.gif?site=ossrs.net&path=/player/obs'/>
|
||||
<img src='https://ossrs.net/gif/v1/sls.gif?site=ossrs.net&path=/player/obs'/>
|
||||
<div class="navbar navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container">
|
||||
|
@ -22,6 +22,7 @@
|
|||
<div class="nav-collapse collapse">
|
||||
<ul class="nav">
|
||||
<li><a id="nav_srs_player" href="srs_player.html">SRS播放器</a></li>
|
||||
<li><a id="nav_rtc_player" href="rtc_player.html">RTC播放器</a></li>
|
||||
<li class="active"><a id="nav_srs_publisher" href="srs_publisher.html">SRS编码器</a></li>
|
||||
<li><a id="nav_srs_chat" href="srs_chat.html">SRS会议</a></li>
|
||||
<li><a id="nav_srs_bwt" href="srs_bwt.html">SRS测网速</a></li>
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<img src='https://ossrs.net:8443/gif/v1/sls.gif?site=ossrs.net&path=/player/srspublisher'/>
|
||||
<img src='https://ossrs.net/gif/v1/sls.gif?site=ossrs.net&path=/player/srspublisher'/>
|
||||
<div class="navbar navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container">
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<img src='https://ossrs.net:8443/gif/v1/sls.gif?site=ossrs.net&path=/player/vlc'/>
|
||||
<img src='https://ossrs.net/gif/v1/sls.gif?site=ossrs.net&path=/player/vlc'/>
|
||||
<div class="navbar navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container">
|
||||
|
@ -19,6 +19,7 @@
|
|||
<div class="nav-collapse collapse">
|
||||
<ul class="nav">
|
||||
<li><a id="nav_srs_player" href="srs_player.html">SRS播放器</a></li>
|
||||
<li><a id="nav_rtc_player" href="rtc_player.html">RTC播放器</a></li>
|
||||
<li><a id="nav_srs_publisher" href="srs_publisher.html">SRS编码器</a></li>
|
||||
<li><a id="nav_srs_chat" href="srs_chat.html">SRS会议</a></li>
|
||||
<li><a id="nav_srs_bwt" href="srs_bwt.html">SRS测网速</a></li>
|
||||
|
|
|
@ -198,19 +198,32 @@ srs_error_t SrsResponseOnlyHttpConn::pop_message(ISrsHttpMessage** preq)
|
|||
srs_error_t err = srs_success;
|
||||
|
||||
SrsStSocket skt;
|
||||
|
||||
|
||||
if ((err = skt.initialize(stfd)) != srs_success) {
|
||||
return srs_error_wrap(err, "init socket");
|
||||
}
|
||||
|
||||
if ((err = parser->parse_message(&skt, preq)) != srs_success) {
|
||||
return srs_error_wrap(err, "parse message");
|
||||
|
||||
// Check user interrupt by interval.
|
||||
skt.set_recv_timeout(3 * SRS_UTIME_SECONDS);
|
||||
|
||||
// drop all request body.
|
||||
char body[4096];
|
||||
while (true) {
|
||||
if ((err = trd->pull()) != srs_success) {
|
||||
return srs_error_wrap(err, "timeout");
|
||||
}
|
||||
|
||||
if ((err = skt.read(body, 4096, NULL)) != srs_success) {
|
||||
// Because we use timeout to check trd state, so we should ignore any timeout.
|
||||
if (srs_error_code(err) == ERROR_SOCKET_TIMEOUT) {
|
||||
srs_freep(err);
|
||||
continue;
|
||||
}
|
||||
|
||||
return srs_error_wrap(err, "read response");
|
||||
}
|
||||
}
|
||||
|
||||
// Attach owner connection to message.
|
||||
SrsHttpMessage* hreq = (SrsHttpMessage*)(*preq);
|
||||
hreq->set_connection(this);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
@ -219,12 +232,12 @@ srs_error_t SrsResponseOnlyHttpConn::on_got_http_message(ISrsHttpMessage* msg)
|
|||
srs_error_t err = srs_success;
|
||||
|
||||
ISrsHttpResponseReader* br = msg->body_reader();
|
||||
|
||||
|
||||
// when not specified the content length, ignore.
|
||||
if (msg->content_length() == -1) {
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
// drop all request body.
|
||||
char body[4096];
|
||||
while (!br->eof()) {
|
||||
|
@ -236,6 +249,11 @@ srs_error_t SrsResponseOnlyHttpConn::on_got_http_message(ISrsHttpMessage* msg)
|
|||
return err;
|
||||
}
|
||||
|
||||
void SrsResponseOnlyHttpConn::expire()
|
||||
{
|
||||
SrsHttpConn::expire();
|
||||
}
|
||||
|
||||
SrsHttpServer::SrsHttpServer(SrsServer* svr)
|
||||
{
|
||||
server = svr;
|
||||
|
|
|
@ -101,6 +101,9 @@ public:
|
|||
virtual srs_error_t pop_message(ISrsHttpMessage** preq);
|
||||
public:
|
||||
virtual srs_error_t on_got_http_message(ISrsHttpMessage* msg);
|
||||
public:
|
||||
// Set connection to expired.
|
||||
virtual void expire();
|
||||
};
|
||||
|
||||
// The http server, use http stream or static server to serve requests.
|
||||
|
|
|
@ -593,10 +593,15 @@ srs_error_t SrsLiveStream::do_serve_http(ISrsHttpResponseWriter* w, ISrsHttpMess
|
|||
SrsAutoFree(SrsPithyPrint, pprint);
|
||||
|
||||
SrsMessageArray msgs(SRS_PERF_MW_MSGS);
|
||||
|
||||
// Use receive thread to accept the close event to avoid FD leak.
|
||||
// @see https://github.com/ossrs/srs/issues/636#issuecomment-298208427
|
||||
SrsHttpMessage* hr = dynamic_cast<SrsHttpMessage*>(r);
|
||||
SrsResponseOnlyHttpConn* hc = dynamic_cast<SrsResponseOnlyHttpConn*>(hr->connection());
|
||||
|
||||
// update the statistic when source disconveried.
|
||||
SrsStatistic* stat = SrsStatistic::instance();
|
||||
if ((err = stat->on_client(_srs_context->get_id(), req, NULL, SrsRtmpConnPlay)) != srs_success) {
|
||||
if ((err = stat->on_client(_srs_context->get_id(), req, hc, SrsRtmpConnPlay)) != srs_success) {
|
||||
return srs_error_wrap(err, "stat on client");
|
||||
}
|
||||
|
||||
|
@ -614,11 +619,6 @@ srs_error_t SrsLiveStream::do_serve_http(ISrsHttpResponseWriter* w, ISrsHttpMess
|
|||
}
|
||||
|
||||
SrsFlvStreamEncoder* ffe = dynamic_cast<SrsFlvStreamEncoder*>(enc);
|
||||
|
||||
// Use receive thread to accept the close event to avoid FD leak.
|
||||
// @see https://github.com/ossrs/srs/issues/636#issuecomment-298208427
|
||||
SrsHttpMessage* hr = dynamic_cast<SrsHttpMessage*>(r);
|
||||
SrsResponseOnlyHttpConn* hc = dynamic_cast<SrsResponseOnlyHttpConn*>(hr->connection());
|
||||
|
||||
// Set the socket options for transport.
|
||||
bool tcp_nodelay = _srs_config->get_tcp_nodelay(req->vhost);
|
||||
|
|
|
@ -30,7 +30,9 @@
|
|||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <algorithm>
|
||||
#ifndef SRS_AUTO_OSX
|
||||
#include <sys/inotify.h>
|
||||
#endif
|
||||
using namespace std;
|
||||
|
||||
#include <srs_kernel_log.hpp>
|
||||
|
@ -481,6 +483,7 @@ srs_error_t SrsInotifyWorker::start()
|
|||
{
|
||||
srs_error_t err = srs_success;
|
||||
|
||||
#ifndef SRS_AUTO_OSX
|
||||
// Whether enable auto reload config.
|
||||
bool auto_reload = _srs_config->inotify_auto_reload();
|
||||
if (!auto_reload && _srs_in_docker && _srs_config->auto_reload_for_docker()) {
|
||||
|
@ -551,6 +554,7 @@ srs_error_t SrsInotifyWorker::start()
|
|||
if ((err = trd->start()) != srs_success) {
|
||||
return srs_error_wrap(err, "inotify");
|
||||
}
|
||||
#endif
|
||||
|
||||
return err;
|
||||
}
|
||||
|
@ -559,6 +563,7 @@ srs_error_t SrsInotifyWorker::cycle()
|
|||
{
|
||||
srs_error_t err = srs_success;
|
||||
|
||||
#ifndef SRS_AUTO_OSX
|
||||
string config_path = _srs_config->config();
|
||||
string config_file = srs_path_basename(config_path);
|
||||
string k8s_file = "..data";
|
||||
|
@ -598,6 +603,7 @@ srs_error_t SrsInotifyWorker::cycle()
|
|||
|
||||
srs_usleep(3000 * SRS_UTIME_MILLISECONDS);
|
||||
}
|
||||
#endif
|
||||
|
||||
return err;
|
||||
}
|
||||
|
@ -761,7 +767,7 @@ srs_error_t SrsServer::initialize(ISrsServerCycle* ch)
|
|||
srs_error_t SrsServer::initialize_st()
|
||||
{
|
||||
srs_error_t err = srs_success;
|
||||
|
||||
|
||||
// @remark, st alloc segment use mmap, which only support 32757 threads,
|
||||
// if need to support more, for instance, 100k threads, define the macro MALLOC_STACK.
|
||||
// TODO: FIXME: maybe can use "sysctl vm.max_map_count" to refine.
|
||||
|
|
|
@ -35,6 +35,9 @@
|
|||
#include <sys/time.h>
|
||||
#include <math.h>
|
||||
#include <map>
|
||||
#ifdef SRS_AUTO_OSX
|
||||
#include <sys/sysctl.h>
|
||||
#endif
|
||||
using namespace std;
|
||||
|
||||
#include <srs_kernel_log.hpp>
|
||||
|
@ -326,6 +329,7 @@ SrsProcSystemStat* srs_get_system_proc_stat()
|
|||
|
||||
bool get_proc_system_stat(SrsProcSystemStat& r)
|
||||
{
|
||||
#ifndef SRS_AUTO_OSX
|
||||
FILE* f = fopen("/proc/stat", "r");
|
||||
if (f == NULL) {
|
||||
srs_warn("open system cpu stat failed, ignore");
|
||||
|
@ -355,6 +359,7 @@ bool get_proc_system_stat(SrsProcSystemStat& r)
|
|||
}
|
||||
|
||||
fclose(f);
|
||||
#endif
|
||||
|
||||
r.ok = true;
|
||||
|
||||
|
@ -363,6 +368,7 @@ bool get_proc_system_stat(SrsProcSystemStat& r)
|
|||
|
||||
bool get_proc_self_stat(SrsProcSelfStat& r)
|
||||
{
|
||||
#ifndef SRS_AUTO_OSX
|
||||
FILE* f = fopen("/proc/self/stat", "r");
|
||||
if (f == NULL) {
|
||||
srs_warn("open self cpu stat failed, ignore");
|
||||
|
@ -389,6 +395,7 @@ bool get_proc_self_stat(SrsProcSelfStat& r)
|
|||
&r.guest_time, &r.cguest_time);
|
||||
|
||||
fclose(f);
|
||||
#endif
|
||||
|
||||
r.ok = true;
|
||||
|
||||
|
@ -484,6 +491,7 @@ SrsDiskStat* srs_get_disk_stat()
|
|||
|
||||
bool srs_get_disk_vmstat_stat(SrsDiskStat& r)
|
||||
{
|
||||
#ifndef SRS_AUTO_OSX
|
||||
FILE* f = fopen("/proc/vmstat", "r");
|
||||
if (f == NULL) {
|
||||
srs_warn("open vmstat failed, ignore");
|
||||
|
@ -503,6 +511,7 @@ bool srs_get_disk_vmstat_stat(SrsDiskStat& r)
|
|||
}
|
||||
|
||||
fclose(f);
|
||||
#endif
|
||||
|
||||
r.ok = true;
|
||||
|
||||
|
@ -513,13 +522,14 @@ bool srs_get_disk_diskstats_stat(SrsDiskStat& r)
|
|||
{
|
||||
r.ok = true;
|
||||
r.sample_time = srsu2ms(srs_get_system_time());
|
||||
|
||||
|
||||
#ifndef SRS_AUTO_OSX
|
||||
// if disabled, ignore all devices.
|
||||
SrsConfDirective* conf = _srs_config->get_stats_disk_device();
|
||||
if (conf == NULL) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
FILE* f = fopen("/proc/diskstats", "r");
|
||||
if (f == NULL) {
|
||||
srs_warn("open vmstat failed, ignore");
|
||||
|
@ -584,6 +594,7 @@ bool srs_get_disk_diskstats_stat(SrsDiskStat& r)
|
|||
}
|
||||
|
||||
fclose(f);
|
||||
#endif
|
||||
|
||||
r.ok = true;
|
||||
|
||||
|
@ -675,7 +686,8 @@ SrsMemInfo* srs_get_meminfo()
|
|||
void srs_update_meminfo()
|
||||
{
|
||||
SrsMemInfo& r = _srs_system_meminfo;
|
||||
|
||||
|
||||
#ifndef SRS_AUTO_OSX
|
||||
FILE* f = fopen("/proc/meminfo", "r");
|
||||
if (f == NULL) {
|
||||
srs_warn("open meminfo failed, ignore");
|
||||
|
@ -701,6 +713,7 @@ void srs_update_meminfo()
|
|||
}
|
||||
|
||||
fclose(f);
|
||||
#endif
|
||||
|
||||
r.sample_time = srsu2ms(srs_get_system_time());
|
||||
r.MemActive = r.MemTotal - r.MemFree;
|
||||
|
@ -767,7 +780,8 @@ void srs_update_platform_info()
|
|||
SrsPlatformInfo& r = _srs_system_platform_info;
|
||||
|
||||
r.srs_startup_time = srsu2ms(srs_get_system_startup_time());
|
||||
|
||||
|
||||
#ifndef SRS_AUTO_OSX
|
||||
if (true) {
|
||||
FILE* f = fopen("/proc/uptime", "r");
|
||||
if (f == NULL) {
|
||||
|
@ -796,7 +810,44 @@ void srs_update_platform_info()
|
|||
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
#else
|
||||
// man 3 sysctl
|
||||
if (true) {
|
||||
struct timeval tv;
|
||||
size_t len = sizeof(timeval);
|
||||
|
||||
int mib[2];
|
||||
mib[0] = CTL_KERN;
|
||||
mib[1] = KERN_BOOTTIME;
|
||||
if (sysctl(mib, 2, &tv, &len, NULL, 0) < 0) {
|
||||
srs_warn("sysctl boottime failed, ignore");
|
||||
return;
|
||||
}
|
||||
|
||||
time_t bsec = tv.tv_sec;
|
||||
time_t csec = ::time(NULL);
|
||||
r.os_uptime = difftime(csec, bsec);
|
||||
}
|
||||
|
||||
// man 3 sysctl
|
||||
if (true) {
|
||||
struct loadavg la;
|
||||
size_t len = sizeof(loadavg);
|
||||
|
||||
int mib[2];
|
||||
mib[0] = CTL_VM;
|
||||
mib[1] = VM_LOADAVG;
|
||||
if (sysctl(mib, 2, &la, &len, NULL, 0) < 0) {
|
||||
srs_warn("sysctl loadavg failed, ignore");
|
||||
return;
|
||||
}
|
||||
|
||||
r.load_one_minutes = (double)la.ldavg[0] / la.fscale;
|
||||
r.load_five_minutes = (double)la.ldavg[1] / la.fscale;
|
||||
r.load_fifteen_minutes = (double)la.ldavg[2] / la.fscale;
|
||||
}
|
||||
#endif
|
||||
|
||||
r.ok = true;
|
||||
}
|
||||
|
||||
|
@ -842,6 +893,7 @@ int srs_get_network_devices_count()
|
|||
|
||||
void srs_update_network_devices()
|
||||
{
|
||||
#ifndef SRS_AUTO_OSX
|
||||
if (true) {
|
||||
FILE* f = fopen("/proc/net/dev", "r");
|
||||
if (f == NULL) {
|
||||
|
@ -878,6 +930,7 @@ void srs_update_network_devices()
|
|||
|
||||
fclose(f);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
SrsNetworkRtmpServer::SrsNetworkRtmpServer()
|
||||
|
@ -924,7 +977,8 @@ void srs_update_rtmp_server(int nb_conn, SrsKbps* kbps)
|
|||
int nb_tcp_total = 0;
|
||||
int nb_tcp_mem = 0;
|
||||
int nb_udp4 = 0;
|
||||
|
||||
|
||||
#ifndef SRS_AUTO_OSX
|
||||
if (true) {
|
||||
FILE* f = fopen("/proc/net/sockstat", "r");
|
||||
if (f == NULL) {
|
||||
|
@ -954,9 +1008,20 @@ void srs_update_rtmp_server(int nb_conn, SrsKbps* kbps)
|
|||
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
#else
|
||||
// TODO: FIXME: impelments it.
|
||||
nb_socks = 0;
|
||||
nb_tcp4_hashed = 0;
|
||||
nb_tcp_orphans = 0;
|
||||
nb_tcp_tws = 0;
|
||||
nb_tcp_total = 0;
|
||||
nb_tcp_mem = 0;
|
||||
nb_udp4 = 0;
|
||||
#endif
|
||||
|
||||
int nb_tcp_estab = 0;
|
||||
|
||||
|
||||
#ifndef SRS_AUTO_OSX
|
||||
if (true) {
|
||||
FILE* f = fopen("/proc/net/snmp", "r");
|
||||
if (f == NULL) {
|
||||
|
@ -986,6 +1051,7 @@ void srs_update_rtmp_server(int nb_conn, SrsKbps* kbps)
|
|||
|
||||
fclose(f);
|
||||
}
|
||||
#endif
|
||||
|
||||
// @see: https://github.com/shemminger/iproute2/blob/master/misc/ss.c
|
||||
// TODO: FIXME: ignore the slabstat, @see: get_slabstat()
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
#define RTMP_SIG_SRS_CODE "Leo"
|
||||
#define RTMP_SIG_SRS_URL "https://github.com/ossrs/srs"
|
||||
#define RTMP_SIG_SRS_LICENSE "MIT"
|
||||
#define RTMP_SIG_SRS_AUTHORS "winlin,wenjie,runner365"
|
||||
#define RTMP_SIG_SRS_AUTHORS "Winlin,Wenjie,Runner365,John,B.P.Y"
|
||||
#define RTMP_SIG_SRS_VERSION SRS_XSTR(VERSION_MAJOR) "." SRS_XSTR(VERSION_MINOR) "." SRS_XSTR(VERSION_REVISION)
|
||||
#define RTMP_SIG_SRS_SERVER RTMP_SIG_SRS_KEY "/" RTMP_SIG_SRS_VERSION "(" RTMP_SIG_SRS_CODE ")"
|
||||
|
||||
|
|
|
@ -24,6 +24,6 @@
|
|||
#ifndef SRS_CORE_VERSION3_HPP
|
||||
#define SRS_CORE_VERSION3_HPP
|
||||
|
||||
#define SRS_VERSION3_REVISION 134
|
||||
#define SRS_VERSION3_REVISION 138
|
||||
|
||||
#endif
|
||||
|
|
|
@ -24,6 +24,6 @@
|
|||
#ifndef SRS_CORE_VERSION4_HPP
|
||||
#define SRS_CORE_VERSION4_HPP
|
||||
|
||||
#define SRS_VERSION4_REVISION 14
|
||||
#define SRS_VERSION4_REVISION 15
|
||||
|
||||
#endif
|
||||
|
|
|
@ -124,7 +124,9 @@ srs_utime_t srs_get_system_startup_time()
|
|||
}
|
||||
|
||||
// For utest to mock it.
|
||||
#ifndef SRS_AUTO_OSX
|
||||
_srs_gettimeofday_t _srs_gettimeofday = ::gettimeofday;
|
||||
#endif
|
||||
|
||||
srs_utime_t srs_update_system_time()
|
||||
{
|
||||
|
|
|
@ -166,7 +166,11 @@ extern int srs_chunk_header_c3(int perfer_cid, uint32_t timestamp, char* cache,
|
|||
|
||||
// For utest to mock it.
|
||||
#include <sys/time.h>
|
||||
typedef int (*_srs_gettimeofday_t)(struct timeval* tv, struct timezone* tz);
|
||||
#ifdef SRS_AUTO_OSX
|
||||
#define _srs_gettimeofday gettimeofday
|
||||
#else
|
||||
typedef int (*_srs_gettimeofday_t) (struct timeval* tv, struct timezone* tz);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -129,8 +129,8 @@ srs_error_t do_main(int argc, char** argv)
|
|||
srs_trace("%s, %s", RTMP_SIG_SRS_SERVER, RTMP_SIG_SRS_LICENSE);
|
||||
srs_trace("authors: %s", RTMP_SIG_SRS_AUTHORS);
|
||||
srs_trace("contributors: %s", SRS_AUTO_CONSTRIBUTORS);
|
||||
srs_trace("cwd=%s, work_dir=%s, build: %s, configure: %s, uname: %s",
|
||||
_srs_config->cwd().c_str(), cwd.c_str(), SRS_AUTO_BUILD_DATE, SRS_AUTO_USER_CONFIGURE, SRS_AUTO_UNAME);
|
||||
srs_trace("cwd=%s, work_dir=%s, build: %s, configure: %s, uname: %s, osx: %d",
|
||||
_srs_config->cwd().c_str(), cwd.c_str(), SRS_AUTO_BUILD_DATE, SRS_AUTO_USER_CONFIGURE, SRS_AUTO_UNAME, SRS_AUTO_OSX_BOOL);
|
||||
srs_trace("configure detail: " SRS_AUTO_CONFIGURE);
|
||||
#ifdef SRS_AUTO_EMBEDED_TOOL_CHAIN
|
||||
srs_trace("crossbuild tool chain: " SRS_AUTO_EMBEDED_TOOL_CHAIN);
|
||||
|
|
|
@ -336,21 +336,25 @@ srs_error_t srs_write_large_iovs(ISrsProtocolReadWriter* skt, iovec* iovs, int s
|
|||
#endif
|
||||
|
||||
// send in a time.
|
||||
if (size < limits) {
|
||||
if (size <= limits) {
|
||||
if ((err = skt->writev(iovs, size, pnwrite)) != srs_success) {
|
||||
return srs_error_wrap(err, "writev");
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
// send in multiple times.
|
||||
int cur_iov = 0;
|
||||
ssize_t nwrite = 0;
|
||||
while (cur_iov < size) {
|
||||
int cur_count = srs_min(limits, size - cur_iov);
|
||||
if ((err = skt->writev(iovs + cur_iov, cur_count, pnwrite)) != srs_success) {
|
||||
if ((err = skt->writev(iovs + cur_iov, cur_count, &nwrite)) != srs_success) {
|
||||
return srs_error_wrap(err, "writev");
|
||||
}
|
||||
cur_iov += cur_count;
|
||||
if (pnwrite) {
|
||||
*pnwrite += nwrite;
|
||||
}
|
||||
}
|
||||
|
||||
return err;
|
||||
|
|
|
@ -46,7 +46,7 @@ int SrsThreadContext::generate_id()
|
|||
static int id = 0;
|
||||
|
||||
if (id == 0) {
|
||||
id = (100 + ((int)(int64_t)this)%1000);
|
||||
id = (100 + ((uint32_t)(int64_t)this)%1000);
|
||||
}
|
||||
|
||||
int gid = id++;
|
||||
|
|
|
@ -4208,6 +4208,7 @@ VOID TEST(KernelUtilityTest, CoverBitsBufferAll)
|
|||
}
|
||||
}
|
||||
|
||||
#ifndef SRS_AUTO_OSX
|
||||
extern _srs_gettimeofday_t _srs_gettimeofday;
|
||||
int mock_gettimeofday(struct timeval* /*tp*/, struct timezone* /*tzp*/) {
|
||||
return -1;
|
||||
|
@ -4238,6 +4239,7 @@ VOID TEST(KernelUtilityTest, CoverTimeSpecial)
|
|||
EXPECT_TRUE(-1 == srs_update_system_time());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
extern int64_t _srs_system_time_startup_time;
|
||||
extern int64_t _srs_system_time_us_cache;
|
||||
|
|
|
@ -230,8 +230,6 @@ srs_error_t MockBufferIO::writev(const iovec *iov, int iov_size, ssize_t* nwrite
|
|||
total += writen;
|
||||
}
|
||||
|
||||
sbytes += total;
|
||||
|
||||
if (nwrite) {
|
||||
*nwrite = total;
|
||||
}
|
||||
|
@ -6412,3 +6410,65 @@ VOID TEST(ProtocolKbpsTest, RAWStatistic)
|
|||
}
|
||||
}
|
||||
|
||||
VOID TEST(ProtocolKbpsTest, WriteLargeIOVs)
|
||||
{
|
||||
srs_error_t err;
|
||||
|
||||
if (true) {
|
||||
iovec iovs[1];
|
||||
iovs[0].iov_base = (char*)"Hello";
|
||||
iovs[0].iov_len = 5;
|
||||
|
||||
MockBufferIO io;
|
||||
ssize_t nn = 0;
|
||||
HELPER_EXPECT_SUCCESS(srs_write_large_iovs(&io, iovs, 1, &nn));
|
||||
EXPECT_EQ(5, nn);
|
||||
EXPECT_EQ(5, io.sbytes);
|
||||
}
|
||||
|
||||
if (true) {
|
||||
iovec iovs[1024];
|
||||
int nn_iovs = (int)(sizeof(iovs)/sizeof(iovec));
|
||||
for (int i = 0; i < nn_iovs; i++) {
|
||||
iovs[i].iov_base = (char*)"Hello";
|
||||
iovs[i].iov_len = 5;
|
||||
}
|
||||
|
||||
MockBufferIO io;
|
||||
ssize_t nn = 0;
|
||||
HELPER_EXPECT_SUCCESS(srs_write_large_iovs(&io, iovs, nn_iovs, &nn));
|
||||
EXPECT_EQ(5 * nn_iovs, nn);
|
||||
EXPECT_EQ(5 * nn_iovs, io.sbytes);
|
||||
}
|
||||
|
||||
if (true) {
|
||||
iovec iovs[1025];
|
||||
int nn_iovs = (int)(sizeof(iovs)/sizeof(iovec));
|
||||
for (int i = 0; i < nn_iovs; i++) {
|
||||
iovs[i].iov_base = (char*)"Hello";
|
||||
iovs[i].iov_len = 5;
|
||||
}
|
||||
|
||||
MockBufferIO io;
|
||||
ssize_t nn = 0;
|
||||
HELPER_EXPECT_SUCCESS(srs_write_large_iovs(&io, iovs, nn_iovs, &nn));
|
||||
EXPECT_EQ(5 * nn_iovs, nn);
|
||||
EXPECT_EQ(5 * nn_iovs, io.sbytes);
|
||||
}
|
||||
|
||||
if (true) {
|
||||
iovec iovs[4096];
|
||||
int nn_iovs = (int)(sizeof(iovs)/sizeof(iovec));
|
||||
for (int i = 0; i < nn_iovs; i++) {
|
||||
iovs[i].iov_base = (char*)"Hello";
|
||||
iovs[i].iov_len = 5;
|
||||
}
|
||||
|
||||
MockBufferIO io;
|
||||
ssize_t nn = 0;
|
||||
HELPER_EXPECT_SUCCESS(srs_write_large_iovs(&io, iovs, nn_iovs, &nn));
|
||||
EXPECT_EQ(5 * nn_iovs, nn);
|
||||
EXPECT_EQ(5 * nn_iovs, io.sbytes);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue