From 8f5ad8c45c7ae54cd9ae782c54fa08195e5a83c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Ancher?= Date: Mon, 5 Oct 2020 10:23:56 +0200 Subject: [PATCH 1/6] Fix compilation under Windows/MinGW64 --- ngx_rtmp.h | 6 +++--- ngx_rtmp_auto_push_module.c | 3 ++- ngx_rtmp_eval.c | 1 + ngx_rtmp_exec_module.c | 2 ++ ngx_rtmp_mp4_module.c | 4 ++-- ngx_rtmp_record_module.c | 8 ++++---- 6 files changed, 14 insertions(+), 10 deletions(-) diff --git a/ngx_rtmp.h b/ngx_rtmp.h index cbe6a93e3..f59aa3239 100644 --- a/ngx_rtmp.h +++ b/ngx_rtmp.h @@ -18,7 +18,7 @@ #include "ngx_rtmp_bandwidth.h" -#if (NGX_WIN32) +#if (NGX_WIN32) && !defined(__int8) typedef __int8 int8_t; typedef unsigned __int8 uint8_t; #endif @@ -182,7 +182,7 @@ typedef struct { /* disable zero-sized array warning by msvc */ -#if (NGX_WIN32) +#if (NGX_WIN32) && (_MSC_VER) #pragma warning(push) #pragma warning(disable:4200) #endif @@ -271,7 +271,7 @@ typedef struct { } ngx_rtmp_session_t; -#if (NGX_WIN32) +#if (NGX_WIN32) && (_MSC_VER) #pragma warning(pop) #endif diff --git a/ngx_rtmp_auto_push_module.c b/ngx_rtmp_auto_push_module.c index 60c85d77b..ba84efa4e 100644 --- a/ngx_rtmp_auto_push_module.c +++ b/ngx_rtmp_auto_push_module.c @@ -10,9 +10,10 @@ #include "ngx_rtmp_relay_module.h" +#if !(NGX_WIN32) static ngx_rtmp_publish_pt next_publish; static ngx_rtmp_delete_stream_pt next_delete_stream; - +#endif static ngx_int_t ngx_rtmp_auto_push_init_process(ngx_cycle_t *cycle); static void ngx_rtmp_auto_push_exit_process(ngx_cycle_t *cycle); diff --git a/ngx_rtmp_eval.c b/ngx_rtmp_eval.c index 1e5195a90..c658f14ef 100644 --- a/ngx_rtmp_eval.c +++ b/ngx_rtmp_eval.c @@ -166,6 +166,7 @@ ngx_rtmp_eval(void *ctx, ngx_str_t *in, ngx_rtmp_eval_t **e, ngx_str_t *out, state = ESCAPE; continue; } + /* fall through */ case ESCAPE: ngx_rtmp_eval_append(&b, &c, 1, log); diff --git a/ngx_rtmp_exec_module.c b/ngx_rtmp_exec_module.c index fccd4ba70..541300523 100644 --- a/ngx_rtmp_exec_module.c +++ b/ngx_rtmp_exec_module.c @@ -284,6 +284,7 @@ ngx_module_t ngx_rtmp_exec_module = { }; +#if !(NGX_WIN32) static void ngx_rtmp_exec_eval_ctx_cstr(void *sctx, ngx_rtmp_eval_t *e, ngx_str_t *ret) { @@ -406,6 +407,7 @@ static ngx_rtmp_eval_t * ngx_rtmp_exec_event_eval[] = { ngx_rtmp_exec_event_specific_eval, NULL }; +#endif static void * diff --git a/ngx_rtmp_mp4_module.c b/ngx_rtmp_mp4_module.c index 0259ca2f6..f00204977 100644 --- a/ngx_rtmp_mp4_module.c +++ b/ngx_rtmp_mp4_module.c @@ -32,7 +32,7 @@ static ngx_int_t ngx_rtmp_mp4_reset(ngx_rtmp_session_t *s); /* disable zero-sized array warning by msvc */ -#if (NGX_WIN32) +#if (NGX_WIN32) && (_MSC_VER) #pragma warning(push) #pragma warning(disable:4200) #endif @@ -115,7 +115,7 @@ typedef struct { } ngx_rtmp_mp4_offsets64_t; -#if (NGX_WIN32) +#if (NGX_WIN32) && (_MSC_VER) #pragma warning(pop) #endif diff --git a/ngx_rtmp_record_module.c b/ngx_rtmp_record_module.c index dc2de12c4..4e2cebb99 100644 --- a/ngx_rtmp_record_module.c +++ b/ngx_rtmp_record_module.c @@ -510,12 +510,12 @@ ngx_rtmp_record_node_open(ngx_rtmp_session_t *s, #if (NGX_WIN32) { LONG lo, hi; - + DWORD ret; lo = 0; hi = 0; - lo = SetFilePointer(rctx->file.fd, lo, &hi, FILE_END); - file_size = (lo == INVALID_SET_FILE_POINTER ? - (off_t) -1 : (off_t) hi << 32 | (off_t) lo); + ret = SetFilePointer(rctx->file.fd, lo, &hi, FILE_END); + file_size = (ret == INVALID_SET_FILE_POINTER ? + (off_t) -1 : (off_t) hi << 32 | (off_t) ret); } #else file_size = lseek(rctx->file.fd, 0, SEEK_END); From 6797c612bd834ffbf31b376a31768b401861af45 Mon Sep 17 00:00:00 2001 From: Elijah Date: Sat, 5 Feb 2022 13:18:31 -0500 Subject: [PATCH 2/6] add CI and support files for builds --- .github/workflows/build.yml | 139 ++++++++++++++++++++++++++++++++++++ support/index.html | 24 +++++++ support/nginx.conf | 131 +++++++++++++++++++++++++++++++++ 3 files changed, 294 insertions(+) create mode 100644 .github/workflows/build.yml create mode 100644 support/index.html create mode 100644 support/nginx.conf diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..3d77f03d2 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,139 @@ +name: Build +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + workflow_dispatch: + release: + types: [published] +jobs: + build-linux: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2.4.0 + with: + path: nginx-rtmp-module + - name: Prepare build environment + run: | + cd ~ + sudo apt-get install gcc make mercurial git wget + hg clone http://hg.nginx.org/nginx + git clone -b OpenSSL_1_1_1-stable https://github.com/openssl/openssl.git + wget https://sourceforge.net/projects/pcre/files/pcre/8.45/pcre-8.45.zip/download -O pcre.zip + unzip pcre.zip + wget https://www.zlib.net/zlib-1.2.11.tar.gz -O zlib.tgz + tar xzf zlib.tgz + mv $GITHUB_WORKSPACE/nginx-rtmp-module ~ + cd nginx + rm conf/nginx.conf + cp ~/nginx-rtmp-module/support/nginx.conf conf/nginx.conf + rm docs/html/index.html + cp ~/nginx-rtmp-module/support/index.html docs/html/index.html + auto/configure --prefix=. --add-module=../nginx-rtmp-module --with-openssl=../openssl --with-zlib=../zlib-1.2.11 --with-pcre=../pcre-8.45 + - name: Build nginx + run: | + cd ~/nginx + make -j2 + - name: Move build files to directory + run: | + cd ~/nginx + mkdir build + mkdir build/logs + touch build/logs/error.log + touch build/logs/access.log + mkdir build/sbin + cp objs/nginx build/sbin/ + cp -r conf build/ + cp -r docs/html build/ + - name: Upload artifact + uses: actions/upload-artifact@v2 + with: + name: build-linux + path: /home/runner/nginx/build/ + - name: Create archive + run: | + cd ~/nginx + tar -czf nginx-with-rtmp-linux.tar.gz build + - name: Upload release + if: ${{ github.event_name == 'release' }} + uses: alexellis/upload-assets@0.2.2 + env: + GITHUB_TOKEN: ${{ github.token }} + with: + asset_paths: '["/home/runner/nginx/nginx-with-rtmp-linux.tar.gz"]' + build-windows: + runs-on: windows-latest + steps: + - uses: actions/checkout@v2.4.0 + with: + path: nginx-rtmp-module + - uses: actions/checkout@v2.4.0 + with: + repository: openssl/openssl + ref: OpenSSL_1_1_1-stable + path: openssl + - uses: ilammy/msvc-dev-cmd@v1 + with: + arch: amd64_x86 + - uses: ilammy/setup-nasm@v1.2.1 + - uses: shogo82148/actions-setup-perl@v1 + with: + distribution: strawberry + - name: Prepare build environment + shell: bash + run: | + cd ~ + rm /usr/bin/perl.exe /usr/bin/link.exe + chocolatey install wget unzip zip + hg clone http://hg.nginx.org/nginx + mv $GITHUB_WORKSPACE/openssl ~ + mv $GITHUB_WORKSPACE/nginx-rtmp-module ~ + wget https://sourceforge.net/projects/pcre/files/pcre/8.45/pcre-8.45.zip/download -O pcre.zip + unzip pcre.zip + wget https://www.zlib.net/zlib-1.2.11.tar.gz -O zlib.tgz + tar xzf zlib.tgz + cd nginx + rm conf/nginx.conf + cp ~/nginx-rtmp-module/support/nginx.conf conf/nginx.conf + rm docs/html/index.html + cp ~/nginx-rtmp-module/support/index.html docs/html/index.html + sed -i 's/-WX/ /' auto/cc/msvc + auto/configure --prefix=. --add-module=../nginx-rtmp-module --with-openssl=../openssl --with-zlib=../zlib-1.2.11 --with-pcre=../pcre-8.45 --with-cc=cl + pwd + - name: Build nginx + shell: bash + run: | + cd ~/nginx + set CL=/MP + nmake + - name: Move build files to directory + shell: bash + run: | + cd ~/nginx + mkdir build + mkdir build/logs + touch build/logs/error.log + touch build/logs/access.log + mkdir build/sbin + cp objs/nginx.exe build/sbin/ + cp -r conf build/ + cp -r docs/html build/ + - name: Upload artifact + uses: actions/upload-artifact@v2 + with: + name: build-win32 + path: C:\Users\runneradmin\nginx\build + - name: Create archive + shell: bash + run: | + cd ~/nginx + zip -r nginx-with-rtmp-win32.zip build + - name: Upload release + if: ${{ github.event_name == 'release' }} + uses: alexellis/upload-assets@0.2.2 + env: + GITHUB_TOKEN: ${{ github.token }} + with: + asset_paths: '["C:\Users\runneradmin\nginx\nginx-with-rtmp-win32.zip"]' diff --git a/support/index.html b/support/index.html new file mode 100644 index 000000000..968adefac --- /dev/null +++ b/support/index.html @@ -0,0 +1,24 @@ + + + +Welcome to nginx! + + + +

