diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..825d44c73 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,161 @@ +name: Build +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + workflow_dispatch: + release: + types: [published] +jobs: + build-linux: + runs-on: ubuntu-latest + steps: + - 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 + 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 + 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: 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/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 + 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 + - name: Build nginx + shell: bash + run: | + cd ~/nginx + 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: 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\nginx-with-rtmp-win32.zip + create-release: + needs: [build-windows, build-linux] + if: ${{ github.event_name == '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: '["/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-with-rtmp-win32.zip"]' 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 a92a86318..8dd35960a 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 */ /* fall through */ 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); 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; + } + } +}