Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SRT: Support Coroutine Native SRT over ST. #3010

Closed
wants to merge 41 commits into from
Closed
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
aff6102
Refine SRT code, with StateThread adpater
xiaozhihong Apr 15, 2022
193fcbd
SRT: Support debugging with CLion.
winlinvip Apr 16, 2022
a499a8c
SRT: Eliminate unused files for SRT.
winlinvip Apr 16, 2022
85e9581
SRT: check srt_connect return value
xiaozhihong Apr 16, 2022
7352bfe
SRT: support rtmp to srt
xiaozhihong Apr 20, 2022
5d33eec
SRT: fix utest failed
xiaozhihong Apr 22, 2022
8cea168
SRT: Fix cmake bug, quit if error.
winlinvip May 23, 2022
05d3d96
SRT: Update full.conf for new configs.
winlinvip May 23, 2022
4ce091e
SRT: Update full.conf for review.
winlinvip May 23, 2022
86d48c4
SRT: Add srt vhost section to full.conf.
winlinvip May 25, 2022
738e110
SRT: Refine parse SRT listen ip and port.
winlinvip May 28, 2022
bc59917
SRT: Refine the schedule resolution to 10ms if idle.
winlinvip May 28, 2022
f5101ae
SRT: Initialize SRT eventloop in adapter.
winlinvip May 28, 2022
16063d1
SRT: Refine get_srt_poller to poller.
winlinvip May 28, 2022
a7725f6
SRT: Refine the SRT socket code.
winlinvip May 28, 2022
14fb187
SRT: Add SRT option annotation in full.conf
xiaozhihong May 30, 2022
8558fb9
SRT: Tsbpdmode default on
xiaozhihong May 30, 2022
a3e0a3c
SRT: refine int to srs_utime_t in srt timeout config
xiaozhihong May 30, 2022
c096dfa
SRT: add option peer_idle_timeout in full.conf
xiaozhihong May 30, 2022
40725ab
SRT: use srs code style in function defination
xiaozhihong May 30, 2022
b217eaf
SRT: remove mix_correct
xiaozhihong May 30, 2022
c4abac8
SRT: remove rtmp_to_srt
xiaozhihong May 30, 2022
563cb81
SRT: Rename srs_service_st_srt to srs_protocol_srt
winlinvip Jun 7, 2022
083b8ce
SRT: Wrap SRT stat object.
winlinvip Jun 7, 2022
031ea96
SRT: Extract ISrsSrtPoller to hide SRT_EPOLL_EVENT
winlinvip Jun 7, 2022
248ce93
SRT: Hide srt implements from API.
winlinvip Jun 7, 2022
99a6d72
SRT: Undo extract of fetch_or_create_source and change mode_ to local.
winlinvip Jun 8, 2022
b2b6087
SRT: Refine packet error handler.
winlinvip Jun 8, 2022
a89c725
SRT: Add todo for coroutine yield.
winlinvip Jun 9, 2022
5933942
SRT: Merge develop, rename bridger to bridge.
winlinvip Jun 9, 2022
2668fec
SRT: Merge develop, rename filename in protocol.
winlinvip Jun 9, 2022
85591e9
SRT: Merge develop, prefix for protocol files.
winlinvip Jun 9, 2022
d57fd6b
Merge branch 'develop' into feature/srt
winlinvip Jun 9, 2022
93d0cfb
SRT: Merge develop, fix build fail.
winlinvip Jun 9, 2022
4c32b52
SRT: Refine code, remove SrsSrtListenerType
winlinvip Jun 10, 2022
424f5ec
SRT: Change bridges to bridge.
winlinvip Jun 10, 2022
f933e7f
SRT: move accept log into srt conn cycle
xiaozhihong Jun 12, 2022
9d97402
SRT: readd mix_correct, compatible old srt conf
xiaozhihong Jun 12, 2022
b7aad03
SRT: add srs_core_lock, support scope lock guard
xiaozhihong Jun 12, 2022
edc291a
SRT: add srt log handle, srs log supoort multithread
xiaozhihong Jun 12, 2022
d7dcf6d
SRT: Refine the lock for log.
winlinvip Jun 14, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions trunk/auto/depends.sh
Original file line number Diff line number Diff line change
Expand Up @@ -253,11 +253,9 @@ function OSX_prepare()

