Merge branch '3.0release' into develop

min
winlin 5 years ago
commit c848050bb6

@ -3,7 +3,6 @@
[![](https://circleci.com/gh/ossrs/srs/tree/develop.svg?style=svg&circle-token=1ef1d5b5b0cde6c8c282ed856a18199f9e8f85a9)](https://circleci.com/gh/ossrs/srs/tree/develop)
[![](https://codecov.io/gh/ossrs/srs/branch/develop/graph/badge.svg)](https://codecov.io/gh/ossrs/srs/branch/develop)
[![](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 is a simple live streaming cluster, a simple joy.
@ -154,6 +153,10 @@ Please select according to languages:
### V3 changes
* v3.0, 2019-10-06, Support log rotate by init.d command. 3.0.60
* v3.0, 2019-10-06, We prefer ipv4, only use ipv6 if ipv4 is disabled. 3.0.59
* v3.0, 2019-10-05, Support systemctl service for CentOS7. 3.0.58
* v3.0, 2019-10-04, Disable SO_REUSEPORT if not supported. 3.0.57
* <strong>v3.0, 2019-10-04, [3.0 alpha0(3.0.56)][r3.0a0] released. 107946 lines.</strong>
* v3.0, 2019-10-04, Support go-oryx rtmplb with [proxy protocol](https://github.com/ossrs/go-oryx/wiki/RtmpProxy). 3.0.56
* v3.0, 2019-10-03, Fix [#775][bug #775], Support SO_REUSEPORT to improve edge performance. 3.0.54

@ -0,0 +1,15 @@
# the config for srs origin-edge cluster
# @see https://github.com/ossrs/srs/wiki/v1_CN_Edge
# @see full.conf for detail config.
listen 19351;
max_connections 1000;
pid objs/edge1.pid;
daemon off;
srs_log_tank console;
vhost __defaultVhost__ {
cluster {
mode remote;
origin 127.0.0.1:19350;
}
}

@ -0,0 +1,15 @@
# the config for srs origin-edge cluster
# @see https://github.com/ossrs/srs/wiki/v1_CN_Edge
# @see full.conf for detail config.
listen 19352;
max_connections 1000;
pid objs/edge2.pid;
daemon off;
srs_log_tank console;
vhost __defaultVhost__ {
cluster {
mode remote;
origin 127.0.0.1:19350;
}
}

22
trunk/configure vendored

@ -484,22 +484,30 @@ install:
@mkdir -p \$(__REAL_INSTALL)
@echo "Now make the http root dir"
@mkdir -p \$(__REAL_INSTALL)/objs/nginx/html
@cp research/api-server/static-dir/crossdomain.xml \$(__REAL_INSTALL)/objs/nginx/html
@cp -f research/api-server/static-dir/crossdomain.xml \$(__REAL_INSTALL)/objs/nginx/html
@echo "Now copy binary files"
@mkdir -p \$(__REAL_INSTALL)/objs
@cp objs/srs \$(__REAL_INSTALL)/objs
@cp -f objs/srs \$(__REAL_INSTALL)/objs
@echo "Now copy srs conf files"
@mkdir -p \$(__REAL_INSTALL)/conf
@cp conf/*.conf \$(__REAL_INSTALL)/conf
@cp -f conf/*.conf \$(__REAL_INSTALL)/conf
@echo "Now copy init.d script files"
@mkdir -p \$(__REAL_INSTALL)/etc/init.d
@cp etc/init.d/srs \$(__REAL_INSTALL)/etc/init.d
@cp -f etc/init.d/srs \$(__REAL_INSTALL)/etc/init.d
@sed -i "s|^ROOT=.*|ROOT=\"\$(SRS_PREFIX)\"|g" \$(__REAL_INSTALL)/etc/init.d/srs
@echo "Now copy systemctl service files"
@mkdir -p \$(__REAL_INSTALL)/usr/lib/systemd/system
@cp -f usr/lib/systemd/system/srs.service \$(__REAL_INSTALL)/usr/lib/systemd/system/srs.service
@echo ""
@echo "SRS is installed, to link and start srs:"
@echo " sudo ln -sf \$(SRS_PREFIX)/etc/init.d/srs /etc/init.d/srs"
@echo "The api installed, to link and start srs, please"
@echo "For CentOS6:"
@echo " sudo ln -sf \$(SRS_PREFIX)/etc/init.d/srs /etc/init.d/srs &&"
@echo " /etc/init.d/srs start"
@echo "@see: https://github.com/ossrs/srs/wiki/v1_CN_LinuxService"
@echo "For CentOS7:"
@echo " sudo ln -sf \$(SRS_PREFIX)/etc/init.d/srs /etc/init.d/srs &&"
@echo " sudo cp -f \$(SRS_PREFIX)/usr/lib/systemd/system/srs.service /usr/lib/systemd/system/srs.service && sudo systemctl daemon-reload && sudo systemctl enable srs &&"
@echo " sudo systemctl start srs"
@echo "@see: https://github.com/ossrs/srs/wiki/v3_CN_LinuxService"
END
fi

@ -166,6 +166,18 @@ reload() {
return 0
}
logrotate() {
# not start, exit
load_process_info
if [[ 0 -ne $? ]]; then failed_msg "SRS not start."; return 0; fi
ok_msg "Reopen log file of SRS(pid ${srs_pid})..."
kill -s SIGUSR1 ${srs_pid}
ok_msg "Log rotated"
return 0
}
menu() {
case "$1" in
start)
@ -184,8 +196,13 @@ menu() {
reload)
reload
;;
rotate)
logrotate
;;
*)
echo "Usage: $0 {start|stop|status|restart|reload}"
echo "Usage: $0 {start|stop|status|restart|reload|rotate}"
echo " reload Apply log file by not restarting SRS"
echo " rotate For log rotate, to send SIGUSR1 to SRS to reopen the log file."
return 1
;;
esac

@ -69,6 +69,7 @@ ok_msg "copy core components"
mkdir -p $install_root
cp -r $work_dir/${INSTALL}/conf $install_root &&
cp -r $work_dir/${INSTALL}/etc $install_root &&
cp -r $work_dir/${INSTALL}/usr $install_root &&
cp -r $work_dir/${INSTALL}/objs $install_root
) >>$log 2>&1
ret=$?; if [[ 0 -ne ${ret} ]]; then failed_msg "copy core components failed"; exit $ret; fi
@ -83,6 +84,17 @@ ok_msg "install init.d scripts"
ret=$?; if [[ 0 -ne ${ret} ]]; then failed_msg "install init.d scripts failed"; exit $ret; fi
ok_msg "install init.d scripts success"
# For systemctl
if [[ -d /usr/lib/systemd/system ]]; then
ok_msg "install srs.service for systemctl"
(
cp -f $install_root/usr/lib/systemd/system/srs.service /usr/lib/systemd/system/srs.service &&
systemctl daemon-reload
) >>$log 2>&1
ret=$?; if [[ 0 -ne ${ret} ]]; then failed_msg "install srs.service for systemctl failed"; exit $ret; fi
ok_msg "install srs.service for systemctl success"
fi
# install system service
lsb_release --id|grep "CentOS" >/dev/null 2>&1; os_id_centos=$?
lsb_release --id|grep "Ubuntu" >/dev/null 2>&1; os_id_ubuntu=$?
@ -90,7 +102,11 @@ lsb_release --id|grep "Debian" >/dev/null 2>&1; os_id_debian=$?
lsb_release --id|grep "Raspbian" >/dev/null 2>&1; os_id_rasabian=$?
if [[ 0 -eq $os_id_centos ]]; then
ok_msg "install system service for CentOS"
/sbin/chkconfig --add srs && /sbin/chkconfig srs on
if [[ -d /usr/lib/systemd/system ]]; then
systemctl enable srs
else
/sbin/chkconfig --add srs && /sbin/chkconfig srs on
fi
ret=$?; if [[ 0 -ne ${ret} ]]; then failed_msg "install system service failed"; exit $ret; fi
ok_msg "install system service success"
elif [[ 0 -eq $os_id_ubuntu ]]; then
@ -113,9 +129,11 @@ else
fi
echo ""
echo "see: https://github.com/ossrs/srs/wiki/v1_CN_LinuxService"
echo "install success, you can:"
echo "see: https://github.com/ossrs/srs/wiki/v3_CN_LinuxService"
echo "install success, you can start SRS on CentOS6:"
echo -e "${GREEN} sudo /etc/init.d/srs start${BLACK}"
echo "or CentOS7:"
echo -e "${GREEN} sudo systemctl start srs${BLACK}"
echo "srs root is ${INSTALL}"
exit 0

@ -87,7 +87,9 @@ ret=$?; if [[ $ret -ne 0 ]]; then
failed_msg "lsb_release not found. "
failed_msg "to install on centos/debian(ubuntu/respberry-pi):";
failed_msg " sudo yum install -y lsb-release";
failed_msg " sudo aptitude install -y lsb-release";
failed_msg " sudo aptitude install -y lsb-release";
failed_msg "or centos7:"
failed_msg " sudo yum install -y redhat-lsb"
exit $ret;
fi

@ -0,0 +1,15 @@
#!/bin/bash
if [[ -d /usr/lib/systemd/system ]]; then
systemctl disable srs
systemctl stop srs
rm -f /usr/lib/systemd/system/srs.service
rm -f /etc/init.d/srs
else
/sbin/chkconfig srs off
/sbin/chkconfig --del srs
/etc/init.d/srs stop
rm -f /etc/init.d/srs
fi
rm -rf /usr/local/srs
echo "SRS uninstalled"

@ -52,7 +52,7 @@ SrsRtpConn::SrsRtpConn(SrsRtspConn* r, int p, int sid)
_port = p;
stream_id = sid;
// TODO: support listen at <[ip:]port>
listener = new SrsUdpListener(this, srs_any_address4listener(), p);
listener = new SrsUdpListener(this, srs_any_address_for_listener(), p);
cache = new SrsRtpPacket();
pprint = SrsPithyPrint::create_caster();
}

@ -1017,9 +1017,8 @@ srs_error_t SrsServer::listen_rtmp()
for (int i = 0; i < (int)ip_ports.size(); i++) {
SrsListener* listener = new SrsBufferListener(this, SrsListenerRtmpStream);
listeners.push_back(listener);
std::string ip;
int port;
int port; string ip;
srs_parse_endpoint(ip_ports[i], ip, port);
if ((err = listener->listen(ip, port)) != srs_success) {
@ -1113,7 +1112,7 @@ srs_error_t SrsServer::listen_stream_caster()
}
// TODO: support listen at <[ip:]port>
if ((err = listener->listen(srs_any_address4listener(), port)) != srs_success) {
if ((err = listener->listen(srs_any_address_for_listener(), port)) != srs_success) {
return srs_error_wrap(err, "listen at %d", port);
}
}

@ -27,7 +27,7 @@
// The version config.
#define VERSION_MAJOR 3
#define VERSION_MINOR 0
#define VERSION_REVISION 56
#define VERSION_REVISION 60
// The macros generated by configure script.
#include <srs_auto_headers.hpp>

@ -210,18 +210,29 @@ void srs_parse_hostport(const string& hostport, string& host, int& port)
}
}
string srs_any_address4listener()
string srs_any_address_for_listener()
{
int fd = socket(AF_INET6, SOCK_DGRAM, 0);
// socket()
// A -1 is returned if an error occurs, otherwise the return value is a
// descriptor referencing the socket.
if(fd != -1) {
close(fd);
bool ipv4_active = false;
bool ipv6_active = false;
if (true) {
int fd = socket(AF_INET, SOCK_DGRAM, 0);
if(fd != -1) {
ipv4_active = true;
close(fd);
}
}
if (true) {
int fd = socket(AF_INET6, SOCK_DGRAM, 0);
if(fd != -1) {
ipv6_active = true;
close(fd);
}
}
if (ipv6_active && !ipv4_active) {
return "::";
}
return "0.0.0.0";
}
@ -240,7 +251,7 @@ void srs_parse_endpoint(string hostport, string& ip, int& port)
const string sport = hostport.substr(pos + 1);
port = ::atoi(sport.c_str());
} else {
ip = srs_any_address4listener();
ip = srs_any_address_for_listener();
port = ::atoi(hostport.c_str());
}
}

@ -48,7 +48,8 @@ extern srs_utime_t srs_get_system_startup_time();
extern srs_utime_t srs_update_system_time();
// The "ANY" address to listen, it's "0.0.0.0" for ipv4, and "::" for ipv6.
extern std::string srs_any_address4listener();
// @remark We prefer ipv4, only use ipv6 if ipv4 is disabled.
extern std::string srs_any_address_for_listener();
// The dns resolve utility, return the resolved ip address.
extern std::string srs_dns_resolve(std::string host, int& family);

@ -112,10 +112,15 @@ srs_error_t srs_fd_reuseaddr(int fd)
srs_error_t srs_fd_reuseport(int fd)
{
#if defined(SO_REUSEPORT)
int v = 1;
if (setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &v, sizeof(int)) == -1) {
return srs_error_new(ERROR_SOCKET_SETREUSEADDR, "SO_REUSEPORT fd=%v", fd);
}
#else
#warning "SO_REUSEPORT is not supported by your OS"
srs_warn("SO_REUSEPORT is not supported util Linux kernel 3.9");
#endif
return srs_success;
}

@ -4086,7 +4086,7 @@ VOID TEST(KernelUtilityTest, CoverTimeUtilityAll)
}
if (true) {
string ep = srs_any_address4listener();
string ep = srs_any_address_for_listener();
EXPECT_TRUE(ep == "0.0.0.0" || ep == "::");
}

@ -0,0 +1,12 @@
[Unit]
Description=The SRS Media Stream Cluster
After=network.target
[Service]
Type=forking
ExecStart=/etc/init.d/srs start
ExecReload=/etc/init.d/srs reload
ExecStop=/etc/init.d/srs stop
[Install]
WantedBy=multi-user.target
Loading…
Cancel
Save