Merge 3.0release

min
winlin 6 years ago
commit 9f10f890cf

@ -11,7 +11,7 @@ jobs:
- image: ossrs/dev
steps:
- checkout
- run: cd trunk && ./configure && make && ./objs/srs_utest
- run: cd trunk && ./configure --gcov && make && ./objs/srs_utest && bash auto/coverage.sh
workflows:
version: 2
build_and_test:

@ -1,12 +1,13 @@
# Simple-RTMP-Server
[![CircleCI](https://circleci.com/gh/ossrs/srs/tree/develop.svg?style=svg&circle-token=1ef1d5b5b0cde6c8c282ed856a18199f9e8f85a9)](https://circleci.com/gh/ossrs/srs/tree/develop)
[![codecov](https://codecov.io/gh/ossrs/srs/branch/develop/graph/badge.svg)](https://codecov.io/gh/ossrs/srs/branch/develop)
[![Wechat](https://cloud.githubusercontent.com/assets/2777660/22814959/c51cbe72-ef92-11e6-81cc-32b657b285d5.png)](https://github.com/ossrs/srs/wiki/v1_CN_Contact#wechat)
[<img width="52" alt="Skype" src="https://cloud.githubusercontent.com/assets/2777660/24329166/3821a328-1230-11e7-844a-506a5d17dd3d.png">](https://github.com/ossrs/srs/wiki/v1_EN_Contact#skype-or-gitter)
SRS/3.0, [OuXuli][release3]<br/>
SRS是一个简单的流媒体直播集群。<br/>
SRS is a simple live streaming cluster.
SRS是一个简单的流媒体直播集群,简单的快乐<br/>
SRS, created on 2013.10, a simple joy, is a simple live streaming cluster.
Download binaries from github.io: [Centos6-x86_64][centos0], [more...][more0]<br/>
Download binaries from ossrs.net: [Centos6-x86_64][centos1], [more...][more1]<br/>
@ -14,9 +15,18 @@ About the wiki of SRS/3.0, please read [Chinese][srs_CN] or [English][srs_EN].
> Remark: SRS3 hasn't been released and it's really unstable, please use stable branches such as [SRS2](https://github.com/ossrs/srs/tree/2.0release) or [SRS1](https://github.com/ossrs/srs/tree/1.0release) instead, unless you can fix bugs and debug it.
> Remark: Although SRS is licenced under [MIT][LICENSE], but there are some depended libraries which are distributed using their own licenses, please read [License Mixing][LicenseMixing].
> Remark: About the milestone and product plan, please read ([CN][v1_CN_Product], [EN][v1_EN_Product]) wiki.
> Remark: The origin-edge cluster is released, while the origin-origin cluster is coming soon.
> Remark: We are working on utest now.
Enjoy it!
## Content
* [About](#about)
* [Usage](#usage)
* [Wiki](#srs-30-wiki)
* [Features](#features)
@ -34,38 +44,6 @@ About the wiki of SRS/3.0, please read [Chinese][srs_CN] or [English][srs_EN].
* [Mirrors](#mirrors)
* [System Requirements](#system-requirements)
## About
SRS's a simplest, conceptual integrated, industrial-strength live streaming origin cluster.
It's created in 2013.10, by winlin, patched by many developers.
> Remark: Although SRS is licenced under [MIT][LICENSE], but there are some depended libraries
which are distributed using their own licenses, please read [License Mixing][LicenseMixing].
We always choose the best arch to write simplest code.
It's easy to use for the English and Chinese wikis.
The embeded HTTP API and tracable log is useful to integrate.
All features are conceptual integrated.
The live streaming features include RTMP, HTTP-FLV, HLS, HDS and MPEG-DASH, covering major protocols.
The transform features include DVR, Transcode, Forward and Ingest, which is powerful and convenient.
The origin-edge and origin-origin clusters provide strong fault-tolerance and load-balance feature.
User can run SRS on LINUX and OSX, with CPUs such as X86, X64, ARM and MIPS.
> Remark: The origin-edge cluster is released, while the origin-origin cluster is coming soon.
The goal is industrial-strength live streaming origin cluster.
The utests will cover full use-scenarios to avoid bugs from new code.
Complex error logs the stack and message from each level.
The FT and LB cluster make the servies robust.
> Remark: We are working on utest now.
> Remark: About the milestone and product plan, please read ([CN][v1_CN_Product], [EN][v1_EN_Product]) wiki.
Enjoy it!
<a name="product"></a>
### Usage

3
trunk/.gitignore vendored

@ -34,4 +34,7 @@
/test/
.DS_Store
srs
*.dSYM/
*.gcov
*.ts

@ -0,0 +1,25 @@
#!/bin/bash
# In .circleci/config.yml, generate *.gcno with
# ./configure --gcov --without-research --without-librtmp
# and generate *.gcda by
# ./objs/srs_utest
# Collect all *.gcno and *.gcda to objs/cover.
(mkdir -p objs/cover && cd objs/cover &&
cp -R ../../src . &&
for file in `find ../src -name "*.gcno"`; do cp $file .; done &&
for file in `find ../src -name "*.gcda"`; do cp $file .; done)
ret=$?; if [[ $ret -ne 0 ]]; then echo "Collect *.gcno and *.gcda failed, ret=$ret"; exit $ret; fi
# Generate *.gcov to objs/cover
for file in `find src -name "*.cpp"`; do
(mkdir -p objs/cover && cd objs/cover && gcov ../../$file -o .)
ret=$?; if [[ $ret -ne 0 ]]; then echo "Collect $file failed, ret=$ret"; exit $ret; fi
done
# Upload report with *.gcov
export CODECOV_TOKEN="493bba46-c468-4e73-8b45-8cdd8ff62d96" &&
mkdir -p objs/cover && cd objs/cover &&
bash <(curl -s https://codecov.io/bash)
exit 0

@ -713,11 +713,13 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
fi
fi
if [ $SRS_LIBRTMP = YES ]; then
if [[ $SRS_LIBRTMP == YES ]]; then
mkdir -p ${SRS_OBJS}/research
# librtmp
(cd ${SRS_WORKDIR}/research/librtmp && mkdir -p objs && ln -sf `pwd`/objs ../../${SRS_OBJS_DIR}/research/librtmp)
(cd ${SRS_WORKDIR}/research/librtmp && mkdir -p objs &&
rm -rf ../../${SRS_OBJS_DIR}/research/librtmp &&
ln -sf `pwd`/objs ../../${SRS_OBJS_DIR}/research/librtmp)
ret=$?; if [[ $ret -ne 0 ]]; then echo "Link research/librtmp failed, ret=$ret"; exit $ret; fi
fi

@ -43,16 +43,18 @@ SRS_DVR=YES
#
################################################################
# libraries
SRS_FFMPEG_STUB=RESERVED
SRS_FFMPEG_STUB=NO
# arguments
SRS_PREFIX=/usr/local/srs
SRS_JOBS=1
SRS_STATIC=RESERVED
SRS_STATIC=NO
# whether enable the gcov
SRS_GCOV=NO
# whether enable the log verbose/info/trace level.
# always enable the warn/error level.
SRS_LOG_VERBOSE=RESERVED
SRS_LOG_INFO=RESERVED
SRS_LOG_TRACE=RESERVED
SRS_LOG_VERBOSE=NO
SRS_LOG_INFO=NO
SRS_LOG_TRACE=NO
#
################################################################
# experts
@ -154,7 +156,8 @@ Options:
--without-mips-ubuntu12 do not cross build srs on ubuntu12 for mips.
--prefix=<path> The absolute installation path for srs. Default: $SRS_PREFIX
--static whether add '-static' to link options.
--static Whether add '-static' to link options.
--gcov Whether enable the GCOV compiler options.
--jobs[=N] Allow N jobs at once; infinite jobs with no arg.
used for make in the configure, for example, to make ffmpeg.
--log-verbose whether enable the log verbose level. default: no.
@ -267,6 +270,7 @@ function parse_user_option() {
--log-verbose) SRS_LOG_VERBOSE=YES ;;
--log-info) SRS_LOG_INFO=YES ;;
--log-trace) SRS_LOG_TRACE=YES ;;
--gcov) SRS_GCOV=YES ;;
--x86-x64) SRS_X86_X64=YES ;;
--x86-64) SRS_X86_X64=YES ;;
@ -640,6 +644,7 @@ SRS_AUTO_CONFIGURE="--prefix=${SRS_PREFIX}"
if [ $SRS_LOG_VERBOSE = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --log-verbose"; fi
if [ $SRS_LOG_INFO = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --log-info"; fi
if [ $SRS_LOG_TRACE = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --log-trace"; fi
if [ $SRS_GCOV = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --gcov"; fi
echo "User config: $SRS_AUTO_USER_CONFIGURE"
echo "Detail config: ${SRS_AUTO_CONFIGURE}"
}

13
trunk/configure vendored

@ -104,6 +104,13 @@ CXXFLAGS="${CXXFLAGS} ${CppStd}${WarnLevel}${GDBDebug}${LibraryCompile}${SrsGpro
if [ $SRS_GPERF = YES ]; then
CXXFLAGS="${CXXFLAGS} -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free";
fi
# For coverage.
if [[ $SRS_GCOV == YES ]]; then
SrsGcov="-fprofile-arcs -ftest-coverage"
fi
if [[ $SRS_GCOV == YES ]]; then
CXXFLAGS="${CXXFLAGS} ${SrsGcov}";
fi
# Start to generate the Makefile.
cat << END > ${SRS_OBJS}/${SRS_MAKEFILE}
GCC = gcc
@ -153,6 +160,10 @@ fi
if [ $SRS_MIPS_UBUNTU12 = YES ]; then
SrsLinkOptions="${SrsLinkOptions} -lgcc_eh";
fi
# For coverage.
if [[ $SRS_GCOV == YES ]]; then
SrsLinkOptions="${SrsLinkOptions} ${SrsGcov}";
fi
#####################################################################################
# Modules, compile each module, then link to binary
@ -499,7 +510,7 @@ librtmp: server
@echo "Building the client publish/play library."
\$(MAKE) -f ${SRS_OBJS_DIR}/${SRS_MAKEFILE} librtmp
@echo "Building the srs-librtmp example."
(cd research/librtmp; \$(MAKE) ${SrsLibrtmpSampleEntry})
(cd research/librtmp; \$(MAKE) EXTRA_CXXFLAGS="${SrsGcov}" ${SrsLibrtmpSampleEntry})
END
else

@ -303,6 +303,7 @@
3C1232F21AAEAC7000CE8F6C /* srs-api */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; name = "srs-api"; path = "../../../etc/init.d/srs-api"; sourceTree = "<group>"; };
3C1232F31AAEAC7000CE8F6C /* srs-demo */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; name = "srs-demo"; path = "../../../etc/init.d/srs-demo"; sourceTree = "<group>"; };
3C1232F41AAEAC7000CE8F6C /* srs-demo-19350 */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; name = "srs-demo-19350"; path = "../../../etc/init.d/srs-demo-19350"; sourceTree = "<group>"; };
3C1CDBFB2205CE0300A8C08E /* coverage.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; name = coverage.sh; path = ../../../auto/coverage.sh; sourceTree = "<group>"; };
3C1EE6AC1AB1055800576EE9 /* srs_app_hds.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = srs_app_hds.cpp; path = ../../../src/app/srs_app_hds.cpp; sourceTree = "<group>"; };
3C1EE6AD1AB1055800576EE9 /* srs_app_hds.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = srs_app_hds.hpp; path = ../../../src/app/srs_app_hds.hpp; sourceTree = "<group>"; };
3C1EE6B01AB1080900576EE9 /* bandwidth.conf */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = bandwidth.conf; path = ../../../conf/bandwidth.conf; sourceTree = "<group>"; };
@ -446,7 +447,6 @@
3CECAF961EDC100F00C50501 /* sched.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = sched.c; path = "../../../objs/state-threads-1.9.1/sched.c"; sourceTree = "<group>"; };
3CECAF971EDC100F00C50501 /* stk.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = stk.c; path = "../../../objs/state-threads-1.9.1/stk.c"; sourceTree = "<group>"; };
3CECAF981EDC100F00C50501 /* sync.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = sync.c; path = "../../../objs/state-threads-1.9.1/sync.c"; sourceTree = "<group>"; };
3CFBDA271F0338A40054D63E /* circle.yml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = circle.yml; path = ../../../circle.yml; sourceTree = "<group>"; };
8C0652AF2035B5B9000B0661 /* srs_app_coworkers.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = srs_app_coworkers.hpp; path = ../../../src/app/srs_app_coworkers.hpp; sourceTree = "<group>"; };
8C0652B02035B5B9000B0661 /* srs_app_coworkers.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = srs_app_coworkers.cpp; path = ../../../src/app/srs_app_coworkers.cpp; sourceTree = "<group>"; };
/* End PBXFileReference section */
@ -731,6 +731,7 @@
3C1232BB1AAE827E00CE8F6C /* apps.sh */,
3C1232BC1AAE827E00CE8F6C /* auto_headers.sh */,
3C1232BD1AAE827E00CE8F6C /* build_ffmpeg.sh */,
3C1CDBFB2205CE0300A8C08E /* coverage.sh */,
3C1232BE1AAE827E00CE8F6C /* depends.sh */,
3C1232BF1AAE827E00CE8F6C /* generate_header.sh */,
3C1232C01AAE827E00CE8F6C /* generate-srs-librtmp-project.sh */,
@ -825,7 +826,6 @@
3C1EE6D21AB1366500576EE9 /* doc */ = {
isa = PBXGroup;
children = (
3CFBDA271F0338A40054D63E /* circle.yml */,
3C1EE6D31AB1367D00576EE9 /* AUTHORS.txt */,
3C1EE6D51AB1367D00576EE9 /* LICENSE */,
3C1EE6D61AB1367D00576EE9 /* README.md */,

@ -1 +1,3 @@
*.mp4
*.gcno
*.gcda

@ -57,15 +57,15 @@ SRS_RESEARCH_DEPS = Makefile
# for x86/x64 platform
ifeq ($(GCC), gcc)
EXTRA_CXX_FLAG = -g -O0 -ldl -lstdc++ -lm
OTHER_FLAGS += -g -O0 -ldl -lstdc++ -lm
endif
# for arm.
ifeq ($(GCC), arm-linux-gnueabi-gcc)
EXTRA_CXX_FLAG = -g -O0 -ldl -static -lstdc++ -lm
OTHER_FLAGS += -g -O0 -ldl -static -lstdc++ -lm
endif
# for mips, add -lgcc_eh, or stl compile failed.
ifeq ($(GCC), mipsel-openwrt-linux-gcc)
EXTRA_CXX_FLAG = -g -O0 -ldl -lstdc++ -lm -lgcc_eh
OTHER_FLAGS += -g -O0 -ldl -lstdc++ -lm -lgcc_eh
endif
# for ssl or nossl
ifeq ($(HANDSHAKE), SSL)
@ -82,42 +82,44 @@ nossl:
@mkdir -p objs
$(MAKE) HANDSHAKE="NOSSL"
CXXFLAGS += $(OTHER_FLAGS) $(EXTRA_CXXFLAGS)
objs/srs_flv_parser: srs_flv_parser.c $(SRS_RESEARCH_DEPS) $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L)
$(GCC) srs_flv_parser.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(EXTRA_CXX_FLAG) -o objs/srs_flv_parser
$(GCC) srs_flv_parser.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(CXXFLAGS) -o objs/srs_flv_parser
objs/srs_flv_injecter: srs_flv_injecter.c $(SRS_RESEARCH_DEPS) $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L)
$(GCC) srs_flv_injecter.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(EXTRA_CXX_FLAG) -o objs/srs_flv_injecter
$(GCC) srs_flv_injecter.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(CXXFLAGS) -o objs/srs_flv_injecter
objs/srs_publish: srs_publish.c $(SRS_RESEARCH_DEPS) $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L)
$(GCC) srs_publish.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(EXTRA_CXX_FLAG) -o objs/srs_publish
$(GCC) srs_publish.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(CXXFLAGS) -o objs/srs_publish
objs/srs_h264_raw_publish: srs_h264_raw_publish.c $(SRS_RESEARCH_DEPS) $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L)
$(GCC) srs_h264_raw_publish.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(EXTRA_CXX_FLAG) -o objs/srs_h264_raw_publish
$(GCC) srs_h264_raw_publish.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(CXXFLAGS) -o objs/srs_h264_raw_publish
objs/srs_audio_raw_publish: srs_audio_raw_publish.c $(SRS_RESEARCH_DEPS) $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L)
$(GCC) srs_audio_raw_publish.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(EXTRA_CXX_FLAG) -o objs/srs_audio_raw_publish
$(GCC) srs_audio_raw_publish.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(CXXFLAGS) -o objs/srs_audio_raw_publish
objs/srs_aac_raw_publish: srs_aac_raw_publish.c $(SRS_RESEARCH_DEPS) $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L)
$(GCC) srs_aac_raw_publish.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(EXTRA_CXX_FLAG) -o objs/srs_aac_raw_publish
$(GCC) srs_aac_raw_publish.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(CXXFLAGS) -o objs/srs_aac_raw_publish
objs/srs_play: srs_play.c $(SRS_RESEARCH_DEPS) $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L)
$(GCC) srs_play.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(EXTRA_CXX_FLAG) -o objs/srs_play
$(GCC) srs_play.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(CXXFLAGS) -o objs/srs_play
objs/srs_ingest_flv: srs_ingest_flv.c $(SRS_RESEARCH_DEPS) $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L)
$(GCC) srs_ingest_flv.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(EXTRA_CXX_FLAG) -o objs/srs_ingest_flv
$(GCC) srs_ingest_flv.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(CXXFLAGS) -o objs/srs_ingest_flv
objs/srs_ingest_mp4: srs_ingest_mp4.c $(SRS_RESEARCH_DEPS) $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L)
$(GCC) srs_ingest_mp4.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(EXTRA_CXX_FLAG) -o objs/srs_ingest_mp4
$(GCC) srs_ingest_mp4.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(CXXFLAGS) -o objs/srs_ingest_mp4
objs/srs_ingest_rtmp: srs_ingest_rtmp.c $(SRS_RESEARCH_DEPS) $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L)
$(GCC) srs_ingest_rtmp.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(EXTRA_CXX_FLAG) -o objs/srs_ingest_rtmp
$(GCC) srs_ingest_rtmp.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(CXXFLAGS) -o objs/srs_ingest_rtmp
objs/srs_detect_rtmp: srs_detect_rtmp.c $(SRS_RESEARCH_DEPS) $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L)
$(GCC) srs_detect_rtmp.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(EXTRA_CXX_FLAG) -o objs/srs_detect_rtmp
$(GCC) srs_detect_rtmp.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(CXXFLAGS) -o objs/srs_detect_rtmp
objs/srs_bandwidth_check: srs_bandwidth_check.c $(SRS_RESEARCH_DEPS) $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L)
$(GCC) srs_bandwidth_check.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(EXTRA_CXX_FLAG) -o objs/srs_bandwidth_check
$(GCC) srs_bandwidth_check.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(CXXFLAGS) -o objs/srs_bandwidth_check
objs/srs_rtmp_dump: srs_rtmp_dump.c $(SRS_RESEARCH_DEPS) $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L)
$(GCC) srs_rtmp_dump.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(EXTRA_CXX_FLAG) -o objs/srs_rtmp_dump
$(GCC) srs_rtmp_dump.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(CXXFLAGS) -o objs/srs_rtmp_dump