echo "OSX detected, install tools if needed"

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

gcc --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
Expand Down
6 changes: 0 additions & 6 deletions trunk/auto/options.sh
Original file line number Diff line number Diff line change
Expand Up @@ -432,12 +432,6 @@ function apply_auto_options() {
SRS_TOOL_LD=$SRS_TOOL_CC
fi

# The SRT code in SRS requires c++11, although we build libsrt without c++11.
# TODO: FIXME: Remove c++11 code in SRT of SRS.
if [[ $SRS_SRT == YES ]]; then
SRS_CXX11=YES
fi

# Enable FFmpeg fit for RTC to transcode audio from AAC to OPUS, if user enabled it.
if [[ $SRS_RTC == YES && $SRS_FFMPEG_FIT == RESERVED ]]; then
SRS_FFMPEG_FIT=YES
Expand Down
23 changes: 18 additions & 5 deletions trunk/conf/full.conf
Original file line number Diff line number Diff line change
Expand Up @@ -352,23 +352,36 @@ stream_caster {
#############################################################################################
# SRT server section
#############################################################################################
# @doc https://github.com/ossrs/srs/issues/1147#issuecomment-577607026
# @doc https://github.com/ossrs/srs/issues/1147#usage
srt_server {
# whether SRT server is enabled.
# default: off
enabled on;
# The UDP listen port for SRT.
listen 10080;
# For detail parameters, please read wiki:
# https://github.com/ossrs/srs/wiki/v4_CN_SRTParams
# https://github.com/ossrs/srs/wiki/v4_EN_SRTParams
# https://github.com/ossrs/srs/wiki/v5_CN_SRTParams
# https://github.com/ossrs/srs/wiki/v5_EN_SRTParams
maxbw 1000000000;
connect_timeout 4000;
peerlatency 300;
recvlatency 300;
# Default app for vmix, see https://github.com/ossrs/srs/pull/1615
# default: live
default_app live;
peerlatency 0;
recvlatency 0;
latency 0;
xiaozhihong marked this conversation as resolved.
Show resolved Hide resolved
tsbpdmode off;
tlpktdrop off;
sendbuf 2000000;
recvbuf 2000000;
}

vhost srt.vhost.srs.com {
srt {
enabled on;
srt_to_rtmp on;
rtmp_to_srt on;
}
}

#############################################################################################
Expand Down
15 changes: 13 additions & 2 deletions trunk/conf/srt.conf
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,23 @@ srt_server {
listen 10080;
maxbw 1000000000;
connect_timeout 4000;
peerlatency 300;
recvlatency 300;
peerlatency 0;
recvlatency 0;
latency 0;
tsbpdmode off;
tlpktdrop off;
sendbuf 2000000;
recvbuf 2000000;
}

# @doc https://github.com/ossrs/srs/issues/1147#issuecomment-577607026
vhost __defaultVhost__ {
srt {
enabled on;
srt_to_rtmp on;
rtmp_to_srt on;
}

http_remux {
enabled on;
mount [vhost]/[app]/[stream].flv;
Expand Down
32 changes: 11 additions & 21 deletions trunk/configure
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ fi

# srt code path
if [[ $SRS_SRT == YES ]]; then
SrsSRTRoot="${SRS_WORKDIR}/src/srt"
LibSRTRoot="${SRS_OBJS_DIR}/srt/include"; LibSRTfile="${SRS_OBJS_DIR}/srt/lib/libsrt.a"
if [[ $SRS_SHARED_SRT == YES ]]; then LibSRTfile="-L${SRS_OBJS_DIR}/srt/lib -lsrt"; fi
fi
Expand Down Expand Up @@ -228,6 +227,10 @@ MODULE_FILES=("srs_protocol_amf0" "srs_protocol_io" "srs_rtmp_stack"
"srs_raw_avc" "srs_rtsp_stack" "srs_http_stack" "srs_protocol_kbps" "srs_protocol_json"
"srs_protocol_format" "srs_service_log" "srs_service_st" "srs_service_http_client" "srs_service_http_conn"
"srs_service_rtmp_conn" "srs_service_utility" "srs_service_conn")
if [[ $SRS_SRT == YES ]]; then
MODULE_FILES+=("srs_service_st_srt")
ModuleLibIncs+=(${LibSRTRoot})
fi
if [[ $SRS_RTC == YES ]]; then
MODULE_FILES+=("srs_rtc_stun_stack")
ModuleLibIncs+=(${LibSrtpRoot})
Expand All @@ -237,16 +240,6 @@ if [[ $SRS_FFMPEG_FIT == YES ]]; then
fi
PROTOCOL_INCS="src/protocol"; MODULE_DIR=${PROTOCOL_INCS} . auto/modules.sh
PROTOCOL_OBJS="${MODULE_OBJS[@]}"
#
#srt protocol features.
if [[ $SRS_SRT == YES ]]; then
MODULE_ID="SRT"
MODULE_DEPENDS=("CORE" "KERNEL" "PROTOCOL" "APP")
ModuleLibIncs=(${SRS_OBJS_DIR} ${LibSSLRoot} ${LibSRTRoot})
MODULE_FILES=("srt_server" "srt_handle" "srt_conn" "srt_to_rtmp" "ts_demux" "srt_data" "srt_log")
SRT_INCS=(${LibSRTRoot} ${SrsSRTRoot}); MODULE_DIR=${SrsSRTRoot} . auto/modules.sh
SRT_OBJS="${MODULE_OBJS[@]}"
fi

#
#App Module, for SRS server only.
Expand All @@ -262,6 +255,9 @@ fi
if [[ $SRS_FFMPEG_FIT == YES ]]; then
ModuleLibIncs+=("${LibFfmpegRoot[*]}")
fi
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_bandwidth" "srs_app_st" "srs_app_log" "srs_app_config"
Expand All @@ -273,6 +269,9 @@ MODULE_FILES=("srs_app_server" "srs_app_conn" "srs_app_rtmp_conn" "srs_app_sourc
"srs_app_caster_flv" "srs_app_latest_version" "srs_app_uuid" "srs_app_process" "srs_app_ng_exec"
"srs_app_hourglass" "srs_app_dash" "srs_app_fragment" "srs_app_dvr"
"srs_app_coworkers" "srs_app_hybrid" "srs_app_threads")
if [[ $SRS_SRT == YES ]]; then
MODULE_FILES+=("srs_app_srt_server" "srs_app_srt_listener" "srs_app_srt_conn" "srs_app_srt_utility" "srs_app_srt_source")
fi
if [[ $SRS_RTC == YES ]]; then
MODULE_FILES+=("srs_app_rtc_conn" "srs_app_rtc_dtls" "srs_app_rtc_sdp"
"srs_app_rtc_queue" "srs_app_rtc_server" "srs_app_rtc_source" "srs_app_rtc_api")
Expand All @@ -294,9 +293,6 @@ APP_OBJS="${MODULE_OBJS[@]}"
#Server Module, for SRS only.
MODULE_ID="SERVER"
MODULE_DEPENDS=("CORE" "KERNEL" "PROTOCOL" "APP")
if [[ $SRS_SRT == YES ]]; then
MODULE_DEPENDS+=("SRT")
fi
ModuleLibIncs=(${SRS_OBJS_DIR} ${LibSTRoot} ${LibGperfRoot} ${LibSSLRoot})
if [[ $SRS_RTC == YES ]]; then
ModuleLibIncs+=(${LibSrtpRoot})
Expand All @@ -306,7 +302,6 @@ if [[ $SRS_FFMPEG_FIT == YES ]]; then
fi
if [[ $SRS_SRT == YES ]]; then
ModuleLibIncs+=(${LibSRTRoot})
ModuleLibIncs+=("${SrsSRTRoot[*]}")
fi
MODULE_FILES=("srs_main_server")
SERVER_INCS="src/main"; MODULE_DIR=${SERVER_INCS} . auto/modules.sh
Expand All @@ -324,7 +319,6 @@ if [[ $SRS_FFMPEG_FIT == YES ]]; then
fi
if [[ $SRS_SRT == YES ]]; then
ModuleLibIncs+=(${LibSRTRoot})
ModuleLibIncs+=("${SrsSRTRoot[*]}")
fi
MODULE_FILES=()
DEFINES=""
Expand Down Expand Up @@ -370,7 +364,6 @@ if [[ $SRS_FFMPEG_FIT == YES ]]; then
fi
if [[ $SRS_SRT == YES ]]; then
ModuleLibIncs+=(${LibSRTRoot})
ModuleLibIncs+=("${SrsSRTRoot[*]}")
MODULE_OBJS="${MODULE_OBJS} ${SRT_OBJS[@]}"
fi
LINK_OPTIONS="${SrsLinkOptions}${SrsGprofLink}${SrsGperfLink}"
Expand Down Expand Up @@ -413,7 +406,7 @@ if [ $SRS_UTEST = YES ]; then
ModuleLibIncs+=("${LibFfmpegRoot[*]}")
fi
if [[ $SRS_SRT == YES ]]; then
ModuleLibIncs+=("${SrsSRTRoot[*]}")
ModuleLibIncs+=("${LibSRTRoot[*]}")
fi
ModuleLibFiles=(${LibSTfile} ${LibSSLfile})
if [[ $SRS_RTC == YES ]]; then
Expand All @@ -426,9 +419,6 @@ if [ $SRS_UTEST = YES ]; then
ModuleLibFiles+=("${LibSRTfile[*]}")
fi
MODULE_DEPENDS=("CORE" "KERNEL" "PROTOCOL" "APP")
if [[ $SRS_SRT == YES ]]; then
MODULE_DEPENDS+=("SRT")
fi
MODULE_OBJS="${CORE_OBJS[@]} ${KERNEL_OBJS[@]} ${PROTOCOL_OBJS[@]} ${APP_OBJS[@]} ${SRT_OBJS[@]}"
LINK_OPTIONS="-lpthread ${SrsLinkOptions}" MODULE_DIR="src/utest" APP_NAME="srs_utest" . auto/utest.sh
fi
Expand Down
19 changes: 10 additions & 9 deletions trunk/ide/srs_clion/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,17 @@ ProcessorCount(JOBS)

# We should always configure SRS for switching between branches.
IF (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
EXEC_PROGRAM("cd ${SRS_DIR} && ./configure --osx --srt=on --utest=on --jobs=${JOBS}")
EXECUTE_PROCESS(
COMMAND ./configure --osx --srt=on --utest=on --jobs=${JOBS}
WORKING_DIRECTORY ${SRS_DIR} RESULT_VARIABLE ret)
ELSE ()
EXEC_PROGRAM("cd ${SRS_DIR} && ./configure --srt=on --utest=on --jobs=${JOBS}")
EXECUTE_PROCESS(
COMMAND ./configure --srt=on --utest=on --jobs=${JOBS}
WORKING_DIRECTORY ${SRS_DIR} RESULT_VARIABLE ret)
ENDIF ()
if(NOT ret EQUAL 0)
message(FATAL_ERROR "FAILED: ${ret}")
endif()

set(DEPS_LIBS ${SRS_DIR}/objs/st/libst.a
${SRS_DIR}/objs/openssl/lib/libssl.a
Expand Down Expand Up @@ -61,19 +68,13 @@ INCLUDE_DIRECTORIES(${SRS_DIR}/objs
${SRS_DIR}/src/kernel
${SRS_DIR}/src/protocol
${SRS_DIR}/src/app
${SRS_DIR}/src/service
${SRS_DIR}/src/srt)
${SRS_DIR}/src/service)

# Common used sources for SRS and utest.
AUX_SOURCE_DIRECTORY(${SRS_DIR}/src/core SOURCE_FILES)
AUX_SOURCE_DIRECTORY(${SRS_DIR}/src/kernel SOURCE_FILES)
AUX_SOURCE_DIRECTORY(${SRS_DIR}/src/protocol SOURCE_FILES)
AUX_SOURCE_DIRECTORY(${SRS_DIR}/src/app SOURCE_FILES)
AUX_SOURCE_DIRECTORY(${SRS_DIR}/src/srt SOURCE_FILES)

# Remove the duplicated test main for srt.
# TODO: FIMXE: Remove the file directly, use utest or main or research.
list(REMOVE_ITEM SOURCE_FILES ${SRS_DIR}/src/srt/ts_demux_test.cpp)

ADD_DEFINITIONS("-g -O0")

Expand Down
Loading