Skip to content

Commit

Permalink
feat(sctp): update build script, usage configure --sctp=on, default off
Browse files Browse the repository at this point in the history
  • Loading branch information
johzzy committed Apr 2, 2023
1 parent cfdbd98 commit 162cb17
Show file tree
Hide file tree
Showing 13 changed files with 230 additions and 4 deletions.
4 changes: 4 additions & 0 deletions trunk/3rdparty/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,7 @@ links:
http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz
* speex:
http://downloads.xiph.org/releases/speex/speex-1.2rc1.tar.gz
* srtp:
https://github.com/cisco/libsrtp/releases/tag/v2.3.0
* usrsctp:
https://github.com/sctplab/usrsctp
7 changes: 7 additions & 0 deletions trunk/auto/auto_headers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ echo "#define SRS_BUILD_DATE \"`date \"+%Y-%m-%d %H:%M:%S\"`\"" >> $SRS_AUTO_HEA
echo "#define SRS_UNAME \"`uname -a`\"" >> $SRS_AUTO_HEADERS_H
echo "#define SRS_USER_CONFIGURE \"${SRS_AUTO_USER_CONFIGURE}\"" >> $SRS_AUTO_HEADERS_H
echo "#define SRS_CONFIGURE \"${SRS_AUTO_CONFIGURE}\"" >> $SRS_AUTO_HEADERS_H
echo "#define GIT_COMMIT_ID \"`git rev-parse --short HEAD`\"" >> $SRS_AUTO_HEADERS_H
echo "" >> $SRS_AUTO_HEADERS_H

function srs_define_macro()
Expand Down Expand Up @@ -104,6 +105,12 @@ else
srs_undefine_macro "SRS_SIMULATOR" $SRS_AUTO_HEADERS_H
fi

if [[ $SRS_SCTP == YES ]]; then
srs_define_macro "SRS_SCTP" $SRS_AUTO_HEADERS_H
else
srs_undefine_macro "SRS_SCTP" $SRS_AUTO_HEADERS_H
fi

if [[ $SRS_HTTPS == YES ]]; then
srs_define_macro "SRS_HTTPS" $SRS_AUTO_HEADERS_H
else
Expand Down
28 changes: 28 additions & 0 deletions trunk/auto/depends.sh
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,34 @@ if [[ $SRS_RTC == YES ]]; then
ret=$?; if [[ $ret -ne 0 ]]; then echo "Build libsrtp failed, ret=$ret"; exit $ret; fi
fi



#####################################################################################
# sctp, for WebRTC datachannel
#####################################################################################
# aclocal
# https://github.com/Homebrew/homebrew-core/issues/21125
# brew install automake