@ -458,7 +458,7 @@ srs_error_t SrsHlsMuxer::segment_open()
// open temp ts file.
std::string tmp_file = current->tmppath();
if ((err = current->tscw->open(tmp_file.c_str())) != srs_success) {
if ((err = current->writer->open(tmp_file)) != srs_success) {
return srs_error_wrap(err, "open hls muxer");
}

@ -251,24 +251,17 @@ void SrsBuffer::write_bytes(char* data, int size)
p += size;
}
SrsBitBuffer::SrsBitBuffer()
SrsBitBuffer::SrsBitBuffer(SrsBuffer* b)
{
cb = 0;
cb_left = 0;
stream = NULL;
stream = b;
}
SrsBitBuffer::~SrsBitBuffer()
{
}
srs_error_t SrsBitBuffer::initialize(SrsBuffer* s) {
stream = s;
cb = 0;
cb_left = 0;
return srs_success;
}
bool SrsBitBuffer::empty() {
if (cb_left) {
return false;

@ -206,10 +206,9 @@ private:
uint8_t cb_left;
SrsBuffer* stream;
public:
SrsBitBuffer();
SrsBitBuffer(SrsBuffer* b);
virtual ~SrsBitBuffer();
public:
virtual srs_error_t initialize(SrsBuffer* s);
virtual bool empty();
virtual int8_t read_bit();
};

@ -175,6 +175,14 @@ bool SrsFlvVideo::acceptable(char* data, int size)
return true;
}
SrsFlvAudio::SrsFlvAudio()
{
}
SrsFlvAudio::~SrsFlvAudio()
{
}
bool SrsFlvAudio::sh(char* data, int size)
{
// sequence header only for aac
@ -426,7 +434,6 @@ SrsFrame::SrsFrame()
SrsFrame::~SrsFrame()
{
srs_freep(codec);
}
srs_error_t SrsFrame::initialize(SrsCodecConfig* c)
@ -887,10 +894,7 @@ srs_error_t SrsFormat::avc_demux_sps_rbsp(char* rbsp, int nb_rbsp)
return srs_error_new(ERROR_HLS_DECODE_ERROR, "sps the level_idc invalid");
}
SrsBitBuffer bs;
if ((err = bs.initialize(&stream)) != srs_success) {
return srs_error_wrap(err, "init bit buffer");
}
SrsBitBuffer bs(&stream);
int32_t seq_parameter_set_id = -1;
if ((err = srs_avc_nalu_read_uev(&bs, seq_parameter_set_id)) != srs_success) {
@ -1353,10 +1357,10 @@ srs_error_t SrsFormat::audio_aac_sequence_header_demux(char* data, int size)
// donot force to LC, @see: https://github.com/ossrs/srs/issues/81
// the source will print the sequence header info.
//if (aac_profile > 3) {
// Mark all extended profiles as LC
// to make Android as happy as possible.
// @see: ngx_rtmp_hls_parse_aac_header
//aac_profile = 1;
// Mark all extended profiles as LC
// to make Android as happy as possible.
// @see: ngx_rtmp_hls_parse_aac_header
//aac_profile = 1;
//}
return err;

@ -704,7 +704,7 @@ public:
public:
// for sequence header, whether parse the h.264 sps.
// TODO: FIXME: Refine it.
bool avc_parse_sps;
bool avc_parse_sps;
public:
SrsFormat();
virtual ~SrsFormat();

@ -908,6 +908,10 @@ srs_error_t SrsFlvVodStreamDecoder::read_sequence_header_summary(int64_t* pstart
av_sequence_offset_end = reader->tellg() + data_size + SRS_FLV_PREVIOUS_TAG_SIZE;
reader->skip(data_size + SRS_FLV_PREVIOUS_TAG_SIZE);
}
if (got_audio && got_video) {
break;
}
}
// seek to the sequence header start offset.

