mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Merge pull request #1 from ossrs/feature/srt
Refine code before merge to SRS.
This commit is contained in:
commit
d792ac2e57
13 changed files with 115 additions and 68 deletions
|
@ -70,6 +70,12 @@ else
|
|||
srs_undefine_macro "SRS_AUTO_HDS" $SRS_AUTO_HEADERS_H
|
||||
fi
|
||||
|
||||
if [ $SRS_SRT = YES ]; then
|
||||
srs_define_macro "SRS_AUTO_SRT" $SRS_AUTO_HEADERS_H
|
||||
else
|
||||
srs_undefine_macro "SRS_AUTO_SRT" $SRS_AUTO_HEADERS_H
|
||||
fi
|
||||
|
||||
if [ $SRS_MEM_WATCH = YES ]; then
|
||||
srs_define_macro "SRS_AUTO_MEM_WATCH" $SRS_AUTO_HEADERS_H
|
||||
else
|
||||
|
|
|
@ -16,6 +16,7 @@ help=no
|
|||
################################################################
|
||||
# feature options
|
||||
SRS_HDS=NO
|
||||
SRS_SRT=NO
|
||||
SRS_NGINX=NO
|
||||
SRS_FFMPEG_TOOL=NO
|
||||
SRS_LIBRTMP=NO
|
||||
|
|
|
@ -58,7 +58,7 @@ USER_DIR = .
|
|||
CPPFLAGS += -I\$(GTEST_DIR)/include
|
||||
|
||||
# Flags passed to the C++ compiler.
|
||||
CXXFLAGS += -g -Wall -Wextra -O0 ${EXTRA_DEFINES}
|
||||
CXXFLAGS += ${CXXFLAGS} -Wextra ${EXTRA_DEFINES}
|
||||
|
||||
# All tests produced by this Makefile. Remember to add new tests you
|
||||
# created to the list.
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
# main config for srs.
|
||||
# @see full.conf for detail config.
|
||||
# SRT config.
|
||||
|
||||
listen 1935;
|
||||
max_connections 1000;
|
||||
srs_log_tank file;
|
||||
srs_log_file ./objs/srs.log;
|
||||
srs_log_tank console;
|
||||
daemon off;
|
||||
|
||||
http_api {
|
||||
|
@ -22,22 +20,12 @@ srt_server {
|
|||
listen 10080;
|
||||
}
|
||||
|
||||
# @doc https://github.com/ossrs/srs/issues/1147#issuecomment-577492117
|
||||
vhost __defaultVhost__ {
|
||||
}
|
||||
|
||||
vhost srs.srt.com.cn {
|
||||
}
|
||||
|
||||
# 无vhost配置(__defaultVhost__), 示例:
|
||||
# srt推流地址:srt://127.0.0.1:10080?streamid=live/test1?m=push
|
||||
# srt拉流地址:srt://127.0.0.1:10080?streamid=live/test1?m=pull
|
||||
# rtmp拉流地址:rtmp://127.0.0.1/live/test1
|
||||
|
||||
# 带有vhost配置, 示例:
|
||||
# srt推流地址:srt://127.0.0.1:10080?streamid=srs.srt.com.cn/live/test1?m=push
|
||||
# srt拉流地址:srt://127.0.0.1:10080?streamid=srs.srt.com.cn/live/test1?m=pull
|
||||
# rtmp拉流地址:rtmp://127.0.0.1/live?vhost=srs.srt.com.cn/test1
|
||||
|
||||
stats {
|
||||
network 0;
|
||||
disk sda sdb xvda xvdb;
|
||||
|
|
73
trunk/configure
vendored
73
trunk/configure
vendored
|
@ -96,10 +96,11 @@ END
|
|||
GDBDebug=" -g -O0"
|
||||
# the warning level.
|
||||
WarnLevel=" -Wall"
|
||||
# c++11 enable.
|
||||
cpp11=" -std=c++11 -pthread"
|
||||
# the compile standard.
|
||||
CppStd="-ansi"
|
||||
if [[ $SRS_SRT == YES ]]; then
|
||||
CppStd="-std=c++11"
|
||||
fi
|
||||
# for library compile
|
||||
if [[ $SRS_EXPORT_LIBRTMP_PROJECT == YES ]]; then
|
||||
LibraryCompile=" -fPIC"
|
||||
|
@ -109,7 +110,7 @@ SrsGprof=""; SrsGprofLink=""; if [ $SRS_GPROF = YES ]; then SrsGprof=" -pg -lc_p
|
|||
# performance of gperf
|
||||
SrsGperf=""; SrsGperfLink=""; if [ $SRS_GPERF = YES ]; then SrsGperfLink=" -lpthread"; fi
|
||||
# the cxx flag generated.
|
||||
CXXFLAGS="${CXXFLAGS} ${CppStd}${WarnLevel}${cpp11}${GDBDebug}${LibraryCompile}${SrsGprof}"
|
||||
CXXFLAGS="${CXXFLAGS} ${CppStd}${WarnLevel}${GDBDebug}${LibraryCompile}${SrsGprof}"
|
||||
if [ $SRS_GPERF = YES ]; then
|
||||
CXXFLAGS="${CXXFLAGS} -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free";
|
||||
fi
|
||||
|
@ -133,7 +134,8 @@ ARFLAGS = -rs
|
|||
LINK = g++
|
||||
CXXFLAGS = ${CXXFLAGS}
|
||||
|
||||
.PHONY: default srs librtmp
|
||||
.PHONY: default srs srs_ingest_hls librtmp
|
||||
|
||||
default:
|
||||
|
||||
END
|
||||
|
@ -158,11 +160,15 @@ fi
|
|||
if [ $SRS_GPERF_MD = YES ]; then
|
||||
LibGperfFile="${SRS_OBJS_DIR}/gperf/lib/libtcmalloc_debug.a";
|
||||
fi
|
||||
#srt code path
|
||||
LibSRTRoot="${SRS_WORKDIR}/src/srt"
|
||||
|
||||
# srt code path
|
||||
if [[ $SRS_SRT == YES ]]; then
|
||||
LibSRTRoot="${SRS_WORKDIR}/src/srt"
|
||||
fi
|
||||
# the link options, always use static link
|
||||
SrsLinkOptions="-pthread -ldl -lsrt";
|
||||
SrsLinkOptions="-ldl";
|
||||
if [[ $SRS_SRT == YES ]]; then
|
||||
SrsLinkOptions="${SrsLinkOptions} -pthread -lsrt";
|
||||
fi
|
||||
if [[ $SRS_SSL == YES && $SRS_USE_SYS_SSL == YES ]]; then
|
||||
SrsLinkOptions="${SrsLinkOptions} -lssl -lcrypto";
|
||||
fi
|
||||
|
@ -212,12 +218,12 @@ PROTOCOL_OBJS="${MODULE_OBJS[@]}"
|
|||
#
|
||||
#srt protocol features.
|
||||
if [ $SRS_SRT = YES ]; then
|
||||
MODULE_ID="SRT"
|
||||
MODULE_DEPENDS=("CORE" "KERNEL" "PROTOCOL" "SERVICE" "APP")
|
||||
ModuleLibIncs=(${SRS_OBJS_DIR})
|
||||
MODULE_FILES=("srt_server" "srt_handle" "srt_conn" "srt_to_rtmp" "ts_demux" "srt_data")
|
||||
SRT_INCS=${LibSRTRoot}; MODULE_DIR=${LibSRTRoot} . auto/modules.sh
|
||||
SRT_OBJS="${MODULE_OBJS[@]}"
|
||||
MODULE_ID="SRT"
|
||||
MODULE_DEPENDS=("CORE" "KERNEL" "PROTOCOL" "SERVICE" "APP")
|
||||
ModuleLibIncs=(${SRS_OBJS_DIR})
|
||||
MODULE_FILES=("srt_server" "srt_handle" "srt_conn" "srt_to_rtmp" "ts_demux" "srt_data")
|
||||
SRT_INCS=${LibSRTRoot}; MODULE_DIR=${LibSRTRoot} . auto/modules.sh
|
||||
SRT_OBJS="${MODULE_OBJS[@]}"
|
||||
fi
|
||||
|
||||
#
|
||||
|
@ -238,7 +244,10 @@ fi
|
|||
if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
|
||||
MODULE_ID="APP"
|
||||
MODULE_DEPENDS=("CORE" "KERNEL" "PROTOCOL" "SERVICE")
|
||||
ModuleLibIncs=(${LibSTRoot} ${SRS_OBJS_DIR} ${LibSSLRoot} ${LibSRTRoot})
|
||||
ModuleLibIncs=(${LibSTRoot} ${SRS_OBJS_DIR} ${LibSSLRoot})
|
||||
if [[ $SRS_SRT == YES ]]; then
|
||||
ModuleLibIncs+=("${LibSRTRoot[*]}")
|
||||
fi
|
||||
MODULE_FILES=("srs_app_server" "srs_app_conn" "srs_app_rtmp_conn" "srs_app_source"
|
||||
"srs_app_refer" "srs_app_hls" "srs_app_forward" "srs_app_encoder" "srs_app_http_stream"
|
||||
"srs_app_thread" "srs_app_bandwidth" "srs_app_st" "srs_app_log" "srs_app_config"
|
||||
|
@ -272,8 +281,14 @@ LIBS_OBJS="${MODULE_OBJS[@]}"
|
|||
#Server Module, for SRS only.
|
||||
if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
|
||||
MODULE_ID="SERVER"
|
||||
MODULE_DEPENDS=("CORE" "KERNEL" "PROTOCOL" "SERVICE" "APP" "SRT")
|
||||
ModuleLibIncs=(${LibSTRoot} ${SRS_OBJS_DIR} ${LibGperfRoot} ${LibSSLRoot} ${LibSRTRoot})
|
||||
MODULE_DEPENDS=("CORE" "KERNEL" "PROTOCOL" "SERVICE" "APP")
|
||||
if [[ $SRS_SRT == YES ]]; then
|
||||
MODULE_DEPENDS+=("SRT")
|
||||
fi
|
||||
ModuleLibIncs=(${LibSTRoot} ${SRS_OBJS_DIR} ${LibGperfRoot} ${LibSSLRoot})
|
||||
if [[ $SRS_SRT == YES ]]; then
|
||||
ModuleLibIncs+=("${LibSRTRoot[*]}")
|
||||
fi
|
||||
MODULE_FILES=("srs_main_server")
|
||||
SERVER_INCS="src/main"; MODULE_DIR=${SERVER_INCS} . auto/modules.sh
|
||||
SERVER_OBJS="${MODULE_OBJS[@]}"
|
||||
|
@ -312,14 +327,18 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
|
|||
# all depends libraries
|
||||
ModuleLibFiles=(${LibSTfile} ${LibSSLfile} ${LibGperfFile})
|
||||
# all depends objects
|
||||
MODULE_OBJS="${CORE_OBJS[@]} ${KERNEL_OBJS[@]} ${PROTOCOL_OBJS[@]} ${SRT_OBJS[@]} ${SERVICE_OBJS[@]} ${APP_OBJS[@]} ${SERVER_OBJS[@]}"
|
||||
MODULE_OBJS="${CORE_OBJS[@]} ${KERNEL_OBJS[@]} ${PROTOCOL_OBJS[@]} ${SERVICE_OBJS[@]} ${APP_OBJS[@]} ${SERVER_OBJS[@]}"
|
||||
ModuleLibIncs=(${LibSTRoot} ${SRS_OBJS_DIR} ${LibGperfRoot} ${LibSSLRoot})
|
||||
if [[ $SRS_SRT == YES ]]; then
|
||||
MODULE_OBJS="${MODULE_OBJS} ${SRT_OBJS[@]}"
|
||||
fi
|
||||
LINK_OPTIONS="${SrsLinkOptions}${SrsGprofLink}${SrsGperfLink}"
|
||||
#
|
||||
# srs: srs(simple rtmp server) over st(state-threads)
|
||||
BUILD_KEY="srs" APP_MAIN="srs_main_server" APP_NAME="srs" . auto/apps.sh
|
||||
#
|
||||
# For modules, without the app module.
|
||||
MODULE_OBJS="${CORE_OBJS[@]} ${KERNEL_OBJS[@]} ${SRT_OBJS[@]} ${PROTOCOL_OBJS[@]} ${SERVICE_OBJS[@]} ${MAIN_OBJS[@]}"
|
||||
MODULE_OBJS="${CORE_OBJS[@]} ${KERNEL_OBJS[@]} ${PROTOCOL_OBJS[@]} ${SERVICE_OBJS[@]} ${MAIN_OBJS[@]}"
|
||||
#
|
||||
for SRS_MODULE in ${SRS_MODULES[*]}; do
|
||||
. $SRS_MODULE/config
|
||||
|
@ -339,10 +358,16 @@ if [ $SRS_UTEST = YES ]; then
|
|||
MODULE_FILES=("srs_utest" "srs_utest_amf0" "srs_utest_protocol" "srs_utest_kernel" "srs_utest_core"
|
||||
"srs_utest_config" "srs_utest_rtmp" "srs_utest_http" "srs_utest_avc" "srs_utest_reload"
|
||||
"srs_utest_mp4" "srs_utest_service" "srs_utest_app")
|
||||
ModuleLibIncs=(${SRS_OBJS_DIR} ${LibSTRoot} ${LibSSLRoot} ${LibSRTRoot})
|
||||
ModuleLibIncs=(${SRS_OBJS_DIR} ${LibSTRoot} ${LibSSLRoot})
|
||||
if [[ $SRS_SRT == YES ]]; then
|
||||
ModuleLibIncs+=("${LibSRTRoot[*]}")
|
||||
fi
|
||||
ModuleLibFiles=(${LibSTfile} ${LibSSLfile})
|
||||
MODULE_DEPENDS=("CORE" "KERNEL" "PROTOCOL" "SERVICE" "APP" "SRT")
|
||||
MODULE_OBJS="${CORE_OBJS[@]} ${KERNEL_OBJS[@]} ${PROTOCOL_OBJS[@]} ${SERVICE_OBJS[@]} ${APP_OBJS[@]}"
|
||||
MODULE_DEPENDS=("CORE" "KERNEL" "PROTOCOL" "SERVICE" "APP")
|
||||
if [[ $SRS_SRT == YES ]]; then
|
||||
MODULE_DEPENDS+=("SRT")
|
||||
fi
|
||||
MODULE_OBJS="${CORE_OBJS[@]} ${KERNEL_OBJS[@]} ${PROTOCOL_OBJS[@]} ${SERVICE_OBJS[@]} ${APP_OBJS[@]} ${SRT_OBJS[@]}"
|
||||
LINK_OPTIONS="-lpthread ${SrsLinkOptions}" MODULE_DIR="src/utest" APP_NAME="srs_utest" . auto/utest.sh
|
||||
fi
|
||||
|
||||
|
@ -360,7 +385,7 @@ mv ${SRS_WORKDIR}/${SRS_MAKEFILE} ${SRS_WORKDIR}/${SRS_MAKEFILE}.bk
|
|||
|
||||
# generate phony header
|
||||
cat << END > ${SRS_WORKDIR}/${SRS_MAKEFILE}
|
||||
.PHONY: default _default install install-api help clean server librtmp _prepare_dir $__mphonys
|
||||
.PHONY: default _default install install-api help clean server srs_ingest_hls librtmp utest _prepare_dir $__mphonys
|
||||
|
||||
# install prefix.
|
||||
SRS_PREFIX=${SRS_PREFIX}
|
||||
|
@ -375,7 +400,7 @@ END
|
|||
# the server, librtmp and utest
|
||||
# where the bellow will check and disable some entry by only echo.
|
||||
cat << END >> ${SRS_WORKDIR}/${SRS_MAKEFILE}
|
||||
_default: server librtmp __modules $__mdefaults
|
||||
_default: server srs_ingest_hls librtmp utest __modules $__mdefaults
|
||||
@bash objs/_srs_build_summary.sh
|
||||
|
||||
help:
|
||||
|
|
7
trunk/modules/hls-ingester/config
Normal file
7
trunk/modules/hls-ingester/config
Normal file
|
@ -0,0 +1,7 @@
|
|||
|
||||
# The module to ingest hls to replace ffmpeg with better behavior.
|
||||
SRS_MODULE_NAME=("srs_hls_ingester")
|
||||
SRS_MODULE_MAIN=("srs_main_ingest_hls")
|
||||
SRS_MODULE_APP=()
|
||||
SRS_MODULE_DEFINES=""
|
||||
SRS_MODULE_MAKEFILE=""
|
7
trunk/modules/mp4-parser/config
Normal file
7
trunk/modules/mp4-parser/config
Normal file
|
@ -0,0 +1,7 @@
|
|||
|
||||
# The module to parse mp4 file.
|
||||
SRS_MODULE_NAME=("srs_mp4_parser")
|
||||
SRS_MODULE_MAIN=("srs_main_mp4_parser")
|
||||
SRS_MODULE_APP=()
|
||||
SRS_MODULE_DEFINES=""
|
||||
SRS_MODULE_MAKEFILE=""
|
27
trunk/modules/readme.txt
Normal file
27
trunk/modules/readme.txt
Normal file
|
@ -0,0 +1,27 @@
|
|||
SRS Module Rules(SRS模块规则)
|
||||
1. Each module in its seperate home directory(一个模块一个目录).
|
||||
2. There is a config file in home(目录下放一个config文件).
|
||||
3. All variables in configure are available(所有的configure中的变量模块中可以使用).
|
||||
|
||||
The Variables in config(模块中需要定义变量,例如):
|
||||
1. SRS_MODULE_NAME:The application binary name, optional. (模块名称,用来做Makefile的phony以及执行binary文件名。模块的二进制输出。为空时没有独立的二进制。)
|
||||
2. SRS_MODULE_MAIN:The source file in src/main directory, optional. (模块的main函数所在的cpp文件,在src/main目录。模块在main的文件。可以为空。)
|
||||
3. SRS_MODULE_APP:The source file in src/app directory, optional. (模块在src/app目录的源文件列表。模块在app的文件。可以为空。)
|
||||
4. SRS_MODULE_DEFINES: The extra defined macros, optional. (模块编译时的额外宏定义。在app和main模块加入。可以为空。)
|
||||
5. SRS_MODULE_MAKEFILE: The specified Makefile, optional. (模块的Makefile。在make时会执行这个Makefile。可以为空。)
|
||||
|
||||
Reset all Variables at the beginning(在配置开头必须清空这些变量):
|
||||
SRS_MODULE_NAME=()
|
||||
SRS_MODULE_MAIN=()
|
||||
SRS_MODULE_APP=()
|
||||
SRS_MODULE_DEFINES=""
|
||||
SRS_MODULE_MAKEFILE=""
|
||||
|
||||
For example(下面是一个实例):
|
||||
SRS_MODULE_NAME=("srs_rtmfpd")
|
||||
SRS_MODULE_MAIN=("srs_main_rtmfpd")
|
||||
SRS_MODULE_APP=("srs_app_rtfmpd")
|
||||
SRS_MODULE_DEFINES="-DRTMFPD"
|
||||
SRS_MODULE_MAKEFILE="modules/rtmfpd/Makefile"
|
||||
|
||||
winlin, 2015.3
|
|
@ -688,9 +688,11 @@ srs_error_t SrsServer::listen()
|
|||
if ((err = conn_manager->start()) != srs_success) {
|
||||
return srs_error_wrap(err, "connection manager");
|
||||
}
|
||||
#ifdef SRS_AUTO_SRT
|
||||
if ((err = listen_srt()) != srs_success) {
|
||||
return srs_error_wrap(err, "srt listen");
|
||||
}
|
||||
#endif
|
||||
|
||||
return err;
|
||||
}
|
||||
|
@ -1007,6 +1009,7 @@ srs_error_t SrsServer::do_cycle()
|
|||
return err;
|
||||
}
|
||||
|
||||
#ifdef SRS_AUTO_SRT
|
||||
srs_error_t SrsServer::listen_srt() {
|
||||
srs_error_t err = srs_success;
|
||||
|
||||
|
@ -1030,6 +1033,7 @@ srs_error_t SrsServer::listen_srt() {
|
|||
}
|
||||
return err;
|
||||
}
|
||||
#endif
|
||||
|
||||
srs_error_t SrsServer::listen_rtmp()
|
||||
{
|
||||
|
|
|
@ -36,8 +36,10 @@
|
|||
#include <srs_app_listener.hpp>
|
||||
#include <srs_app_conn.hpp>
|
||||
#include <srs_service_st.hpp>
|
||||
#include "../srt/srt_server.hpp"
|
||||
#include "../srt/srt_to_rtmp.hpp"
|
||||
#ifdef SRS_AUTO_SRT
|
||||
#include <srt_server.hpp>
|
||||
#include <srt_to_rtmp.hpp>
|
||||
#endif
|
||||
|
||||
class SrsServer;
|
||||
class SrsConnection;
|
||||
|
@ -211,11 +213,10 @@ private:
|
|||
SrsHttpHeartbeat* http_heartbeat;
|
||||
SrsIngester* ingester;
|
||||
SrsCoroutineManager* conn_manager;
|
||||
|
||||
private:
|
||||
//srt server
|
||||
#ifdef SRS_AUTO_SRT
|
||||
// srt server
|
||||
SRT_SERVER_PTR srt_ptr;
|
||||
|
||||
#endif
|
||||
private:
|
||||
// The pid file fd, lock the file write when server is running.
|
||||
// @remark the init.d script should cleanup the pid file, when stop service,
|
||||
|
@ -286,8 +287,10 @@ private:
|
|||
virtual srs_error_t listen_http_api();
|
||||
virtual srs_error_t listen_http_stream();
|
||||
virtual srs_error_t listen_stream_caster();
|
||||
#ifdef SRS_AUTO_SRT
|
||||
//start listen srt udp port
|
||||
virtual srs_error_t listen_srt();
|
||||
#endif
|
||||
// Close the listeners for specified type,
|
||||
// Remove the listen object from manager.
|
||||
virtual void close_listeners(SrsListenerType type);
|
||||
|
|
|
@ -1456,7 +1456,6 @@ srs_error_t SrsOriginHub::create_forwarders()
|
|||
if (!_srs_config->get_forward_enabled(req->vhost)) {
|
||||
return err;
|
||||
}
|
||||
srs_trace("srs vhost(%s) forward is enable.", req->host.c_str());
|
||||
|
||||
SrsConfDirective* conf = _srs_config->get_forwards(req->vhost);
|
||||
for (int i = 0; conf && i < (int)conf->args.size(); i++) {
|
||||
|
|
|
@ -142,26 +142,5 @@ extern ISrsThreadContext* _srs_context;
|
|||
#define srs_trace(msg, ...) (void)0
|
||||
#endif
|
||||
|
||||
inline void srs_trace_data(const char* data_p, int len, const char* dscr)
|
||||
{
|
||||
const int MAX = 256;
|
||||
char debug_data[MAX];
|
||||
char debug_len = 0;
|
||||
|
||||
debug_len += sprintf(debug_data + debug_len, "%s", dscr);
|
||||
|
||||
for (int index = 0; index < len; index++) {
|
||||
if (index % 16 == 0) {
|
||||
debug_len += sprintf(debug_data + debug_len, "\r\n");
|
||||
}
|
||||
debug_len += sprintf(debug_data + debug_len, " %02x", (unsigned char)data_p[index]);
|
||||
if (index >= 32) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
srs_trace("%s", debug_data);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -214,6 +214,7 @@ void show_macro_features()
|
|||
ss << ", dash:" << "on";
|
||||
ss << ", hls:" << srs_bool2switch(true);
|
||||
ss << ", hds:" << srs_bool2switch(SRS_AUTO_HDS_BOOL);
|
||||
ss << ", srt:" << srs_bool2switch(SRS_AUTO_SRT_BOOL);
|
||||
// hc(http callback)
|
||||
ss << ", hc:" << srs_bool2switch(true);
|
||||
// ha(http api)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue