From b02c81425118015f11f005ce0976ef5f17d625d6 Mon Sep 17 00:00:00 2001 From: winlin Date: Sat, 14 Aug 2021 21:09:44 +0800 Subject: [PATCH 1/9] Expose live streaming ports for SRS 3.0 --- trunk/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/trunk/Dockerfile b/trunk/Dockerfile index a48b22e79..34b6b0589 100644 --- a/trunk/Dockerfile +++ b/trunk/Dockerfile @@ -23,8 +23,8 @@ RUN cp -R research/players /usr/local/srs/objs/nginx/html/ ############################################################ FROM centos:7 AS dist -# Expose ports for streaming @see https://github.com/ossrs/srs#ports -EXPOSE 1935 1985 8080 8000/udp 10080/udp +# Expose ports for live streaming +EXPOSE 1935 1985 8080 # FFMPEG 4.1 COPY --from=build /usr/local/bin/ffmpeg /usr/local/srs/objs/ffmpeg/bin/ffmpeg From 8d44b982ee15c541318b4193c10a758782afddbd Mon Sep 17 00:00:00 2001 From: winlin Date: Sun, 15 Aug 2021 12:05:15 +0800 Subject: [PATCH 2/9] Actions: Add CI for utest and coverage --- .github/workflows/release.yml | 2 +- .github/workflows/test.yml | 40 +++++++++++++++++++++++++++++++++++ README.md | 2 +- trunk/Dockerfile | 4 ++-- trunk/Dockerfile.cov | 9 ++++++++ trunk/Dockerfile.test | 9 ++++++++ trunk/auto/coverage.sh | 38 +++++++++++++++------------------ 7 files changed, 79 insertions(+), 25 deletions(-) create mode 100644 .github/workflows/test.yml create mode 100644 trunk/Dockerfile.cov create mode 100644 trunk/Dockerfile.test diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 00418403a..e3be44e94 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,7 +7,7 @@ on: jobs: k8s: - name: release-k8s + name: actions-release-k8s runs-on: ubuntu-20.04 steps: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 000000000..a0b439693 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,40 @@ +name: "Test" + +on: [push, pull_request] + +jobs: + utest: + name: actions-test-utest + runs-on: ubuntu-20.04 + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + ################################################################ + # Tests + - name: Build test image + run: docker build --tag srs:test -f trunk/Dockerfile.test trunk + # For utest + - name: Run SRS utest + run: docker run --rm srs:test bash -c 'make && ./objs/srs_utest' + coverage: + name: actions-test-coverage + runs-on: ubuntu-20.04 + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + ################################################################ + # Tests + - name: Build coverage image + run: docker build --tag srs:cov -f trunk/Dockerfile.cov . + # For coverage + - name: Run SRS covergae + if: ${{ startsWith(github.ref, 'refs/heads/') }} + run: | + SRS_BRANCH=$(echo ${{ github.ref }}| awk -F '/' '{print $3}') && SRS_SHA=${{ github.sha }} && SRS_PROJECT=/srs + echo "For ref=${{ github.ref }}, sha=${{ github.sha }}, SRS_BRANCH=$SRS_BRANCH, SRS_SHA=$SRS_SHA, SRS_PROJECT=$SRS_PROJECT" + docker run --rm --env SRS_BRANCH=$SRS_BRANCH --env SRS_SHA=$SRS_SHA --env SRS_PROJECT=$SRS_PROJECT \ + srs:cov bash -c 'make && ./objs/srs_utest && bash auto/coverage.sh' \ No newline at end of file diff --git a/README.md b/README.md index 7d9ec939f..8aac68cb7 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # SRS(Simple Realtime Server) ![](http://ossrs.net/gif/v1/sls.gif?site=github.com&path=/srs/srs3) -[![](https://circleci.com/gh/ossrs/srs/tree/3.0release.svg?style=svg&circle-token=1ef1d5b5b0cde6c8c282ed856a18199f9e8f85a9)](https://circleci.com/gh/ossrs/srs/tree/3.0release) +[![](https://github.com/ossrs/srs/actions/workflows/test.yml/badge.svg?branch=3.0release)](https://github.com/ossrs/srs/actions?query=workflow%3ATest+branch%3A3.0release) [![](https://codecov.io/gh/ossrs/srs/branch/3.0release/graph/badge.svg)](https://codecov.io/gh/ossrs/srs/branch/3.0release) [![](https://cloud.githubusercontent.com/assets/2777660/22814959/c51cbe72-ef92-11e6-81cc-32b657b285d5.png)](https://github.com/ossrs/srs/wiki/v1_CN_Contact#wechat) diff --git a/trunk/Dockerfile b/trunk/Dockerfile index 34b6b0589..7fcb72aab 100644 --- a/trunk/Dockerfile +++ b/trunk/Dockerfile @@ -4,8 +4,8 @@ FROM ossrs/srs:dev AS build RUN yum install -y gcc make gcc-c++ patch unzip perl git # Build and install SRS. -COPY . /trunk -WORKDIR /trunk +COPY . /srs/trunk +WORKDIR /srs/trunk RUN ./configure --jobs=2 && make -j2 && make install # All config files for SRS. diff --git a/trunk/Dockerfile.cov b/trunk/Dockerfile.cov new file mode 100644 index 000000000..a898cb969 --- /dev/null +++ b/trunk/Dockerfile.cov @@ -0,0 +1,9 @@ +FROM ossrs/srs:dev + +# Install depends tools. +RUN yum install -y gcc make gcc-c++ patch unzip perl git + +# Build and install SRS. +COPY . /srs +WORKDIR /srs/trunk +RUN ./configure --with-utest --gcov --jobs=2 && make -j2 diff --git a/trunk/Dockerfile.test b/trunk/Dockerfile.test new file mode 100644 index 000000000..ca41c2072 --- /dev/null +++ b/trunk/Dockerfile.test @@ -0,0 +1,9 @@ +FROM ossrs/srs:dev + +# Install depends tools. +RUN yum install -y gcc make gcc-c++ patch unzip perl git + +# Build and install SRS. +COPY . /srs/trunk +WORKDIR /srs/trunk +RUN ./configure --with-utest --jobs=2 && make -j2 diff --git a/trunk/auto/coverage.sh b/trunk/auto/coverage.sh index 55cb7ce46..0e7443f28 100644 --- a/trunk/auto/coverage.sh +++ b/trunk/auto/coverage.sh @@ -1,36 +1,31 @@ #!/bin/bash # In .circleci/config.yml, generate *.gcno with -# ./configure --gcov --without-research --without-librtmp && make +# ./configure --gcov --with-utest --without-research --without-librtmp && make # and generate *.gcda by # ./objs/srs_utest # Workdir is objs/cover. workdir=`pwd`/objs/cover -# Tool git is required to map the right path. -git --version >/dev/null 2>&1 -ret=$?; if [[ $ret -ne 0 ]]; then echo "Tool git is required, ret=$ret"; exit $ret; fi - # Create trunk under workdir. mkdir -p $workdir && cd $workdir ret=$?; if [[ $ret -ne 0 ]]; then echo "Enter workdir failed, ret=$ret"; exit $ret; fi -# Collect all *.gcno and *.gcda to objs/cover. -cd $workdir && (rm -rf src && cp -R ../../src . && cp -R ../src/* src/) -ret=$?; if [[ $ret -ne 0 ]]; then echo "Collect *.gcno and *.gcda failed, ret=$ret"; exit $ret; fi - -# Generate *.gcov for coverage. -cd $workdir && -for file in `find src -name "*.cpp"|grep -v utest`; do - gcov $file -o `dirname $file` - ret=$?; if [[ $ret -ne 0 ]]; then echo "Collect $file failed, ret=$ret"; exit $ret; fi -done - -# Cook the gcov files. -cd $workdir && -find . -name "*.gcov"|grep -v srs|xargs rm -f -ret=$?; if [[ $ret -ne 0 ]]; then echo "Cook gcov files failed, ret=$ret"; exit $ret; fi +CODECOV_ARGS="" +if [[ $SRS_BRANCH != '' ]]; then + # -B branch Specify the branch name + CODECOV_ARGS="$CODECOV_ARGS -B $SRS_BRANCH" +fi +if [[ $SRS_SHA != '' ]]; then + # -C sha Specify the commit sha + CODECOV_ARGS="$CODECOV_ARGS -C $SRS_SHA" +fi +if [[ $SRS_PROJECT != '' ]]; then + # -R root dir Used when not in git/hg project to identify project root directory + # -p dir Project root directory. Also used when preparing gcov + CODECOV_ARGS="$CODECOV_ARGS -R $SRS_PROJECT -p $SRS_PROJECT" +fi # Upload report with *.gcov # Remark: The file codecov.yml is not neccessary. It literally depends on git. @@ -41,5 +36,6 @@ ret=$?; if [[ $ret -ne 0 ]]; then echo "Cook gcov files failed, ret=$ret"; exit # https://circleci.com/gh/ossrs/srs/tree/3.0release cd $workdir && export CODECOV_TOKEN="493bba46-c468-4e73-8b45-8cdd8ff62d96" && -bash <(curl -s https://codecov.io/bash) && +bash <(curl -s https://codecov.io/bash) $CODECOV_ARGS && echo "Done" && exit 0 + From 1d79ef87a516475b241d5c5a96c1b5b7fef12da1 Mon Sep 17 00:00:00 2001 From: winlin Date: Sun, 15 Aug 2021 17:41:15 +0800 Subject: [PATCH 3/9] Acitons: Support pullrequest CI --- .github/workflows/test.yml | 15 +++++++++++---- trunk/auto/coverage.sh | 12 ++++++++---- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a0b439693..19f8b7914 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -32,9 +32,16 @@ jobs: run: docker build --tag srs:cov -f trunk/Dockerfile.cov . # For coverage - name: Run SRS covergae - if: ${{ startsWith(github.ref, 'refs/heads/') }} + if: ${{ startsWith(github.ref, 'refs/heads/') || startsWith(github.ref, 'refs/remotes/') }} run: | - SRS_BRANCH=$(echo ${{ github.ref }}| awk -F '/' '{print $3}') && SRS_SHA=${{ github.sha }} && SRS_PROJECT=/srs - echo "For ref=${{ github.ref }}, sha=${{ github.sha }}, SRS_BRANCH=$SRS_BRANCH, SRS_SHA=$SRS_SHA, SRS_PROJECT=$SRS_PROJECT" - docker run --rm --env SRS_BRANCH=$SRS_BRANCH --env SRS_SHA=$SRS_SHA --env SRS_PROJECT=$SRS_PROJECT \ + # The hash of commit. + SRS_SHA=${{ github.sha }} + # Note that the root of SRS, must contains .git, for report fixing. + SRS_PROJECT=/srs + # The github.ref is, for example, refs/heads/3.0release + SRS_BRANCH=$(echo ${{ github.ref }}| awk -F 'refs/heads/' '{print $2}'| awk -F '/' '{print $1}') + # The github.ref is, for example, refs/remotes/pull/2536/merge + SRS_PR=$(echo ${{ github.ref }}| awk -F 'refs/remotes/pull/' '{print $2}'| awk -F '/' '{print $1}') + echo "For ref=${{ github.ref }}, sha=${{ github.sha }}, SRS_BRANCH=$SRS_BRANCH, SRS_PR=$SRS_PR, SRS_SHA=$SRS_SHA, SRS_PROJECT=$SRS_PROJECT" + docker run --rm --env SRS_BRANCH=$SRS_BRANCH --env SRS_PR=$SRS_PR --env SRS_SHA=$SRS_SHA --env SRS_PROJECT=$SRS_PROJECT \ srs:cov bash -c 'make && ./objs/srs_utest && bash auto/coverage.sh' \ No newline at end of file diff --git a/trunk/auto/coverage.sh b/trunk/auto/coverage.sh index 0e7443f28..25f7041d5 100644 --- a/trunk/auto/coverage.sh +++ b/trunk/auto/coverage.sh @@ -13,6 +13,11 @@ mkdir -p $workdir && cd $workdir ret=$?; if [[ $ret -ne 0 ]]; then echo "Enter workdir failed, ret=$ret"; exit $ret; fi CODECOV_ARGS="" +if [[ $SRS_PROJECT != '' ]]; then + # -R root dir Used when not in git/hg project to identify project root directory + # -p dir Project root directory. Also used when preparing gcov + CODECOV_ARGS="$CODECOV_ARGS -R $SRS_PROJECT -p $SRS_PROJECT" +fi if [[ $SRS_BRANCH != '' ]]; then # -B branch Specify the branch name CODECOV_ARGS="$CODECOV_ARGS -B $SRS_BRANCH" @@ -21,10 +26,9 @@ if [[ $SRS_SHA != '' ]]; then # -C sha Specify the commit sha CODECOV_ARGS="$CODECOV_ARGS -C $SRS_SHA" fi -if [[ $SRS_PROJECT != '' ]]; then - # -R root dir Used when not in git/hg project to identify project root directory - # -p dir Project root directory. Also used when preparing gcov - CODECOV_ARGS="$CODECOV_ARGS -R $SRS_PROJECT -p $SRS_PROJECT" +if [[ $SRS_PR != '' ]]; then + # -P pr Specify the pull request number + CODECOV_ARGS="$CODECOV_ARGS -P $SRS_PR" fi # Upload report with *.gcov From b3516b88dca225301762ea68f9c31fbd5d4593c5 Mon Sep 17 00:00:00 2001 From: winlin Date: Sun, 15 Aug 2021 17:45:43 +0800 Subject: [PATCH 4/9] Acitons: Support pullrequest CI --- .github/workflows/test.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 19f8b7914..da05795f2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -32,7 +32,6 @@ jobs: run: docker build --tag srs:cov -f trunk/Dockerfile.cov . # For coverage - name: Run SRS covergae - if: ${{ startsWith(github.ref, 'refs/heads/') || startsWith(github.ref, 'refs/remotes/') }} run: | # The hash of commit. SRS_SHA=${{ github.sha }} From 2431e0b14034673ea430f2e96b165620647f7981 Mon Sep 17 00:00:00 2001 From: winlin Date: Sun, 15 Aug 2021 17:49:03 +0800 Subject: [PATCH 5/9] Acitons: Support pullrequest CI --- .github/workflows/test.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index da05795f2..3dd2f54be 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -32,6 +32,7 @@ jobs: run: docker build --tag srs:cov -f trunk/Dockerfile.cov . # For coverage - name: Run SRS covergae + if: ${{ startsWith(github.ref, 'refs/heads/') || startsWith(github.ref, 'refs/pull/') }} run: | # The hash of commit. SRS_SHA=${{ github.sha }} @@ -39,8 +40,8 @@ jobs: SRS_PROJECT=/srs # The github.ref is, for example, refs/heads/3.0release SRS_BRANCH=$(echo ${{ github.ref }}| awk -F 'refs/heads/' '{print $2}'| awk -F '/' '{print $1}') - # The github.ref is, for example, refs/remotes/pull/2536/merge - SRS_PR=$(echo ${{ github.ref }}| awk -F 'refs/remotes/pull/' '{print $2}'| awk -F '/' '{print $1}') + # The github.ref is, for example, refs/pull/2536/merge + SRS_PR=$(echo ${{ github.ref }}| awk -F 'refs/pull/' '{print $2}'| awk -F '/' '{print $1}') echo "For ref=${{ github.ref }}, sha=${{ github.sha }}, SRS_BRANCH=$SRS_BRANCH, SRS_PR=$SRS_PR, SRS_SHA=$SRS_SHA, SRS_PROJECT=$SRS_PROJECT" docker run --rm --env SRS_BRANCH=$SRS_BRANCH --env SRS_PR=$SRS_PR --env SRS_SHA=$SRS_SHA --env SRS_PROJECT=$SRS_PROJECT \ srs:cov bash -c 'make && ./objs/srs_utest && bash auto/coverage.sh' \ No newline at end of file From 9eadebdde7f99aadf79c22b1b97bb938c8999992 Mon Sep 17 00:00:00 2001 From: winlin Date: Sun, 15 Aug 2021 21:33:08 +0800 Subject: [PATCH 6/9] Fix version query bug. --- trunk/src/app/srs_app_latest_version.cpp | 2 ++ trunk/src/core/srs_core_version3.hpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/trunk/src/app/srs_app_latest_version.cpp b/trunk/src/app/srs_app_latest_version.cpp index d67f40af4..66ac01561 100644 --- a/trunk/src/app/srs_app_latest_version.cpp +++ b/trunk/src/app/srs_app_latest_version.cpp @@ -44,6 +44,8 @@ extern bool _srs_in_docker; void srs_build_features(stringstream& ss) { + ss << "&os=linux"; + ss << "&docker=" << _srs_in_docker << "&packager=" << SRS_AUTO_PACKAGER; } diff --git a/trunk/src/core/srs_core_version3.hpp b/trunk/src/core/srs_core_version3.hpp index 838281207..688c75843 100644 --- a/trunk/src/core/srs_core_version3.hpp +++ b/trunk/src/core/srs_core_version3.hpp @@ -24,6 +24,6 @@ #ifndef SRS_CORE_VERSION3_HPP #define SRS_CORE_VERSION3_HPP -#define SRS_VERSION3_REVISION 168 +#define SRS_VERSION3_REVISION 169 #endif From 21be9daba4797800231204711a10537f1672d6cc Mon Sep 17 00:00:00 2001 From: winlin Date: Sun, 15 Aug 2021 21:49:24 +0800 Subject: [PATCH 7/9] Update README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 8aac68cb7..3fd14ca29 100755 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ ![](http://ossrs.net/gif/v1/sls.gif?site=github.com&path=/srs/srs3) [![](https://github.com/ossrs/srs/actions/workflows/test.yml/badge.svg?branch=3.0release)](https://github.com/ossrs/srs/actions?query=workflow%3ATest+branch%3A3.0release) +[![](https://github.com/ossrs/srs/actions/workflows/release.yml/badge.svg)](https://github.com/ossrs/srs/actions?query=workflow%3ARelease) [![](https://codecov.io/gh/ossrs/srs/branch/3.0release/graph/badge.svg)](https://codecov.io/gh/ossrs/srs/branch/3.0release) [![](https://cloud.githubusercontent.com/assets/2777660/22814959/c51cbe72-ef92-11e6-81cc-32b657b285d5.png)](https://github.com/ossrs/srs/wiki/v1_CN_Contact#wechat) From b4220ee7c110c61da91a9bdf325befa1c0a57d72 Mon Sep 17 00:00:00 2001 From: winlin Date: Sun, 5 Sep 2021 15:03:03 +0800 Subject: [PATCH 8/9] Refine Dockerfile --- .github/workflows/release.yml | 2 +- .github/workflows/test.yml | 2 +- trunk/Dockerfile | 2 +- trunk/Dockerfile.test | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e3be44e94..574217ba5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -32,7 +32,7 @@ jobs: shell: bash run: | echo "Release ossrs/srs:$SRS_TAG" - docker build --tag ossrs/srs:$SRS_TAG trunk + docker build --tag ossrs/srs:$SRS_TAG -f trunk/Dockerfile . - name: Login docker hub uses: docker/login-action@v1 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3dd2f54be..291ee14f4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,7 +14,7 @@ jobs: ################################################################ # Tests - name: Build test image - run: docker build --tag srs:test -f trunk/Dockerfile.test trunk + run: docker build --tag srs:test -f trunk/Dockerfile.test . # For utest - name: Run SRS utest run: docker run --rm srs:test bash -c 'make && ./objs/srs_utest' diff --git a/trunk/Dockerfile b/trunk/Dockerfile index 7fcb72aab..7a3e32d34 100644 --- a/trunk/Dockerfile +++ b/trunk/Dockerfile @@ -4,7 +4,7 @@ FROM ossrs/srs:dev AS build RUN yum install -y gcc make gcc-c++ patch unzip perl git # Build and install SRS. -COPY . /srs/trunk +COPY . /srs WORKDIR /srs/trunk RUN ./configure --jobs=2 && make -j2 && make install diff --git a/trunk/Dockerfile.test b/trunk/Dockerfile.test index ca41c2072..de1eb633e 100644 --- a/trunk/Dockerfile.test +++ b/trunk/Dockerfile.test @@ -4,6 +4,6 @@ FROM ossrs/srs:dev RUN yum install -y gcc make gcc-c++ patch unzip perl git # Build and install SRS. -COPY . /srs/trunk +COPY . /srs WORKDIR /srs/trunk RUN ./configure --with-utest --jobs=2 && make -j2 From e801174ab21b306462cb760abc47e514e8568195 Mon Sep 17 00:00:00 2001 From: winlin Date: Sun, 28 Jun 2020 16:58:14 +0800 Subject: [PATCH 9/9] Fix #2606: Memory leak for RTMP client, pick from 4.0. v3.0.170 --- README.md | 1 + trunk/src/core/srs_core_version3.hpp | 2 +- trunk/src/service/srs_service_rtmp_conn.cpp | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3fd14ca29..39d262cf4 100755 --- a/README.md +++ b/README.md @@ -130,6 +130,7 @@ Other important wiki: ## V3 changes +* v3.0, 2021-10-08, Fix [#2606](https://github.com/ossrs/srs/issues/2606): Memory leak for RTMP client, pick from 4.0. v3.0.170 * v3.0, 2021-08-14, [3.0 release8(3.0.168)](https://github.com/ossrs/srs/releases/tag/v3.0-r8) released. 124469 lines. * v3.0, 2021-07-04, [3.0 release7(3.0.164)](https://github.com/ossrs/srs/releases/tag/v3.0-r7) released. 123463 lines. * v3.0, 2021-07-04, For [#2424](https://github.com/ossrs/srs/issues/2424), use srandom/random to generate. 3.0.164 diff --git a/trunk/src/core/srs_core_version3.hpp b/trunk/src/core/srs_core_version3.hpp index 688c75843..d4156cec3 100644 --- a/trunk/src/core/srs_core_version3.hpp +++ b/trunk/src/core/srs_core_version3.hpp @@ -24,6 +24,6 @@ #ifndef SRS_CORE_VERSION3_HPP #define SRS_CORE_VERSION3_HPP -#define SRS_VERSION3_REVISION 169 +#define SRS_VERSION3_REVISION 170 #endif diff --git a/trunk/src/service/srs_service_rtmp_conn.cpp b/trunk/src/service/srs_service_rtmp_conn.cpp index 2a7c7c8bb..2f856d824 100644 --- a/trunk/src/service/srs_service_rtmp_conn.cpp +++ b/trunk/src/service/srs_service_rtmp_conn.cpp @@ -57,6 +57,7 @@ SrsBasicRtmpClient::~SrsBasicRtmpClient() close(); srs_freep(kbps); srs_freep(clk); + srs_freep(req); } srs_error_t SrsBasicRtmpClient::connect()