Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sync base repo #2

Merged
merged 6 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
* **[misc]** if some changes were done and bugs were fixed.

* Ensure that your codes conform to code conventions:
* All files are prefixed by 'ngx_'.
* All files are prefixed by 'ngx\_'.
* Include #ifndef \_FILE\_NAME\_H\_INCLUDED\_, #define \_FILE\_NAME\_H\_INCLUDED\_ and #endif in header files.
* Comments use /* ... */ are preferable.
* It would be better that built-in types appear before customized types.
* There should be no less than 2 spaces between types and variables.
* Variables are aligned by character, not '*'.
* Variables are aligned by character, not '\*'.
* No more than 80 characters in a single code or comment line.
* Two blank lines between two functions, styles of macro and type definitions are same as functions.

Expand Down
2 changes: 0 additions & 2 deletions ngx_rtmp.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,6 @@ typedef struct {

ngx_buf_t **free;
ngx_int_t nfree;

unsigned proxy_protocol:1;
} ngx_rtmp_connection_t;


Expand Down
66 changes: 45 additions & 21 deletions ngx_rtmp_auto_push_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ ngx_rtmp_auto_push_init_process(ngx_cycle_t *cycle)
struct sockaddr_un *saun;
#if (nginx_version >= 1009011)
ngx_event_t *rev;
ngx_connection_t *c, *old;
ngx_connection_t *c;
ngx_module_t **modules;
ngx_int_t i, auto_push_index, event_core_index;
#endif
Expand Down Expand Up @@ -310,26 +310,6 @@ ngx_rtmp_auto_push_init_process(ngx_cycle_t *cycle)
rev->deferred_accept = ls->deferred_accept;
#endif

if (!(ngx_event_flags & NGX_USE_IOCP_EVENT)) {
if (ls->previous) {

/*
* delete the old accept events that were bound to
* the old cycle read events array
*/

old = ls->previous->connection;

if (ngx_del_event(old->read, NGX_READ_EVENT, NGX_CLOSE_EVENT)
== NGX_ERROR)
{
return NGX_ERROR;
}

old->fd = (ngx_socket_t) -1;
}
}

#if (nginx_version >= 1009013)
rev->handler = (c->type == SOCK_STREAM) ? ngx_event_accept
: ngx_event_recvmsg;
Expand Down Expand Up @@ -369,11 +349,55 @@ ngx_rtmp_auto_push_exit_process(ngx_cycle_t *cycle)
ngx_rtmp_auto_push_conf_t *apcf;
u_char path[NGX_MAX_PATH];

ngx_listening_t *ls;
ngx_connection_t *c;
size_t n;

apcf = (ngx_rtmp_auto_push_conf_t *) ngx_get_conf(cycle->conf_ctx,
ngx_rtmp_auto_push_module);
if (apcf->auto_push == 0) {
return;
}

ls = cycle->listening.elts;

for (n = 0; n < cycle->listening.nelts; ++n, ++ls) {
if ((ls->handler == ngx_rtmp_init_connection) &&
(ls->sockaddr && ls->sockaddr->sa_family == AF_UNIX))
{
c = ls->connection;

if (c) {
if (c->read->active) {
if (!(ngx_event_flags & NGX_USE_IOCP_EVENT)) {

/*
* delete the old accept events that were bound to
* the old cycle read events array
*/

ngx_del_event(c->read,
NGX_READ_EVENT, NGX_CLOSE_EVENT);

ngx_free_connection(c);

c->fd = (ngx_socket_t) -1;
}
}
}

if (ngx_close_socket(ls->fd) == -1) {
ngx_log_error(NGX_LOG_ERR, cycle->log, ngx_socket_errno,
ngx_close_socket_n "%V failed",
&ls->addr_text);
}

ls->fd = (ngx_socket_t) -1;

break;
}
}

*ngx_snprintf(path, sizeof(path),
"%V/" NGX_RTMP_AUTO_PUSH_SOCKNAME ".%i",
&apcf->socket_dir, ngx_process_slot)
Expand Down
1 change: 1 addition & 0 deletions ngx_rtmp_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,7 @@ ngx_rtmp_prepare_message(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,

hsize = hdrsize[fmt];

(void) nbufs;
ngx_log_debug8(NGX_LOG_DEBUG_RTMP, s->connection->log, 0,
"RTMP prep %s (%d) fmt=%d csid=%uD timestamp=%uD "
"mlen=%uD msid=%uD nbufs=%d",
Expand Down
2 changes: 1 addition & 1 deletion ngx_rtmp_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ ngx_rtmp_init_connection(ngx_connection_t *c)

s->auto_pushed = unix_socket;

if (rconn->proxy_protocol) {
if (rconn->addr_conf->proxy_protocol) {
ngx_rtmp_proxy_protocol(s);

} else {
Expand Down
5 changes: 5 additions & 0 deletions ngx_rtmp_mp4_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,13 @@ typedef struct {
} ngx_rtmp_mp4_ctx_t;


#if (NGX_HAVE_LITTLE_ENDIAN)
#define ngx_rtmp_mp4_make_tag(a, b, c, d) \
((uint32_t)d << 24 | (uint32_t)c << 16 | (uint32_t)b << 8 | (uint32_t)a)
#else
#define ngx_rtmp_mp4_make_tag(a, b, c, d) \
((uint32_t)a << 24 | (uint32_t)b << 16 | (uint32_t)c << 8 | (uint32_t)d)
#endif


static ngx_inline uint32_t
Expand Down
28 changes: 28 additions & 0 deletions ngx_rtmp_receive.c
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,8 @@ ngx_rtmp_amf_message_handler(ngx_rtmp_session_t *s,
ngx_rtmp_core_main_conf_t *cmcf;
ngx_array_t *ch;
ngx_rtmp_handler_pt *ph;
ngx_chain_t *cl;
ngx_int_t amf_len;
size_t len, n;

static u_char func[128];
Expand Down Expand Up @@ -393,6 +395,32 @@ ngx_rtmp_amf_message_handler(ngx_rtmp_session_t *s,

cmcf = ngx_rtmp_get_module_main_conf(s, ngx_rtmp_core_module);

/*
* work around the buggy option `-map` in FFmpeg, see:
* https://trac.ffmpeg.org/ticket/10565
*/
if (in->buf->pos[0] == NGX_RTMP_AMF_NUMBER) {
cl = in;
amf_len = 0;

while (cl) {
amf_len += cl->buf->last - cl->buf->pos;
/* type: 1B, number payload: 8B */
if (amf_len >= 9) {
break;
}

cl = cl->next;
}

if (amf_len < 9) {
ngx_log_error(NGX_LOG_WARN, s->connection->log, 0,
"AMF malformed: type=%d, length=%D, ignored",
NGX_RTMP_AMF_NUMBER, amf_len);
return NGX_OK;
}
}

/* read AMF func name & transaction id */
ngx_memzero(&act, sizeof(act));
act.link = in;
Expand Down