Welcome to nginx!

+

If you see this page, the nginx web server is successfully installed and +working. Further configuration is required.

+ +

For online documentation and support please refer to +nginx.org.
+Commercial support is available at +nginx.com.

+

The RTMP module is also installed. For usage information you can check the wiki, which contains both a basic tutorial and a comprehensive guide to all the available directives.

+ +

Thank you for using nginx.

+ + diff --git a/support/nginx.conf b/support/nginx.conf new file mode 100644 index 000000000..58522b1c0 --- /dev/null +++ b/support/nginx.conf @@ -0,0 +1,131 @@ + +#user nobody; +worker_processes 1; + +#error_log logs/error.log; +#error_log logs/error.log notice; +#error_log logs/error.log info; + +#pid logs/nginx.pid; + + +events { + worker_connections 1024; +} + + +http { + include mime.types; + default_type application/octet-stream; + + #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + # '$status $body_bytes_sent "$http_referer" ' + # '"$http_user_agent" "$http_x_forwarded_for"'; + + #access_log logs/access.log main; + + sendfile on; + #tcp_nopush on; + + #keepalive_timeout 0; + keepalive_timeout 65; + + #gzip on; + + server { + listen 80; + server_name localhost; + + #charset koi8-r; + + #access_log logs/host.access.log main; + + location / { + root html; + index index.html index.htm; + } + + #error_page 404 /404.html; + + # redirect server error pages to the static page /50x.html + # + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root html; + } + + # proxy the PHP scripts to Apache listening on 127.0.0.1:80 + # + #location ~ \.php$ { + # proxy_pass http://127.0.0.1; + #} + + # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 + # + #location ~ \.php$ { + # root html; + # fastcgi_pass 127.0.0.1:9000; + # fastcgi_index index.php; + # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; + # include fastcgi_params; + #} + + # deny access to .htaccess files, if Apache's document root + # concurs with nginx's one + # + #location ~ /\.ht { + # deny all; + #} + } + + + # another virtual host using mix of IP-, name-, and port-based configuration + # + #server { + # listen 8000; + # listen somename:8080; + # server_name somename alias another.alias; + + # location / { + # root html; + # index index.html index.htm; + # } + #} + + + # HTTPS server + # + #server { + # listen 443 ssl; + # server_name localhost; + + # ssl_certificate cert.pem; + # ssl_certificate_key cert.key; + + # ssl_session_cache shared:SSL:1m; + # ssl_session_timeout 5m; + + # ssl_ciphers HIGH:!aNULL:!MD5; + # ssl_prefer_server_ciphers on; + + # location / { + # root html; + # index index.html index.htm; + # } + #} + +} + +# Very simple RTMP server +rtmp { + server { + listen 1935; + application stream { + live on; + #hls on; + #hls_path /hls/; + #hls_fragment 3; + #hls_playlist_length 60; + } + } +} From ccc5b0edac74c0da4e4d4a18dddd3649d4255946 Mon Sep 17 00:00:00 2001 From: Elijah R <62162399+elijahr2411@users.noreply.github.com> Date: Sat, 5 Feb 2022 13:55:09 -0500 Subject: [PATCH 3/6] Update build.yml --- .github/workflows/build.yml | 76 ++++++++++++++++++++++++------------- 1 file changed, 50 insertions(+), 26 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3d77f03d2..3994b3fd8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,16 +11,22 @@ jobs: build-linux: runs-on: ubuntu-latest steps: - - name: Checkout + - name: Clone nginx-rtmp-module uses: actions/checkout@v2.4.0 with: path: nginx-rtmp-module + - name: Clone OpenSSL + uses: actions/checkout@v2.4.0 + with: + repository: openssl/openssl + ref: OpenSSL_1_1_1-stable + path: openssl - name: Prepare build environment run: | cd ~ sudo apt-get install gcc make mercurial git wget hg clone http://hg.nginx.org/nginx - git clone -b OpenSSL_1_1_1-stable https://github.com/openssl/openssl.git + mv $GITHUB_WORKSPACE/openssl ~ wget https://sourceforge.net/projects/pcre/files/pcre/8.45/pcre-8.45.zip/download -O pcre.zip unzip pcre.zip wget https://www.zlib.net/zlib-1.2.11.tar.gz -O zlib.tgz @@ -47,38 +53,36 @@ jobs: cp objs/nginx build/sbin/ cp -r conf build/ cp -r docs/html build/ + - name: Create archive + run: | + cd ~/nginx/build + tar -czf nginx-with-rtmp-linux.tar.gz * - name: Upload artifact uses: actions/upload-artifact@v2 with: name: build-linux - path: /home/runner/nginx/build/ - - name: Create archive - run: | - cd ~/nginx - tar -czf nginx-with-rtmp-linux.tar.gz build - - name: Upload release - if: ${{ github.event_name == 'release' }} - uses: alexellis/upload-assets@0.2.2 - env: - GITHUB_TOKEN: ${{ github.token }} - with: - asset_paths: '["/home/runner/nginx/nginx-with-rtmp-linux.tar.gz"]' + path: /home/runner/nginx/build/nginx-with-rtmp-linux.tar.gz build-windows: runs-on: windows-latest steps: - uses: actions/checkout@v2.4.0 + name: Clone nginx-rtmp-module with: path: nginx-rtmp-module - uses: actions/checkout@v2.4.0 + name: Clone OpenSSL with: repository: openssl/openssl ref: OpenSSL_1_1_1-stable path: openssl - uses: ilammy/msvc-dev-cmd@v1 + name: Setup msbuild environment with: arch: amd64_x86 - uses: ilammy/setup-nasm@v1.2.1 + name: Install NASM - uses: shogo82148/actions-setup-perl@v1 + name: Install PERL with: distribution: strawberry - name: Prepare build environment @@ -120,20 +124,40 @@ jobs: cp objs/nginx.exe build/sbin/ cp -r conf build/ cp -r docs/html build/ + - name: Generate zip artifact + shell: bash + run: | + cd ~/nginx/build + zip -r nginx-with-rtmp-win32.zip * - name: Upload artifact uses: actions/upload-artifact@v2 with: name: build-win32 - path: C:\Users\runneradmin\nginx\build - - name: Create archive - shell: bash - run: | - cd ~/nginx - zip -r nginx-with-rtmp-win32.zip build - - name: Upload release - if: ${{ github.event_name == 'release' }} - uses: alexellis/upload-assets@0.2.2 - env: + path: C:\Users\runneradmin\nginx\build\nginx-with-rtmp-win32.zip + create-release: + needs: [build-windows, build-linux] + if: ${{ github.action == 'release' }} + runs-on: ubuntu-latest + steps: + - name: Download Windows artifact + uses: actions/download-artifact@v2.1.0 + with: + name: build-win32 + path: /home/runner/ + - name: Download Linux artifact + uses: actions/download-artifact@v2.1.0 + with: + name: build-linux + path: /home/runner/ + - name: Upload linux release + uses: alexellis/upload-assets@0.2.2 + env: GITHUB_TOKEN: ${{ github.token }} - with: - asset_paths: '["C:\Users\runneradmin\nginx\nginx-with-rtmp-win32.zip"]' + with: + asset_paths: '["/home/runner/nginx/nginx-with-rtmp-linux.tar.gz"]' + - name: Upload windows release + uses: alexellis/upload-assets@0.2.2 + env: + GITHUB_TOKEN: ${{ github.token }} + with: + asset_paths: '["/home/runner/nginx/nginx-with-rtmp-win32.zip"]' From 3a919fbf15a29336316f83f31b10df095962a127 Mon Sep 17 00:00:00 2001 From: Elijah R <62162399+elijahr2411@users.noreply.github.com> Date: Sat, 5 Feb 2022 14:18:09 -0500 Subject: [PATCH 4/6] Update build.yml --- .github/workflows/build.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3994b3fd8..56e6935c5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -105,12 +105,10 @@ jobs: cp ~/nginx-rtmp-module/support/index.html docs/html/index.html sed -i 's/-WX/ /' auto/cc/msvc auto/configure --prefix=. --add-module=../nginx-rtmp-module --with-openssl=../openssl --with-zlib=../zlib-1.2.11 --with-pcre=../pcre-8.45 --with-cc=cl - pwd - name: Build nginx shell: bash run: | cd ~/nginx - set CL=/MP nmake - name: Move build files to directory shell: bash @@ -136,7 +134,7 @@ jobs: path: C:\Users\runneradmin\nginx\build\nginx-with-rtmp-win32.zip create-release: needs: [build-windows, build-linux] - if: ${{ github.action == 'release' }} + if: ${{ github.event_name == 'release' }} runs-on: ubuntu-latest steps: - name: Download Windows artifact From b24bb710ddbea4290eb979efd4e9813831962906 Mon Sep 17 00:00:00 2001 From: Elijah R <62162399+elijahr2411@users.noreply.github.com> Date: Sat, 5 Feb 2022 14:32:47 -0500 Subject: [PATCH 5/6] Update build.yml --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 56e6935c5..b43c9091e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -147,6 +147,7 @@ jobs: with: name: build-linux path: /home/runner/ + - run: ls -R ~ - name: Upload linux release uses: alexellis/upload-assets@0.2.2 env: From c9dd593c6504b7841905e5ef248c41665daed45f Mon Sep 17 00:00:00 2001 From: Elijah R <62162399+elijahr2411@users.noreply.github.com> Date: Sat, 5 Feb 2022 14:47:17 -0500 Subject: [PATCH 6/6] Update build.yml --- .github/workflows/build.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b43c9091e..825d44c73 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -147,16 +147,15 @@ jobs: with: name: build-linux path: /home/runner/ - - run: ls -R ~ - name: Upload linux release uses: alexellis/upload-assets@0.2.2 env: GITHUB_TOKEN: ${{ github.token }} with: - asset_paths: '["/home/runner/nginx/nginx-with-rtmp-linux.tar.gz"]' + asset_paths: '["/home/runner/nginx-with-rtmp-linux.tar.gz"]' - name: Upload windows release uses: alexellis/upload-assets@0.2.2 env: GITHUB_TOKEN: ${{ github.token }} with: - asset_paths: '["/home/runner/nginx/nginx-with-rtmp-win32.zip"]' + asset_paths: '["/home/runner/nginx-with-rtmp-win32.zip"]'