if [[ $SRS_SCTP == YES ]]; then
if [[ -f ${SRS_OBJS}/${SRS_PLATFORM}/sctp/lib/libusrsctp.a ]]; then
echo "The usrsctp is ok.";
else
echo "Building usrsctp.";
(
rm -rf ${SRS_OBJS}/${SRS_PLATFORM}/usrsctp && cd ${SRS_OBJS}/${SRS_PLATFORM} &&
mkdir -p usrsctp && cd usrsctp && cp -R ../../../3rdparty/usrsctp/* . &&
./bootstrap && ./configure --prefix=`pwd`/_release --enable-static --disable-shared && make ${SRS_JOBS} && make install
cd .. && rm -rf sctp && ln -sf usrsctp/_release sctp
)
fi
# check status
ret=$?; if [[ $ret -ne 0 ]]; then echo "Build usrsctp failed, ret=$ret"; exit $ret; fi
# Always update the links.
(cd ${SRS_OBJS} && rm -rf sctp && ln -sf ${SRS_PLATFORM}/usrsctp/_release sctp)
if [ ! -f ${SRS_OBJS}/sctp/lib/libusrsctp.a ]; then echo "Build usrsctp failed."; exit -1; fi
fi

#####################################################################################
# libopus, for WebRTC to transcode AAC with Opus.
#####################################################################################
Expand Down
4 changes: 4 additions & 0 deletions trunk/auto/options.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ SRS_SRT=YES
SRS_RTC=YES
SRS_H265=NO
SRS_GB28181=NO
SRS_SCTP=NO
SRS_CXX11=YES
SRS_CXX14=NO
SRS_BACKTRACE=YES
Expand Down Expand Up @@ -169,6 +170,7 @@ Features:
--srt=on|off Whether build the SRT. Default: $(value2switch $SRS_SRT)
--rtc=on|off Whether build the WebRTC. Default: $(value2switch $SRS_RTC)
--gb28181=on|off Whether build the GB28181. Default: $(value2switch $SRS_GB28181)
--sctp=on|off Whether build the SCTP for DataChannel. Default: $(value2switch $SRS_SCTP)
--cxx11=on|off Whether enable the C++11. Default: $(value2switch $SRS_CXX11)
--cxx14=on|off Whether enable the C++14. Default: $(value2switch $SRS_CXX14)
--ffmpeg-fit=on|off Whether enable the FFmpeg fit(source code). Default: $(value2switch $SRS_FFMPEG_FIT)
Expand Down Expand Up @@ -356,6 +358,7 @@ function parse_user_option() {
--ffmpeg-opus) SRS_FFMPEG_OPUS=$(switch2value $value) ;;
--h265) SRS_H265=$(switch2value $value) ;;
--gb28181) SRS_GB28181=$(switch2value $value) ;;
--sctp) SRS_SCTP=$(switch2value $value) ;;

--cxx11) SRS_CXX11=$(switch2value $value) ;;
--cxx14) SRS_CXX14=$(switch2value $value) ;;
Expand Down Expand Up @@ -631,6 +634,7 @@ function regenerate_options() {
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --rtc=$(value2switch $SRS_RTC)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --h265=$(value2switch $SRS_H265)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --gb28181=$(value2switch $SRS_GB28181)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --sctp=$(value2switch $SRS_SCTP)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --simulator=$(value2switch $SRS_SIMULATOR)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --cxx11=$(value2switch $SRS_CXX11)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --cxx14=$(value2switch $SRS_CXX14)"
Expand Down
2 changes: 1 addition & 1 deletion trunk/research/console/en_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html ng-app="scApp">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>SRS控制台</title>
<title>SRS Console</title>
<link rel="stylesheet" type="text/css" href="js/3rdparty/bootstrap.min.css"/>
<link rel="stylesheet" type="text/css" href="js/srs.console.css"/>
<style>
Expand Down
2 changes: 1 addition & 1 deletion trunk/research/console/views/streams_en.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@
</div>
</div>
</div>
</div>
</div>
4 changes: 2 additions & 2 deletions trunk/research/console/views/vhosts_en.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
<td><a href="javascript:void(0)" ng-click="gogogo('/vhosts/' + vhost.id)">{{vhost.id}}</a></td>
<td>{{vhost.name}}</td>
<td>{{vhost.enabled| sc_filter_enabled}}</td>
<td>{{vhost.streams}}</td>
<td>{{vhost.clients}}</td>
<td>{{vhost.streams}}</td>
<td>{{vhost.clients}}</td>
<td>{{vhost.kbps.recv_30s| sc_filter_bitrate_k}}</td>
<td>{{vhost.kbps.send_30s| sc_filter_bitrate_k}}</td>
<td>{{vhost.hls.enabled| sc_filter_enabled}}</td>
Expand Down
1 change: 1 addition & 0 deletions trunk/research/players/js/srs.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ function update_nav() {
$("#nav_rtc_publisher").attr("href", "rtc_publisher.html" + window.location.search);
$("#nav_whip").attr("href", "whip.html" + window.location.search);
$("#nav_whep").attr("href", "whep.html" + window.location.search);
$("#nav_rtc_datachannel").attr("href", "rtc_datachannel.html" + window.location.search);
$("#nav_srs_publisher").attr("href", "srs_publisher.html" + window.location.search);
$("#nav_srs_chat").attr("href", "srs_chat.html" + window.location.search);
$("#nav_srs_bwt").attr("href", "srs_bwt.html" + window.location.search);
Expand Down
178 changes: 178 additions & 0 deletions trunk/research/players/rtc_datachannel.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
<!DOCTYPE html>
<html>
<head>
<title>SRS</title>
<meta charset="utf-8">
<style>
body{
padding-top: 55px;
}
</style>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css"/>
<script type="text/javascript" src="js/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="js/adapter-7.4.0.min.js"></script>
<script type="text/javascript" src="js/winlin.utility.js"></script>
<script type="text/javascript" src="js/srs.page.js"></script>
</head>
<body>
<img src='https://ossrs.net/gif/v1/sls.gif?site=ossrs.net&path=/player/rtcdatachannel'/>
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a id="srs_index" class="brand" href="https://github.com/ossrs/srs">SRS</a>
<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_rtc_publisher" href="rtc_publisher.html">RTC推流</a></li>
<li class="active"><a id="nav_rtc_datachannel" href="rtc_datachannel.html">RTC数据</a></li>
<li><a href="http://ossrs.net/srs.release/releases/app.html">iOS/Andriod</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>-->
<!--<li><a id="nav_jwplayer6" href="jwplayer6.html">JWPlayer6播放器</a></li>-->
<!--<li><a id="nav_osmf" href="osmf.html">AdobeOSMF播放器</a></li>-->
<!--<li><a id="nav_vlc" href="vlc.html">VLC播放器</a></li>-->
<li><a id="nav_gb28181" href="srs_gb28181.html">GB28181</a></li>
<li><a href="https://github.com/ossrs/srs">源码</a></li>
</ul>
</div>
</div>
</div>
</div>
<div class="container">
<div class="form-inline">
URL:
<input type="text" id="txt_url" class="input-xxlarge" value="">
<button class="btn btn-primary" id="btn_connect">连接</button>
</div>

<div id="rtc_data">
<label></label>
<div class="form-inline">
SND:
<input type="text" id="txt_send" class="input-xxlarge" value="">
<button class="btn btn-primary" id="btn_send">发送</button>
</div>

<label></label>
<div class="form-inline">
RCV:
<input type="text" id="txt_receive" class="input-xxlarge" value="">
</div>
</div>

<footer>
<p></p>
<p><a href="https://github.com/ossrs/srs">SRS Team &copy; 2020</a></p>
</footer>
</div>
<script type="text/javascript">
var pc = null; // Global handler to do cleanup when replaying.
var dc = null;
$(function(){
var connectServer = function() {
// $('#rtc_data').show();
var urlObject = parse_rtmp_url($("#txt_url").val());
var schema = window.location.protocol;

// Close PC when user replay.
if (pc) {
pc.close();
}
if (dc) {
dc.close();
}

pc = new RTCPeerConnection(null);
// @see https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/createDataChannel
dc = pc.createDataChannel("sdc", {
ordered: false, maxRetransmits: 5
});
dc.onmessage = function (e) {
console.log("receive message: ", e);
$('#txt_receive').val(e.data);
};
dc.onopen = function () {
$('#rtc_data').show();
console.log("datachannel open");
};

dc.onclose = function () {
$('#rtc_data').hide();
console.log("datachannel close");
};
new Promise(function(resolve, reject) {
pc.createOffer(function(offer){
resolve(offer);
},function(reason){
reject(reason);
});
}).then(function(offer) {
return pc.setLocalDescription(offer).then(function(){ return offer; });
}).then(function(offer) {
return new Promise(function(resolve, reject) {
var port = urlObject.port || 1985;

// @see https://github.com/rtcdn/rtcdn-draft
var api = urlObject.user_query.data || '/rtc/v1/data/';
if (api.lastIndexOf('/') != api.length - 1) {
api += '/';
}

var url = schema + '//' + urlObject.server + ':' + port + api;
for (var key in urlObject.user_query) {
if (key != 'api' && key != 'data') {
url += '&' + key + '=' + urlObject.user_query[key];
}
}
// Replace /rtc/v1/data/&k=v to /rtc/v1/data/?k=v
url = url.replace(api + '&', api + '?');

// @see https://github.com/rtcdn/rtcdn-draft
var data = {
api: url, streamurl: urlObject.url, clientip: null, sdp: offer.sdp
};
console.log("Generated offer: ", data);

$.ajax({
type: "POST", url: url, data: JSON.stringify(data),
contentType:'application/json', dataType: 'json'
}).done(function(data) {
console.log("Got answer: ", data);
if (data.code) {
reject(data); return;
}
resolve(data.sdp);
}).fail(function(reason){
reject(reason);
});
});
}).then(function(answer) {
return pc.setRemoteDescription(new RTCSessionDescription({type: 'answer', sdp: answer}));
}).catch(function(reason) {
pc.close(); $('#rtc_data').hide();
throw reason;
});
};

$('#rtc_data').hide();
var query = parse_query_string();
srs_init_rtc("#txt_url", query);

$("#btn_send").click(function(e) {
if (!dc) return;
console.log("send message: ", $('#txt_send').val());
console.log('readyState:', dc.readyState);
dc.send($('#txt_send').val());
});

$("#btn_connect").click(connectServer);
if (query.autostart === 'true') {
connectServer();
}
});
</script>
</body>
</html>

1 change: 1 addition & 0 deletions trunk/research/players/rtc_player.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<li><a id="nav_rtc_publisher" href="rtc_publisher.html">RTC推流</a></li>
<li><a id="nav_whip" href="whip.html">WHIP</a></li>
<li><a id="nav_whep" href="whip.html">WHEP</a></li>
<li><a id="nav_rtc_datachannel" href="rtc_datachannel.html">RTC数据</a></li>
<li><a href="http://ossrs.net/srs.release/releases/app.html">iOS/Andriod</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>-->
Expand Down
1 change: 1 addition & 0 deletions trunk/research/players/rtc_publisher.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<li class="active"><a id="nav_rtc_publisher" href="rtc_publisher.html">RTC推流</a></li>
<li><a id="nav_whip" href="whip.html">WHIP</a></li>
<li><a id="nav_whep" href="whip.html">WHEP</a></li>
<li><a id="nav_rtc_datachannel" href="rtc_datachannel.html">RTC数据</a></li>
<li><a href="http://ossrs.net/srs.release/releases/app.html">iOS/Andriod</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>-->
Expand Down
1 change: 1 addition & 0 deletions trunk/research/players/srs_gb28181.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
<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_rtc_publisher" href="rtc_publisher.html">RTC推流</a></li>
<li><a id="nav_rtc_datachannel" href="rtc_datachannel.html">RTC数据</a></li>
<li><a href="http://ossrs.net/srs.release/releases/app.html">iOS/Andriod</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>-->
Expand Down
1 change: 1 addition & 0 deletions trunk/research/players/srs_player.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<li><a id="nav_rtc_publisher" href="rtc_publisher.html">RTC推流</a></li>
<li><a id="nav_whip" href="whip.html">WHIP</a></li>
<li><a id="nav_whep" href="whip.html">WHEP</a></li>
<li><a id="nav_rtc_datachannel" href="rtc_datachannel.html">RTC数据</a></li>
<li><a href="http://ossrs.net/srs.release/releases/app.html">iOS/Andriod</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>-->
Expand Down

0 comments on commit 162cb17

Please sign in to comment.