@ -298,7 +298,7 @@ srs_error_t SrsTsContext::decode(SrsBuffer* stream, ISrsTsHandler* handler)
return err;
}
srs_error_t SrsTsContext::encode(SrsFileWriter* writer, SrsTsMessage* msg, SrsVideoCodecId vc, SrsAudioCodecId ac)
srs_error_t SrsTsContext::encode(ISrsStreamWriter* writer, SrsTsMessage* msg, SrsVideoCodecId vc, SrsAudioCodecId ac)
{
srs_error_t err = srs_success;
@ -380,7 +380,7 @@ void SrsTsContext::set_sync_byte(int8_t sb)
sync_byte = sb;
}
srs_error_t SrsTsContext::encode_pat_pmt(SrsFileWriter* writer, int16_t vpid, SrsTsStream vs, int16_t apid, SrsTsStream as)
srs_error_t SrsTsContext::encode_pat_pmt(ISrsStreamWriter* writer, int16_t vpid, SrsTsStream vs, int16_t apid, SrsTsStream as)
{
srs_error_t err = srs_success;
@ -441,7 +441,7 @@ srs_error_t SrsTsContext::encode_pat_pmt(SrsFileWriter* writer, int16_t vpid, Sr
return err;
}
srs_error_t SrsTsContext::encode_pes(SrsFileWriter* writer, SrsTsMessage* msg, int16_t pid, SrsTsStream sid, bool pure_audio)
srs_error_t SrsTsContext::encode_pes(ISrsStreamWriter* writer, SrsTsMessage* msg, int16_t pid, SrsTsStream sid, bool pure_audio)
{
srs_error_t err = srs_success;
@ -752,8 +752,9 @@ SrsTsPacket* SrsTsPacket::create_pat(SrsTsContext* context, int16_t pmt_number,
return pkt;
}
SrsTsPacket* SrsTsPacket::create_pmt(SrsTsContext* context, int16_t pmt_number, int16_t pmt_pid, int16_t vpid, SrsTsStream vs, int16_t apid, SrsTsStream as)
{
SrsTsPacket* SrsTsPacket::create_pmt(SrsTsContext* context,
int16_t pmt_number, int16_t pmt_pid, int16_t vpid, SrsTsStream vs, int16_t apid, SrsTsStream as
) {
SrsTsPacket* pkt = new SrsTsPacket(context);
pkt->sync_byte = 0x47;
pkt->transport_error_indicator = 0;
@ -800,9 +801,9 @@ SrsTsPacket* SrsTsPacket::create_pmt(SrsTsContext* context, int16_t pmt_number,
}
SrsTsPacket* SrsTsPacket::create_pes_first(SrsTsContext* context,
int16_t pid, SrsTsPESStreamId sid, uint8_t continuity_counter, bool discontinuity,
int64_t pcr, int64_t dts, int64_t pts, int size
) {
int16_t pid, SrsTsPESStreamId sid, uint8_t continuity_counter, bool discontinuity,
int64_t pcr, int64_t dts, int64_t pts, int size
) {
SrsTsPacket* pkt = new SrsTsPacket(context);
pkt->sync_byte = 0x47;
pkt->transport_error_indicator = 0;
@ -2543,7 +2544,7 @@ srs_error_t SrsTsPayloadPMT::psi_encode(SrsBuffer* stream)
return err;
}
SrsTsContextWriter::SrsTsContextWriter(SrsFileWriter* w, SrsTsContext* c, SrsAudioCodecId ac, SrsVideoCodecId vc)
SrsTsContextWriter::SrsTsContextWriter(ISrsStreamWriter* w, SrsTsContext* c, SrsAudioCodecId ac, SrsVideoCodecId vc)
{
writer = w;
context = c;
@ -2554,25 +2555,6 @@ SrsTsContextWriter::SrsTsContextWriter(SrsFileWriter* w, SrsTsContext* c, SrsAud
SrsTsContextWriter::~SrsTsContextWriter()
{
close();
}
srs_error_t SrsTsContextWriter::open(string p)
{
srs_error_t err = srs_success;
path = p;
close();
// reset the context for a new ts start.
context->reset();
if ((err = writer->open(path)) != srs_success) {
return srs_error_wrap(err, "ts: open writer");
}
return err;
}
srs_error_t SrsTsContextWriter::write_audio(SrsTsMessage* audio)
@ -2605,11 +2587,6 @@ srs_error_t SrsTsContextWriter::write_video(SrsTsMessage* video)
return err;
}
void SrsTsContextWriter::close()
{
writer->close();
}
SrsVideoCodecId SrsTsContextWriter::video_codec()
{
return vcodec;
@ -3011,7 +2988,7 @@ SrsTsTransmuxer::~SrsTsTransmuxer()
srs_freep(context);
}
srs_error_t SrsTsTransmuxer::initialize(SrsFileWriter* fw)
srs_error_t SrsTsTransmuxer::initialize(ISrsStreamWriter* fw)
{
srs_error_t err = srs_success;
@ -3021,20 +2998,12 @@ srs_error_t SrsTsTransmuxer::initialize(SrsFileWriter* fw)
srs_assert(fw);
if (!fw->is_open()) {
return srs_error_new(ERROR_KERNEL_FLV_STREAM_CLOSED, "ts: stream is not open");
}
writer = fw;
srs_freep(tscw);
// TODO: FIXME: Support config the codec.
tscw = new SrsTsContextWriter(fw, context, SrsAudioCodecIdAAC, SrsVideoCodecIdAVC);
if ((err = tscw->open("")) != srs_success) {
return srs_error_wrap(err, "ts: open writer");
}
return err;
}

@ -38,7 +38,7 @@
class SrsBuffer;
class SrsTsMessageCache;
class SrsTsContextWriter;
class SrsFileWriter;
class ISrsStreamWriter;
class SrsFileReader;
class SrsFormat;
class SrsSimpleStream;
@ -131,6 +131,7 @@ enum SrsTsStream
{
// ITU-T | ISO/IEC Reserved
SrsTsStreamReserved = 0x00,
SrsTsStreamForbidden = 0xff,
// ISO/IEC 11172 Video
// ITU-T Rec. H.262 | ISO/IEC 13818-2 Video or ISO/IEC 11172-2 constrained parameter video stream
// ISO/IEC 11172 Audio
@ -402,7 +403,7 @@ public:
* @param vc the video codec, write the PAT/PMT table when changed.
* @param ac the audio codec, write the PAT/PMT table when changed.
*/
virtual srs_error_t encode(SrsFileWriter* writer, SrsTsMessage* msg, SrsVideoCodecId vc, SrsAudioCodecId ac);
virtual srs_error_t encode(ISrsStreamWriter* writer, SrsTsMessage* msg, SrsVideoCodecId vc, SrsAudioCodecId ac);
// drm methods
public:
/**
@ -411,8 +412,8 @@ public:
*/
virtual void set_sync_byte(int8_t sb);
private:
virtual srs_error_t encode_pat_pmt(SrsFileWriter* writer, int16_t vpid, SrsTsStream vs, int16_t apid, SrsTsStream as);
virtual srs_error_t encode_pes(SrsFileWriter* writer, SrsTsMessage* msg, int16_t pid, SrsTsStream sid, bool pure_audio);
virtual srs_error_t encode_pat_pmt(ISrsStreamWriter* writer, int16_t vpid, SrsTsStream vs, int16_t apid, SrsTsStream as);
virtual srs_error_t encode_pes(ISrsStreamWriter* writer, SrsTsMessage* msg, int16_t pid, SrsTsStream sid, bool pure_audio);
};
/**
@ -1542,17 +1543,12 @@ private:
SrsAudioCodecId acodec;
private:
SrsTsContext* context;
SrsFileWriter* writer;
ISrsStreamWriter* writer;
std::string path;
public:
SrsTsContextWriter(SrsFileWriter* w, SrsTsContext* c, SrsAudioCodecId ac, SrsVideoCodecId vc);
SrsTsContextWriter(ISrsStreamWriter* w, SrsTsContext* c, SrsAudioCodecId ac, SrsVideoCodecId vc);
virtual ~SrsTsContextWriter();
public:
/**
* open the writer, donot write the PSI of ts.
* @param p a string indicates the path of ts file to mux to.
*/
virtual srs_error_t open(std::string p);
/**
* write an audio frame to ts,
*/
@ -1561,10 +1557,6 @@ public:
* write a video frame to ts,
*/
virtual srs_error_t write_video(SrsTsMessage* video);
/**
* close the writer.
*/
virtual void close();
public:
/**
* get the video codec of ts muxer.
@ -1627,7 +1619,7 @@ private:
class SrsTsTransmuxer
{
private:
SrsFileWriter* writer;
ISrsStreamWriter* writer;
private:
SrsFormat* format;
SrsTsMessageCache* tsmc;
@ -1641,7 +1633,7 @@ public:
* initialize the underlayer file stream.
* @param fw the writer to use for ts encoder, user must free it.
*/
virtual srs_error_t initialize(SrsFileWriter* fw);
virtual srs_error_t initialize(ISrsStreamWriter* fw);
public:
/**
* write audio/video packet.

@ -77,6 +77,10 @@ srs_error_t srs_avc_nalu_read_uev(SrsBitBuffer* stream, int32_t& v)
v = (1 << leadingZeroBits) - 1;
for (int i = 0; i < (int)leadingZeroBits; i++) {
if (stream->empty()) {
return srs_error_new(ERROR_AVC_NALU_UEV, "no bytes for leadingZeroBits=%d", leadingZeroBits);
}
int32_t b = stream->read_bit();
v += b << (leadingZeroBits - 1 - i);
}
@ -97,8 +101,8 @@ srs_error_t srs_avc_nalu_read_bit(SrsBitBuffer* stream, int8_t& v)
return err;
}
static int64_t _srs_system_time_us_cache = 0;
static int64_t _srs_system_time_startup_time = 0;
int64_t _srs_system_time_us_cache = 0;
int64_t _srs_system_time_startup_time = 0;
int64_t srs_get_system_time_ms()
{
@ -1009,7 +1013,7 @@ uint8_t srs_from_hex_char(uint8_t c)
return -1;
}
char *srs_data_to_hex(char *des,const u_int8_t *src,int len)
char* srs_data_to_hex(char* des, const u_int8_t* src, int len)
{
if(src == NULL || len == 0 || des == NULL){
return NULL;

@ -232,10 +232,7 @@ srs_error_t SrsRtpPacket::decode_97(SrsBuffer* stream)
int required_size = 0;
// append left bytes to payload.
payload->append(
stream->data() + stream->pos() + au_size,
stream->size() - stream->pos() - au_size
);
payload->append(stream->data() + stream->pos() + au_size, stream->size() - stream->pos() - au_size);
char* p = payload->bytes();
for (int i = 0; i < au_size; i += 2) {

@ -33,36 +33,13 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <srs_app_log.hpp>
#define SRS_UTEST_DEV
#undef SRS_UTEST_DEV
// enable all utest.
#ifndef SRS_UTEST_DEV
#define ENABLE_UTEST_AMF0
#define ENABLE_UTEST_CONFIG
#define ENABLE_UTEST_CORE
#define ENABLE_UTEST_KERNEL
#define ENABLE_UTEST_PROTOCOL
#define ENABLE_UTEST_RELOAD
#endif
// disable some for fast dev, compile and startup.
#ifdef SRS_UTEST_DEV
#undef ENABLE_UTEST_AMF0
#undef ENABLE_UTEST_CONFIG
#undef ENABLE_UTEST_CORE
#undef ENABLE_UTEST_KERNEL
#undef ENABLE_UTEST_PROTOCOL
#undef ENABLE_UTEST_RELOAD
#endif
#ifdef SRS_UTEST_DEV
#define ENABLE_UTEST_RELOAD
#endif
// we add an empty macro for upp to show the smart tips.
#define VOID
// Public all private and protected members.
#define private public
#define protected public
// the asserts of gtest:
// * {ASSERT|EXPECT}_EQ(expected, actual): Tests that expected == actual
// * {ASSERT|EXPECT}_NE(v1, v2): Tests that v1 != v2

@ -84,8 +84,6 @@ srs_error_t MockSrsConfig::parse(string buf)
return err;
}
#ifdef ENABLE_UTEST_CONFIG
VOID TEST(ConfigTest, CheckMacros)
{
#ifndef SRS_CONSTS_LOCALHOST
@ -1806,5 +1804,3 @@ VOID TEST(ConfigMainTest, CheckConf_vhost_ingest_id)
EXPECT_TRUE(ERROR_SUCCESS != conf.parse(_MIN_OK_CONF"vhost v{ingest{} ingest{}}"));
}
#endif

@ -22,8 +22,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <srs_utest_core.hpp>
#ifdef ENABLE_UTEST_CORE
using namespace std;
#include <srs_core_autofree.hpp>
@ -66,5 +64,3 @@ VOID TEST(CoreMacroseTest, Check)
#endif
}
#endif

File diff suppressed because it is too large Load Diff

@ -31,7 +31,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <string>
#include <srs_kernel_file.hpp>
#include <srs_kernel_buffer.hpp>
#include <srs_protocol_stream.hpp>
#include <srs_kernel_ts.hpp>
class MockBufferReader: public ISrsReader
{
@ -48,7 +50,10 @@ class MockSrsFileWriter : public SrsFileWriter
{
public:
char* data;
int size;
int offset;
srs_error_t err;
int error_offset;
public:
MockSrsFileWriter();
virtual ~MockSrsFileWriter();
@ -57,9 +62,11 @@ public:
virtual void close();
public:
virtual bool is_open();
virtual void seek2(int64_t offset);
virtual int64_t tellg();
public:
virtual srs_error_t write(void* buf, size_t count, ssize_t* pnwrite);
virtual srs_error_t lseek(off_t offset, int whence, off_t* seeked);
// for mock
public:
void mock_reset_offset();
@ -73,6 +80,7 @@ public:
int offset;
public:
MockSrsFileReader();
MockSrsFileReader(const char* data, int nb_data);
virtual ~MockSrsFileReader();
public:
virtual srs_error_t open(std::string file);
@ -93,5 +101,27 @@ public:
void mock_reset_offset();
};
class MockSrsCodec : public ISrsCodec
{
public:
MockSrsCodec();
virtual ~MockSrsCodec();
public:
virtual int nb_bytes();
virtual srs_error_t encode(SrsBuffer* buf);
virtual srs_error_t decode(SrsBuffer* buf);
};
class MockTsHandler : public ISrsTsHandler
{
public:
SrsTsMessage* msg;
public:
MockTsHandler();
virtual ~MockTsHandler();
public:
virtual srs_error_t on_ts_message(SrsTsMessage* m);
};
#endif

@ -275,8 +275,6 @@ MockWallClock* MockWallClock::set_clock(int64_t ms)
return this;
}
#ifdef ENABLE_UTEST_PROTOCOL
// verify the sha256
VOID TEST(ProtocolHandshakeTest, OpensslSha256)
{
@ -6004,5 +6002,3 @@ VOID TEST(ProtocolKbpsTest, RAWStatistic)
}
}
#endif

@ -299,8 +299,6 @@ srs_error_t MockSrsReloadConfig::do_reload(string buf)
return err;
}
#ifdef ENABLE_UTEST_RELOAD
VOID TEST(ConfigReloadTest, ReloadEmpty)
{
MockReloadHandler handler;
@ -920,5 +918,3 @@ VOID TEST(ConfigReloadTest, ReloadVhostIngestUpdated)
handler.reset();
}
#endif

Loading…
Cancel
Save