Squash: Support RPM. Fix bugs.

pull/2714/head
winlin 3 years ago
parent a01354a595
commit 523b055c06

@ -18,14 +18,17 @@ jobs:
uses: actions/checkout@v2
# The github.ref is, for example, refs/tags/v4.0.145 or refs/tags/v4.0-r8
# Generate variables like:
# SRS_TAG=v4.0.145
# SRS_TAG=v4.0-r8
# SRS_TAG=v4.0.145
# SRS_VERSION=4.0.145
# SRS_MAJOR=4
# @see https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
- name: Generate varaiables
run: |
SRS_TAG=$(echo ${{ github.ref }}| awk -F '/' '{print $3}')
echo "SRS_TAG=$SRS_TAG" >> $GITHUB_ENV
SRS_VERSION=$(echo ${SRS_TAG}| sed 's/^v//g')
echo "SRS_VERSION=$SRS_VERSION" >> $GITHUB_ENV
SRS_MAJOR=$(echo $SRS_TAG| cut -c 2)
echo "SRS_MAJOR=$SRS_MAJOR" >> $GITHUB_ENV
# Create source tar for release. Note that it's for OpenWRT package srs-server, so the filename MUST be
@ -35,12 +38,24 @@ jobs:
# SRS_SOURCE_MD5=83e38700a80a26e30b2df054e69956e5
- name: Create source tar.gz
run: |
DEST_DIR=srs-server-$(echo ${SRS_TAG}| sed 's/^v//g') && mkdir -p $DEST_DIR &&
DEST_DIR=srs-server-$SRS_VERSION && mkdir -p $DEST_DIR &&
cp README.md $DEST_DIR && cp LICENSE $DEST_DIR && cp -R trunk $DEST_DIR/trunk &&
(cd $DEST_DIR/trunk/3rdparty && rm -rf *.zip openssl-*.gz srs-bench) &&
tar zcf ${DEST_DIR}.tar.gz ${DEST_DIR} && du -sh ${DEST_DIR}* && rm -rf ${DEST_DIR} &&
echo "SRS_SOURCE_TAR=${DEST_DIR}.tar.gz" >> $GITHUB_ENV &&
echo "SRS_SOURCE_MD5=$(md5sum ${DEST_DIR}.tar.gz| awk '{print $1}')" >> $GITHUB_ENV
# Create package tar for release
# Generate variables like:
# SRS_PACKAGE_ZIP=SRS-CentOS7-x86_64-4.0.145.zip
# SRS_PACKAGE_MD5=3880a26e30b283edf05700a4e69956e5
- name: Create package zip
run: |
docker build --tag srs:pkg --build-arg version=$SRS_VERSION -f trunk/Dockerfile.pkg . &&
SRS_PACKAGE_ZIP=SRS-CentOS7-x86_64-$SRS_VERSION.zip &&
docker run --rm -v $(pwd):/output srs:pkg cp objs/$SRS_PACKAGE_ZIP /output/ &&
du -sh $SRS_PACKAGE_ZIP &&
echo "SRS_PACKAGE_ZIP=$SRS_PACKAGE_ZIP" >> $GITHUB_ENV &&
echo "SRS_PACKAGE_MD5=$(md5sum $SRS_PACKAGE_ZIP| awk '{print $1}')" >> $GITHUB_ENV
################################################################
# Tests
@ -116,15 +131,25 @@ jobs:
body: |
${{ github.event.head_commit.message }}
${{ env.SRS_SOURCE_MD5 }} [${{ env.SRS_SOURCE_TAR }}](https://github.com/ossrs/srs/releases/download/${{ env.SRS_TAG }}/${{ env.SRS_SOURCE_TAR }})
${{ env.SRS_PACKAGE_MD5 }} [${{ env.SRS_PACKAGE_ZIP }}](https://github.com/ossrs/srs/releases/download/${{ env.SRS_TAG }}/${{ env.SRS_PACKAGE_ZIP }})
draft: false
prerelease: true
# Upload release files
- name: Upload Release Assets
id: upload-release-assets
# Upload release source files
- name: Upload Release Assets Source
id: upload-release-assets-source
uses: dwenegar/upload-release-assets@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_id: ${{ steps.create_release.outputs.id }}
assets_path: ${{ env.SRS_SOURCE_TAR }}
# Upload release package files
- name: Upload Release Assets Package
id: upload-release-assets-package
uses: dwenegar/upload-release-assets@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_id: ${{ steps.create_release.outputs.id }}
assets_path: ${{ env.SRS_PACKAGE_ZIP }}

@ -92,7 +92,7 @@ A big `THANK YOU` also goes to:
## Releases
* 2021-10-28, Release [v4.0.187](https://github.com/ossrs/srs/releases/tag/v4.0.187), 4.0 dev7, v4.0.187, 143831 lines.
* 2021-11-02, Release [v4.0.191](https://github.com/ossrs/srs/releases/tag/v4.0.191), 4.0 dev7, v4.0.191, 143890 lines.
* 2021-10-12, Release [v4.0.177](https://github.com/ossrs/srs/releases/tag/v4.0.177), 4.0 dev6, v4.0.177, 143686 lines.
* 2021-09-05, Release [v4.0.161](https://github.com/ossrs/srs/releases/tag/v4.0.161), 4.0 dev5, v4.0.161, 145865 lines.
* 2021-08-15, Release [v4.0.156](https://github.com/ossrs/srs/releases/tag/v4.0.156), 4.0 dev4, v4.0.156, 145490 lines.

@ -0,0 +1,4 @@
82c82
< char bit_string[MAX_PRINT_STRING_LEN];
---
> static char bit_string[MAX_PRINT_STRING_LEN];

@ -0,0 +1,16 @@
FROM ossrs/srs:dev
# version=4.0.145
ARG version
# Install depends tools.
RUN yum install -y zip
# Setup the packager env.
ENV SRS_AUTO_PACKAGER ossrs
# Build and install SRS.
ADD srs-server-${version}.tar.gz /srs
WORKDIR /srs/srs-server-${version}/trunk
RUN ./scripts/package.sh --x86-x64 --jobs=2

@ -617,6 +617,7 @@ if [[ $SRS_RTC == YES ]]; then
(
rm -rf ${SRS_OBJS}/srtp2 && cd ${SRS_OBJS}/${SRS_PLATFORM} &&
rm -rf libsrtp-2-fit && cp -R ../../3rdparty/libsrtp-2-fit . && cd libsrtp-2-fit &&
patch -p0 crypto/math/datatypes.c ../../../3rdparty/patches/srtp/gcc10-01.patch &&
$SRTP_CONFIGURE ${SRTP_OPTIONS} --prefix=`pwd`/_release &&
make ${SRS_JOBS} && make install &&
cd .. && rm -rf srtp2 && ln -sf libsrtp-2-fit/_release srtp2

@ -30,6 +30,11 @@ The changelog for SRS.
## SRS 4.0 Changelog
* v4.0, 2021-11-04, Merge [#2707](https://github.com/ossrs/srs/pull/2707): Refuse edge request when state is stopping. v4.0.192
* v4.0, 2021-11-02, Auto create package by github actions. v4.0.191
* v4.0, 2021-10-30, Merge [#2552](https://github.com/ossrs/srs/pull/2552): Script: Refine CentOS7 service script to restart SRS. v4.0.190
* v4.0, 2021-10-30, Merge [#2397](https://github.com/ossrs/srs/pull/2397): SRTP: Patch libsrtp2 to fix GCC10 build fail. v4.0.189
* v4.0, 2021-10-30, Merge [#2284](https://github.com/ossrs/srs/pull/2284): Forward: Fast quit when cycle fail. v4.0.188
* v4.0, 2021-10-28, Merge [#2186](https://github.com/ossrs/srs/pull/2186): Gop: Ignore zero timestamp when shrinking. v4.0.187
* v4.0, 2021-10-27, Merge [#1963](https://github.com/ossrs/srs/pull/1963): Cluster: Origin server shouldn't be it's own coworker. v4.0.186
* v4.0, 2021-10-25, Merge [#2692](https://github.com/ossrs/srs/pull/2692): API: Add server_id into http_hooks. v4.0.185

@ -25,9 +25,9 @@ set(DEPS_LIBS ${SRS_DIR}/objs/st/libst.a
${SRS_DIR}/objs/openssl/lib/libssl.a
${SRS_DIR}/objs/openssl/lib/libcrypto.a
${SRS_DIR}/objs/srtp2/lib/libsrtp2.a
${SRS_DIR}/objs/opus/lib/libopus.a
${SRS_DIR}/objs/ffmpeg/lib/libavutil.a
${SRS_DIR}/objs/ffmpeg/lib/libavcodec.a
${SRS_DIR}/objs/ffmpeg/lib/libavutil.a
${SRS_DIR}/objs/opus/lib/libopus.a
${SRS_DIR}/objs/ffmpeg/lib/libswresample.a)
foreach(DEPS_LIB ${DEPS_LIBS})
IF (NOT EXISTS ${DEPS_LIB})
@ -62,7 +62,7 @@ ADD_DEFINITIONS("-g -O0")
ADD_EXECUTABLE(srs ${SOURCE_FILES})
TARGET_LINK_LIBRARIES(srs dl)
TARGET_LINK_LIBRARIES(srs ${DEPS_LIBS})
TARGET_LINK_LIBRARIES(srs -ldl)
TARGET_LINK_LIBRARIES(srs -ldl -pthread)
MESSAGE(STATUS "@see https://github.com/ossrs/srs/wiki/v4_CN_IDE")

@ -0,0 +1,50 @@
# main config for srs.
# @see full.conf for detail config.
daemon off;
pid /var/lib/srs/srs.pid;
work_dir /var/lib/srs;
listen 1935;
max_connections 1000;
srs_log_tank file;
srs_log_file /var/log/srs/srs.log;
http_api {
enabled on;
listen 1985;
}
http_server {
enabled on;
listen 8080;
dir /usr/share/srs/html;
}
rtc_server {
enabled on;
listen 8000;
# @see https://github.com/ossrs/srs/wiki/v4_CN_WebRTC#config-candidate
candidate $CANDIDATE;
}
stats {
network 0;
disk sda sdb xvda xvdb;
}
vhost __defaultVhost__ {
hls {
enabled on;
}
http_remux {
enabled on;
mount [vhost]/[app]/[stream].flv;
}
rtc {
enabled on;
# @see https://github.com/ossrs/srs/wiki/v4_CN_WebRTC#rtmp-to-rtc
rtmp_to_rtc off;
# @see https://github.com/ossrs/srs/wiki/v4_CN_WebRTC#rtc-to-rtmp
rtc_to_rtmp off;
}
}

@ -0,0 +1,76 @@
#!/bin/sh
#
# srs - a simple, high efficiency and realtime video server
#
# chkconfig: <default runlevel(s)> <start> <stop>
### BEGIN INIT INFO
# Provides: srs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: a simple, high efficiency and realtime video server
### END INIT INFO
# Source function library.
. /etc/rc.d/init.d/functions
exec="/usr/bin/srs"
prog=${exec##*/}
configfile=/etc/srs/srs.conf
[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
lockfile=/var/lock/subsys/$prog
start() {
echo -n $"Starting $prog: "
daemon --user nobody $exec -c $configfile
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop() {
echo -n $"Stopping $prog: "
killproc $exec -TERM
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
reload() {
echo -n $"reloading $prog: "
killproc $exec -HUP
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
rotate() {
echo -n $"logrotate $prog: "
killproc $exec -USR1
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
restart() {
stop
start
}
case "$1" in
start|stop|restart|reload|rotate)
$1
;;
status)
status $prog
;;
*)
echo $"Usage: $0 {start|stop|status|restart|reload|rotate}"
exit 2
esac

@ -0,0 +1,15 @@
/var/log/srs/*.log {
daily
missingok
rotate 30
compress
delaycompress
notifempty
create 640 root nobody
sharedscripts
postrotate
if [ -f /var/lib/srs/srs.pid ]; then
kill -USR1 `cat /var/lib/srs/srs.pid`
fi
endscript
}

@ -0,0 +1,23 @@
[Unit]
Description=srs - a simple, high efficiency and realtime video server
Documentation=https://github.com/ossrs/srs/wiki
After=network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target
[Service]
Type=simple
User=nobody
Group=nobody
WorkingDirectory=/var/lib/srs
EnvironmentFile=-/etc/sysconfig/srs
PIDFile=/var/lib/srs/srs.pid
ExecStartPre=/usr/bin/srs -c /etc/srs/srs.conf -t
ExecStart=/usr/bin/srs -c /etc/srs/srs.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
Restart=on-failure
PrivateTmp=true
[Install]
WantedBy=multi-user.target

@ -0,0 +1,103 @@
%define use_systemd (0%{?fedora} && 0%{?fedora} >= 18) || (0%{?rhel} && 0%{?rhel} >= 7) || (0%{?suse_version} == 1315)
Name: srs
Version: 3.0.168
Release: 1%{?dist}
Summary: a simple, high efficiency and realtime video server
License: MIT
URL: https://github.com/ossrs/srs
Source0: %{name}-3.0-r8.tar.gz
Source1: srs.conf
Source2: srs.service
Source3: srs.init
Source4: srs.logrotate
BuildRequires: python
BuildRequires: rsync
%if %{use_systemd}
BuildRequires: systemd
Requires: systemd
%else
BuildRequires: initscripts
Requires: initscripts
%endif
%description
SRS is a simple, high efficiency and realtime video server, supports RTMP/WebRTC/HLS/HTTP-FLV/SRT.
%prep
%setup -q -n srs-3.0-r8
%build
cd trunk
./configure --prefix=/usr
make %{?_smp_mflags}
%install
rm -rf $RPM_BUILD_ROOT
%{__mkdir_p} $RPM_BUILD_ROOT%{_bindir}
%{__mkdir_p} $RPM_BUILD_ROOT%{_initrddir}
%{__mkdir_p} $RPM_BUILD_ROOT%{_datadir}/%{name}
%{__mkdir_p} $RPM_BUILD_ROOT%{_sharedstatedir}/%{name}
%{__mkdir_p} $RPM_BUILD_ROOT%{_localstatedir}/log/%{name}
%{__install} -m 755 trunk/objs/srs $RPM_BUILD_ROOT%{_bindir}
#http_server file
rsync -aqL --delete trunk/objs/nginx/ $RPM_BUILD_ROOT%{_datadir}/%{name}/
#%{__mkdir_p} $RPM_BUILD_ROOT%{_sysconfdir}/%{name}
%{__install} -D -m 644 trunk/packaging/redhat/srs.conf $RPM_BUILD_ROOT%{_sysconfdir}/%{name}/srs.conf
#init files
%if %{use_systemd}
%{__mkdir} -p $RPM_BUILD_ROOT%{_unitdir}
%{__install} -p -m 644 trunk/packaging/redhat/srs.service $RPM_BUILD_ROOT%{_unitdir}/srs.service
%else
%{__mkdir} -p $RPM_BUILD_ROOT%{_initrddir}
%{__install} -p -m 755 trunk/packaging/redhat/srs.init $RPM_BUILD_ROOT%{_initrddir}/srs
sed -i 's/daemon/{s/off/on/g}' %{_sysconfdir}/%{name}/srs.conf
%endif
#logrotate
%{__install} -D -p -m 644 trunk/packaging/redhat/srs.logrotate $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/srs
%pre
# Add the "srs" user
# getent group srs >/dev/null || groupadd -r srs
# getent passwd srs >/dev/null || useradd -r -g srs -s /sbin/nologin -d /var/lib/srs srs
%post
%if %{use_systemd}
%systemd_post %{name}.service
%endif
%preun
%if %{use_systemd}
%systemd_preun %{name}.service
%endif
%files
%defattr(-,root,root,-)
%{_bindir}/*
%config(noreplace) %{_sysconfdir}/srs/srs.conf
%{_sysconfdir}/logrotate.d/srs
%{_datadir}/%{name}
%dir %attr(0755, nobody, nobody) %{_localstatedir}/log/%{name}
%dir %attr(0755, nobody, nobody) %{_sharedstatedir}/%{name}
%doc trunk/conf
%license LICENSE
%if %{use_systemd}
%{_unitdir}/srs.service
%else
%{_initrddir}/%{name}
%endif
%changelog
* Mon Nov 1 2021 Purple Grape <purplegrape4@gmail.com>
- rpm init

@ -175,6 +175,12 @@ srs_error_t SrsForwarder::cycle()
srs_freep(err);
}
// Never wait if thread error, fast quit.
// @see https://github.com/ossrs/srs/pull/2284
if ((err = trd->pull()) != srs_success) {
return srs_error_wrap(err, "forwarder");
}
srs_usleep(SRS_FORWARDER_CIMS);
}

@ -237,10 +237,8 @@ srs_error_t SrsGoApiRtcPlay::check_remote_sdp(const SrsSdp& remote_sdp)
return srs_error_new(ERROR_RTC_SDP_EXCHANGE, "now only suppor rtcp-mux");
}
for (std::vector<SrsMediaPayloadType>::const_iterator iter_media = iter->payload_types_.begin(); iter_media != iter->payload_types_.end(); ++iter_media) {
if (iter->sendonly_) {
return srs_error_new(ERROR_RTC_SDP_EXCHANGE, "play API only support sendrecv/recvonly");
}
if (iter->sendonly_) {
return srs_error_new(ERROR_RTC_SDP_EXCHANGE, "play API only support sendrecv/recvonly");
}
}
@ -489,10 +487,8 @@ srs_error_t SrsGoApiRtcPublish::check_remote_sdp(const SrsSdp& remote_sdp)
return srs_error_new(ERROR_RTC_SDP_EXCHANGE, "now only suppor rtcp-mux");
}
for (std::vector<SrsMediaPayloadType>::const_iterator iter_media = iter->payload_types_.begin(); iter_media != iter->payload_types_.end(); ++iter_media) {
if (iter->recvonly_) {
return srs_error_new(ERROR_RTC_SDP_EXCHANGE, "publish API only support sendrecv/sendonly");
}
if (iter->recvonly_) {
return srs_error_new(ERROR_RTC_SDP_EXCHANGE, "publish API only support sendrecv/sendonly");
}
}

@ -202,7 +202,16 @@ void SrsFastCoroutine::stop()
if (trd) {
void* res = NULL;
int r0 = st_thread_join((st_thread_t)trd, &res);
srs_assert(!r0);
if (r0) {
// By st_thread_join
if (errno == EINVAL) srs_assert(!r0);
if (errno == EDEADLK) srs_assert(!r0);
// By st_cond_timedwait
if (errno == EINTR) srs_assert(!r0);
if (errno == ETIME) srs_assert(!r0);
// Others
srs_assert(!r0);
}
srs_error_t err_res = (srs_error_t)res;
if (err_res != srs_success) {

@ -54,7 +54,9 @@
#endif
#include <assert.h>
#ifndef srs_assert
#define srs_assert(expression) assert(expression)
#endif
#include <stddef.h>
#include <sys/types.h>

@ -9,6 +9,6 @@
#define VERSION_MAJOR 4
#define VERSION_MINOR 0
#define VERSION_REVISION 187
#define VERSION_REVISION 192
#endif

@ -74,8 +74,17 @@ void srs_close_stfd(srs_netfd_t& stfd)
{
if (stfd) {
// we must ensure the close is ok.
int err = st_netfd_close((st_netfd_t)stfd);
srs_assert(err != -1);
int r0 = st_netfd_close((st_netfd_t)stfd);
if (r0) {
// By _st_epoll_fd_close or _st_kq_fd_close
if (errno == EBUSY) srs_assert(!r0);
// By close
if (errno == EBADF) srs_assert(!r0);
if (errno == EINTR) srs_assert(!r0);
if (errno == EIO) srs_assert(!r0);
// Others
srs_assert(!r0);
}
stfd = NULL;
}
}

@ -229,7 +229,7 @@ void srt_server::srt_handle_connection(SRT_SOCKSTATUS status, SRTSOCKET input_fd
} else if (srt_conn_ptr->get_mode() == PUSH_SRT_MODE) {
conn_event = SRT_EPOLL_IN | SRT_EPOLL_ERR;
} else {
srt_log_trace("stream mode error, it shoulde be m=push or m=pull, streamid:%s",
srt_log_trace("stream mode error, it should be m=push or m=pull, streamid:%s",
srt_conn_ptr->get_streamid().c_str());
srt_conn_ptr->close();
return;

@ -10,7 +10,7 @@
/*
#include <srs_utest_reload.hpp>
*/
#include <srs_core.hpp>
#include <srs_utest.hpp>
#include <srs_utest_config.hpp>
#include <srs_app_reload.hpp>

@ -24,6 +24,7 @@ using namespace std;
#include <srs_service_conn.hpp>
#include <sys/socket.h>
#include <netdb.h>
#include <st.h>
MockSrsConnection::MockSrsConnection()
{
@ -1452,3 +1453,35 @@ VOID TEST(TCPServerTest, ContextUtility)
}
}
class MockStopSelfThread : public ISrsCoroutineHandler
{
public:
int r0;
int r1;
SrsFastCoroutine trd;
MockStopSelfThread() : trd("mock", this), r0(0), r1(0) {
}
virtual ~MockStopSelfThread() {
}
srs_error_t start() {
return trd.start();
}
void stop() {
trd.stop();
}
virtual srs_error_t cycle() {
r0 = st_thread_join((st_thread_t)trd.trd, NULL);
r1 = errno;
return srs_success;
}
};
VOID TEST(StopSelfThreadTest, ShouldFailWhenStopSelf)
{
MockStopSelfThread trd;
trd.start();
srs_usleep(0);
EXPECT_EQ(-1, trd.r0);
EXPECT_EQ(EDEADLK, trd.r1);
}

@ -4,6 +4,7 @@ After=network.target
[Service]
Type=forking
Restart=always
ExecStart=/etc/init.d/srs start
ExecReload=/etc/init.d/srs reload
ExecStop=/etc/init.d/srs stop

Loading…
Cancel
Save